this.scales = {};
// Build the x axis. The line chart only supports a single x axis
- var ScaleClass = Chart.scales.getScaleConstructor(this.options.scales.xAxes[0].type);
+ var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scales.xAxes[0].type);
var xScale = new ScaleClass({
ctx: this.chart.ctx,
options: this.options.scales.xAxes[0],
// Build up all the y scales
helpers.each(this.options.scales.yAxes, function(yAxisOptions) {
- var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type);
+ var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type);
var scale = new ScaleClass({
ctx: this.chart.ctx,
options: yAxisOptions,
// Build the x axes
helpers.each(this.options.scales.xAxes, function(xAxisOptions) {
- var ScaleClass = Chart.scales.getScaleConstructor(xAxisOptions.type);
+ var ScaleClass = Chart.scaleService.getScaleConstructor(xAxisOptions.type);
var scale = new ScaleClass({
ctx: this.chart.ctx,
options: xAxisOptions,
// Build the y axes
helpers.each(this.options.scales.yAxes, function(yAxisOptions) {
- var ScaleClass = Chart.scales.getScaleConstructor(yAxisOptions.type);
+ var ScaleClass = Chart.scaleService.getScaleConstructor(yAxisOptions.type);
var scale = new ScaleClass({
ctx: this.chart.ctx,
options: yAxisOptions,
// Scale setup
var self = this;
- var ScaleClass = Chart.scales.getScaleConstructor(this.options.scale.type);
+ var ScaleClass = Chart.scaleService.getScaleConstructor(this.options.scale.type);
this.scale = new ScaleClass({
options: this.options.scale,
lineArc: true,
buildScale: function() {
var self = this;
- var ScaleConstructor = Chart.scales.getScaleConstructor(this.options.scale.type);
+ var ScaleConstructor = Chart.scaleService.getScaleConstructor(this.options.scale.type);
this.scale = new ScaleConstructor({
options: this.options.scale,
height: this.chart.height,
// a service where scales are registered with their respective charts so that changing the
// scales does not require
Chart.scaleService = {
+ // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then
+ // use the new chart options to grab the correct scale
+ constructors: {},
+ // Use a registration function so that we can move to an ES6 map when we no longer need to support
+ // old browsers
+ registerScaleType: function(type, scaleConstructor) {
+ this.constructors[type] = scaleConstructor;
+ },
+ getScaleConstructor: function(type) {
+ return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined;
+ },
+
// The interesting function
fitScalesForChart: function(chartInstance, width, height) {
var xPadding = width > 30 ? 5 : 2;
}
}
};
-
- // Scale registration object. Extensions can register new scale types (such as log or DB scales) and then
- // use the new chart options to grab the correct scale
- Chart.scales = {
- constructors: {},
- // Use a registration function so that we can move to an ES6 map when we no longer need to support
- // old browsers
- registerScaleType: function(type, scaleConstructor) {
- this.constructors[type] = scaleConstructor;
- },
- getScaleConstructor: function(type) {
- return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined;
- }
- };
-
}).call(this);
}
}
});
- Chart.scales.registerScaleType("category", DatasetScale);
-
-
-
+ Chart.scaleService.registerScaleType("category", DatasetScale);
}).call(this);
}
}
});
- Chart.scales.registerScaleType("linear", LinearScale);
-
-
+ Chart.scaleService.registerScaleType("linear", LinearScale);
+
}).call(this);
}
}
});
- Chart.scales.registerScaleType("radialLinear", LinearRadialScale);
+ Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale);
}).call(this);