mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Clean up code climate style issues and formatting.
This commit is contained in:
parent
756208413b
commit
01b88f19df
@ -5,7 +5,7 @@ module.exports = function(Chart) {
|
|||||||
var helpers = Chart.helpers;
|
var helpers = Chart.helpers;
|
||||||
|
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
aspectRatio: 1,
|
aspectRatio: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.Radar = function(context, config) {
|
Chart.Radar = function(context, config) {
|
||||||
|
|||||||
@ -4,20 +4,20 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
hover: {
|
hover: {
|
||||||
mode: 'single',
|
mode: 'single'
|
||||||
},
|
},
|
||||||
|
|
||||||
scales: {
|
scales: {
|
||||||
xAxes: [{
|
xAxes: [{
|
||||||
type: "linear", // scatter should not use a category axis
|
type: "linear", // scatter should not use a category axis
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
id: "x-axis-1", // need an ID so datasets can reference the scale
|
id: "x-axis-1" // need an ID so datasets can reference the scale
|
||||||
}],
|
}],
|
||||||
yAxes: [{
|
yAxes: [{
|
||||||
type: "linear",
|
type: "linear",
|
||||||
position: "left",
|
position: "left",
|
||||||
id: "y-axis-1",
|
id: "y-axis-1"
|
||||||
}],
|
}]
|
||||||
},
|
},
|
||||||
|
|
||||||
tooltips: {
|
tooltips: {
|
||||||
@ -30,7 +30,7 @@ module.exports = function(Chart) {
|
|||||||
return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')';
|
return '(' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Register the default config for this type
|
// Register the default config for this type
|
||||||
|
|||||||
@ -19,13 +19,13 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
// grid line settings
|
// grid line settings
|
||||||
gridLines: {
|
gridLines: {
|
||||||
offsetGridLines: true,
|
offsetGridLines: true
|
||||||
},
|
}
|
||||||
}],
|
}],
|
||||||
yAxes: [{
|
yAxes: [{
|
||||||
type: "linear",
|
type: "linear"
|
||||||
}],
|
}]
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.controllers.bar = Chart.DatasetController.extend({
|
Chart.controllers.bar = Chart.DatasetController.extend({
|
||||||
@ -52,7 +52,7 @@ module.exports = function(Chart) {
|
|||||||
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Rectangle({
|
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Rectangle({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@ module.exports = function(Chart) {
|
|||||||
var rectangle = new Chart.elements.Rectangle({
|
var rectangle = new Chart.elements.Rectangle({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
|
|
||||||
var numBars = this.getBarCount();
|
var numBars = this.getBarCount();
|
||||||
@ -117,8 +117,8 @@ module.exports = function(Chart) {
|
|||||||
width: this.calculateBarWidth(numBars),
|
width: this.calculateBarWidth(numBars),
|
||||||
backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor),
|
backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor),
|
||||||
borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor),
|
borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor),
|
||||||
borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth),
|
borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth)
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
rectangle.pivot();
|
rectangle.pivot();
|
||||||
},
|
},
|
||||||
@ -193,7 +193,7 @@ module.exports = function(Chart) {
|
|||||||
categorySpacing: categorySpacing,
|
categorySpacing: categorySpacing,
|
||||||
fullBarWidth: fullBarWidth,
|
fullBarWidth: fullBarWidth,
|
||||||
barWidth: barWidth,
|
barWidth: barWidth,
|
||||||
barSpacing: barSpacing,
|
barSpacing: barSpacing
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -13,13 +13,13 @@ module.exports = function(Chart) {
|
|||||||
xAxes: [{
|
xAxes: [{
|
||||||
type: "linear", // bubble should probably use a linear scale by default
|
type: "linear", // bubble should probably use a linear scale by default
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
id: "x-axis-0", // need an ID so datasets can reference the scale
|
id: "x-axis-0" // need an ID so datasets can reference the scale
|
||||||
}],
|
}],
|
||||||
yAxes: [{
|
yAxes: [{
|
||||||
type: "linear",
|
type: "linear",
|
||||||
position: "left",
|
position: "left",
|
||||||
id: "y-axis-0",
|
id: "y-axis-0"
|
||||||
}],
|
}]
|
||||||
},
|
},
|
||||||
|
|
||||||
tooltips: {
|
tooltips: {
|
||||||
@ -34,7 +34,7 @@ module.exports = function(Chart) {
|
|||||||
return datasetLabel + ': (' + dataPoint.x + ', ' + dataPoint.y + ', ' + dataPoint.r + ')';
|
return datasetLabel + ': (' + dataPoint.x + ', ' + dataPoint.y + ', ' + dataPoint.r + ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ module.exports = function(Chart) {
|
|||||||
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({
|
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -56,7 +56,7 @@ module.exports = function(Chart) {
|
|||||||
var point = new Chart.elements.Point({
|
var point = new Chart.elements.Point({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset the point
|
// Reset the point
|
||||||
@ -120,8 +120,8 @@ module.exports = function(Chart) {
|
|||||||
borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.point.borderWidth),
|
borderWidth: point.custom && point.custom.borderWidth ? point.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.point.borderWidth),
|
||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius),
|
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius)
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
|
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
|
||||||
|
|||||||
@ -9,7 +9,7 @@ module.exports = function(Chart) {
|
|||||||
//Boolean - Whether we animate the rotation of the Doughnut
|
//Boolean - Whether we animate the rotation of the Doughnut
|
||||||
animateRotate: true,
|
animateRotate: true,
|
||||||
//Boolean - Whether we animate scaling the Doughnut from the centre
|
//Boolean - Whether we animate scaling the Doughnut from the centre
|
||||||
animateScale: false,
|
animateScale: false
|
||||||
},
|
},
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
hover: {
|
hover: {
|
||||||
@ -70,7 +70,9 @@ module.exports = function(Chart) {
|
|||||||
// Need to override these to give a nice default
|
// Need to override these to give a nice default
|
||||||
tooltips: {
|
tooltips: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: function() { return '';},
|
title: function() {
|
||||||
|
return '';
|
||||||
|
},
|
||||||
label: function(tooltipItem, data) {
|
label: function(tooltipItem, data) {
|
||||||
return data.labels[tooltipItem.index] + ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
|
return data.labels[tooltipItem.index] + ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
|
||||||
}
|
}
|
||||||
@ -95,7 +97,7 @@ module.exports = function(Chart) {
|
|||||||
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({
|
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -104,7 +106,7 @@ module.exports = function(Chart) {
|
|||||||
var arc = new Chart.elements.Arc({
|
var arc = new Chart.elements.Arc({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
|
|
||||||
if (colorForNewElement && helpers.isArray(this.getDataset().backgroundColor)) {
|
if (colorForNewElement && helpers.isArray(this.getDataset().backgroundColor)) {
|
||||||
@ -119,7 +121,9 @@ module.exports = function(Chart) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getVisibleDatasetCount: function getVisibleDatasetCount() {
|
getVisibleDatasetCount: function getVisibleDatasetCount() {
|
||||||
return helpers.where(this.chart.data.datasets, function(ds) { return helpers.isDatasetVisible(ds); }).length;
|
return helpers.where(this.chart.data.datasets, function(ds) {
|
||||||
|
return helpers.isDatasetVisible(ds);
|
||||||
|
}).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
|
// Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
|
||||||
@ -190,7 +194,7 @@ module.exports = function(Chart) {
|
|||||||
borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor),
|
borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor),
|
||||||
|
|
||||||
label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index])
|
label: helpers.getValueAtIndexOrDefault(this.getDataset().label, index, this.chart.data.labels[index])
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!reset) {
|
if (!reset) {
|
||||||
@ -244,7 +248,6 @@ module.exports = function(Chart) {
|
|||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -19,8 +19,8 @@ module.exports = function(Chart) {
|
|||||||
yAxes: [{
|
yAxes: [{
|
||||||
type: "linear",
|
type: "linear",
|
||||||
id: 'y-axis-0'
|
id: 'y-axis-0'
|
||||||
}],
|
}]
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -32,14 +32,14 @@ module.exports = function(Chart) {
|
|||||||
this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({
|
this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_points: this.getDataset().metaData,
|
_points: this.getDataset().metaData
|
||||||
});
|
});
|
||||||
|
|
||||||
helpers.each(this.getDataset().data, function(value, index) {
|
helpers.each(this.getDataset().data, function(value, index) {
|
||||||
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({
|
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -48,7 +48,7 @@ module.exports = function(Chart) {
|
|||||||
var point = new Chart.elements.Point({
|
var point = new Chart.elements.Point({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset the point
|
// Reset the point
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
scale: {
|
scale: {
|
||||||
type: "radialLinear",
|
type: "radialLinear",
|
||||||
lineArc: true, // so that lines are circular
|
lineArc: true // so that lines are circular
|
||||||
},
|
},
|
||||||
|
|
||||||
//Boolean - Whether to animate the rotation of the chart
|
//Boolean - Whether to animate the rotation of the chart
|
||||||
@ -68,7 +68,9 @@ module.exports = function(Chart) {
|
|||||||
// Need to override these to give a nice default
|
// Need to override these to give a nice default
|
||||||
tooltips: {
|
tooltips: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: function() { return ''; },
|
title: function() {
|
||||||
|
return '';
|
||||||
|
},
|
||||||
label: function(tooltipItem, data) {
|
label: function(tooltipItem, data) {
|
||||||
return data.labels[tooltipItem.index] + ': ' + tooltipItem.yLabel;
|
return data.labels[tooltipItem.index] + ': ' + tooltipItem.yLabel;
|
||||||
}
|
}
|
||||||
@ -86,7 +88,7 @@ module.exports = function(Chart) {
|
|||||||
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({
|
this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -95,7 +97,7 @@ module.exports = function(Chart) {
|
|||||||
var arc = new Chart.elements.Arc({
|
var arc = new Chart.elements.Arc({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset the point
|
// Reset the point
|
||||||
@ -105,7 +107,9 @@ module.exports = function(Chart) {
|
|||||||
this.getDataset().metaData.splice(index, 0, arc);
|
this.getDataset().metaData.splice(index, 0, arc);
|
||||||
},
|
},
|
||||||
getVisibleDatasetCount: function getVisibleDatasetCount() {
|
getVisibleDatasetCount: function getVisibleDatasetCount() {
|
||||||
return helpers.where(this.chart.data.datasets, function(ds) { return helpers.isDatasetVisible(ds); }).length;
|
return helpers.where(this.chart.data.datasets, function(ds) {
|
||||||
|
return helpers.isDatasetVisible(ds);
|
||||||
|
}).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function update(reset) {
|
update: function update(reset) {
|
||||||
@ -180,7 +184,7 @@ module.exports = function(Chart) {
|
|||||||
borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor),
|
borderColor: arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor),
|
||||||
|
|
||||||
label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index])
|
label: helpers.getValueAtIndexOrDefault(this.chart.data.labels, index, this.chart.data.labels[index])
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
arc.pivot();
|
arc.pivot();
|
||||||
|
|||||||
@ -7,13 +7,13 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
Chart.defaults.radar = {
|
Chart.defaults.radar = {
|
||||||
scale: {
|
scale: {
|
||||||
type: "radialLinear",
|
type: "radialLinear"
|
||||||
},
|
},
|
||||||
elements: {
|
elements: {
|
||||||
line: {
|
line: {
|
||||||
tension: 0, // no bezier in radar
|
tension: 0 // no bezier in radar
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.controllers.radar = Chart.DatasetController.extend({
|
Chart.controllers.radar = Chart.DatasetController.extend({
|
||||||
@ -39,8 +39,8 @@ module.exports = function(Chart) {
|
|||||||
_index: index,
|
_index: index,
|
||||||
_model: {
|
_model: {
|
||||||
x: 0, //xScale.getPixelForValue(null, index, true),
|
x: 0, //xScale.getPixelForValue(null, index, true),
|
||||||
y: 0, //this.chartArea.bottom,
|
y: 0 //this.chartArea.bottom,
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -49,7 +49,7 @@ module.exports = function(Chart) {
|
|||||||
var point = new Chart.elements.Point({
|
var point = new Chart.elements.Point({
|
||||||
_chart: this.chart.chart,
|
_chart: this.chart.chart,
|
||||||
_datasetIndex: this.index,
|
_datasetIndex: this.index,
|
||||||
_index: index,
|
_index: index
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset the point
|
// Reset the point
|
||||||
@ -99,8 +99,8 @@ module.exports = function(Chart) {
|
|||||||
// Scale
|
// Scale
|
||||||
scaleTop: scale.top,
|
scaleTop: scale.top,
|
||||||
scaleBottom: scale.bottom,
|
scaleBottom: scale.bottom,
|
||||||
scaleZero: scaleBase,
|
scaleZero: scaleBase
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getDataset().metaDataset.pivot();
|
this.getDataset().metaDataset.pivot();
|
||||||
@ -137,8 +137,8 @@ module.exports = function(Chart) {
|
|||||||
pointStyle: point.custom && point.custom.pointStyle ? point.custom.pointStyle : helpers.getValueAtIndexOrDefault(this.getDataset().pointStyle, index, this.chart.options.elements.point.pointStyle),
|
pointStyle: point.custom && point.custom.pointStyle ? point.custom.pointStyle : helpers.getValueAtIndexOrDefault(this.getDataset().pointStyle, index, this.chart.options.elements.point.pointStyle),
|
||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius),
|
hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius)
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
|
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
|
||||||
|
|||||||
@ -9,7 +9,7 @@ module.exports = function(Chart) {
|
|||||||
duration: 1000,
|
duration: 1000,
|
||||||
easing: "easeOutQuart",
|
easing: "easeOutQuart",
|
||||||
onProgress: helpers.noop,
|
onProgress: helpers.noop,
|
||||||
onComplete: helpers.noop,
|
onComplete: helpers.noop
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.Animation = Chart.Element.extend({
|
Chart.Animation = Chart.Element.extend({
|
||||||
@ -19,7 +19,7 @@ module.exports = function(Chart) {
|
|||||||
render: null, // render function used by the animation service
|
render: null, // render function used by the animation service
|
||||||
|
|
||||||
onAnimationProgress: null, // user specified callback to fire on each step of the animation
|
onAnimationProgress: null, // user specified callback to fire on each step of the animation
|
||||||
onAnimationComplete: null, // user specified callback to fire when the animation finishes
|
onAnimationComplete: null // user specified callback to fire when the animation finishes
|
||||||
});
|
});
|
||||||
|
|
||||||
Chart.animationService = {
|
Chart.animationService = {
|
||||||
@ -46,7 +46,7 @@ module.exports = function(Chart) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If there are no animations queued, manually kickstart a digest, for lack of a better word
|
// If there are no animations queued, manually kickstart a digest, for lack of a better word
|
||||||
if (this.animations.length == 1) {
|
if (this.animations.length === 1) {
|
||||||
helpers.requestAnimFrame.call(window, this.digestWrapper);
|
helpers.requestAnimFrame.call(window, this.digestWrapper);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -91,7 +91,7 @@ module.exports = function(Chart) {
|
|||||||
this.animations[i].animationObject.onAnimationProgress.call(this.animations[i].chartInstance, this.animations[i]);
|
this.animations[i].animationObject.onAnimationProgress.call(this.animations[i].chartInstance, this.animations[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.animations[i].animationObject.currentStep == this.animations[i].animationObject.numSteps) {
|
if (this.animations[i].animationObject.currentStep === this.animations[i].animationObject.numSteps) {
|
||||||
if (this.animations[i].animationObject.onAnimationComplete && this.animations[i].animationObject.onAnimationComplete.call) {
|
if (this.animations[i].animationObject.onAnimationComplete && this.animations[i].animationObject.onAnimationComplete.call) {
|
||||||
this.animations[i].animationObject.onAnimationComplete.call(this.animations[i].chartInstance, this.animations[i]);
|
this.animations[i].animationObject.onAnimationComplete.call(this.animations[i].chartInstance, this.animations[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module.exports = function(Chart) {
|
|||||||
Object.defineProperty(this, 'data', {
|
Object.defineProperty(this, 'data', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this.config.data;
|
return this.config.data;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Add the chart instance to the global namespace
|
//Add the chart instance to the global namespace
|
||||||
@ -35,7 +35,7 @@ module.exports = function(Chart) {
|
|||||||
this.resize(true);
|
this.resize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialize.call(this);
|
this.initialize();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@ -133,7 +133,7 @@ module.exports = function(Chart) {
|
|||||||
ctx: this.chart.ctx,
|
ctx: this.chart.ctx,
|
||||||
options: xAxisOptions,
|
options: xAxisOptions,
|
||||||
chart: this,
|
chart: this,
|
||||||
id: xAxisOptions.id,
|
id: xAxisOptions.id
|
||||||
});
|
});
|
||||||
|
|
||||||
this.scales[scale.id] = scale;
|
this.scales[scale.id] = scale;
|
||||||
@ -150,7 +150,7 @@ module.exports = function(Chart) {
|
|||||||
ctx: this.chart.ctx,
|
ctx: this.chart.ctx,
|
||||||
options: yAxisOptions,
|
options: yAxisOptions,
|
||||||
chart: this,
|
chart: this,
|
||||||
id: yAxisOptions.id,
|
id: yAxisOptions.id
|
||||||
});
|
});
|
||||||
|
|
||||||
this.scales[scale.id] = scale;
|
this.scales[scale.id] = scale;
|
||||||
@ -165,7 +165,7 @@ module.exports = function(Chart) {
|
|||||||
var scale = new ScaleClass({
|
var scale = new ScaleClass({
|
||||||
ctx: this.chart.ctx,
|
ctx: this.chart.ctx,
|
||||||
options: this.options.scale,
|
options: this.options.scale,
|
||||||
chart: this,
|
chart: this
|
||||||
});
|
});
|
||||||
|
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
@ -192,7 +192,7 @@ module.exports = function(Chart) {
|
|||||||
this.legend = new Chart.Legend({
|
this.legend = new Chart.Legend({
|
||||||
ctx: this.chart.ctx,
|
ctx: this.chart.ctx,
|
||||||
options: this.options.legend,
|
options: this.options.legend,
|
||||||
chart: this,
|
chart: this
|
||||||
});
|
});
|
||||||
|
|
||||||
Chart.layoutService.addBox(this, this.legend);
|
Chart.layoutService.addBox(this, this.legend);
|
||||||
@ -225,7 +225,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
if (types.length > 1) {
|
if (types.length > 1) {
|
||||||
for (var i = 1; i < types.length; i++) {
|
for (var i = 1; i < types.length; i++) {
|
||||||
if (types[i] != types[i - 1]) {
|
if (types[i] !== types[i - 1]) {
|
||||||
this.isCombo = true;
|
this.isCombo = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
render: function render(duration, lazy) {
|
render: function render(duration, lazy) {
|
||||||
|
|
||||||
if (this.options.animation && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration == 'undefined' && this.options.animation.duration !== 0))) {
|
if (this.options.animation && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && this.options.animation.duration !== 0))) {
|
||||||
var animation = new Chart.Animation();
|
var animation = new Chart.Animation();
|
||||||
animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps
|
animation.numSteps = (duration || this.options.animation.duration) / 16.66; //60 fps
|
||||||
animation.easing = this.options.animation.easing;
|
animation.easing = this.options.animation.easing;
|
||||||
@ -415,7 +415,7 @@ module.exports = function(Chart) {
|
|||||||
_chart: this.chart,
|
_chart: this.chart,
|
||||||
_chartInstance: this,
|
_chartInstance: this,
|
||||||
_data: this.data,
|
_data: this.data,
|
||||||
_options: this.options,
|
_options: this.options
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ module.exports = function(Chart) {
|
|||||||
this.lastTooltipActive = this.lastTooltipActive || [];
|
this.lastTooltipActive = this.lastTooltipActive || [];
|
||||||
|
|
||||||
// Find Active Elements for hover and tooltips
|
// Find Active Elements for hover and tooltips
|
||||||
if (e.type == 'mouseout') {
|
if (e.type === 'mouseout') {
|
||||||
this.active = [];
|
this.active = [];
|
||||||
this.tooltipActive = [];
|
this.tooltipActive = [];
|
||||||
} else {
|
} else {
|
||||||
@ -457,7 +457,7 @@ module.exports = function(Chart) {
|
|||||||
this.options.hover.onHover.call(this, this.active);
|
this.options.hover.onHover.call(this, this.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.type == 'mouseup' || e.type == 'click') {
|
if (e.type === 'mouseup' || e.type === 'click') {
|
||||||
if (this.options.onClick) {
|
if (this.options.onClick) {
|
||||||
this.options.onClick.call(this, e, this.active);
|
this.options.onClick.call(this, e, this.active);
|
||||||
}
|
}
|
||||||
@ -555,6 +555,6 @@ module.exports = function(Chart) {
|
|||||||
this.lastActive = this.active;
|
this.lastActive = this.active;
|
||||||
this.lastTooltipActive = this.tooltipActive;
|
this.lastTooltipActive = this.tooltipActive;
|
||||||
return this;
|
return this;
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -65,7 +65,7 @@ module.exports = function(Chart) {
|
|||||||
draw: helpers.noop,
|
draw: helpers.noop,
|
||||||
removeHoverStyle: helpers.noop,
|
removeHoverStyle: helpers.noop,
|
||||||
setHoverStyle: helpers.noop,
|
setHoverStyle: helpers.noop,
|
||||||
update: helpers.noop,
|
update: helpers.noop
|
||||||
});
|
});
|
||||||
|
|
||||||
Chart.DatasetController.extend = helpers.inherits;
|
Chart.DatasetController.extend = helpers.inherits;
|
||||||
|
|||||||
@ -83,7 +83,7 @@ module.exports = function(Chart) {
|
|||||||
helpers.each(value, function(valueObj, index) {
|
helpers.each(value, function(valueObj, index) {
|
||||||
|
|
||||||
if (index < baseArray.length) {
|
if (index < baseArray.length) {
|
||||||
if (typeof baseArray[index] == 'object' && baseArray[index] !== null && typeof valueObj == 'object' && valueObj !== null) {
|
if (typeof baseArray[index] === 'object' && baseArray[index] !== null && typeof valueObj === 'object' && valueObj !== null) {
|
||||||
// Two objects are coming together. Do a merge of them.
|
// Two objects are coming together. Do a merge of them.
|
||||||
baseArray[index] = helpers.configMerge(baseArray[index], valueObj);
|
baseArray[index] = helpers.configMerge(baseArray[index], valueObj);
|
||||||
} else {
|
} else {
|
||||||
@ -95,7 +95,7 @@ module.exports = function(Chart) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") {
|
} else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
|
||||||
// If we are overwriting an object with an object, do a merge of the properties.
|
// If we are overwriting an object with an object, do a merge of the properties.
|
||||||
base[key] = helpers.configMerge(base[key], value);
|
base[key] = helpers.configMerge(base[key], value);
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ module.exports = function(Chart) {
|
|||||||
base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj));
|
base[key].push(helpers.configMerge(valueObj.type ? Chart.scaleService.getScaleDefaults(valueObj.type) : {}, valueObj));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (base.hasOwnProperty(key) && typeof base[key] == "object" && base[key] !== null && typeof value == "object") {
|
} else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
|
||||||
// If we are overwriting an object with an object, do a merge of the properties.
|
// If we are overwriting an object with an object, do a merge of the properties.
|
||||||
base[key] = helpers.configMerge(base[key], value);
|
base[key] = helpers.configMerge(base[key], value);
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ module.exports = function(Chart) {
|
|||||||
if (t === 0) {
|
if (t === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((t /= 1) == 1) {
|
if ((t /= 1) === 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -531,7 +531,7 @@ module.exports = function(Chart) {
|
|||||||
if (t === 0) {
|
if (t === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((t /= 1) == 1) {
|
if ((t /= 1) === 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -552,7 +552,7 @@ module.exports = function(Chart) {
|
|||||||
if (t === 0) {
|
if (t === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((t /= 1 / 2) == 2) {
|
if ((t /= 1 / 2) === 2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -874,7 +874,7 @@ module.exports = function(Chart) {
|
|||||||
return Array.isArray(obj);
|
return Array.isArray(obj);
|
||||||
};
|
};
|
||||||
helpers.pushAllIfDefined = function(element, array) {
|
helpers.pushAllIfDefined = function(element, array) {
|
||||||
if (typeof element == "undefined") {
|
if (typeof element === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ module.exports = function() {
|
|||||||
hover: {
|
hover: {
|
||||||
onHover: null,
|
onHover: null,
|
||||||
mode: 'single',
|
mode: 'single',
|
||||||
animationDuration: 400,
|
animationDuration: 400
|
||||||
},
|
},
|
||||||
onClick: null,
|
onClick: null,
|
||||||
defaultColor: 'rgba(0,0,0,0.1)',
|
defaultColor: 'rgba(0,0,0,0.1)',
|
||||||
@ -96,7 +96,7 @@ module.exports = function() {
|
|||||||
|
|
||||||
return text.join("");
|
return text.join("");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return Chart;
|
return Chart;
|
||||||
|
|||||||
@ -36,21 +36,21 @@ module.exports = function(Chart) {
|
|||||||
var yPadding = height > 30 ? 5 : 2;
|
var yPadding = height > 30 ? 5 : 2;
|
||||||
|
|
||||||
var leftBoxes = helpers.where(chartInstance.boxes, function(box) {
|
var leftBoxes = helpers.where(chartInstance.boxes, function(box) {
|
||||||
return box.options.position == "left";
|
return box.options.position === "left";
|
||||||
});
|
});
|
||||||
var rightBoxes = helpers.where(chartInstance.boxes, function(box) {
|
var rightBoxes = helpers.where(chartInstance.boxes, function(box) {
|
||||||
return box.options.position == "right";
|
return box.options.position === "right";
|
||||||
});
|
});
|
||||||
var topBoxes = helpers.where(chartInstance.boxes, function(box) {
|
var topBoxes = helpers.where(chartInstance.boxes, function(box) {
|
||||||
return box.options.position == "top";
|
return box.options.position === "top";
|
||||||
});
|
});
|
||||||
var bottomBoxes = helpers.where(chartInstance.boxes, function(box) {
|
var bottomBoxes = helpers.where(chartInstance.boxes, function(box) {
|
||||||
return box.options.position == "bottom";
|
return box.options.position === "bottom";
|
||||||
});
|
});
|
||||||
|
|
||||||
// Boxes that overlay the chartarea such as the radialLinear scale
|
// Boxes that overlay the chartarea such as the radialLinear scale
|
||||||
var chartAreaBoxes = helpers.where(chartInstance.boxes, function(box) {
|
var chartAreaBoxes = helpers.where(chartInstance.boxes, function(box) {
|
||||||
return box.options.position == "chartArea";
|
return box.options.position === "chartArea";
|
||||||
});
|
});
|
||||||
|
|
||||||
function fullWidthSorter(a, b) {
|
function fullWidthSorter(a, b) {
|
||||||
@ -136,7 +136,7 @@ module.exports = function(Chart) {
|
|||||||
minBoxSizes.push({
|
minBoxSizes.push({
|
||||||
horizontal: isHorizontal,
|
horizontal: isHorizontal,
|
||||||
minSize: minSize,
|
minSize: minSize,
|
||||||
box: box,
|
box: box
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ module.exports = function(Chart) {
|
|||||||
left: totalLeftBoxesWidth,
|
left: totalLeftBoxesWidth,
|
||||||
right: totalRightBoxesWidth,
|
right: totalRightBoxesWidth,
|
||||||
top: 0,
|
top: 0,
|
||||||
bottom: 0,
|
bottom: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
|
// Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
|
||||||
@ -306,7 +306,7 @@ module.exports = function(Chart) {
|
|||||||
left: totalLeftBoxesWidth,
|
left: totalLeftBoxesWidth,
|
||||||
top: totalTopBoxesHeight,
|
top: totalTopBoxesHeight,
|
||||||
right: totalLeftBoxesWidth + maxChartAreaWidth,
|
right: totalLeftBoxesWidth + maxChartAreaWidth,
|
||||||
bottom: totalTopBoxesHeight + maxChartAreaHeight,
|
bottom: totalTopBoxesHeight + maxChartAreaHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 9
|
// Step 9
|
||||||
|
|||||||
@ -55,7 +55,7 @@ module.exports = function(Chart) {
|
|||||||
};
|
};
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.Legend = Chart.Element.extend({
|
Chart.Legend = Chart.Element.extend({
|
||||||
@ -133,7 +133,7 @@ module.exports = function(Chart) {
|
|||||||
// Reset minSize
|
// Reset minSize
|
||||||
this.minSize = {
|
this.minSize = {
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
afterSetDimensions: helpers.noop,
|
afterSetDimensions: helpers.noop,
|
||||||
@ -196,7 +196,7 @@ module.exports = function(Chart) {
|
|||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
width: width,
|
width: width,
|
||||||
height: this.options.labels.fontSize,
|
height: this.options.labels.fontSize
|
||||||
};
|
};
|
||||||
|
|
||||||
this.lineWidths[this.lineWidths.length - 1] += width + this.options.labels.padding;
|
this.lineWidths[this.lineWidths.length - 1] += width + this.options.labels.padding;
|
||||||
@ -217,7 +217,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
// Shared Methods
|
// Shared Methods
|
||||||
isHorizontal: function() {
|
isHorizontal: function() {
|
||||||
return this.options.position == "top" || this.options.position == "bottom";
|
return this.options.position === "top" || this.options.position === "bottom";
|
||||||
},
|
},
|
||||||
|
|
||||||
// Actualy draw the legend on the canvas
|
// Actualy draw the legend on the canvas
|
||||||
@ -227,7 +227,7 @@ module.exports = function(Chart) {
|
|||||||
var cursor = {
|
var cursor = {
|
||||||
x: this.left + ((this.width - this.lineWidths[0]) / 2),
|
x: this.left + ((this.width - this.lineWidths[0]) / 2),
|
||||||
y: this.top + this.options.labels.padding,
|
y: this.top + this.options.labels.padding,
|
||||||
line: 0,
|
line: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily);
|
var labelFont = helpers.fontString(this.options.labels.fontSize, this.options.labels.fontStyle, this.options.labels.fontFamily);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module.exports = function(Chart) {
|
|||||||
drawTicks: true,
|
drawTicks: true,
|
||||||
zeroLineWidth: 1,
|
zeroLineWidth: 1,
|
||||||
zeroLineColor: "rgba(0,0,0,0.25)",
|
zeroLineColor: "rgba(0,0,0,0.25)",
|
||||||
offsetGridLines: false,
|
offsetGridLines: false
|
||||||
},
|
},
|
||||||
|
|
||||||
// scale label
|
// scale label
|
||||||
@ -30,7 +30,7 @@ module.exports = function(Chart) {
|
|||||||
labelString: '',
|
labelString: '',
|
||||||
|
|
||||||
// display property
|
// display property
|
||||||
display: false,
|
display: false
|
||||||
},
|
},
|
||||||
|
|
||||||
// label settings
|
// label settings
|
||||||
@ -49,8 +49,8 @@ module.exports = function(Chart) {
|
|||||||
autoSkipPadding: 20,
|
autoSkipPadding: 20,
|
||||||
callback: function(value) {
|
callback: function(value) {
|
||||||
return '' + value;
|
return '' + value;
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.Scale = Chart.Element.extend({
|
Chart.Scale = Chart.Element.extend({
|
||||||
@ -259,7 +259,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
this.minSize = {
|
this.minSize = {
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Width
|
// Width
|
||||||
@ -483,7 +483,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
helpers.each(this.ticks, function(label, index) {
|
helpers.each(this.ticks, function(label, index) {
|
||||||
// Blank ticks
|
// Blank ticks
|
||||||
var isLastTick = this.ticks.length == index + 1;
|
var isLastTick = this.ticks.length === index + 1;
|
||||||
var shouldSkip = skipRatio > 1 && index % skipRatio > 0;
|
var shouldSkip = skipRatio > 1 && index % skipRatio > 0;
|
||||||
if (shouldSkip && !isLastTick || (label === undefined || label === null)) {
|
if (shouldSkip && !isLastTick || (label === undefined || label === null)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -29,6 +29,6 @@ module.exports = function(Chart) {
|
|||||||
helpers.each(chartInstance.scales, function(scale) {
|
helpers.each(chartInstance.scales, function(scale) {
|
||||||
Chart.layoutService.addBox(chartInstance, scale);
|
Chart.layoutService.addBox(chartInstance, scale);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -16,7 +16,7 @@ module.exports = function(Chart) {
|
|||||||
padding: 10,
|
padding: 10,
|
||||||
|
|
||||||
// actual title
|
// actual title
|
||||||
text: '',
|
text: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.Title = Chart.Element.extend({
|
Chart.Title = Chart.Element.extend({
|
||||||
@ -90,7 +90,7 @@ module.exports = function(Chart) {
|
|||||||
// Reset minSize
|
// Reset minSize
|
||||||
this.minSize = {
|
this.minSize = {
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0,
|
height: 0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
afterSetDimensions: helpers.noop,
|
afterSetDimensions: helpers.noop,
|
||||||
@ -142,7 +142,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
// Shared Methods
|
// Shared Methods
|
||||||
isHorizontal: function() {
|
isHorizontal: function() {
|
||||||
return this.options.position == "top" || this.options.position == "bottom";
|
return this.options.position === "top" || this.options.position === "bottom";
|
||||||
},
|
},
|
||||||
|
|
||||||
// Actualy draw the title block on the canvas
|
// Actualy draw the title block on the canvas
|
||||||
@ -170,9 +170,9 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
// Title
|
// Title
|
||||||
if (this.options.display) {
|
if (this.options.display) {
|
||||||
titleX = this.options.position == 'left' ? this.left + (this.options.fontSize / 2) : this.right - (this.options.fontSize / 2);
|
titleX = this.options.position === 'left' ? this.left + (this.options.fontSize / 2) : this.right - (this.options.fontSize / 2);
|
||||||
titleY = this.top + ((this.bottom - this.top) / 2);
|
titleY = this.top + ((this.bottom - this.top) / 2);
|
||||||
var rotation = this.options.position == 'left' ? -0.5 * Math.PI : 0.5 * Math.PI;
|
var rotation = this.options.position === 'left' ? -0.5 * Math.PI : 0.5 * Math.PI;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.translate(titleX, titleY);
|
ctx.translate(titleX, titleY);
|
||||||
|
|||||||
@ -70,8 +70,8 @@ module.exports = function(Chart) {
|
|||||||
// Args are: (tooltipItems, data)
|
// Args are: (tooltipItems, data)
|
||||||
beforeFooter: helpers.noop,
|
beforeFooter: helpers.noop,
|
||||||
footer: helpers.noop,
|
footer: helpers.noop,
|
||||||
afterFooter: helpers.noop,
|
afterFooter: helpers.noop
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper to push or concat based on if the 2nd parameter is an array or not
|
// Helper to push or concat based on if the 2nd parameter is an array or not
|
||||||
@ -127,8 +127,8 @@ module.exports = function(Chart) {
|
|||||||
cornerRadius: options.tooltips.cornerRadius,
|
cornerRadius: options.tooltips.cornerRadius,
|
||||||
backgroundColor: options.tooltips.backgroundColor,
|
backgroundColor: options.tooltips.backgroundColor,
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
legendColorBackground: options.tooltips.multiKeyBackground,
|
legendColorBackground: options.tooltips.multiKeyBackground
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ module.exports = function(Chart) {
|
|||||||
xLabel: element._xScale ? element._xScale.getLabelForIndex(element._index, element._datasetIndex) : '',
|
xLabel: element._xScale ? element._xScale.getLabelForIndex(element._index, element._datasetIndex) : '',
|
||||||
yLabel: yScale ? yScale.getLabelForIndex(element._index, element._datasetIndex) : '',
|
yLabel: yScale ? yScale.getLabelForIndex(element._index, element._datasetIndex) : '',
|
||||||
index: element._index,
|
index: element._index,
|
||||||
datasetIndex: element._datasetIndex,
|
datasetIndex: element._datasetIndex
|
||||||
});
|
});
|
||||||
tooltipPosition = this.getAveragePosition(this._active);
|
tooltipPosition = this.getAveragePosition(this._active);
|
||||||
} else {
|
} else {
|
||||||
@ -250,7 +250,7 @@ module.exports = function(Chart) {
|
|||||||
xLabel: currentElement._xScale ? currentElement._xScale.getLabelForIndex(currentElement._index, currentElement._datasetIndex) : '',
|
xLabel: currentElement._xScale ? currentElement._xScale.getLabelForIndex(currentElement._index, currentElement._datasetIndex) : '',
|
||||||
yLabel: yScale ? yScale.getLabelForIndex(currentElement._index, currentElement._datasetIndex) : '',
|
yLabel: yScale ? yScale.getLabelForIndex(currentElement._index, currentElement._datasetIndex) : '',
|
||||||
index: element._index,
|
index: element._index,
|
||||||
datasetIndex: datasetIndex,
|
datasetIndex: datasetIndex
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -274,14 +274,14 @@ module.exports = function(Chart) {
|
|||||||
beforeBody: this.getBeforeBody(tooltipItems, this._data),
|
beforeBody: this.getBeforeBody(tooltipItems, this._data),
|
||||||
body: this.getBody(tooltipItems, this._data),
|
body: this.getBody(tooltipItems, this._data),
|
||||||
afterBody: this.getAfterBody(tooltipItems, this._data),
|
afterBody: this.getAfterBody(tooltipItems, this._data),
|
||||||
footer: this.getFooter(tooltipItems, this._data),
|
footer: this.getFooter(tooltipItems, this._data)
|
||||||
});
|
});
|
||||||
|
|
||||||
helpers.extend(this._model, {
|
helpers.extend(this._model, {
|
||||||
x: Math.round(tooltipPosition.x),
|
x: Math.round(tooltipPosition.x),
|
||||||
y: Math.round(tooltipPosition.y),
|
y: Math.round(tooltipPosition.y),
|
||||||
caretPadding: helpers.getValueOrDefault(tooltipPosition.padding, 2),
|
caretPadding: helpers.getValueOrDefault(tooltipPosition.padding, 2),
|
||||||
labelColors: labelColors,
|
labelColors: labelColors
|
||||||
});
|
});
|
||||||
|
|
||||||
// We need to determine alignment of
|
// We need to determine alignment of
|
||||||
@ -420,7 +420,7 @@ module.exports = function(Chart) {
|
|||||||
pt.y -= (size.height / 2);
|
pt.y -= (size.height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.yAlign == 'center') {
|
if (vm.yAlign === 'center') {
|
||||||
if (vm.xAlign === 'left') {
|
if (vm.xAlign === 'left') {
|
||||||
pt.x += vm.caretPadding + vm.caretSize;
|
pt.x += vm.caretPadding + vm.caretSize;
|
||||||
} else if (vm.xAlign === 'right') {
|
} else if (vm.xAlign === 'right') {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module.exports = function(Chart) {
|
|||||||
borderDash: [],
|
borderDash: [],
|
||||||
borderDashOffset: 0.0,
|
borderDashOffset: 0.0,
|
||||||
borderJoinStyle: 'miter',
|
borderJoinStyle: 'miter',
|
||||||
fill: true, // do we fill in the area between the line and its base axis
|
fill: true // do we fill in the area between the line and its base axis
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.elements.Line = Chart.Element.extend({
|
Chart.elements.Line = Chart.Element.extend({
|
||||||
@ -156,6 +156,6 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -13,7 +13,7 @@ module.exports = function(Chart) {
|
|||||||
// Hover
|
// Hover
|
||||||
hitRadius: 1,
|
hitRadius: 1,
|
||||||
hoverRadius: 4,
|
hoverRadius: 4,
|
||||||
hoverBorderWidth: 1,
|
hoverBorderWidth: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -69,8 +69,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
switch (vm.pointStyle) {
|
switch (vm.pointStyle) {
|
||||||
// Default includes circle
|
// Default includes circle
|
||||||
default:
|
default: ctx.beginPath();
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(vm.x, vm.y, radius, 0, Math.PI * 2);
|
ctx.arc(vm.x, vm.y, radius, 0, Math.PI * 2);
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module.exports = function(Chart) {
|
|||||||
Chart.defaults.global.elements.rectangle = {
|
Chart.defaults.global.elements.rectangle = {
|
||||||
backgroundColor: Chart.defaults.global.defaultColor,
|
backgroundColor: Chart.defaults.global.defaultColor,
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
borderColor: Chart.defaults.global.defaultColor,
|
borderColor: Chart.defaults.global.defaultColor
|
||||||
};
|
};
|
||||||
|
|
||||||
Chart.elements.Rectangle = Chart.Element.extend({
|
Chart.elements.Rectangle = Chart.Element.extend({
|
||||||
@ -80,7 +80,7 @@ module.exports = function(Chart) {
|
|||||||
x: vm.x,
|
x: vm.x,
|
||||||
y: vm.y
|
y: vm.y
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -5,7 +5,7 @@ module.exports = function(Chart) {
|
|||||||
var helpers = Chart.helpers;
|
var helpers = Chart.helpers;
|
||||||
// Default config for a category scale
|
// Default config for a category scale
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
position: "bottom",
|
position: "bottom"
|
||||||
};
|
};
|
||||||
|
|
||||||
var DatasetScale = Chart.Scale.extend({
|
var DatasetScale = Chart.Scale.extend({
|
||||||
@ -40,7 +40,7 @@ module.exports = function(Chart) {
|
|||||||
|
|
||||||
return this.top + Math.round(heightOffset);
|
return this.top + Math.round(heightOffset);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig);
|
Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig);
|
||||||
|
|||||||
@ -49,7 +49,7 @@ module.exports = function(Chart) {
|
|||||||
if (valuesPerType[dataset.type] === undefined) {
|
if (valuesPerType[dataset.type] === undefined) {
|
||||||
valuesPerType[dataset.type] = {
|
valuesPerType[dataset.type] = {
|
||||||
positiveValues: [],
|
positiveValues: [],
|
||||||
negativeValues: [],
|
negativeValues: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ module.exports = function(Chart) {
|
|||||||
}
|
}
|
||||||
this.ticks.push(this.options.ticks.max !== undefined ? this.options.ticks.max : niceMax);
|
this.ticks.push(this.options.ticks.max !== undefined ? this.options.ticks.max : niceMax);
|
||||||
|
|
||||||
if (this.options.position == "left" || this.options.position == "right") {
|
if (this.options.position === "left" || this.options.position === "right") {
|
||||||
// We are in a vertical orientation. The top value is the highest. So reverse the array
|
// We are in a vertical orientation. The top value is the highest. So reverse the array
|
||||||
this.ticks.reverse();
|
this.ticks.reverse();
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ module.exports = function(Chart) {
|
|||||||
},
|
},
|
||||||
getPixelForTick: function(index, includeOffset) {
|
getPixelForTick: function(index, includeOffset) {
|
||||||
return this.getPixelForValue(this.ticksAsNumbers[index], null, null, includeOffset);
|
return this.getPixelForValue(this.ticksAsNumbers[index], null, null, includeOffset);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);
|
Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,7 @@ module.exports = function(Chart) {
|
|||||||
var lastTick = this.options.ticks.max !== undefined ? this.options.ticks.max : tickVal;
|
var lastTick = this.options.ticks.max !== undefined ? this.options.ticks.max : tickVal;
|
||||||
this.tickValues.push(lastTick);
|
this.tickValues.push(lastTick);
|
||||||
|
|
||||||
if (this.options.position == "left" || this.options.position == "right") {
|
if (this.options.position === "left" || this.options.position === "right") {
|
||||||
// We are in a vertical orientation. The top value is the highest. So reverse the array
|
// We are in a vertical orientation. The top value is the highest. So reverse the array
|
||||||
this.tickValues.reverse();
|
this.tickValues.reverse();
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ module.exports = function(Chart) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return pixel;
|
return pixel;
|
||||||
},
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
Chart.scaleService.registerScaleType("logarithmic", LogarithmicScale, defaultConfig);
|
Chart.scaleService.registerScaleType("logarithmic", LogarithmicScale, defaultConfig);
|
||||||
|
|||||||
@ -30,7 +30,7 @@ module.exports = function(Chart) {
|
|||||||
backdropPaddingY: 2,
|
backdropPaddingY: 2,
|
||||||
|
|
||||||
//Number - The backdrop padding to the side of the label in pixels
|
//Number - The backdrop padding to the side of the label in pixels
|
||||||
backdropPaddingX: 2,
|
backdropPaddingX: 2
|
||||||
},
|
},
|
||||||
|
|
||||||
pointLabels: {
|
pointLabels: {
|
||||||
@ -50,7 +50,7 @@ module.exports = function(Chart) {
|
|||||||
callback: function(label) {
|
callback: function(label) {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var LinearRadialScale = Chart.Scale.extend({
|
var LinearRadialScale = Chart.Scale.extend({
|
||||||
|
|||||||
@ -37,11 +37,11 @@ module.exports = function(Chart) {
|
|||||||
maxStep: 3
|
maxStep: 3
|
||||||
}, {
|
}, {
|
||||||
name: 'quarter',
|
name: 'quarter',
|
||||||
maxStep: 4,
|
maxStep: 4
|
||||||
}, {
|
}, {
|
||||||
name: 'year',
|
name: 'year',
|
||||||
maxStep: false
|
maxStep: false
|
||||||
}, ],
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
@ -63,9 +63,9 @@ module.exports = function(Chart) {
|
|||||||
'week': 'll', // Week 46, or maybe "[W]WW - YYYY" ?
|
'week': 'll', // Week 46, or maybe "[W]WW - YYYY" ?
|
||||||
'month': 'MMM YYYY', // Sept 2015
|
'month': 'MMM YYYY', // Sept 2015
|
||||||
'quarter': '[Q]Q - YYYY', // Q3
|
'quarter': '[Q]Q - YYYY', // Q3
|
||||||
'year': 'YYYY', // 2015
|
'year': 'YYYY' // 2015
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var TimeScale = Chart.Scale.extend({
|
var TimeScale = Chart.Scale.extend({
|
||||||
@ -287,7 +287,7 @@ module.exports = function(Chart) {
|
|||||||
},
|
},
|
||||||
parseTime: function(label) {
|
parseTime: function(label) {
|
||||||
// Date objects
|
// Date objects
|
||||||
if (typeof label.getMonth === 'function' || typeof label == 'number') {
|
if (typeof label.getMonth === 'function' || typeof label === 'number') {
|
||||||
return moment(label);
|
return moment(label);
|
||||||
}
|
}
|
||||||
// Moment support
|
// Moment support
|
||||||
@ -300,7 +300,7 @@ module.exports = function(Chart) {
|
|||||||
}
|
}
|
||||||
// Moment format parsing
|
// Moment format parsing
|
||||||
return moment(label, this.options.time.format);
|
return moment(label, this.options.time.format);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
Chart.scaleService.registerScaleType("time", TimeScale, defaultConfig);
|
Chart.scaleService.registerScaleType("time", TimeScale, defaultConfig);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user