# Anatomy

Charts are made of several components grouped together. The structure is built with a simple HTML <table> element. The different components are styled using CSS classes which are defined for the parent element but affect inner HTML elements.

# Chart Layers

The following animation shows how the various elements are separated into layers:

 
 
 
 
 
 
 
 
 
 
 
 
 
2016
2017
2018
2019
2020
Chart Heading
 
 
 
 
 
Open in:

As was previously mentioned, the layers are composed of different HTML elements nested inside the <table> element.

# Chart Structure

With the help of CSS classes, the HTML table displayed as a chart. These utility classes change the appearance of the table by applying styles on various inner HTML elements.

To transform the <table> into a chart, only two inner HTML elements are required, the <tbody> and <td> elements, without them, nothing works. The other elements are optional. However, we recommend using all the elements, including <caption>, <thead>, and <th>, as they provide more clarity for search-engines and screen-reader users.

# HTML Table

The following table, for example, provides meaningful information like a heading, labels and data. With semantic markup the information visible to search-engines and screen readers.

<table class="charts-css column show-heading show-labels show-primary-axis show-4-secondary-axes show-data-axes data-spacing-15 hide-data">

  <caption> Chart Heading </caption>

  <thead>
    <tr>
      <th scope="col"> Year </th>
      <th scope="col"> Value </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <th> 2016 </th>
      <td style="--size: calc( 20 / 100 );"> 20 </td>
    </tr>
    <tr>
      <th> 2017 </th>
      <td style="--size: calc( 40 / 100 );"> 40 </td>
    </tr>
    <tr>
      <th> 2018 </th>
      <td style="--size: calc( 60 / 100 );"> 60 </td>
    </tr>
    <tr>
      <th> 2019 </th>
      <td style="--size: calc( 80 / 100 );"> 80 </td>
    </tr>
    <tr>
      <th> 2020 </th>
      <td style="--size: calc( 100 / 100 );"> 100 </td>
    </tr>
  </tbody>

</table>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

# Chart View

With the help of CSS classes, the user will see the following chart:

Chart Heading
Year Value
2016 20
2017 40
2018 60
2019 80
2020 100
Open in:

# Table View

When removing the CSS classes, the style will be removed and the user will see a regular table:

Chart Heading
Year Value
2016 20
2017 40
2018 60
2019 80
2020 100