//Globally expose the defaults to allow for user updating/changing
Chart.defaults = {
global: {
- // Boolean - Whether to animate the chart
- animation: true,
- // Number - Number of animation steps
- animationDuration: 1000,
+ // Animation defaults
+ animation: {
+ // Number - Number of animation steps
+ duration: 1000,
- // String - Animation easing effect
- animationEasing: "easeOutQuart",
+ // String - Animation easing effect
+ easing: "easeOutQuart",
- // Boolean - If we should show the scale at all
- showScale: true,
+ // Function - Will fire on animation progression.
+ onProgress: function() {},
- // Boolean - If we want to override with a hard coded scale
- scaleOverride: false,
-
- // ** Required if scaleOverride is true **
- // Number - The number of steps in a hard coded scale
- scaleSteps: null,
- // Number - The value jump in the hard coded scale
- scaleStepWidth: null,
- // Number - The scale starting value
- scaleStartValue: null,
-
- // String - Colour of the scale line
- scaleLineColor: "rgba(0,0,0,.1)",
-
- // Number - Pixel width of the scale line
- scaleLineWidth: 1,
-
- // Boolean - Whether to show labels on the scale
- scaleShowLabels: true,
-
- // Interpolated JS string - can access value
- scaleLabel: "<%=value%>",
-
- // Boolean - Whether the scale should stick to integers, and not show any floats even if drawing space is there
- scaleIntegersOnly: true,
-
- // Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
- scaleBeginAtZero: false,
-
- // String - Scale label font declaration for the scale label
- scaleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
-
- // Number - Scale label font size in pixels
- scaleFontSize: 12,
-
- // String - Scale label font weight style
- scaleFontStyle: "normal",
-
- // String - Scale label font colour
- scaleFontColor: "#666",
+ // Function - Will fire on animation completion.
+ onComplete: function() {},
+ },
// Boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: false,
// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,
- //String / Boolean - Hover mode for events.
- hoverMode: 'single', // 'label', 'dataset', 'false'
+ // Array - Array of string names to attach interaction events
+ events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"],
- //Function(event) - Custom hover handler
- onHover: null,
+ // Hover defaults
+ hover: {
- //Function(event, clickedElements) - Custom click handler
- onClick: null,
+ // String || boolean
+ mode: 'single', // 'label', 'dataset', 'false'
- //Function - Custom hover handler
- hoverAnimationDuration: 400,
+ //Function(event, activeElements) - Custom hover handler
+ onHover: null,
- // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove
- showTooltips: true,
+ //Function - Custom hover handler
+ animationDuration: 400,
+ },
- // Boolean - Determines whether to draw built-in tooltip or call custom tooltip function
- customTooltips: false,
+ //Function(event, clickedElements) - Custom click handler
+ onClick: null,
- // Array - Array of string names to attach interaction events
- events: ["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"],
+ // Tooltip Defaults
+ tooltips: {
+
+ // Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove
+ enabled: true,
- // String - Tooltip background colour
- tooltipBackgroundColor: "rgba(0,0,0,0.8)",
+ // Function - Determines whether to draw built-in tooltip or call custom tooltip function
+ custom: null,
- // String - Tooltip label font declaration for the scale label
- tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+ // String - Tooltip background colour
+ backgroundColor: "rgba(0,0,0,0.8)",
- // Number - Tooltip label font size in pixels
- tooltipFontSize: 14,
+ // String - Tooltip label font declaration for the scale label
+ fontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
- // String - Tooltip font weight style
- tooltipFontStyle: "normal",
+ // Number - Tooltip label font size in pixels
+ fontSize: 14,
- // String - Tooltip label font colour
- tooltipFontColor: "#fff",
+ // String - Tooltip font weight style
+ fontStyle: "normal",
- // String - Tooltip title font declaration for the scale label
- tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+ // String - Tooltip label font colour
+ fontColor: "#fff",
- // Number - Tooltip title font size in pixels
- tooltipTitleFontSize: 14,
+ // String - Tooltip title font declaration for the scale label
+ titleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
- // String - Tooltip title font weight style
- tooltipTitleFontStyle: "bold",
+ // Number - Tooltip title font size in pixels
+ titleFontSize: 14,
- // String - Tooltip title font colour
- tooltipTitleFontColor: "#fff",
+ // String - Tooltip title font weight style
+ titleFontStyle: "bold",
- // Number - pixel width of padding around tooltip text
- tooltipYPadding: 6,
+ // String - Tooltip title font colour
+ titleFontColor: "#fff",
- // Number - pixel width of padding around tooltip text
- tooltipXPadding: 6,
+ // Number - pixel width of padding around text
+ yPadding: 6,
- // Number - Size of the caret on the tooltip
- tooltipCaretSize: 8,
+ // Number - pixel width of padding around text
+ xPadding: 6,
- // Number - Pixel radius of the tooltip border
- tooltipCornerRadius: 6,
+ // Number - Size of the caret on the
+ caretSize: 8,
- // Number - Pixel offset from point x to tooltip edge
- tooltipXOffset: 10,
+ // Number - Pixel radius of the border
+ cornerRadius: 6,
- // String - Template string for single tooltips
- tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",
+ // Number - Pixel offset from point x to edge
+ xOffset: 10,
- // String - Template string for single tooltips
- multiTooltipTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",
+ // String - Template string for singles
+ template: "<%if (label){%><%=label%>: <%}%><%= value %>",
- // String - Colour behind the legend colour block
- multiTooltipKeyBackground: '#fff',
+ // String - Template string for singles
+ multiTemplate: "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",
- // Function - Will fire on animation progression.
- onAnimationProgress: function() {},
+ // String - Colour behind the legend colour block
+ multiKeyBackground: '#fff',
- // Function - Will fire on animation completion.
- onAnimationComplete: function() {},
+ },
// Color String - Used for undefined Colros
defaultColor: 'rgba(0,0,0,0.1)',
baseArray.push(valueObj); // nothing to merge
}
});
- }
- else if (base.hasOwnProperty(key) && typeof base[key] == "object" && typeof value == "object") {
+ } else if (base.hasOwnProperty(key) && typeof base[key] == "object" && 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);
} else {
}
});
});
-
+
return base;
},
indexOf = helpers.indexOf = function(arrayToSearch, item) {
min = helpers.min = function(array) {
return Math.min.apply(Math, array);
},
- sign = helpers.sign = function(x) {
- if (Math.sign) {
- return Math.sign(x);
- } else {
- x = +x; // convert to a number
- if (x === 0 || isNaN(x)) {
- return x;
- }
- return x > 0 ? 1 : -1;
- }
- },
+ sign = helpers.sign = function(x) {
+ if (Math.sign) {
+ return Math.sign(x);
+ } else {
+ x = +x; // convert to a number
+ if (x === 0 || isNaN(x)) {
+ return x;
+ }
+ return x > 0 ? 1 : -1;
+ }
+ },
cap = helpers.cap = function(valueToCap, maxValue, minValue) {
if (isNumber(maxValue)) {
if (valueToCap > maxValue) {
toRadians = helpers.toRadians = function(degrees) {
return degrees * (Math.PI / 180);
},
- toDegrees = helpers.toDegrees = function(radians) {
- return radians * (180 / Math.PI);
- },
+ toDegrees = helpers.toDegrees = function(radians) {
+ return radians * (180 / Math.PI);
+ },
// Gets the angle from vertical upright to the point about a centre.
getAngleFromPoint = helpers.getAngleFromPoint = function(centrePoint, anglePoint) {
var distanceFromXCenter = anglePoint.x - centrePoint.x,
};
},
- // Implementation of the nice number algorithm used in determining where axis labels will go
- niceNum = helpers.niceNum = function(range, round) {
- var exponent = Math.floor(Math.log10(range));
- var fraction = range / Math.pow(10, exponent);
- var niceFraction;
-
- if (round) {
- if (fraction < 1.5) {
- niceFraction = 1;
- } else if (fraction < 3) {
- niceFraction = 2;
- } else if (fraction < 7) {
- niceFraction = 5;
- } else {
- niceFraction = 10;
- }
- } else {
- if (fraction <= 1.0) {
- niceFraction = 1;
- } else if (fraction <= 2) {
- niceFraction = 2;
- } else if (fraction <= 5) {
- niceFraction = 5;
- } else {
- niceFraction = 10;
- }
- }
-
- return niceFraction * Math.pow(10, exponent);
- },
+ // Implementation of the nice number algorithm used in determining where axis labels will go
+ niceNum = helpers.niceNum = function(range, round) {
+ var exponent = Math.floor(Math.log10(range));
+ var fraction = range / Math.pow(10, exponent);
+ var niceFraction;
+
+ if (round) {
+ if (fraction < 1.5) {
+ niceFraction = 1;
+ } else if (fraction < 3) {
+ niceFraction = 2;
+ } else if (fraction < 7) {
+ niceFraction = 5;
+ } else {
+ niceFraction = 10;
+ }
+ } else {
+ if (fraction <= 1.0) {
+ niceFraction = 1;
+ } else if (fraction <= 2) {
+ niceFraction = 2;
+ } else if (fraction <= 5) {
+ niceFraction = 5;
+ } else {
+ niceFraction = 10;
+ }
+ }
+
+ return niceFraction * Math.pow(10, exponent);
+ },
/* jshint ignore:start */
// Blows up jshint errors based on the new Function constructor
//Templating methods