-"use strict";
+'use strict';
module.exports = function(Chart) {
return new Chart(context, config);
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
return new Chart(context, config);
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
return new Chart(context, config);
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
return new Chart(context, config);
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
return new Chart(context, config);
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
-
+
Chart.Radar = function(context, config) {
- config.options = Chart.helpers.configMerge({ aspectRatio: 1 }, config.options);
+ config.options = Chart.helpers.configMerge({aspectRatio: 1}, config.options);
config.type = 'radar';
return new Chart(context, config);
-"use strict";
+'use strict';
module.exports = function(Chart) {
scales: {
xAxes: [{
- type: "linear", // scatter should not use a category axis
- position: "bottom",
- id: "x-axis-1" // need an ID so datasets can reference the scale
+ type: 'linear', // scatter should not use a category axis
+ position: 'bottom',
+ id: 'x-axis-1' // need an ID so datasets can reference the scale
}],
yAxes: [{
- type: "linear",
- position: "left",
- id: "y-axis-1"
+ type: 'linear',
+ position: 'left',
+ id: 'y-axis-1'
}]
},
return new Chart(context, config);
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
Chart.defaults.bar = {
hover: {
- mode: "label"
+ mode: 'label'
},
scales: {
xAxes: [{
- type: "category",
+ type: 'category',
// Specific to Bar Controller
categoryPercentage: 0.8,
}
}],
yAxes: [{
- type: "linear"
+ type: 'linear'
}]
}
};
// it extends bar (like pie extends doughnut)
Chart.defaults.horizontalBar = {
hover: {
- mode: "label"
+ mode: 'label'
},
scales: {
xAxes: [{
- type: "linear",
- position: "bottom"
+ type: 'linear',
+ position: 'bottom'
}],
yAxes: [{
- position: "left",
- type: "category",
+ position: 'left',
+ type: 'category',
// Specific to Horizontal Bar Controller
categoryPercentage: 0.8,
borderWidth: custom.borderWidth ? custom.borderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth)
},
- draw: function () {
+ draw: function() {
var ctx = this._chart.ctx;
var vm = this._view;
}
},
- inRange: function (mouseX, mouseY) {
+ inRange: function(mouseX, mouseY) {
var vm = this._view;
var inRange = false;
rectangle.pivot();
},
- calculateBarBase: function (datasetIndex, index) {
+ calculateBarBase: function(datasetIndex, index) {
var me = this;
var meta = me.getMeta();
var xScale = me.getScaleForId(meta.xAxisID);
return xScale.getBasePixel();
},
- getRuler: function (index) {
+ getRuler: function(index) {
var me = this;
var meta = me.getMeta();
var yScale = me.getScaleForId(meta.yAxisID);
};
},
- calculateBarHeight: function (index) {
+ calculateBarHeight: function(index) {
var me = this;
var yScale = me.getScaleForId(me.getMeta().yAxisID);
if (yScale.options.barThickness) {
return yScale.options.stacked ? ruler.categoryHeight : ruler.barHeight;
},
- calculateBarX: function (index, datasetIndex) {
+ calculateBarX: function(index, datasetIndex) {
var me = this;
var meta = me.getMeta();
var xScale = me.getScaleForId(meta.xAxisID);
return xScale.getPixelForValue(value);
},
- calculateBarY: function (index, datasetIndex) {
+ calculateBarY: function(index, datasetIndex) {
var me = this;
var meta = me.getMeta();
var yScale = me.getScaleForId(meta.yAxisID);
-"use strict";
+'use strict';
module.exports = function(Chart) {
Chart.defaults.bubble = {
hover: {
- mode: "single"
+ mode: 'single'
},
scales: {
xAxes: [{
- type: "linear", // bubble should probably use a linear scale by default
- position: "bottom",
- id: "x-axis-0" // need an ID so datasets can reference the scale
+ type: 'linear', // bubble should probably use a linear scale by default
+ position: 'bottom',
+ id: 'x-axis-0' // need an ID so datasets can reference the scale
}],
yAxes: [{
- type: "linear",
- position: "left",
- id: "y-axis-0"
+ type: 'linear',
+ position: 'left',
+ id: 'y-axis-0'
}]
},
-"use strict";
+'use strict';
module.exports = function(Chart) {
defaults.doughnut = {
animation: {
- //Boolean - Whether we animate the rotation of the Doughnut
+ // Boolean - Whether we animate the rotation of the Doughnut
animateRotate: true,
- //Boolean - Whether we animate scaling the Doughnut from the centre
+ // Boolean - Whether we animate scaling the Doughnut from the centre
animateScale: false
},
aspectRatio: 1,
}
text.push('</ul>');
- return text.join("");
+ return text.join('');
},
legend: {
labels: {
}
},
- //The percentage of the chart that we cut out of the middle.
+ // The percentage of the chart that we cut out of the middle.
cutoutPercentage: 50,
- //The rotation of the chart, where the first data arc begins.
+ // The rotation of the chart, where the first data arc begins.
rotation: Math.PI * -0.5,
- //The total circumference of the chart.
+ // The total circumference of the chart.
circumference: Math.PI * 2.0,
// Need to override these to give a nice default
}
});
- /*if (total === 0) {
+ /* if (total === 0) {
total = NaN;
}*/
}
},
- //gets the max border or hover width to properly scale pie charts
- getMaxBorderWidth: function (elements) {
+ // gets the max border or hover width to properly scale pie charts
+ getMaxBorderWidth: function(elements) {
var max = 0,
index = this.index,
length = elements.length,
-"use strict";
+'use strict';
module.exports = function(Chart) {
spanGaps: false,
hover: {
- mode: "label"
+ mode: 'label'
},
scales: {
xAxes: [{
- type: "category",
+ type: 'category',
id: 'x-axis-0'
}],
yAxes: [{
- type: "linear",
+ type: 'linear',
id: 'y-axis-0'
}]
}
-"use strict";
+'use strict';
module.exports = function(Chart) {
Chart.defaults.polarArea = {
scale: {
- type: "radialLinear",
+ type: 'radialLinear',
lineArc: true, // so that lines are circular
ticks: {
beginAtZero: true
}
},
- //Boolean - Whether to animate the rotation of the chart
+ // Boolean - Whether to animate the rotation of the chart
animation: {
animateRotate: true,
animateScale: true
}
text.push('</ul>');
- return text.join("");
+ return text.join('');
},
legend: {
labels: {
}
}
- //var negHalfPI = -0.5 * Math.PI;
+ // var negHalfPI = -0.5 * Math.PI;
var datasetStartAngle = opts.startAngle;
var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
var startAngle = datasetStartAngle + (circumference * visibleCount);
-"use strict";
+'use strict';
module.exports = function(Chart) {
Chart.defaults.radar = {
scale: {
- type: "radialLinear"
+ type: 'radialLinear'
},
elements: {
line: {
-/*global window: false */
-"use strict";
+/* global window: false */
+'use strict';
module.exports = function(Chart) {
Chart.defaults.global.animation = {
duration: 1000,
- easing: "easeOutQuart",
+ easing: 'easeOutQuart',
onProgress: helpers.noop,
onComplete: helpers.noop
};
Chart.Animation = Chart.Element.extend({
currentStep: null, // the current animation step
numSteps: 60, // default number of steps
- easing: "", // the easing to use for this animation
+ easing: '', // the easing to use for this animation
render: null, // render function used by the animation service
onAnimationProgress: null, // user specified callback to fire on each step of the animation
}
}
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
// Global Chart canvas helpers object for drawing items to canvas
case 'rect':
size = 1 / Math.SQRT2 * radius;
ctx.beginPath();
- ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
+ ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
break;
case 'rectRot':
ctx.stroke();
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
var helpers = Chart.helpers;
- //Create a dictionary of chart types, to allow for extension of existing types
+ // Create a dictionary of chart types, to allow for extension of existing types
Chart.types = {};
- //Store a reference to each instance - allowing us to globally resize chart instances on window resize.
- //Destroy method on the chart will remove the instance of the chart from this reference.
+ // Store a reference to each instance - allowing us to globally resize chart instances on window resize.
+ // Destroy method on the chart will remove the instance of the chart from this reference.
Chart.instances = {};
// Controllers available for dataset visualization eg. bar, line, slice, etc.
}
});
- //Add the chart instance to the global namespace
+ // Add the chart instance to the global namespace
Chart.instances[this.id] = this;
if (this.options.responsive) {
helpers.retinaScale(chart);
// Notify any plugins about the resize
- var newSize = { width: newWidth, height: newHeight };
+ var newSize = {width: newWidth, height: newHeight};
Chart.plugins.notify('resize', [me, newSize]);
// Notify of resize
if (options.scales) {
items = items.concat(
(options.scales.xAxes || []).map(function(xAxisOptions) {
- return { options: xAxisOptions, dtype: 'category' }; }),
+ return {options: xAxisOptions, dtype: 'category'}; }),
(options.scales.yAxes || []).map(function(yAxisOptions) {
- return { options: yAxisOptions, dtype: 'linear' }; }));
+ return {options: yAxisOptions, dtype: 'linear'}; }));
}
if (options.scale) {
- items.push({ options: options.scale, dtype: 'radialLinear', isDefault: true });
+ items.push({options: options.scale, dtype: 'radialLinear', isDefault: true});
}
helpers.each(items, function(item) {
var me = this;
var i, ilen;
- if (Chart.plugins.notify('beforeDatasetsUpdate', [ me ])) {
+ if (Chart.plugins.notify('beforeDatasetsUpdate', [me])) {
for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
me.getDatasetMeta(i).controller.update();
}
- Chart.plugins.notify('afterDatasetsUpdate', [ me ]);
+ Chart.plugins.notify('afterDatasetsUpdate', [me]);
}
},
var animationOptions = me.options.animation;
if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
var animation = new Chart.Animation();
- animation.numSteps = (duration || animationOptions.duration) / 16.66; //60 fps
+ animation.numSteps = (duration || animationOptions.duration) / 16.66; // 60 fps
animation.easing = animationOptions.easing;
// render function
var eventPosition = helpers.getRelativePosition(e, me.chart);
var elementsArray = [];
- var found = (function() {
+ var found = function() {
if (me.data.datasets) {
for (var i = 0; i < me.data.datasets.length; i++) {
var meta = me.getDatasetMeta(i);
}
}
}
- }).call(me);
+ }.call(me);
if (!found) {
return elementsArray;
if (me.isDatasetVisible(datasetIndex)) {
var meta = me.getDatasetMeta(datasetIndex),
element = meta.data[found._index];
- if(element && !element._view.skip){
+ if(element && !element._view.skip) {
elementsArray.push(element);
}
}
var eventPosition = helpers.getRelativePosition(e, me.chart);
var elementsArray = [];
- var found = (function() {
+ var found = function() {
if (me.data.datasets) {
for (var i = 0; i < me.data.datasets.length; i++) {
var meta = me.getDatasetMeta(i);
}
}
}
- }).call(me);
+ }.call(me);
if (!found) {
return elementsArray;
helpers.each(me.data.datasets, function(dataset, datasetIndex) {
if (me.isDatasetVisible(datasetIndex)) {
var meta = me.getDatasetMeta(datasetIndex);
- var index = helpers.findIndex(meta.data, function (it) {
+ var index = helpers.findIndex(meta.data, function(it) {
return found._model.x === it._model.x;
});
if(index !== -1 && !meta.data[index]._view.skip) {
switch (mode) {
case 'single':
- elements = [ elements[0] ];
+ elements = [elements[0]];
break;
case 'label':
case 'dataset':
me.tooltipActive = [];
} else {
me.active = me.getElementsAtEventForMode(e, hoverOptions.mode);
- me.tooltipActive = me.getElementsAtEventForMode(e, tooltipsOptions.mode);
+ me.tooltipActive = me.getElementsAtEventForMode(e, tooltipsOptions.mode);
}
// On Hover hook
-"use strict";
+'use strict';
module.exports = function(Chart) {
});
Chart.DatasetController.extend = helpers.inherits;
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
-/*global window: false */
-/*global document: false */
-"use strict";
+/* global window: false */
+/* global document: false */
+'use strict';
var color = require('chartjs-color');
module.exports = function(Chart) {
- //Global Chart helpers object for utility methods and classes
+ // Global Chart helpers object for utility methods and classes
var helpers = Chart.helpers = {};
- //-- Basic js utility methods
+ // -- Basic js utility methods
helpers.each = function(loopable, callback, self, reverse) {
// Check to see if null or undefined firstly.
var i, len;
}
});
- } 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.
base[key] = helpers.configMerge(base[key], value);
base[key].push(helpers.configMerge(Chart.scaleService.getScaleDefaults(axisType), 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.
base[key] = helpers.configMerge(base[key], value);
}
};
helpers.inherits = function(extensions) {
- //Basic javascript inheritance based on the model created in Backbone.js
+ // Basic javascript inheritance based on the model created in Backbone.js
var parent = this;
- var ChartElement = (extensions && extensions.hasOwnProperty("constructor")) ? extensions.constructor : function() {
+ var ChartElement = (extensions && extensions.hasOwnProperty('constructor')) ? extensions.constructor : function() {
return parent.apply(this, arguments);
};
return id++;
};
}());
- //-- Math methods
+ // -- Math methods
helpers.isNumber = function(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
};
return (pixelWidth % 2 === 0) ? 0 : 0.5;
};
helpers.splineCurve = function(firstPoint, middlePoint, afterPoint, t) {
- //Props to Rob Spencer at scaled innovation for his post on splining between points
- //http://scaledinnovation.com/analytics/splines/aboutSplines.html
+ // Props to Rob Spencer at scaled innovation for his post on splining between points
+ // http://scaledinnovation.com/analytics/splines/aboutSplines.html
// This function must also respect "skipped" points
tauK = 3 / Math.sqrt(squaredMagnitude);
pointCurrent.mK = alphaK * tauK * pointCurrent.deltaK;
- pointAfter.mK = betaK * tauK * pointCurrent.deltaK;
+ pointAfter.mK = betaK * tauK * pointCurrent.deltaK;
}
// Compute control points
return niceFraction * Math.pow(10, exponent);
};
- //Easing functions adapted from Robert Penner's easing equations
- //http://www.robertpenner.com/easing/
+ // Easing functions adapted from Robert Penner's easing equations
+ // http://www.robertpenner.com/easing/
var easingEffects = helpers.easingEffects = {
linear: function(t) {
return t;
return easingEffects.easeOutBounce(t * 2 - 1) * 0.5 + 1 * 0.5;
}
};
- //Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
+ // Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
helpers.requestAnimFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
return window.clearTimeout(callback, 1000 / 60);
};
}());
- //-- DOM methods
+ // -- DOM methods
helpers.getRelativePosition = function(evt, chart) {
var mouseX, mouseY;
var e = evt.originalEvent || evt,
if (node.addEventListener) {
node.addEventListener(eventType, method);
} else if (node.attachEvent) {
- node.attachEvent("on" + eventType, method);
+ node.attachEvent('on' + eventType, method);
} else {
- node["on" + eventType] = method;
+ node['on' + eventType] = method;
}
};
helpers.removeEvent = function(node, eventType, handler) {
if (node.removeEventListener) {
node.removeEventListener(eventType, handler, false);
} else if (node.detachEvent) {
- node.detachEvent("on" + eventType, handler);
+ node.detachEvent('on' + eventType, handler);
} else {
- node["on" + eventType] = helpers.noop;
+ node['on' + eventType] = helpers.noop;
}
};
helpers.bindEvents = function(chartInstance, arrayOfEvents, handler) {
* @private
*/
function isConstrainedValue(value) {
- return value !== undefined && value !== null && value !== 'none';
+ return value !== undefined && value !== null && value !== 'none';
}
// Private helper to get a constraint dimension
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';
};
- //-- Canvas methods
+ // -- Canvas methods
helpers.clear = function(chart) {
chart.ctx.clearRect(0, 0, chart.width, chart.height);
};
helpers.fontString = function(pixelSize, fontStyle, fontFamily) {
- return fontStyle + " " + pixelSize + "px " + fontFamily;
+ return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
};
helpers.longestText = function(ctx, font, arrayOfThings, cache) {
cache = cache || {};
}
return longest;
};
- helpers.measureText = function (ctx, data, gc, longest, string) {
+ helpers.measureText = function(ctx, data, gc, longest, string) {
var textWidth = data[string];
if (!textWidth) {
textWidth = data[string] = ctx.measureText(string).width;
function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
- //! @see http://stackoverflow.com/a/14853974
+ // ! @see http://stackoverflow.com/a/14853974
helpers.arrayEquals = function(a0, a1) {
var i, ilen, v0, v1;
-"use strict";
+'use strict';
module.exports = function() {
- //Occupy the global variable of Chart, and create a simple base class
+ // Occupy the global variable of Chart, and create a simple base class
var Chart = function(context, config) {
var me = this;
var helpers = Chart.helpers;
- me.config = config || {
+ me.config = config || {
data: {
datasets: []
}
// Support a canvas domnode
if (context.getContext) {
- context = context.getContext("2d");
+ context = context.getContext('2d');
}
me.ctx = context;
};
- //Globally expose the defaults to allow for user updating/changing
+ // Globally expose the defaults to allow for user updating/changing
Chart.defaults = {
global: {
responsive: true,
responsiveAnimationDuration: 0,
maintainAspectRatio: true,
- events: ["mousemove", "mouseout", "click", "touchstart", "touchmove"],
+ events: ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'],
hover: {
onHover: null,
mode: 'single',
onClick: null,
defaultColor: 'rgba(0,0,0,0.1)',
defaultFontColor: '#666',
- defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+ defaultFontFamily: '\'Helvetica Neue\', \'Helvetica\', \'Arial\', sans-serif',
defaultFontSize: 12,
defaultFontStyle: 'normal',
showLines: true,
}
text.push('</ul>');
- return text.join("");
+ return text.join('');
}
}
};
-"use strict";
+'use strict';
module.exports = function(Chart) {
var yPadding = 0;
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) {
- return box.options.position === "right";
+ return box.options.position === 'right';
});
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) {
- return box.options.position === "bottom";
+ return box.options.position === 'bottom';
});
// Boxes that overlay the chartarea such as the radialLinear scale
var chartAreaBoxes = helpers.where(chartInstance.boxes, function(box) {
- return box.options.position === "chartArea";
+ return box.options.position === 'chartArea';
});
// Ensure that full width boxes are at the very top / bottom
-"use strict";
+'use strict';
module.exports = function(Chart) {
buildLabels: function() {
var me = this;
me.legendItems = me.options.labels.generateLabels.call(me, me.chart);
- if(me.options.reverse){
+ if(me.options.reverse) {
me.legendItems.reverse();
}
},
var lineWidths = me.lineWidths = [0];
var totalHeight = me.legendItems.length ? fontSize + (labelOpts.padding) : 0;
- ctx.textAlign = "left";
+ ctx.textAlign = 'left';
ctx.textBaseline = 'top';
helpers.each(me.legendItems, function(legendItem, i) {
// Shared Methods
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
labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
// Canvas setup
- ctx.textAlign = "left";
+ ctx.textAlign = 'left';
ctx.textBaseline = 'top';
ctx.lineWidth = 0.5;
ctx.strokeStyle = fontColor; // for strikethrough effect
-"use strict";
+'use strict';
module.exports = function(Chart) {
-"use strict";
+'use strict';
module.exports = function(Chart) {
Chart.defaults.scale = {
display: true,
- position: "left",
+ position: 'left',
// grid line settings
gridLines: {
display: true,
- color: "rgba(0, 0, 0, 0.1)",
+ color: 'rgba(0, 0, 0, 0.1)',
lineWidth: 1,
drawBorder: true,
drawOnChartArea: true,
drawTicks: true,
tickMarkLength: 10,
zeroLineWidth: 1,
- zeroLineColor: "rgba(0,0,0,0.25)",
+ zeroLineColor: 'rgba(0,0,0,0.25)',
offsetGridLines: false,
borderDash: [],
borderDashOffset: 0.0
var globalDefaults = Chart.defaults.global;
var optionTicks = me.options.ticks;
- //Get the width of each grid by calculating the difference
- //between x offsets between 0 and 1.
+ // Get the width of each grid by calculating the difference
+ // between x offsets between 0 and 1.
var tickFontSize = helpers.getValueOrDefault(optionTicks.fontSize, globalDefaults.defaultFontSize);
var tickFontStyle = helpers.getValueOrDefault(optionTicks.fontStyle, globalDefaults.defaultFontStyle);
var tickFontFamily = helpers.getValueOrDefault(optionTicks.fontFamily, globalDefaults.defaultFontFamily);
// only the index matters for a dataset scale, but we want a consistent interface between scales
var tickWidth = me.getPixelForTick(1) - me.getPixelForTick(0) - 6;
- //Max label rotation can be set or default to 90 - also act as a loop counter
+ // Max label rotation can be set or default to 90 - also act as a loop counter
while (labelWidth > tickWidth && me.labelRotation < optionTicks.maxRotation) {
cosRotation = Math.cos(helpers.toRadians(me.labelRotation));
sinRotation = Math.sin(helpers.toRadians(me.labelRotation));
// Shared Methods
isHorizontal: function() {
- return this.options.position === "top" || this.options.position === "bottom";
+ return this.options.position === 'top' || this.options.position === 'bottom';
},
isFullWidth: function() {
return (this.options.fullWidth);
return NaN;
}
// If it is in fact an object, dive in one more level
- if (typeof(rawValue) === "object") {
+ if (typeof(rawValue) === 'object') {
if ((rawValue instanceof Date) || (rawValue.isValid)) {
return rawValue;
} else {
},
// Utility for getting the pixel location of a percentage of scale
- getPixelForDecimal: function(decimal /*, includeOffset*/ ) {
+ getPixelForDecimal: function(decimal /* , includeOffset*/) {
var me = this;
if (me.isHorizontal()) {
var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
}
- var xTickStart = options.position === "right" ? me.left : me.right - tl;
- var xTickEnd = options.position === "right" ? me.left + tl : me.right;
- var yTickStart = options.position === "bottom" ? me.top : me.bottom - tl;
- var yTickEnd = options.position === "bottom" ? me.top + tl : me.bottom;
+ var xTickStart = options.position === 'right' ? me.left : me.right - tl;
+ var xTickEnd = options.position === 'right' ? me.left + tl : me.right;
+ var yTickStart = options.position === 'bottom' ? me.top : me.bottom - tl;
+ var yTickEnd = options.position === 'bottom' ? me.top + tl : me.bottom;
helpers.each(me.ticks, function(label, index) {
// If the callback returned a null or undefined value, do not draw this line
// Draw the first index specially
lineWidth = gridLines.zeroLineWidth;
lineColor = gridLines.zeroLineColor;
- } else {
+ } else {
lineWidth = helpers.getValueAtIndexOrDefault(gridLines.lineWidth, index);
lineColor = helpers.getValueAtIndexOrDefault(gridLines.color, index);
}
-"use strict";
+'use strict';
module.exports = function(Chart) {
});
}
};
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
// These methods are ordered by lifecyle. Utilities then follow.
- beforeUpdate: function () {
+ beforeUpdate: function() {
var chartOpts = this.chart.options;
if (chartOpts && chartOpts.title) {
this.options = helpers.configMerge(Chart.defaults.global.title, chartOpts.title);
// Shared Methods
isHorizontal: function() {
var pos = this.options.position;
- return pos === "top" || pos === "bottom";
+ return pos === 'top' || pos === 'bottom';
},
// Actualy draw the title block on the canvas
-"use strict";
+'use strict';
module.exports = function(Chart) {
enabled: true,
custom: null,
mode: 'single',
- backgroundColor: "rgba(0,0,0,0.8)",
- titleFontStyle: "bold",
+ backgroundColor: 'rgba(0,0,0,0.8)',
+ titleFontStyle: 'bold',
titleSpacing: 2,
titleMarginBottom: 6,
- titleFontColor: "#fff",
- titleAlign: "left",
+ titleFontColor: '#fff',
+ titleAlign: 'left',
bodySpacing: 2,
- bodyFontColor: "#fff",
- bodyAlign: "left",
- footerFontStyle: "bold",
+ bodyFontColor: '#fff',
+ bodyAlign: 'left',
+ footerFontStyle: 'bold',
footerSpacing: 2,
footerMarginTop: 6,
- footerFontColor: "#fff",
- footerAlign: "left",
+ footerFontColor: '#fff',
+ footerAlign: 'left',
yPadding: 6,
xPadding: 6,
- yAlign : 'center',
- xAlign : 'center',
+ yAlign: 'center',
+ xAlign: 'center',
caretSize: 5,
cornerRadius: 6,
multiKeyBackground: '#fff',
function pushOrConcat(base, toPush) {
if (toPush) {
if (helpers.isArray(toPush)) {
- //base = base.concat(toPush);
+ // base = base.concat(toPush);
Array.prototype.push.apply(base, toPush);
} else {
base.push(toPush);
for (i = 0, len = elements.length; i < len; ++i) {
var el = elements[i];
- if (el && el.hasValue()){
+ if (el && el.hasValue()) {
var pos = el.tooltipPosition();
xPositions.push(pos.x);
yPositions.push(pos.y);
var x = 0,
y = 0;
for (i = 0; i < xPositions.length; ++i) {
- if (xPositions[ i ]) {
+ if (xPositions[i]) {
x += xPositions[i];
y += yPositions[i];
}
// Positioning
xPadding: tooltipOpts.xPadding,
yPadding: tooltipOpts.yPadding,
- xAlign : tooltipOpts.xAlign,
- yAlign : tooltipOpts.yAlign,
+ xAlign: tooltipOpts.xAlign,
+ yAlign: tooltipOpts.yAlign,
// Body
bodyFontColor: tooltipOpts.bodyFontColor,
// If the user provided a sorting function, use it to modify the tooltip items
if (opts.itemSort) {
- tooltipItems = tooltipItems.sort(function(a,b) {
- return opts.itemSort(a,b, data);
+ tooltipItems = tooltipItems.sort(function(a, b) {
+ return opts.itemSort(a, b, data);
});
}
if (title.length) {
ctx.textAlign = vm._titleAlign;
- ctx.textBaseline = "top";
+ ctx.textBaseline = 'top';
var titleFontSize = vm.titleFontSize,
titleSpacing = vm.titleSpacing;
var body = vm.body;
ctx.textAlign = vm._bodyAlign;
- ctx.textBaseline = "top";
+ ctx.textBaseline = 'top';
var bodyFontColor = helpers.color(vm.bodyFontColor);
var textColor = bodyFontColor.alpha(opacity * bodyFontColor.alpha()).rgbString();
pt.y += vm.footerMarginTop;
ctx.textAlign = vm._footerAlign;
- ctx.textBaseline = "top";
+ ctx.textBaseline = 'top';
var footerFontColor = helpers.color(vm.footerFontColor);
ctx.fillStyle = footerFontColor.alpha(opacity * footerFontColor.alpha()).rgbString();
-"use strict";
+'use strict';
module.exports = function(Chart) {
globalOpts.elements.arc = {
backgroundColor: globalOpts.defaultColor,
- borderColor: "#fff",
+ borderColor: '#fff',
borderWidth: 2
};
angle = pointRelativePosition.angle,
distance = pointRelativePosition.distance;
- //Sanitise angle range
+ // Sanitise angle range
var startAngle = vm.startAngle;
var endAngle = vm.endAngle;
while (endAngle < startAngle) {
angle += 2.0 * Math.PI;
}
- //Check if within the range of the open/close angle
+ // Check if within the range of the open/close angle
var betweenAngles = (angle >= startAngle && angle <= endAngle),
withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius);
-"use strict";
+'use strict';
module.exports = function(Chart) {
var vm = point._view;
if (point._view.steppedLine === true) {
ctx.lineTo(point._view.x, previousPoint._view.y);
- ctx.lineTo(point._view.x, point._view.y);
+ ctx.lineTo(point._view.x, point._view.y);
} else if (point._view.tension === 0) {
ctx.lineTo(vm.x, vm.y);
} else {
}
} else {
if (lastDrawnIndex !== (index - 1)) {
- // There was a gap and this is the first point after the gap. If we've never drawn a point, this is a special case.
+ // There was a gap and this is the first point after the gap. If we've never drawn a point, this is a special case.
// If the first data point is NaN, then there is no real gap to skip
if (spanGaps && lastDrawnIndex !== -1) {
// We are spanning the gap, so simple draw a line to this point
ctx.restore();
}
});
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
-"use strict";
+'use strict';
module.exports = function(Chart) {
}
});
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
var helpers = Chart.helpers;
// Default config for a category scale
var defaultConfig = {
- position: "bottom"
+ position: 'bottom'
};
var DatasetScale = Chart.Scale.extend({
}
});
- Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig);
+ Chart.scaleService.registerScaleType('category', DatasetScale, defaultConfig);
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
var helpers = Chart.helpers;
var defaultConfig = {
- position: "left",
+ position: 'left',
ticks: {
callback: function(tickValue, index, ticks) {
// If we have lots of ticks, don't use the ones
return this.getPixelForValue(this.ticksAsNumbers[index]);
}
});
- Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);
+ Chart.scaleService.registerScaleType('linear', LinearScale, defaultConfig);
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
Chart.Scale.prototype.convertTicksToLabels.call(me);
}
});
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
var helpers = Chart.helpers;
var defaultConfig = {
- position: "left",
+ position: 'left',
// label settings
ticks: {
callback: function(value, index, arr) {
var remain = value / (Math.pow(10, Math.floor(helpers.log10(value))));
- if (value === 0){
+ if (value === 0) {
return '0';
} else if (remain === 1 || remain === 2 || remain === 5 || index === 0 || index === arr.length - 1) {
return value.toExponential();
var exp;
var significand;
- if(tickVal === 0){
+ if(tickVal === 0) {
exp = Math.floor(helpers.log10(me.minNotZero));
significand = Math.round(me.minNotZero / Math.pow(10, exp));
} else {
} else {
// Bottom - top since pixels increase downard on a screen
innerDimension = me.height - (paddingTop + paddingBottom);
- if(start === 0 && !tickOpts.reverse){
+ if(start === 0 && !tickOpts.reverse) {
range = helpers.log10(me.end) - helpers.log10(me.minNotZero);
if (newVal === start) {
pixel = me.bottom - paddingBottom;
- } else if(newVal === me.minNotZero){
+ } else if(newVal === me.minNotZero) {
pixel = me.bottom - paddingBottom - innerDimension * 0.02;
} else {
pixel = me.bottom - paddingBottom - innerDimension * 0.02 - (innerDimension * 0.98/ range * (helpers.log10(newVal)-helpers.log10(me.minNotZero)));
}
- } else if (me.end === 0 && tickOpts.reverse){
+ } else if (me.end === 0 && tickOpts.reverse) {
range = helpers.log10(me.start) - helpers.log10(me.minNotZero);
if (newVal === me.end) {
pixel = me.top + paddingTop;
- } else if(newVal === me.minNotZero){
+ } else if(newVal === me.minNotZero) {
pixel = me.top + paddingTop + innerDimension * 0.02;
} else {
pixel = me.top + paddingTop + innerDimension * 0.02 + (innerDimension * 0.98/ range * (helpers.log10(newVal)-helpers.log10(me.minNotZero)));
return value;
}
});
- Chart.scaleService.registerScaleType("logarithmic", LogarithmicScale, defaultConfig);
+ Chart.scaleService.registerScaleType('logarithmic', LogarithmicScale, defaultConfig);
-};
\ No newline at end of file
+};
-"use strict";
+'use strict';
module.exports = function(Chart) {
var defaultConfig = {
display: true,
- //Boolean - Whether to animate scaling the chart from the centre
+ // Boolean - Whether to animate scaling the chart from the centre
animate: true,
lineArc: false,
- position: "chartArea",
+ position: 'chartArea',
angleLines: {
display: true,
- color: "rgba(0, 0, 0, 0.1)",
+ color: 'rgba(0, 0, 0, 0.1)',
lineWidth: 1
},
// label settings
ticks: {
- //Boolean - Show a backdrop to the scale label
+ // Boolean - Show a backdrop to the scale label
showLabelBackdrop: true,
- //String - The colour of the label backdrop
- backdropColor: "rgba(255,255,255,0.75)",
+ // String - The colour of the label backdrop
+ backdropColor: 'rgba(255,255,255,0.75)',
- //Number - The backdrop padding above & below the label in pixels
+ // Number - The backdrop padding above & below the label in pixels
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
},
pointLabels: {
- //Number - Point label font size in pixels
+ // Number - Point label font size in pixels
fontSize: 10,
- //Function - Used to convert point labels
+ // Function - Used to convert point labels
callback: function(label) {
return label;
}
}
ctx.textAlign = 'center';
- ctx.textBaseline = "middle";
+ ctx.textBaseline = 'middle';
ctx.fillStyle = tickFontColor;
ctx.fillText(label, me.xCenter, yHeight);
}
}
}
});
- Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale, defaultConfig);
+ Chart.scaleService.registerScaleType('radialLinear', LinearRadialScale, defaultConfig);
};
-/*global window: false */
-"use strict";
+/* global window: false */
+'use strict';
var moment = require('moment');
moment = typeof(moment) === 'function' ? moment : window.moment;
};
var defaultConfig = {
- position: "bottom",
+ position: 'bottom',
time: {
parser: false, // false == a pattern string from http://momentjs.com/docs/#/parsing/string-format/ or a custom callback that converts its argument to a moment
}
// Custom parsing (return an instance of moment)
if (typeof me.options.time.format !== 'string' && me.options.time.format.call) {
- console.warn("options.time.format is deprecated and replaced by options.time.parser. See http://nnnick.github.io/Chart.js/docs-v2/#scales-time-scale");
+ console.warn('options.time.format is deprecated and replaced by options.time.parser. See http://nnnick.github.io/Chart.js/docs-v2/#scales-time-scale');
return me.options.time.format(label);
}
// Moment format parsing
return moment(label, me.options.time.format);
}
});
- Chart.scaleService.registerScaleType("time", TimeScale, defaultConfig);
+ Chart.scaleService.registerScaleType('time', TimeScale, defaultConfig);
};