Skip to content

Commit c7752ba

Browse files
committed
Customization: add wrapper element example
1 parent eac741d commit c7752ba

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

src/customization/README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ next: ./3d-effects
55

66
# Customization
77

8-
One of the key features in **Charts.CSS** is the ability to customize the visibility using basic CSS. Frontend developers can target any HTML element and customize it. This philosophical guideline is what makes the framework so flexible and easy to use.
8+
One of the key features in **Charts.CSS** is the ability to **_customize the visibility using basic CSS_**. Frontend developers can target any HTML element and customize it. This philosophical guideline is what makes the framework so flexible and easy to use.
99

1010
## Custom Styling
1111

12-
To add your custom CSS simply add either an `id` or a `class` to your `<table>` tag.
12+
To add your custom CSS simply add an `id` attribute to the `<table>` tag:
1313

1414
```html
15-
<table class="charts-css ..." id="my-chart">
15+
<table id="my-chart" class="charts-css bar|column|area|line ...">
1616
...
1717
</table>
1818
```
@@ -22,20 +22,43 @@ To add your custom CSS simply add either an `id` or a `class` to your `<table>`
2222
}
2323
```
2424

25-
Recommended best practice is to add the chart type to the selector. This way the style will apply only on that chart type and not the other types. Why? because each chart type has its own structure and layout. You don't want un-expected side-effects when switching between charts.
25+
Or add an `id` attribute to a [wrapper element](/components/wrapper/):
2626

27+
```html
28+
<div id="my-chart">
29+
30+
<table class="charts-css bar|column|area|line multiple ...">
31+
</table>
32+
33+
<ul class="charts-css legend">
34+
</ul>
35+
36+
</div>
37+
```
2738
```css
28-
/* Custom style applies only on bar charts */
39+
#my-chart > table {
40+
...
41+
}
42+
```
43+
44+
### Best Practice
45+
46+
It's recommend to add the chart type to your selector. This way the custom style will apply only on that specific chart type and not all the types.
47+
48+
```css
49+
/* Customize only bar charts */
2950
#my-chart.bar {
3051
...
3152
}
3253

33-
/* Other style applies only on pie charts */
54+
/* Customize only pie charts */
3455
#my-chart.pie {
3556
...
3657
}
3758
```
3859

60+
Why is this important? because each chart type has its own structure and layout. You don't want unexpected side-effects when switching between charts types.
61+
3962
## Basic Examples
4063

4164
There are many ways you can customize the framework. We prepared some basic examples to get you started, separated into 3 topics.

0 commit comments

Comments
 (0)