Bar Chart 📊
The most minimal bar chart consists of <tbody> inside a <table class="picospa-chart bar">.
Any <tr> with a <td> inside will become a bar.
Feature Set
- Bars are the main elements of this chart, are the rows inside
<tbody>- one
<tbody>is one group of bars that can be styled together
- one
- Caption will be shown above the chart, it's the content inside
<cpation> - X-Axis Label the labels shown below the chart, they are the rows inside
<tfoot> Y-Axis Labelnot yet- Grid Lines the lines aligned with the labels
Minimal Bar Chart
| Ten | 75 |
|---|---|
| Ten | 100 |
| Nine | 90 |
| Eight | 50 |
| 0 | |
| 25% | |
| 50% | |
| 75% | |
| 100% |
This bar chart features already a couple of things:
<table class="picospa-chart bar">- the classes define that this is a chart and the type, a "bar"
- by default each chart expands to 100% of the available width the parent allows
- Grid Lines –
style="--picochart-grid-line: 0.1px solid yellow"--picochart-grid-lineis a CSS variable where you can define what the grid lines look like, this is a border-style definition- if you do not define
--picochart-grid-linethere are not grid lines - if you define
--picochart-grid-lineonly on the<tfoot>you have only horizontal grid lines - if you define
--picochart-grid-lineonly on the<tbody>you have only vertical grid lines - if you define
--picochart-grid-lineon the<table>you have both grid lines - vertical grid line shows only when the
<tr>inside the<tfoot>has a<th></th>
- Caption –
<caption>Minimal Bar Chart</caption>- Every bar may have an optional caption above the chart
- Table Height –
<tbody style="height: 5em;">- a
<tbody>contains a group of data, given by multiple<tr>s - the
heightis adhered and the main tool for sizing
- a
- The X-Axis –
<tfoot>- all
<tr>s inside are labels that show at the bottom of the chart
- all
The complete code looks like this;
<table class="picospa-chart bar" style="--picochart-grid-line: 0.1px solid yellow">
<caption>Minimal Bar Chart</caption>
<tbody style="height: 5em;">
<tr><th>Ten</th><td style="--percent: 75%">75</td></tr>
<tr><th>Ten</th><td style="--percent: 100%">100</td></tr>
<tr><th>Nine</th><td style="--percent: 90%">90</td></tr>
<tr><th>Eight</th><td style="--percent: 50%">50</td></tr>
</tbody>
<tfoot>
<tr><th></th><td>0</td></tr>
<tr><th></th><td>25%</td></tr>
<tr><th></th><td>50%</td></tr>
<tr><th></th><td>75%</td></tr>
<tr><th></th><td>100%</td></tr>
</tfoot>
</table>
Full Featured Bar Chart
The bar chart below has:
- a caption
- multiple tbodys
- colgroup
- x- and y-axis
- colored bars
- different grid lines for x and y
- 5 labels, but only 3 grid lines
| Ten | 10 |
|---|---|
| Nine | 9 |
| Eight | 8 |
| Seven | 7 |
| Six | 6 |
| Five | 5 |
| Four | 4 |
| Three | 3 |
| One | 1 |
| Two | 2 |
| 0 | |
| 2.5 | |
| 5 | |
| 7.5 | |
| 10 |