Skip to content

Commit 93469f9

Browse files
committed
[chartjs] Improve doc example for formatting Y axis
1 parent 3d0ae08 commit 93469f9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Chartjs/doc/index.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ custom Stimulus controller:
185185
console.log(event.detail.config);
186186
187187
// For instance you can format Y axis
188-
// Add a new scales config
188+
// To avoid overriding existing config, you should distinguish 3 cases:
189+
// # 1. No existing scales config => add a new scales config
189190
event.detail.config.options.scales = {
190191
y: {
191192
ticks: {
@@ -195,7 +196,15 @@ custom Stimulus controller:
195196
},
196197
},
197198
};
198-
// ... or update an existing Y axis config
199+
// # 2. Existing scales config without Y axis config => add new Y axis config
200+
event.detail.config.options.scales.y = {
201+
ticks: {
202+
callback: function (value, index, values) {
203+
/* ... */
204+
},
205+
},
206+
};
207+
// # 3. Existing Y axis config => update it
199208
event.detail.config.options.scales.y.ticks = {
200209
callback: function (value, index, values) {
201210
/* ... */

0 commit comments

Comments
 (0)