The scale service

The scale service can be used to update scales during changes. You can use it to pass a partial configuration that will be merged with the current configuration. In the following code, it was used to set the minimum boundary for ticks in the linear scale, and append text to tick labels in the category scale:

Chart.scaleService.updateScaleDefaults('linear', {
ticks: {
min: -100000
},
afterTickToLabelConversion: function(axis) {
axis.ticks.forEach((d,i) => axis.ticks[i] = +d/1000);
}
});

Chart.scaleService.updateScaleDefaults('category', {
afterTickToLabelConversion: function(axis) {
axis.ticks.forEach((d,i) => axis.ticks[i] = d + " Ocean")
}
});

See the full code in Advanced/adv-4-scaleService.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset