Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
var defaults = require('./core.defaults'); | ||
var helpers = require('../helpers/index'); | ||
|
||
module.exports = { | ||
constructors: {}, | ||
|
||
defaults: {}, | ||
registerControllerType: function(type, scaleConstructor, scaleDefaults) { | ||
this.constructors[type] = scaleConstructor; | ||
this.defaults[type] = helpers.clone(scaleDefaults); | ||
}, | ||
|
||
getControllerConstructor: function(type) { | ||
return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined; | ||
}, | ||
|
||
getControllerDefaults: function(type) { | ||
// Return the scale defaults merged with the global settings so that we always use the latest ones | ||
return this.defaults.hasOwnProperty(type) ? helpers.merge({}, [defaults.scale, this.defaults[type]]) : {}; | ||
}, | ||
|
||
updateControllerDefaults: function(type, additions) { | ||
var me = this; | ||
if (me.defaults.hasOwnProperty(type)) { | ||
me.defaults[type] = helpers.extend(me.defaults[type], additions); | ||
} | ||
}, | ||
|
||
addControllerToLayout: function(chart) { | ||
// Adds each scale to the chart.boxes array to be sized accordingly | ||
helpers.each(chart.scales, function(scale) { | ||
// Set ILayoutItem parameters for backwards compatibility | ||
scale.fullWidth = scale.options.fullWidth; | ||
scale.position = scale.options.position; | ||
scale.weight = scale.options.weight; | ||
layouts.addBox(chart, scale); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters