Please don't forget to read Usage part of each element.
Chart
Comparing different values that are hierarchically equivalent. Each bar is mapped to a dimension value with a length determined by a metric.
Overview
Chart is a type of columns graph that is used to compare values and show trends over time. In a billing context for example, a columns chart allows the user to grab rapidly his billing information, make comparisons and track his billing trends.
Stacked columns charts are useful for showing group relationships and value differences across more complex categories and subcategories. Stacked column charts can also be used to show group relationships within subsets of ordinal data. They plot the relative value that each data series contributes to the total.
Multi columns by axe Y
Multi columns by axe Y allows the user to compare multiple columns within the same period.
Hover/Focused state
State visible when the cursor hovers one column and triggered by keyboard navigation or click. The hovered/triggered column keeps the default state and the opacity of the others columns decreases. Cursor becomes a pointer.
The popover message reveals more detailed information or context for specific each column of the chart. The popover should repeat the corresponding values of the data point on both axes and any other relevant details.
Anatomy
Avoid filling the chart frame with too many elements, as it impacts the user’s ability to interpret the data.
- Column
- Positive values
- Negative values
-
Chart frame
The chart frame is the area where the data will be visualized -
Ticks
Help the reader understand the proportions and scale of the data, the indicators involved, and their unit of measure -
Axes
Help the reader understand the proportions and scale of the data, the indicators involved, and their unit of measure. The numerical axis should start at zero. -
Interaction info
Helps the user to understand how to interact with the chart. Mandatory for accessibility reason. -
Legends
The Legends explain the chart’s meaning by defining the association of each color property to the corresponding data.
Legends
Legends summarize the distinguishing visual properties such as colors in the chart. A legend helps the user build the necessary associations to make sense of the chart. The legends are positioned at the bottom of a chart by default.
Your chart doesn’t need a legend if it only presents one data category. Only use a legend for represent categories.
Les légendes des graphiques utilisent la couleur comme propriété distinctive par défaut pour les ensembles de données et les valeurs. Ce type de différenciation pourrait ne pas être suffisant pour les utilisateurs souffrant de déficience visuelle, mais comme les informations sont disponibles au survol/clic (catégorie de légende + valeur), nous assurons l'accessibilité des informations pour ces utilisateurs également.
Sizes and colors
Everything is loaded by the JavaScript. This box is only for your information
- <caption>
must have a
show-for-sr
class. It also must be filled by the name of the graph; - <thead>
must have an
aria-hidden="true"
; - <button>
inside <td>
must have an
aria-label
with the name of the column + the total in euro of the column separated by a comma; - div.rs-chart-labels
must have an
aria-hidden="true"
.
Chart is a webcomponent which needs data-rslib-webcomponent-load="rslib.apps.chart" attribute to work.
Use data-rslib-chart attribute to pass data to make your graph dynamic.
You have two ways to put data info: multiple arrays or one object which each bar.
Parameters
Parameters inside data-rslib-chart are set like a JSON.
Element name | Type | Value example | Infos |
---|---|---|---|
chartTitle | object | 'en': 'Billing', 'fr': 'Facture', 'nl': 'Billing', 'de': 'Billing' |
Object with string for each language. This is mandatory. |
unit | string | € | Unity of axe Y. This is the default value. |
legend | object | 'green': { 'key': 'refund', 'en': 'Refund', 'fr': 'Remboursement', 'nl': 'Terugbetaling', 'de': 'Rückerstattung' }, ... |
Object that content legend per color, with key linked to data and string for each language. If you set nothing, see translation chapter that show default values. To change one value, you have to set all necessary/used legend. |
xAxesLabel | object | 'keyName': { 'en': 'Name for EN', 'fr': 'Name for FR', 'nl': 'Name for NL', 'de': 'Name for DE' }, ... |
Object that content axe X label, with key linked to data and string for each language. You have to set all necessary/used Axe X labels. |
chartData | Array | { 'name': '#1269562', 'date': '2020-09-03', 'data': { 'refund': -60.99 }, 'totalAmount': 999.99, 'xAxisKey': 9 } |
Array that content all bars.
|
Translations
Only one copy to set for all translations? You could use
Legend
You could choose your own
Axe X naming
By default, you don't have to set this value. Put a number as key that correspond to a month: 1 for January, 2 for February, etc.
If you need custom one, have fun. Set wanted keys with its translations and use it on data.
Noticed that:
- on mobile, you will see maximum 6 axes X
- on desktop, maximum 12
- only 3 characters are displayed
Other copies
All those copies are automatic. You don't need to set them if default correspond to your case.
Default graph
Put a spinner inside rs-chart
div is mandatory for the accessibility. See spinner article for more details.
To have the Chart, put a <div>
with the class rs-chart
. Put the attributes data-rslib-webcomponent-load="rslib.apps.chart"
and data-invoke="Chart.init"
to make it works.
Multi bars by axe Y
Graph inside small gridding
For space reason, the graph can't be inside a smaller gridding than medium-7
if you display 12 column on medium up.
Empty / Error state
JavaScript
As Chart is a webcomponent, you will have to load
CONTEXT refers to document or html element parent.