},
}
```
+
+### Update Default Scale config
+The default configuration for a scale can be easily changed using the scale service. Pass in a partial configuration that will be merged with the current scale default configuration.
+
+For example, to set the minimum value of 0 for all linear scales, you would do the following. Any linear scales created after this time would now have a minimum of 0.
+```
+Chart.scaleService.updateScaleDefaults('linear', {
+ ticks: {
+ min: 0
+ }
+})
+```
\ No newline at end of file
// Return the scale defaults merged with the global settings so that we always use the latest ones
return this.defaults.hasOwnProperty(type) ? helpers.scaleMerge(Chart.defaults.scale, this.defaults[type]) : {};
},
+ updateScaleDefaults: function(type, additions) {
+ var defaults = this.defaults;
+ if (defaults.hasOwnProperty(type)) {
+ defaults[type] = helpers.extend(defaults[type], additions);
+ }
+ },
addScalesToLayout: function(chartInstance) {
// Adds each scale to the chart.boxes array to be sized accordingly
helpers.each(chartInstance.scales, function(scale) {
--- /dev/null
+// Tests of the scale service
+describe('Test the scale service', function() {
+
+ it('should update scale defaults', function() {
+ var defaults = {
+ testProp: true
+ };
+ var type = 'my_test_type';
+ var Constructor = function() {
+ this.initialized = true;
+ };
+ Chart.scaleService.registerScaleType(type, Constructor, defaults);
+
+ // Should equal defaults but not be an identical object
+ expect(Chart.scaleService.getScaleDefaults(type)).toEqual(jasmine.objectContaining({
+ testProp: true
+ }));
+
+ Chart.scaleService.updateScaleDefaults(type, {
+ testProp: 'red',
+ newProp: 42
+ });
+
+ expect(Chart.scaleService.getScaleDefaults(type)).toEqual(jasmine.objectContaining({
+ testProp: 'red',
+ newProp: 42
+ }));
+ });
+});