Skip to content

Commit 8239ff1

Browse files
authored
Anatomy: Update content (ChartsCSS#35)
1 parent 57c7415 commit 8239ff1

File tree

1 file changed

+59
-48
lines changed

1 file changed

+59
-48
lines changed

src/docs/anatomy.md

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ next: ../../components/
55

66
# Anatomy
77

8-
Charts are made of several [components](../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 applied on inner HTML elements.
8+
Charts are made of several [components](../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.
99

1010
## Chart Layers
1111

@@ -88,23 +88,23 @@ The following animation shows how the various elements are separated into layers
8888
<tbody>
8989
<tr>
9090
<th> </th>
91-
<td style="--size:0;"></td>
91+
<td style="--size: 0;"></td>
9292
</tr>
9393
<tr>
9494
<th> </th>
95-
<td style="--size:0;"></td>
95+
<td style="--size: 0;"></td>
9696
</tr>
9797
<tr>
9898
<th> </th>
99-
<td style="--size:0;"></td>
99+
<td style="--size: 0;"></td>
100100
</tr>
101101
<tr>
102102
<th> </th>
103-
<td style="--size:0;"></td>
103+
<td style="--size: 0;"></td>
104104
</tr>
105105
<tr>
106106
<th> </th>
107-
<td style="--size:0;"></td>
107+
<td style="--size: 0;"></td>
108108
</tr>
109109
</tbody>
110110
</table>
@@ -113,23 +113,23 @@ The following animation shows how the various elements are separated into layers
113113
<tbody>
114114
<tr>
115115
<th> </th>
116-
<td style="--size:0.2;"></td>
116+
<td style="--size: 0.2;"></td>
117117
</tr>
118118
<tr>
119119
<th> </th>
120-
<td style="--size:0.4;"></td>
120+
<td style="--size: 0.4;"></td>
121121
</tr>
122122
<tr>
123123
<th> </th>
124-
<td style="--size:0.6;"></td>
124+
<td style="--size: 0.6;"></td>
125125
</tr>
126126
<tr>
127127
<th> </th>
128-
<td style="--size:0.8;"></td>
128+
<td style="--size: 0.8;"></td>
129129
</tr>
130130
<tr>
131131
<th> </th>
132-
<td style="--size:1;"></td>
132+
<td style="--size: 1;"></td>
133133
</tr>
134134
</tbody>
135135
</table>
@@ -162,13 +162,23 @@ The following animation shows how the various elements are separated into layers
162162

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

165-
For example, the [heading](../components/heading/) layer is created from the `<caption>` element, the data [labels](../components/labels/) are created from the `<th>` element, the [data](../components/data/)/[dataset](../components/datasets/) uses `<td>` elements, and the [axes](../components/axes/) layer is generated from the `<tbody>` elements.
165+
* [Heading layer](../components/heading/) - generated from the `<caption>` element.
166+
* [Labels layer](../components/labels/) - generated from the `<th>` elements.
167+
* [Data layer](../components/data/) - generated from the `<td>` elements.
168+
* [Axes layer](../components/axes/) - generated from the `<tbody>` element.
166169

167-
## HTML Table
170+
## Chart Structure
168171

169-
The raw data is a basic HTML `<table>` element visible to search engines and screen readers:
172+
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.
170173

171-
<table>
174+
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.
175+
176+
### HTML Table
177+
178+
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.
179+
180+
```html
181+
<table class="charts-css column show-heading show-labels show-primary-axis show-4-secondary-axes show-data-axes data-spacing-15 hide-data">
172182

173183
<caption> Chart Heading </caption>
174184

@@ -182,34 +192,43 @@ The raw data is a basic HTML `<table>` element visible to search engines and scr
182192
<tbody>
183193
<tr>
184194
<th> 2016 </th>
185-
<td style="--size:0.2;"> 20 </td>
195+
<td style="--size: calc( 20 / 100 );"> 20 </td>
186196
</tr>
187197
<tr>
188198
<th> 2017 </th>
189-
<td style="--size:0.4;"> 40 </td>
199+
<td style="--size: calc( 40 / 100 );"> 40 </td>
190200
</tr>
191201
<tr>
192202
<th> 2018 </th>
193-
<td style="--size:0.6;"> 60 </td>
203+
<td style="--size: calc( 60 / 100 );"> 60 </td>
194204
</tr>
195205
<tr>
196206
<th> 2019 </th>
197-
<td style="--size:0.8;"> 80 </td>
207+
<td style="--size: calc( 80 / 100 );"> 80 </td>
198208
</tr>
199209
<tr>
200210
<th> 2020 </th>
201-
<td style="--size:1.0;"> 100 </td>
211+
<td style="--size: calc( 100 / 100 );"> 100 </td>
202212
</tr>
203213
</tbody>
204214

205215
</table>
216+
```
206217

207-
## Chart Table
218+
### Chart View
208219

209-
With the use of CSS classes, we can convert the raw data into a chart. These classes change the HTML structure's appearance.
220+
With the help of CSS classes, the user will see the following chart:
210221

211-
```html
212-
<table class="charts-css column show-heading show-labels show-primary-axis show-4-secondary-axes show-data-axes data-spacing-15 hide-data">
222+
<code-example code-example-id="anatomy-simple-chart">
223+
<template v-slot:css-code>
224+
#anatomy-simple-chart {
225+
height: 300px;
226+
max-width: 400px;
227+
margin: 0 auto;
228+
}
229+
</template>
230+
<template v-slot:html-code>
231+
<table class="charts-css column show-heading show-labels show-primary-axis show-4-secondary-axes show-data-axes data-spacing-15 hide-data" id="anatomy-simple-chart">
213232

214233
<caption> Chart Heading </caption>
215234

@@ -223,41 +242,35 @@ With the use of CSS classes, we can convert the raw data into a chart. These cla
223242
<tbody>
224243
<tr>
225244
<th> 2016 </th>
226-
<td style="--size:0.2;"></td>
245+
<td style="--size: calc( 20 / 100 );"> 20 </td>
227246
</tr>
228247
<tr>
229248
<th> 2017 </th>
230-
<td style="--size:0.4;"></td>
249+
<td style="--size: calc( 40 / 100 );"> 40 </td>
231250
</tr>
232251
<tr>
233252
<th> 2018 </th>
234-
<td style="--size:0.6;"></td>
253+
<td style="--size: calc( 60 / 100 );"> 60 </td>
235254
</tr>
236255
<tr>
237256
<th> 2019 </th>
238-
<td style="--size:0.8;"></td>
257+
<td style="--size: calc( 80 / 100 );"> 80 </td>
239258
</tr>
240259
<tr>
241260
<th> 2020 </th>
242-
<td style="--size:1.0;"></td>
261+
<td style="--size: calc( 100 / 100 );"> 100 </td>
243262
</tr>
244263
</tbody>
245264

246265
</table>
247-
```
266+
</template>
267+
</code-example>
248268

249-
The result is a `<table>` element displayed to the user as a chart:
269+
### Table View
250270

251-
<code-example code-example-id="anatomy-simple-chart">
252-
<template v-slot:css-code>
253-
#anatomy-simple-chart {
254-
height: 300px;
255-
max-width: 400px;
256-
margin: 0 auto;
257-
}
258-
</template>
259-
<template v-slot:html-code>
260-
<table class="charts-css column show-heading show-labels show-primary-axis show-4-secondary-axes show-data-axes data-spacing-15 hide-data" id="anatomy-simple-chart">
271+
Removing the CSS classes, the style will be removed and the user will see a regular table:
272+
273+
<table>
261274

262275
<caption> Chart Heading </caption>
263276

@@ -271,26 +284,24 @@ The result is a `<table>` element displayed to the user as a chart:
271284
<tbody>
272285
<tr>
273286
<th> 2016 </th>
274-
<td style="--size:0.2;"> <span class="data"> 20 </span> </td>
287+
<td style="--size: calc( 20 / 100 );"> 20 </td>
275288
</tr>
276289
<tr>
277290
<th> 2017 </th>
278-
<td style="--size:0.4;"> <span class="data"> 40 </span> </td>
291+
<td style="--size: calc( 40 / 100 );"> 40 </td>
279292
</tr>
280293
<tr>
281294
<th> 2018 </th>
282-
<td style="--size:0.6;"> <span class="data"> 60 </span> </td>
295+
<td style="--size: calc( 60 / 100 );"> 60 </td>
283296
</tr>
284297
<tr>
285298
<th> 2019 </th>
286-
<td style="--size:0.8;"> <span class="data"> 80 </span> </td>
299+
<td style="--size: calc( 80 / 100 );"> 80 </td>
287300
</tr>
288301
<tr>
289302
<th> 2020 </th>
290-
<td style="--size:1.0;"> <span class="data"> 100 </span> </td>
303+
<td style="--size: calc( 100 / 100 );"> 100 </td>
291304
</tr>
292305
</tbody>
293306

294307
</table>
295-
</template>
296-
</code-example>

0 commit comments

Comments
 (0)