language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | chartjs | Chart.js | c81a55fed1d9da9f97cc26391083876e5471e84f.json | Add jsDelivr as CDN install option (#4881) | docs/getting-started/installation.md | @@ -3,6 +3,7 @@ Chart.js can be installed via npm or bower. It is recommended to get Chart.js th
## npm
[](https://npmjs.com/package/chart.js)
+[](https://npmjs.com/package/chart.js)
```bash
npm install chart.js --save
@@ -16,9 +17,19 @@ bower install chart.js --save
```
## CDN
-[](https://cdnjs.com/libraries/Chart.js)
+### CDNJS
+[](https://cdnjs.com/libraries/Chart.js)
-or just use these [Chart.js CDN](https://cdnjs.com/libraries/Chart.js) links.
+Chart.js built files are available on [CDNJS](https://cdnjs.com/):
+
+https://cdnjs.com/libraries/Chart.js
+
+### jsDelivr
+[](https://cdn.jsdelivr.net/npm/chart.js@latest/dist/) [](https://www.jsdelivr.com/package/npm/chart.js)
+
+Chart.js built files are also available through [jsDelivr](http://www.jsdelivr.com/):
+
+https://www.jsdelivr.com/package/npm/chart.js?path=dist
## Github
[](https://github.com/chartjs/Chart.js/releases/latest) | false |
Other | chartjs | Chart.js | 3fe198c86098ae50d5d5e9b74d111d5f8fa74bf0.json | Fix responsive issue when the chart is recreated (#4774)
Chrome specific issue that happens when destroying a chart and re-creating it immediately (same animation frame?). The CSS animation used to detect when the canvas become visible is not re-evaluated, breaking responsiveness. Accessing the `offsetParent` property will force a reflow and re-evaluate the CSS animation. | src/platforms/platform.dom.js | @@ -236,6 +236,13 @@ function watchForRender(node, handler) {
addEventListener(node, type, proxy);
});
+ // #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR class
+ // is removed then added back immediately (same animation frame?). Accessing the
+ // `offsetParent` property will force a reflow and re-evaluate the CSS animation.
+ // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics
+ // https://github.com/chartjs/Chart.js/issues/4737
+ expando.reflow = !!node.offsetParent;
+
node.classList.add(CSS_RENDER_MONITOR);
}
| true |
Other | chartjs | Chart.js | 3fe198c86098ae50d5d5e9b74d111d5f8fa74bf0.json | Fix responsive issue when the chart is recreated (#4774)
Chrome specific issue that happens when destroying a chart and re-creating it immediately (same animation frame?). The CSS animation used to detect when the canvas become visible is not re-evaluated, breaking responsiveness. Accessing the `offsetParent` property will force a reflow and re-evaluate the CSS animation. | test/jasmine.utils.js | @@ -75,7 +75,13 @@ function acquireChart(config, options) {
wrapper.appendChild(canvas);
window.document.body.appendChild(wrapper);
- chart = new Chart(canvas.getContext('2d'), config);
+ try {
+ chart = new Chart(canvas.getContext('2d'), config);
+ } catch (e) {
+ window.document.body.removeChild(wrapper);
+ throw e;
+ }
+
chart.$test = {
persistent: options.persistent,
wrapper: wrapper | true |
Other | chartjs | Chart.js | 3fe198c86098ae50d5d5e9b74d111d5f8fa74bf0.json | Fix responsive issue when the chart is recreated (#4774)
Chrome specific issue that happens when destroying a chart and re-creating it immediately (same animation frame?). The CSS animation used to detect when the canvas become visible is not re-evaluated, breaking responsiveness. Accessing the `offsetParent` property will force a reflow and re-evaluate the CSS animation. | test/specs/core.controller.tests.js | @@ -495,6 +495,45 @@ describe('Chart', function() {
});
});
});
+
+ // https://github.com/chartjs/Chart.js/issues/4737
+ it('should resize the canvas when re-creating the chart', function(done) {
+ var chart = acquireChart({
+ options: {
+ responsive: true
+ }
+ }, {
+ wrapper: {
+ style: 'width: 320px'
+ }
+ });
+
+ waitForResize(chart, function() {
+ var canvas = chart.canvas;
+ expect(chart).toBeChartOfSize({
+ dw: 320, dh: 320,
+ rw: 320, rh: 320,
+ });
+
+ chart.destroy();
+ chart = new Chart(canvas, {
+ type: 'line',
+ options: {
+ responsive: true
+ }
+ });
+
+ canvas.parentNode.style.width = '455px';
+ waitForResize(chart, function() {
+ expect(chart).toBeChartOfSize({
+ dw: 455, dh: 455,
+ rw: 455, rh: 455,
+ });
+
+ done();
+ });
+ });
+ });
});
describe('config.options.responsive: true (maintainAspectRatio: true)', function() {
@@ -627,7 +666,7 @@ describe('Chart', function() {
});
});
- describe('config.options.devicePixelRatio 3', function() {
+ describe('config.options.devicePixelRatio', function() {
beforeEach(function() {
this.devicePixelRatio = window.devicePixelRatio;
window.devicePixelRatio = 1; | true |
Other | chartjs | Chart.js | 0bd0654efb4a19f192a485d88daadbe8ee2f44c0.json | fix colour settings of BeforeLabel and BeforeBody (#4783)
* fix colour settings of BeforeLabel and BeforeBody
* delete redundant variable declaration
* collect label colour setting. | src/core/core.tooltip.js | @@ -677,13 +677,16 @@ module.exports = function(Chart) {
};
// Before body lines
+ ctx.fillStyle = mergeOpacity(vm.bodyFontColor, opacity);
helpers.each(vm.beforeBody, fillLineOfText);
var drawColorBoxes = vm.displayColors;
xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;
// Draw body lines now
helpers.each(body, function(bodyItem, i) {
+ var textColor = mergeOpacity(vm.labelTextColors[i], opacity);
+ ctx.fillStyle = textColor;
helpers.each(bodyItem.before, fillLineOfText);
helpers.each(bodyItem.lines, function(line) {
@@ -701,7 +704,6 @@ module.exports = function(Chart) {
// Inner square
ctx.fillStyle = mergeOpacity(vm.labelColors[i].backgroundColor, opacity);
ctx.fillRect(pt.x + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2);
- var textColor = mergeOpacity(vm.labelTextColors[i], opacity);
ctx.fillStyle = textColor;
}
| false |
Other | chartjs | Chart.js | 52145de5db5dc3bae093880429b35954f0034993.json | Fix regression in x-axis interaction mode (#4762) | src/core/core.interaction.js | @@ -215,7 +215,7 @@ module.exports = {
* @private
*/
'x-axis': function(chart, e) {
- return indexMode(chart, e, {intersect: true});
+ return indexMode(chart, e, {intersect: false});
},
/** | true |
Other | chartjs | Chart.js | 52145de5db5dc3bae093880429b35954f0034993.json | Fix regression in x-axis interaction mode (#4762) | test/specs/global.deprecations.tests.js | @@ -325,6 +325,45 @@ describe('Deprecations', function() {
});
});
+ describe('Version 2.4.0', function() {
+ describe('x-axis mode', function() {
+ it ('behaves like index mode with intersect: false', function() {
+ var data = {
+ datasets: [{
+ label: 'Dataset 1',
+ data: [10, 20, 30],
+ pointHoverBorderColor: 'rgb(255, 0, 0)',
+ pointHoverBackgroundColor: 'rgb(0, 255, 0)'
+ }, {
+ label: 'Dataset 2',
+ data: [40, 40, 40],
+ pointHoverBorderColor: 'rgb(0, 0, 255)',
+ pointHoverBackgroundColor: 'rgb(0, 255, 255)'
+ }],
+ labels: ['Point 1', 'Point 2', 'Point 3']
+ };
+
+ var chart = window.acquireChart({
+ type: 'line',
+ data: data
+ });
+ var meta0 = chart.getDatasetMeta(0);
+ var meta1 = chart.getDatasetMeta(1);
+
+ var evt = {
+ type: 'click',
+ chart: chart,
+ native: true, // needed otherwise things its a DOM event
+ x: 0,
+ y: 0
+ };
+
+ var elements = Chart.Interaction.modes['x-axis'](chart, evt);
+ expect(elements).toEqual([meta0.data[0], meta1.data[0]]);
+ });
+ });
+ });
+
describe('Version 2.1.5', function() {
// https://github.com/chartjs/Chart.js/pull/2752
describe('Chart.pluginService', function() { | true |
Other | chartjs | Chart.js | 4396a5304172820ed33b0cc2f90458f76796c432.json | Expand scale jsdocs (#4736) | src/core/core.scale.js | @@ -538,17 +538,33 @@ module.exports = function(Chart) {
return rawValue;
},
- // Used to get the value to display in the tooltip for the data at the given index
- // function getLabelForIndex(index, datasetIndex)
+ /**
+ * Used to get the value to display in the tooltip for the data at the given index
+ * @param index
+ * @param datasetIndex
+ */
getLabelForIndex: helpers.noop,
- // Used to get data value locations. Value can either be an index or a numerical value
+ /**
+ * Returns the location of the given data point. Value can either be an index or a numerical value
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ * @param value
+ * @param index
+ * @param datasetIndex
+ */
getPixelForValue: helpers.noop,
- // Used to get the data value from a given pixel. This is the inverse of getPixelForValue
+ /**
+ * Used to get the data value from a given pixel. This is the inverse of getPixelForValue
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ * @param pixel
+ */
getValueForPixel: helpers.noop,
- // Used for tick location, should
+ /**
+ * Returns the location of the tick at the given index
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
getPixelForTick: function(index) {
var me = this;
var offset = me.options.offset;
@@ -569,7 +585,10 @@ module.exports = function(Chart) {
return me.top + (index * (innerHeight / (me._ticks.length - 1)));
},
- // Utility for getting the pixel location of a percentage of scale
+ /**
+ * Utility for getting the pixel location of a percentage of scale
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
getPixelForDecimal: function(decimal) {
var me = this;
if (me.isHorizontal()) {
@@ -583,6 +602,10 @@ module.exports = function(Chart) {
return me.top + (decimal * me.height);
},
+ /**
+ * Returns the pixel for the minimum chart value
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
+ */
getBasePixel: function() {
return this.getPixelForValue(this.getBaseValue());
}, | false |
Other | chartjs | Chart.js | 543c31d5496526a47123a923fef95c22f6980f4d.json | Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page. | README.md | @@ -1,8 +1,6 @@
# Chart.js
-[](https://travis-ci.org/chartjs/Chart.js) [](https://codeclimate.com/github/chartjs/Chart.js) [](https://coveralls.io/github/chartjs/Chart.js?branch=master)
-
-[](https://chart-js-automation.herokuapp.com/)
+[](https://travis-ci.org/chartjs/Chart.js) [](https://codeclimate.com/github/chartjs/Chart.js) [](https://coveralls.io/github/chartjs/Chart.js?branch=master) [](https://chart-js-automation.herokuapp.com/)
*Simple HTML5 Charts using the canvas element* [chartjs.org](http://www.chartjs.org)
| true |
Other | chartjs | Chart.js | 543c31d5496526a47123a923fef95c22f6980f4d.json | Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page. | docs/README.md | @@ -1,6 +1,6 @@
# Chart.js
-[](https://chart-js-automation.herokuapp.com/)
+[](https://chart-js-automation.herokuapp.com/)
## Installation
| true |
Other | chartjs | Chart.js | 543c31d5496526a47123a923fef95c22f6980f4d.json | Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page. | docs/getting-started/installation.md | @@ -2,22 +2,27 @@
Chart.js can be installed via npm or bower. It is recommended to get Chart.js this way.
## npm
+[](https://npmjs.com/package/chart.js)
```bash
npm install chart.js --save
```
## Bower
+[](https://libraries.io/bower/chartjs)
```bash
bower install chart.js --save
```
## CDN
-or just use these [Chart.js CDN](https://cdnjs.com/libraries/Chart.js) links.
+[](https://cdnjs.com/libraries/Chart.js)
+or just use these [Chart.js CDN](https://cdnjs.com/libraries/Chart.js) links.
## Github
+[](https://github.com/chartjs/Chart.js/releases/latest)
+
You can download the latest version of [Chart.js on GitHub](https://github.com/chartjs/Chart.js/releases/latest).
If you download or clone the repository, you must [build](../developers/contributing.md#building-chartjs) Chart.js to generate the dist files. Chart.js no longer comes with prebuilt release versions, so an alternative option to downloading the repo is **strongly** advised.
@@ -38,4 +43,4 @@ Files:
* `dist/Chart.bundle.js`
* `dist/Chart.bundle.min.js`
-The bundled version includes Moment.js built into the same file. This version should be used if you wish to use time axes and want a single file to include. Do not use this build if your application already includes Moment.js. If you do, Moment.js will be included twice, increasing the page load time and potentially introducing version issues.
\ No newline at end of file
+The bundled version includes Moment.js built into the same file. This version should be used if you wish to use time axes and want a single file to include. Do not use this build if your application already includes Moment.js. If you do, Moment.js will be included twice, increasing the page load time and potentially introducing version issues. | true |
Other | chartjs | Chart.js | 543c31d5496526a47123a923fef95c22f6980f4d.json | Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page. | samples/charts/area/line-boundaries.html | @@ -35,11 +35,11 @@
};
function generateData(config) {
- return utils.numbers(utils.merge(inputs, config || {}));
+ return utils.numbers(Chart.helpers.merge(inputs, config || {}));
}
function generateLabels(config) {
- return utils.months(utils.merge({
+ return utils.months(Chart.helpers.merge({
count: inputs.count,
section: 3
}, config || {}));
@@ -85,7 +85,7 @@
fill: boundary
}]
},
- options: utils.merge(options, {
+ options: Chart.helpers.merge(options, {
title: {
text: 'fill: ' + boundary,
display: true | true |
Other | chartjs | Chart.js | 543c31d5496526a47123a923fef95c22f6980f4d.json | Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page. | samples/index.html | @@ -7,6 +7,7 @@
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" href="favicon.ico">
<script src="samples.js"></script>
+ <script src="utils.js"></script>
<title>Chart.js samples</title>
</head>
<body> | true |
Other | chartjs | Chart.js | 543c31d5496526a47123a923fef95c22f6980f4d.json | Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page. | samples/utils.js | @@ -1,5 +1,3 @@
-/* global Chart */
-
'use strict';
window.chartColors = {
@@ -41,6 +39,8 @@ window.chartColors = {
];
var Samples = global.Samples || (global.Samples = {});
+ var Color = global.Color;
+
Samples.utils = {
// Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
srand: function(seed) {
@@ -119,18 +119,29 @@ window.chartColors = {
transparentize: function(color, opacity) {
var alpha = opacity === undefined ? 0.5 : 1 - opacity;
- return Chart.helpers.color(color).alpha(alpha).rgbString();
- },
-
- merge: Chart.helpers.configMerge
+ return Color(color).alpha(alpha).rgbString();
+ }
};
- Samples.utils.srand(Date.now());
-
// DEPRECATED
window.randomScalingFactor = function() {
return Math.round(Samples.utils.rand(-100, 100));
};
-}(this));
+ // INITIALIZATION
+
+ Samples.utils.srand(Date.now());
+ // Google Analytics
+ /* eslint-disable */
+ if (document.location.hostname.match(/^(www\.)?chartjs\.org$/)) {
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ ga('create', 'UA-28909194-3', 'auto');
+ ga('send', 'pageview');
+ }
+ /* eslint-enable */
+
+}(this)); | true |
Other | chartjs | Chart.js | c7464ebf91af37482912b434a9e5dc25cf46666e.json | Add platform basic implementation (fallback) (#4708)
If `window` or `document` are `undefined`, a minimal platform implementation is used instead, which one only returns a context2d read from the given canvas/context. | src/platforms/platform.basic.js | @@ -0,0 +1,15 @@
+/**
+ * Platform fallback implementation (minimal).
+ * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939
+ */
+
+module.exports = {
+ acquireContext: function(item) {
+ if (item && item.canvas) {
+ // Support for any object associated to a canvas (including a context2d)
+ item = item.canvas;
+ }
+
+ return item && item.getContext('2d') || null;
+ }
+}; | true |
Other | chartjs | Chart.js | c7464ebf91af37482912b434a9e5dc25cf46666e.json | Add platform basic implementation (fallback) (#4708)
If `window` or `document` are `undefined`, a minimal platform implementation is used instead, which one only returns a context2d read from the given canvas/context. | src/platforms/platform.dom.js | @@ -305,6 +305,13 @@ function injectCSS(platform, css) {
}
module.exports = {
+ /**
+ * This property holds whether this platform is enabled for the current environment.
+ * Currently used by platform.js to select the proper implementation.
+ * @private
+ */
+ _enabled: typeof window !== 'undefined' && typeof document !== 'undefined',
+
initialize: function() {
var keyframes = 'from{opacity:0.99}to{opacity:1}';
| true |
Other | chartjs | Chart.js | c7464ebf91af37482912b434a9e5dc25cf46666e.json | Add platform basic implementation (fallback) (#4708)
If `window` or `document` are `undefined`, a minimal platform implementation is used instead, which one only returns a context2d read from the given canvas/context. | src/platforms/platform.js | @@ -1,10 +1,11 @@
'use strict';
var helpers = require('../helpers/index');
+var basic = require('./platform.basic');
+var dom = require('./platform.dom');
-// By default, select the browser (DOM) platform.
// @TODO Make possible to select another platform at build time.
-var implementation = require('./platform.dom');
+var implementation = dom._enabled ? dom : basic;
/**
* @namespace Chart.platform | true |
Other | chartjs | Chart.js | 459c81d9316e3fa7c02e8670467e7727096c3875.json | Remove trailing `.js` in plugin names (docs) | docs/notes/extensions.md | @@ -13,12 +13,12 @@ In addition, many charts can be found on the [npm registry](https://www.npmjs.co
## Plugins
- - <a href="https://github.com/chartjs/chartjs-plugin-annotation" target="_blank">chartjs-plugin-annotation.js</a> - Draws lines and boxes on chart area.
- - <a href="https://github.com/chartjs/chartjs-plugin-datalabels" target="_blank">chartjs-plugin-datalabels.js</a> - Displays labels on data for any type of charts.
- - <a href="https://github.com/chartjs/chartjs-plugin-deferred" target="_blank">chartjs-plugin-deferred.js</a> - Defers initial chart update until chart scrolls into viewport.
- - <a href="https://github.com/compwright/chartjs-plugin-draggable" target="_blank">chartjs-plugin-draggable.js</a> - Makes select chart elements draggable with the mouse.
- - <a href="https://github.com/y-takey/chartjs-plugin-stacked100" target="_blank">chartjs-plugin-stacked100.js</a> - Draws 100% stacked bar chart.
- - <a href="https://github.com/chartjs/chartjs-plugin-zoom" target="_blank">chartjs-plugin-zoom.js</a> - Enables zooming and panning on charts.
+ - <a href="https://github.com/chartjs/chartjs-plugin-annotation" target="_blank">chartjs-plugin-annotation</a> - Draws lines and boxes on chart area.
+ - <a href="https://github.com/chartjs/chartjs-plugin-datalabels" target="_blank">chartjs-plugin-datalabels</a> - Displays labels on data for any type of charts.
+ - <a href="https://github.com/chartjs/chartjs-plugin-deferred" target="_blank">chartjs-plugin-deferred</a> - Defers initial chart update until chart scrolls into viewport.
+ - <a href="https://github.com/compwright/chartjs-plugin-draggable" target="_blank">chartjs-plugin-draggable</a> - Makes select chart elements draggable with the mouse.
+ - <a href="https://github.com/y-takey/chartjs-plugin-stacked100" target="_blank">chartjs-plugin-stacked100</a> - Draws 100% stacked bar chart.
+ - <a href="https://github.com/chartjs/chartjs-plugin-zoom" target="_blank">chartjs-plugin-zoom</a> - Enables zooming and panning on charts.
In addition, many plugins can be found on the [npm registry](https://www.npmjs.com/search?q=chartjs-plugin-).
| false |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | docs/SUMMARY.md | @@ -10,6 +10,7 @@
* [Interactions](general/interactions/README.md)
* [Events](general/interactions/events.md)
* [Modes](general/interactions/modes.md)
+ * [Options](general/options.md)
* [Colors](general/colors.md)
* [Fonts](general/fonts.md)
* [Configuration](configuration/README.md)
@@ -34,7 +35,7 @@
* [Category](axes/cartesian/category.md)
* [Linear](axes/cartesian/linear.md)
* [Logarithmic](axes/cartesian/logarithmic.md)
- * [Time](axes/cartesian/time.md)
+ * [Time](axes/cartesian/time.md)
* [Radial](axes/radial/README.md)
* [Linear](axes/radial/linear.md)
* [Labelling](axes/labelling.md) | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | docs/charts/bubble.md | @@ -1,6 +1,6 @@
# Bubble Chart
-A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles.
+A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles.
{% chartjs %}
{
@@ -38,34 +38,60 @@ var myBubbleChart = new Chart(ctx,{
The bubble chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of the bubbles is generally set this way.
-All properties, except `label` can be specified as an array. If these are set to an array value, the first value applies to the first bubble in the dataset, the second value to the second bubble, and so on.
+| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
+| ---- | ---- | :----: | :----: | ----
+| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
+| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
+| [`borderWidth`](#styling) | `Number` | Yes | Yes | `3`
+| [`data`](#data-structure) | `Object[]` | - | - | **required**
+| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
+| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
+| [`hoverBorderWidth`](#interactions) | `Number` | Yes | Yes | `1`
+| [`hoverRadius`](#interactions) | `Number` | Yes | Yes | `4`
+| [`hitRadius`](#interactions) | `Number` | Yes | Yes | `1`
+| [`label`](#labeling) | `String` | - | - | `undefined`
+| [`pointStyle`](#styling) | `String` | Yes | Yes | `circle`
+| [`radius`](#styling) | `Number` | Yes | Yes | `3`
-| Name | Type | Description
-| ---- | ---- | -----------
-| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
-| `backgroundColor` | `Color/Color[]` | The fill color for bubbles.
-| `borderColor` | `Color/Color[]` | The border color for bubbles.
-| `borderWidth` | `Number/Number[]` | The width of the point bubbles in pixels.
-| `hoverBackgroundColor` | `Color/Color[]` | Bubble background color when hovered.
-| `hoverBorderColor` | `Color/Color[]` | Bubble border color when hovered.
-| `hoverBorderWidth` | `Number/Number[]` | Border width of point when hovered.
-| `hoverRadius` | `Number/Number[]` | Additional radius to add to data radius on hover.
+### Labeling
-## Config Options
+`label` defines the text associated to the dataset and which appears in the legend and tooltips.
-The bubble chart has no unique configuration options. To configure options common to all of the bubbles, the [point element options](../configuration/elements.md#point-configuration) are used.
+### Styling
+
+The style of each bubble can be controlled with the following properties:
+
+| Name | Description
+| ---- | ----
+| `backgroundColor` | bubble background color
+| `borderColor` | bubble border color
+| `borderWidth` | bubble border width (in pixels)
+| `pointStyle` | bubble [shape style](../configuration/elements#point-styles)
+| `radius` | bubble radius (in pixels)
+
+All these values, if `undefined`, fallback to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options.
+
+### Interactions
+
+The interaction with each bubble can be controlled with the following properties:
+
+| Name | Description
+| ---- | -----------
+| `hoverBackgroundColor` | bubble background color when hovered
+| `hoverBorderColor` | bubble border color hovered
+| `hoverBorderWidth` | bubble border width when hovered (in pixels)
+| `hoverRadius` | bubble **additional** radius when hovered (in pixels)
+| `hitRadius` | bubble **additional** radius for hit detection (in pixels)
+
+All these values, if `undefined`, fallback to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options.
## Default Options
We can also change the default values for the Bubble chart type. Doing so will give all bubble charts created after this point the new defaults. The default configuration for the bubble chart can be accessed at `Chart.defaults.bubble`.
## Data Structure
-For a bubble chart, datasets need to contain an array of data points. Each point must implement the [bubble data object](#bubble-data-object) interface.
-
-### Bubble Data Object
-
-Data for the bubble chart is passed in the form of an object. The object must implement the following interface. It is important to note that the radius property, `r` is **not** scaled by the chart. It is the raw radius in pixels of the bubble that is drawn on the canvas.
+Bubble chart datasets need to contain a `data` array of points, each points represented by an object containing the following properties:
```javascript
{
@@ -75,7 +101,9 @@ Data for the bubble chart is passed in the form of an object. The object must im
// Y Value
y: <Number>,
- // Radius of bubble. This is not scaled.
+ // Bubble radius in pixels (not scaled).
r: <Number>
}
```
+
+**Important:** the radius property, `r` is **not** scaled by the chart, it is the raw radius in pixels of the bubble that is drawn on the canvas. | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | docs/charts/line.md | @@ -6,11 +6,11 @@ A line chart is a way of plotting data points on a line. Often, it is used to sh
"type": "line",
"data": {
"labels": [
- "January",
- "February",
- "March",
- "April",
- "May",
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
"June",
"July"
],
@@ -62,7 +62,7 @@ All point* properties can be specified as an array. If these are set to an array
| `pointBorderColor` | `Color/Color[]` | The border color for points.
| `pointBorderWidth` | `Number/Number[]` | The width of the point border in pixels.
| `pointRadius` | `Number/Number[]` | The radius of the point shape. If set to 0, the point is not rendered.
-| `pointStyle` | `String/String[]/Image/Image[]` | Style of the point. [more...](#pointstyle)
+| `pointStyle` | `String/String[]/Image/Image[]` | Style of the point. [more...](../configuration/elements#point-styles)
| `pointHitRadius` | `Number/Number[]` | The pixel size of the non-displayed point that reacts to mouse events.
| `pointHoverBackgroundColor` | `Color/Color[]` | Point background color when hovered.
| `pointHoverBorderColor` | `Color/Color[]` | Point border color when hovered.
@@ -75,29 +75,14 @@ All point* properties can be specified as an array. If these are set to an array
### cubicInterpolationMode
The following interpolation modes are supported:
* 'default'
-* 'monotone'.
+* 'monotone'.
The 'default' algorithm uses a custom weighted cubic interpolation, which produces pleasant curves for all types of datasets.
The 'monotone' algorithm is more suited to `y = f(x)` datasets : it preserves monotonicity (or piecewise monotonicity) of the dataset being interpolated, and ensures local extremums (if any) stay at input data points.
If left untouched (`undefined`), the global `options.elements.line.cubicInterpolationMode` property is used.
-### pointStyle
-The style of point. Options are:
-* 'circle'
-* 'cross'
-* 'crossRot'
-* 'dash'.
-* 'line'
-* 'rect'
-* 'rectRounded'
-* 'rectRot'
-* 'star'
-* 'triangle'
-
-If the option is an image, that image is drawn on the canvas using [drawImage](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/drawImage).
-
### Stepped Line
The following values are supported for `steppedLine`:
* `false`: No Step Interpolation (default)
@@ -127,7 +112,7 @@ Chart.defaults.line.spanGaps = true;
## Data Structure
-The `data` property of a dataset for a line chart can be passed in two formats.
+The `data` property of a dataset for a line chart can be passed in two formats.
### Number[]
```javascript | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | docs/configuration/elements.md | @@ -18,14 +18,30 @@ Global point options: `Chart.defaults.global.elements.point`
| Name | Type | Default | Description
| -----| ---- | --------| -----------
| `radius` | `Number` | `3` | Point radius.
-| `pointStyle` | `String` | `circle` | Point style.
+| [`pointStyle`](#point-styles) | `String` | `circle` | Point style.
| `backgroundColor` | `Color` | `'rgba(0,0,0,0.1)'` | Point fill color.
| `borderWidth` | `Number` | `1` | Point stroke width.
| `borderColor` | `Color` | `'rgba(0,0,0,0.1)'` | Point stroke color.
| `hitRadius` | `Number` | `1` | Extra radius added to point radius for hit detection.
| `hoverRadius` | `Number` | `4` | Point radius when hovered.
| `hoverBorderWidth` | `Number` | `1` | Stroke width when hovered.
+### Point Styles
+
+The following values are supported:
+- `'circle'`
+- `'cross'`
+- `'crossRot'`
+- `'dash'`
+- `'line'`
+- `'rect'`
+- `'rectRounded'`
+- `'rectRot'`
+- `'star'`
+- `'triangle'`
+
+If the value is an image, that image is drawn on the canvas using [drawImage](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/drawImage).
+
## Line Configuration
Line elements are used to represent the line in a line chart.
| true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | docs/general/README.md | @@ -1,9 +1,10 @@
-# General Chart.js Configuration
+# General Configuration
-These sections describe general configuration options that can apply elsewhere in the documentation.
+These sections describe general configuration options that can apply elsewhere in the documentation.
-* [Colors](./colors.md) defines acceptable color values
-* [Font](./fonts.md) defines various font options
-* [Interactions](./interactions/README.md) defines options that reflect how hovering chart elements works
* [Responsive](./responsive.md) defines responsive chart options that apply to all charts.
-* [Device Pixel Ratio](./device-pixel-ratio.md) defines the ratio between display pixels and rendered pixels
\ No newline at end of file
+* [Device Pixel Ratio](./device-pixel-ratio.md) defines the ratio between display pixels and rendered pixels.
+* [Interactions](./interactions/README.md) defines options that reflect how hovering chart elements works.
+* [Options](./options.md) scriptable and indexable options syntax.
+* [Colors](./colors.md) defines acceptable color values.
+* [Font](./fonts.md) defines various font options. | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | docs/general/options.md | @@ -0,0 +1,45 @@
+# Options
+
+## Scriptable Options
+
+Scriptable options also accept a function which is called for each data and that takes the unique argument `context` representing contextual information (see [option context](options.md#option-context)).
+
+Example:
+
+```javascript
+color: function(context) {
+ return context.data < 0 ? 'red' : // draw negative values in red
+ index%2 ? 'blue' : 'green'; // else, alternate values in blue and green
+}
+```
+
+> **Note:** scriptable options are only supported by a few bubble chart options.
+
+## Indexable Options
+
+Indexable options also accept an array in which each item corresponds to the element at the same index. Note that this method requires to provide as many items as data, so, in most cases, using a [function](#scriptable-options) is more appropriated if supported.
+
+Example:
+
+```javascript
+color: [
+ 'red', // color for data at index 0
+ 'blue', // color for data at index 1
+ 'green', // color for data at index 2
+ 'black', // color for data at index 3
+ //...
+]
+```
+
+## Option Context
+
+The option context is used to give contextual information when resolving options and currently only applies to [scriptable options](#scriptable-options).
+
+The context object contains the following properties:
+
+- `chart`: the associated chart
+- `dataIndex`: index of the current data
+- `dataset`: dataset at index `datasetIndex`
+- `datasetIndex`: index of the current dataset
+
+**Important**: since the context can represent different types of entities (dataset, data, etc.), some properties may be `undefined` so be sure to test any context property before using it. | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | samples/samples.js | @@ -167,6 +167,12 @@
title: 'HTML tooltips (points)',
path: 'tooltips/custom-points.html'
}]
+ }, {
+ title: 'Scriptable',
+ items: [{
+ title: 'Bubble Chart',
+ path: 'scriptable/bubble.html'
+ }]
}, {
title: 'Advanced',
items: [{ | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | samples/scriptable/bubble.html | @@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Scriptable > Bubble | Chart.js sample</title>
+ <link rel="stylesheet" type="text/css" href="../style.css">
+ <script src="../../dist/Chart.js"></script>
+ <script src="../utils.js"></script>
+</head>
+<body>
+ <div class="content">
+ <div class="wrapper"><canvas id="chart-0"></canvas></div>
+ <div class="toolbar">
+ <button onclick="randomize(this)">Randomize</button>
+ <button onclick="addDataset(this)">Add Dataset</button>
+ <button onclick="removeDataset(this)">Remove Dataset</button>
+ </div>
+ </div>
+
+ <script>
+ var DATA_COUNT = 16;
+ var MIN_XY = -150;
+ var MAX_XY = 100;
+
+ var presets = window.chartColors;
+ var utils = Samples.utils;
+
+ utils.srand(110);
+
+ function colorize(opaque, context) {
+ var value = context.dataset.data[context.dataIndex];
+ var x = value.x / 100;
+ var y = value.y / 100;
+ var r = x < 0 && y < 0 ? 250 : x < 0 ? 150 : y < 0 ? 50 : 0;
+ var g = x < 0 && y < 0 ? 0 : x < 0 ? 50 : y < 0 ? 150 : 250;
+ var b = x < 0 && y < 0 ? 0 : x > 0 && y > 0 ? 250 : 150;
+ var a = opaque ? 1 : 0.5 * value.v / 1000;
+
+ return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
+ }
+
+ function generateData() {
+ var data = [];
+ var i;
+
+ for (i = 0; i < DATA_COUNT; ++i) {
+ data.push({
+ x: utils.rand(MIN_XY, MAX_XY),
+ y: utils.rand(MIN_XY, MAX_XY),
+ v: utils.rand(0, 1000)
+ });
+ }
+
+ return data;
+ }
+
+ var data = {
+ datasets: [{
+ data: generateData()
+ }, {
+ data: generateData()
+ }]
+ };
+
+ var options = {
+ aspectRatio: 1,
+ legend: false,
+ tooltips: false,
+
+ elements: {
+ point: {
+ backgroundColor: colorize.bind(null, false),
+
+ borderColor: colorize.bind(null, true),
+
+ borderWidth: function(context) {
+ return Math.min(Math.max(1, context.datasetIndex + 1), 8);
+ },
+
+ hoverBackgroundColor: 'transparent',
+
+ hoverBorderColor: function(context) {
+ return utils.color(context.datasetIndex);
+ },
+
+ hoverBorderWidth: function(context) {
+ var value = context.dataset.data[context.dataIndex];
+ return Math.round(8 * value.v / 1000);
+ },
+
+ radius: function(context) {
+ var value = context.dataset.data[context.dataIndex];
+ var size = context.chart.width;
+ var base = Math.abs(value.v) / 1000;
+ return (size / 24) * base;
+ }
+ }
+ }
+ };
+
+ var chart = new Chart('chart-0', {
+ type: 'bubble',
+ data: data,
+ options: options
+ });
+
+ function randomize() {
+ chart.data.datasets.forEach(function(dataset) {
+ dataset.data = generateData()
+ });
+ chart.update();
+ }
+
+ function addDataset() {
+ chart.data.datasets.push({
+ data: generateData()
+ });
+ chart.update();
+ }
+
+ function removeDataset() {
+ chart.data.datasets.shift();
+ chart.update();
+ }
+ </script>
+</body>
+</html> | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | samples/utils.js | @@ -12,10 +12,6 @@ window.chartColors = {
grey: 'rgb(201, 203, 207)'
};
-window.randomScalingFactor = function() {
- return (Math.random() > 0.5 ? 1.0 : -1.0) * Math.round(Math.random() * 100);
-};
-
(function(global) {
var Months = [
'January',
@@ -32,6 +28,18 @@ window.randomScalingFactor = function() {
'December'
];
+ var COLORS = [
+ '#4dc9f6',
+ '#f67019',
+ '#f53794',
+ '#537bc4',
+ '#acc236',
+ '#166a8f',
+ '#00a950',
+ '#58595b',
+ '#8549ba'
+ ];
+
var Samples = global.Samples || (global.Samples = {});
Samples.utils = {
// Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
@@ -105,6 +113,10 @@ window.randomScalingFactor = function() {
return values;
},
+ color: function(index) {
+ return COLORS[index % COLORS.length];
+ },
+
transparentize: function(color, opacity) {
var alpha = opacity === undefined ? 0.5 : 1 - opacity;
return Chart.helpers.color(color).alpha(alpha).rgbString();
@@ -115,5 +127,10 @@ window.randomScalingFactor = function() {
Samples.utils.srand(Date.now());
+ // DEPRECATED
+ window.randomScalingFactor = function() {
+ return Math.round(Samples.utils.rand(-100, 100));
+ };
+
}(this));
| true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | src/controllers/controller.bubble.js | @@ -41,9 +41,14 @@ defaults._set('bubble', {
module.exports = function(Chart) {
Chart.controllers.bubble = Chart.DatasetController.extend({
-
+ /**
+ * @protected
+ */
dataElementType: elements.Point,
+ /**
+ * @protected
+ */
update: function(reset) {
var me = this;
var meta = me.getMeta();
@@ -55,71 +60,121 @@ module.exports = function(Chart) {
});
},
+ /**
+ * @protected
+ */
updateElement: function(point, index, reset) {
var me = this;
var meta = me.getMeta();
+ var custom = point.custom || {};
var xScale = me.getScaleForId(meta.xAxisID);
var yScale = me.getScaleForId(meta.yAxisID);
-
- var custom = point.custom || {};
- var dataset = me.getDataset();
- var data = dataset.data[index];
- var pointElementOptions = me.chart.options.elements.point;
+ var options = me._resolveElementOptions(point, index);
+ var data = me.getDataset().data[index];
var dsIndex = me.index;
- helpers.extend(point, {
- // Utility
- _xScale: xScale,
- _yScale: yScale,
- _datasetIndex: dsIndex,
- _index: index,
-
- // Desired view properties
- _model: {
- x: reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex),
- y: reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex),
- // Appearance
- radius: reset ? 0 : custom.radius ? custom.radius : me.getRadius(data),
-
- // Tooltip
- hitRadius: custom.hitRadius ? custom.hitRadius : helpers.valueAtIndexOrDefault(dataset.hitRadius, index, pointElementOptions.hitRadius)
- }
- });
-
- // Trick to reset the styles of the point
- Chart.DatasetController.prototype.removeHoverStyle.call(me, point, pointElementOptions);
-
- var model = point._model;
- model.skip = custom.skip ? custom.skip : (isNaN(model.x) || isNaN(model.y));
+ var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex);
+ var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex);
+
+ point._xScale = xScale;
+ point._yScale = yScale;
+ point._options = options;
+ point._datasetIndex = dsIndex;
+ point._index = index;
+ point._model = {
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderWidth: options.borderWidth,
+ hitRadius: options.hitRadius,
+ pointStyle: options.pointStyle,
+ radius: reset ? 0 : options.radius,
+ skip: custom.skip || isNaN(x) || isNaN(y),
+ x: x,
+ y: y,
+ };
point.pivot();
},
- getRadius: function(value) {
- return value.r || this.chart.options.elements.point.radius;
- },
-
+ /**
+ * @protected
+ */
setHoverStyle: function(point) {
- var me = this;
- Chart.DatasetController.prototype.setHoverStyle.call(me, point);
-
- // Radius
- var dataset = me.chart.data.datasets[point._datasetIndex];
- var index = point._index;
- var custom = point.custom || {};
var model = point._model;
- model.radius = custom.hoverRadius ? custom.hoverRadius : (helpers.valueAtIndexOrDefault(dataset.hoverRadius, index, me.chart.options.elements.point.hoverRadius)) + me.getRadius(dataset.data[index]);
+ var options = point._options;
+
+ model.backgroundColor = helpers.valueOrDefault(options.hoverBackgroundColor, helpers.getHoverColor(options.backgroundColor));
+ model.borderColor = helpers.valueOrDefault(options.hoverBorderColor, helpers.getHoverColor(options.borderColor));
+ model.borderWidth = helpers.valueOrDefault(options.hoverBorderWidth, options.borderWidth);
+ model.radius = options.radius + options.hoverRadius;
},
+ /**
+ * @protected
+ */
removeHoverStyle: function(point) {
- var me = this;
- Chart.DatasetController.prototype.removeHoverStyle.call(me, point, me.chart.options.elements.point);
+ var model = point._model;
+ var options = point._options;
+
+ model.backgroundColor = options.backgroundColor;
+ model.borderColor = options.borderColor;
+ model.borderWidth = options.borderWidth;
+ model.radius = options.radius;
+ },
- var dataVal = me.chart.data.datasets[point._datasetIndex].data[point._index];
+ /**
+ * @private
+ */
+ _resolveElementOptions: function(point, index) {
+ var me = this;
+ var chart = me.chart;
+ var datasets = chart.data.datasets;
+ var dataset = datasets[me.index];
var custom = point.custom || {};
- var model = point._model;
+ var options = chart.options.elements.point;
+ var resolve = helpers.options.resolve;
+ var data = dataset.data[index];
+ var values = {};
+ var i, ilen, key;
+
+ // Scriptable options
+ var context = {
+ chart: chart,
+ dataIndex: index,
+ dataset: dataset,
+ datasetIndex: me.index
+ };
+
+ var keys = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderWidth',
+ 'hoverBackgroundColor',
+ 'hoverBorderColor',
+ 'hoverBorderWidth',
+ 'hoverRadius',
+ 'hitRadius',
+ 'pointStyle'
+ ];
+
+ for (i = 0, ilen = keys.length; i < ilen; ++i) {
+ key = keys[i];
+ values[key] = resolve([
+ custom[key],
+ dataset[key],
+ options[key]
+ ], context, index);
+ }
+
+ // Custom radius resolution
+ values.radius = resolve([
+ custom.radius,
+ data ? data.r : undefined,
+ dataset.radius,
+ options.radius
+ ], context, index);
- model.radius = custom.radius ? custom.radius : me.getRadius(dataVal);
+ return values;
}
});
}; | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | src/helpers/helpers.options.js | @@ -3,7 +3,8 @@
var helpers = require('./helpers.core');
/**
- * @namespace Chart.helpers.options
+ * @alias Chart.helpers.options
+ * @namespace
*/
module.exports = {
/**
@@ -62,5 +63,34 @@ module.exports = {
height: t + b,
width: l + r
};
+ },
+
+ /**
+ * Evaluates the given `inputs` sequentially and returns the first defined value.
+ * @param {Array[]} inputs - An array of values, falling back to the last value.
+ * @param {Object} [context] - If defined and the current value is a function, the value
+ * is called with `context` as first argument and the result becomes the new input.
+ * @param {Number} [index] - If defined and the current value is an array, the value
+ * at `index` become the new input.
+ * @since 2.7.0
+ */
+ resolve: function(inputs, context, index) {
+ var i, ilen, value;
+
+ for (i = 0, ilen = inputs.length; i < ilen; ++i) {
+ value = inputs[i];
+ if (value === undefined) {
+ continue;
+ }
+ if (context !== undefined && typeof value === 'function') {
+ value = value(context);
+ }
+ if (index !== undefined && helpers.isArray(value)) {
+ value = value[index];
+ }
+ if (value !== undefined) {
+ return value;
+ }
+ }
}
}; | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | test/jasmine.index.js | @@ -43,6 +43,7 @@ var utils = require('./jasmine.utils');
'}');
jasmine.specsFromFixtures = utils.specsFromFixtures;
+ jasmine.triggerMouseEvent = utils.triggerMouseEvent;
beforeEach(function() {
jasmine.addMatchers(matchers); | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | test/jasmine.utils.js | @@ -158,11 +158,26 @@ function waitForResize(chart, callback) {
};
}
+function triggerMouseEvent(chart, type, el) {
+ var node = chart.canvas;
+ var rect = node.getBoundingClientRect();
+ var event = new MouseEvent(type, {
+ clientX: rect.left + el._model.x,
+ clientY: rect.top + el._model.y,
+ cancelable: true,
+ bubbles: true,
+ view: window
+ });
+
+ node.dispatchEvent(event);
+}
+
module.exports = {
injectCSS: injectCSS,
createCanvas: createCanvas,
acquireChart: acquireChart,
releaseChart: releaseChart,
specsFromFixtures: specsFromFixtures,
+ triggerMouseEvent: triggerMouseEvent,
waitForResize: waitForResize
}; | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | test/specs/controller.bubble.tests.js | @@ -273,160 +273,138 @@ describe('Bubble controller tests', function() {
expect(meta.data[4] instanceof Chart.elements.Point).toBe(true);
});
- it('should set hover styles', function() {
- var chart = window.acquireChart({
- type: 'bubble',
- data: {
- datasets: [{
- data: [{
- x: 10,
- y: 10,
- r: 5
- }, {
- x: -15,
- y: -10,
- r: 1
- }, {
- x: 0,
- y: -9,
- r: 2
- }, {
- x: -4,
- y: 10,
- r: 1
+ describe('Interactions', function() {
+ beforeEach(function() {
+ this.chart = window.acquireChart({
+ type: 'bubble',
+ data: {
+ labels: ['label1', 'label2', 'label3', 'label4'],
+ datasets: [{
+ data: [{
+ x: 5,
+ y: 5,
+ r: 20
+ }, {
+ x: -15,
+ y: -10,
+ r: 15
+ }, {
+ x: 15,
+ y: 10,
+ r: 10
+ }, {
+ x: -15,
+ y: 10,
+ r: 5
+ }]
}]
- }],
- labels: ['label1', 'label2', 'label3', 'label4']
- },
- options: {
- elements: {
- point: {
- backgroundColor: 'rgb(255, 255, 0)',
- borderWidth: 1,
- borderColor: 'rgb(255, 255, 255)',
- hitRadius: 1,
- hoverRadius: 4,
- hoverBorderWidth: 1,
- radius: 3
+ },
+ options: {
+ elements: {
+ point: {
+ backgroundColor: 'rgb(100, 150, 200)',
+ borderColor: 'rgb(50, 100, 150)',
+ borderWidth: 2,
+ radius: 3
+ }
}
}
- }
+ });
});
- var meta = chart.getDatasetMeta(0);
- var point = meta.data[0];
-
- meta.controller.setHoverStyle(point);
- expect(point._model.backgroundColor).toBe('rgb(229, 230, 0)');
- expect(point._model.borderColor).toBe('rgb(230, 230, 230)');
- expect(point._model.borderWidth).toBe(1);
- expect(point._model.radius).toBe(9);
-
- // Can set hover style per dataset
- chart.data.datasets[0].hoverRadius = 3.3;
- chart.data.datasets[0].hoverBackgroundColor = 'rgb(77, 79, 81)';
- chart.data.datasets[0].hoverBorderColor = 'rgb(123, 125, 127)';
- chart.data.datasets[0].hoverBorderWidth = 2.1;
-
- meta.controller.setHoverStyle(point);
- expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)');
- expect(point._model.borderColor).toBe('rgb(123, 125, 127)');
- expect(point._model.borderWidth).toBe(2.1);
- expect(point._model.radius).toBe(8.3);
-
- // Custom style
- point.custom = {
- hoverRadius: 4.4,
- hoverBorderWidth: 5.5,
- hoverBackgroundColor: 'rgb(0, 0, 0)',
- hoverBorderColor: 'rgb(10, 10, 10)'
- };
-
- meta.controller.setHoverStyle(point);
- expect(point._model.backgroundColor).toBe('rgb(0, 0, 0)');
- expect(point._model.borderColor).toBe('rgb(10, 10, 10)');
- expect(point._model.borderWidth).toBe(5.5);
- expect(point._model.radius).toBe(4.4);
- });
+ it ('should handle default hover styles', function() {
+ var chart = this.chart;
+ var point = chart.getDatasetMeta(0).data[0];
+
+ jasmine.triggerMouseEvent(chart, 'mousemove', point);
+ expect(point._model.backgroundColor).toBe('rgb(49, 135, 221)');
+ expect(point._model.borderColor).toBe('rgb(22, 89, 156)');
+ expect(point._model.borderWidth).toBe(1);
+ expect(point._model.radius).toBe(20 + 4);
+
+ jasmine.triggerMouseEvent(chart, 'mouseout', point);
+ expect(point._model.backgroundColor).toBe('rgb(100, 150, 200)');
+ expect(point._model.borderColor).toBe('rgb(50, 100, 150)');
+ expect(point._model.borderWidth).toBe(2);
+ expect(point._model.radius).toBe(20);
+ });
- it('should remove hover styles', function() {
- var chart = window.acquireChart({
- type: 'bubble',
- data: {
- datasets: [{
- data: [{
- x: 10,
- y: 10,
- r: 5
- }, {
- x: -15,
- y: -10,
- r: 1
- }, {
- x: 0,
- y: -9,
- r: 2
- }, {
- x: -4,
- y: 10,
- r: 1
- }]
- }],
- labels: ['label1', 'label2', 'label3', 'label4']
- },
- options: {
- elements: {
- point: {
- backgroundColor: 'rgb(255, 255, 0)',
- borderWidth: 1,
- borderColor: 'rgb(255, 255, 255)',
- hitRadius: 1,
- hoverRadius: 4,
- hoverBorderWidth: 1,
- radius: 3
- }
- }
- }
+ it ('should handle hover styles defined via dataset properties', function() {
+ var chart = this.chart;
+ var point = chart.getDatasetMeta(0).data[0];
+
+ Chart.helpers.merge(chart.data.datasets[0], {
+ hoverBackgroundColor: 'rgb(200, 100, 150)',
+ hoverBorderColor: 'rgb(150, 50, 100)',
+ hoverBorderWidth: 8.4,
+ hoverRadius: 4.2
+ });
+
+ chart.update();
+
+ jasmine.triggerMouseEvent(chart, 'mousemove', point);
+ expect(point._model.backgroundColor).toBe('rgb(200, 100, 150)');
+ expect(point._model.borderColor).toBe('rgb(150, 50, 100)');
+ expect(point._model.borderWidth).toBe(8.4);
+ expect(point._model.radius).toBe(20 + 4.2);
+
+ jasmine.triggerMouseEvent(chart, 'mouseout', point);
+ expect(point._model.backgroundColor).toBe('rgb(100, 150, 200)');
+ expect(point._model.borderColor).toBe('rgb(50, 100, 150)');
+ expect(point._model.borderWidth).toBe(2);
+ expect(point._model.radius).toBe(20);
});
- var meta = chart.getDatasetMeta(0);
- var point = meta.data[0];
-
- chart.options.elements.point.backgroundColor = 'rgb(45, 46, 47)';
- chart.options.elements.point.borderColor = 'rgb(50, 51, 52)';
- chart.options.elements.point.borderWidth = 10.1;
- chart.options.elements.point.radius = 1.01;
-
- meta.controller.removeHoverStyle(point);
- expect(point._model.backgroundColor).toBe('rgb(45, 46, 47)');
- expect(point._model.borderColor).toBe('rgb(50, 51, 52)');
- expect(point._model.borderWidth).toBe(10.1);
- expect(point._model.radius).toBe(5);
-
- // Can set hover style per dataset
- chart.data.datasets[0].radius = 3.3;
- chart.data.datasets[0].backgroundColor = 'rgb(77, 79, 81)';
- chart.data.datasets[0].borderColor = 'rgb(123, 125, 127)';
- chart.data.datasets[0].borderWidth = 2.1;
-
- meta.controller.removeHoverStyle(point);
- expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)');
- expect(point._model.borderColor).toBe('rgb(123, 125, 127)');
- expect(point._model.borderWidth).toBe(2.1);
- expect(point._model.radius).toBe(5);
-
- // Custom style
- point.custom = {
- radius: 4.4,
- borderWidth: 5.5,
- backgroundColor: 'rgb(0, 0, 0)',
- borderColor: 'rgb(10, 10, 10)'
- };
+ it ('should handle hover styles defined via element options', function() {
+ var chart = this.chart;
+ var point = chart.getDatasetMeta(0).data[0];
+
+ Chart.helpers.merge(chart.options.elements.point, {
+ hoverBackgroundColor: 'rgb(200, 100, 150)',
+ hoverBorderColor: 'rgb(150, 50, 100)',
+ hoverBorderWidth: 8.4,
+ hoverRadius: 4.2
+ });
+
+ chart.update();
+
+ jasmine.triggerMouseEvent(chart, 'mousemove', point);
+ expect(point._model.backgroundColor).toBe('rgb(200, 100, 150)');
+ expect(point._model.borderColor).toBe('rgb(150, 50, 100)');
+ expect(point._model.borderWidth).toBe(8.4);
+ expect(point._model.radius).toBe(20 + 4.2);
+
+ jasmine.triggerMouseEvent(chart, 'mouseout', point);
+ expect(point._model.backgroundColor).toBe('rgb(100, 150, 200)');
+ expect(point._model.borderColor).toBe('rgb(50, 100, 150)');
+ expect(point._model.borderWidth).toBe(2);
+ expect(point._model.radius).toBe(20);
+ });
- meta.controller.removeHoverStyle(point);
- expect(point._model.backgroundColor).toBe('rgb(0, 0, 0)');
- expect(point._model.borderColor).toBe('rgb(10, 10, 10)');
- expect(point._model.borderWidth).toBe(5.5);
- expect(point._model.radius).toBe(4.4);
+ it ('should handle hover styles defined via element custom', function() {
+ var chart = this.chart;
+ var point = chart.getDatasetMeta(0).data[0];
+
+ point.custom = {
+ hoverBackgroundColor: 'rgb(200, 100, 150)',
+ hoverBorderColor: 'rgb(150, 50, 100)',
+ hoverBorderWidth: 8.4,
+ hoverRadius: 4.2
+ };
+
+ chart.update();
+
+ jasmine.triggerMouseEvent(chart, 'mousemove', point);
+ expect(point._model.backgroundColor).toBe('rgb(200, 100, 150)');
+ expect(point._model.borderColor).toBe('rgb(150, 50, 100)');
+ expect(point._model.borderWidth).toBe(8.4);
+ expect(point._model.radius).toBe(20 + 4.2);
+
+ jasmine.triggerMouseEvent(chart, 'mouseout', point);
+ expect(point._model.backgroundColor).toBe('rgb(100, 150, 200)');
+ expect(point._model.borderColor).toBe('rgb(50, 100, 150)');
+ expect(point._model.borderWidth).toBe(2);
+ expect(point._model.radius).toBe(20);
+ });
});
}); | true |
Other | chartjs | Chart.js | 872dfec0f3a99bfbf3dbc84e4b07bde1c986e93d.json | Introduce scriptable options (bubble chart) (#4671)
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section. | test/specs/helpers.options.tests.js | @@ -61,4 +61,65 @@ describe('Chart.helpers.options', function() {
{top: 0, right: 0, bottom: 0, left: 0, height: 0, width: 0});
});
});
+
+ describe('resolve', function() {
+ it ('should fallback to the first defined input', function() {
+ expect(options.resolve([42])).toBe(42);
+ expect(options.resolve([42, 'foo'])).toBe(42);
+ expect(options.resolve([undefined, 42, 'foo'])).toBe(42);
+ expect(options.resolve([42, 'foo', undefined])).toBe(42);
+ expect(options.resolve([undefined])).toBe(undefined);
+ });
+ it ('should correctly handle empty values (null, 0, "")', function() {
+ expect(options.resolve([0, 'foo'])).toBe(0);
+ expect(options.resolve(['', 'foo'])).toBe('');
+ expect(options.resolve([null, 'foo'])).toBe(null);
+ });
+ it ('should support indexable options if index is provided', function() {
+ var input = [42, 'foo', 'bar'];
+ expect(options.resolve([input], undefined, 0)).toBe(42);
+ expect(options.resolve([input], undefined, 1)).toBe('foo');
+ expect(options.resolve([input], undefined, 2)).toBe('bar');
+ });
+ it ('should fallback if an indexable option value is undefined', function() {
+ var input = [42, undefined, 'bar'];
+ expect(options.resolve([input], undefined, 5)).toBe(undefined);
+ expect(options.resolve([input, 'foo'], undefined, 1)).toBe('foo');
+ expect(options.resolve([input, 'foo'], undefined, 5)).toBe('foo');
+ });
+ it ('should not handle indexable options if index is undefined', function() {
+ var array = [42, 'foo', 'bar'];
+ expect(options.resolve([array])).toBe(array);
+ expect(options.resolve([array], undefined, undefined)).toBe(array);
+ });
+ it ('should support scriptable options if context is provided', function() {
+ var input = function(context) {
+ return context.v * 2;
+ };
+ expect(options.resolve([42], {v: 42})).toBe(42);
+ expect(options.resolve([input], {v: 42})).toBe(84);
+ });
+ it ('should fallback if a scriptable option returns undefined', function() {
+ var input = function() {};
+ expect(options.resolve([input], {v: 42})).toBe(undefined);
+ expect(options.resolve([input, 'foo'], {v: 42})).toBe('foo');
+ expect(options.resolve([input, undefined, 'foo'], {v: 42})).toBe('foo');
+ });
+ it ('should not handle scriptable options if context is undefined', function() {
+ var input = function(context) {
+ return context.v * 2;
+ };
+ expect(options.resolve([input])).toBe(input);
+ expect(options.resolve([input], undefined)).toBe(input);
+ });
+ it ('should handle scriptable and indexable option', function() {
+ var input = function(context) {
+ return [context.v, undefined, 'bar'];
+ };
+ expect(options.resolve([input, 'foo'], {v: 42}, 0)).toBe(42);
+ expect(options.resolve([input, 'foo'], {v: 42}, 1)).toBe('foo');
+ expect(options.resolve([input, 'foo'], {v: 42}, 5)).toBe('foo');
+ expect(options.resolve([input, ['foo', 'bar']], {v: 42}, 1)).toBe('bar');
+ });
+ });
}); | true |
Other | chartjs | Chart.js | b9afeaf973999516cd3fdfdf4ec7c86b223d9263.json | remove redundant tooltip initialize (#4655) | src/core/core.controller.js | @@ -718,7 +718,6 @@ module.exports = function(Chart) {
_data: me.data,
_options: me.options.tooltips
}, me);
- me.tooltip.initialize();
},
/** | false |
Other | chartjs | Chart.js | 8dca88c7d52f9ec153e920eb2a89254f98b1d44d.json | Fix tests on OSX with retina screen
* Fix retina unit test failures
* Honor config file formatting
* Prevent gulp error on non-zero karma result | .editorconfig | @@ -8,3 +8,11 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
+
+[gulpfile.js]
+indent_style = space
+indent_size = 2
+
+[*.yml]
+indent_style = space
+indent_size = 2 | true |
Other | chartjs | Chart.js | 8dca88c7d52f9ec153e920eb2a89254f98b1d44d.json | Fix tests on OSX with retina screen
* Fix retina unit test failures
* Honor config file formatting
* Prevent gulp error on non-zero karma result | gulpfile.js | @@ -188,7 +188,12 @@ function unittestTask(done) {
args: {
coverage: !!argv.coverage
}
- }, done).start();
+ },
+ // https://github.com/karma-runner/gulp-karma/issues/18
+ function(error) {
+ error = error ? new Error('Karma returned with the error code: ' + error) : undefined;
+ done(error);
+ }).start();
}
function librarySizeTask() { | true |
Other | chartjs | Chart.js | 8dca88c7d52f9ec153e920eb2a89254f98b1d44d.json | Fix tests on OSX with retina screen
* Fix retina unit test failures
* Honor config file formatting
* Prevent gulp error on non-zero karma result | test/jasmine.index.js | @@ -22,6 +22,10 @@ var utils = require('./jasmine.utils');
return new Context();
}
+ // force ratio=1 for tests on high-res/retina devices
+ // fixes https://github.com/chartjs/Chart.js/issues/4515
+ window.devicePixelRatio = 1;
+
window.acquireChart = acquireChart;
window.releaseChart = releaseChart;
window.waitForResize = utils.waitForResize; | true |
Other | chartjs | Chart.js | 8dca88c7d52f9ec153e920eb2a89254f98b1d44d.json | Fix tests on OSX with retina screen
* Fix retina unit test failures
* Honor config file formatting
* Prevent gulp error on non-zero karma result | test/specs/platform.dom.tests.js | @@ -394,8 +394,8 @@ describe('Platform.dom', function() {
expect(notifiedEvent.type).toBe(evt.type);
// Relative Position
- expect(notifiedEvent.x).toBe(chart.width / 2);
- expect(notifiedEvent.y).toBe(chart.height / 2);
+ expect(notifiedEvent.x).toBeCloseToPixel(chart.width / 2);
+ expect(notifiedEvent.y).toBeCloseToPixel(chart.height / 2);
});
});
}); | true |
Other | chartjs | Chart.js | 2c52209ba73cc9b190608319dbba0593f3df455e.json | Replace the IFRAME resizer by DIVs (#4596)
Resize detection is now based on scroll events from two divs nested under a main one. Implementation inspired from https://github.com/marcj/css-element-queries. | src/core/core.controller.js | @@ -731,9 +731,7 @@ module.exports = function(Chart) {
listeners[type] = listener;
});
- // Responsiveness is currently based on the use of an iframe, however this method causes
- // performance issues and could be troublesome when used with ad blockers. So make sure
- // that the user is still able to create a chart without iframe when responsive is false.
+ // Elements used to detect size change should not be injected for non responsive charts.
// See https://github.com/chartjs/Chart.js/issues/2210
if (me.options.responsive) {
listener = function() { | true |
Other | chartjs | Chart.js | 2c52209ba73cc9b190608319dbba0593f3df455e.json | Replace the IFRAME resizer by DIVs (#4596)
Resize detection is now based on scroll events from two divs nested under a main one. Implementation inspired from https://github.com/marcj/css-element-queries. | src/platforms/platform.dom.js | @@ -165,43 +165,62 @@ function throttled(fn, thisArg) {
};
}
+// Implementation based on https://github.com/marcj/css-element-queries
function createResizer(handler) {
- var iframe = document.createElement('iframe');
- iframe.className = 'chartjs-hidden-iframe';
- iframe.style.cssText =
- 'display:block;' +
- 'overflow:hidden;' +
- 'border:0;' +
- 'margin:0;' +
- 'top:0;' +
+ var resizer = document.createElement('div');
+ var cls = CSS_PREFIX + 'size-monitor';
+ var maxSize = 1000000;
+ var style =
+ 'position:absolute;' +
'left:0;' +
- 'bottom:0;' +
+ 'top:0;' +
'right:0;' +
- 'height:100%;' +
- 'width:100%;' +
- 'position:absolute;' +
+ 'bottom:0;' +
+ 'overflow:hidden;' +
'pointer-events:none;' +
+ 'visibility:hidden;' +
'z-index:-1;';
- // Prevent the iframe to gain focus on tab.
- // https://github.com/chartjs/Chart.js/issues/3090
- iframe.tabIndex = -1;
-
- // Prevent iframe from gaining focus on ItemMode keyboard navigation
- // Accessibility bug fix
- iframe.setAttribute('aria-hidden', 'true');
-
- // If the iframe is re-attached to the DOM, the resize listener is removed because the
- // content is reloaded, so make sure to install the handler after the iframe is loaded.
- // https://github.com/chartjs/Chart.js/issues/3521
- addEventListener(iframe, 'load', function() {
- addEventListener(iframe.contentWindow || iframe, 'resize', handler);
- // The iframe size might have changed while loading, which can also
- // happen if the size has been changed while detached from the DOM.
+ resizer.style.cssText = style;
+ resizer.className = cls;
+ resizer.innerHTML =
+ '<div class="' + cls + '-expand" style="' + style + '">' +
+ '<div style="' +
+ 'position:absolute;' +
+ 'width:' + maxSize + 'px;' +
+ 'height:' + maxSize + 'px;' +
+ 'left:0;' +
+ 'top:0">' +
+ '</div>' +
+ '</div>' +
+ '<div class="' + cls + '-shrink" style="' + style + '">' +
+ '<div style="' +
+ 'position:absolute;' +
+ 'width:200%;' +
+ 'height:200%;' +
+ 'left:0; ' +
+ 'top:0">' +
+ '</div>' +
+ '</div>';
+
+ var expand = resizer.childNodes[0];
+ var shrink = resizer.childNodes[1];
+
+ resizer._reset = function() {
+ expand.scrollLeft = maxSize;
+ expand.scrollTop = maxSize;
+ shrink.scrollLeft = maxSize;
+ shrink.scrollTop = maxSize;
+ };
+ var onScroll = function() {
+ resizer._reset();
handler();
- });
+ };
+
+ addEventListener(expand, 'scroll', onScroll.bind(expand, 'expand'));
+ addEventListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink'));
- return iframe;
+ return resizer;
}
// https://davidwalsh.name/detect-node-insertion
@@ -253,6 +272,9 @@ function addResizeListener(node, listener, chart) {
if (container && container !== resizer.parentNode) {
container.insertBefore(resizer, container.firstChild);
}
+
+ // The container size might have changed, let's reset the resizer state.
+ resizer._reset();
}
});
} | true |
Other | chartjs | Chart.js | 2c52209ba73cc9b190608319dbba0593f3df455e.json | Replace the IFRAME resizer by DIVs (#4596)
Resize detection is now based on scroll events from two divs nested under a main one. Implementation inspired from https://github.com/marcj/css-element-queries. | test/specs/core.controller.tests.js | @@ -420,7 +420,8 @@ describe('Chart', function() {
waitForResize(chart, function() {
var resizer = wrapper.firstChild;
- expect(resizer.tagName).toBe('IFRAME');
+ expect(resizer.className).toBe('chartjs-size-monitor');
+ expect(resizer.tagName).toBe('DIV');
expect(chart).toBeChartOfSize({
dw: 455, dh: 355,
rw: 455, rh: 355,
@@ -687,7 +688,8 @@ describe('Chart', function() {
var wrapper = chart.canvas.parentNode;
var resizer = wrapper.firstChild;
expect(wrapper.childNodes.length).toBe(2);
- expect(resizer.tagName).toBe('IFRAME');
+ expect(resizer.className).toBe('chartjs-size-monitor');
+ expect(resizer.tagName).toBe('DIV');
chart.destroy();
| true |
Other | chartjs | Chart.js | f90ee8c786c24e44a252964c74970382d9c39016.json | Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer. | src/chart.js | @@ -60,6 +60,8 @@ plugins.push(
Chart.plugins.register(plugins);
+Chart.platform.initialize();
+
module.exports = Chart;
if (typeof window !== 'undefined') {
window.Chart = Chart; | true |
Other | chartjs | Chart.js | f90ee8c786c24e44a252964c74970382d9c39016.json | Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer. | src/core/core.helpers.js | @@ -500,6 +500,10 @@ module.exports = function(Chart) {
};
helpers.getMaximumWidth = function(domNode) {
var container = domNode.parentNode;
+ if (!container) {
+ return domNode.clientWidth;
+ }
+
var paddingLeft = parseInt(helpers.getStyle(container, 'padding-left'), 10);
var paddingRight = parseInt(helpers.getStyle(container, 'padding-right'), 10);
var w = container.clientWidth - paddingLeft - paddingRight;
@@ -508,6 +512,10 @@ module.exports = function(Chart) {
};
helpers.getMaximumHeight = function(domNode) {
var container = domNode.parentNode;
+ if (!container) {
+ return domNode.clientHeight;
+ }
+
var paddingTop = parseInt(helpers.getStyle(container, 'padding-top'), 10);
var paddingBottom = parseInt(helpers.getStyle(container, 'padding-bottom'), 10);
var h = container.clientHeight - paddingTop - paddingBottom; | true |
Other | chartjs | Chart.js | f90ee8c786c24e44a252964c74970382d9c39016.json | Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer. | src/platforms/platform.dom.js | @@ -6,19 +6,21 @@
var helpers = require('../helpers/index');
+var EXPANDO_KEY = '$chartjs';
+var CSS_PREFIX = 'chartjs-';
+var CSS_RENDER_MONITOR = CSS_PREFIX + 'render-monitor';
+var CSS_RENDER_ANIMATION = CSS_PREFIX + 'render-animation';
+var ANIMATION_START_EVENTS = ['animationstart', 'webkitAnimationStart'];
+
/**
* DOM event types -> Chart.js event types.
* Note: only events with different types are mapped.
* @see https://developer.mozilla.org/en-US/docs/Web/Events
*/
-
-var eventTypeMap = {
- // Touch events
+var EVENT_TYPES = {
touchstart: 'mousedown',
touchmove: 'mousemove',
touchend: 'mouseup',
-
- // Pointer events
pointerenter: 'mouseenter',
pointerdown: 'mousedown',
pointermove: 'mousemove',
@@ -56,7 +58,7 @@ function initCanvas(canvas, config) {
var renderWidth = canvas.getAttribute('width');
// Chart.js modifies some canvas values that we want to restore on destroy
- canvas._chartjs = {
+ canvas[EXPANDO_KEY] = {
initial: {
height: renderHeight,
width: renderWidth,
@@ -140,11 +142,29 @@ function createEvent(type, chart, x, y, nativeEvent) {
}
function fromNativeEvent(event, chart) {
- var type = eventTypeMap[event.type] || event.type;
+ var type = EVENT_TYPES[event.type] || event.type;
var pos = helpers.getRelativePosition(event, chart);
return createEvent(type, chart, pos.x, pos.y, event);
}
+function throttled(fn, thisArg) {
+ var ticking = false;
+ var args = [];
+
+ return function() {
+ args = Array.prototype.slice.call(arguments);
+ thisArg = thisArg || this;
+
+ if (!ticking) {
+ ticking = true;
+ helpers.requestAnimFrame.call(window, function() {
+ ticking = false;
+ fn.apply(thisArg, args);
+ });
+ }
+ };
+}
+
function createResizer(handler) {
var iframe = document.createElement('iframe');
iframe.className = 'chartjs-hidden-iframe';
@@ -176,7 +196,6 @@ function createResizer(handler) {
// https://github.com/chartjs/Chart.js/issues/3521
addEventListener(iframe, 'load', function() {
addEventListener(iframe.contentWindow || iframe, 'resize', handler);
-
// The iframe size might have changed while loading, which can also
// happen if the size has been changed while detached from the DOM.
handler();
@@ -185,45 +204,100 @@ function createResizer(handler) {
return iframe;
}
-function addResizeListener(node, listener, chart) {
- var stub = node._chartjs = {
- ticking: false
- };
-
- // Throttle the callback notification until the next animation frame.
- var notify = function() {
- if (!stub.ticking) {
- stub.ticking = true;
- helpers.requestAnimFrame.call(window, function() {
- if (stub.resizer) {
- stub.ticking = false;
- return listener(createEvent('resize', chart));
- }
- });
+// https://davidwalsh.name/detect-node-insertion
+function watchForRender(node, handler) {
+ var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
+ var proxy = expando.renderProxy = function(e) {
+ if (e.animationName === CSS_RENDER_ANIMATION) {
+ handler();
}
};
- // Let's keep track of this added iframe and thus avoid DOM query when removing it.
- stub.resizer = createResizer(notify);
+ helpers.each(ANIMATION_START_EVENTS, function(type) {
+ addEventListener(node, type, proxy);
+ });
- node.insertBefore(stub.resizer, node.firstChild);
+ node.classList.add(CSS_RENDER_MONITOR);
}
-function removeResizeListener(node) {
- if (!node || !node._chartjs) {
- return;
+function unwatchForRender(node) {
+ var expando = node[EXPANDO_KEY] || {};
+ var proxy = expando.renderProxy;
+
+ if (proxy) {
+ helpers.each(ANIMATION_START_EVENTS, function(type) {
+ removeEventListener(node, type, proxy);
+ });
+
+ delete expando.renderProxy;
}
- var resizer = node._chartjs.resizer;
- if (resizer) {
+ node.classList.remove(CSS_RENDER_MONITOR);
+}
+
+function addResizeListener(node, listener, chart) {
+ var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
+
+ // Let's keep track of this added resizer and thus avoid DOM query when removing it.
+ var resizer = expando.resizer = createResizer(throttled(function() {
+ if (expando.resizer) {
+ return listener(createEvent('resize', chart));
+ }
+ }));
+
+ // The resizer needs to be attached to the node parent, so we first need to be
+ // sure that `node` is attached to the DOM before injecting the resizer element.
+ watchForRender(node, function() {
+ if (expando.resizer) {
+ var container = node.parentNode;
+ if (container && container !== resizer.parentNode) {
+ container.insertBefore(resizer, container.firstChild);
+ }
+ }
+ });
+}
+
+function removeResizeListener(node) {
+ var expando = node[EXPANDO_KEY] || {};
+ var resizer = expando.resizer;
+
+ delete expando.resizer;
+ unwatchForRender(node);
+
+ if (resizer && resizer.parentNode) {
resizer.parentNode.removeChild(resizer);
- node._chartjs.resizer = null;
+ }
+}
+
+function injectCSS(platform, css) {
+ // http://stackoverflow.com/q/3922139
+ var style = platform._style || document.createElement('style');
+ if (!platform._style) {
+ platform._style = style;
+ css = '/* Chart.js */\n' + css;
+ style.setAttribute('type', 'text/css');
+ document.getElementsByTagName('head')[0].appendChild(style);
}
- delete node._chartjs;
+ style.appendChild(document.createTextNode(css));
}
module.exports = {
+ initialize: function() {
+ var keyframes = 'from{opacity:0.99}to{opacity:1}';
+
+ injectCSS(this,
+ // DOM rendering detection
+ // https://davidwalsh.name/detect-node-insertion
+ '@-webkit-keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
+ '@keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
+ '.' + CSS_RENDER_MONITOR + '{' +
+ '-webkit-animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
+ 'animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
+ '}'
+ );
+ },
+
acquireContext: function(item, config) {
if (typeof item === 'string') {
item = document.getElementById(item);
@@ -259,11 +333,11 @@ module.exports = {
releaseContext: function(context) {
var canvas = context.canvas;
- if (!canvas._chartjs) {
+ if (!canvas[EXPANDO_KEY]) {
return;
}
- var initial = canvas._chartjs.initial;
+ var initial = canvas[EXPANDO_KEY].initial;
['height', 'width'].forEach(function(prop) {
var value = initial[prop];
if (helpers.isNullOrUndef(value)) {
@@ -283,19 +357,19 @@ module.exports = {
// https://www.w3.org/TR/2011/WD-html5-20110525/the-canvas-element.html
canvas.width = canvas.width;
- delete canvas._chartjs;
+ delete canvas[EXPANDO_KEY];
},
addEventListener: function(chart, type, listener) {
var canvas = chart.canvas;
if (type === 'resize') {
// Note: the resize event is not supported on all browsers.
- addResizeListener(canvas.parentNode, listener, chart);
+ addResizeListener(canvas, listener, chart);
return;
}
- var stub = listener._chartjs || (listener._chartjs = {});
- var proxies = stub.proxies || (stub.proxies = {});
+ var expando = listener[EXPANDO_KEY] || (listener[EXPANDO_KEY] = {});
+ var proxies = expando.proxies || (expando.proxies = {});
var proxy = proxies[chart.id + '_' + type] = function(event) {
listener(fromNativeEvent(event, chart));
};
@@ -307,12 +381,12 @@ module.exports = {
var canvas = chart.canvas;
if (type === 'resize') {
// Note: the resize event is not supported on all browsers.
- removeResizeListener(canvas.parentNode, listener);
+ removeResizeListener(canvas, listener);
return;
}
- var stub = listener._chartjs || {};
- var proxies = stub.proxies || {};
+ var expando = listener[EXPANDO_KEY] || {};
+ var proxies = expando.proxies || {};
var proxy = proxies[chart.id + '_' + type];
if (!proxy) {
return; | true |
Other | chartjs | Chart.js | f90ee8c786c24e44a252964c74970382d9c39016.json | Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer. | src/platforms/platform.js | @@ -12,6 +12,11 @@ var implementation = require('./platform.dom');
* @since 2.4.0
*/
module.exports = helpers.extend({
+ /**
+ * @since 2.7.0
+ */
+ initialize: function() {},
+
/**
* Called at chart construction time, returns a context2d instance implementing
* the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}. | true |
Other | chartjs | Chart.js | f90ee8c786c24e44a252964c74970382d9c39016.json | Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer. | test/jasmine.matchers.js | @@ -123,8 +123,8 @@ function toBeChartOfSize() {
var canvas = actual.ctx.canvas;
var style = getComputedStyle(canvas);
var pixelRatio = actual.options.devicePixelRatio || window.devicePixelRatio;
- var dh = parseInt(style.height, 10);
- var dw = parseInt(style.width, 10);
+ var dh = parseInt(style.height, 10) || 0;
+ var dw = parseInt(style.width, 10) || 0;
var rh = canvas.height;
var rw = canvas.width;
var orh = rh / pixelRatio; | true |
Other | chartjs | Chart.js | f90ee8c786c24e44a252964c74970382d9c39016.json | Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer. | test/specs/core.controller.tests.js | @@ -363,6 +363,90 @@ describe('Chart', function() {
});
});
+ // https://github.com/chartjs/Chart.js/issues/3790
+ it('should resize the canvas if attached to the DOM after construction', function(done) {
+ var canvas = document.createElement('canvas');
+ var wrapper = document.createElement('div');
+ var body = window.document.body;
+ var chart = new Chart(canvas, {
+ type: 'line',
+ options: {
+ responsive: true,
+ maintainAspectRatio: false
+ }
+ });
+
+ expect(chart).toBeChartOfSize({
+ dw: 0, dh: 0,
+ rw: 0, rh: 0,
+ });
+
+ wrapper.style.cssText = 'width: 455px; height: 355px';
+ wrapper.appendChild(canvas);
+ body.appendChild(wrapper);
+
+ waitForResize(chart, function() {
+ expect(chart).toBeChartOfSize({
+ dw: 455, dh: 355,
+ rw: 455, rh: 355,
+ });
+
+ body.removeChild(wrapper);
+ chart.destroy();
+ done();
+ });
+ });
+
+ it('should resize the canvas when attached to a different parent', function(done) {
+ var canvas = document.createElement('canvas');
+ var wrapper = document.createElement('div');
+ var body = window.document.body;
+ var chart = new Chart(canvas, {
+ type: 'line',
+ options: {
+ responsive: true,
+ maintainAspectRatio: false
+ }
+ });
+
+ expect(chart).toBeChartOfSize({
+ dw: 0, dh: 0,
+ rw: 0, rh: 0,
+ });
+
+ wrapper.style.cssText = 'width: 455px; height: 355px';
+ wrapper.appendChild(canvas);
+ body.appendChild(wrapper);
+
+ waitForResize(chart, function() {
+ var resizer = wrapper.firstChild;
+ expect(resizer.tagName).toBe('IFRAME');
+ expect(chart).toBeChartOfSize({
+ dw: 455, dh: 355,
+ rw: 455, rh: 355,
+ });
+
+ var target = document.createElement('div');
+ target.style.cssText = 'width: 640px; height: 480px';
+ target.appendChild(canvas);
+ body.appendChild(target);
+
+ waitForResize(chart, function() {
+ expect(target.firstChild).toBe(resizer);
+ expect(wrapper.firstChild).toBe(null);
+ expect(chart).toBeChartOfSize({
+ dw: 640, dh: 480,
+ rw: 640, rh: 480,
+ });
+
+ body.removeChild(wrapper);
+ body.removeChild(target);
+ chart.destroy();
+ done();
+ });
+ });
+ });
+
// https://github.com/chartjs/Chart.js/issues/3521
it('should resize the canvas after the wrapper has been re-attached to the DOM', function(done) {
var chart = acquireChart({
@@ -592,23 +676,26 @@ describe('Chart', function() {
});
describe('controller.destroy', function() {
- it('should remove the resizer element when responsive: true', function() {
+ it('should remove the resizer element when responsive: true', function(done) {
var chart = acquireChart({
options: {
responsive: true
}
});
- var wrapper = chart.canvas.parentNode;
- var resizer = wrapper.firstChild;
+ waitForResize(chart, function() {
+ var wrapper = chart.canvas.parentNode;
+ var resizer = wrapper.firstChild;
+ expect(wrapper.childNodes.length).toBe(2);
+ expect(resizer.tagName).toBe('IFRAME');
- expect(wrapper.childNodes.length).toBe(2);
- expect(resizer.tagName).toBe('IFRAME');
+ chart.destroy();
- chart.destroy();
+ expect(wrapper.childNodes.length).toBe(1);
+ expect(wrapper.firstChild.tagName).toBe('CANVAS');
- expect(wrapper.childNodes.length).toBe(1);
- expect(wrapper.firstChild.tagName).toBe('CANVAS');
+ done();
+ });
});
});
| true |
Other | chartjs | Chart.js | d480e11ea09681d3d95dd827688ff1a3819117ba.json | Render charts only once in time scale tests (#6347) | test/specs/scale.time.tests.js | @@ -1,6 +1,6 @@
// Time scale tests
describe('Time scale tests', function() {
- function createScale(data, options) {
+ function createScale(data, options, dimensions) {
var scaleID = 'myScale';
var mockContext = window.createMockContext();
var Constructor = Chart.scaleService.getScaleConstructor('time');
@@ -13,7 +13,9 @@ describe('Time scale tests', function() {
id: scaleID
});
- scale.update(400, 50);
+ var width = (dimensions && dimensions.width) || 400;
+ var height = (dimensions && dimensions.height) || 50;
+ scale.update(width, height);
return scale;
}
@@ -122,8 +124,7 @@ describe('Time scale tests', function() {
};
var scaleOptions = Chart.scaleService.getScaleDefaults('time');
- var scale = createScale(mockData, scaleOptions);
- scale.update(1000, 200);
+ var scale = createScale(mockData, scaleOptions, {width: 1000, height: 200});
var ticks = getTicksLabels(scale);
// `bounds === 'data'`: first and last ticks removed since outside the data range
@@ -134,8 +135,7 @@ describe('Time scale tests', function() {
var mockData = {
labels: [newDateFromRef(0), newDateFromRef(1), newDateFromRef(2), newDateFromRef(4), newDateFromRef(6), newDateFromRef(7), newDateFromRef(9)], // days
};
- var scale = createScale(mockData, Chart.scaleService.getScaleDefaults('time'));
- scale.update(1000, 200);
+ var scale = createScale(mockData, Chart.scaleService.getScaleDefaults('time'), {width: 1000, height: 200});
var ticks = getTicksLabels(scale);
// `bounds === 'data'`: first and last ticks removed since outside the data range
@@ -181,10 +181,9 @@ describe('Time scale tests', function() {
}],
}
}
- });
+ }, {canvas: {width: 800, height: 200}});
var xScale = chart.scales.xScale0;
- xScale.update(800, 200);
var ticks = getTicksLabels(xScale);
// `bounds === 'data'`: first and last ticks removed since outside the data range
@@ -230,10 +229,9 @@ describe('Time scale tests', function() {
}],
}
}
- });
+ }, {canvas: {width: 800, height: 200}});
var tScale = chart.scales.tScale0;
- tScale.update(800, 200);
var ticks = getTicksLabels(tScale);
// `bounds === 'data'`: first and last ticks removed since outside the data range
@@ -290,8 +288,7 @@ describe('Time scale tests', function() {
var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('time'));
config.time.unit = 'hour';
- var scale = createScale(mockData, config);
- scale.update(2500, 200);
+ var scale = createScale(mockData, config, {width: 2500, height: 200});
var ticks = getTicksLabels(scale);
expect(ticks).toEqual(['8PM', '9PM', '10PM', '11PM', '12AM', '1AM', '2AM', '3AM', '4AM', '5AM', '6AM', '7AM', '8AM', '9AM', '10AM', '11AM', '12PM', '1PM', '2PM', '3PM', '4PM', '5PM', '6PM', '7PM', '8PM', '9PM']);
@@ -383,8 +380,7 @@ describe('Time scale tests', function() {
}
}, Chart.scaleService.getScaleDefaults('time'));
- var scale = createScale(mockData, config);
- scale.update(800, 200);
+ var scale = createScale(mockData, config, {width: 800, height: 200});
var ticks = getTicksLabels(scale);
// last date is feb 15 because we round to start of week
@@ -405,8 +401,7 @@ describe('Time scale tests', function() {
}
}, Chart.scaleService.getScaleDefaults('time'));
- var scale = createScale(mockData, config);
- scale.update(2500, 200);
+ var scale = createScale(mockData, config, {width: 2500, height: 200});
var ticks = getTicksLabels(scale);
expect(ticks).toEqual(['8PM', '10PM']);
@@ -600,10 +595,9 @@ describe('Time scale tests', function() {
}],
}
}
- });
+ }, {canvas: {width: 800, height: 200}});
this.scale = this.chart.scales.xScale0;
- this.scale.update(800, 200);
});
it('should be bounded by nearest step\'s year start and end', function() { | false |
Other | chartjs | Chart.js | d81914ea29aa8fd26a6aef286b37922a267b2252.json | Adjust virtical alignment of tooptip items (#6292) | src/core/core.tooltip.js | @@ -748,25 +748,26 @@ var exports = Element.extend({
drawTitle: function(pt, vm, ctx) {
var title = vm.title;
+ var length = title.length;
+ var titleFontSize, titleSpacing, i;
- if (title.length) {
+ if (length) {
pt.x = getAlignedX(vm, vm._titleAlign);
ctx.textAlign = vm._titleAlign;
- ctx.textBaseline = 'top';
+ ctx.textBaseline = 'middle';
- var titleFontSize = vm.titleFontSize;
- var titleSpacing = vm.titleSpacing;
+ titleFontSize = vm.titleFontSize;
+ titleSpacing = vm.titleSpacing;
ctx.fillStyle = vm.titleFontColor;
ctx.font = helpers.fontString(titleFontSize, vm._titleFontStyle, vm._titleFontFamily);
- var i, len;
- for (i = 0, len = title.length; i < len; ++i) {
- ctx.fillText(title[i], pt.x, pt.y);
+ for (i = 0; i < length; ++i) {
+ ctx.fillText(title[i], pt.x, pt.y + titleFontSize / 2);
pt.y += titleFontSize + titleSpacing; // Line Height and spacing
- if (i + 1 === title.length) {
+ if (i + 1 === length) {
pt.y += vm.titleMarginBottom - titleSpacing; // If Last, add margin, remove spacing
}
}
@@ -779,23 +780,22 @@ var exports = Element.extend({
var bodyAlign = vm._bodyAlign;
var body = vm.body;
var drawColorBoxes = vm.displayColors;
- var labelColors = vm.labelColors;
var xLinePadding = 0;
var colorX = drawColorBoxes ? getAlignedX(vm, 'left') : 0;
- var textColor;
+
+ var fillLineOfText = function(line) {
+ ctx.fillText(line, pt.x + xLinePadding, pt.y + bodyFontSize / 2);
+ pt.y += bodyFontSize + bodySpacing;
+ };
+
+ var bodyItem, textColor, labelColors, lines, i, j, ilen, jlen;
ctx.textAlign = bodyAlign;
- ctx.textBaseline = 'top';
+ ctx.textBaseline = 'middle';
ctx.font = helpers.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
pt.x = getAlignedX(vm, bodyAlign);
- // Before Body
- var fillLineOfText = function(line) {
- ctx.fillText(line, pt.x + xLinePadding, pt.y);
- pt.y += bodyFontSize + bodySpacing;
- };
-
// Before body lines
ctx.fillStyle = vm.bodyFontColor;
helpers.each(vm.beforeBody, fillLineOfText);
@@ -805,12 +805,16 @@ var exports = Element.extend({
: 0;
// Draw body lines now
- helpers.each(body, function(bodyItem, i) {
+ for (i = 0, ilen = body.length; i < ilen; ++i) {
+ bodyItem = body[i];
textColor = vm.labelTextColors[i];
+ labelColors = vm.labelColors[i];
+
ctx.fillStyle = textColor;
helpers.each(bodyItem.before, fillLineOfText);
- helpers.each(bodyItem.lines, function(line) {
+ lines = bodyItem.lines;
+ for (j = 0, jlen = lines.length; j < jlen; ++j) {
// Draw Legend-like boxes if needed
if (drawColorBoxes) {
// Fill a white rect so that colours merge nicely if the opacity is < 1
@@ -819,20 +823,20 @@ var exports = Element.extend({
// Border
ctx.lineWidth = 1;
- ctx.strokeStyle = labelColors[i].borderColor;
+ ctx.strokeStyle = labelColors.borderColor;
ctx.strokeRect(colorX, pt.y, bodyFontSize, bodyFontSize);
// Inner square
- ctx.fillStyle = labelColors[i].backgroundColor;
+ ctx.fillStyle = labelColors.backgroundColor;
ctx.fillRect(colorX + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2);
ctx.fillStyle = textColor;
}
- fillLineOfText(line);
- });
+ fillLineOfText(lines[j]);
+ }
helpers.each(bodyItem.after, fillLineOfText);
- });
+ }
// Reset back to 0 for after body
xLinePadding = 0;
@@ -844,21 +848,25 @@ var exports = Element.extend({
drawFooter: function(pt, vm, ctx) {
var footer = vm.footer;
+ var length = footer.length;
+ var footerFontSize, i;
- if (footer.length) {
+ if (length) {
pt.x = getAlignedX(vm, vm._footerAlign);
pt.y += vm.footerMarginTop;
ctx.textAlign = vm._footerAlign;
- ctx.textBaseline = 'top';
+ ctx.textBaseline = 'middle';
+
+ footerFontSize = vm.footerFontSize;
ctx.fillStyle = vm.footerFontColor;
- ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
+ ctx.font = helpers.fontString(footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
- helpers.each(footer, function(line) {
- ctx.fillText(line, pt.x, pt.y);
- pt.y += vm.footerFontSize + vm.footerSpacing;
- });
+ for (i = 0; i < length; ++i) {
+ ctx.fillText(footer[i], pt.x, pt.y + footerFontSize / 2);
+ pt.y += footerFontSize + vm.footerSpacing;
+ }
}
},
| true |
Other | chartjs | Chart.js | d81914ea29aa8fd26a6aef286b37922a267b2252.json | Adjust virtical alignment of tooptip items (#6292) | src/plugins/plugin.legend.js | @@ -256,7 +256,7 @@ var Legend = Element.extend({
var totalHeight = 0;
ctx.textAlign = 'left';
- ctx.textBaseline = 'top';
+ ctx.textBaseline = 'middle';
helpers.each(me.legendItems, function(legendItem, i) {
var boxWidth = getBoxWidth(labelOpts, fontSize); | true |
Other | chartjs | Chart.js | d81914ea29aa8fd26a6aef286b37922a267b2252.json | Adjust virtical alignment of tooptip items (#6292) | test/specs/core.tooltip.tests.js | @@ -1208,14 +1208,14 @@ describe('Core.Tooltip', function() {
expect(mockContext.getCalls()).toEqual(Array.prototype.concat(drawBody, [
{name: 'setTextAlign', args: ['left']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['title', 105, 105]},
+ {name: 'fillText', args: ['title', 105, 111]},
{name: 'setTextAlign', args: ['left']},
{name: 'setFillStyle', args: ['#fff']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['label', 105, 123]},
+ {name: 'fillText', args: ['label', 105, 129]},
{name: 'setTextAlign', args: ['left']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['footer', 105, 141]},
+ {name: 'fillText', args: ['footer', 105, 147]},
{name: 'restore', args: []}
]));
});
@@ -1228,14 +1228,14 @@ describe('Core.Tooltip', function() {
expect(mockContext.getCalls()).toEqual(Array.prototype.concat(drawBody, [
{name: 'setTextAlign', args: ['right']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['title', 195, 105]},
+ {name: 'fillText', args: ['title', 195, 111]},
{name: 'setTextAlign', args: ['right']},
{name: 'setFillStyle', args: ['#fff']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['label', 195, 123]},
+ {name: 'fillText', args: ['label', 195, 129]},
{name: 'setTextAlign', args: ['right']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['footer', 195, 141]},
+ {name: 'fillText', args: ['footer', 195, 147]},
{name: 'restore', args: []}
]));
});
@@ -1248,14 +1248,14 @@ describe('Core.Tooltip', function() {
expect(mockContext.getCalls()).toEqual(Array.prototype.concat(drawBody, [
{name: 'setTextAlign', args: ['center']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['title', 150, 105]},
+ {name: 'fillText', args: ['title', 150, 111]},
{name: 'setTextAlign', args: ['center']},
{name: 'setFillStyle', args: ['#fff']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['label', 150, 123]},
+ {name: 'fillText', args: ['label', 150, 129]},
{name: 'setTextAlign', args: ['center']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['footer', 150, 141]},
+ {name: 'fillText', args: ['footer', 150, 147]},
{name: 'restore', args: []}
]));
});
@@ -1268,14 +1268,14 @@ describe('Core.Tooltip', function() {
expect(mockContext.getCalls()).toEqual(Array.prototype.concat(drawBody, [
{name: 'setTextAlign', args: ['right']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['title', 195, 105]},
+ {name: 'fillText', args: ['title', 195, 111]},
{name: 'setTextAlign', args: ['center']},
{name: 'setFillStyle', args: ['#fff']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['label', 150, 123]},
+ {name: 'fillText', args: ['label', 150, 129]},
{name: 'setTextAlign', args: ['left']},
{name: 'setFillStyle', args: ['#fff']},
- {name: 'fillText', args: ['footer', 105, 141]},
+ {name: 'fillText', args: ['footer', 105, 147]},
{name: 'restore', args: []}
]));
}); | true |
Other | chartjs | Chart.js | bb5f12ad2abea9b92d1d2d1bae991a26a95c3cfb.json | Support object values for bar charts (#6323)
* Support object values for bar charts
* Check if null or undefined
* Refactor category scale code
* Make isNullOrUndef global | src/scales/scale.category.js | @@ -1,7 +1,10 @@
'use strict';
+var helpers = require('../helpers/index');
var Scale = require('../core/core.scale');
+var isNullOrUndef = helpers.isNullOrUndef;
+
var defaultConfig = {
position: 'bottom'
};
@@ -10,31 +13,43 @@ module.exports = Scale.extend({
determineDataLimits: function() {
var me = this;
var labels = me._getLabels();
- me.minIndex = 0;
- me.maxIndex = labels.length - 1;
+ var ticksOpts = me.options.ticks;
+ var min = ticksOpts.min;
+ var max = ticksOpts.max;
+ var minIndex = 0;
+ var maxIndex = labels.length - 1;
var findIndex;
- if (me.options.ticks.min !== undefined) {
+ if (min !== undefined) {
// user specified min value
- findIndex = labels.indexOf(me.options.ticks.min);
- me.minIndex = findIndex !== -1 ? findIndex : me.minIndex;
+ findIndex = labels.indexOf(min);
+ if (findIndex >= 0) {
+ minIndex = findIndex;
+ }
}
- if (me.options.ticks.max !== undefined) {
+ if (max !== undefined) {
// user specified max value
- findIndex = labels.indexOf(me.options.ticks.max);
- me.maxIndex = findIndex !== -1 ? findIndex : me.maxIndex;
+ findIndex = labels.indexOf(max);
+ if (findIndex >= 0) {
+ maxIndex = findIndex;
+ }
}
- me.min = labels[me.minIndex];
- me.max = labels[me.maxIndex];
+ me.minIndex = minIndex;
+ me.maxIndex = maxIndex;
+ me.min = labels[minIndex];
+ me.max = labels[maxIndex];
},
buildTicks: function() {
var me = this;
var labels = me._getLabels();
+ var minIndex = me.minIndex;
+ var maxIndex = me.maxIndex;
+
// If we are viewing some subset of labels, slice the original array
- me.ticks = (me.minIndex === 0 && me.maxIndex === labels.length - 1) ? labels : labels.slice(me.minIndex, me.maxIndex + 1);
+ me.ticks = (minIndex === 0 && maxIndex === labels.length - 1) ? labels : labels.slice(minIndex, maxIndex + 1);
},
getLabelForIndex: function(index, datasetIndex) {
@@ -49,61 +64,58 @@ module.exports = Scale.extend({
},
// Used to get data value locations. Value can either be an index or a numerical value
- getPixelForValue: function(value, index) {
+ getPixelForValue: function(value, index, datasetIndex) {
var me = this;
var offset = me.options.offset;
+
// 1 is added because we need the length but we have the indexes
- var offsetAmt = Math.max((me.maxIndex + 1 - me.minIndex - (offset ? 0 : 1)), 1);
+ var offsetAmt = Math.max(me.maxIndex + 1 - me.minIndex - (offset ? 0 : 1), 1);
+
+ var isHorizontal = me.isHorizontal();
+ var valueDimension = (isHorizontal ? me.width : me.height) / offsetAmt;
+ var valueCategory, labels, idx, pixel;
+
+ if (!isNullOrUndef(index) && !isNullOrUndef(datasetIndex)) {
+ value = me.chart.data.datasets[datasetIndex].data[index];
+ }
// If value is a data object, then index is the index in the data array,
// not the index of the scale. We need to change that.
- var valueCategory;
- if (value !== undefined && value !== null) {
- valueCategory = me.isHorizontal() ? value.x : value.y;
+ if (!isNullOrUndef(value)) {
+ valueCategory = isHorizontal ? value.x : value.y;
}
if (valueCategory !== undefined || (value !== undefined && isNaN(index))) {
- var labels = me._getLabels();
- value = valueCategory || value;
- var idx = labels.indexOf(value);
+ labels = me._getLabels();
+ value = helpers.valueOrDefault(valueCategory, value);
+ idx = labels.indexOf(value);
index = idx !== -1 ? idx : index;
}
- if (me.isHorizontal()) {
- var valueWidth = me.width / offsetAmt;
- var widthOffset = (valueWidth * (index - me.minIndex));
-
- if (offset) {
- widthOffset += (valueWidth / 2);
- }
-
- return me.left + widthOffset;
- }
- var valueHeight = me.height / offsetAmt;
- var heightOffset = (valueHeight * (index - me.minIndex));
+ pixel = valueDimension * (index - me.minIndex);
if (offset) {
- heightOffset += (valueHeight / 2);
+ pixel += valueDimension / 2;
}
- return me.top + heightOffset;
+ return (isHorizontal ? me.left : me.top) + pixel;
},
getPixelForTick: function(index) {
- return this.getPixelForValue(this.ticks[index], index + this.minIndex, null);
+ return this.getPixelForValue(this.ticks[index], index + this.minIndex);
},
getValueForPixel: function(pixel) {
var me = this;
var offset = me.options.offset;
+ var offsetAmt = Math.max(me._ticks.length - (offset ? 0 : 1), 1);
+ var isHorizontal = me.isHorizontal();
+ var valueDimension = (isHorizontal ? me.width : me.height) / offsetAmt;
var value;
- var offsetAmt = Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
- var horz = me.isHorizontal();
- var valueDimension = (horz ? me.width : me.height) / offsetAmt;
- pixel -= horz ? me.left : me.top;
+ pixel -= isHorizontal ? me.left : me.top;
if (offset) {
- pixel -= (valueDimension / 2);
+ pixel -= valueDimension / 2;
}
if (pixel <= 0) { | true |
Other | chartjs | Chart.js | bb5f12ad2abea9b92d1d2d1bae991a26a95c3cfb.json | Support object values for bar charts (#6323)
* Support object values for bar charts
* Check if null or undefined
* Refactor category scale code
* Make isNullOrUndef global | test/specs/scale.category.tests.js | @@ -390,4 +390,157 @@ describe('Category scale tests', function() {
expect(yScale.getPixelForValue(0, 1, 0)).toBeCloseToPixel(107);
expect(yScale.getPixelForValue(0, 3, 0)).toBeCloseToPixel(407);
});
+
+ it('Should get the correct pixel for an object value when horizontal', function() {
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ xAxisID: 'xScale0',
+ yAxisID: 'yScale0',
+ data: [
+ {x: 0, y: 10},
+ {x: 1, y: 5},
+ {x: 2, y: 0},
+ {x: 3, y: 25},
+ {x: 0, y: 78}
+ ]
+ }],
+ labels: [0, 1, 2, 3]
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'xScale0',
+ type: 'category',
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'yScale0',
+ type: 'linear'
+ }]
+ }
+ }
+ });
+
+ var xScale = chart.scales.xScale0;
+ expect(xScale.getPixelForValue({x: 0, y: 10}, 0, 0)).toBeCloseToPixel(29);
+ expect(xScale.getPixelForValue({x: 3, y: 25}, 3, 0)).toBeCloseToPixel(506);
+ expect(xScale.getPixelForValue({x: 0, y: 78}, 4, 0)).toBeCloseToPixel(29);
+ });
+
+ it('Should get the correct pixel for an object value when vertical', function() {
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ xAxisID: 'xScale0',
+ yAxisID: 'yScale0',
+ data: [
+ {x: 0, y: 2},
+ {x: 1, y: 4},
+ {x: 2, y: 0},
+ {x: 3, y: 3},
+ {x: 0, y: 1}
+ ]
+ }],
+ labels: [0, 1, 2, 3],
+ yLabels: [0, 1, 2, 3, 4]
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'xScale0',
+ type: 'category',
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'yScale0',
+ type: 'category',
+ position: 'left'
+ }]
+ }
+ }
+ });
+
+ var yScale = chart.scales.yScale0;
+ expect(yScale.getPixelForValue({x: 0, y: 2}, 0, 0)).toBeCloseToPixel(257);
+ expect(yScale.getPixelForValue({x: 0, y: 1}, 4, 0)).toBeCloseToPixel(144);
+ });
+
+ it('Should get the correct pixel for an object value in a bar chart', function() {
+ var chart = window.acquireChart({
+ type: 'bar',
+ data: {
+ datasets: [{
+ xAxisID: 'xScale0',
+ yAxisID: 'yScale0',
+ data: [
+ {x: 0, y: 10},
+ {x: 1, y: 5},
+ {x: 2, y: 0},
+ {x: 3, y: 25},
+ {x: 0, y: 78}
+ ]
+ }],
+ labels: [0, 1, 2, 3]
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'xScale0',
+ type: 'category',
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'yScale0',
+ type: 'linear'
+ }]
+ }
+ }
+ });
+
+ var xScale = chart.scales.xScale0;
+ expect(xScale.getPixelForValue(null, 0, 0)).toBeCloseToPixel(89);
+ expect(xScale.getPixelForValue(null, 3, 0)).toBeCloseToPixel(449);
+ expect(xScale.getPixelForValue(null, 4, 0)).toBeCloseToPixel(89);
+ });
+
+ it('Should get the correct pixel for an object value in a horizontal bar chart', function() {
+ var chart = window.acquireChart({
+ type: 'horizontalBar',
+ data: {
+ datasets: [{
+ xAxisID: 'xScale0',
+ yAxisID: 'yScale0',
+ data: [
+ {x: 10, y: 0},
+ {x: 5, y: 1},
+ {x: 0, y: 2},
+ {x: 25, y: 3},
+ {x: 78, y: 0}
+ ]
+ }],
+ labels: [0, 1, 2, 3]
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'xScale0',
+ type: 'linear',
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'yScale0',
+ type: 'category'
+ }]
+ }
+ }
+ });
+
+ var yScale = chart.scales.yScale0;
+ expect(yScale.getPixelForValue(null, 0, 0)).toBeCloseToPixel(88);
+ expect(yScale.getPixelForValue(null, 3, 0)).toBeCloseToPixel(426);
+ expect(yScale.getPixelForValue(null, 4, 0)).toBeCloseToPixel(88);
+ });
}); | true |
Other | chartjs | Chart.js | 9eecdf4da1bf79169642edd93275236d1aa9851b.json | Update dataset metadata when axisID changes (#6321) | src/core/core.datasetController.js | @@ -139,13 +139,16 @@ helpers.extend(DatasetController.prototype, {
linkScales: function() {
var me = this;
var meta = me.getMeta();
+ var chart = me.chart;
+ var scales = chart.scales;
var dataset = me.getDataset();
+ var scalesOpts = chart.options.scales;
- if (meta.xAxisID === null || !(meta.xAxisID in me.chart.scales)) {
- meta.xAxisID = dataset.xAxisID || me.chart.options.scales.xAxes[0].id;
+ if (meta.xAxisID === null || !(meta.xAxisID in scales) || dataset.xAxisID) {
+ meta.xAxisID = dataset.xAxisID || scalesOpts.xAxes[0].id;
}
- if (meta.yAxisID === null || !(meta.yAxisID in me.chart.scales)) {
- meta.yAxisID = dataset.yAxisID || me.chart.options.scales.yAxes[0].id;
+ if (meta.yAxisID === null || !(meta.yAxisID in scales) || dataset.yAxisID) {
+ meta.yAxisID = dataset.yAxisID || scalesOpts.yAxes[0].id;
}
},
| true |
Other | chartjs | Chart.js | 9eecdf4da1bf79169642edd93275236d1aa9851b.json | Update dataset metadata when axisID changes (#6321) | test/specs/core.datasetController.tests.js | @@ -221,6 +221,45 @@ describe('Chart.DatasetController', function() {
expect(meta.data.length).toBe(42);
});
+ it('should re-synchronize metadata when scaleID changes', function() {
+ var chart = acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ data: [],
+ xAxisID: 'firstXScaleID',
+ yAxisID: 'firstYScaleID',
+ }]
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'firstXScaleID'
+ }, {
+ id: 'secondXScaleID'
+ }],
+ yAxes: [{
+ id: 'firstYScaleID'
+ }, {
+ id: 'secondYScaleID'
+ }]
+ }
+ }
+ });
+
+ var meta = chart.getDatasetMeta(0);
+
+ expect(meta.xAxisID).toBe('firstXScaleID');
+ expect(meta.yAxisID).toBe('firstYScaleID');
+
+ chart.data.datasets[0].xAxisID = 'secondXScaleID';
+ chart.data.datasets[0].yAxisID = 'secondYScaleID';
+ chart.update();
+
+ expect(meta.xAxisID).toBe('secondXScaleID');
+ expect(meta.yAxisID).toBe('secondYScaleID');
+ });
+
it('should cleanup attached properties when the reference changes or when the chart is destroyed', function() {
var data0 = [0, 1, 2, 3, 4, 5];
var data1 = [6, 7, 8]; | true |
Other | chartjs | Chart.js | b02a3a8175152d5e6d2bed54d5f0348ee9b3d840.json | Fix regression with lineTension (#6288) | docs/charts/radar.md | @@ -75,7 +75,7 @@ The radar chart allows a number of properties to be specified for each dataset.
| [`borderWidth`](#line-styling) | `number` | Yes | - | `3`
| [`fill`](#line-styling) | <code>boolean|string</code> | Yes | - | `true`
| [`label`](#general) | `string` | - | - | `''`
-| [`lineTension`](#line-styling) | `number` | - | - | `0.4`
+| [`lineTension`](#line-styling) | `number` | - | - | `0`
| [`pointBackgroundColor`](#point-styling) | `Color` | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
| [`pointBorderColor`](#point-styling) | `Color` | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
| [`pointBorderWidth`](#point-styling) | `number` | Yes | Yes | `1` | true |
Other | chartjs | Chart.js | b02a3a8175152d5e6d2bed54d5f0348ee9b3d840.json | Fix regression with lineTension (#6288) | src/controllers/controller.line.js | @@ -73,8 +73,8 @@ module.exports = DatasetController.extend({
var line = meta.dataset;
var points = meta.data || [];
var options = me.chart.options;
- var dataset = me.getDataset();
- var showLine = me._showLine = valueOrDefault(me._config.showLine, options.showLines);
+ var config = me._config;
+ var showLine = me._showLine = valueOrDefault(config.showLine, options.showLines);
var i, ilen;
me._xScale = me.getScaleForId(meta.xAxisID);
@@ -83,8 +83,8 @@ module.exports = DatasetController.extend({
// Update Line
if (showLine) {
// Compatibility: If the properties are defined with only the old name, use those values
- if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
- dataset.lineTension = dataset.tension;
+ if (config.tension !== undefined && config.lineTension === undefined) {
+ config.lineTension = config.tension;
}
// Utility
@@ -161,7 +161,7 @@ module.exports = DatasetController.extend({
*/
_resolveDatasetElementOptions: function(element) {
var me = this;
- var datasetOpts = me._config;
+ var config = me._config;
var custom = element.custom || {};
var options = me.chart.options;
var lineOptions = options.elements.line;
@@ -170,9 +170,9 @@ module.exports = DatasetController.extend({
// The default behavior of lines is to break at null values, according
// to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
// This option gives lines the ability to span gaps
- values.spanGaps = valueOrDefault(datasetOpts.spanGaps, options.spanGaps);
- values.tension = valueOrDefault(datasetOpts.lineTension, lineOptions.tension);
- values.steppedLine = resolve([custom.steppedLine, datasetOpts.steppedLine, lineOptions.stepped]);
+ values.spanGaps = valueOrDefault(config.spanGaps, options.spanGaps);
+ values.tension = valueOrDefault(config.lineTension, lineOptions.tension);
+ values.steppedLine = resolve([custom.steppedLine, config.steppedLine, lineOptions.stepped]);
return values;
}, | true |
Other | chartjs | Chart.js | b02a3a8175152d5e6d2bed54d5f0348ee9b3d840.json | Fix regression with lineTension (#6288) | src/controllers/controller.radar.js | @@ -69,12 +69,12 @@ module.exports = DatasetController.extend({
var line = meta.dataset;
var points = meta.data || [];
var scale = me.chart.scale;
- var dataset = me.getDataset();
+ var config = me._config;
var i, ilen;
// Compatibility: If the properties are defined with only the old name, use those values
- if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
- dataset.lineTension = dataset.tension;
+ if (config.tension !== undefined && config.lineTension === undefined) {
+ config.lineTension = config.tension;
}
// Utility | true |
Other | chartjs | Chart.js | abbddd1298c6dee2e294bf6689b4e62160087347.json | Allow specifying labels in time scale options (#6257) | docs/axes/cartesian/time.md | @@ -149,7 +149,7 @@ The `ticks.source` property controls the ticks generation.
* `'auto'`: generates "optimal" ticks based on scale size and time options
* `'data'`: generates ticks from data (including labels from data `{t|x|y}` objects)
-* `'labels'`: generates ticks from user given `data.labels` values ONLY
+* `'labels'`: generates ticks from user given `labels` ONLY
### Parser
If this property is defined as a string, it is interpreted as a custom format to be used by Moment.js to parse the date. | true |
Other | chartjs | Chart.js | abbddd1298c6dee2e294bf6689b4e62160087347.json | Allow specifying labels in time scale options (#6257) | src/core/core.scale.js | @@ -214,6 +214,14 @@ var Scale = Element.extend({
return this._ticks;
},
+ /**
+ * @private
+ */
+ _getLabels: function() {
+ var data = this.chart.data;
+ return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
+ },
+
// These methods are ordered by lifecyle. Utilities then follow.
// Any function defined here is inherited by all scale types.
// Any function can be extended by the scale type | true |
Other | chartjs | Chart.js | abbddd1298c6dee2e294bf6689b4e62160087347.json | Allow specifying labels in time scale options (#6257) | src/scales/scale.category.js | @@ -7,19 +7,9 @@ var defaultConfig = {
};
module.exports = Scale.extend({
- /**
- * Internal function to get the correct labels. If data.xLabels or data.yLabels are defined, use those
- * else fall back to data.labels
- * @private
- */
- getLabels: function() {
- var data = this.chart.data;
- return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
- },
-
determineDataLimits: function() {
var me = this;
- var labels = me.getLabels();
+ var labels = me._getLabels();
me.minIndex = 0;
me.maxIndex = labels.length - 1;
var findIndex;
@@ -42,7 +32,7 @@ module.exports = Scale.extend({
buildTicks: function() {
var me = this;
- var labels = me.getLabels();
+ var labels = me._getLabels();
// If we are viewing some subset of labels, slice the original array
me.ticks = (me.minIndex === 0 && me.maxIndex === labels.length - 1) ? labels : labels.slice(me.minIndex, me.maxIndex + 1);
},
@@ -72,7 +62,7 @@ module.exports = Scale.extend({
valueCategory = me.isHorizontal() ? value.x : value.y;
}
if (valueCategory !== undefined || (value !== undefined && isNaN(index))) {
- var labels = me.getLabels();
+ var labels = me._getLabels();
value = valueCategory || value;
var idx = labels.indexOf(value);
index = idx !== -1 ? idx : index; | true |
Other | chartjs | Chart.js | abbddd1298c6dee2e294bf6689b4e62160087347.json | Allow specifying labels in time scale options (#6257) | src/scales/scale.time.js | @@ -519,7 +519,7 @@ module.exports = Scale.extend({
var datasets = [];
var labels = [];
var i, j, ilen, jlen, data, timestamp;
- var dataLabels = chart.data.labels || [];
+ var dataLabels = me._getLabels();
// Convert labels to timestamps
for (i = 0, ilen = dataLabels.length; i < ilen; ++i) { | true |
Other | chartjs | Chart.js | abbddd1298c6dee2e294bf6689b4e62160087347.json | Allow specifying labels in time scale options (#6257) | test/specs/scale.time.tests.js | @@ -1682,6 +1682,57 @@ describe('Time scale tests', function() {
});
});
+ describe('labels', function() {
+ it('should read labels from scale / xLabels / yLabels', function() {
+ var timeOpts = {
+ parser: 'YYYY',
+ unit: 'year',
+ displayFormats: {
+ year: 'YYYY'
+ }
+ };
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {
+ labels: ['1975', '1976', '1977'],
+ xLabels: ['1985', '1986', '1987'],
+ yLabels: ['1995', '1996', '1997']
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'time',
+ labels: ['2015', '2016', '2017'],
+ time: timeOpts
+ },
+ {
+ id: 'x2',
+ type: 'time',
+ time: timeOpts
+ }],
+ yAxes: [{
+ id: 'y',
+ type: 'time',
+ time: timeOpts
+ },
+ {
+ id: 'y2',
+ type: 'time',
+ labels: ['2005', '2006', '2007'],
+ time: timeOpts
+ }]
+ }
+ }
+ });
+
+ expect(getTicksLabels(chart.scales.x)).toEqual(['2015', '2016', '2017']);
+ expect(getTicksLabels(chart.scales.x2)).toEqual(['1985', '1986', '1987']);
+ expect(getTicksLabels(chart.scales.y)).toEqual(['1995', '1996', '1997']);
+ expect(getTicksLabels(chart.scales.y2)).toEqual(['2005', '2006', '2007']);
+ });
+ });
+
describe('Deprecations', function() {
describe('options.time.displayFormats', function() {
it('should generate defaults from adapter presets', function() { | true |
Other | chartjs | Chart.js | e35b8891ce2144f3ca9a842a316d3dd6ff791027.json | Treat 0 as a valid point label for radial scale (#6279) | src/scales/scale.radialLinear.js | @@ -156,7 +156,7 @@ function fitWithPointLabels(scale) {
var valueCount = getValueCount(scale);
for (i = 0; i < valueCount; i++) {
pointPosition = scale.getPointPosition(i, scale.drawingArea + 5);
- textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i] || '');
+ textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i]);
scale._pointLabelSizes[i] = textSize;
// Add quarter circle to make degree 0 mean top of circle
@@ -247,7 +247,7 @@ function drawPointLabels(scale) {
var angle = helpers.toDegrees(angleRadians);
ctx.textAlign = getTextAlignForAngle(angle);
adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition);
- fillText(ctx, scale.pointLabels[i] || '', pointLabelPosition, plFont.lineHeight);
+ fillText(ctx, scale.pointLabels[i], pointLabelPosition, plFont.lineHeight);
}
ctx.restore();
}
@@ -348,7 +348,10 @@ module.exports = LinearScaleBase.extend({
LinearScaleBase.prototype.convertTicksToLabels.call(me);
// Point labels
- me.pointLabels = me.chart.data.labels.map(me.options.pointLabels.callback, me);
+ me.pointLabels = me.chart.data.labels.map(function() {
+ var label = helpers.callback(me.options.pointLabels.callback, arguments, me);
+ return label || label === 0 ? label : '';
+ });
},
getLabelForIndex: function(index, datasetIndex) { | true |
Other | chartjs | Chart.js | e35b8891ce2144f3ca9a842a316d3dd6ff791027.json | Treat 0 as a valid point label for radial scale (#6279) | test/specs/scale.radialLinear.tests.js | @@ -366,6 +366,20 @@ describe('Test the radial linear scale', function() {
expect(chart.scale.pointLabels).toEqual(['0', '1', '2', '3', '4']);
});
+ it('Should build point labels from falsy values', function() {
+ var chart = window.acquireChart({
+ type: 'radar',
+ data: {
+ datasets: [{
+ data: [10, 5, 0, 25, 78, 20]
+ }],
+ labels: [0, '', undefined, null, NaN, false]
+ }
+ });
+
+ expect(chart.scale.pointLabels).toEqual([0, '', '', '', '', '']);
+ });
+
it('should correctly set the center point', function() {
var chart = window.acquireChart({
type: 'radar', | true |
Other | chartjs | Chart.js | e5c68e2c82cb112af0d71860736ba76cf864701d.json | Fix data in financial sample (#6244) | samples/scales/time/financial.html | @@ -17,6 +17,7 @@
<body>
<div style="width:1000px">
+ <p>This example demonstrates a time series scale by drawing a financial line chart using just the core library. For more specific functionality for financial charts, please see <a href="https://github.com/chartjs/chartjs-chart-financial">chartjs-chart-financial</a></p>
<canvas id="chart1"></canvas>
</div>
<br>
@@ -37,6 +38,27 @@
<button id="update">update</button>
<script>
function generateData() {
+ var unit = document.getElementById('unit').value;
+
+ function unitLessThanDay() {
+ return unit === 'second' || unit === 'minute' || unit === 'hour';
+ }
+
+ function beforeNineThirty(date) {
+ return date.hour() < 9 || (date.hour() === 9 && date.minute() < 30);
+ }
+
+ // Returns true if outside 9:30am-4pm on a weekday
+ function outsideMarketHours(date) {
+ if (date.isoWeekday() > 5) {
+ return true;
+ }
+ if (unitLessThanDay() && (beforeNineThirty(date) || date.hour() > 16)) {
+ return true;
+ }
+ return false;
+ }
+
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
@@ -53,11 +75,17 @@
var date = moment('Jan 01 1990', 'MMM DD YYYY');
var now = moment();
var data = [];
- var unit = document.getElementById('unit').value;
- for (; data.length < 60 && date.isBefore(now); date = date.clone().add(1, unit)) {
- if (date.isoWeekday() <= 5) {
- data.push(randomBar(date, data.length > 0 ? data[data.length - 1].y : 30));
+ var lessThanDay = unitLessThanDay();
+ for (; data.length < 60 && date.isBefore(now); date = date.clone().add(1, unit).startOf(unit)) {
+ if (outsideMarketHours(date)) {
+ if (!lessThanDay || !beforeNineThirty(date)) {
+ date = date.clone().add(date.isoWeekday() >= 5 ? 8 - date.isoWeekday() : 1, 'day');
+ }
+ if (lessThanDay) {
+ date = date.hour(9).minute(30).second(0);
+ }
}
+ data.push(randomBar(date, data.length > 0 ? data[data.length - 1].y : 30));
}
return data; | false |
Other | chartjs | Chart.js | 196274defcd206c7581bd20dd005f650aa63c4f5.json | Use tick.major rather than recomputing (#6265) | src/scales/scale.time.js | @@ -672,10 +672,10 @@ module.exports = Scale.extend({
var minorFormat = formats[me._unit];
var majorUnit = me._majorUnit;
var majorFormat = formats[majorUnit];
- var majorTime = +adapter.startOf(time, majorUnit);
+ var tick = ticks[index];
var tickOpts = options.ticks;
var majorTickOpts = tickOpts.major;
- var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
+ var major = majorTickOpts.enabled && majorUnit && majorFormat && tick && tick.major;
var label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
var nestedTickOpts = major ? majorTickOpts : tickOpts.minor;
var formatter = helpers.options.resolve([
@@ -785,7 +785,7 @@ module.exports = Scale.extend({
// pick the longest format (milliseconds) for guestimation
var format = displayFormats[timeOpts.unit] || displayFormats.millisecond;
- var exampleLabel = me.tickFormatFunction(exampleTime, 0, [], format);
+ var exampleLabel = me.tickFormatFunction(exampleTime, 0, ticksFromTimestamps(me, [exampleTime], me._majorUnit), format);
var size = me._getLabelSize(exampleLabel);
// Using margins instead of padding because padding is not calculated | false |
Other | chartjs | Chart.js | 89f2e04ff057848ae43885089fc0060e375746a2.json | Fix ticks generation for vertical time scale (#6258) | src/scales/scale.time.js | @@ -753,10 +753,9 @@ module.exports = Scale.extend({
},
/**
- * Crude approximation of what the label width might be
* @private
*/
- getLabelWidth: function(label) {
+ _getLabelSize: function(label) {
var me = this;
var ticksOpts = me.options.ticks;
var tickLabelWidth = me.ctx.measureText(label).width;
@@ -765,7 +764,18 @@ module.exports = Scale.extend({
var sinRotation = Math.sin(angle);
var tickFontSize = valueOrDefault(ticksOpts.fontSize, defaults.global.defaultFontSize);
- return (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation);
+ return {
+ w: (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation),
+ h: (tickLabelWidth * sinRotation) + (tickFontSize * cosRotation)
+ };
+ },
+
+ /**
+ * Crude approximation of what the label width might be
+ * @private
+ */
+ getLabelWidth: function(label) {
+ return this._getLabelSize(label).w;
},
/**
@@ -779,17 +789,19 @@ module.exports = Scale.extend({
// pick the longest format (milliseconds) for guestimation
var format = displayFormats[timeOpts.unit] || displayFormats.millisecond;
-
var exampleLabel = me.tickFormatFunction(exampleTime, 0, [], format);
- var tickLabelWidth = me.getLabelWidth(exampleLabel);
+ var size = me._getLabelSize(exampleLabel);
// Using margins instead of padding because padding is not calculated
// at this point (buildTicks). Margins are provided from previous calculation
// in layout steps 5/6
- var innerWidth = me.isHorizontal()
- ? me.width - (margins.left + margins.right)
- : me.height - (margins.top + margins.bottom);
- var capacity = Math.floor(innerWidth / tickLabelWidth);
+ var capacity = Math.floor(me.isHorizontal()
+ ? (me.width - margins.left - margins.right) / size.w
+ : (me.height - margins.top - margins.bottom) / size.h);
+
+ if (me.options.offset) {
+ capacity--;
+ }
return capacity > 0 ? capacity : 1;
} | false |
Other | chartjs | Chart.js | a9d4ebf8810b30c5681ae41ce380522aa7248d40.json | Remove the old slack token used for notifications. (#6245) | .travis.yml | @@ -15,9 +15,6 @@ script:
- gulp bower
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls || true
-notifications:
- slack: chartjs:pcfCZR6ugg5TEcaLtmIfQYuA
-
sudo: required
dist: trusty
| false |
Other | chartjs | Chart.js | ddee91eb9f7f68d64b1634c103ebbc8421b23c7a.json | Fix tooltip title in radar charts (#6238) | src/controllers/controller.radar.js | @@ -27,13 +27,6 @@ module.exports = DatasetController.extend({
return this.chart.scale.id;
},
- /**
- * @private
- */
- _getIndexScaleId: function() {
- return this.chart.scale.id;
- },
-
datasetElementType: elements.Line,
dataElementType: elements.Point, | true |
Other | chartjs | Chart.js | ddee91eb9f7f68d64b1634c103ebbc8421b23c7a.json | Fix tooltip title in radar charts (#6238) | test/specs/controller.radar.tests.js | @@ -444,7 +444,7 @@ describe('Chart.controllers.radar', function() {
expect(meta1.data[0]._model.radius).toBe(20);
});
- it('should return same id for index and value scale', function() {
+ it('should return id for value scale', function() {
var chart = window.acquireChart({
type: 'radar',
data: {
@@ -460,7 +460,6 @@ describe('Chart.controllers.radar', function() {
});
var controller = chart.getDatasetMeta(0).controller;
- expect(controller._getIndexScaleId()).toBe('test');
expect(controller._getValueScaleId()).toBe('test');
});
}); | true |
Other | chartjs | Chart.js | 89af7b1383fffd477e0f6245770920e36450ac58.json | Fix missing tooltip value in radar charts (#6209) | src/controllers/controller.radar.js | @@ -20,6 +20,19 @@ defaults._set('radar', {
});
module.exports = DatasetController.extend({
+ /**
+ * @private
+ */
+ _getValueScaleId: function() {
+ return this.chart.scale.id;
+ },
+
+ /**
+ * @private
+ */
+ _getIndexScaleId: function() {
+ return this.chart.scale.id;
+ },
datasetElementType: elements.Line,
| true |
Other | chartjs | Chart.js | 89af7b1383fffd477e0f6245770920e36450ac58.json | Fix missing tooltip value in radar charts (#6209) | test/specs/controller.radar.tests.js | @@ -443,4 +443,24 @@ describe('Chart.controllers.radar', function() {
expect(meta0.data[0]._model.radius).toBe(10);
expect(meta1.data[0]._model.radius).toBe(20);
});
+
+ it('should return same id for index and value scale', function() {
+ var chart = window.acquireChart({
+ type: 'radar',
+ data: {
+ datasets: [{
+ data: [10, 15, 0, 4],
+ pointBorderWidth: 0
+ }],
+ labels: ['label1', 'label2', 'label3', 'label4']
+ },
+ options: {
+ scale: {id: 'test'}
+ }
+ });
+
+ var controller = chart.getDatasetMeta(0).controller;
+ expect(controller._getIndexScaleId()).toBe('test');
+ expect(controller._getValueScaleId()).toBe('test');
+ });
}); | true |
Other | chartjs | Chart.js | faad02331393b5ae4f07eafc119002fa21966118.json | Fix typo in doughnut documentation (#6186) | docs/charts/doughnut.md | @@ -84,7 +84,7 @@ The following values are supported for `borderAlign`.
* `'center'` (default)
* `'inner'`
-When `'center'` is set, the borders of arcs next to each other will overlap. When `'inner'` is set, it is guaranteed that all the borders are not overlap.
+When `'center'` is set, the borders of arcs next to each other will overlap. When `'inner'` is set, it is guaranteed that all borders will not overlap.
### Interactions
| false |
Other | chartjs | Chart.js | 86ed35446d394ec505d879e79fd29e6ecb199b87.json | Fix hover animations and optimize pivot() (#6129) | src/core/core.element.js | @@ -66,7 +66,7 @@ helpers.extend(Element.prototype, {
pivot: function() {
var me = this;
if (!me._view) {
- me._view = helpers.clone(me._model);
+ me._view = helpers.extend({}, me._model);
}
me._start = {};
return me;
@@ -80,7 +80,7 @@ helpers.extend(Element.prototype, {
// No animation -> No Transition
if (!model || ease === 1) {
- me._view = model;
+ me._view = helpers.extend({}, model);
me._start = null;
return me;
} | true |
Other | chartjs | Chart.js | 86ed35446d394ec505d879e79fd29e6ecb199b87.json | Fix hover animations and optimize pivot() (#6129) | test/specs/core.element.tests.js | @@ -18,6 +18,7 @@ describe('Core element tests', function() {
element.transition(0.25);
expect(element._view).toEqual(element._model);
+ expect(element._view).not.toBe(element._model);
expect(element._view.objectProp).toBe(element._model.objectProp); // not cloned
element._model.numberProp = 100;
@@ -40,5 +41,11 @@ describe('Core element tests', function() {
},
colorProp: 'rgb(64, 64, 0)',
});
+
+ // Final transition clones model into view
+ element.transition(1);
+
+ expect(element._view).toEqual(element._model);
+ expect(element._view).not.toBe(element._model);
});
}); | true |
Other | chartjs | Chart.js | 86ed35446d394ec505d879e79fd29e6ecb199b87.json | Fix hover animations and optimize pivot() (#6129) | test/specs/core.tooltip.tests.js | @@ -137,11 +137,11 @@ describe('Core.Tooltip', function() {
footer: [],
caretPadding: 2,
labelColors: [{
- borderColor: 'rgb(255, 0, 0)',
- backgroundColor: 'rgb(0, 255, 0)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}, {
- borderColor: 'rgb(0, 0, 255)',
- backgroundColor: 'rgb(0, 255, 255)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}]
}));
@@ -338,8 +338,8 @@ describe('Core.Tooltip', function() {
caretPadding: 2,
labelTextColors: ['#fff'],
labelColors: [{
- borderColor: 'rgb(255, 0, 0)',
- backgroundColor: 'rgb(0, 255, 0)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}]
}));
@@ -488,11 +488,11 @@ describe('Core.Tooltip', function() {
caretPadding: 2,
labelTextColors: ['labelTextColor', 'labelTextColor'],
labelColors: [{
- borderColor: 'rgb(255, 0, 0)',
- backgroundColor: 'rgb(0, 255, 0)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}, {
- borderColor: 'rgb(0, 0, 255)',
- backgroundColor: 'rgb(0, 255, 255)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}]
}));
@@ -547,6 +547,7 @@ describe('Core.Tooltip', function() {
// Check and see if tooltip was displayed
var tooltip = chart.tooltip;
+ var globalDefaults = Chart.defaults.global;
expect(tooltip._view).toEqual(jasmine.objectContaining({
// Positioning
@@ -568,11 +569,11 @@ describe('Core.Tooltip', function() {
afterBody: [],
footer: [],
labelColors: [{
- borderColor: 'rgb(0, 0, 255)',
- backgroundColor: 'rgb(0, 255, 255)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}, {
- borderColor: 'rgb(255, 0, 0)',
- backgroundColor: 'rgb(0, 255, 0)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}]
}));
@@ -629,6 +630,7 @@ describe('Core.Tooltip', function() {
// Check and see if tooltip was displayed
var tooltip = chart.tooltip;
+ var globalDefaults = Chart.defaults.global;
expect(tooltip._view).toEqual(jasmine.objectContaining({
// Positioning
@@ -646,8 +648,8 @@ describe('Core.Tooltip', function() {
afterBody: [],
footer: [],
labelColors: [{
- borderColor: 'rgb(0, 0, 255)',
- backgroundColor: 'rgb(0, 255, 255)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}]
}));
});
@@ -1088,11 +1090,11 @@ describe('Core.Tooltip', function() {
caretPadding: 2,
labelTextColors: ['labelTextColor', 'labelTextColor'],
labelColors: [{
- borderColor: 'rgb(255, 0, 0)',
- backgroundColor: 'rgb(0, 255, 0)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}, {
- borderColor: 'rgb(0, 0, 255)',
- backgroundColor: 'rgb(0, 255, 255)'
+ borderColor: globalDefaults.defaultColor,
+ backgroundColor: globalDefaults.defaultColor
}]
}));
}); | true |
Other | chartjs | Chart.js | 87a74f99a1e73fef3ebd314a11c322829c3d7cd1.json | Fix missing Chart.Chart (deprecated) alias (#6112) | src/index.js | @@ -51,6 +51,15 @@ if (typeof window !== 'undefined') {
// DEPRECATIONS
+/**
+ * Provided for backward compatibility, not available anymore
+ * @namespace Chart.Chart
+ * @deprecated since version 2.8.0
+ * @todo remove at version 3
+ * @private
+ */
+Chart.Chart = Chart;
+
/**
* Provided for backward compatibility, not available anymore
* @namespace Chart.Legend | true |
Other | chartjs | Chart.js | 87a74f99a1e73fef3ebd314a11c322829c3d7cd1.json | Fix missing Chart.Chart (deprecated) alias (#6112) | test/specs/global.deprecations.tests.js | @@ -24,6 +24,12 @@ describe('Deprecations', function() {
});
});
+ describe('Chart.Chart', function() {
+ it('should be defined as an alias to Chart', function() {
+ expect(Chart.Chart).toBe(Chart);
+ });
+ });
+
describe('Chart.helpers.aliasPixel', function() {
it('should be defined as a function', function() {
expect(typeof Chart.helpers.aliasPixel).toBe('function'); | true |
Other | chartjs | Chart.js | 31aebf3bab8a6a45edce853360bc469ed42d386e.json | Include generated CSS in the GitHub releases | .travis.yml | @@ -42,13 +42,12 @@ deploy:
branch: release
- provider: releases
api_key: $GITHUB_AUTH_TOKEN
- file:
- - "./dist/Chart.bundle.js"
- - "./dist/Chart.bundle.min.js"
- - "./dist/Chart.js"
- - "./dist/Chart.min.js"
- - "./dist/Chart.js.zip"
skip_cleanup: true
+ file_glob: true
+ file:
+ - ./dist/*.css
+ - ./dist/*.js
+ - ./dist/*.zip
on:
tags: true
- provider: npm | false |
Other | chartjs | Chart.js | 344628ba9c5fc95a1edbc9cf94488461d24a4b32.json | Fix animation regression introduced by #5331 (#6108) | src/core/core.animations.js | @@ -93,20 +93,24 @@ module.exports = {
*/
advance: function() {
var animations = this.animations;
- var animation, chart;
+ var animation, chart, numSteps, nextStep;
var i = 0;
+ // 1 animation per chart, so we are looping charts here
while (i < animations.length) {
animation = animations[i];
chart = animation.chart;
+ numSteps = animation.numSteps;
- animation.currentStep = Math.floor((Date.now() - animation.startTime) / animation.duration * animation.numSteps);
- animation.currentStep = Math.min(animation.currentStep, animation.numSteps);
+ // Make sure that currentStep starts at 1
+ // https://github.com/chartjs/Chart.js/issues/6104
+ nextStep = Math.floor((Date.now() - animation.startTime) / animation.duration * numSteps) + 1;
+ animation.currentStep = Math.min(nextStep, numSteps);
helpers.callback(animation.render, [chart, animation], chart);
helpers.callback(animation.onAnimationProgress, [animation], chart);
- if (animation.currentStep >= animation.numSteps) {
+ if (animation.currentStep >= numSteps) {
helpers.callback(animation.onAnimationComplete, [animation], chart);
chart.animating = false;
animations.splice(i, 1); | false |
Other | chartjs | Chart.js | 946c6d0617bfa0eb21e86f6f75d7f34b2bb1dc85.json | Fix document errors related to ticks (#6099) | docs/axes/cartesian/README.md | @@ -29,10 +29,10 @@ The following options are common to all cartesian axes but do not apply to other
| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what.
| `autoSkipPadding` | `number` | `0` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled.
| `labelOffset` | `number` | `0` | Distance in pixels to offset the label from the centre point of the tick (in the x direction for the x axis, and the y direction for the y axis). *Note: this can cause labels at the edges to be cropped by the edge of the canvas*
-| `maxRotation` | `number` | `90` | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.*
+| `maxRotation` | `number` | `50` | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.*
| `minRotation` | `number` | `0` | Minimum rotation for tick labels. *Note: Only applicable to horizontal scales.*
| `mirror` | `boolean` | `false` | Flips tick labels around axis, displaying the labels inside the chart instead of outside. *Note: Only applicable to vertical scales.*
-| `padding` | `number` | `10` | Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
+| `padding` | `number` | `0` | Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
### Axis ID
The properties `dataset.xAxisID` or `dataset.yAxisID` have to match the scale properties `scales.xAxes.id` or `scales.yAxes.id`. This is especially needed if multi-axes charts are used. | true |
Other | chartjs | Chart.js | 946c6d0617bfa0eb21e86f6f75d7f34b2bb1dc85.json | Fix document errors related to ticks (#6099) | docs/axes/styling.md | @@ -54,10 +54,11 @@ The minorTick configuration is nested under the ticks configuration in the `mino
| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
## Major Tick Configuration
-The majorTick configuration is nested under the ticks configuration in the `major` key. It defines options for the major tick marks that are generated by the axis. Omitted options are inherited from `ticks` configuration.
+The majorTick configuration is nested under the ticks configuration in the `major` key. It defines options for the major tick marks that are generated by the axis. Omitted options are inherited from `ticks` configuration. These options are disabled by default.
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
+| `enabled` | `boolean` | `false` | If true, major tick options are used to show major ticks.
| `callback` | `function` | | Returns the string representation of the tick value as it should be displayed on the chart. See [callback](../axes/labelling.md#creating-custom-tick-formats).
| `fontColor` | `Color` | `'#666'` | Font color for tick labels.
| `fontFamily` | `string` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family for the tick labels, follows CSS font-family options. | true |
Other | chartjs | Chart.js | 48f10196f627f75aa75a7ae5b4d674ae9b334277.json | Use null checking for which points to draw/bezier | src/Chart.Line.js | @@ -250,40 +250,47 @@
var ctx = this.chart.ctx;
+ // Some helper methods for getting the next/prev points
+ var hasValue = function(item){
+ return item.value !== null;
+ },
+ nextPoint = function(point, collection, index){
+ return helpers.findNextWhere(collection, hasValue, index) || point;
+ },
+ previousPoint = function(point, collection, index){
+ return helpers.findPreviousWhere(collection, hasValue, index) || point;
+ };
+
this.scale.draw(easingDecimal);
helpers.each(this.datasets,function(dataset){
+ var pointsWithValues = helpers.where(dataset.points, hasValue);
//Transition each point first so that the line and point drawing isn't out of sync
//We can use this extra loop to calculate the control points of this dataset also in this loop
- helpers.each(dataset.points,function(point,index){
+ helpers.each(dataset.points, function(point, index){
if (point.hasValue()){
point.transition({
y : this.scale.calculateY(point.value),
x : this.scale.calculateX(index)
}, easingDecimal);
}
-
},this);
// Control points need to be calculated in a seperate loop, because we need to know the current x/y of the point
// This would cause issues when there is no animation, because the y of the next point would be 0, so beziers would be skewed
if (this.options.bezierCurve){
- helpers.each(dataset.points,function(point,index){
- //If we're at the start or end, we don't have a previous/next point
- //By setting the tension to 0 here, the curve will transition to straight at the end
- if (index === 0){
- point.controlPoints = helpers.splineCurve(point,point,dataset.points[index+1],0);
- }
- else if (index >= dataset.points.length-1){
- point.controlPoints = helpers.splineCurve(dataset.points[index-1],point,point,0);
- }
- else{
- point.controlPoints = helpers.splineCurve(dataset.points[index-1],point,dataset.points[index+1],this.options.bezierCurveTension);
- }
+ helpers.each(pointsWithValues, function(point, index){
+ var tension = (index > 0 && index < pointsWithValues.length - 1) ? this.options.bezierCurveTension : 0;
+ point.controlPoints = helpers.splineCurve(
+ previousPoint(point, pointsWithValues, index),
+ point,
+ nextPoint(point, pointsWithValues, index),
+ tension
+ );
},this);
}
@@ -292,36 +299,36 @@
ctx.lineWidth = this.options.datasetStrokeWidth;
ctx.strokeStyle = dataset.strokeColor;
ctx.beginPath();
- helpers.each(dataset.points,function(point,index){
- if (point.hasValue()){
- if (index>0){
- if(this.options.bezierCurve){
- ctx.bezierCurveTo(
- dataset.points[index-1].controlPoints.outer.x,
- dataset.points[index-1].controlPoints.outer.y,
- point.controlPoints.inner.x,
- point.controlPoints.inner.y,
- point.x,
- point.y
- );
- }
- else{
- ctx.lineTo(point.x,point.y);
- }
+ helpers.each(pointsWithValues, function(point, index){
+ if (index === 0){
+ ctx.moveTo(point.x, point.y);
+ }
+ else{
+ if(this.options.bezierCurve){
+ var previous = previousPoint(point, pointsWithValues, index);
+
+ ctx.bezierCurveTo(
+ previous.controlPoints.outer.x,
+ previous.controlPoints.outer.y,
+ point.controlPoints.inner.x,
+ point.controlPoints.inner.y,
+ point.x,
+ point.y
+ );
}
else{
- ctx.moveTo(point.x,point.y);
+ ctx.lineTo(point.x,point.y);
}
}
- },this);
- ctx.stroke();
+ }, this);
+ ctx.stroke();
- if (this.options.datasetFill){
+ if (this.options.datasetFill && pointsWithValues.length > 0){
//Round off the line by going to the base of the chart, back to the start, then fill.
- ctx.lineTo(dataset.points[dataset.points.length-1].x, this.scale.endPoint);
- ctx.lineTo(this.scale.calculateX(0), this.scale.endPoint);
+ ctx.lineTo(pointsWithValues[pointsWithValues.length - 1].x, this.scale.endPoint);
+ ctx.lineTo(pointsWithValues[0].x, this.scale.endPoint);
ctx.fillStyle = dataset.fillColor;
ctx.closePath();
ctx.fill();
@@ -330,12 +337,9 @@
//Now draw the points over the line
//A little inefficient double looping, but better than the line
//lagging behind the point positions
- helpers.each(dataset.points,function(point){
- if (point.hasValue()){
- point.draw();
- }
+ helpers.each(pointsWithValues,function(point){
+ point.draw();
});
-
},this);
}
}); | false |
Other | chartjs | Chart.js | 55a115179e4717f10f25301a1b86fbc6cfd21de2.json | Fix reference error when tagging a release | gulpfile.js | @@ -81,7 +81,7 @@ gulp.task('bump', function(complete){
});
gulp.task('release', ['build'], function(){
- exec('git tag -a v' + newVersion);
+ exec('git tag -a v' + package.version);
});
gulp.task('jshint', function(){ | false |
Other | chartjs | Chart.js | adf6f3abb2ee4f7a3bb770cfefcd804e38b90af7.json | Create a task to bump + write version numbers
Also run `gulp release` to tag the latest release. | bower.json | @@ -4,7 +4,8 @@
"description": "Simple HTML5 Charts using the canvas element",
"homepage": "https://github.com/nnnick/Chart.js",
"author": "nnnick",
- "main": ["Chart.min.js"],
- "dependencies": {
- }
+ "main": [
+ "Chart.min.js"
+ ],
+ "dependencies": {}
}
\ No newline at end of file | true |
Other | chartjs | Chart.js | adf6f3abb2ee4f7a3bb770cfefcd804e38b90af7.json | Create a task to bump + write version numbers
Also run `gulp release` to tag the latest release. | gulpfile.js | @@ -5,7 +5,13 @@ var gulp = require('gulp'),
jshint = require('gulp-jshint'),
size = require('gulp-size'),
connect = require('gulp-connect'),
- exec = require('child_process').exec;
+ replace = require('gulp-replace'),
+ inquirer = require('inquirer'),
+ semver = require('semver'),
+ exec = require('child_process').exec,
+ fs = require('fs'),
+ package = require('./package.json'),
+ bower = require('./bower.json');
var srcDir = './src/';
/*
@@ -28,8 +34,10 @@ gulp.task('build', function(){
// So we can use this to sort out dependency order - aka include Core first!
srcFiles.push(srcDir+'*');
}
+
return gulp.src(srcFiles)
.pipe(concat('Chart.js'))
+ .pipe(replace('{{ version }}', package.version))
.pipe(gulp.dest(outputDir))
.pipe(uglify({preserveComments:'some'}))
.pipe(concat('Chart.min.js'))
@@ -40,6 +48,42 @@ gulp.task('build', function(){
};
});
+/*
+ * Usage : gulp bump
+ * Prompts: Version increment to bump
+ * Output: - New version number written into package.json & bower.json
+ */
+
+gulp.task('bump', function(complete){
+ util.log('Current version:', util.colors.cyan(package.version));
+ var choices = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'].map(function(versionType){
+ return versionType + ' (v' + semver.inc(package.version, versionType) + ')';
+ });
+ inquirer.prompt({
+ type: 'list',
+ name: 'version',
+ message: 'What version update would you like?',
+ choices: choices
+ }, function(res){
+ var increment = res.version.split(' ')[0],
+ newVersion = semver.inc(package.version, increment);
+
+ // Set the new versions into the bower/package object
+ package.version = newVersion;
+ bower.version = newVersion;
+
+ // Write these to their own files, then build the output
+ fs.writeFileSync('package.json', JSON.stringify(package, null, 2));
+ fs.writeFileSync('bower.json', JSON.stringify(bower, null, 2));
+
+ complete();
+ });
+});
+
+gulp.task('release', ['build'], function(){
+ exec('git tag -a v' + newVersion);
+});
+
gulp.task('jshint', function(){
return gulp.src(srcDir + '*.js')
.pipe(jshint()) | true |
Other | chartjs | Chart.js | adf6f3abb2ee4f7a3bb770cfefcd804e38b90af7.json | Create a task to bump + write version numbers
Also run `gulp release` to tag the latest release. | package.json | @@ -12,10 +12,13 @@
"devDependencies": {
"gulp": "3.5.x",
"gulp-concat": "~2.1.x",
- "gulp-uglify": "~0.2.x",
- "gulp-util": "~2.2.x",
+ "gulp-connect": "~2.0.5",
"gulp-jshint": "~1.5.1",
+ "gulp-replace": "^0.4.0",
"gulp-size": "~0.4.0",
- "gulp-connect": "~2.0.5"
+ "gulp-uglify": "~0.2.x",
+ "gulp-util": "~2.2.x",
+ "inquirer": "^0.5.1",
+ "semver": "^3.0.1"
}
} | true |
Other | chartjs | Chart.js | adf6f3abb2ee4f7a3bb770cfefcd804e38b90af7.json | Create a task to bump + write version numbers
Also run `gulp release` to tag the latest release. | src/Chart.Core.js | @@ -1,6 +1,7 @@
/*!
* Chart.js
* http://chartjs.org/
+ * Version: {{ version }}
*
* Copyright 2014 Nick Downie
* Released under the MIT license | true |
Other | chartjs | Chart.js | edb245b649049671fe4983161dbc55d694c23c89.json | Add main file | package.json | @@ -3,6 +3,7 @@
"homepage": "http://www.chartjs.org",
"description": "Simple HTML5 charts using the canvas element.",
"version": "1.0.1-beta.2",
+ "main": "Chart.js",
"repository": {
"type": "git",
"url": "https://github.com/nnnick/Chart.js.git" | false |
Other | chartjs | Chart.js | 16cf465575325bf21a94d2a345d8bf4d9d097f11.json | Add a small amount to docs. | Chart.js | @@ -91,7 +91,7 @@
// 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
+ // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,
// Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove | true |
Other | chartjs | Chart.js | 16cf465575325bf21a94d2a345d8bf4d9d097f11.json | Add a small amount to docs. | src/Chart.Core.js | @@ -91,7 +91,7 @@
// 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
+ // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
maintainAspectRatio: true,
// Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove | true |
Other | chartjs | Chart.js | 2f59921f7adf40f957f7316ab0dc783f6688608f.json | Make a start on sparse data for line charts | src/Chart.Line.js | @@ -98,19 +98,16 @@
helpers.each(dataset.data,function(dataPoint,index){
- //Best way to do this? or in draw sequence...?
- if (helpers.isNumber(dataPoint)){
//Add a new point for each piece of data, passing any required data to draw.
- datasetObject.points.push(new this.PointClass({
- value : dataPoint,
- label : data.labels[index],
- datasetLabel: dataset.label,
- strokeColor : dataset.pointStrokeColor,
- fillColor : dataset.pointColor,
- highlightFill : dataset.pointHighlightFill || dataset.pointColor,
- highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor
- }));
- }
+ datasetObject.points.push(new this.PointClass({
+ value : dataPoint,
+ label : data.labels[index],
+ datasetLabel: dataset.label,
+ strokeColor : dataset.pointStrokeColor,
+ fillColor : dataset.pointColor,
+ highlightFill : dataset.pointHighlightFill || dataset.pointColor,
+ highlightStroke : dataset.pointHighlightStroke || dataset.pointStrokeColor
+ }));
},this);
this.buildScale(data.labels);
@@ -217,17 +214,15 @@
//Map the values array for each of the datasets
helpers.each(valuesArray,function(value,datasetIndex){
- if (helpers.isNumber(value)){
- //Add a new point for each piece of data, passing any required data to draw.
- this.datasets[datasetIndex].points.push(new this.PointClass({
- value : value,
- label : label,
- x: this.scale.calculateX(this.scale.valuesCount+1),
- y: this.scale.endPoint,
- strokeColor : this.datasets[datasetIndex].pointStrokeColor,
- fillColor : this.datasets[datasetIndex].pointColor
- }));
- }
+ //Add a new point for each piece of data, passing any required data to draw.
+ this.datasets[datasetIndex].points.push(new this.PointClass({
+ value : value,
+ label : label,
+ x: this.scale.calculateX(this.scale.valuesCount+1),
+ y: this.scale.endPoint,
+ strokeColor : this.datasets[datasetIndex].pointStrokeColor,
+ fillColor : this.datasets[datasetIndex].pointColor
+ }));
},this);
this.scale.addXLabel(label);
@@ -264,10 +259,12 @@
//We can use this extra loop to calculate the control points of this dataset also in this loop
helpers.each(dataset.points,function(point,index){
- point.transition({
- y : this.scale.calculateY(point.value),
- x : this.scale.calculateX(index)
- }, easingDecimal);
+ if (helpers.isNumber(point.value)){
+ point.transition({
+ y : this.scale.calculateY(point.value),
+ x : this.scale.calculateX(index)
+ }, easingDecimal);
+ }
},this);
@@ -296,24 +293,26 @@
ctx.strokeStyle = dataset.strokeColor;
ctx.beginPath();
helpers.each(dataset.points,function(point,index){
- if (index>0){
- if(this.options.bezierCurve){
- ctx.bezierCurveTo(
- dataset.points[index-1].controlPoints.outer.x,
- dataset.points[index-1].controlPoints.outer.y,
- point.controlPoints.inner.x,
- point.controlPoints.inner.y,
- point.x,
- point.y
- );
+ if (helpers.isNumber(point.value)){
+ if (index>0){
+ if(this.options.bezierCurve){
+ ctx.bezierCurveTo(
+ dataset.points[index-1].controlPoints.outer.x,
+ dataset.points[index-1].controlPoints.outer.y,
+ point.controlPoints.inner.x,
+ point.controlPoints.inner.y,
+ point.x,
+ point.y
+ );
+ }
+ else{
+ ctx.lineTo(point.x,point.y);
+ }
+
}
else{
- ctx.lineTo(point.x,point.y);
+ ctx.moveTo(point.x,point.y);
}
-
- }
- else{
- ctx.moveTo(point.x,point.y);
}
},this);
ctx.stroke();
@@ -332,7 +331,9 @@
//A little inefficient double looping, but better than the line
//lagging behind the point positions
helpers.each(dataset.points,function(point){
- point.draw();
+ if (helpers.isNumber(point.value)){
+ point.draw();
+ }
});
},this); | false |
Other | chartjs | Chart.js | e25fd5e37cbfe62fe5d7ff6adf108b800b205662.json | Create null value bars, and hide if not numeric | src/Chart.Bar.js | @@ -104,18 +104,16 @@
this.datasets.push(datasetObject);
helpers.each(dataset.data,function(dataPoint,index){
- if (helpers.isNumber(dataPoint)){
- //Add a new point for each piece of data, passing any required data to draw.
- datasetObject.bars.push(new this.BarClass({
- value : dataPoint,
- label : data.labels[index],
- datasetLabel: dataset.label,
- strokeColor : dataset.strokeColor,
- fillColor : dataset.fillColor,
- highlightFill : dataset.highlightFill || dataset.fillColor,
- highlightStroke : dataset.highlightStroke || dataset.strokeColor
- }));
- }
+ //Add a new point for each piece of data, passing any required data to draw.
+ datasetObject.bars.push(new this.BarClass({
+ value : dataPoint,
+ label : data.labels[index],
+ datasetLabel: dataset.label,
+ strokeColor : dataset.strokeColor,
+ fillColor : dataset.fillColor,
+ highlightFill : dataset.highlightFill || dataset.fillColor,
+ highlightStroke : dataset.highlightStroke || dataset.strokeColor
+ }));
},this);
},this);
@@ -230,19 +228,17 @@
addData : function(valuesArray,label){
//Map the values array for each of the datasets
helpers.each(valuesArray,function(value,datasetIndex){
- if (helpers.isNumber(value)){
- //Add a new point for each piece of data, passing any required data to draw.
- this.datasets[datasetIndex].bars.push(new this.BarClass({
- value : value,
- label : label,
- x: this.scale.calculateBarX(this.datasets.length, datasetIndex, this.scale.valuesCount+1),
- y: this.scale.endPoint,
- width : this.scale.calculateBarWidth(this.datasets.length),
- base : this.scale.endPoint,
- strokeColor : this.datasets[datasetIndex].strokeColor,
- fillColor : this.datasets[datasetIndex].fillColor
- }));
- }
+ //Add a new point for each piece of data, passing any required data to draw.
+ this.datasets[datasetIndex].bars.push(new this.BarClass({
+ value : value,
+ label : label,
+ x: this.scale.calculateBarX(this.datasets.length, datasetIndex, this.scale.valuesCount+1),
+ y: this.scale.endPoint,
+ width : this.scale.calculateBarWidth(this.datasets.length),
+ base : this.scale.endPoint,
+ strokeColor : this.datasets[datasetIndex].strokeColor,
+ fillColor : this.datasets[datasetIndex].fillColor
+ }));
},this);
this.scale.addXLabel(label);
@@ -279,13 +275,15 @@
//Draw all the bars for each dataset
helpers.each(this.datasets,function(dataset,datasetIndex){
helpers.each(dataset.bars,function(bar,index){
- bar.base = this.scale.endPoint;
- //Transition then draw
- bar.transition({
- x : this.scale.calculateBarX(this.datasets.length, datasetIndex, index),
- y : this.scale.calculateY(bar.value),
- width : this.scale.calculateBarWidth(this.datasets.length)
- }, easingDecimal).draw();
+ if (helpers.isNumber(bar.value)){
+ bar.base = this.scale.endPoint;
+ //Transition then draw
+ bar.transition({
+ x : this.scale.calculateBarX(this.datasets.length, datasetIndex, index),
+ y : this.scale.calculateY(bar.value),
+ width : this.scale.calculateBarWidth(this.datasets.length)
+ }, easingDecimal).draw();
+ }
},this);
},this); | false |
Other | chartjs | Chart.js | 55fc0cfd49749c6dded5964bb7356325021f25bc.json | Change package.json name to lowercase | package.json | @@ -1,5 +1,5 @@
{
- "name": "Chart.js",
+ "name": "chart.js",
"homepage": "http://www.chartjs.org",
"description": "Simple HTML5 charts using the canvas element.",
"version": "1.0.1-beta.2", | false |
Other | chartjs | Chart.js | 3e1b120cbeff4caa90ff15880a9e0075e70b50f2.json | Build latest output files for new version | Chart.js | @@ -873,7 +873,9 @@
yMin;
helpers.each(this.datasets, function(dataset){
dataCollection = dataset.points || dataset.bars || dataset.segments;
- Elements.push(dataCollection[dataIndex]);
+ if (dataCollection[dataIndex]){
+ Elements.push(dataCollection[dataIndex]);
+ }
});
helpers.each(Elements, function(element) {
@@ -1996,6 +1998,7 @@
datasetObject.bars.push(new this.BarClass({
value : dataPoint,
label : data.labels[index],
+ datasetLabel: dataset.label,
strokeColor : dataset.strokeColor,
fillColor : dataset.fillColor,
highlightFill : dataset.highlightFill || dataset.fillColor,
@@ -2470,8 +2473,7 @@
datasetObject.points.push(new this.PointClass({
value : dataPoint,
label : data.labels[index],
- // x: this.scale.calculateX(index),
- // y: this.scale.endPoint,
+ datasetLabel: dataset.label,
strokeColor : dataset.pointStrokeColor,
fillColor : dataset.pointColor,
highlightFill : dataset.pointHighlightFill || dataset.pointColor,
@@ -3079,6 +3081,7 @@
datasetObject.points.push(new this.PointClass({
value : dataPoint,
label : data.labels[index],
+ datasetLabel: dataset.label,
x: (this.options.animation) ? this.scale.xCenter : pointPosition.x,
y: (this.options.animation) ? this.scale.yCenter : pointPosition.y,
strokeColor : dataset.pointStrokeColor,
@@ -3233,6 +3236,7 @@
this.eachPoints(function(point){
point.save();
});
+ this.reflow();
this.render();
},
reflow: function(){ | true |
Other | chartjs | Chart.js | 3e1b120cbeff4caa90ff15880a9e0075e70b50f2.json | Build latest output files for new version | Chart.min.js | @@ -6,5 +6,5 @@
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
-(function(){"use strict";var t=this,i=t.Chart,e=function(t){this.canvas=t.canvas,this.ctx=t;this.width=t.canvas.width,this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this};e.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,showTooltips:!0,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},e.types={};var s=e.helpers={},n=s.each=function(t,i,e){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n<t.length;n++)i.apply(e,[t[n],n].concat(s))}else for(var o in t)i.apply(e,[t[o],o].concat(s))},o=s.clone=function(t){var i={};return n(t,function(e,s){t.hasOwnProperty(s)&&(i[s]=e)}),i},a=s.extend=function(t){return n(Array.prototype.slice.call(arguments,1),function(i){n(i,function(e,s){i.hasOwnProperty(s)&&(t[s]=e)})}),t},h=s.merge=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift({}),a.apply(null,t)},l=s.indexOf=function(t,i){if(Array.prototype.indexOf)return t.indexOf(i);for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1},r=s.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},s=function(){this.constructor=e};return s.prototype=i.prototype,e.prototype=new s,e.extend=r,t&&a(e.prototype,t),e.__super__=i.prototype,e},c=s.noop=function(){},u=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof t.define&&t.define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,i,e){if(f(i)){if(t>i)return i}else if(f(e)&&e>t)return e;return t},s.getDecimalPlaces=function(t){return t%1!==0&&f(t)?t.toString().split(".")[1].length:0}),S=s.radians=function(t){return t*(Math.PI/180)},x=(s.getAngleFromPoint=function(t,i){var e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s),o=2*Math.PI+Math.atan2(s,e);return 0>e&&0>s&&(o+=2*Math.PI),{angle:o,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),C=(s.splineCurve=function(t,i,e,s){var n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=s*n/(n+o),h=s*o/(n+o);return{inner:{x:i.x-a*(e.x-t.x),y:i.y-a*(e.y-t.y)},outer:{x:i.x+h*(e.x-t.x),y:i.y+h*(e.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),y=(s.calculateScaleRange=function(t,i,e,s,n){var o=2,a=Math.floor(i/(1.5*e)),h=o>=a,l=g(t),r=m(t);l===r&&(l+=.5,r>=.5&&!s?r-=.5:l+=.5);for(var c=Math.abs(l-r),u=C(c),d=Math.ceil(l/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(r/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,v=Math.pow(10,u),S=Math.round(f/v);(S>a||a>2*S)&&!h;)if(S>a)v*=2,S=Math.round(f/v),S%1!==0&&(h=!0);else if(n&&u>=0){if(v/2%1!==0)break;v/=2,S=Math.round(f/v)}else v/=2,S=Math.round(f/v);return h&&(S=o,v=f/S),{steps:S,stepValue:v,min:p,max:p+S*v}},s.template=function(t,i){function e(t,i){var e=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return i?e(i):e}var s={};return e(t,i)}),b=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=y(t,{value:e+s*(n+1)})}),o},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)))},easeOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin(2*(1*t-i)*Math.PI/e)+1)},easeInOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:2==(t/=.5)?1:(e||(e=.3*1.5),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),1>t?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)*.5+1)},easeInBack:function(t){var i=1.70158;return 1*(t/=1)*t*((i+1)*t-i)},easeOutBack:function(t){var i=1.70158;return 1*((t=t/1-1)*t*((i+1)*t+i)+1)},easeInOutBack:function(t){var i=1.70158;return(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},easeInBounce:function(t){return 1-b.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*b.easeInBounce(2*t):.5*b.easeOutBounce(2*t-1)+.5}}),w=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),P=(s.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),s.animationLoop=function(t,i,e,s,n,o){var a=0,h=b[e]||b.linear,l=function(){a++;var e=a/i,r=h(e);t.call(o,r,e,a),s.call(o,r,e),i>a?o.animationFrame=w(l):n.apply(o)};w(l)},s.getRelativePosition=function(t){var i,e,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect();return s.touches?(i=s.touches[0].clientX-o.left,e=s.touches[0].clientY-o.top):(i=s.clientX-o.left,e=s.clientY-o.top),{x:i,y:e}},s.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),L=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},k=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},P(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){L(t.chart.canvas,e,i)})}),F=s.getMaximumSize=function(t){var i=t.parentNode;return i.clientWidth},R=s.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=s+"px",i.canvas.height=s*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))},A=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},T=s.fontString=function(t,i,e){return i+" "+t+"px "+e},M=s.longestText=function(t,i,e){t.font=i;var s=0;return n(e,function(i){var e=t.measureText(i).width;s=e>s?e:s}),s},W=s.drawRoundedRectangle=function(t,i,e,s,n,o){t.beginPath(),t.moveTo(i+o,e),t.lineTo(i+s-o,e),t.quadraticCurveTo(i+s,e,i+s,e+o),t.lineTo(i+s,e+n-o),t.quadraticCurveTo(i+s,e+n,i+s-o,e+n),t.lineTo(i+o,e+n),t.quadraticCurveTo(i,e+n,i,e+n-o),t.lineTo(i,e+o),t.quadraticCurveTo(i,e,i+o,e),t.closePath()};e.instances={},e.Type=function(t,i,s){this.options=i,this.chart=s,this.id=u(),e.instances[this.id]=this,i.responsive&&this.resize(),this.initialize.call(this,t)},a(e.Type.prototype,{initialize:function(){return this},clear:function(){return A(this.chart),this},stop:function(){return s.cancelAnimFrame.call(t,this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=F(this.chart.canvas),s=e/this.chart.aspectRatio;return i.width=this.chart.width=e,i.height=this.chart.height=s,R(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return y(this.options.legendTemplate,this)},destroy:function(){this.clear(),k(this,this.events),delete e.instances[this.id]},showTooltip:function(t,i){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var o=function(t){var i=!1;return t.length!==this.activeElements.length?i=!0:(n(t,function(t,e){t!==this.activeElements[e]&&(i=!0)},this),i)}.call(this,t);if(o||i){if(this.activeElements=t,this.draw(),t.length>0)if(this.datasets&&this.datasets.length>1){for(var a,h,r=this.datasets.length-1;r>=0&&(a=this.datasets[r].points||this.datasets[r].bars||this.datasets[r].segments,h=l(a,t[0]),-1===h);r--);var c=[],u=[],d=function(){var t,i,e,n,o,a=[],l=[],r=[];return s.each(this.datasets,function(i){t=i.points||i.bars||i.segments,a.push(t[h])}),s.each(a,function(t){l.push(t.x),r.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(r),e=g(r),n=m(l),i=g(l),{x:n>this.chart.width/2?n:i,y:(o+e)/2}}.call(this,h);new e.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:u,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx}).draw()}else n(t,function(t){var i=t.tooltipPosition();new e.Tooltip({x:Math.round(i.x),y:Math.round(i.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:y(this.options.tooltipTemplate,t),chart:this.chart}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),e.Type.extend=function(t){var i=this,s=function(){return i.apply(this,arguments)};if(s.prototype=o(i.prototype),a(s.prototype,t),s.extend=e.Type.extend,t.name||i.prototype.name){var n=t.name||i.prototype.name,l=e.defaults[i.prototype.name]?o(e.defaults[i.prototype.name]):{};e.defaults[n]=a(l,t.defaults),e.types[n]=s,e.prototype[n]=function(t,i){var o=h(e.defaults.global,e.defaults[n],i||{});return new s(t,o,this)}}else d("Name not provided for this chart, so it hasn't been registered");return i},e.Element=function(t){a(this,t),this.initialize.apply(this,arguments),this.save()},a(e.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):a(this,this._saved),this},save:function(){return this._saved=o(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,i){this._saved[i]=this[i],this[i]=t},this),this},transition:function(t,i){return n(t,function(t,e){this[e]=(t-this._saved[e])*i+this._saved[e]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}}}),e.Element.extend=r,e.Point=e.Element.extend({display:!0,inRange:function(t,i){var e=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(i-this.y,2)<Math.pow(e,2)},draw:function(){if(this.display){var t=this.ctx;t.beginPath(),t.arc(this.x,this.y,this.radius,0,2*Math.PI),t.closePath(),t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.fillStyle=this.fillColor,t.fill(),t.stroke()}}}),e.Arc=e.Element.extend({inRange:function(t,i){var e=s.getAngleFromPoint(this,{x:t,y:i}),n=e.angle>=this.startAngle&&e.angle<=this.endAngle,o=e.distance>=this.innerRadius&&e.distance<=this.outerRadius;return n&&o},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,i=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*i,y:this.y+Math.sin(t)*i}},draw:function(t){var i=this.ctx;i.beginPath(),i.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),i.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),i.closePath(),i.strokeStyle=this.strokeColor,i.lineWidth=this.strokeWidth,i.fillStyle=this.fillColor,i.fill(),i.lineJoin="bevel",this.showStroke&&i.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this.ctx,i=this.width/2,e=this.x-i,s=this.x+i,n=this.base-(this.base-this.y),o=this.strokeWidth/2;this.showStroke&&(e+=o,s-=o,n+=o),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(e,this.base),t.lineTo(e,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,i){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&i>=this.y&&i<=this.base}}),e.Tooltip=e.Element.extend({draw:function(){var t=this.chart.ctx;t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=2,e=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+i;this.x+e/2>this.chart.width?this.xAlign="left":this.x-e/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var o=this.x-e/2,a=this.y-n;switch(t.fillStyle=this.fillColor,this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-i),t.lineTo(this.x+this.caretHeight,this.y-(i+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(i+this.caretHeight)),t.closePath(),t.fill();break;case"below":a=this.y+i+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+i),t.lineTo(this.x+this.caretHeight,this.y+i+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+i+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":o=this.x-e+(this.cornerRadius+this.caretHeight);break;case"right":o=this.x-(this.cornerRadius+this.caretHeight)}W(t,o,a,e,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,o+e/2,a+s/2)}}),e.MultiTooltip=e.Element.extend({initialize:function(){this.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=T(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,i=M(this.ctx,this.font,this.labels)+this.fontSize+3,e=g([i,t]);this.width=e+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var i=this.y-this.height/2+this.yPadding,e=t-1;return 0===t?i+this.titleFontSize/2:i+(1.5*this.fontSize*e+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){W(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(i,e){t.fillStyle=this.textColor,t.fillText(i,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(e+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[e].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}),e.Scale=e.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?M(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,i=this.endPoint-this.startPoint;for(this.calculateYRange(i),this.buildYLabels(),this.calculateXLabelRotation();i>this.endPoint-this.startPoint;)i=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(i),this.buildYLabels(),t<this.yLabelWidth&&this.calculateXLabelRotation()},calculateXLabelRotation:function(){this.ctx.font=this.font;var t,i,e=this.ctx.measureText(this.xLabels[0]).width,s=this.ctx.measureText(this.xLabels[this.xLabels.length-1]).width;if(this.xScalePaddingRight=s/2+3,this.xScalePaddingLeft=e/2>this.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=M(this.ctx,this.font,this.xLabels);this.xLabelWidth=o;for(var a=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>a&&0===this.xLabelRotation||this.xLabelWidth>a&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(S(this.xLabelRotation)),t=n*e,i=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*o;this.xLabelRotation>0&&(this.endPoint-=Math.sin(S(this.xLabelRotation))*o+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var i=this.drawingArea()/(this.min-this.max);return this.endPoint-i*(t-this.min)},calculateX:function(t){var i=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),e=i/(this.valuesCount-(this.offsetGridLines?0:1)),s=e*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=e/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,i=(this.endPoint-this.startPoint)/this.steps,e=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,o){var a=this.endPoint-i*o,h=Math.round(a);t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),t.moveTo(e,h),t.lineTo(this.width,h),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(e-5,h),t.lineTo(e,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(i,e){var s=this.calculateX(e)+x(this.lineWidth),n=this.calculateX(e-(this.offsetGridLines?.5:0))+x(this.lineWidth),o=this.xLabelRotation>0;t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(-1*S(this.xLabelRotation)),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(i,0,0),t.restore()},this))}}),e.RadialScale=e.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,e,s,n,o,a,h,l,r,c,u,d=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;i<this.valuesCount;i++)t=this.getPointPosition(i,d),e=this.ctx.measureText(y(this.templateString,{value:this.labels[i]})).width+5,0===i||i===this.valuesCount/2?(s=e/2,t.x+s>p&&(p=t.x+s,n=i),t.x-s<g&&(g=t.x-s,a=i)):i<this.valuesCount/2?t.x+e>p&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e<g&&(g=t.x-e,a=i);l=g,r=Math.ceil(p-this.width),o=this.getIndexAngle(n),h=this.getIndexAngle(a),c=r/Math.sin(o+Math.PI/2),u=l/Math.sin(h+Math.PI/2),c=f(c)?c:0,u=f(u)?u:0,this.drawingArea=d-(u+c)/2,this.setCenterPoint(u,c)},setCenterPoint:function(t,i){var e=this.width-i-this.drawingArea,s=t+this.drawingArea;this.xCenter=(s+e)/2,this.yCenter=this.height/2},getIndexAngle:function(t){var i=2*Math.PI/this.valuesCount;return t*i-Math.PI/2},getPointPosition:function(t,i){var e=this.getIndexAngle(t);return{x:Math.cos(e)*i+this.xCenter,y:Math.sin(e)*i+this.yCenter}},draw:function(){if(this.display){var t=this.ctx;if(n(this.yLabels,function(i,e){if(e>0){var s,n=e*(this.drawingArea/this.steps),o=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var a=0;a<this.valuesCount;a++)s=this.getPointPosition(a,this.calculateCenterOffset(this.min+e*this.stepValue)),0===a?t.moveTo(s.x,s.y):t.lineTo(s.x,s.y);t.closePath(),t.stroke()}if(this.showLabels){if(t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.showLabelBackdrop){var h=t.measureText(i).width;t.fillStyle=this.backdropColor,t.fillRect(this.xCenter-h/2-this.backdropPaddingX,o-this.fontSize/2-this.backdropPaddingY,h+2*this.backdropPaddingX,this.fontSize+2*this.backdropPaddingY)}t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.fontColor,t.fillText(i,this.xCenter,o)}}},this),!this.lineArc){t.lineWidth=this.angleLineWidth,t.strokeStyle=this.angleLineColor;for(var i=this.valuesCount-1;i>=0;i--){if(this.angleLineWidth>0){var e=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(e.x,e.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var o=this.labels.length,a=this.labels.length/2,h=a/2,l=h>i||i>o-h,r=i===h||i===o-h;t.textAlign=0===i?"center":i===a?"center":a>i?"left":"right",t.textBaseline=r?"middle":l?"bottom":"top",t.fillText(this.labels[i],s.x,s.y)}}}}}),s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(e.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return e}):"object"==typeof module&&module.exports&&(module.exports=e),t.Chart=e,e.noConflict=function(){return t.Chart=i,e}}).call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Bar",defaults:s,initialize:function(t){var s=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,i,e){var n=this.calculateBaseWidth(),o=this.calculateX(e)-n/2,a=this.calculateBarWidth(t);return o+a*i+i*s.barDatasetSpacing+a/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return i/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.bars.push(new this.BarClass({value:n,label:t.labels[o],strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,i,s){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,s,i),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(i,s){e.each(i.bars,t,this,s)},this)},getBarsAtEvent:function(t){for(var i,s=[],n=e.getRelativePosition(t),o=function(t){s.push(t.bars[i])},a=0;a<this.datasets.length;a++)for(i=0;i<this.datasets[a].bars.length;i++)if(this.datasets[a].bars[i].inRange(n.x,n.y))return e.each(this.datasets,o),s;return s},buildScale:function(t){var i=this,s=function(){var t=[];return i.eachBars(function(i){t.push(i.value)}),t},n={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(s(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.barShowStroke?this.options.barStrokeWidth:0,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(n,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new this.ScaleClass(n)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].bars.push(new this.BarClass({value:t,label:i,x:this.scale.calculateBarX(this.datasets.length,s,this.scale.valuesCount+1),y:this.scale.endPoint,width:this.scale.calculateBarWidth(this.datasets.length),base:this.scale.endPoint,strokeColor:this.datasets[s].strokeColor,fillColor:this.datasets[s].fillColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.bars.shift()},this),this.update()},reflow:function(){e.extend(this.BarClass.prototype,{y:this.scale.endPoint,base:this.scale.endPoint});var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t,s){e.each(t.bars,function(t,e){t.base=this.scale.endPoint,t.transition({x:this.scale.calculateBarX(this.datasets.length,s,e),y:this.scale.calculateY(t.value),width:this.scale.calculateBarWidth(this.datasets.length)},i).draw()},this)},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,percentageInnerCutout:50,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.segments=[],this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];
-e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.calculateTotal(t),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({value:t.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(t.value),label:t.label})),e||(this.reflow(),this.update())},calculateCircumference:function(t){return 2*Math.PI*(t/this.total)},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this)},update:function(){this.calculateTotal(this.segments),e.each(this.activeElements,function(t){t.restore(["fillColor"])}),e.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,e.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var i=t?t:1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},i),t.endAngle=t.startAngle+t.circumference,t.draw(),0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle)},this)}}),i.types.Doughnut.extend({name:"Pie",defaults:e.merge(s,{percentageInnerCutout:0})})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,bezierCurve:!0,bezierCurveTension:.4,pointDot:!0,pointDotRadius:4,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Line",defaults:s,initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(t){return Math.pow(t-this.x,2)<Math.pow(this.radius+this.hitDetectionRadius,2)}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.points.push(new this.PointClass({value:n,label:t.labels[o],strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))},this),this.buildScale(t.labels),this.eachPoints(function(t,i){e.extend(t,{x:this.scale.calculateX(i),y:this.scale.endPoint}),t.save()},this)},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachPoints(function(t){t.save()}),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.datasets,function(t){e.each(t.points,function(t){t.inRange(s.x,s.y)&&i.push(t)})},this),i},buildScale:function(t){var s=this,n=function(){var t=[];return s.eachPoints(function(i){t.push(i.value)}),t},o={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(n(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.pointDotRadius+this.options.pointDotStrokeWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(o,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new i.Scale(o)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].points.push(new this.PointClass({value:t,label:i,x:this.scale.calculateX(this.scale.valuesCount+1),y:this.scale.endPoint,strokeColor:this.datasets[s].pointStrokeColor,fillColor:this.datasets[s].pointColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.points.shift()},this),this.update()},reflow:function(){var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();var s=this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.transition({y:this.scale.calculateY(t.value),x:this.scale.calculateX(e)},i)},this),this.options.bezierCurve&&e.each(t.points,function(i,s){i.controlPoints=0===s?e.splineCurve(i,i,t.points[s+1],0):s>=t.points.length-1?e.splineCurve(t.points[s-1],i,i,0):e.splineCurve(t.points[s-1],i,t.points[s+1],this.options.bezierCurveTension)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(i,e){e>0?this.options.bezierCurve?s.bezierCurveTo(t.points[e-1].controlPoints.outer.x,t.points[e-1].controlPoints.outer.y,i.controlPoints.inner.x,i.controlPoints.inner.y,i.x,i.y):s.lineTo(i.x,i.y):s.moveTo(i.x,i.y)},this),s.stroke(),this.options.datasetFill&&(s.lineTo(t.points[t.points.length-1].x,this.scale.endPoint),s.lineTo(this.scale.calculateX(0),this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),e.each(t.points,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBeginAtZero:!0,scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,scaleShowLine:!0,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.segments=[],this.SegmentArc=i.Arc.extend({showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,ctx:this.chart.ctx,innerRadius:0,x:this.chart.width/2,y:this.chart.height/2}),this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,valuesCount:t.length}),this.updateScaleRange(t),this.scale.update(),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value,outerRadius:this.options.animateScale?0:this.scale.calculateCenterOffset(t.value),circumference:this.options.animateRotate?0:this.scale.getCircumference(),startAngle:1.5*Math.PI})),e||(this.reflow(),this.update())},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var i=[];e.each(t,function(t){i.push(t.value)});var s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s,{size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.calculateTotal(this.segments),e.each(this.segments,function(t){t.save()}),this.render()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),e.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),e.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var i=t||1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},i),t.endAngle=t.startAngle+t.circumference,0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle),t.draw()},this),this.scale.draw()}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers;i.Type.extend({name:"Radar",defaults:{scaleShowLine:!0,angleShowLineOut:!0,scaleShowLabels:!1,scaleBeginAtZero:!0,angleLineColor:"rgba(0,0,0,.1)",angleLineWidth:1,pointLabelFontFamily:"'Arial'",pointLabelFontStyle:"normal",pointLabelFontSize:10,pointLabelFontColor:"#666",pointDot:!0,pointDotRadius:3,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'},initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx}),this.datasets=[],this.buildScale(t),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(n,o){if(e.isNumber(n)){var a;this.scale.animation||(a=this.scale.getPointPosition(o,this.scale.calculateCenterOffset(n))),s.points.push(new this.PointClass({value:n,label:t.labels[o],x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))}},this)},this),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=e.getRelativePosition(t),s=e.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},i),n=2*Math.PI/this.scale.valuesCount,o=Math.round((s.angle-1.5*Math.PI)/n),a=[];return(o>=this.scale.valuesCount||0>o)&&(o=0),s.distance<=this.scale.drawingArea&&e.each(this.datasets,function(t){a.push(t.points[o])}),a},buildScale:function(t){this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,angleLineColor:this.options.angleLineColor,angleLineWidth:this.options.angleShowLineOut?this.options.angleLineWidth:0,pointLabelFontColor:this.options.pointLabelFontColor,pointLabelFontSize:this.options.pointLabelFontSize,pointLabelFontFamily:this.options.pointLabelFontFamily,pointLabelFontStyle:this.options.pointLabelFontStyle,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,labels:t.labels,valuesCount:t.datasets[0].data.length}),this.scale.setScaleSize(),this.updateScaleRange(t.datasets),this.scale.buildYLabels()},updateScaleRange:function(t){var i=function(){var i=[];return e.each(t,function(t){t.data?i=i.concat(t.data):e.each(t.points,function(t){i.push(t.value)})}),i}(),s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s)},addData:function(t,i){this.scale.valuesCount++,e.each(t,function(t,s){if(e.isNumber(t)){var n=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[s].points.push(new this.PointClass({value:t,label:i,x:n.x,y:n.y,strokeColor:this.datasets[s].pointStrokeColor,fillColor:this.datasets[s].pointColor}))}},this),this.scale.labels.push(i),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),e.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){this.eachPoints(function(t){t.save()}),this.render()},reflow:function(){e.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2}),this.updateScaleRange(this.datasets),this.scale.setScaleSize(),this.scale.buildYLabels()},draw:function(t){var i=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.transition(this.scale.getPointPosition(e,this.scale.calculateCenterOffset(t.value)),i)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(t,i){0===i?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),e.each(t.points,function(t){t.draw()})},this)}})}.call(this);
\ No newline at end of file
+(function(){"use strict";var t=this,i=t.Chart,e=function(t){this.canvas=t.canvas,this.ctx=t;this.width=t.canvas.width,this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this};e.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,showTooltips:!0,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},e.types={};var s=e.helpers={},n=s.each=function(t,i,e){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n<t.length;n++)i.apply(e,[t[n],n].concat(s))}else for(var o in t)i.apply(e,[t[o],o].concat(s))},o=s.clone=function(t){var i={};return n(t,function(e,s){t.hasOwnProperty(s)&&(i[s]=e)}),i},a=s.extend=function(t){return n(Array.prototype.slice.call(arguments,1),function(i){n(i,function(e,s){i.hasOwnProperty(s)&&(t[s]=e)})}),t},h=s.merge=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift({}),a.apply(null,t)},l=s.indexOf=function(t,i){if(Array.prototype.indexOf)return t.indexOf(i);for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1},r=s.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},s=function(){this.constructor=e};return s.prototype=i.prototype,e.prototype=new s,e.extend=r,t&&a(e.prototype,t),e.__super__=i.prototype,e},c=s.noop=function(){},u=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof t.define&&t.define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,i,e){if(f(i)){if(t>i)return i}else if(f(e)&&e>t)return e;return t},s.getDecimalPlaces=function(t){return t%1!==0&&f(t)?t.toString().split(".")[1].length:0}),S=s.radians=function(t){return t*(Math.PI/180)},x=(s.getAngleFromPoint=function(t,i){var e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s),o=2*Math.PI+Math.atan2(s,e);return 0>e&&0>s&&(o+=2*Math.PI),{angle:o,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),C=(s.splineCurve=function(t,i,e,s){var n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=s*n/(n+o),h=s*o/(n+o);return{inner:{x:i.x-a*(e.x-t.x),y:i.y-a*(e.y-t.y)},outer:{x:i.x+h*(e.x-t.x),y:i.y+h*(e.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),y=(s.calculateScaleRange=function(t,i,e,s,n){var o=2,a=Math.floor(i/(1.5*e)),h=o>=a,l=g(t),r=m(t);l===r&&(l+=.5,r>=.5&&!s?r-=.5:l+=.5);for(var c=Math.abs(l-r),u=C(c),d=Math.ceil(l/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(r/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,v=Math.pow(10,u),S=Math.round(f/v);(S>a||a>2*S)&&!h;)if(S>a)v*=2,S=Math.round(f/v),S%1!==0&&(h=!0);else if(n&&u>=0){if(v/2%1!==0)break;v/=2,S=Math.round(f/v)}else v/=2,S=Math.round(f/v);return h&&(S=o,v=f/S),{steps:S,stepValue:v,min:p,max:p+S*v}},s.template=function(t,i){function e(t,i){var e=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return i?e(i):e}var s={};return e(t,i)}),b=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=y(t,{value:e+s*(n+1)})}),o},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)))},easeOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin(2*(1*t-i)*Math.PI/e)+1)},easeInOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:2==(t/=.5)?1:(e||(e=.3*1.5),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),1>t?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)*.5+1)},easeInBack:function(t){var i=1.70158;return 1*(t/=1)*t*((i+1)*t-i)},easeOutBack:function(t){var i=1.70158;return 1*((t=t/1-1)*t*((i+1)*t+i)+1)},easeInOutBack:function(t){var i=1.70158;return(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},easeInBounce:function(t){return 1-b.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*b.easeInBounce(2*t):.5*b.easeOutBounce(2*t-1)+.5}}),w=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),P=(s.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),s.animationLoop=function(t,i,e,s,n,o){var a=0,h=b[e]||b.linear,l=function(){a++;var e=a/i,r=h(e);t.call(o,r,e,a),s.call(o,r,e),i>a?o.animationFrame=w(l):n.apply(o)};w(l)},s.getRelativePosition=function(t){var i,e,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect();return s.touches?(i=s.touches[0].clientX-o.left,e=s.touches[0].clientY-o.top):(i=s.clientX-o.left,e=s.clientY-o.top),{x:i,y:e}},s.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),L=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},k=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},P(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){L(t.chart.canvas,e,i)})}),F=s.getMaximumSize=function(t){var i=t.parentNode;return i.clientWidth},R=s.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=s+"px",i.canvas.height=s*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))},A=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},T=s.fontString=function(t,i,e){return i+" "+t+"px "+e},M=s.longestText=function(t,i,e){t.font=i;var s=0;return n(e,function(i){var e=t.measureText(i).width;s=e>s?e:s}),s},W=s.drawRoundedRectangle=function(t,i,e,s,n,o){t.beginPath(),t.moveTo(i+o,e),t.lineTo(i+s-o,e),t.quadraticCurveTo(i+s,e,i+s,e+o),t.lineTo(i+s,e+n-o),t.quadraticCurveTo(i+s,e+n,i+s-o,e+n),t.lineTo(i+o,e+n),t.quadraticCurveTo(i,e+n,i,e+n-o),t.lineTo(i,e+o),t.quadraticCurveTo(i,e,i+o,e),t.closePath()};e.instances={},e.Type=function(t,i,s){this.options=i,this.chart=s,this.id=u(),e.instances[this.id]=this,i.responsive&&this.resize(),this.initialize.call(this,t)},a(e.Type.prototype,{initialize:function(){return this},clear:function(){return A(this.chart),this},stop:function(){return s.cancelAnimFrame.call(t,this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=F(this.chart.canvas),s=e/this.chart.aspectRatio;return i.width=this.chart.width=e,i.height=this.chart.height=s,R(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return y(this.options.legendTemplate,this)},destroy:function(){this.clear(),k(this,this.events),delete e.instances[this.id]},showTooltip:function(t,i){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var o=function(t){var i=!1;return t.length!==this.activeElements.length?i=!0:(n(t,function(t,e){t!==this.activeElements[e]&&(i=!0)},this),i)}.call(this,t);if(o||i){if(this.activeElements=t,this.draw(),t.length>0)if(this.datasets&&this.datasets.length>1){for(var a,h,r=this.datasets.length-1;r>=0&&(a=this.datasets[r].points||this.datasets[r].bars||this.datasets[r].segments,h=l(a,t[0]),-1===h);r--);var c=[],u=[],d=function(){var t,i,e,n,o,a=[],l=[],r=[];return s.each(this.datasets,function(i){t=i.points||i.bars||i.segments,t[h]&&a.push(t[h])}),s.each(a,function(t){l.push(t.x),r.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(r),e=g(r),n=m(l),i=g(l),{x:n>this.chart.width/2?n:i,y:(o+e)/2}}.call(this,h);new e.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:u,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx}).draw()}else n(t,function(t){var i=t.tooltipPosition();new e.Tooltip({x:Math.round(i.x),y:Math.round(i.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:y(this.options.tooltipTemplate,t),chart:this.chart}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),e.Type.extend=function(t){var i=this,s=function(){return i.apply(this,arguments)};if(s.prototype=o(i.prototype),a(s.prototype,t),s.extend=e.Type.extend,t.name||i.prototype.name){var n=t.name||i.prototype.name,l=e.defaults[i.prototype.name]?o(e.defaults[i.prototype.name]):{};e.defaults[n]=a(l,t.defaults),e.types[n]=s,e.prototype[n]=function(t,i){var o=h(e.defaults.global,e.defaults[n],i||{});return new s(t,o,this)}}else d("Name not provided for this chart, so it hasn't been registered");return i},e.Element=function(t){a(this,t),this.initialize.apply(this,arguments),this.save()},a(e.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):a(this,this._saved),this},save:function(){return this._saved=o(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,i){this._saved[i]=this[i],this[i]=t},this),this},transition:function(t,i){return n(t,function(t,e){this[e]=(t-this._saved[e])*i+this._saved[e]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}}}),e.Element.extend=r,e.Point=e.Element.extend({display:!0,inRange:function(t,i){var e=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(i-this.y,2)<Math.pow(e,2)},draw:function(){if(this.display){var t=this.ctx;t.beginPath(),t.arc(this.x,this.y,this.radius,0,2*Math.PI),t.closePath(),t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.fillStyle=this.fillColor,t.fill(),t.stroke()}}}),e.Arc=e.Element.extend({inRange:function(t,i){var e=s.getAngleFromPoint(this,{x:t,y:i}),n=e.angle>=this.startAngle&&e.angle<=this.endAngle,o=e.distance>=this.innerRadius&&e.distance<=this.outerRadius;return n&&o},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,i=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*i,y:this.y+Math.sin(t)*i}},draw:function(t){var i=this.ctx;i.beginPath(),i.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),i.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),i.closePath(),i.strokeStyle=this.strokeColor,i.lineWidth=this.strokeWidth,i.fillStyle=this.fillColor,i.fill(),i.lineJoin="bevel",this.showStroke&&i.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this.ctx,i=this.width/2,e=this.x-i,s=this.x+i,n=this.base-(this.base-this.y),o=this.strokeWidth/2;this.showStroke&&(e+=o,s-=o,n+=o),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(e,this.base),t.lineTo(e,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,i){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&i>=this.y&&i<=this.base}}),e.Tooltip=e.Element.extend({draw:function(){var t=this.chart.ctx;t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=2,e=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+i;this.x+e/2>this.chart.width?this.xAlign="left":this.x-e/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var o=this.x-e/2,a=this.y-n;switch(t.fillStyle=this.fillColor,this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-i),t.lineTo(this.x+this.caretHeight,this.y-(i+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(i+this.caretHeight)),t.closePath(),t.fill();break;case"below":a=this.y+i+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+i),t.lineTo(this.x+this.caretHeight,this.y+i+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+i+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":o=this.x-e+(this.cornerRadius+this.caretHeight);break;case"right":o=this.x-(this.cornerRadius+this.caretHeight)}W(t,o,a,e,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,o+e/2,a+s/2)}}),e.MultiTooltip=e.Element.extend({initialize:function(){this.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=T(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,i=M(this.ctx,this.font,this.labels)+this.fontSize+3,e=g([i,t]);this.width=e+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var i=this.y-this.height/2+this.yPadding,e=t-1;return 0===t?i+this.titleFontSize/2:i+(1.5*this.fontSize*e+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){W(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(i,e){t.fillStyle=this.textColor,t.fillText(i,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(e+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[e].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}),e.Scale=e.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?M(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,i=this.endPoint-this.startPoint;for(this.calculateYRange(i),this.buildYLabels(),this.calculateXLabelRotation();i>this.endPoint-this.startPoint;)i=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(i),this.buildYLabels(),t<this.yLabelWidth&&this.calculateXLabelRotation()},calculateXLabelRotation:function(){this.ctx.font=this.font;var t,i,e=this.ctx.measureText(this.xLabels[0]).width,s=this.ctx.measureText(this.xLabels[this.xLabels.length-1]).width;if(this.xScalePaddingRight=s/2+3,this.xScalePaddingLeft=e/2>this.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=M(this.ctx,this.font,this.xLabels);this.xLabelWidth=o;for(var a=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>a&&0===this.xLabelRotation||this.xLabelWidth>a&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(S(this.xLabelRotation)),t=n*e,i=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*o;this.xLabelRotation>0&&(this.endPoint-=Math.sin(S(this.xLabelRotation))*o+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var i=this.drawingArea()/(this.min-this.max);return this.endPoint-i*(t-this.min)},calculateX:function(t){var i=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),e=i/(this.valuesCount-(this.offsetGridLines?0:1)),s=e*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=e/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,i=(this.endPoint-this.startPoint)/this.steps,e=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,o){var a=this.endPoint-i*o,h=Math.round(a);t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),t.moveTo(e,h),t.lineTo(this.width,h),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(e-5,h),t.lineTo(e,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(i,e){var s=this.calculateX(e)+x(this.lineWidth),n=this.calculateX(e-(this.offsetGridLines?.5:0))+x(this.lineWidth),o=this.xLabelRotation>0;t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(-1*S(this.xLabelRotation)),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(i,0,0),t.restore()},this))}}),e.RadialScale=e.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,e,s,n,o,a,h,l,r,c,u,d=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;i<this.valuesCount;i++)t=this.getPointPosition(i,d),e=this.ctx.measureText(y(this.templateString,{value:this.labels[i]})).width+5,0===i||i===this.valuesCount/2?(s=e/2,t.x+s>p&&(p=t.x+s,n=i),t.x-s<g&&(g=t.x-s,a=i)):i<this.valuesCount/2?t.x+e>p&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e<g&&(g=t.x-e,a=i);l=g,r=Math.ceil(p-this.width),o=this.getIndexAngle(n),h=this.getIndexAngle(a),c=r/Math.sin(o+Math.PI/2),u=l/Math.sin(h+Math.PI/2),c=f(c)?c:0,u=f(u)?u:0,this.drawingArea=d-(u+c)/2,this.setCenterPoint(u,c)},setCenterPoint:function(t,i){var e=this.width-i-this.drawingArea,s=t+this.drawingArea;this.xCenter=(s+e)/2,this.yCenter=this.height/2},getIndexAngle:function(t){var i=2*Math.PI/this.valuesCount;return t*i-Math.PI/2},getPointPosition:function(t,i){var e=this.getIndexAngle(t);return{x:Math.cos(e)*i+this.xCenter,y:Math.sin(e)*i+this.yCenter}},draw:function(){if(this.display){var t=this.ctx;if(n(this.yLabels,function(i,e){if(e>0){var s,n=e*(this.drawingArea/this.steps),o=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var a=0;a<this.valuesCount;a++)s=this.getPointPosition(a,this.calculateCenterOffset(this.min+e*this.stepValue)),0===a?t.moveTo(s.x,s.y):t.lineTo(s.x,s.y);t.closePath(),t.stroke()}if(this.showLabels){if(t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.showLabelBackdrop){var h=t.measureText(i).width;t.fillStyle=this.backdropColor,t.fillRect(this.xCenter-h/2-this.backdropPaddingX,o-this.fontSize/2-this.backdropPaddingY,h+2*this.backdropPaddingX,this.fontSize+2*this.backdropPaddingY)}t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.fontColor,t.fillText(i,this.xCenter,o)}}},this),!this.lineArc){t.lineWidth=this.angleLineWidth,t.strokeStyle=this.angleLineColor;for(var i=this.valuesCount-1;i>=0;i--){if(this.angleLineWidth>0){var e=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(e.x,e.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var o=this.labels.length,a=this.labels.length/2,h=a/2,l=h>i||i>o-h,r=i===h||i===o-h;t.textAlign=0===i?"center":i===a?"center":a>i?"left":"right",t.textBaseline=r?"middle":l?"bottom":"top",t.fillText(this.labels[i],s.x,s.y)}}}}}),s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(e.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return e}):"object"==typeof module&&module.exports&&(module.exports=e),t.Chart=e,e.noConflict=function(){return t.Chart=i,e}}).call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Bar",defaults:s,initialize:function(t){var s=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,i,e){var n=this.calculateBaseWidth(),o=this.calculateX(e)-n/2,a=this.calculateBarWidth(t);return o+a*i+i*s.barDatasetSpacing+a/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return i/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.bars.push(new this.BarClass({value:n,label:t.labels[o],datasetLabel:i.label,strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,i,s){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,s,i),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(i,s){e.each(i.bars,t,this,s)},this)},getBarsAtEvent:function(t){for(var i,s=[],n=e.getRelativePosition(t),o=function(t){s.push(t.bars[i])},a=0;a<this.datasets.length;a++)for(i=0;i<this.datasets[a].bars.length;i++)if(this.datasets[a].bars[i].inRange(n.x,n.y))return e.each(this.datasets,o),s;return s},buildScale:function(t){var i=this,s=function(){var t=[];return i.eachBars(function(i){t.push(i.value)}),t},n={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(s(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.barShowStroke?this.options.barStrokeWidth:0,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(n,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new this.ScaleClass(n)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].bars.push(new this.BarClass({value:t,label:i,x:this.scale.calculateBarX(this.datasets.length,s,this.scale.valuesCount+1),y:this.scale.endPoint,width:this.scale.calculateBarWidth(this.datasets.length),base:this.scale.endPoint,strokeColor:this.datasets[s].strokeColor,fillColor:this.datasets[s].fillColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.bars.shift()},this),this.update()},reflow:function(){e.extend(this.BarClass.prototype,{y:this.scale.endPoint,base:this.scale.endPoint});var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t,s){e.each(t.bars,function(t,e){t.base=this.scale.endPoint,t.transition({x:this.scale.calculateBarX(this.datasets.length,s,e),y:this.scale.calculateY(t.value),width:this.scale.calculateBarWidth(this.datasets.length)},i).draw()},this)},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,percentageInnerCutout:50,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.segments=[],this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];
+e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.calculateTotal(t),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({value:t.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(t.value),label:t.label})),e||(this.reflow(),this.update())},calculateCircumference:function(t){return 2*Math.PI*(t/this.total)},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this)},update:function(){this.calculateTotal(this.segments),e.each(this.activeElements,function(t){t.restore(["fillColor"])}),e.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,e.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var i=t?t:1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},i),t.endAngle=t.startAngle+t.circumference,t.draw(),0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle)},this)}}),i.types.Doughnut.extend({name:"Pie",defaults:e.merge(s,{percentageInnerCutout:0})})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,bezierCurve:!0,bezierCurveTension:.4,pointDot:!0,pointDotRadius:4,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Line",defaults:s,initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(t){return Math.pow(t-this.x,2)<Math.pow(this.radius+this.hitDetectionRadius,2)}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.points.push(new this.PointClass({value:n,label:t.labels[o],datasetLabel:i.label,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))},this),this.buildScale(t.labels),this.eachPoints(function(t,i){e.extend(t,{x:this.scale.calculateX(i),y:this.scale.endPoint}),t.save()},this)},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachPoints(function(t){t.save()}),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.datasets,function(t){e.each(t.points,function(t){t.inRange(s.x,s.y)&&i.push(t)})},this),i},buildScale:function(t){var s=this,n=function(){var t=[];return s.eachPoints(function(i){t.push(i.value)}),t},o={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(n(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.pointDotRadius+this.options.pointDotStrokeWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(o,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new i.Scale(o)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].points.push(new this.PointClass({value:t,label:i,x:this.scale.calculateX(this.scale.valuesCount+1),y:this.scale.endPoint,strokeColor:this.datasets[s].pointStrokeColor,fillColor:this.datasets[s].pointColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.points.shift()},this),this.update()},reflow:function(){var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();var s=this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.transition({y:this.scale.calculateY(t.value),x:this.scale.calculateX(e)},i)},this),this.options.bezierCurve&&e.each(t.points,function(i,s){i.controlPoints=0===s?e.splineCurve(i,i,t.points[s+1],0):s>=t.points.length-1?e.splineCurve(t.points[s-1],i,i,0):e.splineCurve(t.points[s-1],i,t.points[s+1],this.options.bezierCurveTension)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(i,e){e>0?this.options.bezierCurve?s.bezierCurveTo(t.points[e-1].controlPoints.outer.x,t.points[e-1].controlPoints.outer.y,i.controlPoints.inner.x,i.controlPoints.inner.y,i.x,i.y):s.lineTo(i.x,i.y):s.moveTo(i.x,i.y)},this),s.stroke(),this.options.datasetFill&&(s.lineTo(t.points[t.points.length-1].x,this.scale.endPoint),s.lineTo(this.scale.calculateX(0),this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),e.each(t.points,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBeginAtZero:!0,scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,scaleShowLine:!0,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.segments=[],this.SegmentArc=i.Arc.extend({showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,ctx:this.chart.ctx,innerRadius:0,x:this.chart.width/2,y:this.chart.height/2}),this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,valuesCount:t.length}),this.updateScaleRange(t),this.scale.update(),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value,outerRadius:this.options.animateScale?0:this.scale.calculateCenterOffset(t.value),circumference:this.options.animateRotate?0:this.scale.getCircumference(),startAngle:1.5*Math.PI})),e||(this.reflow(),this.update())},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var i=[];e.each(t,function(t){i.push(t.value)});var s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s,{size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.calculateTotal(this.segments),e.each(this.segments,function(t){t.save()}),this.render()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),e.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),e.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var i=t||1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},i),t.endAngle=t.startAngle+t.circumference,0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle),t.draw()},this),this.scale.draw()}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers;i.Type.extend({name:"Radar",defaults:{scaleShowLine:!0,angleShowLineOut:!0,scaleShowLabels:!1,scaleBeginAtZero:!0,angleLineColor:"rgba(0,0,0,.1)",angleLineWidth:1,pointLabelFontFamily:"'Arial'",pointLabelFontStyle:"normal",pointLabelFontSize:10,pointLabelFontColor:"#666",pointDot:!0,pointDotRadius:3,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'},initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx}),this.datasets=[],this.buildScale(t),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(n,o){if(e.isNumber(n)){var a;this.scale.animation||(a=this.scale.getPointPosition(o,this.scale.calculateCenterOffset(n))),s.points.push(new this.PointClass({value:n,label:t.labels[o],datasetLabel:i.label,x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))}},this)},this),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=e.getRelativePosition(t),s=e.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},i),n=2*Math.PI/this.scale.valuesCount,o=Math.round((s.angle-1.5*Math.PI)/n),a=[];return(o>=this.scale.valuesCount||0>o)&&(o=0),s.distance<=this.scale.drawingArea&&e.each(this.datasets,function(t){a.push(t.points[o])}),a},buildScale:function(t){this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,angleLineColor:this.options.angleLineColor,angleLineWidth:this.options.angleShowLineOut?this.options.angleLineWidth:0,pointLabelFontColor:this.options.pointLabelFontColor,pointLabelFontSize:this.options.pointLabelFontSize,pointLabelFontFamily:this.options.pointLabelFontFamily,pointLabelFontStyle:this.options.pointLabelFontStyle,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,labels:t.labels,valuesCount:t.datasets[0].data.length}),this.scale.setScaleSize(),this.updateScaleRange(t.datasets),this.scale.buildYLabels()},updateScaleRange:function(t){var i=function(){var i=[];return e.each(t,function(t){t.data?i=i.concat(t.data):e.each(t.points,function(t){i.push(t.value)})}),i}(),s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s)},addData:function(t,i){this.scale.valuesCount++,e.each(t,function(t,s){if(e.isNumber(t)){var n=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[s].points.push(new this.PointClass({value:t,label:i,x:n.x,y:n.y,strokeColor:this.datasets[s].pointStrokeColor,fillColor:this.datasets[s].pointColor}))}},this),this.scale.labels.push(i),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),e.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){e.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2}),this.updateScaleRange(this.datasets),this.scale.setScaleSize(),this.scale.buildYLabels()},draw:function(t){var i=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.transition(this.scale.getPointPosition(e,this.scale.calculateCenterOffset(t.value)),i)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(t,i){0===i?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),e.each(t.points,function(t){t.draw()})},this)}})}.call(this);
\ No newline at end of file | true |
Other | chartjs | Chart.js | ea9d144c71819cbb3499d0640102689e10e25a02.json | Reflow the Radar before updating to update scale | src/Chart.Radar.js | @@ -275,6 +275,7 @@
this.eachPoints(function(point){
point.save();
});
+ this.reflow();
this.render();
},
reflow: function(){ | false |
Other | chartjs | Chart.js | 7a231313668f3b3dfe949dabd2c8da69f9088c55.json | Add datasetLabel to elements for tooltip templates | src/Chart.Bar.js | @@ -109,6 +109,7 @@
datasetObject.bars.push(new this.BarClass({
value : dataPoint,
label : data.labels[index],
+ datasetLabel: dataset.label,
strokeColor : dataset.strokeColor,
fillColor : dataset.fillColor,
highlightFill : dataset.highlightFill || dataset.fillColor, | true |
Other | chartjs | Chart.js | 7a231313668f3b3dfe949dabd2c8da69f9088c55.json | Add datasetLabel to elements for tooltip templates | src/Chart.Line.js | @@ -104,8 +104,7 @@
datasetObject.points.push(new this.PointClass({
value : dataPoint,
label : data.labels[index],
- // x: this.scale.calculateX(index),
- // y: this.scale.endPoint,
+ datasetLabel: dataset.label,
strokeColor : dataset.pointStrokeColor,
fillColor : dataset.pointColor,
highlightFill : dataset.pointHighlightFill || dataset.pointColor, | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.