Skip to content

Commit a26ca0a

Browse files
authored
docs: add docs for changing from time scale to logarithmic/linear scale (#10527)
1 parent f0be17c commit a26ca0a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/axes/cartesian/time.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,35 @@ let chart = new Chart(ctx, {
161161
});
162162
```
163163

164+
## Changing the scale type from Time scale to Logarithmic/Linear scale.
165+
166+
When changing the scale type from Time scale to Logarithmic/Linear scale, you need to add `bounds: 'ticks'` to the scale options. Changing the `bounds` parameter is necessary because its default value is the `'data'` for the Time scale.
167+
168+
Initial config:
169+
170+
```javascript
171+
const chart = new Chart(ctx, {
172+
type: 'line',
173+
data: data,
174+
options: {
175+
scales: {
176+
x: {
177+
type: 'time',
178+
}
179+
}
180+
}
181+
});
182+
```
183+
184+
Scale update:
185+
186+
```javascript
187+
chart.options.scales.x = {
188+
type: 'logarithmic',
189+
bounds: 'ticks'
190+
};
191+
```
192+
164193
## Internal data format
165194

166195
Internally time scale uses milliseconds since epoch

0 commit comments

Comments
 (0)