You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/customization/basic-styling.md
+89-49Lines changed: 89 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,54 +7,6 @@ prev: ../
7
7
8
8
Charts are styled using regular CSS rules. You can apply custom styles on any HTML element or [chart layer](../docs/anatomy/) inside the `<table>` element.
9
9
10
-
## Style Specific Elements
11
-
12
-
To style specific elements, use any method supported by CSS.
13
-
14
-
### CSS Selectors
15
-
16
-
Use CSS `:nth-of-type()` pseudo-class to match the nth data CSS based on the position among siblings.
17
-
18
-
```html
19
-
<tbody>
20
-
<tr>
21
-
<td> 20 </td>
22
-
</tr>
23
-
<tr>
24
-
<td> 40 </td>
25
-
</tr>
26
-
<tr>
27
-
<td> 60 </td>
28
-
</tr>
29
-
<tbody>
30
-
```
31
-
32
-
```css
33
-
#my-charttbodytr:nth-of-type(2) td {
34
-
font-weight: bold;
35
-
}
36
-
```
37
-
38
-
### CSS Classes
39
-
40
-
Use custom classes on the element you want to style, and apply custom styles only on that CSS class.
41
-
42
-
```html
43
-
<tr>
44
-
<td> 20 </td>
45
-
<td> 40 </td>
46
-
<td> 60 </td>
47
-
<td> 80 </td>
48
-
<tdclass="highlight"> 100 </td>
49
-
</tr>
50
-
```
51
-
52
-
```css
53
-
.highlight {
54
-
font-weight: bold;
55
-
}
56
-
```
57
-
58
10
## Style Chart Elements
59
11
60
12
To style specific chart elements or layers, use one of the HTML tags - `<caption>`, `<tbody>`, `<tr>`, `<th>` or `<td>`.
@@ -121,7 +73,7 @@ To control the chart width/height ratio, use one of the following selectors.
121
73
122
74
```css
123
75
#my-chart.bartbody {
124
-
aspect-ratio: none;
76
+
aspect-ratio: auto;
125
77
}
126
78
127
79
#my-chart.columntbody {
@@ -140,3 +92,91 @@ To control the chart width/height ratio, use one of the following selectors.
140
92
aspect-ratio: 1 / 1;
141
93
}
142
94
```
95
+
96
+
## Style Specific Elements
97
+
98
+
To style specific elements, use any method supported by CSS.
99
+
100
+
### CSS Selectors
101
+
102
+
Use CSS `:nth-of-type()` pseudo-class to match the nth data CSS based on the position among siblings.
103
+
104
+
```html
105
+
<tbody>
106
+
<tr>
107
+
<td> 20 </td>
108
+
</tr>
109
+
<tr>
110
+
<td> 40 </td>
111
+
</tr>
112
+
<tr>
113
+
<td> 60 </td>
114
+
</tr>
115
+
<tbody>
116
+
```
117
+
118
+
```css
119
+
#my-charttbodytr:nth-of-type(2) td {
120
+
font-weight: bold;
121
+
}
122
+
```
123
+
124
+
### CSS Classes
125
+
126
+
Use custom classes on the element you want to style, and apply custom styles only on that CSS class.
127
+
128
+
```html
129
+
<tr>
130
+
<td> 20 </td>
131
+
<td> 40 </td>
132
+
<td> 60 </td>
133
+
<td> 80 </td>
134
+
<tdclass="highlight"> 100 </td>
135
+
</tr>
136
+
```
137
+
138
+
```css
139
+
.highlight {
140
+
font-weight: bold;
141
+
}
142
+
```
143
+
144
+
## Style with CSS Variables
145
+
146
+
**Charts.css** offers several [custom CSS variables](../development/supported-features/#variables) to style different chart elements.
0 commit comments