PageSourceSearch

https://tofas.com.tr/_catalogs/masterpage/bower_components/chart.js/dist/Chart.js

js tofas.com.tr collected 2026-09-24 19:34:58 UTC 403,941 bytes, 14,384 lines download raw bytes

1/*!
2 * Chart.js
3 * http://chartjs.org/
4 * Version: 2.7.2
5 *
6 * Copyright 2018 Chart.js Contributors
7 * Released under the MIT license
8 * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
9 */
10(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Chart = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
11
12},{}],2:[function(require,module,exports){
13/* MIT license */
14var colorNames = require(6);
15
16module.exports = {
17   getRgba: getRgba,
18   getHsla: getHsla,
19   getRgb: getRgb,
20   getHsl: getHsl,
21   getHwb: getHwb,
22   getAlpha: getAlpha,
23
24   hexString: hexString,
25   rgbString: rgbString,
26   rgbaString: rgbaString,
27   percentString: percentString,
28   percentaString: percentaString,
29   hslString: hslString,
30   hslaString: hslaString,
31   hwbString: hwbString,
32   keyword: keyword
33}
34
35function getRgba(string) {
36   if (!string) {
37      return;
38   }
39   var abbr =  /^#([a-fA-F0-9]{3})$/i,
40       hex =  /^#([a-fA-F0-9]{6})$/i,
41       rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
42       per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i,
43       keyword = /(\w+)/;
44
45   var rgb = [0, 0, 0],
46       a = 1,
47       match = string.match(abbr);
48   if (match) {
49      match = match[1];
50      for (var i = 0; i < rgb.length; i++) {
51         rgb[i] = parseInt(match[i] + match[i], 16);
52      }
53   }
54   else if (match = string.match(hex)) {
55      match = match[1];
56      for (var i = 0; i < rgb.length; i++) {
57         rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16);
58      }
59   }
60   else if (match = string.match(rgba)) {
61      for (var i = 0; i < rgb.length; i++) {
62         rgb[i] = parseInt(match[i + 1]);
63      }
64      a = parseFloat(match[4]);
65   }
66   else if (match = string.match(per)) {
67      for (var i = 0; i < rgb.length; i++) {
68         rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
69      }
70      a = parseFloat(match[4]);
71   }
72   else if (match = string.match(keyword)) {
73      if (match[1] == "transparent") {
74         return [0, 0, 0, 0];
75      }
76      rgb = colorNames[match[1]];
77      if (!rgb) {
78         return;
79      }
80   }
81
82   for (var i = 0; i < rgb.length; i++) {
83      rgb[i] = scale(rgb[i], 0, 255);
84   }
85   if (!a && a != 0) {
86      a = 1;
87   }
88   else {
89      a = scale(a, 0, 1);
90   }
91   rgb[3] = a;
92   return rgb;
93}
94
95function getHsla(string) {
96   if (!string) {
97      return;
98   }
99   var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
100   var match = string.match(hsl);
101   if (match) {
102      var alpha = parseFloat(match[4]);
103      var h = scale(parseInt(match[1]), 0, 360),
104          s = scale(parseFloat(match[2]), 0, 100),
105          l = scale(parseFloat(match[3]), 0, 100),
106          a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
107      return [h, s, l, a];
108   }
109}
110
111function getHwb(string) {
112   if (!string) {
113      return;
114   }
115   var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
116   var match = string.match(hwb);
117   if (match) {
118    var alpha = parseFloat(match[4]);
119      var h = scale(parseInt(match[1]), 0, 360),
120          w = scale(parseFloat(match[2]), 0, 100),
121          b = scale(parseFloat(match[3]), 0, 100),
122          a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
123      return [h, w, b, a];
124   }
125}
126
127function getRgb(string) {
128   var rgba = getRgba(string);
129   return rgba && rgba.slice(0, 3);
130}
131
132function getHsl(string) {
133  var hsla = getHsla(string);
134  return hsla && hsla.slice(0, 3);
135}
136
137function getAlpha(string) {
138   var vals = getRgba(string);
139   if (vals) {
140      return vals[3];
141   }
142   else if (vals = getHsla(string)) {
143      return vals[3];
144   }
145   else if (vals = getHwb(string)) {
146      return vals[3];
147   }
148}
149
150// generators
151function hexString(rgb) {
152   return "#" + hexDouble(rgb[0]) + hexDouble(rgb[1])
153              + hexDouble(rgb[2]);
154}
155
156function rgbString(rgba, alpha) {
vendor: 14,231 bytes, lines 157-761
157   if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
158      return rgbaString(rgba, alpha);
159   }
160   return "rgb(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + ")";
161}
162
163function rgbaString(rgba, alpha) {
164   if (alpha === undefined) {
165      alpha = (rgba[3] !== undefined ? rgba[3] : 1);
166   }
167   return "rgba(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2]
168           + ", " + alpha + ")";
169}
170
171function percentString(rgba, alpha) {
172   if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
173      return percentaString(rgba, alpha);
174   }
175   var r = Math.round(rgba[0]/255 * 100),
176       g = Math.round(rgba[1]/255 * 100),
177       b = Math.round(rgba[2]/255 * 100);
178
179   return "rgb(" + r + "%, " + g + "%, " + b + "%)";
180}
181
182function percentaString(rgba, alpha) {
183   var r = Math.round(rgba[0]/255 * 100),
184       g = Math.round(rgba[1]/255 * 100),
185       b = Math.round(rgba[2]/255 * 100);
186   return "rgba(" + r + "%, " + g + "%, " + b + "%, " + (alpha || rgba[3] || 1) + ")";
187}
188
189function hslString(hsla, alpha) {
190   if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
191      return hslaString(hsla, alpha);
192   }
193   return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)";
194}
195
196function hslaString(hsla, alpha) {
197   if (alpha === undefined) {
198      alpha = (hsla[3] !== undefined ? hsla[3] : 1);
199   }
200   return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, "
201           + alpha + ")";
202}
203
204// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
205// (hwb have alpha optional & 1 is default value)
206function hwbString(hwb, alpha) {
207   if (alpha === undefined) {
208      alpha = (hwb[3] !== undefined ? hwb[3] : 1);
209   }
210   return "hwb(" + hwb[0] + ", " + hwb[1] + "%, " + hwb[2] + "%"
211           + (alpha !== undefined && alpha !== 1 ? ", " + alpha : "") + ")";
212}
213
214function keyword(rgb) {
215  return reverseNames[rgb.slice(0, 3)];
216}
217
218// helpers
219function scale(num, min, max) {
220   return Math.min(Math.max(min, num), max);
221}
222
223function hexDouble(num) {
224  var str = num.toString(16).toUpperCase();
225  return (str.length < 2) ? "0" + str : str;
226}
227
228
229//create a list of reverse color names
230var reverseNames = {};
231for (var name in colorNames) {
232   reverseNames[colorNames[name]] = name;
233}
234
235},{"6":6}],3:[function(require,module,exports){
236/* MIT license */
237var convert = require(5);
238var string = require(2);
239
240var Color = function (obj) {
241	if (obj instanceof Color) {
242		return obj;
243	}
244	if (!(this instanceof Color)) {
245		return new Color(obj);
246	}
247
248	this.valid = false;
249	this.values = {
250		rgb: [0, 0, 0],
251		hsl: [0, 0, 0],
252		hsv: [0, 0, 0],
253		hwb: [0, 0, 0],
254		cmyk: [0, 0, 0, 0],
255		alpha: 1
256	};
257
258	// parse Color() argument
259	var vals;
260	if (typeof obj === 'string') {
261		vals = string.getRgba(obj);
262		if (vals) {
263			this.setValues('rgb', vals);
264		} else if (vals = string.getHsla(obj)) {
265			this.setValues('hsl', vals);
266		} else if (vals = string.getHwb(obj)) {
267			this.setValues('hwb', vals);
268		}
269	} else if (typeof obj === 'object') {
270		vals = obj;
271		if (vals.r !== undefined || vals.red !== undefined) {
272			this.setValues('rgb', vals);
273		} else if (vals.l !== undefined || vals.lightness !== undefined) {
274			this.setValues('hsl', vals);
275		} else if (vals.v !== undefined || vals.value !== undefined) {
276			this.setValues('hsv', vals);
277		} else if (vals.w !== undefined || vals.whiteness !== undefined) {
278			this.setValues('hwb', vals);
279		} else if (vals.c !== undefined || vals.cyan !== undefined) {
280			this.setValues('cmyk', vals);
281		}
282	}
283};
284
285Color.prototype = {
286	isValid: function () {
287		return this.valid;
288	},
289	rgb: function () {
290		return this.setSpace('rgb', arguments);
291	},
292	hsl: function () {
293		return this.setSpace('hsl', arguments);
294	},
295	hsv: function () {
296		return this.setSpace('hsv', arguments);
297	},
298	hwb: function () {
299		return this.setSpace('hwb', arguments);
300	},
301	cmyk: function () {
302		return this.setSpace('cmyk', arguments);
303	},
304
305	rgbArray: function () {
306		return this.values.rgb;
307	},
308	hslArray: function () {
309		return this.values.hsl;
310	},
311	hsvArray: function () {
312		return this.values.hsv;
313	},
314	hwbArray: function () {
315		var values = this.values;
316		if (values.alpha !== 1) {
317			return values.hwb.concat([values.alpha]);
318		}
319		return values.hwb;
320	},
321	cmykArray: function () {
322		return this.values.cmyk;
323	},
324	rgbaArray: function () {
325		var values = this.values;
326		return values.rgb.concat([values.alpha]);
327	},
328	hslaArray: function () {
329		var values = this.values;
330		return values.hsl.concat([values.alpha]);
331	},
332	alpha: function (val) {
333		if (val === undefined) {
334			return this.values.alpha;
335		}
336		this.setValues('alpha', val);
337		return this;
338	},
339
340	red: function (val) {
341		return this.setChannel('rgb', 0, val);
342	},
343	green: function (val) {
344		return this.setChannel('rgb', 1, val);
345	},
346	blue: function (val) {
347		return this.setChannel('rgb', 2, val);
348	},
349	hue: function (val) {
350		if (val) {
351			val %= 360;
352			val = val < 0 ? 360 + val : val;
353		}
354		return this.setChannel('hsl', 0, val);
355	},
356	saturation: function (val) {
357		return this.setChannel('hsl', 1, val);
358	},
359	lightness: function (val) {
360		return this.setChannel('hsl', 2, val);
361	},
362	saturationv: function (val) {
363		return this.setChannel('hsv', 1, val);
364	},
365	whiteness: function (val) {
366		return this.setChannel('hwb', 1, val);
367	},
368	blackness: function (val) {
369		return this.setChannel('hwb', 2, val);
370	},
371	value: function (val) {
372		return this.setChannel('hsv', 2, val);
373	},
374	cyan: function (val) {
375		return this.setChannel('cmyk', 0, val);
376	},
377	magenta: function (val) {
378		return this.setChannel('cmyk', 1, val);
379	},
380	yellow: function (val) {
381		return this.setChannel('cmyk', 2, val);
382	},
383	black: function (val) {
384		return this.setChannel('cmyk', 3, val);
385	},
386
387	hexString: function () {
388		return string.hexString(this.values.rgb);
389	},
390	rgbString: function () {
391		return string.rgbString(this.values.rgb, this.values.alpha);
392	},
393	rgbaString: function () {
394		return string.rgbaString(this.values.rgb, this.values.alpha);
395	},
396	percentString: function () {
397		return string.percentString(this.values.rgb, this.values.alpha);
398	},
399	hslString: function () {
400		return string.hslString(this.values.hsl, this.values.alpha);
401	},
402	hslaString: function () {
403		return string.hslaString(this.values.hsl, this.values.alpha);
404	},
405	hwbString: function () {
406		return string.hwbString(this.values.hwb, this.values.alpha);
407	},
408	keyword: function () {
409		return string.keyword(this.values.rgb, this.values.alpha);
410	},
411
412	rgbNumber: function () {
413		var rgb = this.values.rgb;
414		return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
415	},
416
417	luminosity: function () {
418		// http://www.w3.org/TR/WCAG20/#relativeluminancedef
419		var rgb = this.values.rgb;
420		var lum = [];
421		for (var i = 0; i < rgb.length; i++) {
422			var chan = rgb[i] / 255;
423			lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
424		}
425		return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
426	},
427
428	contrast: function (color2) {
429		// http://www.w3.org/TR/WCAG20/#contrast-ratiodef
430		var lum1 = this.luminosity();
431		var lum2 = color2.luminosity();
432		if (lum1 > lum2) {
433			return (lum1 + 0.05) / (lum2 + 0.05);
434		}
435		return (lum2 + 0.05) / (lum1 + 0.05);
436	},
437
438	level: function (color2) {
439		var contrastRatio = this.contrast(color2);
440		if (contrastRatio >= 7.1) {
441			return 'AAA';
442		}
443
444		return (contrastRatio >= 4.5) ? 'AA' : '';
445	},
446
447	dark: function () {
448		// YIQ equation from http://24ways.org/2010/calculating-color-contrast
449		var rgb = this.values.rgb;
450		var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
451		return yiq < 128;
452	},
453
454	light: function () {
455		return !this.dark();
456	},
457
458	negate: function () {
459		var rgb = [];
460		for (var i = 0; i < 3; i++) {
461			rgb[i] = 255 - this.values.rgb[i];
462		}
463		this.setValues('rgb', rgb);
464		return this;
465	},
466
467	lighten: function (ratio) {
468		var hsl = this.values.hsl;
469		hsl[2] += hsl[2] * ratio;
470		this.setValues('hsl', hsl);
471		return this;
472	},
473
474	darken: function (ratio) {
475		var hsl = this.values.hsl;
476		hsl[2] -= hsl[2] * ratio;
477		this.setValues('hsl', hsl);
478		return this;
479	},
480
481	saturate: function (ratio) {
482		var hsl = this.values.hsl;
483		hsl[1] += hsl[1] * ratio;
484		this.setValues('hsl', hsl);
485		return this;
486	},
487
488	desaturate: function (ratio) {
489		var hsl = this.values.hsl;
490		hsl[1] -= hsl[1] * ratio;
491		this.setValues('hsl', hsl);
492		return this;
493	},
494
495	whiten: function (ratio) {
496		var hwb = this.values.hwb;
497		hwb[1] += hwb[1] * ratio;
498		this.setValues('hwb', hwb);
499		return this;
500	},
501
502	blacken: function (ratio) {
503		var hwb = this.values.hwb;
504		hwb[2] += hwb[2] * ratio;
505		this.setValues('hwb', hwb);
506		return this;
507	},
508
509	greyscale: function () {
510		var rgb = this.values.rgb;
511		// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
512		var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
513		this.setValues('rgb', [val, val, val]);
514		return this;
515	},
516
517	clearer: function (ratio) {
518		var alpha = this.values.alpha;
519		this.setValues('alpha', alpha - (alpha * ratio));
520		return this;
521	},
522
523	opaquer: function (ratio) {
524		var alpha = this.values.alpha;
525		this.setValues('alpha', alpha + (alpha * ratio));
526		return this;
527	},
528
529	rotate: function (degrees) {
530		var hsl = this.values.hsl;
531		var hue = (hsl[0] + degrees) % 360;
532		hsl[0] = hue < 0 ? 360 + hue : hue;
533		this.setValues('hsl', hsl);
534		return this;
535	},
536
537	/**
538	 * Ported from sass implementation in C
539	 * https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
540	 */
541	mix: function (mixinColor, weight) {
542		var color1 = this;
543		var color2 = mixinColor;
544		var p = weight === undefined ? 0.5 : weight;
545
546		var w = 2 * p - 1;
547		var a = color1.alpha() - color2.alpha();
548
549		var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
550		var w2 = 1 - w1;
551
552		return this
553			.rgb(
554				w1 * color1.red() + w2 * color2.red(),
555				w1 * color1.green() + w2 * color2.green(),
556				w1 * color1.blue() + w2 * color2.blue()
557			)
558			.alpha(color1.alpha() * p + color2.alpha() * (1 - p));
559	},
560
561	toJSON: function () {
562		return this.rgb();
563	},
564
565	clone: function () {
566		// NOTE(SB): using node-clone creates a dependency to Buffer when using browserify,
567		// making the final build way to big to embed in Chart.js. So let's do it manually,
568		// assuming that values to clone are 1 dimension arrays containing only numbers,
569		// except 'alpha' which is a number.
570		var result = new Color();
571		var source = this.values;
572		var target = result.values;
573		var value, type;
574
575		for (var prop in source) {
576			if (source.hasOwnProperty(prop)) {
577				value = source[prop];
578				type = ({}).toString.call(value);
579				if (type === '[object Array]') {
580					target[prop] = value.slice(0);
581				} else if (type === '[object Number]') {
582					target[prop] = value;
583				} else {
584					console.error('unexpected color value:', value);
585				}
586			}
587		}
588
589		return result;
590	}
591};
592
593Color.prototype.spaces = {
594	rgb: ['red', 'green', 'blue'],
595	hsl: ['hue', 'saturation', 'lightness'],
596	hsv: ['hue', 'saturation', 'value'],
597	hwb: ['hue', 'whiteness', 'blackness'],
598	cmyk: ['cyan', 'magenta', 'yellow', 'black']
599};
600
601Color.prototype.maxes = {
602	rgb: [255, 255, 255],
603	hsl: [360, 100, 100],
604	hsv: [360, 100, 100],
605	hwb: [360, 100, 100],
606	cmyk: [100, 100, 100, 100]
607};
608
609Color.prototype.getValues = function (space) {
610	var values = this.values;
611	var vals = {};
612
613	for (var i = 0; i < space.length; i++) {
614		vals[space.charAt(i)] = values[space][i];
615	}
616
617	if (values.alpha !== 1) {
618		vals.a = values.alpha;
619	}
620
621	// {r: 255, g: 255, b: 255, a: 0.4}
622	return vals;
623};
624
625Color.prototype.setValues = function (space, vals) {
626	var values = this.values;
627	var spaces = this.spaces;
628	var maxes = this.maxes;
629	var alpha = 1;
630	var i;
631
632	this.valid = true;
633
634	if (space === 'alpha') {
635		alpha = vals;
636	} else if (vals.length) {
637		// [10, 10, 10]
638		values[space] = vals.slice(0, space.length);
639		alpha = vals[space.length];
640	} else if (vals[space.charAt(0)] !== undefined) {
641		// {r: 10, g: 10, b: 10}
642		for (i = 0; i < space.length; i++) {
643			values[space][i] = vals[space.charAt(i)];
644		}
645
646		alpha = vals.a;
647	} else if (vals[spaces[space][0]] !== undefined) {
648		// {red: 10, green: 10, blue: 10}
649		var chans = spaces[space];
650
651		for (i = 0; i < space.length; i++) {
652			values[space][i] = vals[chans[i]];
653		}
654
655		alpha = vals.alpha;
656	}
657
658	values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? values.alpha : alpha)));
659
660	if (space === 'alpha') {
661		return false;
662	}
663
664	var capped;
665
666	// cap values of the space prior converting all values
667	for (i = 0; i < space.length; i++) {
668		capped = Math.max(0, Math.min(maxes[space][i], values[space][i]));
669		values[space][i] = Math.round(capped);
670	}
671
672	// convert to all the other color spaces
673	for (var sname in spaces) {
674		if (sname !== space) {
675			values[sname] = convert[space][sname](values[space]);
676		}
677	}
678
679	return true;
680};
681
682Color.prototype.setSpace = function (space, args) {
683	var vals = args[0];
684
685	if (vals === undefined) {
686		// color.rgb()
687		return this.getValues(space);
688	}
689
690	// color.rgb(10, 10, 10)
691	if (typeof vals === 'number') {
692		vals = Array.prototype.slice.call(args);
693	}
694
695	this.setValues(space, vals);
696	return this;
697};
698
699Color.prototype.setChannel = function (space, index, val) {
700	var svalues = this.values[space];
701	if (val === undefined) {
702		// color.red()
703		return svalues[index];
704	} else if (val === svalues[index]) {
705		// color.red(color.red())
706		return this;
707	}
708
709	// color.red(100)
710	svalues[index] = val;
711	this.setValues(space, svalues);
712
713	return this;
714};
715
716if (typeof window !== 'undefined') {
717	window.Color = Color;
718}
719
720module.exports = Color;
721
722},{"2":2,"5":5}],4:[function(require,module,exports){
723/* MIT license */
724
725module.exports = {
726  rgb2hsl: rgb2hsl,
727  rgb2hsv: rgb2hsv,
728  rgb2hwb: rgb2hwb,
729  rgb2cmyk: rgb2cmyk,
730  rgb2keyword: rgb2keyword,
731  rgb2xyz: rgb2xyz,
732  rgb2lab: rgb2lab,
733  rgb2lch: rgb2lch,
734
735  hsl2rgb: hsl2rgb,
736  hsl2hsv: hsl2hsv,
737  hsl2hwb: hsl2hwb,
738  hsl2cmyk: hsl2cmyk,
739  hsl2keyword: hsl2keyword,
740
741  hsv2rgb: hsv2rgb,
742  hsv2hsl: hsv2hsl,
743  hsv2hwb: hsv2hwb,
744  hsv2cmyk: hsv2cmyk,
745  hsv2keyword: hsv2keyword,
746
747  hwb2rgb: hwb2rgb,
748  hwb2hsl: hwb2hsl,
749  hwb2hsv: hwb2hsv,
750  hwb2cmyk: hwb2cmyk,
751  hwb2keyword: hwb2keyword,
752
753  cmyk2rgb: cmyk2rgb,
754  cmyk2hsl: cmyk2hsl,
755  cmyk2hsv: cmyk2hsv,
756  cmyk2hwb: cmyk2hwb,
757  cmyk2keyword: cmyk2keyword,
758
759  keyword2rgb: keyword2rgb,
760  keyword2hsl: keyword2hsl,
761  keyword2hsv: keyword2hsv,
762  keyword2hwb: keyword2hwb,
763  keyword2cmyk: keyword2cmyk,
764  keyword2lab: keyword2lab,
765  keyword2xyz: keyword2xyz,
766
767  xyz2rgb: xyz2rgb,
768  xyz2lab: xyz2lab,
769  xyz2lch: xyz2lch,
770
771  lab2xyz: lab2xyz,
772  lab2rgb: lab2rgb,
773  lab2lch: lab2lch,
774
775  lch2lab: lch2lab,
776  lch2xyz: lch2xyz,
777  lch2rgb: lch2rgb
778}
779
780
781function rgb2hsl(rgb) {
782  var r = rgb[0]/255,
783      g = rgb[1]/255,
784      b = rgb[2]/255,
785      min = Math.min(r, g, b),
786      max = Math.max(r, g, b),
787      delta = max - min,
788      h, s, l;
789
790  if (max == min)
791    h = 0;
792  else if (r == max)
793    h = (g - b) / delta;
794  else if (g == max)
795    h = 2 + (b - r) / delta;
796  else if (b == max)
797    h = 4 + (r - g)/ delta;
798
799  h = Math.min(h * 60, 360);
800
801  if (h < 0)
802    h += 360;
803
804  l = (min + max) / 2;
805
806  if (max == min)
807    s = 0;
808  else if (l <= 0.5)
809    s = delta / (max + min);
810  else
811    s = delta / (2 - max - min);
812
813  return [h, s * 100, l * 100];
814}
815
816function rgb2hsv(rgb) {
817  var r = rgb[0],
818      g = rgb[1],
819      b = rgb[2],
820      min = Math.min(r, g, b),
821      max = Math.max(r, g, b),
822      delta = max - min,
823      h, s, v;
824
825  if (max == 0)
826    s = 0;
827  else
828    s = (delta/max * 1000)/10;
829
830  if (max == min)
831    h = 0;
832  else if (r == max)
833    h = (g - b) / delta;
834  else if (g == max)
835    h = 2 + (b - r) / delta;
836  else if (b == max)
837    h = 4 + (r - g) / delta;
838
839  h = Math.min(h * 60, 360);
840
841  if (h < 0)
842    h += 360;
843
844  v = ((max / 255) * 1000) / 10;
845
846  return [h, s, v];
847}
848
849function rgb2hwb(rgb) {
850  var r = rgb[0],
851      g = rgb[1],
852      b = rgb[2],
853      h = rgb2hsl(rgb)[0],
854      w = 1/255 * Math.min(r, Math.min(g, b)),
855      b = 1 - 1/255 * Math.max(r, Math.max(g, b));
856
857  return [h, w * 100, b * 100];
858}
859
860function rgb2cmyk(rgb) {
861  var r = rgb[0] / 255,
862      g = rgb[1] / 255,
863      b = rgb[2] / 255,
864      c, m, y, k;
865
866  k = Math.min(1 - r, 1 - g, 1 - b);
867  c = (1 - r - k) / (1 - k) || 0;
868  m = (1 - g - k) / (1 - k) || 0;
869  y = (1 - b - k) / (1 - k) || 0;
870  return [c * 100, m * 100, y * 100, k * 100];
871}
872
873function rgb2keyword(rgb) {
874  return reverseKeywords[JSON.stringify(rgb)];
875}
876
877function rgb2xyz(rgb) {
878  var r = rgb[0] / 255,
879      g = rgb[1] / 255,
880      b = rgb[2] / 255;
881
882  // assume sRGB
883  r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
884  g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
885  b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
886
887  var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
888  var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
889  var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
890
891  return [x * 100, y *100, z * 100];
892}
893
894function rgb2lab(rgb) {
895  var xyz = rgb2xyz(rgb),
896        x = xyz[0],
897        y = xyz[1],
898        z = xyz[2],
899        l, a, b;
900
901  x /= 95.047;
902  y /= 100;
903  z /= 108.883;
904
905  x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
906  y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
907  z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
908
909  l = (116 * y) - 16;
910  a = 500 * (x - y);
911  b = 200 * (y - z);
912
913  return [l, a, b];
914}
915
916function rgb2lch(args) {
917  return lab2lch(rgb2lab(args));
918}
919
920function hsl2rgb(hsl) {
921  var h = hsl[0] / 360,
922      s = hsl[1] / 100,
923      l = hsl[2] / 100,
924      t1, t2, t3, rgb, val;
925
926  if (s == 0) {
927    val = l * 255;
928    return [val, val, val];
929  }
930
931  if (l < 0.5)
932    t2 = l * (1 + s);
933  else
934    t2 = l + s - l * s;
935  t1 = 2 * l - t2;
936
937  rgb = [0, 0, 0];
938  for (var i = 0; i < 3; i++) {
939    t3 = h + 1 / 3 * - (i - 1);
940    t3 < 0 && t3++;
941    t3 > 1 && t3--;
942
943    if (6 * t3 < 1)
944      val = t1 + (t2 - t1) * 6 * t3;
945    else if (2 * t3 < 1)
946      val = t2;
947    else if (3 * t3 < 2)
948      val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
949    else
950      val = t1;
951
952    rgb[i] = val * 255;
953  }
954
955  return rgb;
956}
957
958function hsl2hsv(hsl) {
959  var h = hsl[0],
960      s = hsl[1] / 100,
961      l = hsl[2] / 100,
962      sv, v;
963
964  if(l === 0) {
965      // no need to do calc on black
966      // also avoids divide by 0 error
967      return [0, 0, 0];
968  }
969
970  l *= 2;
971  s *= (l <= 1) ? l : 2 - l;
972  v = (l + s) / 2;
973  sv = (2 * s) / (l + s);
974  return [h, sv * 100, v * 100];
975}
976
977function hsl2hwb(args) {
978  return rgb2hwb(hsl2rgb(args));
979}
980
981function hsl2cmyk(args) {
982  return rgb2cmyk(hsl2rgb(args));
983}
984
985function hsl2keyword(args) {
986  return rgb2keyword(hsl2rgb(args));
987}
988
989
990function hsv2rgb(hsv) {
991  var h = hsv[0] / 60,
992      s = hsv[1] / 100,
993      v = hsv[2] / 100,
994      hi = Math.floor(h) % 6;
995
996  var f = h - Math.floor(h),
997      p = 255 * v * (1 - s),
998      q = 255 * v * (1 - (s * f)),
999      t = 255 * v * (1 - (s * (1 - f))),
1000      v = 255 * v;
1001
1002  switch(hi) {
1003    case 0:
1004      return [v, t, p];
1005    case 1:
1006      return [q, v, p];
1007    case 2:
1008      return [p, v, t];
1009    case 3:
1010      return [p, q, v];
1011    case 4:
1012      return [t, p, v];
1013    case 5:
1014      return [v, p, q];
1015  }
1016}
1017
1018function hsv2hsl(hsv) {
1019  var h = hsv[0],
1020      s = hsv[1] / 100,
1021      v = hsv[2] / 100,
1022      sl, l;
1023
1024  l = (2 - s) * v;
1025  sl = s * v;
1026  sl /= (l <= 1) ? l : 2 - l;
1027  sl = sl || 0;
1028  l /= 2;
1029  return [h, sl * 100, l * 100];
1030}
1031
1032function hsv2hwb(args) {
1033  return rgb2hwb(hsv2rgb(args))
1034}
1035
1036function hsv2cmyk(args) {
1037  return rgb2cmyk(hsv2rgb(args));
1038}
1039
1040function hsv2keyword(args) {
1041  return rgb2keyword(hsv2rgb(args));
1042}
1043
1044// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
1045function hwb2rgb(hwb) {
1046  var h = hwb[0] / 360,
1047      wh = hwb[1] / 100,
1048      bl = hwb[2] / 100,
1049      ratio = wh + bl,
1050      i, v, f, n;
1051
1052  // wh + bl cant be > 1
1053  if (ratio > 1) {
1054    wh /= ratio;
1055    bl /= ratio;
1056  }
1057
1058  i = Math.floor(6 * h);
1059  v = 1 - bl;
1060  f = 6 * h - i;
1061  if ((i & 0x01) != 0) {
1062    f = 1 - f;
1063  }
1064  n = wh + f * (v - wh);  // linear interpolation
1065
1066  switch (i) {
1067    default:
1068    case 6:
1069    case 0: r = v; g = n; b = wh; break;
1070    case 1: r = n; g = v; b = wh; break;
1071    case 2: r = wh; g = v; b = n; break;
1072    case 3: r = wh; g = n; b = v; break;
1073    case 4: r = n; g = wh; b = v; break;
1074    case 5: r = v; g = wh; b = n; break;
1075  }
1076
1077  return [r * 255, g * 255, b * 255];
1078}
1079
1080function hwb2hsl(args) {
1081  return rgb2hsl(hwb2rgb(args));
1082}
1083
1084function hwb2hsv(args) {
1085  return rgb2hsv(hwb2rgb(args));
1086}
1087
1088function hwb2cmyk(args) {
1089  return rgb2cmyk(hwb2rgb(args));
1090}
1091
1092function hwb2keyword(args) {
1093  return rgb2keyword(hwb2rgb(args));
1094}
1095
1096function cmyk2rgb(cmyk) {
1097  var c = cmyk[0] / 100,
1098      m = cmyk[1] / 100,
1099      y = cmyk[2] / 100,
1100      k = cmyk[3] / 100,
1101      r, g, b;
1102
1103  r = 1 - Math.min(1, c * (1 - k) + k);
1104  g = 1 - Math.min(1, m * (1 - k) + k);
1105  b = 1 - Math.min(1, y * (1 - k) + k);
1106  return [r * 255, g * 255, b * 255];
1107}
1108
1109function cmyk2hsl(args) {
1110  return rgb2hsl(cmyk2rgb(args));
1111}
1112
1113function cmyk2hsv(args) {
1114  return rgb2hsv(cmyk2rgb(args));
1115}
1116
1117function cmyk2hwb(args) {
1118  return rgb2hwb(cmyk2rgb(args));
1119}
1120
1121function cmyk2keyword(args) {
1122  return rgb2keyword(cmyk2rgb(args));
1123}
1124
1125
1126function xyz2rgb(xyz) {
1127  var x = xyz[0] / 100,
1128      y = xyz[1] / 100,
1129      z = xyz[2] / 100,
1130      r, g, b;
1131
1132  r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
1133  g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
1134  b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
1135
1136  // assume sRGB
1137  r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
1138    : r = (r * 12.92);
1139
1140  g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
1141    : g = (g * 12.92);
1142
1143  b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
1144    : b = (b * 12.92);
1145
1146  r = Math.min(Math.max(0, r), 1);
1147  g = Math.min(Math.max(0, g), 1);
1148  b = Math.min(Math.max(0, b), 1);
1149
1150  return [r * 255, g * 255, b * 255];
1151}
1152
1153function xyz2lab(xyz) {
1154  var x = xyz[0],
1155      y = xyz[1],
1156      z = xyz[2],
1157      l, a, b;
1158
1159  x /= 95.047;
1160  y /= 100;
1161  z /= 108.883;
1162
1163  x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
1164  y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
1165  z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
1166
1167  l = (116 * y) - 16;
1168  a = 500 * (x - y);
1169  b = 200 * (y - z);
1170
1171  return [l, a, b];
1172}
1173
1174function xyz2lch(args) {
1175  return lab2lch(xyz2lab(args));
1176}
1177
1178function lab2xyz(lab) {
1179  var l = lab[0],
1180      a = lab[1],
1181      b = lab[2],
1182      x, y, z, y2;
1183
1184  if (l <= 8) {
1185    y = (l * 100) / 903.3;
1186    y2 = (7.787 * (y / 100)) + (16 / 116);
1187  } else {
1188    y = 100 * Math.pow((l + 16) / 116, 3);
1189    y2 = Math.pow(y / 100, 1/3);
1190  }
1191
1192  x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);
1193
1194  z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);
1195
1196  return [x, y, z];
1197}
1198
1199function lab2lch(lab) {
1200  var l = lab[0],
1201      a = lab[1],
1202      b = lab[2],
1203      hr, h, c;
1204
1205  hr = Math.atan2(b, a);
1206  h = hr * 360 / 2 / Math.PI;
1207  if (h < 0) {
1208    h += 360;
1209  }
1210  c = Math.sqrt(a * a + b * b);
1211  return [l, c, h];
1212}
1213
1214function lab2rgb(args) {
1215  return xyz2rgb(lab2xyz(args));
1216}
1217
1218function lch2lab(lch) {
1219  var l = lch[0],
1220      c = lch[1],
1221      h = lch[2],
1222      a, b, hr;
1223
1224  hr = h / 360 * 2 * Math.PI;
1225  a = c * Math.cos(hr);
1226  b = c * Math.sin(hr);
1227  return [l, a, b];
1228}
1229
1230function lch2xyz(args) {
1231  return lab2xyz(lch2lab(args));
1232}
1233
1234function lch2rgb(args) {
1235  return lab2rgb(lch2lab(args));
1236}
1237
1238function keyword2rgb(keyword) {
1239  return cssKeywords[keyword];
1240}
1241
1242function keyword2hsl(args) {
1243  return rgb2hsl(keyword2rgb(args));
1244}
1245
1246function keyword2hsv(args) {
1247  return rgb2hsv(keyword2rgb(args));
1248}
1249
1250function keyword2hwb(args) {
1251  return rgb2hwb(keyword2rgb(args));
1252}
1253
1254function keyword2cmyk(args) {
1255  return rgb2cmyk(keyword2rgb(args));
1256}
1257
1258function keyword2lab(args) {
1259  return rgb2lab(keyword2rgb(args));
1260}
1261
1262function keyword2xyz(args) {
1263  return rgb2xyz(keyword2rgb(args));
1264}
1265
1266var cssKeywords = {
1267  aliceblue:  [240,248,255],
1268  antiquewhite: [250,235,215],
1269  aqua: [0,255,255],
1270  aquamarine: [127,255,212],
1271  azure:  [240,255,255],
1272  beige:  [245,245,220],
1273  bisque: [255,228,196],
1274  black:  [0,0,0],
1275  blanchedalmond: [255,235,205],
1276  blue: [0,0,255],
1277  blueviolet: [138,43,226],
1278  brown:  [165,42,42],
1279  burlywood:  [222,184,135],
1280  cadetblue:  [95,158,160],
1281  chartreuse: [127,255,0],
1282  chocolate:  [210,105,30],
1283  coral:  [255,127,80],
1284  cornflowerblue: [100,149,237],
1285  cornsilk: [255,248,220],
1286  crimson:  [220,20,60],
1287  cyan: [0,255,255],
1288  darkblue: [0,0,139],
1289  darkcyan: [0,139,139],
1290  darkgoldenrod:  [184,134,11],
1291  darkgray: [169,169,169],
1292  darkgreen:  [0,100,0],
1293  darkgrey: [169,169,169],
1294  darkkhaki:  [189,183,107],
1295  darkmagenta:  [139,0,139],
1296  darkolivegreen: [85,107,47],
1297  darkorange: [255,140,0],
1298  darkorchid: [153,50,204],
1299  darkred:  [139,0,0],
1300  darksalmon: [233,150,122],
1301  darkseagreen: [143,188,143],
1302  darkslateblue:  [72,61,139],
1303  darkslategray:  [47,79,79],
1304  darkslategrey:  [47,79,79],
1305  darkturquoise:  [0,206,209],
1306  darkviolet: [148,0,211],
1307  deeppink: [255,20,147],
1308  deepskyblue:  [0,191,255],
1309  dimgray:  [105,105,105],
1310  dimgrey:  [105,105,105],
1311  dodgerblue: [30,144,255],
1312  firebrick:  [178,34,34],
1313  floralwhite:  [255,250,240],
1314  forestgreen:  [34,139,34],
1315  fuchsia:  [255,0,255],
1316  gainsboro:  [220,220,220],
1317  ghostwhite: [248,248,255],
1318  gold: [255,215,0],
1319  goldenrod:  [218,165,32],
1320  gray: [128,128,128],
1321  green:  [0,128,0],
1322  greenyellow:  [173,255,47],
1323  grey: [128,128,128],
1324  honeydew: [240,255,240],
1325  hotpink:  [255,105,180],
1326  indianred:  [205,92,92],
1327  indigo: [75,0,130],
1328  ivory:  [255,255,240],
1329  khaki:  [240,230,140],
1330  lavender: [230,230,250],
1331  lavenderblush:  [255,240,245],
1332  lawngreen:  [124,252,0],
1333  lemonchiffon: [255,250,205],
1334  lightblue:  [173,216,230],
1335  lightcoral: [240,128,128],
1336  lightcyan:  [224,255,255],
1337  lightgoldenrodyellow: [250,250,210],
1338  lightgray:  [211,211,211],
1339  lightgreen: [144,238,144],
1340  lightgrey:  [211,211,211],
1341  lightpink:  [255,182,193],
1342  lightsalmon:  [255,160,122],
1343  lightseagreen:  [32,178,170],
1344  lightskyblue: [135,206,250],
1345  lightslategray: [119,136,153],
1346  lightslategrey: [119,136,153],
1347  lightsteelblue: [176,196,222],
1348  lightyellow:  [255,255,224],
1349  lime: [0,255,0],
1350  limegreen:  [50,205,50],
1351  linen:  [250,240,230],
1352  magenta:  [255,0,255],
1353  maroon: [128,0,0],
1354  mediumaquamarine: [102,205,170],
1355  mediumblue: [0,0,205],
1356  mediumorchid: [186,85,211],
1357  mediumpurple: [147,112,219],
1358  mediumseagreen: [60,179,113],
1359  mediumslateblue:  [123,104,238],
1360  mediumspringgreen:  [0,250,154],
1361  mediumturquoise:  [72,209,204],
1362  mediumvioletred:  [199,21,133],
1363  midnightblue: [25,25,112],
1364  mintcream:  [245,255,250],
1365  mistyrose:  [255,228,225],
1366  moccasin: [255,228,181],
1367  navajowhite:  [255,222,173],
1368  navy: [0,0,128],
1369  oldlace:  [253,245,230],
1370  olive:  [128,128,0],
1371  olivedrab:  [107,142,35],
1372  orange: [255,165,0],
1373  orangered:  [255,69,0],
1374  orchid: [218,112,214],
1375  palegoldenrod:  [238,232,170],
1376  palegreen:  [152,251,152],
1377  paleturquoise:  [175,238,238],
1378  palevioletred:  [219,112,147],
1379  papayawhip: [255,239,213],
1380  peachpuff:  [255,218,185],
1381  peru: [205,133,63],
1382  pink: [255,192,203],
1383  plum: [221,160,221],
1384  powderblue: [176,224,230],
1385  purple: [128,0,128],
1386  rebeccapurple: [102, 51, 153],
1387  red:  [255,0,0],
1388  rosybrown:  [188,143,143],
1389  royalblue:  [65,105,225],
1390  saddlebrown:  [139,69,19],
1391  salmon: [250,128,114],
1392  sandybrown: [244,164,96],
1393  seagreen: [46,139,87],
1394  seashell: [255,245,238],
1395  sienna: [160,82,45],
1396  silver: [192,192,192],
1397  skyblue:  [135,206,235],
1398  slateblue:  [106,90,205],
1399  slategray:  [112,128,144],
1400  slategrey:  [112,128,144],
1401  snow: [255,250,250],
1402  springgreen:  [0,255,127],
1403  steelblue:  [70,130,180],
1404  tan:  [210,180,140],
1405  teal: [0,128,128],
1406  thistle:  [216,191,216],
1407  tomato: [255,99,71],
1408  turquoise:  [64,224,208],
1409  violet: [238,130,238],
1410  wheat:  [245,222,179],
1411  white:  [255,255,255],
1412  whitesmoke: [245,245,245],
1413  yellow: [255,255,0],
1414  yellowgreen:  [154,205,50]
1415};
1416
1417var reverseKeywords = {};
1418for (var key in cssKeywords) {
1419  reverseKeywords[JSON.stringify(cssKeywords[key])] = key;
1420}
1421
1422},{}],5:[function(require,module,exports){
1423var conversions = require(4);
1424
1425var convert = function() {
1426   return new Converter();
1427}
1428
1429for (var func in conversions) {
1430  // export Raw versions
1431  convert[func + "Raw"] =  (function(func) {
1432    // accept array or plain args
1433    return function(arg) {
1434      if (typeof arg == "number")
1435        arg = Array.prototype.slice.call(arguments);
1436      return conversions[func](arg);
1437    }
1438  })(func);
1439
1440  var pair = /(\w+)2(\w+)/.exec(func),
1441      from = pair[1],
1442      to = pair[2];
1443
1444  // export rgb2hsl and ["rgb"]["hsl"]
1445  convert[from] = convert[from] || {};
1446
1447  convert[from][to] = convert[func] = (function(func) { 
1448    return function(arg) {
1449      if (typeof arg == "number")
1450        arg = Array.prototype.slice.call(arguments);
1451      
1452      var val = conversions[func](arg);
1453      if (typeof val == "string" || val === undefined)
1454        return val; // keyword
1455
1456      for (var i = 0; i < val.length; i++)
1457        val[i] = Math.round(val[i]);
1458      return val;
1459    }
1460  })(func);
1461}
1462
1463
1464/* Converter does lazy conversion and caching */
1465var Converter = function() {
1466   this.convs = {};
1467};
1468
1469/* Either get the values for a space or
1470  set the values for a space, depending on args */
1471Converter.prototype.routeSpace = function(space, args) {
1472   var values = args[0];
1473   if (values === undefined) {
1474      // color.rgb()
1475      return this.getValues(space);
1476   }
1477   // color.rgb(10, 10, 10)
1478   if (typeof values == "number") {
1479      values = Array.prototype.slice.call(args);        
1480   }
1481
1482   return this.setValues(space, values);
1483};
1484  
1485/* Set the values for a space, invalidating cache */
1486Converter.prototype.setValues = function(space, values) {
1487   this.space = space;
1488   this.convs = {};
1489   this.convs[space] = values;
1490   return this;
1491};
1492
1493/* Get the values for a space. If there's already
1494  a conversion for the space, fetch it, otherwise
1495  compute it */
1496Converter.prototype.getValues = function(space) {
1497   var vals = this.convs[space];
1498   if (!vals) {
1499      var fspace = this.space,
1500          from = this.convs[fspace];
1501      vals = convert[fspace][space](from);
1502
1503      this.convs[space] = vals;
1504   }
1505  return vals;
1506};
1507
1508["rgb", "hsl", "hsv", "cmyk", "keyword"].forEach(function(space) {
1509   Converter.prototype[space] = function(vals) {
1510      return this.routeSpace(space, arguments);
1511   }
1512});
1513
1514module.exports = convert;
1515},{"4":4}],6:[function(require,module,exports){
1516'use strict'
1517
1518module.exports = {
1519	"aliceblue": [240, 248, 255],
1520	"antiquewhite": [250, 235, 215],
1521	"aqua": [0, 255, 255],
1522	"aquamarine": [127, 255, 212],
1523	"azure": [240, 255, 255],
1524	"beige": [245, 245, 220],
1525	"bisque": [255, 228, 196],
1526	"black": [0, 0, 0],
1527	"blanchedalmond": [255, 235, 205],
1528	"blue": [0, 0, 255],
1529	"blueviolet": [138, 43, 226],
1530	"brown": [165, 42, 42],
1531	"burlywood": [222, 184, 135],
1532	"cadetblue": [95, 158, 160],
1533	"chartreuse": [127, 255, 0],
1534	"chocolate": [210, 105, 30],
1535	"coral": [255, 127, 80],
1536	"cornflowerblue": [100, 149, 237],
1537	"cornsilk": [255, 248, 220],
1538	"crimson": [220, 20, 60],
1539	"cyan": [0, 255, 255],
1540	"darkblue": [0, 0, 139],
1541	"darkcyan": [0, 139, 139],
1542	"darkgoldenrod": [184, 134, 11],
1543	"darkgray": [169, 169, 169],
1544	"darkgreen": [0, 100, 0],
1545	"darkgrey": [169, 169, 169],
1546	"darkkhaki": [189, 183, 107],
1547	"darkmagenta": [139, 0, 139],
1548	"darkolivegreen": [85, 107, 47],
1549	"darkorange": [255, 140, 0],
1550	"darkorchid": [153, 50, 204],
1551	"darkred": [139, 0, 0],
1552	"darksalmon": [233, 150, 122],
1553	"darkseagreen": [143, 188, 143],
1554	"darkslateblue": [72, 61, 139],
1555	"darkslategray": [47, 79, 79],
1556	"darkslategrey": [47, 79, 79],
1557	"darkturquoise": [0, 206, 209],
1558	"darkviolet": [148, 0, 211],
1559	"deeppink": [255, 20, 147],
1560	"deepskyblue": [0, 191, 255],
1561	"dimgray": [105, 105, 105],
1562	"dimgrey": [105, 105, 105],
1563	"dodgerblue": [30, 144, 255],
1564	"firebrick": [178, 34, 34],
1565	"floralwhite": [255, 250, 240],
1566	"forestgreen": [34, 139, 34],
1567	"fuchsia": [255, 0, 255],
1568	"gainsboro": [220, 220, 220],
1569	"ghostwhite": [248, 248, 255],
1570	"gold": [255, 215, 0],
1571	"goldenrod": [218, 165, 32],
1572	"gray": [128, 128, 128],
1573	"green": [0, 128, 0],
1574	"greenyellow": [173, 255, 47],
1575	"grey": [128, 128, 128],
1576	"honeydew": [240, 255, 240],
1577	"hotpink": [255, 105, 180],
1578	"indianred": [205, 92, 92],
1579	"indigo": [75, 0, 130],
1580	"ivory": [255, 255, 240],
1581	"khaki": [240, 230, 140],
1582	"lavender": [230, 230, 250],
1583	"lavenderblush": [255, 240, 245],
1584	"lawngreen": [124, 252, 0],
1585	"lemonchiffon": [255, 250, 205],
1586	"lightblue": [173, 216, 230],
1587	"lightcoral": [240, 128, 128],
1588	"lightcyan": [224, 255, 255],
1589	"lightgoldenrodyellow": [250, 250, 210],
1590	"lightgray": [211, 211, 211],
1591	"lightgreen": [144, 238, 144],
1592	"lightgrey": [211, 211, 211],
1593	"lightpink": [255, 182, 193],
1594	"lightsalmon": [255, 160, 122],
1595	"lightseagreen": [32, 178, 170],
1596	"lightskyblue": [135, 206, 250],
1597	"lightslategray": [119, 136, 153],
1598	"lightslategrey": [119, 136, 153],
1599	"lightsteelblue": [176, 196, 222],
1600	"lightyellow": [255, 255, 224],
1601	"lime": [0, 255, 0],
1602	"limegreen": [50, 205, 50],
1603	"linen": [250, 240, 230],
1604	"magenta": [255, 0, 255],
1605	"maroon": [128, 0, 0],
1606	"mediumaquamarine": [102, 205, 170],
1607	"mediumblue": [0, 0, 205],
1608	"mediumorchid": [186, 85, 211],
1609	"mediumpurple": [147, 112, 219],
1610	"mediumseagreen": [60, 179, 113],
1611	"mediumslateblue": [123, 104, 238],
1612	"mediumspringgreen": [0, 250, 154],
1613	"mediumturquoise": [72, 209, 204],
1614	"mediumvioletred": [199, 21, 133],
1615	"midnightblue": [25, 25, 112],
1616	"mintcream": [245, 255, 250],
1617	"mistyrose": [255, 228, 225],
1618	"moccasin": [255, 228, 181],
1619	"navajowhite": [255, 222, 173],
1620	"navy": [0, 0, 128],
1621	"oldlace": [253, 245, 230],
1622	"olive": [128, 128, 0],
1623	"olivedrab": [107, 142, 35],
1624	"orange": [255, 165, 0],
1625	"orangered": [255, 69, 0],
1626	"orchid": [218, 112, 214],
1627	"palegoldenrod": [238, 232, 170],
1628	"palegreen": [152, 251, 152],
1629	"paleturquoise": [175, 238, 238],
1630	"palevioletred": [219, 112, 147],
1631	"papayawhip": [255, 239, 213],
1632	"peachpuff": [255, 218, 185],
1633	"peru": [205, 133, 63],
1634	"pink": [255, 192, 203],
1635	"plum": [221, 160, 221],
1636	"powderblue": [176, 224, 230],
1637	"purple": [128, 0, 128],
1638	"rebeccapurple": [102, 51, 153],
1639	"red": [255, 0, 0],
1640	"rosybrown": [188, 143, 143],
1641	"royalblue": [65, 105, 225],
1642	"saddlebrown": [139, 69, 19],
1643	"salmon": [250, 128, 114],
1644	"sandybrown": [244, 164, 96],
1645	"seagreen": [46, 139, 87],
1646	"seashell": [255, 245, 238],
1647	"sienna": [160, 82, 45],
1648	"silver": [192, 192, 192],
1649	"skyblue": [135, 206, 235],
1650	"slateblue": [106, 90, 205],
1651	"slategray": [112, 128, 144],
1652	"slategrey": [112, 128, 144],
1653	"snow": [255, 250, 250],
1654	"springgreen": [0, 255, 127],
1655	"steelblue": [70, 130, 180],
1656	"tan": [210, 180, 140],
1657	"teal": [0, 128, 128],
1658	"thistle": [216, 191, 216],
1659	"tomato": [255, 99, 71],
1660	"turquoise": [64, 224, 208],
1661	"violet": [238, 130, 238],
1662	"wheat": [245, 222, 179],
1663	"white": [255, 255, 255],
1664	"whitesmoke": [245, 245, 245],
1665	"yellow": [255, 255, 0],
1666	"yellowgreen": [154, 205, 50]
1667};
1668
1669},{}],7:[function(require,module,exports){
1670/**
1671 * @namespace Chart
1672 */
1673var Chart = require(29)();
1674
1675Chart.helpers = require(45);
1676
1677// @todo dispatch these helpers into appropriated helpers/helpers.* file and write unit tests!
1678require(27)(Chart);
1679
1680Chart.defaults = require(25);
1681Chart.Element = require(26);
1682Chart.elements = require(40);
1683Chart.Interaction = require(28);
1684Chart.layouts = require(30);
1685Chart.platform = require(48);
1686Chart.plugins = require(31);
1687Chart.Ticks = require(34);
1688
1689require(22)(Chart);
1690require(23)(Chart);
1691require(24)(Chart);
1692require(33)(Chart);
1693require(32)(Chart);
1694require(35)(Chart);
1695
1696require(55)(Chart);
1697require(53)(Chart);
1698require(54)(Chart);
1699require(56)(Chart);
1700require(57)(Chart);
1701require(58)(Chart);
1702
1703// Controllers must be loaded after elements
1704// See Chart.core.datasetController.dataElementType
1705require(15)(Chart);
1706require(16)(Chart);
1707require(17)(Chart);
1708require(18)(Chart);
1709require(19)(Chart);
1710require(20)(Chart);
1711require(21)(Chart);
1712
1713require(8)(Chart);
1714require(9)(Chart);
1715require(10)(Chart);
1716require(11)(Chart);
1717require(12)(Chart);
1718require(13)(Chart);
1719require(14)(Chart);
1720
1721// Loading built-it plugins
1722var plugins = require(49);
1723for (var k in plugins) {
1724	if (plugins.hasOwnProperty(k)) {
1725		Chart.plugins.register(plugins[k]);
1726	}
1727}
1728
1729Chart.platform.initialize();
1730
1731module.exports = Chart;
1732if (typeof window !== 'undefined') {
1733	window.Chart = Chart;
1734}
1735
1736// DEPRECATIONS
1737
1738/**
1739 * Provided for backward compatibility, not available anymore
1740 * @namespace Chart.Legend
1741 * @deprecated since version 2.1.5
1742 * @todo remove at version 3
1743 * @private
1744 */
1745Chart.Legend = plugins.legend._element;
1746
1747/**
1748 * Provided for backward compatibility, not available anymore
1749 * @namespace Chart.Title
1750 * @deprecated since version 2.1.5
1751 * @todo remove at version 3
1752 * @private
1753 */
1754Chart.Title = plugins.title._element;
1755
1756/**
1757 * Provided for backward compatibility, use Chart.plugins instead
1758 * @namespace Chart.pluginService
1759 * @deprecated since version 2.1.5
1760 * @todo remove at version 3
1761 * @private
1762 */
1763Chart.pluginService = Chart.plugins;
1764
1765/**
1766 * Provided for backward compatibility, inheriting from Chart.PlugingBase has no
1767 * effect, instead simply create/register plugins via plain JavaScript objects.
1768 * @interface Chart.PluginBase
1769 * @deprecated since version 2.5.0
1770 * @todo remove at version 3
1771 * @private
1772 */
1773Chart.PluginBase = Chart.Element.extend({});
1774
1775/**
1776 * Provided for backward compatibility, use Chart.helpers.canvas instead.
1777 * @namespace Chart.canvasHelpers
1778 * @deprecated since version 2.6.0
1779 * @todo remove at version 3
1780 * @private
1781 */
1782Chart.canvasHelpers = Chart.helpers.canvas;
1783
1784/**
1785 * Provided for backward compatibility, use Chart.layouts instead.
1786 * @namespace Chart.layoutService
1787 * @deprecated since version 2.8.0
1788 * @todo remove at version 3
1789 * @private
1790 */
1791Chart.layoutService = Chart.layouts;
1792
1793},{"10":10,"11":11,"12":12,"13":13,"14":14,"15":15,"16":16,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"26":26,"27":27,"28":28,"29":29,"30":30,"31":31,"32":32,"33":33,"34":34,"35":35,"40":40,"45":45,"48":48,"49":49,"53":53,"54":54,"55":55,"56":56,"57":57,"58":58,"8":8,"9":9}],8:[function(require,module,exports){
1794'use strict';
1795
1796module.exports = function(Chart) {
1797
1798	Chart.Bar = function(context, config) {
1799		config.type = 'bar';
1800
1801		return new Chart(context, config);
1802	};
1803
1804};
1805
1806},{}],9:[function(require,module,exports){
1807'use strict';
1808
1809module.exports = function(Chart) {
1810
1811	Chart.Bubble = function(context, config) {
1812		config.type = 'bubble';
1813		return new Chart(context, config);
1814	};
1815
1816};
1817
1818},{}],10:[function(require,module,exports){
1819'use strict';
1820
1821module.exports = function(Chart) {
1822
1823	Chart.Doughnut = function(context, config) {
1824		config.type = 'doughnut';
1825
1826		return new Chart(context, config);
1827	};
1828
1829};
1830
1831},{}],11:[function(require,module,exports){
1832'use strict';
1833
1834module.exports = function(Chart) {
1835
1836	Chart.Line = function(context, config) {
1837		config.type = 'line';
1838
1839		return new Chart(context, config);
1840	};
1841
1842};
1843
1844},{}],12:[function(require,module,exports){
1845'use strict';
1846
1847module.exports = function(Chart) {
1848
1849	Chart.PolarArea = function(context, config) {
1850		config.type = 'polarArea';
1851
1852		return new Chart(context, config);
1853	};
1854
1855};
1856
1857},{}],13:[function(require,module,exports){
1858'use strict';
1859
1860module.exports = function(Chart) {
1861
1862	Chart.Radar = function(context, config) {
1863		config.type = 'radar';
1864
1865		return new Chart(context, config);
1866	};
1867
1868};
1869
1870},{}],14:[function(require,module,exports){
1871'use strict';
1872
1873module.exports = function(Chart) {
1874	Chart.Scatter = function(context, config) {
1875		config.type = 'scatter';
1876		return new Chart(context, config);
1877	};
1878};
1879
1880},{}],15:[function(require,module,exports){
1881'use strict';
1882
1883var defaults = require(25);
1884var elements = require(40);
1885var helpers = require(45);
1886
1887defaults._set('bar', {
1888	hover: {
1889		mode: 'label'
1890	},
1891
1892	scales: {
1893		xAxes: [{
1894			type: 'category',
1895
1896			// Specific to Bar Controller
1897			categoryPercentage: 0.8,
1898			barPercentage: 0.9,
1899
1900			// offset settings
1901			offset: true,
1902
1903			// grid line settings
1904			gridLines: {
1905				offsetGridLines: true
1906			}
1907		}],
1908
1909		yAxes: [{
1910			type: 'linear'
1911		}]
1912	}
1913});
1914
1915defaults._set('horizontalBar', {
1916	hover: {
1917		mode: 'index',
1918		axis: 'y'
1919	},
1920
1921	scales: {
1922		xAxes: [{
1923			type: 'linear',
1924			position: 'bottom'
1925		}],
1926
1927		yAxes: [{
1928			position: 'left',
1929			type: 'category',
1930
1931			// Specific to Horizontal Bar Controller
1932			categoryPercentage: 0.8,
1933			barPercentage: 0.9,
1934
1935			// offset settings
1936			offset: true,
1937
1938			// grid line settings
1939			gridLines: {
1940				offsetGridLines: true
1941			}
1942		}]
1943	},
1944
1945	elements: {
1946		rectangle: {
1947			borderSkipped: 'left'
1948		}
1949	},
1950
1951	tooltips: {
1952		callbacks: {
1953			title: function(item, data) {
1954				// Pick first xLabel for now
1955				var title = '';
1956
1957				if (item.length > 0) {
1958					if (item[0].yLabel) {
1959						title = item[0].yLabel;
1960					} else if (data.labels.length > 0 && item[0].index < data.labels.length) {
1961						title = data.labels[item[0].index];
1962					}
1963				}
1964
1965				return title;
1966			},
1967
1968			label: function(item, data) {
1969				var datasetLabel = data.datasets[item.datasetIndex].label || '';
1970				return datasetLabel + ': ' + item.xLabel;
1971			}
1972		},
1973		mode: 'index',
1974		axis: 'y'
1975	}
1976});
1977
1978/**
1979 * Computes the "optimal" sample size to maintain bars equally sized while preventing overlap.
1980 * @private
1981 */
1982function computeMinSampleSize(scale, pixels) {
1983	var min = scale.isHorizontal() ? scale.width : scale.height;
1984	var ticks = scale.getTicks();
1985	var prev, curr, i, ilen;
1986
1987	for (i = 1, ilen = pixels.length; i < ilen; ++i) {
1988		min = Math.min(min, pixels[i] - pixels[i - 1]);
1989	}
1990
1991	for (i = 0, ilen = ticks.length; i < ilen; ++i) {
1992		curr = scale.getPixelForTick(i);
1993		min = i > 0 ? Math.min(min, curr - prev) : min;
1994		prev = curr;
1995	}
1996
1997	return min;
1998}
1999
2000/**
2001 * Computes an "ideal" category based on the absolute bar thickness or, if undefined or null,
2002 * uses the smallest interval (see computeMinSampleSize) that prevents bar overlapping. This
2003 * mode currently always generates bars equally sized (until we introduce scriptable options?).
2004 * @private
2005 */
2006function computeFitCategoryTraits(index, ruler, options) {
2007	var thickness = options.barThickness;
2008	var count = ruler.stackCount;
2009	var curr = ruler.pixels[index];
2010	var size, ratio;
2011
2012	if (helpers.isNullOrUndef(thickness)) {
2013		size = ruler.min * options.categoryPercentage;
2014		ratio = options.barPercentage;
2015	} else {
2016		// When bar thickness is enforced, category and bar percentages are ignored.
2017		// Note(SB): we could add support for relative bar thickness (e.g. barThickness: '50%')
2018		// and deprecate barPercentage since this value is ignored when thickness is absolute.
2019		size = thickness * count;
2020		ratio = 1;
2021	}
2022
2023	return {
2024		chunk: size / count,
2025		ratio: ratio,
2026		start: curr - (size / 2)
2027	};
2028}
2029
2030/**
2031 * Computes an "optimal" category that globally arranges bars side by side (no gap when
2032 * percentage options are 1), based on the previous and following categories. This mode
2033 * generates bars with different widths when data are not evenly spaced.
2034 * @private
2035 */
2036function computeFlexCategoryTraits(index, ruler, options) {
2037	var pixels = ruler.pixels;
2038	var curr = pixels[index];
2039	var prev = index > 0 ? pixels[index - 1] : null;
2040	var next = index < pixels.length - 1 ? pixels[index + 1] : null;
2041	var percent = options.categoryPercentage;
2042	var start, size;
2043
2044	if (prev === null) {
2045		// first data: its size is double based on the next point or,
2046		// if it's also the last data, we use the scale end extremity.
2047		prev = curr - (next === null ? ruler.end - curr : next - curr);
2048	}
2049
2050	if (next === null) {
2051		// last data: its size is also double based on the previous point.
2052		next = curr + curr - prev;
2053	}
2054
2055	start = curr - ((curr - prev) / 2) * percent;
2056	size = ((next - prev) / 2) * percent;
2057
2058	return {
2059		chunk: size / ruler.stackCount,
2060		ratio: options.barPercentage,
2061		start: start
2062	};
2063}
2064
2065module.exports = function(Chart) {
2066
2067	Chart.controllers.bar = Chart.DatasetController.extend({
2068
2069		dataElementType: elements.Rectangle,
2070
2071		initialize: function() {
2072			var me = this;
2073			var meta;
2074
2075			Chart.DatasetController.prototype.initialize.apply(me, arguments);
2076
2077			meta = me.getMeta();
2078			meta.stack = me.getDataset().stack;
2079			meta.bar = true;
2080		},
2081
2082		update: function(reset) {
2083			var me = this;
2084			var rects = me.getMeta().data;
2085			var i, ilen;
2086
2087			me._ruler = me.getRuler();
2088
2089			for (i = 0, ilen = rects.length; i < ilen; ++i) {
2090				me.updateElement(rects[i], i, reset);
2091			}
2092		},
2093
2094		updateElement: function(rectangle, index, reset) {
2095			var me = this;
2096			var chart = me.chart;
2097			var meta = me.getMeta();
2098			var dataset = me.getDataset();
2099			var custom = rectangle.custom || {};
2100			var rectangleOptions = chart.options.elements.rectangle;
2101
2102			rectangle._xScale = me.getScaleForId(meta.xAxisID);
2103			rectangle._yScale = me.getScaleForId(meta.yAxisID);
2104			rectangle._datasetIndex = me.index;
2105			rectangle._index = index;
2106
2107			rectangle._model = {
2108				datasetLabel: dataset.label,
2109				label: chart.data.labels[index],
2110				borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleOptions.borderSkipped,
2111				backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleOptions.backgroundColor),
2112				borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleOptions.borderColor),
2113				borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleOptions.borderWidth)
2114			};
2115
2116			me.updateElementGeometry(rectangle, index, reset);
2117
2118			rectangle.pivot();
2119		},
2120
2121		/**
2122		 * @private
2123		 */
2124		updateElementGeometry: function(rectangle, index, reset) {
2125			var me = this;
2126			var model = rectangle._model;
2127			var vscale = me.getValueScale();
2128			var base = vscale.getBasePixel();
2129			var horizontal = vscale.isHorizontal();
2130			var ruler = me._ruler || me.getRuler();
2131			var vpixels = me.calculateBarValuePixels(me.index, index);
2132			var ipixels = me.calculateBarIndexPixels(me.index, index, ruler);
2133
2134			model.horizontal = horizontal;
2135			model.base = reset ? base : vpixels.base;
2136			model.x = horizontal ? reset ? base : vpixels.head : ipixels.center;
2137			model.y = horizontal ? ipixels.center : reset ? base : vpixels.head;
2138			model.height = horizontal ? ipixels.size : undefined;
2139			model.width = horizontal ? undefined : ipixels.size;
2140		},
2141
2142		/**
2143		 * @private
2144		 */
2145		getValueScaleId: function() {
2146			return this.getMeta().yAxisID;
2147		},
2148
2149		/**
2150		 * @private
2151		 */
2152		getIndexScaleId: function() {
2153			return this.getMeta().xAxisID;
2154		},
2155
2156		/**
2157		 * @private
2158		 */
2159		getValueScale: function() {
2160			return this.getScaleForId(this.getValueScaleId());
2161		},
2162
2163		/**
2164		 * @private
2165		 */
2166		getIndexScale: function() {
2167			return this.getScaleForId(this.getIndexScaleId());
2168		},
2169
2170		/**
2171		 * Returns the stacks based on groups and bar visibility.
2172		 * @param {Number} [last] - The dataset index
2173		 * @returns {Array} The stack list
2174		 * @private
2175		 */
2176		_getStacks: function(last) {
2177			var me = this;
2178			var chart = me.chart;
2179			var scale = me.getIndexScale();
2180			var stacked = scale.options.stacked;
2181			var ilen = last === undefined ? chart.data.datasets.length : last + 1;
2182			var stacks = [];
2183			var i, meta;
2184
2185			for (i = 0; i < ilen; ++i) {
2186				meta = chart.getDatasetMeta(i);
2187				if (meta.bar && chart.isDatasetVisible(i) &&
2188					(stacked === false ||
2189					(stacked === true && stacks.indexOf(meta.stack) === -1) ||
2190					(stacked === undefined && (meta.stack === undefined || stacks.indexOf(meta.stack) === -1)))) {
2191					stacks.push(meta.stack);
2192				}
2193			}
2194
2195			return stacks;
2196		},
2197
2198		/**
2199		 * Returns the effective number of stacks based on groups and bar visibility.
2200		 * @private
2201		 */
2202		getStackCount: function() {
2203			return this._getStacks().length;
2204		},
2205
2206		/**
2207		 * Returns the stack index for the given dataset based on groups and bar visibility.
2208		 * @param {Number} [datasetIndex] - The dataset index
2209		 * @param {String} [name] - The stack name to find
2210		 * @returns {Number} The stack index
2211		 * @private
2212		 */
2213		getStackIndex: function(datasetIndex, name) {
2214			var stacks = this._getStacks(datasetIndex);
2215			var index = (name !== undefined)
2216				? stacks.indexOf(name)
2217				: -1; // indexOf returns -1 if element is not present
2218
2219			return (index === -1)
2220				? stacks.length - 1
2221				: index;
2222		},
2223
2224		/**
2225		 * @private
2226		 */
2227		getRuler: function() {
2228			var me = this;
2229			var scale = me.getIndexScale();
2230			var stackCount = me.getStackCount();
2231			var datasetIndex = me.index;
2232			var isHorizontal = scale.isHorizontal();
2233			var start = isHorizontal ? scale.left : scale.top;
2234			var end = start + (isHorizontal ? scale.width : scale.height);
2235			var pixels = [];
2236			var i, ilen, min;
2237
2238			for (i = 0, ilen = me.getMeta().data.length; i < ilen; ++i) {
2239				pixels.push(scale.getPixelForValue(null, i, datasetIndex));
2240			}
2241
2242			min = helpers.isNullOrUndef(scale.options.barThickness)
2243				? computeMinSampleSize(scale, pixels)
2244				: -1;
2245
2246			return {
2247				min: min,
2248				pixels: pixels,
2249				start: start,
2250				end: end,
2251				stackCount: stackCount,
2252				scale: scale
2253			};
2254		},
2255
2256		/**
2257		 * Note: pixel values are not clamped to the scale area.
2258		 * @private
2259		 */
2260		calculateBarValuePixels: function(datasetIndex, index) {
2261			var me = this;
2262			var chart = me.chart;
2263			var meta = me.getMeta();
2264			var scale = me.getValueScale();
2265			var datasets = chart.data.datasets;
2266			var value = scale.getRightValue(datasets[datasetIndex].data[index]);
2267			var stacked = scale.options.stacked;
2268			var stack = meta.stack;
2269			var start = 0;
2270			var i, imeta, ivalue, base, head, size;
2271
2272			if (stacked || (stacked === undefined && stack !== undefined)) {
2273				for (i = 0; i < datasetIndex; ++i) {
2274					imeta = chart.getDatasetMeta(i);
2275
2276					if (imeta.bar &&
2277						imeta.stack === stack &&
2278						imeta.controller.getValueScaleId() === scale.id &&
2279						chart.isDatasetVisible(i)) {
2280
2281						ivalue = scale.getRightValue(datasets[i].data[index]);
2282						if ((value < 0 && ivalue < 0) || (value >= 0 && ivalue > 0)) {
2283							start += ivalue;
2284						}
2285					}
2286				}
2287			}
2288
2289			base = scale.getPixelForValue(start);
2290			head = scale.getPixelForValue(start + value);
2291			size = (head - base) / 2;
2292
2293			return {
2294				size: size,
2295				base: base,
2296				head: head,
2297				center: head + size / 2
2298			};
2299		},
2300
2301		/**
2302		 * @private
2303		 */
2304		calculateBarIndexPixels: function(datasetIndex, index, ruler) {
2305			var me = this;
2306			var options = ruler.scale.options;
2307			var range = options.barThickness === 'flex'
2308				? computeFlexCategoryTraits(index, ruler, options)
2309				: computeFitCategoryTraits(index, ruler, options);
2310
2311			var stackIndex = me.getStackIndex(datasetIndex, me.getMeta().stack);
2312			var center = range.start + (range.chunk * stackIndex) + (range.chunk / 2);
2313			var size = Math.min(
2314				helpers.valueOrDefault(options.maxBarThickness, Infinity),
2315				range.chunk * range.ratio);
2316
2317			return {
2318				base: center - size / 2,
2319				head: center + size / 2,
2320				center: center,
2321				size: size
2322			};
2323		},
2324
2325		draw: function() {
2326			var me = this;
2327			var chart = me.chart;
2328			var scale = me.getValueScale();
2329			var rects = me.getMeta().data;
2330			var dataset = me.getDataset();
2331			var ilen = rects.length;
2332			var i = 0;
2333
2334			helpers.canvas.clipArea(chart.ctx, chart.chartArea);
2335
2336			for (; i < ilen; ++i) {
2337				if (!isNaN(scale.getRightValue(dataset.data[i]))) {
2338					rects[i].draw();
2339				}
2340			}
2341
2342			helpers.canvas.unclipArea(chart.ctx);
2343		},
2344
2345		setHoverStyle: function(rectangle) {
2346			var dataset = this.chart.data.datasets[rectangle._datasetIndex];
2347			var index = rectangle._index;
2348			var custom = rectangle.custom || {};
2349			var model = rectangle._model;
2350
vendor: 4,267 bytes, lines 2351-2492
2351			model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
2352			model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.getHoverColor(model.borderColor));
2353			model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
2354		},
2355
2356		removeHoverStyle: function(rectangle) {
2357			var dataset = this.chart.data.datasets[rectangle._datasetIndex];
2358			var index = rectangle._index;
2359			var custom = rectangle.custom || {};
2360			var model = rectangle._model;
2361			var rectangleElementOptions = this.chart.options.elements.rectangle;
2362
2363			model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor);
2364			model.borderColor = custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor);
2365			model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleElementOptions.borderWidth);
2366		}
2367	});
2368
2369	Chart.controllers.horizontalBar = Chart.controllers.bar.extend({
2370		/**
2371		 * @private
2372		 */
2373		getValueScaleId: function() {
2374			return this.getMeta().xAxisID;
2375		},
2376
2377		/**
2378		 * @private
2379		 */
2380		getIndexScaleId: function() {
2381			return this.getMeta().yAxisID;
2382		}
2383	});
2384};
2385
2386},{"25":25,"40":40,"45":45}],16:[function(require,module,exports){
2387'use strict';
2388
2389var defaults = require(25);
2390var elements = require(40);
2391var helpers = require(45);
2392
2393defaults._set('bubble', {
2394	hover: {
2395		mode: 'single'
2396	},
2397
2398	scales: {
2399		xAxes: [{
2400			type: 'linear', // bubble should probably use a linear scale by default
2401			position: 'bottom',
2402			id: 'x-axis-0' // need an ID so datasets can reference the scale
2403		}],
2404		yAxes: [{
2405			type: 'linear',
2406			position: 'left',
2407			id: 'y-axis-0'
2408		}]
2409	},
2410
2411	tooltips: {
2412		callbacks: {
2413			title: function() {
2414				// Title doesn't make sense for scatter since we format the data as a point
2415				return '';
2416			},
2417			label: function(item, data) {
2418				var datasetLabel = data.datasets[item.datasetIndex].label || '';
2419				var dataPoint = data.datasets[item.datasetIndex].data[item.index];
2420				return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' + dataPoint.r + ')';
2421			}
2422		}
2423	}
2424});
2425
2426
2427module.exports = function(Chart) {
2428
2429	Chart.controllers.bubble = Chart.DatasetController.extend({
2430		/**
2431		 * @protected
2432		 */
2433		dataElementType: elements.Point,
2434
2435		/**
2436		 * @protected
2437		 */
2438		update: function(reset) {
2439			var me = this;
2440			var meta = me.getMeta();
2441			var points = meta.data;
2442
2443			// Update Points
2444			helpers.each(points, function(point, index) {
2445				me.updateElement(point, index, reset);
2446			});
2447		},
2448
2449		/**
2450		 * @protected
2451		 */
2452		updateElement: function(point, index, reset) {
2453			var me = this;
2454			var meta = me.getMeta();
2455			var custom = point.custom || {};
2456			var xScale = me.getScaleForId(meta.xAxisID);
2457			var yScale = me.getScaleForId(meta.yAxisID);
2458			var options = me._resolveElementOptions(point, index);
2459			var data = me.getDataset().data[index];
2460			var dsIndex = me.index;
2461
2462			var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex);
2463			var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex);
2464
2465			point._xScale = xScale;
2466			point._yScale = yScale;
2467			point._options = options;
2468			point._datasetIndex = dsIndex;
2469			point._index = index;
2470			point._model = {
2471				backgroundColor: options.backgroundColor,
2472				borderColor: options.borderColor,
2473				borderWidth: options.borderWidth,
2474				hitRadius: options.hitRadius,
2475				pointStyle: options.pointStyle,
2476				radius: reset ? 0 : options.radius,
2477				skip: custom.skip || isNaN(x) || isNaN(y),
2478				x: x,
2479				y: y,
2480			};
2481
2482			point.pivot();
2483		},
2484
2485		/**
2486		 * @protected
2487		 */
2488		setHoverStyle: function(point) {
2489			var model = point._model;
2490			var options = point._options;
2491
2492			model.backgroundColor = helpers.valueOrDefault(options.hoverBackgroun
2492dColor, helpers.getHoverColor(options.backgroundColor));
2493			model.borderColor = helpers.valueOrDefault(options.hoverBorderColor, helpers.getHoverColor(options.borderColor));
2494			model.borderWidth = helpers.valueOrDefault(options.hoverBorderWidth, options.borderWidth);
2495			model.radius = options.radius + options.hoverRadius;
2496		},
2497
2498		/**
2499		 * @protected
2500		 */
2501		removeHoverStyle: function(point) {
2502			var model = point._model;
2503			var options = point._options;
2504
2505			model.backgroundColor = options.backgroundColor;
2506			model.borderColor = options.borderColor;
2507			model.borderWidth = options.borderWidth;
2508			model.radius = options.radius;
2509		},
2510
2511		/**
2512		 * @private
2513		 */
2514		_resolveElementOptions: function(point, index) {
2515			var me = this;
2516			var chart = me.chart;
2517			var datasets = chart.data.datasets;
2518			var dataset = datasets[me.index];
2519			var custom = point.custom || {};
2520			var options = chart.options.elements.point;
2521			var resolve = helpers.options.resolve;
2522			var data = dataset.data[index];
2523			var values = {};
2524			var i, ilen, key;
2525
2526			// Scriptable options
2527			var context = {
2528				chart: chart,
2529				dataIndex: index,
2530				dataset: dataset,
2531				datasetIndex: me.index
2532			};
2533
2534			var keys = [
2535				'backgroundColor',
2536				'borderColor',
2537				'borderWidth',
2538				'hoverBackgroundColor',
2539				'hoverBorderColor',
2540				'hoverBorderWidth',
2541				'hoverRadius',
2542				'hitRadius',
2543				'pointStyle'
2544			];
2545
2546			for (i = 0, ilen = keys.length; i < ilen; ++i) {
2547				key = keys[i];
2548				values[key] = resolve([
2549					custom[key],
2550					dataset[key],
2551					options[key]
2552				], context, index);
2553			}
2554
2555			// Custom radius resolution
2556			values.radius = resolve([
2557				custom.radius,
2558				data ? data.r : undefined,
2559				dataset.radius,
2560				options.radius
2561			], context, index);
2562
2563			return values;
2564		}
2565	});
2566};
2567
2568},{"25":25,"40":40,"45":45}],17:[function(require,module,exports){
2569'use strict';
2570
2571var defaults = require(25);
2572var elements = require(40);
2573var helpers = require(45);
2574
2575defaults._set('doughnut', {
2576	animation: {
2577		// Boolean - Whether we animate the rotation of the Doughnut
2578		animateRotate: true,
2579		// Boolean - Whether we animate scaling the Doughnut from the centre
2580		animateScale: false
2581	},
2582	hover: {
2583		mode: 'single'
2584	},
2585	legendCallback: function(chart) {
2586		var text = [];
2587		text.push('<ul class="' + chart.id + '-legend">');
2588
2589		var data = chart.data;
2590		var datasets = data.datasets;
2591		var labels = data.labels;
2592
2593		if (datasets.length) {
2594			for (var i = 0; i < datasets[0].data.length; ++i) {
2595				text.push('<li><span style="background-color:' + datasets[0].backgroundColor[i] + '"></span>');
2596				if (labels[i]) {
2597					text.push(labels[i]);
2598				}
2599				text.push('</li>');
2600			}
2601		}
2602
2603		text.push('</ul>');
2604		return text.join('');
2605	},
2606	legend: {
2607		labels: {
2608			generateLabels: function(chart) {
2609				var data = chart.data;
2610				if (data.labels.length && data.datasets.length) {
2611					return data.labels.map(function(label, i) {
2612						var meta = chart.getDatasetMeta(0);
2613						var ds = data.datasets[0];
2614						var arc = meta.data[i];
2615						var custom = arc && arc.custom || {};
2616						var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
2617						var arcOpts = chart.options.elements.arc;
2618						var fill = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
2619						var stroke = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
2620						var bw = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
2621
2622						return {
2623							text: label,
2624							fillStyle: fill,
2625							strokeStyle: stroke,
2626							lineWidth: bw,
2627							hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
2628
2629							// Extra data used for toggling the correct item
2630							index: i
2631						};
2632					});
2633				}
2634				return [];
2635			}
2636		},
2637
2638		onClick: function(e, legendItem) {
2639			var index = legendItem.index;
2640			var chart = this.chart;
2641			var i, ilen, meta;
2642
2643			for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
2644				meta = chart.getDatasetMeta(i);
2645				// toggle visibility of index if exists
2646				if (meta.data[index]) {
2647					meta.data[index].hidden = !meta.data[index].hidden;
2648				}
2649			}
2650
2651			chart.update();
2652		}
2653	},
2654
2655	// The percentage of the chart that we cut out of the middle.
2656	cutoutPercentage: 50,
2657
2658	// The rotation of the chart, where the first data arc begins.
2659	rotation: Math.PI * -0.5,
2660
2661	// The total circumference of the chart.
2662	circumference: Math.PI * 2.0,
2663
2664	// Need to override these to give a nice default
2665	tooltips: {
2666		callbacks: {
2667			title: function() {
2668				return '';
2669			},
2670			label: function(tooltipItem, data) {
2671				var dataLabel = data.labels[tooltipItem.index];
2672				var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
2673
2674				if (helpers.isArray(dataLabel)) {
2675					// show value on first line of multiline label
2676					// need to clone because we are changing the value
2677					dataLabel = dataLabel.slice();
2678					dataLabel[0] += value;
2679				} else {
2680					dataLabel += value;
2681				}
2682
2683				return dataLabel;
2684			}
2685		}
2686	}
2687});
2688
2689defaults._set('pie', helpers.clone(defaults.doughnut));
2690defaults._set('pie', {
2691	cutoutPercentage: 0
2692});
2693
2694module.exports = function(Chart) {
2695
2696	Chart.controllers.doughnut = Chart.controllers.pie = Chart.DatasetController.extend({
2697
2698		dataElementType: elements.Arc,
2699
2700		linkScales: helpers.noop,
2701
2702		// Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
2703		getRingIndex: function(datasetIndex) {
2704			var ringIndex = 0;
2705
2706			for (var j = 0; j < datasetIndex; ++j) {
2707				if (this.chart.isDatasetVisible(j)) {
2708					++ringIndex;
2709				}
2710			}
2711
2712			return ringIndex;
2713		},
2714
2715		update: function(reset) {
2716			var me = this;
2717			var chart = me.chart;
2718			var chartArea = chart.chartArea;
2719			var opts = chart.options;
2720			var arcOpts = opts.elements.arc;
2721			var availableWidth = chartArea.right - chartArea.left - arcOpts.borderWidth;
2722			var availableHeight = chartArea.bottom - chartArea.top - arcOpts.borderWidth;
2723			var minSize = Math.min(availableWidth, availableHeight);
2724			var offset = {x: 0, y: 0};
2725			var meta = me.getMeta();
2726			var cutoutPercentage = opts.cutoutPercentage;
2727			var circumference = opts.circumference;
2728
2729			// If the chart's circumference isn't a full circle, calculate minSize as a ratio of the width/height of the arc
2730			if (circumference < Math.PI * 2.0) {
2731				var startAngle = opts.rotation % (Math.PI * 2.0);
2732				startAngle += Math.PI * 2.0 * (startAngle >= Math.PI ? -1 : startAngle < -Math.PI ? 1 : 0);
2733				var endAngle = startAngle + circumference;
2734				var start = {x: Math.cos(startAngle), y: Math.sin(startAngle)};
2735				var end = {x: Math.cos(endAngle), y: Math.sin(endAngle)};
2736				var contains0 = (startAngle <= 0 && endAngle >= 0) || (startAngle <= Math.PI * 2.0 && Math.PI * 2.0 <= endAngle);
2737				var contains90 = (startAngle <= Math.PI * 0.5 && Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 2.5 && Math.PI * 2.5 <= endAngle);
2738				var contains180 = (startAngle <= -Math.PI && -Math.PI <= endAngle) || (startAngle <= Math.PI && Math.PI <= endAngle);
2739				var contains270 = (startAngle <= -Math.PI * 0.5 && -Math.PI * 0.5 <= endAngle) || (startAngle <= Math.PI * 1.5 && Math.PI * 1.5 <= endAngle);
2740				var cutout = cutoutPercentage / 100.0;
2741				var min = {x: contains180 ? -1 : Math.min(start.x * (start.x < 0 ? 1 : cutout), end.x * (end.x < 0 ? 1 : cutout)), y: contains270 ? -1 : Math.min(start.y * (start.y < 0 ? 1 : cutout), end.y * (end.y < 0 ? 1 : cutout))};
2742				var max = {x: contains0 ? 1 : Math.max(start.x * (start.x > 0 ? 1 : cutout), end.x * (end.x > 0 ? 1 : cutout)), y: contains90 ? 1 : Math.max(start.y * (start.y > 0 ? 1 : cutout), end.y * (end.y > 0 ? 1 : cutout))};
2743				var size = {width: (max.x - min.x) * 0.5, height: (max.y - min.y) * 0.5};
2744				minSize = Math.min(availableWidth / size.width, availableHeight / size.height);
2745				offset = {x: (max.x + min.x) * -0.5, y: (max.y + min.y) * -0.5};
2746			}
2747
2748			chart.borderWidth = me.getMaxBorderWidth(meta.data);
2749			chart.outerRadius = Math.max((minSize - chart.borderWidth) / 2, 0);
2750			chart.innerRadius = Math.max(cutoutPercentage ? (chart.outerRadius / 100) * (cutoutPercentage) : 0, 0);
2751			chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
2752			chart.offsetX = offset.x * chart.outerRadius;
2753			chart.offsetY = offset.y * chart.outerRadius;
2754
2755			meta.total = me.calculateTotal();
2756
2757			me.outerRadius = chart.outerRadius - (chart.radiusLength * me.getRingIndex(me.index));
2758			me.innerRadius = Math.max(me.outerRadius - chart.radiusLength, 0);
2759
2760			helpers.each(meta.data, function(arc, index) {
2761				me.updateElement(arc, index, reset);
2762			});
2763		},
2764
2765		updateElement: function(arc, index, reset) {
2766			var me = this;
2767			var chart = me.chart;
2768			var chartArea = chart.chartArea;
2769			var opts = chart.options;
2770			var animationOpts = opts.animation;
2771			var centerX = (chartArea.left + chartArea.right) / 2;
2772			var centerY = (chartArea.top + chartArea.bottom) / 2;
2773			var startAngle = opts.rotation; // non reset case handled later
2774			var endAngle = opts.rotation; // non reset case handled later
2775			var dataset = me.getDataset();
2776			var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumference / (2.0 * Math.PI));
2777			var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius;
2778			var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius;
2779			var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
2780
2781			helpers.extend(arc, {
2782				// Utility
2783				_datasetIndex: me.index,
2784				_index: index,
2785
2786				// Desired view properties
2787				_model: {
2788					x: centerX + chart.offsetX,
2789					y: centerY + chart.offsetY,
2790					startAngle: startAngle,
2791					endAngle: endAngle,
2792					circumference: circumference,
2793					outerRadius: outerRadius,
2794					innerRadius: innerRadius,
2795					label: valueAtIndexOrDefault(dataset.label, index, chart.data.labels[index])
2796				}
2797			});
2798
2799			var model = arc._model;
2800			// Resets the visual styles
2801			this.removeHoverStyle(arc);
2802
2803			// Set correct angles if not resetting
2804			if (!reset || !animationOpts.animateRotate) {
2805				if (index === 0) {
2806					model.startAngle = opts.rotation;
2807				} else {
2808					model.startAngle = me.getMeta().data[index - 1]._model.endAngle;
2809				}
2810
2811				model.endAngle = model.startAngle + model.circumference;
2812			}
2813
2814			arc.pivot();
2815		},
2816
2817		removeHoverStyle: function(arc) {
2818			Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc);
2819		},
2820
2821		calculateTotal: function() {
2822			var dataset = this.getDataset();
2823			var meta = this.getMeta();
2824			var total = 0;
2825			var value;
2826
2827			helpers.each(meta.data, function(element, index) {
2828				value = dataset.data[index];
2829				if (!isNaN(value) && !element.hidden) {
2830					total += Math.abs(value);
2831				}
2832			});
2833
2834			/* if (total === 0) {
2835				total = NaN;
2836			}*/
2837
2838			return total;
2839		},
2840
2841		calculateCircumference: function(value) {
2842			var total = this.getMeta().total;
2843			if (total > 0 && !isNaN(value)) {
2844				return (Math.PI * 2.0) * (Math.abs(value) / total);
2845			}
2846			return 0;
2847		},
2848
2849		// gets the max border or hover width to properly scale pie charts
2850		getMaxBorderWidth: function(arcs) {
2851			var max = 0;
2852			var index = this.index;
2853			var length = arcs.length;
2854			var borderWidth;
2855			var hoverWidth;
2856
2857			for (var i = 0; i < length; i++) {
2858				borderWidth = arcs[i]._model ? arcs[i]._model.borderWidth : 0;
2859				hoverWidth = arcs[i]._chart ? arcs[i]._chart.config.data.datasets[index].hoverBorderWidth : 0;
2860
2861				max = borderWidth > max ? borderWidth : max;
2862				max = hoverWidth > max ? hoverWidth : max;
2863			}
2864			return max;
2865		}
2866	});
2867};
2868
2869},{"25":25,"40":40,"45":45}],18:[function(require,module,exports){
2870'use strict';
2871
2872var defaults = require(25);
2873var elements = require(40);
2874var helpers = require(45);
2875
2876defaults._set('line', {
2877	showLines: true,
2878	spanGaps: false,
2879
2880	hover: {
2881		mode: 'label'
2882	},
2883
2884	scales: {
2885		xAxes: [{
2886			type: 'category',
2887			id: 'x-axis-0'
2888		}],
2889		yAxes: [{
2890			type: 'linear',
2891			id: 'y-axis-0'
2892		}]
2893	}
2894});
2895
2896module.exports = function(Chart) {
2897
2898	function lineEnabled(dataset, options) {
2899		return helpers.valueOrDefault(dataset.showLine, options.showLines);
2900	}
2901
2902	Chart.controllers.line = Chart.DatasetController.extend({
2903
2904		datasetElementType: elements.Line,
2905
2906		dataElementType: elements.Point,
2907
2908		update: function(reset) {
2909			var me = this;
2910			var meta = me.getMeta();
2911			var line = meta.dataset;
2912			var points = meta.data || [];
2913			var options = me.chart.options;
2914			var lineElementOptions = options.elements.line;
2915			var scale = me.getScaleForId(meta.yAxisID);
2916			var i, ilen, custom;
2917			var dataset = me.getDataset();
2918			var showLine = lineEnabled(dataset, options);
2919
2920			// Update Line
2921			if (showLine) {
2922				custom = line.custom || {};
2923
2924				// Compatibility: If the properties are defined with only the old name, use those values
2925				if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
2926					dataset.lineTension = dataset.tension;
2927				}
2928
2929				// Utility
2930				line._scale = scale;
2931				line._datasetIndex = me.index;
2932				// Data
2933				line._children = points;
2934				// Model
2935				line._model = {
2936					// Appearance
2937					// The default behavior of lines is to break at null values, according
2938					// to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
2939					// This option gives lines the ability to span gaps
2940					spanGaps: dataset.spanGaps ? dataset.spanGaps : options.spanGaps,
2941					tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
2942					backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
2943					borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
2944					borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
2945					borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle),
2946					borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash),
2947					borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset),
2948					borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle),
2949					fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill),
2950					steppedLine: custom.steppedLine ? custom.steppedLine : helpers.valueOrDefault(dataset.steppedLine, lineElementOptions.stepped),
2951					cubicInterpolationMode: custom.cubicInterpolationMode ? custom.cubicInterpolationMode : helpers.valueOrDefault(dataset.cubicInterpolationMode, lineElementOptions.cubicInterpolationMode),
2952				};
2953
2954				line.pivot();
2955			}
2956
2957			// Update Points
2958			for (i = 0, ilen = points.length; i < ilen; ++i) {
2959				me.updateElement(points[i], i, reset);
2960			}
2961
2962			if (showLine && line._model.tension !== 0) {
2963				me.updateBezierControlPoints();
2964			}
2965
2966			// Now pivot the point for animation
2967			for (i = 0, ilen = points.length; i < ilen; ++i) {
2968				points[i].pivot();
2969			}
2970		},
2971
2972		getPointBackgroundColor: function(point, index) {
2973			var backgroundColor = this.chart.options.elements.point.backgroundColor;
2974			var dataset = this.getDataset();
2975			var custom = point.custom || {};
2976
2977			if (custom.backgroundColor) {
2978				backgroundColor = custom.backgroundColor;
2979			}
2979 else if (dataset.pointBackgroundColor) {
2980				backgroundColor = helpers.valueAtIndexOrDefault(dataset.pointBackgroundColor, index, backgroundColor);
2981			} else if (dataset.backgroundColor) {
2982				backgroundColor = dataset.backgroundColor;
2983			}
2984
2985			return backgroundColor;
2986		},
2987
2988		getPointBorderColor: function(point, index) {
2989			var borderColor = this.chart.options.elements.point.borderColor;
2990			var dataset = this.getDataset();
2991			var custom = point.custom || {};
2992
2993			if (custom.borderColor) {
2994				borderColor = custom.borderColor;
2995			} else if (dataset.pointBorderColor) {
2996				borderColor = helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, borderColor);
2997			} else if (dataset.borderColor) {
2998				borderColor = dataset.borderColor;
2999			}
3000
3001			return borderColor;
3002		},
3003
3004		getPointBorderWidth: function(point, index) {
3005			var borderWidth = this.chart.options.elements.point.borderWidth;
3006			var dataset = this.getDataset();
3007			var custom = point.custom || {};
3008
3009			if (!isNaN(custom.borderWidth)) {
3010				borderWidth = custom.borderWidth;
3011			} else if (!isNaN(dataset.pointBorderWidth) || helpers.isArray(dataset.pointBorderWidth)) {
3012				borderWidth = helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, borderWidth);
3013			} else if (!isNaN(dataset.borderWidth)) {
3014				borderWidth = dataset.borderWidth;
3015			}
3016
3017			return borderWidth;
3018		},
3019
3020		updateElement: function(point, index, reset) {
3021			var me = this;
3022			var meta = me.getMeta();
3023			var custom = point.custom || {};
3024			var dataset = me.getDataset();
3025			var datasetIndex = me.index;
3026			var value = dataset.data[index];
3027			var yScale = me.getScaleForId(meta.yAxisID);
3028			var xScale = me.getScaleForId(meta.xAxisID);
3029			var pointOptions = me.chart.options.elements.point;
3030			var x, y;
3031
3032			// Compatibility: If the properties are defined with only the old name, use those values
3033			if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
3034				dataset.pointRadius = dataset.radius;
3035			}
3036			if ((dataset.hitRadius !== undefined) && (dataset.pointHitRadius === undefined)) {
3037				dataset.pointHitRadius = dataset.hitRadius;
3038			}
3039
3040			x = xScale.getPixelForValue(typeof value === 'object' ? value : NaN, index, datasetIndex);
3041			y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex);
3042
3043			// Utility
3044			point._xScale = xScale;
3045			point._yScale = yScale;
3046			point._datasetIndex = datasetIndex;
3047			point._index = index;
3048
3049			// Desired view properties
3050			point._model = {
3051				x: x,
3052				y: y,
3053				skip: custom.skip || isNaN(x) || isNaN(y),
3054				// Appearance
3055				radius: custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointOptions.radius),
3056				pointStyle: custom.pointStyle || helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointOptions.pointStyle),
3057				backgroundColor: me.getPointBackgroundColor(point, index),
3058				borderColor: me.getPointBorderColor(point, index),
3059				borderWidth: me.getPointBorderWidth(point, index),
3060				tension: meta.dataset._model ? meta.dataset._model.tension : 0,
3061				steppedLine: meta.dataset._model ? meta.dataset._model.steppedLine : false,
3062				// Tooltip
3063				hitRadius: custom.hitRadius || helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointOptions.hitRadius)
3064			};
3065		},
3066
3067		calculatePointY: function(value, index, datasetIndex) {
3068			var me = this;
3069			var chart = me.chart;
3070			var meta = me.getMeta();
3071			var yScale = me.getScaleForId(meta.yAxisID);
3072			var sumPos = 0;
3073			var sumNeg = 0;
3074			var i, ds, dsMeta;
3075
3076			if (yScale.options.stacked) {
3077				for (i = 0; i < datasetIndex; i++) {
3078					ds = chart.data.datasets[i];
3079					dsMeta = chart.getDatasetMeta(i);
3080					if (dsMeta.type === 'line' && dsMeta.yAxisID === yScale.id && chart.isDatasetVisible(i)) {
3081						var stackedRightValue = Number(yScale.getRightValue(ds.data[index]));
3082						if (stackedRightValue < 0) {
3083							sumNeg += stackedRightValue || 0;
3084						} else {
3085							sumPos += stackedRightValue || 0;
3086						}
3087					}
3088				}
3089
3090				var rightValue = Number(yScale.getRightValue(value));
3091				if (rightValue < 0) {
3092					return yScale.getPixelForValue(sumNeg + rightValue);
3093				}
3094				return yScale.getPixelForValue(sumPos + rightValue);
3095			}
3096
3097			return yScale.getPixelForValue(value);
3098		},
3099
3100		updateBezierControlPoints: function() {
3101			var me = this;
3102			var meta = me.getMeta();
3103			var area = me.chart.chartArea;
3104			var points = (meta.data || []);
3105			var i, ilen, point, model, controlPoints;
3106
3107			// Only consider points that are drawn in case the spanGaps option is used
3108			if (meta.dataset._model.spanGaps) {
3109				points = points.filter(function(pt) {
3110					return !pt._model.skip;
3111				});
3112			}
3113
3114			function capControlPoint(pt, min, max) {
3115				return Math.max(Math.min(pt, max), min);
3116			}
3117
3118			if (meta.dataset._model.cubicInterpolationMode === 'monotone') {
3119				helpers.splineCurveMonotone(points);
3120			} else {
3121				for (i = 0, ilen = points.length; i < ilen; ++i) {
3122					point = points[i];
3123					model = point._model;
3124					controlPoints = helpers.splineCurve(
3125						helpers.previousItem(points, i)._model,
3126						model,
3127						helpers.nextItem(points, i)._model,
3128						meta.dataset._model.tension
3129					);
3130					model.controlPointPreviousX = controlPoints.previous.x;
3131					model.controlPointPreviousY = controlPoints.previous.y;
3132					model.controlPointNextX = controlPoints.next.x;
3133					model.controlPointNextY = controlPoints.next.y;
3134				}
3135			}
3136
3137			if (me.chart.options.elements.line.capBezierPoints) {
3138				for (i = 0, ilen = points.length; i < ilen; ++i) {
3139					model = points[i]._model;
3140					model.controlPointPreviousX = capControlPoint(model.controlPointPreviousX, area.left, area.right);
3141					model.controlPointPreviousY = capControlPoint(model.controlPointPreviousY, area.top, area.bottom);
3142					model.controlPointNextX = capControlPoint(model.controlPointNextX, area.left, area.right);
3143					model.controlPointNextY = capControlPoint(model.controlPointNextY, area.top, area.bottom);
3144				}
3145			}
3146		},
3147
3148		draw: function() {
3149			var me = this;
3150			var chart = me.chart;
3151			var meta = me.getMeta();
3152			var points = meta.data || [];
3153			var area = chart.chartArea;
3154			var ilen = points.length;
3155			var i = 0;
3156
3157			helpers.canvas.clipArea(chart.ctx, area);
3158
3159			if (lineEnabled(me.getDataset(), chart.options)) {
3160				meta.dataset.draw();
3161			}
3162
3163			helpers.canvas.unclipArea(chart.ctx);
3164
3165			// Draw the points
3166			for (; i < ilen; ++i) {
3167				points[i].draw(area);
3168			}
3169		},
3170
3171		setHoverStyle: function(point) {
3172			// Point
3173			var dataset = this.chart.data.datasets[point._datasetIndex];
3174			var index = point._index;
3175			var custom = point.custom || {};
3176			var model = point._model;
3177
3178			model.radius = custom.hoverRadius || helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
3179			model.backgroundColor = custom.hoverBackgroundColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
3180			model.borderColor = custom.hoverBorderColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
3181			model.borderWidth = custom.hoverBorderWidth || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
3182		},
3183
3184		removeHoverStyle: function(point) {
3185			var me = this;
3186			var dataset = me.chart.data.datasets[point._datasetIndex];
3187			var index = point._index;
3188			var custom = point.custom || {};
3189			var model = point._model;
3190
3191			// Compatibility: If the properties are defined with only the old name, use those values
3192			if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
3193				dataset.pointRadius = dataset.radius;
3194			}
3195
3196			model.radius = custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, me.chart.options.elements.point.radius);
3197			model.backgroundColor = me.getPointBackgroundColor(point, index);
3198			model.borderColor = me.getPointBorderColor(point, index);
3199			model.borderWidth = me.getPointBorderWidth(point, index);
3200		}
3201	});
3202};
3203
3204},{"25":25,"40":40,"45":45}],19:[function(require,module,exports){
3205'use strict';
3206
3207var defaults = require(25);
3208var elements = require(40);
3209var helpers = require(45);
3210
3211defaults._set('polarArea', {
3212	scale: {
3213		type: 'radialLinear',
3214		angleLines: {
3215			display: false
3216		},
3217		gridLines: {
3218			circular: true
3219		},
3220		pointLabels: {
3221			display: false
3222		},
3223		ticks: {
3224			beginAtZero: true
3225		}
3226	},
3227
3228	// Boolean - Whether to animate the rotation of the chart
3229	animation: {
3230		animateRotate: true,
3231		animateScale: true
3232	},
3233
3234	startAngle: -0.5 * Math.PI,
3235	legendCallback: function(chart) {
3236		var text = [];
3237		text.push('<ul class="' + chart.id + '-legend">');
3238
3239		var data = chart.data;
3240		var datasets = data.datasets;
3241		var labels = data.labels;
3242
3243		if (datasets.length) {
3244			for (var i = 0; i < datasets[0].data.length; ++i) {
3245				text.push('<li><span style="background-color:' + datasets[0].backgroundColor[i] + '"></span>');
3246				if (labels[i]) {
3247					text.push(labels[i]);
3248				}
3249				text.push('</li>');
3250			}
3251		}
3252
3253		text.push('</ul>');
3254		return text.join('');
3255	},
3256	legend: {
3257		labels: {
3258			generateLabels: function(chart) {
3259				var data = chart.data;
3260				if (data.labels.length && data.datasets.length) {
3261					return data.labels.map(function(label, i) {
3262						var meta = chart.getDatasetMeta(0);
3263						var ds = data.datasets[0];
3264						var arc = meta.data[i];
3265						var custom = arc.custom || {};
3266						var valueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
3267						var arcOpts = chart.options.elements.arc;
3268						var fill = custom.backgroundColor ? custom.backgroundColor : valueAtIndexOrDefault(ds.backgroundColor, i, arcOpts.backgroundColor);
3269						var stroke = custom.borderColor ? custom.borderColor : valueAtIndexOrDefault(ds.borderColor, i, arcOpts.borderColor);
3270						var bw = custom.borderWidth ? custom.borderWidth : valueAtIndexOrDefault(ds.borderWidth, i, arcOpts.borderWidth);
3271
3272						return {
3273							text: label,
3274							fillStyle: fill,
3275							strokeStyle: stroke,
3276							lineWidth: bw,
3277							hidden: isNaN(ds.data[i]) || meta.data[i].hidden,
3278
3279							// Extra data used for toggling the correct item
3280							index: i
3281						};
3282					});
3283				}
3284				return [];
3285			}
3286		},
3287
3288		onClick: function(e, legendItem) {
3289			var index = legendItem.index;
3290			var chart = this.chart;
3291			var i, ilen, meta;
3292
3293			for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
3294				meta = chart.getDatasetMeta(i);
3295				meta.data[index].hidden = !meta.data[index].hidden;
3296			}
3297
3298			chart.update();
3299		}
3300	},
3301
3302	// Need to override these to give a nice default
3303	tooltips: {
3304		callbacks: {
3305			title: function() {
3306				return '';
3307			},
3308			label: function(item, data) {
3309				return data.labels[item.index] + ': ' + item.yLabel;
3310			}
3311		}
3312	}
3313});
3314
3315module.exports = function(Chart) {
3316
3317	Chart.controllers.polarArea = Chart.DatasetController.extend({
3318
3319		dataElementType: elements.Arc,
3320
3321		linkScales: helpers.noop,
3322
3323		update: function(reset) {
3324			var me = this;
3325			var chart = me.chart;
3326			var chartArea = chart.chartArea;
3327			var meta = me.getMeta();
3328			var opts = chart.options;
3329			var arcOpts = opts.elements.arc;
3330			var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);
3331			chart.outerRadius = Math.max((minSize - arcOpts.borderWidth / 2) / 2, 0);
3332			chart.innerRadius = Math.max(opts.cutoutPercentage ? (chart.outerRadius / 100) * (opts.cutoutPercentage) : 1, 0);
3333			chart.radiusLength = (chart.outerRadius - chart.innerRadius) / chart.getVisibleDatasetCount();
3334
3335			me.outerRadius = chart.outerRadius - (chart.radiusLength * me.index);
3336			me.innerRadius = me.outerRadius - chart.radiusLength;
3337
3338			meta.count = me.countVisibleElements();
3339
3340			helpers.each(meta.data, function(arc, index) {
3341				me.updateElement(arc, index, reset);
3342			});
3343		},
3344
3345		updateElement: function(arc, index, reset) {
3346			var me = this;
3347			var chart = me.chart;
3348			var dataset = me.getDataset();
3349			var opts = chart.options;
3350			var animationOpts = opts.animation;
3351			var scale = chart.scale;
3352			var labels = chart.data.labels;
3353
3354			var circumference = me.calculateCircumference(dataset.data[index]);
3355			var centerX = scale.xCenter;
3356			var centerY = scale.yCenter;
3357
3358			// If there is NaN data before us, we need to calculate the starting angle correctly.
3359			// We could be way more efficient here, but its unlikely that the polar area chart will have a lot of data
3360			var visibleCount = 0;
3361			var meta = me.getMeta();
3362			for (var i = 0; i < index; ++i) {
3363				if (!isNaN(dataset.data[i]) && !meta.data[i].hidden) {
3364					++visibleCount;
3365				}
3366			}
3367
3368			// var negHalfPI = -0.5 * Math.PI;
3369			var datasetStartAngle = opts.startAngle;
3370			var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
3371			var startAngle = datasetStartAngle + (circumference * visibleCount);
3372			var endAngle = startAngle + (arc.hidden ? 0 : circumference);
3373
3374			var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
3375
3376			helpers.extend(arc, {
3377				// Utility
3378				_datasetIndex: me.index,
3379				_index: index,
3380				_scale: scale,
3381
3382				// Desired view properties
3383				_model: {
3384					x: centerX,
3385					y: centerY,
3386					innerRadius: 0,
3387					outerRadius: reset ? resetRadius : distance,
3388					startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle,
3389					endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle,
3390					label: helpers.valueAtIndexOrDefault(labels, index, labels[index])
3391				}
3392			});
3393
3394			// Apply border and fill style
3395			me.removeHoverStyle(arc);
3396
3397			arc.pivot();
3398		},
3399
3400		removeHoverStyle: function(arc) {
3401			Chart.DatasetController.prototype.removeHoverStyle.call(this, arc, this.chart.options.elements.arc);
3402		},
3403
3404		countVisibleElements: function() {
3405			var dataset = this.getDataset();
3406			var meta = this.getMeta();
3407			var count = 0;
3408
3409			helpers.each(meta.data, function(element, index) {
3410				if (!isNaN(dataset.data[index]) && !element.hidden) {
3411					count++;
3412				}
3413			});
3414
3415			return count;
3416		},
3417
3418		calculateCircumference: function(value) {
3419			var count = this.getMeta().count;
3420			if (count > 0 && !isNaN(value)) {
3421				return (2 * Math.PI) / count;
3422			}
3423			return 0;
3424		}
3425	});
3426};
3427
3428},{"25":25,"40":40,"45":45}],20:[function(require,module,exports){
3429'use strict';
3430
3431var defaults = require(25);
3432var elements = require(40);
3433var helpers = require(45);
3434
3435defaults._set('radar', {
3436	scale: {
3437		type: 'radialLinear'
3438	},
3439	elements: {
3440		line: {
3441			tension: 0 // no bezier in radar
3442		}
3443	}
3444});
3445
3446module.exports = function(Chart) {
3447
3448	Chart.controllers.radar = Chart.DatasetController.extend({
3449
3450		datasetElementType: elements.Line,
3451
3452		dataElementType: elements.Point,
3453
3454		linkScales: helpers.noop,
3455
3456		update: function(reset) {
3457			var me = this;
3458			var meta = me.getMeta();
3459			var line = meta.dataset;
3460			var points = meta.data;
3461			var custom = line.custom || {};
3462			var dataset = me.getDataset();
3463			var lineElementOptions = me.chart.options.elements.line;
3464			var scale = me.chart.scale;
3465
3466			// Compatibility: If the properties are defined with only the old name, use those values
3467			if ((dataset.tension !== undefined) && (dataset.lineTension === undefined)) {
3468				dataset.lineTension = dataset.tension;
3469			}
3470
3471			helpers.extend(meta.dataset, {
3472				// Utility
3473				_datasetIndex: me.index,
3474				_scale: scale,
3475				// Data
3476				_children: points,
3477				_loop: true,
3478				// Model
3479				_model: {
3480					// Appearance
3481					tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, lineElementOptions.tension),
3482					backgroundColor: custom.backgroundColor ? custom.backgroundColor : (dataset.backgroundColor || lineElementOptions.backgroundColor),
3483					borderWidth: custom.borderWidth ? custom.borderWidth : (dataset.borderWidth || lineElementOptions.borderWidth),
3484					borderColor: custom.borderColor ? custom.borderColor : (dataset.borderColor || lineElementOptions.borderColor),
3485					fill: custom.fill ? custom.fill : (dataset.fill !== undefined ? dataset.fill : lineElementOptions.fill),
3486					borderCapStyle: custom.borderCapStyle ? custom.borderCapStyle : (dataset.borderCapStyle || lineElementOptions.borderCapStyle),
3487					borderDash: custom.borderDash ? custom.borderDash : (dataset.borderDash || lineElementOptions.borderDash),
3488					borderDashOffset: custom.borderDashOffset ? custom.borderDashOffset : (dataset.borderDashOffset || lineElementOptions.borderDashOffset),
3489					borderJoinStyle: custom.borderJoinStyle ? custom.borderJoinStyle : (dataset.borderJoinStyle || lineElementOptions.borderJoinStyle),
3490				}
3491			});
3492
3493			meta.dataset.pivot();
3494
3495			// Update Points
3496			helpers.each(points, function(point, index) {
3497				me.updateElement(point, index, reset);
3498			}, me);
3499
3500			// Update bezier control points
3501			me.updateBezierControlPoints();
3502		},
3503		updateElement: function(point, index, reset) {
3504			var me = this;
3505			var custom = point.custom || {};
3506			var dataset = me.getDataset();
3507			var scale = me.chart.scale;
3508			var pointElementOptions = me.chart.options.elements.point;
3509			var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]);
3510
3511			// Compatibility: If the properties are defined with only the old name, use those values
3512			if ((dataset.radius !== undefined) && (dataset.pointRadius === undefined)) {
3513				dataset.pointRadius = dataset.radius;
3514			}
3515			if ((dataset.hitRadius !== undefined) && (dataset.pointHitRadius === undefined)) {
3516				dataset.pointHitRadius = dataset.hitRadius;
3517			}
3518
3519			helpers.extend(point, {
3520				// Utility
3521				_datasetIndex: me.index,
3522				_index: index,
3523				_scale: scale,
3524
3525				// Desired view properties
3526				_model: {
3527					x: reset ? scale.xCenter : pointPosition.x, // value not used in dataset scale, but we want a consistent API between scales
3528					y: reset ? scale.yCenter : pointPosition.y,
3529
3530					// Appearance
3531					tension: custom.tension ? custom.tension : helpers.valueOrDefault(dataset.lineTension, me.chart.options.elements.line.tension),
3532					radius: custom.radius ? custom.radius : helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius),
3533					backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.pointBackgroun
3533dColor, index, pointElementOptions.backgroundColor),
3534					borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor),
3535					borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth),
3536					pointStyle: custom.pointStyle ? custom.pointStyle : helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointElementOptions.pointStyle),
3537
3538					// Tooltip
3539					hitRadius: custom.hitRadius ? custom.hitRadius : helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointElementOptions.hitRadius)
3540				}
3541			});
3542
3543			point._model.skip = custom.skip ? custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
3544		},
3545		updateBezierControlPoints: function() {
3546			var chartArea = this.chart.chartArea;
3547			var meta = this.getMeta();
3548
3549			helpers.each(meta.data, function(point, index) {
3550				var model = point._model;
3551				var controlPoints = helpers.splineCurve(
3552					helpers.previousItem(meta.data, index, true)._model,
3553					model,
3554					helpers.nextItem(meta.data, index, true)._model,
3555					model.tension
3556				);
3557
3558				// Prevent the bezier going outside of the bounds of the graph
3559				model.controlPointPreviousX = Math.max(Math.min(controlPoints.previous.x, chartArea.right), chartArea.left);
3560				model.controlPointPreviousY = Math.max(Math.min(controlPoints.previous.y, chartArea.bottom), chartArea.top);
3561
3562				model.controlPointNextX = Math.max(Math.min(controlPoints.next.x, chartArea.right), chartArea.left);
3563				model.controlPointNextY = Math.max(Math.min(controlPoints.next.y, chartArea.bottom), chartArea.top);
3564
3565				// Now pivot the point for animation
3566				point.pivot();
3567			});
3568		},
3569
3570		setHoverStyle: function(point) {
3571			// Point
3572			var dataset = this.chart.data.datasets[point._datasetIndex];
3573			var custom = point.custom || {};
3574			var index = point._index;
3575			var model = point._model;
3576
3577			model.radius = custom.hoverRadius ? custom.hoverRadius : helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
3578			model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
3579			model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
3580			model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
3581		},
3582
3583		removeHoverStyle: function(point) {
3584			var dataset = this.chart.data.datasets[point._datasetIndex];
3585			var custom = point.custom || {};
3586			var index = point._index;
3587			var model = point._model;
3588			var pointElementOptions = this.chart.options.elements.point;
3589
3590			model.radius = custom.radius ? custom.radius : helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointElementOptions.radius);
3591			model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.pointBackgroun
3591dColor, index, pointElementOptions.backgroundColor);
3592			model.borderColor = custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor);
3593			model.borderWidth = custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth);
3594		}
3595	});
3596};
3597
3598},{"25":25,"40":40,"45":45}],21:[function(require,module,exports){
3599'use strict';
3600
3601var defaults = require(25);
3602
3603defaults._set('scatter', {
3604	hover: {
3605		mode: 'single'
3606	},
3607
3608	scales: {
3609		xAxes: [{
3610			id: 'x-axis-1',    // need an ID so datasets can reference the scale
3611			type: 'linear',    // scatter should not use a category axis
3612			position: 'bottom'
3613		}],
3614		yAxes: [{
3615			id: 'y-axis-1',
3616			type: 'linear',
3617			position: 'left'
3618		}]
3619	},
3620
3621	showLines: false,
3622
3623	tooltips: {
3624		callbacks: {
3625			title: function() {
3626				return '';     // doesn't make sense for scatter since data are formatted as a point
3627			},
3628			label: function(item) {
3629				return '(' + item.xLabel + ', ' + item.yLabel + ')';
3630			}
3631		}
3632	}
3633});
3634
3635module.exports = function(Chart) {
3636
3637	// Scatter charts use line controllers
3638	Chart.controllers.scatter = Chart.controllers.line;
3639
3640};
3641
3642},{"25":25}],22:[function(require,module,exports){
3643/* global window: false */
3644'use strict';
3645
3646var defaults = require(25);
3647var Element = require(26);
3648var helpers = require(45);
3649
3650defaults._set('global', {
3651	animation: {
3652		duration: 1000,
3653		easing: 'easeOutQuart',
3654		onProgress: helpers.noop,
3655		onComplete: helpers.noop
3656	}
3657});
3658
3659module.exports = function(Chart) {
3660
3661	Chart.Animation = Element.extend({
3662		chart: null, // the animation associated chart instance
3663		currentStep: 0, // the current animation step
3664		numSteps: 60, // default number of steps
3665		easing: '', // the easing to use for this animation
3666		render: null, // render function used by the animation service
3667
3668		onAnimationProgress: null, // user specified callback to fire on each step of the animation
3669		onAnimationComplete: null, // user specified callback to fire when the animation finishes
3670	});
3671
3672	Chart.animationService = {
3673		frameDuration: 17,
3674		animations: [],
3675		dropFrames: 0,
3676		request: null,
3677
3678		/**
3679		 * @param {Chart} chart - The chart to animate.
3680		 * @param {Chart.Animation} animation - The animation that we will animate.
3681		 * @param {Number} duration - The animation duration in ms.
3682		 * @param {Boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions
3683		 */
3684		addAnimation: function(chart, animation, duration, lazy) {
3685			var animations = this.animations;
3686			var i, ilen;
3687
3688			animation.chart = chart;
3689
3690			if (!lazy) {
3691				chart.animating = true;
3692			}
3693
3694			for (i = 0, ilen = animations.length; i < ilen; ++i) {
3695				if (animations[i].chart === chart) {
3696					animations[i] = animation;
3697					return;
3698				}
3699			}
3700
3701			animations.push(animation);
3702
3703			// If there are no animations queued, manually kickstart a digest, for lack of a better word
3704			if (animations.length === 1) {
3705				this.requestAnimationFrame();
3706			}
3707		},
3708
3709		cancelAnimation: function(chart) {
3710			var index = helpers.findIndex(this.animations, function(animation) {
3711				return animation.chart === chart;
3712			});
3713
3714			if (index !== -1) {
3715				this.animations.splice(index, 1);
3716				chart.animating = false;
3717			}
3718		},
3719
3720		requestAnimationFrame: function() {
3721			var me = this;
3722			if (me.request === null) {
3723				// Skip animation frame requests until the active one is executed.
3724				// This can happen when processing mouse events, e.g. 'mousemove'
3725				// and 'mouseout' events will trigger multiple renders.
3726				me.request = helpers.requestAnimFrame.call(window, function() {
3727					me.request = null;
3728					me.startDigest();
3729				});
3730			}
3731		},
3732
3733		/**
3734		 * @private
3735		 */
3736		startDigest: function() {
3737			var me = this;
3738			var startTime = Date.now();
3739			var framesToDrop = 0;
3740
3741			if (me.dropFrames > 1) {
3742				framesToDrop = Math.floor(me.dropFrames);
3743				me.dropFrames = me.dropFrames % 1;
3744			}
3745
3746			me.advance(1 + framesToDrop);
3747
3748			var endTime = Date.now();
3749
3750			me.dropFrames += (endTime - startTime) / me.frameDuration;
3751
3752			// Do we have more stuff to animate?
3753			if (me.animations.length > 0) {
3754				me.requestAnimationFrame();
3755			}
3756		},
3757
3758		/**
3759		 * @private
3760		 */
3761		advance: function(count) {
3762			var animations = this.animations;
3763			var animation, chart;
3764			var i = 0;
3765
3766			while (i < animations.length) {
3767				animation = animations[i];
3768				chart = animation.chart;
3769
3770				animation.currentStep = (animation.currentStep || 0) + count;
3771				animation.currentStep = Math.min(animation.currentStep, animation.numSteps);
3772
3773				helpers.callback(animation.render, [chart, animation], chart);
3774				helpers.callback(animation.onAnimationProgress, [animation], chart);
3775
3776				if (animation.currentStep >= animation.numSteps) {
3777					helpers.callback(animation.onAnimationComplete, [animation], chart);
3778					chart.animating = false;
3779					animations.splice(i, 1);
3780				} else {
3781					++i;
3782				}
3783			}
3784		}
3785	};
3786
3787	/**
3788	 * Provided for backward compatibility, use Chart.Animation instead
3789	 * @prop Chart.Animation#animationObject
3790	 * @deprecated since version 2.6.0
3791	 * @todo remove at version 3
3792	 */
3793	Object.defineProperty(Chart.Animation.prototype, 'animationObject', {
3794		get: function() {
3795			return this;
3796		}
3797	});
3798
3799	/**
3800	 * Provided for backward compatibility, use Chart.Animation#chart instead
3801	 * @prop Chart.Animation#chartInstance
3802	 * @deprecated since version 2.6.0
3803	 * @todo remove at version 3
3804	 */
3805	Object.defineProperty(Chart.Animation.prototype, 'chartInstance', {
3806		get: function() {
3807			return this.chart;
3808		},
3809		set: function(value) {
3810			this.chart = value;
3811		}
3812	});
3813
3814};
3815
3816},{"25":25,"26":26,"45":45}],23:[function(require,module,exports){
3817'use strict';
3818
3819var defaults = require(25);
3820var helpers = require(45);
3821var Interaction = require(28);
3822var layouts = require(30);
3823var platform = require(48);
3824var plugins = require(31);
3825
3826module.exports = function(Chart) {
3827
3828	// Create a dictionary of chart types, to allow for extension of existing types
3829	Chart.types = {};
3830
3831	// Store a reference to each instance - allowing us to globally resize chart instances on window resize.
3832	// Destroy method on the chart will remove the instance of the chart from this reference.
3833	Chart.instances = {};
3834
3835	// Controllers available for dataset visualization eg. bar, line, slice, etc.
3836	Chart.controllers = {};
3837
3838	/**
3839	 * Initializes the given config with global and chart default values.
3840	 */
3841	function initConfig(config) {
3842		config = config || {};
3843
3844		// Do NOT use configMerge() for the data object because this method merges arrays
3845		// and so would change references to labels and datasets, preventing data updates.
3846		var data = config.data = config.data || {};
3847		data.datasets = data.datasets || [];
3848		data.labels = data.labels || [];
3849
3850		config.options = helpers.configMerge(
3851			defaults.global,
3852			defaults[config.type],
3853			config.options || {});
3854
3855		return config;
3856	}
3857
3858	/**
3859	 * Updates the config of the chart
3860	 * @param chart {Chart} chart to update the options for
3861	 */
3862	function updateConfig(chart) {
3863		var newOptions = chart.options;
3864
3865		helpers.each(chart.scales, function(scale) {
3866			layouts.removeBox(chart, scale);
3867		});
3868
3869		newOptions = helpers.configMerge(
3870			Chart.defaults.global,
3871			Chart.defaults[chart.config.type],
3872			newOptions);
3873
3874		chart.options = chart.config.options = newOptions;
3875		chart.ensureScalesHaveIDs();
3876		chart.buildOrUpdateScales();
3877		// Tooltip
3878		chart.tooltip._options = newOptions.tooltips;
3879		chart.tooltip.initialize();
3880	}
3881
3882	function positionIsHorizontal(position) {
3883		return position === 'top' || position === 'bottom';
3884	}
3885
3886	helpers.extend(Chart.prototype, /** @lends Chart */ {
3887		/**
3888		 * @private
3889		 */
3890		construct: function(item, config) {
3891			var me = this;
3892
3893			config = initConfig(config);
3894
3895			var context = platform.acquireContext(item, config);
3896			var canvas = context && context.canvas;
3897			var height = canvas && canvas.height;
3898			var width = canvas && canvas.width;
3899
3900			me.id = helpers.uid();
3901			me.ctx = context;
3902			me.canvas = canvas;
3903			me.config = config;
3904			me.width = width;
3905			me.height = height;
3906			me.aspectRatio = height ? width / height : null;
3907			me.options = config.options;
3908			me._bufferedRender = false;
vendor: 10,788 bytes, lines 3909-4307
3909
3910			/**
3911			 * Provided for backward compatibility, Chart and Chart.Controller have been merged,
3912			 * the "instance" still need to be defined since it might be called from plugins.
3913			 * @prop Chart#chart
3914			 * @deprecated since version 2.6.0
3915			 * @todo remove at version 3
3916			 * @private
3917			 */
3918			me.chart = me;
3919			me.controller = me; // chart.chart.controller #inception
3920
3921			// Add the chart instance to the global namespace
3922			Chart.instances[me.id] = me;
3923
3924			// Define alias to the config data: `chart.data === chart.config.data`
3925			Object.defineProperty(me, 'data', {
3926				get: function() {
3927					return me.config.data;
3928				},
3929				set: function(value) {
3930					me.config.data = value;
3931				}
3932			});
3933
3934			if (!context || !canvas) {
3935				// The given item is not a compatible context2d element, let's return before finalizing
3936				// the chart initialization but after setting basic chart / controller properties that
3937				// can help to figure out that the chart is not valid (e.g chart.canvas !== null);
3938				// https://github.com/chartjs/Chart.js/issues/2807
3939				console.error("Failed to create chart: can't acquire context from the given item");
3940				return;
3941			}
3942
3943			me.initialize();
3944			me.update();
3945		},
3946
3947		/**
3948		 * @private
3949		 */
3950		initialize: function() {
3951			var me = this;
3952
3953			// Before init plugin notification
3954			plugins.notify(me, 'beforeInit');
3955
3956			helpers.retinaScale(me, me.options.devicePixelRatio);
3957
3958			me.bindEvents();
3959
3960			if (me.options.responsive) {
3961				// Initial resize before chart draws (must be silent to preserve initial animations).
3962				me.resize(true);
3963			}
3964
3965			// Make sure scales have IDs and are built before we build any controllers.
3966			me.ensureScalesHaveIDs();
3967			me.buildOrUpdateScales();
3968			me.initToolTip();
3969
3970			// After init plugin notification
3971			plugins.notify(me, 'afterInit');
3972
3973			return me;
3974		},
3975
3976		clear: function() {
3977			helpers.canvas.clear(this);
3978			return this;
3979		},
3980
3981		stop: function() {
3982			// Stops any current animation loop occurring
3983			Chart.animationService.cancelAnimation(this);
3984			return this;
3985		},
3986
3987		resize: function(silent) {
3988			var me = this;
3989			var options = me.options;
3990			var canvas = me.canvas;
3991			var aspectRatio = (options.maintainAspectRatio && me.aspectRatio) || null;
3992
3993			// the canvas render width and height will be casted to integers so make sure that
3994			// the canvas display style uses the same integer values to avoid blurring effect.
3995
3996			// Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased
3997			var newWidth = Math.max(0, Math.floor(helpers.getMaximumWidth(canvas)));
3998			var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)));
3999
4000			if (me.width === newWidth && me.height === newHeight) {
4001				return;
4002			}
4003
4004			canvas.width = me.width = newWidth;
4005			canvas.height = me.height = newHeight;
4006			canvas.style.width = newWidth + 'px';
4007			canvas.style.height = newHeight + 'px';
4008
4009			helpers.retinaScale(me, options.devicePixelRatio);
4010
4011			if (!silent) {
4012				// Notify any plugins about the resize
4013				var newSize = {width: newWidth, height: newHeight};
4014				plugins.notify(me, 'resize', [newSize]);
4015
4016				// Notify of resize
4017				if (me.options.onResize) {
4018					me.options.onResize(me, newSize);
4019				}
4020
4021				me.stop();
4022				me.update(me.options.responsiveAnimationDuration);
4023			}
4024		},
4025
4026		ensureScalesHaveIDs: function() {
4027			var options = this.options;
4028			var scalesOptions = options.scales || {};
4029			var scaleOptions = options.scale;
4030
4031			helpers.each(scalesOptions.xAxes, function(xAxisOptions, index) {
4032				xAxisOptions.id = xAxisOptions.id || ('x-axis-' + index);
4033			});
4034
4035			helpers.each(scalesOptions.yAxes, function(yAxisOptions, index) {
4036				yAxisOptions.id = yAxisOptions.id || ('y-axis-' + index);
4037			});
4038
4039			if (scaleOptions) {
4040				scaleOptions.id = scaleOptions.id || 'scale';
4041			}
4042		},
4043
4044		/**
4045		 * Builds a map of scale ID to scale object for future lookup.
4046		 */
4047		buildOrUpdateScales: function() {
4048			var me = this;
4049			var options = me.options;
4050			var scales = me.scales || {};
4051			var items = [];
4052			var updated = Object.keys(scales).reduce(function(obj, id) {
4053				obj[id] = false;
4054				return obj;
4055			}, {});
4056
4057			if (options.scales) {
4058				items = items.concat(
4059					(options.scales.xAxes || []).map(function(xAxisOptions) {
4060						return {options: xAxisOptions, dtype: 'category', dposition: 'bottom'};
4061					}),
4062					(options.scales.yAxes || []).map(function(yAxisOptions) {
4063						return {options: yAxisOptions, dtype: 'linear', dposition: 'left'};
4064					})
4065				);
4066			}
4067
4068			if (options.scale) {
4069				items.push({
4070					options: options.scale,
4071					dtype: 'radialLinear',
4072					isDefault: true,
4073					dposition: 'chartArea'
4074				});
4075			}
4076
4077			helpers.each(items, function(item) {
4078				var scaleOptions = item.options;
4079				var id = scaleOptions.id;
4080				var scaleType = helpers.valueOrDefault(scaleOptions.type, item.dtype);
4081
4082				if (positionIsHorizontal(scaleOptions.position) !== positionIsHorizontal(item.dposition)) {
4083					scaleOptions.position = item.dposition;
4084				}
4085
4086				updated[id] = true;
4087				var scale = null;
4088				if (id in scales && scales[id].type === scaleType) {
4089					scale = scales[id];
4090					scale.options = scaleOptions;
4091					scale.ctx = me.ctx;
4092					scale.chart = me;
4093				} else {
4094					var scaleClass = Chart.scaleService.getScaleConstructor(scaleType);
4095					if (!scaleClass) {
4096						return;
4097					}
4098					scale = new scaleClass({
4099						id: id,
4100						type: scaleType,
4101						options: scaleOptions,
4102						ctx: me.ctx,
4103						chart: me
4104					});
4105					scales[scale.id] = scale;
4106				}
4107
4108				scale.mergeTicksOptions();
4109
4110				// TODO(SB): I think we should be able to remove this custom case (options.scale)
4111				// and consider it as a regular scale part of the "scales"" map only! This would
4112				// make the logic easier and remove some useless? custom code.
4113				if (item.isDefault) {
4114					me.scale = scale;
4115				}
4116			});
4117			// clear up discarded scales
4118			helpers.each(updated, function(hasUpdated, id) {
4119				if (!hasUpdated) {
4120					delete scales[id];
4121				}
4122			});
4123
4124			me.scales = scales;
4125
4126			Chart.scaleService.addScalesToLayout(this);
4127		},
4128
4129		buildOrUpdateControllers: function() {
4130			var me = this;
4131			var types = [];
4132			var newControllers = [];
4133
4134			helpers.each(me.data.datasets, function(dataset, datasetIndex) {
4135				var meta = me.getDatasetMeta(datasetIndex);
4136				var type = dataset.type || me.config.type;
4137
4138				if (meta.type && meta.type !== type) {
4139					me.destroyDatasetMeta(datasetIndex);
4140					meta = me.getDatasetMeta(datasetIndex);
4141				}
4142				meta.type = type;
4143
4144				types.push(meta.type);
4145
4146				if (meta.controller) {
4147					meta.controller.updateIndex(datasetIndex);
4148					meta.controller.linkScales();
4149				} else {
4150					var ControllerClass = Chart.controllers[meta.type];
4151					if (ControllerClass === undefined) {
4152						throw new Error('"' + meta.type + '" is not a chart type.');
4153					}
4154
4155					meta.controller = new ControllerClass(me, datasetIndex);
4156					newControllers.push(meta.controller);
4157				}
4158			}, me);
4159
4160			return newControllers;
4161		},
4162
4163		/**
4164		 * Reset the elements of all datasets
4165		 * @private
4166		 */
4167		resetElements: function() {
4168			var me = this;
4169			helpers.each(me.data.datasets, function(dataset, datasetIndex) {
4170				me.getDatasetMeta(datasetIndex).controller.reset();
4171			}, me);
4172		},
4173
4174		/**
4175		* Resets the chart back to it's state before the initial animation
4176		*/
4177		reset: function() {
4178			this.resetElements();
4179			this.tooltip.initialize();
4180		},
4181
4182		update: function(config) {
4183			var me = this;
4184
4185			if (!config || typeof config !== 'object') {
4186				// backwards compatibility
4187				config = {
4188					duration: config,
4189					lazy: arguments[1]
4190				};
4191			}
4192
4193			updateConfig(me);
4194
4195			// plugins options references might have change, let's invalidate the cache
4196			// https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167
4197			plugins._invalidate(me);
4198
4199			if (plugins.notify(me, 'beforeUpdate') === false) {
4200				return;
4201			}
4202
4203			// In case the entire data object changed
4204			me.tooltip._data = me.data;
4205
4206			// Make sure dataset controllers are updated and new controllers are reset
4207			var newControllers = me.buildOrUpdateControllers();
4208
4209			// Make sure all dataset controllers have correct meta data counts
4210			helpers.each(me.data.datasets, function(dataset, datasetIndex) {
4211				me.getDatasetMeta(datasetIndex).controller.buildOrUpdateElements();
4212			}, me);
4213
4214			me.updateLayout();
4215
4216			// Can only reset the new controllers after the scales have been updated
4217			if (me.options.animation && me.options.animation.duration) {
4218				helpers.each(newControllers, function(controller) {
4219					controller.reset();
4220				});
4221			}
4222
4223			me.updateDatasets();
4224
4225			// Need to reset tooltip in case it is displayed with elements that are removed
4226			// after update.
4227			me.tooltip.initialize();
4228
4229			// Last active contains items that were previously in the tooltip.
4230			// When we reset the tooltip, we need to clear it
4231			me.lastActive = [];
4232
4233			// Do this before render so that any plugins that need final scale updates can use it
4234			plugins.notify(me, 'afterUpdate');
4235
4236			if (me._bufferedRender) {
4237				me._bufferedRequest = {
4238					duration: config.duration,
4239					easing: config.easing,
4240					lazy: config.lazy
4241				};
4242			} else {
4243				me.render(config);
4244			}
4245		},
4246
4247		/**
4248		 * Updates the chart layout unless a plugin returns `false` to the `beforeLayout`
4249		 * hook, in which case, plugins will not be called on `afterLayout`.
4250		 * @private
4251		 */
4252		updateLayout: function() {
4253			var me = this;
4254
4255			if (plugins.notify(me, 'beforeLayout') === false) {
4256				return;
4257			}
4258
4259			layouts.update(this, this.width, this.height);
4260
4261			/**
4262			 * Provided for backward compatibility, use `afterLayout` instead.
4263			 * @method IPlugin#afterScaleUpdate
4264			 * @deprecated since version 2.5.0
4265			 * @todo remove at version 3
4266			 * @private
4267			 */
4268			plugins.notify(me, 'afterScaleUpdate');
4269			plugins.notify(me, 'afterLayout');
4270		},
4271
4272		/**
4273		 * Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate`
4274		 * hook, in which case, plugins will not be called on `afterDatasetsUpdate`.
4275		 * @private
4276		 */
4277		updateDatasets: function() {
4278			var me = this;
4279
4280			if (plugins.notify(me, 'beforeDatasetsUpdate') === false) {
4281				return;
4282			}
4283
4284			for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
4285				me.updateDataset(i);
4286			}
4287
4288			plugins.notify(me, 'afterDatasetsUpdate');
4289		},
4290
4291		/**
4292		 * Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate`
4293		 * hook, in which case, plugins will not be called on `afterDatasetUpdate`.
4294		 * @private
4295		 */
4296		updateDataset: function(index) {
4297			var me = this;
4298			var meta = me.getDatasetMeta(index);
4299			var args = {
4300				meta: meta,
4301				index: index
4302			};
4303
4304			if (plugins.notify(me, 'beforeDatasetUpdate', [args]) === false) {
4305				return;
4306			}
4307
4308			meta.controller.update();
4309
4310			plugins.notify(me, 'afterDatasetUpdate', [args]);
4311		},
4312
4313		render: function(config) {
4314			var me = this;
4315
4316			if (!config || typeof config !== 'object') {
4317				// backwards compatibility
4318				config = {
4319					duration: config,
4320					lazy: arguments[1]
4321				};
4322			}
4323
4324			var duration = config.duration;
4325			var lazy = config.lazy;
4326
4327			if (plugins.notify(me, 'beforeRender') === false) {
4328				return;
4329			}
4330
4331			var animationOptions = me.options.animation;
4332			var onComplete = function(animation) {
4333				plugins.notify(me, 'afterRender');
4334				helpers.callback(animationOptions && animationOptions.onComplete, [animation], me);
4335			};
4336
4337			if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
4338				var animation = new Chart.Animation({
4339					numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps
4340					easing: config.easing || animationOptions.easing,
4341
4342					render: function(chart, animationObject) {
4343						var easingFunction = helpers.easing.effects[animationObject.easing];
4344						var currentStep = animationObject.currentStep;
4345						var stepDecimal = currentStep / animationObject.numSteps;
4346
4347						chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep);
4348					},
4349
4350					onAnimationProgress: animationOptions.onProgress,
4351					onAnimationComplete: onComplete
4352				});
4353
4354				Chart.animationService.addAnimation(me, animation, duration, lazy);
4355			} else {
4356				me.draw();
4357
4358				// See https://github.com/chartjs/Chart.js/issues/3781
4359				onComplete(new Chart.Animation({numSteps: 0, chart: me}));
4360			}
4361
4362			return me;
4363		},
4364
4365		draw: function(easingValue) {
4366			var me = this;
4367
4368			me.clear();
4369
4370			if (helpers.isNullOrUndef(easingValue)) {
4371				easingValue = 1;
4372			}
4373
4374			me.transition(easingValue);
4375
4376			if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) {
4377				return;
4378			}
4379
4380			// Draw all the scales
4381			helpers.each(me.boxes, function(box) {
4382				box.draw(me.chartArea);
4383			}, me);
4384
4385			if (me.scale) {
4386				me.scale.draw();
4387			}
4388
4389			me.drawDatasets(easingValue);
4390			me._drawTooltip(easingValue);
4391
4392			plugins.notify(me, 'afterDraw', [easingValue]);
4393		},
4394
4395		/**
4396		 * @private
4397		 */
4398		transition: function(easingValue) {
4399			var me = this;
4400
4401			for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) {
4402				if (me.isDatasetVisible(i)) {
4403					me.getDatasetMeta(i).controller.transition(easingValue);
4404				}
4405			}
4406
4407			me.tooltip.transition(easingValue);
4408		},
4409
4410		/**
4411		 * Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw`
4412		 * hook, in which case, plugins will not be called on `afterDatasetsDraw`.
4413		 * @private
4414		 */
4415		drawDatasets: function(easingValue) {
4416			var me = this;
4417
4418			if (plugins.notify(me, 'beforeDatasetsDraw', [easingValue]) === false) {
4419				return;
4420			}
4421
4422			// Draw datasets reversed to support proper line stacking
4423			for (var i = (me.data.datasets || []).length - 1; i >= 0; --i) {
4424				if (me.isDatasetVisible(i)) {
4425					me.drawDataset(i, easingValue);
4426				}
4427			}
4428
4429			plugins.notify(me, 'afterDatasetsDraw', [easingValue]);
4430		},
4431
4432		/**
4433		 * Draws dataset at index unless a plugin returns `false` to the `beforeDatasetDraw`
4434		 * hook, in which case, plugins will not be called on `afterDatasetDraw`.
4435		 * @private
4436		 */
4437		drawDataset: function(index, easingValue) {
4438			var me = this;
4439			var meta = me.getDatasetMeta(index);
4440			var args = {
4441				meta: meta,
4442				index: index,
4443				easingValue: easingValue
4444			};
4445
4446			if (plugins.notify(me, 'beforeDatasetDraw', [args]) === false) {
4447				return;
4448			}
4449
4450			meta.controller.draw(easingValue);
4451
4452			plugins.notify(me, 'afterDatasetDraw', [args]);
4453		},
4454
4455		/**
4456		 * Draws tooltip unless a plugin returns `false` to the `beforeTooltipDraw`
4457		 * hook, in which case, plugins will not be called on `afterTooltipDraw`.
4458		 * @private
4459		 */
4460		_drawTooltip: function(easingValue) {
4461			var me = this;
4462			var tooltip = me.tooltip;
4463			var args = {
4464				tooltip: tooltip,
4465				easingValue: easingValue
4466			};
4467
4468			if (plugins.notify(me, 'beforeTooltipDraw', [args]) === false) {
4469				return;
4470			}
4471
4472			tooltip.draw();
4473
4474			plugins.notify(me, 'afterTooltipDraw', [args]);
4475		},
4476
4477		// Get the single element that was clicked on
vendor: 45,871 bytes, lines 4478-6082
4478		// @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
4479		getElementAtEvent: function(e) {
4480			return Interaction.modes.single(this, e);
4481		},
4482
4483		getElementsAtEvent: function(e) {
4484			return Interaction.modes.label(this, e, {intersect: true});
4485		},
4486
4487		getElementsAtXAxis: function(e) {
4488			return Interaction.modes['x-axis'](this, e, {intersect: true});
4489		},
4490
4491		getElementsAtEventForMode: function(e, mode, options) {
4492			var method = Interaction.modes[mode];
4493			if (typeof method === 'function') {
4494				return method(this, e, options);
4495			}
4496
4497			return [];
4498		},
4499
4500		getDatasetAtEvent: function(e) {
4501			return Interaction.modes.dataset(this, e, {intersect: true});
4502		},
4503
4504		getDatasetMeta: function(datasetIndex) {
4505			var me = this;
4506			var dataset = me.data.datasets[datasetIndex];
4507			if (!dataset._meta) {
4508				dataset._meta = {};
4509			}
4510
4511			var meta = dataset._meta[me.id];
4512			if (!meta) {
4513				meta = dataset._meta[me.id] = {
4514					type: null,
4515					data: [],
4516					dataset: null,
4517					controller: null,
4518					hidden: null,			// See isDatasetVisible() comment
4519					xAxisID: null,
4520					yAxisID: null
4521				};
4522			}
4523
4524			return meta;
4525		},
4526
4527		getVisibleDatasetCount: function() {
4528			var count = 0;
4529			for (var i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {
4530				if (this.isDatasetVisible(i)) {
4531					count++;
4532				}
4533			}
4534			return count;
4535		},
4536
4537		isDatasetVisible: function(datasetIndex) {
4538			var meta = this.getDatasetMeta(datasetIndex);
4539
4540			// meta.hidden is a per chart dataset hidden flag override with 3 states: if true or false,
4541			// the dataset.hidden value is ignored, else if null, the dataset hidden state is returned.
4542			return typeof meta.hidden === 'boolean' ? !meta.hidden : !this.data.datasets[datasetIndex].hidden;
4543		},
4544
4545		generateLegend: function() {
4546			return this.options.legendCallback(this);
4547		},
4548
4549		/**
4550		 * @private
4551		 */
4552		destroyDatasetMeta: function(datasetIndex) {
4553			var id = this.id;
4554			var dataset = this.data.datasets[datasetIndex];
4555			var meta = dataset._meta && dataset._meta[id];
4556
4557			if (meta) {
4558				meta.controller.destroy();
4559				delete dataset._meta[id];
4560			}
4561		},
4562
4563		destroy: function() {
4564			var me = this;
4565			var canvas = me.canvas;
4566			var i, ilen;
4567
4568			me.stop();
4569
4570			// dataset controllers need to cleanup associated data
4571			for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
4572				me.destroyDatasetMeta(i);
4573			}
4574
4575			if (canvas) {
4576				me.unbindEvents();
4577				helpers.canvas.clear(me);
4578				platform.releaseContext(me.ctx);
4579				me.canvas = null;
4580				me.ctx = null;
4581			}
4582
4583			plugins.notify(me, 'destroy');
4584
4585			delete Chart.instances[me.id];
4586		},
4587
4588		toBase64Image: function() {
4589			return this.canvas.toDataURL.apply(this.canvas, arguments);
4590		},
4591
4592		initToolTip: function() {
4593			var me = this;
4594			me.tooltip = new Chart.Tooltip({
4595				_chart: me,
4596				_chartInstance: me, // deprecated, backward compatibility
4597				_data: me.data,
4598				_options: me.options.tooltips
4599			}, me);
4600		},
4601
4602		/**
4603		 * @private
4604		 */
4605		bindEvents: function() {
4606			var me = this;
4607			var listeners = me._listeners = {};
4608			var listener = function() {
4609				me.eventHandler.apply(me, arguments);
4610			};
4611
4612			helpers.each(me.options.events, function(type) {
4613				platform.addEventListener(me, type, listener);
4614				listeners[type] = listener;
4615			});
4616
4617			// Elements used to detect size change should not be injected for non responsive charts.
4618			// See https://github.com/chartjs/Chart.js/issues/2210
4619			if (me.options.responsive) {
4620				listener = function() {
4621					me.resize();
4622				};
4623
4624				platform.addEventListener(me, 'resize', listener);
4625				listeners.resize = listener;
4626			}
4627		},
4628
4629		/**
4630		 * @private
4631		 */
4632		unbindEvents: function() {
4633			var me = this;
4634			var listeners = me._listeners;
4635			if (!listeners) {
4636				return;
4637			}
4638
4639			delete me._listeners;
4640			helpers.each(listeners, function(listener, type) {
4641				platform.removeEventListener(me, type, listener);
4642			});
4643		},
4644
4645		updateHoverStyle: function(elements, mode, enabled) {
4646			var method = enabled ? 'setHoverStyle' : 'removeHoverStyle';
4647			var element, i, ilen;
4648
4649			for (i = 0, ilen = elements.length; i < ilen; ++i) {
4650				element = elements[i];
4651				if (element) {
4652					this.getDatasetMeta(element._datasetIndex).controller[method](element);
4653				}
4654			}
4655		},
4656
4657		/**
4658		 * @private
4659		 */
4660		eventHandler: function(e) {
4661			var me = this;
4662			var tooltip = me.tooltip;
4663
4664			if (plugins.notify(me, 'beforeEvent', [e]) === false) {
4665				return;
4666			}
4667
4668			// Buffer any update calls so that renders do not occur
4669			me._bufferedRender = true;
4670			me._bufferedRequest = null;
4671
4672			var changed = me.handleEvent(e);
4673			// for smooth tooltip animations issue #4989
4674			// the tooltip should be the source of change
4675			// Animation check workaround:
4676			// tooltip._start will be null when tooltip isn't animating
4677			if (tooltip) {
4678				changed = tooltip._start
4679					? tooltip.handleEvent(e)
4680					: changed | tooltip.handleEvent(e);
4681			}
4682
4683			plugins.notify(me, 'afterEvent', [e]);
4684
4685			var bufferedRequest = me._bufferedRequest;
4686			if (bufferedRequest) {
4687				// If we have an update that was triggered, we need to do a normal render
4688				me.render(bufferedRequest);
4689			} else if (changed && !me.animating) {
4690				// If entering, leaving, or changing elements, animate the change via pivot
4691				me.stop();
4692
4693				// We only need to render at this point. Updating will cause scales to be
4694				// recomputed generating flicker & using more memory than necessary.
4695				me.render(me.options.hover.animationDuration, true);
4696			}
4697
4698			me._bufferedRender = false;
4699			me._bufferedRequest = null;
4700
4701			return me;
4702		},
4703
4704		/**
4705		 * Handle an event
4706		 * @private
4707		 * @param {IEvent} event the event to handle
4708		 * @return {Boolean} true if the chart needs to re-render
4709		 */
4710		handleEvent: function(e) {
4711			var me = this;
4712			var options = me.options || {};
4713			var hoverOptions = options.hover;
4714			var changed = false;
4715
4716			me.lastActive = me.lastActive || [];
4717
4718			// Find Active Elements for hover and tooltips
4719			if (e.type === 'mouseout') {
4720				me.active = [];
4721			} else {
4722				me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions);
4723			}
4724
4725			// Invoke onHover hook
4726			// Need to call with native event here to not break backwards compatibility
4727			helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me);
4728
4729			if (e.type === 'mouseup' || e.type === 'click') {
4730				if (options.onClick) {
4731					// Use e.native here for backwards compatibility
4732					options.onClick.call(me, e.native, me.active);
4733				}
4734			}
4735
4736			// Remove styling for last active (even if it may still be active)
4737			if (me.lastActive.length) {
4738				me.updateHoverStyle(me.lastActive, hoverOptions.mode, false);
4739			}
4740
4741			// Built in hover styling
4742			if (me.active.length && hoverOptions.mode) {
4743				me.updateHoverStyle(me.active, hoverOptions.mode, true);
4744			}
4745
4746			changed = !helpers.arrayEquals(me.active, me.lastActive);
4747
4748			// Remember Last Actives
4749			me.lastActive = me.active;
4750
4751			return changed;
4752		}
4753	});
4754
4755	/**
4756	 * Provided for backward compatibility, use Chart instead.
4757	 * @class Chart.Controller
4758	 * @deprecated since version 2.6.0
4759	 * @todo remove at version 3
4760	 * @private
4761	 */
4762	Chart.Controller = Chart;
4763};
4764
4765},{"25":25,"28":28,"30":30,"31":31,"45":45,"48":48}],24:[function(require,module,exports){
4766'use strict';
4767
4768var helpers = require(45);
4769
4770module.exports = function(Chart) {
4771
4772	var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];
4773
4774	/**
4775	 * Hooks the array methods that add or remove values ('push', pop', 'shift', 'splice',
4776	 * 'unshift') and notify the listener AFTER the array has been altered. Listeners are
4777	 * called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arguments.
4778	 */
4779	function listenArrayEvents(array, listener) {
4780		if (array._chartjs) {
4781			array._chartjs.listeners.push(listener);
4782			return;
4783		}
4784
4785		Object.defineProperty(array, '_chartjs', {
4786			configurable: true,
4787			enumerable: false,
4788			value: {
4789				listeners: [listener]
4790			}
4791		});
4792
4793		arrayEvents.forEach(function(key) {
4794			var method = 'onData' + key.charAt(0).toUpperCase() + key.slice(1);
4795			var base = array[key];
4796
4797			Object.defineProperty(array, key, {
4798				configurable: true,
4799				enumerable: false,
4800				value: function() {
4801					var args = Array.prototype.slice.call(arguments);
4802					var res = base.apply(this, args);
4803
4804					helpers.each(array._chartjs.listeners, function(object) {
4805						if (typeof object[method] === 'function') {
4806							object[method].apply(object, args);
4807						}
4808					});
4809
4810					return res;
4811				}
4812			});
4813		});
4814	}
4815
4816	/**
4817	 * Removes the given array event listener and cleanup extra attached properties (such as
4818	 * the _chartjs stub and overridden methods) if array doesn't have any more listeners.
4819	 */
4820	function unlistenArrayEvents(array, listener) {
4821		var stub = array._chartjs;
4822		if (!stub) {
4823			return;
4824		}
4825
4826		var listeners = stub.listeners;
4827		var index = listeners.indexOf(listener);
4828		if (index !== -1) {
4829			listeners.splice(index, 1);
4830		}
4831
4832		if (listeners.length > 0) {
4833			return;
4834		}
4835
4836		arrayEvents.forEach(function(key) {
4837			delete array[key];
4838		});
4839
4840		delete array._chartjs;
4841	}
4842
4843	// Base class for all dataset controllers (line, bar, etc)
4844	Chart.DatasetController = function(chart, datasetIndex) {
4845		this.initialize(chart, datasetIndex);
4846	};
4847
4848	helpers.extend(Chart.DatasetController.prototype, {
4849
4850		/**
4851		 * Element type used to generate a meta dataset (e.g. Chart.element.Line).
4852		 * @type {Chart.core.element}
4853		 */
4854		datasetElementType: null,
4855
4856		/**
4857		 * Element type used to generate a meta data (e.g. Chart.element.Point).
4858		 * @type {Chart.core.element}
4859		 */
4860		dataElementType: null,
4861
4862		initialize: function(chart, datasetIndex) {
4863			var me = this;
4864			me.chart = chart;
4865			me.index = datasetIndex;
4866			me.linkScales();
4867			me.addElements();
4868		},
4869
4870		updateIndex: function(datasetIndex) {
4871			this.index = datasetIndex;
4872		},
4873
4874		linkScales: function() {
4875			var me = this;
4876			var meta = me.getMeta();
4877			var dataset = me.getDataset();
4878
4879			if (meta.xAxisID === null || !(meta.xAxisID in me.chart.scales)) {
4880				meta.xAxisID = dataset.xAxisID || me.chart.options.scales.xAxes[0].id;
4881			}
4882			if (meta.yAxisID === null || !(meta.yAxisID in me.chart.scales)) {
4883				meta.yAxisID = dataset.yAxisID || me.chart.options.scales.yAxes[0].id;
4884			}
4885		},
4886
4887		getDataset: function() {
4888			return this.chart.data.datasets[this.index];
4889		},
4890
4891		getMeta: function() {
4892			return this.chart.getDatasetMeta(this.index);
4893		},
4894
4895		getScaleForId: function(scaleID) {
4896			return this.chart.scales[scaleID];
4897		},
4898
4899		reset: function() {
4900			this.update(true);
4901		},
4902
4903		/**
4904		 * @private
4905		 */
4906		destroy: function() {
4907			if (this._data) {
4908				unlistenArrayEvents(this._data, this);
4909			}
4910		},
4911
4912		createMetaDataset: function() {
4913			var me = this;
4914			var type = me.datasetElementType;
4915			return type && new type({
4916				_chart: me.chart,
4917				_datasetIndex: me.index
4918			});
4919		},
4920
4921		createMetaData: function(index) {
4922			var me = this;
4923			var type = me.dataElementType;
4924			return type && new type({
4925				_chart: me.chart,
4926				_datasetIndex: me.index,
4927				_index: index
4928			});
4929		},
4930
4931		addElements: function() {
4932			var me = this;
4933			var meta = me.getMeta();
4934			var data = me.getDataset().data || [];
4935			var metaData = meta.data;
4936			var i, ilen;
4937
4938			for (i = 0, ilen = data.length; i < ilen; ++i) {
4939				metaData[i] = metaData[i] || me.createMetaData(i);
4940			}
4941
4942			meta.dataset = meta.dataset || me.createMetaDataset();
4943		},
4944
4945		addElementAndReset: function(index) {
4946			var element = this.createMetaData(index);
4947			this.getMeta().data.splice(index, 0, element);
4948			this.updateElement(element, index, true);
4949		},
4950
4951		buildOrUpdateElements: function() {
4952			var me = this;
4953			var dataset = me.getDataset();
4954			var data = dataset.data || (dataset.data = []);
4955
4956			// In order to correctly handle data addition/deletion animation (an thus simulate
4957			// real-time charts), we need to monitor these data modifications and synchronize
4958			// the internal meta data accordingly.
4959			if (me._data !== data) {
4960				if (me._data) {
4961					// This case happens when the user replaced the data array instance.
4962					unlistenArrayEvents(me._data, me);
4963				}
4964
4965				listenArrayEvents(data, me);
4966				me._data = data;
4967			}
4968
4969			// Re-sync meta data in case the user replaced the data array or if we missed
4970			// any updates and so make sure that we handle number of datapoints changing.
4971			me.resyncElements();
4972		},
4973
4974		update: helpers.noop,
4975
4976		transition: function(easingValue) {
4977			var meta = this.getMeta();
4978			var elements = meta.data || [];
4979			var ilen = elements.length;
4980			var i = 0;
4981
4982			for (; i < ilen; ++i) {
4983				elements[i].transition(easingValue);
4984			}
4985
4986			if (meta.dataset) {
4987				meta.dataset.transition(easingValue);
4988			}
4989		},
4990
4991		draw: function() {
4992			var meta = this.getMeta();
4993			var elements = meta.data || [];
4994			var ilen = elements.length;
4995			var i = 0;
4996
4997			if (meta.dataset) {
4998				meta.dataset.draw();
4999			}
5000
5001			for (; i < ilen; ++i) {
5002				elements[i].draw();
5003			}
5004		},
5005
5006		removeHoverStyle: function(element, elementOpts) {
5007			var dataset = this.chart.data.datasets[element._datasetIndex];
5008			var index = element._index;
5009			var custom = element.custom || {};
5010			var valueOrDefault = helpers.valueAtIndexOrDefault;
5011			var model = element._model;
5012
5013			model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
5014			model.borderColor = custom.borderColor ? custom.borderColor : valueOrDefault(dataset.borderColor, index, elementOpts.borderColor);
5015			model.borderWidth = custom.borderWidth ? custom.borderWidth : valueOrDefault(dataset.borderWidth, index, elementOpts.borderWidth);
5016		},
5017
5018		setHoverStyle: function(element) {
5019			var dataset = this.chart.data.datasets[element._datasetIndex];
5020			var index = element._index;
5021			var custom = element.custom || {};
5022			var valueOrDefault = helpers.valueAtIndexOrDefault;
5023			var getHoverColor = helpers.getHoverColor;
5024			var model = element._model;
5025
5026			model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : valueOrDefault(dataset.hoverBackgroundColor, index, getHoverColor(model.backgroundColor));
5027			model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : valueOrDefault(dataset.hoverBorderColor, index, getHoverColor(model.borderColor));
5028			model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : valueOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
5029		},
5030
5031		/**
5032		 * @private
5033		 */
5034		resyncElements: function() {
5035			var me = this;
5036			var meta = me.getMeta();
5037			var data = me.getDataset().data;
5038			var numMeta = meta.data.length;
5039			var numData = data.length;
5040
5041			if (numData < numMeta) {
5042				meta.data.splice(numData, numMeta - numData);
5043			} else if (numData > numMeta) {
5044				me.insertElements(numMeta, numData - numMeta);
5045			}
5046		},
5047
5048		/**
5049		 * @private
5050		 */
5051		insertElements: function(start, count) {
5052			for (var i = 0; i < count; ++i) {
5053				this.addElementAndReset(start + i);
5054			}
5055		},
5056
5057		/**
5058		 * @private
5059		 */
5060		onDataPush: function() {
5061			this.insertElements(this.getDataset().data.length - 1, arguments.length);
5062		},
5063
5064		/**
5065		 * @private
5066		 */
5067		onDataPop: function() {
5068			this.getMeta().data.pop();
5069		},
5070
5071		/**
5072		 * @private
5073		 */
5074		onDataShift: function() {
5075			this.getMeta().data.shift();
5076		},
5077
5078		/**
5079		 * @private
5080		 */
5081		onDataSplice: function(start, count) {
5082			this.getMeta().data.splice(start, count);
5083			this.insertElements(start, arguments.length - 2);
5084		},
5085
5086		/**
5087		 * @private
5088		 */
5089		onDataUnshift: function() {
5090			this.insertElements(0, arguments.length);
5091		}
5092	});
5093
5094	Chart.DatasetController.extend = helpers.inherits;
5095};
5096
5097},{"45":45}],25:[function(require,module,exports){
5098'use strict';
5099
5100var helpers = require(45);
5101
5102module.exports = {
5103	/**
5104	 * @private
5105	 */
5106	_set: function(scope, values) {
5107		return helpers.merge(this[scope] || (this[scope] = {}), values);
5108	}
5109};
5110
5111},{"45":45}],26:[function(require,module,exports){
5112'use strict';
5113
5114var color = require(3);
5115var helpers = require(45);
5116
5117function interpolate(start, view, model, ease) {
5118	var keys = Object.keys(model);
5119	var i, ilen, key, actual, origin, target, type, c0, c1;
5120
5121	for (i = 0, ilen = keys.length; i < ilen; ++i) {
5122		key = keys[i];
5123
5124		target = model[key];
5125
5126		// if a value is added to the model after pivot() has been called, the view
5127		// doesn't contain it, so let's initialize the view to the target value.
5128		if (!view.hasOwnProperty(key)) {
5129			view[key] = target;
5130		}
5131
5132		actual = view[key];
5133
5134		if (actual === target || key[0] === '_') {
5135			continue;
5136		}
5137
5138		if (!start.hasOwnProperty(key)) {
5139			start[key] = actual;
5140		}
5141
5142		origin = start[key];
5143
5144		type = typeof target;
5145
5146		if (type === typeof origin) {
5147			if (type === 'string') {
5148				c0 = color(origin);
5149				if (c0.valid) {
5150					c1 = color(target);
5151					if (c1.valid) {
5152						view[key] = c1.mix(c0, ease).rgbString();
5153						continue;
5154					}
5155				}
5156			} else if (type === 'number' && isFinite(origin) && isFinite(target)) {
5157				view[key] = origin + (target - origin) * ease;
5158				continue;
5159			}
5160		}
5161
5162		view[key] = target;
5163	}
5164}
5165
5166var Element = function(configuration) {
5167	helpers.extend(this, configuration);
5168	this.initialize.apply(this, arguments);
5169};
5170
5171helpers.extend(Element.prototype, {
5172
5173	initialize: function() {
5174		this.hidden = false;
5175	},
5176
5177	pivot: function() {
5178		var me = this;
5179		if (!me._view) {
5180			me._view = helpers.clone(me._model);
5181		}
5182		me._start = {};
5183		return me;
5184	},
5185
5186	transition: function(ease) {
5187		var me = this;
5188		var model = me._model;
5189		var start = me._start;
5190		var view = me._view;
5191
5192		// No animation -> No Transition
5193		if (!model || ease === 1) {
5194			me._view = model;
5195			me._start = null;
5196			return me;
5197		}
5198
5199		if (!view) {
5200			view = me._view = {};
5201		}
5202
5203		if (!start) {
5204			start = me._start = {};
5205		}
5206
5207		interpolate(start, view, model, ease);
5208
5209		return me;
5210	},
5211
5212	tooltipPosition: function() {
5213		return {
5214			x: this._model.x,
5215			y: this._model.y
5216		};
5217	},
5218
5219	hasValue: function() {
5220		return helpers.isNumber(this._model.x) && helpers.isNumber(this._model.y);
5221	}
5222});
5223
5224Element.extend = helpers.inherits;
5225
5226module.exports = Element;
5227
5228},{"3":3,"45":45}],27:[function(require,module,exports){
5229/* global window: false */
5230/* global document: false */
5231'use strict';
5232
5233var color = require(3);
5234var defaults = require(25);
5235var helpers = require(45);
5236
5237module.exports = function(Chart) {
5238
5239	// -- Basic js utility methods
5240
5241	helpers.configMerge = function(/* objects ... */) {
5242		return helpers.merge(helpers.clone(arguments[0]), [].slice.call(arguments, 1), {
5243			merger: function(key, target, source, options) {
5244				var tval = target[key] || {};
5245				var sval = source[key];
5246
5247				if (key === 'scales') {
5248					// scale config merging is complex. Add our own function here for that
5249					target[key] = helpers.scaleMerge(tval, sval);
5250				} else if (key === 'scale') {
5251					// used in polar area & radar charts since there is only one scale
5252					target[key] = helpers.merge(tval, [Chart.scaleService.getScaleDefaults(sval.type), sval]);
5253				} else {
5254					helpers._merger(key, target, source, options);
5255				}
5256			}
5257		});
5258	};
5259
5260	helpers.scaleMerge = function(/* objects ... */) {
5261		return helpers.merge(helpers.clone(arguments[0]), [].slice.call(arguments, 1), {
5262			merger: function(key, target, source, options) {
5263				if (key === 'xAxes' || key === 'yAxes') {
5264					var slen = source[key].length;
5265					var i, type, scale;
5266
5267					if (!target[key]) {
5268						target[key] = [];
5269					}
5270
5271					for (i = 0; i < slen; ++i) {
5272						scale = source[key][i];
5273						type = helpers.valueOrDefault(scale.type, key === 'xAxes' ? 'category' : 'linear');
5274
5275						if (i >= target[key].length) {
5276							target[key].push({});
5277						}
5278
5279						if (!target[key][i].type || (scale.type && scale.type !== target[key][i].type)) {
5280							// new/untyped scale or type changed: let's apply the new defaults
5281							// then merge source scale to correctly overwrite the defaults.
5282							helpers.merge(target[key][i], [Chart.scaleService.getScaleDefaults(type), scale]);
5283						} else {
5284							// scales type are the same
5285							helpers.merge(target[key][i], scale);
5286						}
5287					}
5288				} else {
5289					helpers._merger(key, target, source, options);
5290				}
5291			}
5292		});
5293	};
5294
5295	helpers.where = function(collection, filterCallback) {
5296		if (helpers.isArray(collection) && Array.prototype.filter) {
5297			return collection.filter(filterCallback);
5298		}
5299		var filtered = [];
5300
5301		helpers.each(collection, function(item) {
5302			if (filterCallback(item)) {
5303				filtered.push(item);
5304			}
5305		});
5306
5307		return filtered;
5308	};
5309	helpers.findIndex = Array.prototype.findIndex ?
5310		function(array, callback, scope) {
5311			return array.findIndex(callback, scope);
5312		} :
5313		function(array, callback, scope) {
5314			scope = scope === undefined ? array : scope;
5315			for (var i = 0, ilen = array.length; i < ilen; ++i) {
5316				if (callback.call(scope, array[i], i, array)) {
5317					return i;
5318				}
5319			}
5320			return -1;
5321		};
5322	helpers.findNextWhere = function(arrayToSearch, filterCallback, startIndex) {
5323		// Default to start of the array
5324		if (helpers.isNullOrUndef(startIndex)) {
5325			startIndex = -1;
5326		}
5327		for (var i = startIndex + 1; i < arrayToSearch.length; i++) {
5328			var currentItem = arrayToSearch[i];
5329			if (filterCallback(currentItem)) {
5330				return currentItem;
5331			}
5332		}
5333	};
5334	helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex) {
5335		// Default to end of the array
5336		if (helpers.isNullOrUndef(startIndex)) {
5337			startIndex = arrayToSearch.length;
5338		}
5339		for (var i = startIndex - 1; i >= 0; i--) {
5340			var currentItem = arrayToSearch[i];
5341			if (filterCallback(currentItem)) {
5342				return currentItem;
5343			}
5344		}
5345	};
5346
5347	// -- Math methods
5348	helpers.isNumber = function(n) {
5349		return !isNaN(parseFloat(n)) && isFinite(n);
5350	};
5351	helpers.almostEquals = function(x, y, epsilon) {
5352		return Math.abs(x - y) < epsilon;
5353	};
5354	helpers.almostWhole = function(x, epsilon) {
5355		var rounded = Math.round(x);
5356		return (((rounded - epsilon) < x) && ((rounded + epsilon) > x));
5357	};
5358	helpers.max = function(array) {
5359		return array.reduce(function(max, value) {
5360			if (!isNaN(value)) {
5361				return Math.max(max, value);
5362			}
5363			return max;
5364		}, Number.NEGATIVE_INFINITY);
5365	};
5366	helpers.min = function(array) {
5367		return array.reduce(function(min, value) {
5368			if (!isNaN(value)) {
5369				return Math.min(min, value);
5370			}
5371			return min;
5372		}, Number.POSITIVE_INFINITY);
5373	};
5374	helpers.sign = Math.sign ?
5375		function(x) {
5376			return Math.sign(x);
5377		} :
5378		function(x) {
5379			x = +x; // convert to a number
5380			if (x === 0 || isNaN(x)) {
5381				return x;
5382			}
5383			return x > 0 ? 1 : -1;
5384		};
5385	helpers.log10 = Math.log10 ?
5386		function(x) {
5387			return Math.log10(x);
5388		} :
5389		function(x) {
5390			var exponent = Math.log(x) * Math.LOG10E; // Math.LOG10E = 1 / Math.LN10.
5391			// Check for whole powers of 10,
5392			// which due to floating point rounding error should be corrected.
5393			var powerOf10 = Math.round(exponent);
5394			var isPowerOf10 = x === Math.pow(10, powerOf10);
5395
5396			return isPowerOf10 ? powerOf10 : exponent;
5397		};
5398	helpers.toRadians = function(degrees) {
5399		return degrees * (Math.PI / 180);
5400	};
5401	helpers.toDegrees = function(radians) {
5402		return radians * (180 / Math.PI);
5403	};
5404	// Gets the angle from vertical upright to the point about a centre.
5405	helpers.getAngleFromPoint = function(centrePoint, anglePoint) {
5406		var distanceFromXCenter = anglePoint.x - centrePoint.x;
5407		var distanceFromYCenter = anglePoint.y - centrePoint.y;
5408		var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);
5409
5410		var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);
5411
5412		if (angle < (-0.5 * Math.PI)) {
5413			angle += 2.0 * Math.PI; // make sure the returned angle is in the range of (-PI/2, 3PI/2]
5414		}
5415
5416		return {
5417			angle: angle,
5418			distance: radialDistanceFromCenter
5419		};
5420	};
5421	helpers.distanceBetweenPoints = function(pt1, pt2) {
5422		return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));
5423	};
5424	helpers.aliasPixel = function(pixelWidth) {
5425		return (pixelWidth % 2 === 0) ? 0 : 0.5;
5426	};
5427	helpers.splineCurve = function(firstPoint, middlePoint, afterPoint, t) {
5428		// Props to Rob Spencer at scaled innovation for his post on splining between points
5429		// http://scaledinnovation.com/analytics/splines/aboutSplines.html
5430
5431		// This function must also respect "skipped" points
5432
5433		var previous = firstPoint.skip ? middlePoint : firstPoint;
5434		var current = middlePoint;
5435		var next = afterPoint.skip ? middlePoint : afterPoint;
5436
5437		var d01 = Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(current.y - previous.y, 2));
5438		var d12 = Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y - current.y, 2));
5439
5440		var s01 = d01 / (d01 + d12);
5441		var s12 = d12 / (d01 + d12);
5442
5443		// If all points are the same, s01 & s02 will be inf
5444		s01 = isNaN(s01) ? 0 : s01;
5445		s12 = isNaN(s12) ? 0 : s12;
5446
5447		var fa = t * s01; // scaling factor for triangle Ta
5448		var fb = t * s12;
5449
5450		return {
5451			previous: {
5452				x: current.x - fa * (next.x - previous.x),
5453				y: current.y - fa * (next.y - previous.y)
5454			},
5455			next: {
5456				x: current.x + fb * (next.x - previous.x),
5457				y: current.y + fb * (next.y - previous.y)
5458			}
5459		};
5460	};
5461	helpers.EPSILON = Number.EPSILON || 1e-14;
5462	helpers.splineCurveMonotone = function(points) {
5463		// This function calculates Bézier control points in a similar way than |splineCurve|,
5464		// but preserves monotonicity of the provided data and ensures no local extremums are added
5465		// between the dataset discrete points due to the interpolation.
5466		// See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
5467
5468		var pointsWithTangents = (points || []).map(function(point) {
5469			return {
5470				model: point._model,
5471				deltaK: 0,
5472				mK: 0
5473			};
5474		});
5475
5476		// Calculate slopes (deltaK) and initialize tangents (mK)
5477		var pointsLen = pointsWithTangents.length;
5478		var i, pointBefore, pointCurrent, pointAfter;
5479		for (i = 0; i < pointsLen; ++i) {
5480			pointCurrent = pointsWithTangents[i];
5481			if (pointCurrent.model.skip) {
5482				continue;
5483			}
5484
5485			pointBefore = i > 0 ? pointsWithTangents[i - 1] : null;
5486			pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;
5487			if (pointAfter && !pointAfter.model.skip) {
5488				var slopeDeltaX = (pointAfter.model.x - pointCurrent.model.x);
5489
5490				// In the case of two points that appear at the same x pixel, slopeDeltaX is 0
5491				pointCurrent.deltaK = slopeDeltaX !== 0 ? (pointAfter.model.y - pointCurrent.model.y) / slopeDeltaX : 0;
5492			}
5493
5494			if (!pointBefore || pointBefore.model.skip) {
5495				pointCurrent.mK = pointCurrent.deltaK;
5496			} else if (!pointAfter || pointAfter.model.skip) {
5497				pointCurrent.mK = pointBefore.deltaK;
5498			} else if (this.sign(pointBefore.deltaK) !== this.sign(pointCurrent.deltaK)) {
5499				pointCurrent.mK = 0;
5500			} else {
5501				pointCurrent.mK = (pointBefore.deltaK + pointCurrent.deltaK) / 2;
5502			}
5503		}
5504
5505		// Adjust tangents to ensure monotonic properties
5506		var alphaK, betaK, tauK, squaredMagnitude;
5507		for (i = 0; i < pointsLen - 1; ++i) {
5508			pointCurrent = pointsWithTangents[i];
5509			pointAfter = pointsWithTangents[i + 1];
5510			if (pointCurrent.model.skip || pointAfter.model.skip) {
5511				continue;
5512			}
5513
5514			if (helpers.almostEquals(pointCurrent.deltaK, 0, this.EPSILON)) {
5515				pointCurrent.mK = pointAfter.mK = 0;
5516				continue;
5517			}
5518
5519			alphaK = pointCurrent.mK / pointCurrent.deltaK;
5520			betaK = pointAfter.mK / pointCurrent.deltaK;
5521			squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);
5522			if (squaredMagnitude <= 9) {
5523				continue;
5524			}
5525
5526			tauK = 3 / Math.sqrt(squaredMagnitude);
5527			pointCurrent.mK = alphaK * tauK * pointCurrent.deltaK;
5528			pointAfter.mK = betaK * tauK * pointCurrent.deltaK;
5529		}
5530
5531		// Compute control points
5532		var deltaX;
5533		for (i = 0; i < pointsLen; ++i) {
5534			pointCurrent = pointsWithTangents[i];
5535			if (pointCurrent.model.skip) {
5536				continue;
5537			}
5538
5539			pointBefore = i > 0 ? pointsWithTangents[i - 1] : null;
5540			pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;
5541			if (pointBefore && !pointBefore.model.skip) {
5542				deltaX = (pointCurrent.model.x - pointBefore.model.x) / 3;
5543				pointCurrent.model.controlPointPreviousX = pointCurrent.model.x - deltaX;
5544				pointCurrent.model.controlPointPreviousY = pointCurrent.model.y - deltaX * pointCurrent.mK;
5545			}
5546			if (pointAfter && !pointAfter.model.skip) {
5547				deltaX = (pointAfter.model.x - pointCurrent.model.x) / 3;
5548				pointCurrent.model.controlPointNextX = pointCurrent.model.x + deltaX;
5549				pointCurrent.model.controlPointNextY = pointCurrent.model.y + deltaX * pointCurrent.mK;
5550			}
5551		}
5552	};
5553	helpers.nextItem = function(collection, index, loop) {
5554		if (loop) {
5555			return index >= collection.length - 1 ? collection[0] : collection[index + 1];
5556		}
5557		return index >= collection.length - 1 ? collection[collection.length - 1] : collection[index + 1];
5558	};
5559	helpers.previousItem = function(collection, index, loop) {
5560		if (loop) {
5561			return index <= 0 ? collection[collection.length - 1] : collection[index - 1];
5562		}
5563		return index <= 0 ? collection[0] : collection[index - 1];
5564	};
5565	// Implementation of the nice number algorithm used in determining where axis labels will go
5566	helpers.niceNum = function(range, round) {
5567		var exponent = Math.floor(helpers.log10(range));
5568		var fraction = range / Math.pow(10, exponent);
5569		var niceFraction;
5570
5571		if (round) {
5572			if (fraction < 1.5) {
5573				niceFraction = 1;
5574			} else if (fraction < 3) {
5575				niceFraction = 2;
5576			} else if (fraction < 7) {
5577				niceFraction = 5;
5578			} else {
5579				niceFraction = 10;
5580			}
5581		} else if (fraction <= 1.0) {
5582			niceFraction = 1;
5583		} else if (fraction <= 2) {
5584			niceFraction = 2;
5585		} else if (fraction <= 5) {
5586			niceFraction = 5;
5587		} else {
5588			niceFraction = 10;
5589		}
5590
5591		return niceFraction * Math.pow(10, exponent);
5592	};
5593	// Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
5594	helpers.requestAnimFrame = (function() {
5595		if (typeof window === 'undefined') {
5596			return function(callback) {
5597				callback();
5598			};
5599		}
5600		return window.requestAnimationFrame ||
5601			window.webkitRequestAnimationFrame ||
5602			window.mozRequestAnimationFrame ||
5603			window.oRequestAnimationFrame ||
5604			window.msRequestAnimationFrame ||
5605			function(callback) {
5606				return window.setTimeout(callback, 1000 / 60);
5607			};
5608	}());
5609	// -- DOM methods
5610	helpers.getRelativePosition = function(evt, chart) {
5611		var mouseX, mouseY;
5612		var e = evt.originalEvent || evt;
5613		var canvas = evt.currentTarget || evt.srcElement;
5614		var boundingRect = canvas.getBoundingClientRect();
5615
5616		var touches = e.touches;
5617		if (touches && touches.length > 0) {
5618			mouseX = touches[0].clientX;
5619			mouseY = touches[0].clientY;
5620
5621		} else {
5622			mouseX = e.clientX;
5623			mouseY = e.clientY;
5624		}
5625
5626		// Scale mouse coordinates into canvas coordinates
5627		// by following the pattern laid out by 'jerryj' in the comments of
5628		// http://www.html5canvastutorials.com/advanced/html5-canvas-mouse-coordinates/
5629		var paddingLeft = parseFloat(helpers.getStyle(canvas, 'padding-left'));
5630		var paddingTop = parseFloat(helpers.getStyle(canvas, 'padding-top'));
5631		var paddingRight = parseFloat(helpers.getStyle(canvas, 'padding-right'));
5632		var paddingBottom = parseFloat(helpers.getStyle(canvas, 'padding-bottom'));
5633		var width = boundingRect.right - boundingRect.left - paddingLeft - paddingRight;
5634		var height = boundingRect.bottom - boundingRect.top - paddingTop - paddingBottom;
5635
5636		// We divide by the current device pixel ratio, because the canvas is scaled up by that amount in each direction. However
5637		// the backend model is in unscaled coordinates. Since we are going to deal with our model coordinates, we go back here
5638		mouseX = Math.round((mouseX - boundingRect.left - paddingLeft) / (width) * canvas.width / chart.currentDevicePixelRatio);
5639		mouseY = Math.round((mouseY - boundingRect.top - paddingTop) / (height) * canvas.height / chart.currentDevicePixelRatio);
5640
5641		return {
5642			x: mouseX,
5643			y: mouseY
5644		};
5645
5646	};
5647
5648	// Private helper function to convert max-width/max-height values that may be percentages into a number
5649	function parseMaxStyle(styleValue, node, parentProperty) {
5650		var valueInPixels;
5651		if (typeof styleValue === 'string') {
5652			valueInPixels = parseInt(styleValue, 10);
5653
5654			if (styleValue.indexOf('%') !== -1) {
5655				// percentage * size in dimension
5656				valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];
5657			}
5658		} else {
5659			valueInPixels = styleValue;
5660		}
5661
5662		return valueInPixels;
5663	}
5664
5665	/**
5666	 * Returns if the given value contains an effective constraint.
5667	 * @private
5668	 */
5669	function isConstrainedValue(value) {
5670		return value !== undefined && value !== null && value !== 'none';
5671	}
5672
5673	// Private helper to get a constraint dimension
5674	// @param domNode : the node to check the constraint on
5675	// @param maxStyle : the style that defines the maximum for the direction we are using (maxWidth / maxHeight)
5676	// @param percentageProperty : property of parent to use when calculating width as a percentage
5677	// @see http://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser
5678	function getConstraintDimension(domNode, maxStyle, percentageProperty) {
5679		var view = document.defaultView;
5680		var parentNode = domNode.parentNode;
5681		var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
5682		var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
5683		var hasCNode = isConstrainedValue(constrainedNode);
5684		var hasCContainer = isConstrainedValue(constrainedContainer);
5685		var infinity = Number.POSITIVE_INFINITY;
5686
5687		if (hasCNode || hasCContainer) {
5688			return Math.min(
5689				hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity,
5690				hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
5691		}
5692
5693		return 'none';
5694	}
5695	// returns Number or undefined if no constraint
5696	helpers.getConstraintWidth = function(domNode) {
5697		return getConstraintDimension(domNode, 'max-width', 'clientWidth');
5698	};
5699	// returns Number or undefined if no constraint
5700	helpers.getConstraintHeight = function(domNode) {
5701		return getConstraintDimension(domNode, 'max-height', 'clientHeight');
5702	};
5703	helpers.getMaximumWidth = function(domNode) {
5704		var container = domNode.parentNode;
5705		if (!container) {
5706			return domNode.clientWidth;
5707		}
5708
5709		var paddingLeft = parseInt(helpers.getStyle(container, 'padding-left'), 10);
5710		var paddingRight = parseInt(helpers.getStyle(container, 'padding-right'), 10);
5711		var w = container.clientWidth - paddingLeft - paddingRight;
5712		var cw = helpers.getConstraintWidth(domNode);
5713		return isNaN(cw) ? w : Math.min(w, cw);
5714	};
5715	helpers.getMaximumHeight = function(domNode) {
5716		var container = domNode.parentNode;
5717		if (!container) {
5718			return domNode.clientHeight;
5719		}
5720
5721		var paddingTop = parseInt(helpers.getStyle(container, 'padding-top'), 10);
5722		var paddingBottom = parseInt(helpers.getStyle(container, 'padding-bottom'), 10);
5723		var h = container.clientHeight - paddingTop - paddingBottom;
5724		var ch = helpers.getConstraintHeight(domNode);
5725		return isNaN(ch) ? h : Math.min(h, ch);
5726	};
5727	helpers.getStyle = function(el, property) {
5728		return el.currentStyle ?
5729			el.currentStyle[property] :
5730			document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
5731	};
5732	helpers.retinaScale = function(chart, forceRatio) {
5733		var pixelRatio = chart.currentDevicePixelRatio = forceRatio || window.devicePixelRatio || 1;
5734		if (pixelRatio === 1) {
5735			return;
5736		}
5737
5738		var canvas = chart.canvas;
5739		var height = chart.height;
5740		var width = chart.width;
5741
5742		canvas.height = height * pixelRatio;
5743		canvas.width = width * pixelRatio;
5744		chart.ctx.scale(pixelRatio, pixelRatio);
5745
5746		// If no style has been set on the canvas, the render size is used as display size,
5747		// making the chart visually bigger, so let's enforce it to the "correct" values.
5748		// See https://github.com/chartjs/Chart.js/issues/3575
5749		if (!canvas.style.height && !canvas.style.width) {
5750			canvas.style.height = height + 'px';
5751			canvas.style.width = width + 'px';
5752		}
5753	};
5754	// -- Canvas methods
5755	helpers.fontString = function(pixelSize, fontStyle, fontFamily) {
5756		return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
5757	};
5758	helpers.longestText = function(ctx, font, arrayOfThings, cache) {
5759		cache = cache || {};
5760		var data = cache.data = cache.data || {};
5761		var gc = cache.garbageCollect = cache.garbageCollect || [];
5762
5763		if (cache.font !== font) {
5764			data = cache.data = {};
5765			gc = cache.garbageCollect = [];
5766			cache.font = font;
5767		}
5768
5769		ctx.font = font;
5770		var longest = 0;
5771		helpers.each(arrayOfThings, function(thing) {
5772			// Undefined strings and arrays should not be measured
5773			if (thing !== undefined && thing !== null && helpers.isArray(thing) !== true) {
5774				longest = helpers.measureText(ctx, data, gc, longest, thing);
5775			} else if (helpers.isArray(thing)) {
5776				// if it is an array lets measure each element
5777				// to do maybe simplify this function a bit so we can do this more recursively?
5778				helpers.each(thing, function(nestedThing) {
5779					// Undefined strings and arrays should not be measured
5780					if (nestedThing !== undefined && nestedThing !== null && !helpers.isArray(nestedThing)) {
5781						longest = helpers.measureText(ctx, data, gc, longest, nestedThing);
5782					}
5783				});
5784			}
5785		});
5786
5787		var gcLen = gc.length / 2;
5788		if (gcLen > arrayOfThings.length) {
5789			for (var i = 0; i < gcLen; i++) {
5790				delete data[gc[i]];
5791			}
5792			gc.splice(0, gcLen);
5793		}
5794		return longest;
5795	};
5796	helpers.measureText = function(ctx, data, gc, longest, string) {
5797		var textWidth = data[string];
5798		if (!textWidth) {
5799			textWidth = data[string] = ctx.measureText(string).width;
5800			gc.push(string);
5801		}
5802		if (textWidth > longest) {
5803			longest = textWidth;
5804		}
5805		return longest;
5806	};
5807	helpers.numberOfLabelLines = function(arrayOfThings) {
5808		var numberOfLines = 1;
5809		helpers.each(arrayOfThings, function(thing) {
5810			if (helpers.isArray(thing)) {
5811				if (thing.length > numberOfLines) {
5812					numberOfLines = thing.length;
5813				}
5814			}
5815		});
5816		return numberOfLines;
5817	};
5818
5819	helpers.color = !color ?
5820		function(value) {
5821			console.error('Color.js not found!');
5822			return value;
5823		} :
5824		function(value) {
5825			/* global CanvasGradient */
5826			if (value instanceof CanvasGradient) {
5827				value = defaults.global.defaultColor;
5828			}
5829
5830			return color(value);
5831		};
5832
5833	helpers.getHoverColor = function(colorValue) {
5834		/* global CanvasPattern */
5835		return (colorValue instanceof CanvasPattern) ?
5836			colorValue :
5837			helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString();
5838	};
5839};
5840
5841},{"25":25,"3":3,"45":45}],28:[function(require,module,exports){
5842'use strict';
5843
5844var helpers = require(45);
5845
5846/**
5847 * Helper function to get relative position for an event
5848 * @param {Event|IEvent} event - The event to get the position for
5849 * @param {Chart} chart - The chart
5850 * @returns {Point} the event position
5851 */
5852function getRelativePosition(e, chart) {
5853	if (e.native) {
5854		return {
5855			x: e.x,
5856			y: e.y
5857		};
5858	}
5859
5860	return helpers.getRelativePosition(e, chart);
5861}
5862
5863/**
5864 * Helper function to traverse all of the visible elements in the chart
5865 * @param chart {chart} the chart
5866 * @param handler {Function} the callback to execute for each visible item
5867 */
5868function parseVisibleItems(chart, handler) {
5869	var datasets = chart.data.datasets;
5870	var meta, i, j, ilen, jlen;
5871
5872	for (i = 0, ilen = datasets.length; i < ilen; ++i) {
5873		if (!chart.isDatasetVisible(i)) {
5874			continue;
5875		}
5876
5877		meta = chart.getDatasetMeta(i);
5878		for (j = 0, jlen = meta.data.length; j < jlen; ++j) {
5879			var element = meta.data[j];
5880			if (!element._view.skip) {
5881				handler(element);
5882			}
5883		}
5884	}
5885}
5886
5887/**
5888 * Helper function to get the items that intersect the event position
5889 * @param items {ChartElement[]} elements to filter
5890 * @param position {Point} the point to be nearest to
5891 * @return {ChartElement[]} the nearest items
5892 */
5893function getIntersectItems(chart, position) {
5894	var elements = [];
5895
5896	parseVisibleItems(chart, function(element) {
5897		if (element.inRange(position.x, position.y)) {
5898			elements.push(element);
5899		}
5900	});
5901
5902	return elements;
5903}
5904
5905/**
5906 * Helper function to get the items nearest to the event position considering all visible items in teh chart
5907 * @param chart {Chart} the chart to look at elements from
5908 * @param position {Point} the point to be nearest to
5909 * @param intersect {Boolean} if true, only consider items that intersect the position
5910 * @param distanceMetric {Function} function to provide the distance between points
5911 * @return {ChartElement[]} the nearest items
5912 */
5913function getNearestItems(chart, position, intersect, distanceMetric) {
5914	var minDistance = Number.POSITIVE_INFINITY;
5915	var nearestItems = [];
5916
5917	parseVisibleItems(chart, function(element) {
5918		if (intersect && !element.inRange(position.x, position.y)) {
5919			return;
5920		}
5921
5922		var center = element.getCenterPoint();
5923		var distance = distanceMetric(position, center);
5924
5925		if (distance < minDistance) {
5926			nearestItems = [element];
5927			minDistance = distance;
5928		} else if (distance === minDistance) {
5929			// Can have multiple items at the same distance in which case we sort by size
5930			nearestItems.push(element);
5931		}
5932	});
5933
5934	return nearestItems;
5935}
5936
5937/**
5938 * Get a distance metric function for two points based on the
5939 * axis mode setting
5940 * @param {String} axis the axis mode. x|y|xy
5941 */
5942function getDistanceMetricForAxis(axis) {
5943	var useX = axis.indexOf('x') !== -1;
5944	var useY = axis.indexOf('y') !== -1;
5945
5946	return function(pt1, pt2) {
5947		var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
5948		var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
5949		return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
5950	};
5951}
5952
5953function indexMode(chart, e, options) {
5954	var position = getRelativePosition(e, chart);
5955	// Default axis for index mode is 'x' to match old behaviour
5956	options.axis = options.axis || 'x';
5957	var distanceMetric = getDistanceMetricForAxis(options.axis);
5958	var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric);
5959	var elements = [];
5960
5961	if (!items.length) {
5962		return [];
5963	}
5964
5965	chart.data.datasets.forEach(function(dataset, datasetIndex) {
5966		if (chart.isDatasetVisible(datasetIndex)) {
5967			var meta = chart.getDatasetMeta(datasetIndex);
5968			var element = meta.data[items[0]._index];
5969
5970			// don't count items that are skipped (null data)
5971			if (element && !element._view.skip) {
5972				elements.push(element);
5973			}
5974		}
5975	});
5976
5977	return elements;
5978}
5979
5980/**
5981 * @interface IInteractionOptions
5982 */
5983/**
5984 * If true, only consider items that intersect the point
5985 * @name IInterfaceOptions#boolean
5986 * @type Boolean
5987 */
5988
5989/**
5990 * Contains interaction related functions
5991 * @namespace Chart.Interaction
5992 */
5993module.exports = {
5994	// Helper function for different modes
5995	modes: {
5996		single: function(chart, e) {
5997			var position = getRelativePosition(e, chart);
5998			var elements = [];
5999
6000			parseVisibleItems(chart, function(element) {
6001				if (element.inRange(position.x, position.y)) {
6002					elements.push(element);
6003					return elements;
6004				}
6005			});
6006
6007			return elements.slice(0, 1);
6008		},
6009
6010		/**
6011		 * @function Chart.Interaction.modes.label
6012		 * @deprecated since version 2.4.0
6013		 * @todo remove at version 3
6014		 * @private
6015		 */
6016		label: indexMode,
6017
6018		/**
6019		 * Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
6020		 * If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
6021		 * @function Chart.Interaction.modes.index
6022		 * @since v2.4.0
6023		 * @param chart {chart} the chart we are returning items from
6024		 * @param e {Event} the event we are find things at
6025		 * @param options {IInteractionOptions} options to use during interaction
6026		 * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
6027		 */
6028		index: indexMode,
6029
6030		/**
6031		 * Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something
6032		 * If the options.intersect is false, we find the nearest item and return the items in that dataset
6033		 * @function Chart.Interaction.modes.dataset
6034		 * @param chart {chart} the chart we are returning items from
6035		 * @param e {Event} the event we are find things at
6036		 * @param options {IInteractionOptions} options to use during interaction
6037		 * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
6038		 */
6039		dataset: function(chart, e, options) {
6040			var position = getRelativePosition(e, chart);
6041			options.axis = options.axis || 'xy';
6042			var distanceMetric = getDistanceMetricForAxis(options.axis);
6043			var items = options.intersect ? getIntersectItems(chart, position) : getNearestItems(chart, position, false, distanceMetric);
6044
6045			if (items.length > 0) {
6046				items = chart.getDatasetMeta(items[0]._datasetIndex).data;
6047			}
6048
6049			return items;
6050		},
6051
6052		/**
6053		 * @function Chart.Interaction.modes.x-axis
6054		 * @deprecated since version 2.4.0. Use index mode and intersect == true
6055		 * @todo remove at version 3
6056		 * @private
6057		 */
6058		'x-axis': function(chart, e) {
6059			return indexMode(chart, e, {intersect: false});
6060		},
6061
6062		/**
6063		 * Point mode returns all elements that hit test based on the event position
6064		 * of the event
6065		 * @function Chart.Interaction.modes.intersect
6066		 * @param chart {chart} the chart we are returning items from
6067		 * @param e {Event} the event we are find things at
6068		 * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
6069		 */
6070		point: function(chart, e) {
6071			var position = getRelativePosition(e, chart);
6072			return getIntersectItems(chart, position);
6073		},
6074
6075		/**
6076		 * nearest mode returns the element closest to the point
6077		 * @function Chart.Interaction.modes.intersect
6078		 * @param chart {chart} the chart we are returning items from
6079		 * @param e {Event} the event we are find things at
6080		 * @param options {IInteractionOptions} options to use
6081		 * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
6082		 */
6083		nearest: function(chart, e, options) {
6084			var position = getRelativePosition(e, chart);
6085			options.axis = options.axis || 'xy';
6086			var distanceMetric = getDistanceMetricForAxis(options.axis);
6087			var nearestItems = getNearestItems(chart, position, options.intersect, distanceMetric);
6088
6089			// We have multiple items at the same distance from the event. Now sort by smallest
6090			if (nearestItems.length > 1) {
6091				nearestItems.sort(function(a, b) {
6092					var sizeA = a.getArea();
6093					var sizeB = b.getArea();
6094					var ret = sizeA - sizeB;
6095
6096					if (ret === 0) {
6097						// if equal sort by dataset index
6098						ret = a._datasetIndex - b._datasetIndex;
6099					}
6100
6101					return ret;
6102				});
6103			}
6104
6105			// Return only 1 item
6106			return nearestItems.slice(0, 1);
6107		},
6108
6109		/**
6110		 * x mode returns the elements that hit-test at the current x coordinate
6111		 * @function Chart.Interaction.modes.x
6112		 * @param chart {chart} the chart we are returning items from
6113		 * @param e {Event} the event we are find things at
6114		 * @param options {IInteractionOptions} options to use
6115		 * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
6116		 */
6117		x: function(chart, e, options) {
6118			var position = getRelativePosition(e, chart);
6119			var items = [];
6120			var intersectsItem = false;
6121
6122			parseVisibleItems(chart, function(element) {
6123				if (element.inXRange(position.x)) {
6124					items.push(element);
6125				}
6126
6127				if (element.inRange(position.x, position.y)) {
6128					intersectsItem = true;
6129				}
6130			});
6131
6132			// If we want to trigger on an intersect and we don't have any items
6133			// that intersect the position, return nothing
6134			if (options.intersect && !intersectsItem) {
6135				items = [];
6136			}
6137			return items;
6138		},
6139
6140		/**
6141		 * y mode returns the elements that hit-test at the current y coordinate
6142		 * @function Chart.Interaction.modes.y
6143		 * @param chart {chart} the chart we are returning items from
6144		 * @param e {Event} the event we are find things at
6145		 * @param options {IInteractionOptions} options to use
6146		 * @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
6147		 */
6148		y: function(chart, e, options) {
6149			var position = getRelativePosition(e, chart);
6150			var items = [];
6151			var intersectsItem = false;
6152
6153			parseVisibleItems(chart, function(element) {
6154				if (element.inYRange(position.y)) {
6155					items.push(element);
6156				}
6157
6158				if (element.inRange(position.x, position.y)) {
6159					intersectsItem = true;
6160				}
6161			});
6162
6163			// If we want to trigger on an intersect and we don't have any items
6164			// that intersect the position, return nothing
6165			if (options.intersect && !intersectsItem) {
6166				items = [];
6167			}
6168			return items;
6169		}
6170	}
6171};
6172
6173},{"45":45}],29:[function(require,module,exports){
6174'use strict';
6175
6176var defaults = require(25);
6177
6178defaults._set('global', {
6179	responsive: true,
6180	responsiveAnimationDuration: 0,
6181	maintainAspectRatio: true,
6182	events: ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'],
6183	hover: {
6184		onHover: null,
6185		mode: 'nearest',
6186		intersect: true,
6187		animationDuration: 400
6188	},
6189	onClick: null,
6190	defaultColor: 'rgba(0,0,0,0.1)',
6191	defaultFontColor: '#666',
6192	defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
6193	defaultFontSize: 12,
6194	defaultFontStyle: 'normal',
6195	showLines: true,
6196
6197	// Element defaults defined in element extensions
6198	elements: {},
6199
6200	// Layout options such as padding
6201	layout: {
6202		padding: {
6203			top: 0,
6204			right: 0,
6205			bottom: 0,
6206			left: 0
6207		}
6208	}
6209});
6210
6211module.exports = function() {
6212
6213	// Occupy the global variable of Chart, and create a simple base class
6214	var Chart = function(item, config) {
6215		this.construct(item, config);
6216		return this;
6217	};
6218
6219	Chart.Chart = Chart;
6220
6221	return Chart;
6222};
6223
6224},{"25":25}],30:[function(require,module,exports){
6225'use strict';
6226
6227var helpers = require(45);
6228
6229function filterByPosition(array, position) {
6230	return helpers.where(array, function(v) {
6231		return v.position === position;
6232	});
6233}
6234
6235function sortByWeight(array, reverse) {
6236	array.forEach(function(v, i) {
6237		v._tmpIndex_ = i;
6238		return v;
6239	});
6240	array.sort(function(a, b) {
6241		var v0 = reverse ? b : a;
6242		var v1 = reverse ? a : b;
6243		return v0.weight === v1.weight ?
6244			v0._tmpIndex_ - v1._tmpIndex_ :
6245			v0.weight - v1.weight;
6246	});
6247	array.forEach(function(v) {
6248		delete v._tmpIndex_;
6249	});
6250}
6251
6252/**
6253 * @interface ILayoutItem
6254 * @prop {String} position - The position of the item in the chart layout. Possible values are
6255 * 'left', 'top', 'right', 'bottom', and 'chartArea'
6256 * @prop {Number} weight - The weight used to sort the item. Higher weights are further away from the chart area
6257 * @prop {Boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down
6258 * @prop {Function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom)
6259 * @prop {Function} update - Takes two parameters: width and height. Returns size of item
6260 * @prop {Function} getPadding -  Returns an object with padding on the edges
6261 * @prop {Number} width - Width of item. Must be valid after update()
6262 * @prop {Number} height - Height of item. Must be valid after update()
6263 * @prop {Number} left - Left edge of the item. Set by layout system and cannot be used in update
6264 * @prop {Number} top - Top edge of the item. Set by layout system and cannot be used in update
6265 * @prop {Number} right - Right edge of the item. Set by layout system and cannot be used in update
6266 * @prop {Number} bottom - Bottom edge of the item. Set by layout system and cannot be used in update
6267 */
6268
6269// The layout service is very self explanatory.  It's responsible for the layout within a chart.
6270// Scales, Legends and Plugins all rely on the layout service and can easily register to be placed anywhere they need
6271// It is this service's responsibility of carrying out that layout.
6272module.exports = {
6273	defaults: {},
6274
6275	/**
6276	 * Register a box to a chart.
6277	 * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
6278	 * @param {Chart} chart - the chart to use
6279	 * @param {ILayoutItem} item - the item to add to be layed out
6280	 */
6281	addBox: function(chart, item) {
6282		if (!chart.boxes) {
6283			chart.boxes = [];
6284		}
6285
6286		// initialize item with default values
6287		item.fullWidth = item.fullWidth || false;
6288		item.position = item.position || 'top';
6289		item.weight = item.weight || 0;
6290
6291		chart.boxes.push(item);
6292	},
6293
6294	/**
6295	 * Remove a layoutItem from a chart
6296	 * @param {Chart} chart - the chart to remove the box from
6297	 * @param {Object} layoutItem - the item to remove from the layout
6298	 */
6299	removeBox: function(chart, layoutItem) {
6300		var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;
6301		if (index !== -1) {
6302			chart.boxes.splice(index, 1);
6303		}
6304	},
6305
6306	/**
6307	 * Sets (or updates) options on the given `item`.
6308	 * @param {Chart} chart - the chart in which the item lives (or will be added to)
6309	 * @param {Object} item - the item to configure with the given options
6310	 * @param {Object} options - the new item options.
6311	 */
6312	configure: function(chart, item, options) {
6313		var props = ['fullWidth', 'position', 'weight'];
6314		var ilen = props.length;
6315		var i = 0;
6316		var prop;
6317
6318		for (; i < ilen; ++i) {
6319			prop = props[i];
6320			if (options.hasOwnProperty(prop)) {
6321				item[prop] = options[prop];
6322			}
6323		}
6324	},
6325
6326	/**
6327	 * Fits boxes of the given chart into the given size by having each box measure itself
6328	 * then running a fitting algorithm
6329	 * @param {Chart} chart - the chart
6330	 * @param {Number} width - the width to fit into
6331	 * @param {Number} height - the height to fit into
6332	 */
6333	update: function(chart, width, height) {
6334		if (!chart) {
6335			return;
6336		}
6337
6338		var layoutOptions = chart.options.layout || {};
6339		var padding = helpers.options.toPadding(layoutOptions.padding);
6340		var leftPadding = padding.left;
6341		var rightPadding = padding.right;
6342		var topPadding = padding.top;
6343		var bottomPadding = padding.bottom;
6344
6345		var leftBoxes = filterByPosition(chart.boxes, 'left');
6346		var rightBoxes = filterByPosition(chart.boxes, 'right');
6347		var topBoxes = filterByPosition(chart.boxes, 'top');
6348		var bottomBoxes = filterByPosition(chart.boxes, 'bottom');
6349		var chartAreaBoxes = filterByPosition(chart.boxes, 'chartArea');
6350
6351		// Sort boxes by weight. A higher weight is further away from the chart area
6352		sortByWeight(leftBoxes, true);
6353		sortByWeight(rightBoxes, false);
6354		sortByWeight(topBoxes, true);
6355		sortByWeight(bottomBoxes, false);
6356
6357		// Essentially we now have any number of boxes on each of the 4 sides.
6358		// Our canvas looks like the following.
6359		// The areas L1 and L2 are the left axes. R1 is the right axis, T1 is the top axis and
6360		// B1 is the bottom axis
6361		// There are also 4 quadrant-like locations (left to right instead of clockwise) reserved for chart overlays
6362		// These locations are single-box locations only, when trying to register a chartArea location that is already taken,
6363		// an error will be thrown.
6364		//
6365		// |----------------------------------------------------|
6366		// |                  T1 (Full Width)                   |
6367		// |----------------------------------------------------|
6368		// |    |    |                 T2                  |    |
6369		// |    |----|-------------------------------------|----|
6370		// |    |    | C1 |                           | C2 |    |
6371		// |    |    |----|                           |----|    |
6372		// |    |    |                                     |    |
6373		// | L1 | L2 |           ChartArea (C0)            | R1 |
6374		// |    |    |                                     |    |
6375		// |    |    |----|                           |----|    |
6376		// |    |    | C3 |                           | C4 |    |
6377		// |    |----|-------------------------------------|----|
6378		// |    |    |                 B1                  |    |
6379		// |----------------------------------------------------|
6380		// |                  B2 (Full Width)                   |
6381		// |----------------------------------------------------|
6382		//
6383		// What we do to find the best sizing, we do the following
6384		// 1. Determine the minimum size of the chart area.
6385		// 2. Split the remaining width equally between each vertical axis
6386		// 3. Split the remaining height equally between each horizontal axis
6387		// 4. Give each layout the maximum size it can be. The layout will return it's minimum size
6388		// 5. Adjust the sizes of each axis based on it's minimum reported size.
6389		// 6. Refit each axis
6390		// 7. Position each axis in the final location
6391		// 8. Tell the chart the final location of the chart area
6392		// 9. Tell any axes that overlay the chart area the positions of the chart area
6393
6394		// Step 1
6395		var chartWidth = width - leftPadding - rightPadding;
6396		var chartHeight = height - topPadding - bottomPadding;
6397		var chartAreaWidth = chartWidth / 2; // min 50%
6398		var chartAreaHeight = chartHeight / 2; // min 50%
6399
6400		// Step 2
6401		var verticalBoxWidth = (width - chartAreaWidth) / (leftBoxes.length + rightBoxes.length);
6402
6403		// Step 3
6404		var horizontalBoxHeight = (height - chartAreaHeight) / (topBoxes.length + bottomBoxes.length);
6405
6406		// Step 4
6407		var maxChartAreaWidth = chartWidth;
6408		var maxChartAreaHeight = chartHeight;
6409		var minBoxSizes = [];
6410
6411		function getMinimumBoxSize(box) {
6412			var minSize;
6413			var isHorizontal = box.isHorizontal();
6414
6415			if (isHorizontal) {
6416				minSize = box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, horizontalBoxHeight);
6417				maxChartAreaHeight -= minSize.height;
6418			} else {
6419				minSize = box.update(verticalBoxWidth, maxChartAreaHeight);
6420				maxChartAreaWidth -= minSize.width;
6421			}
6422
6423			minBoxSizes.push({
6424				horizontal: isHorizontal,
6425				minSize: minSize,
6426				box: box,
6427			});
6428		}
6429
6430		helpers.each(leftBoxes.concat(rightBoxes, topBoxes, bottomBoxes), getMinimumBoxSize);
6431
6432		// If a horizontal box has padding, we move the left boxes over to avoid ugly charts (see issue #2478)
6433		var maxHorizontalLeftPadding = 0;
6434		var maxHorizontalRightPadding = 0;
6435		var maxVerticalTopPadding = 0;
6436		var maxVerticalBottomPadding = 0;
6437
6438		helpers.each(topBoxes.concat(bottomBoxes), function(horizontalBox) {
6439			if (horizontalBox.getPadding) {
6440				var boxPadding = horizontalBox.getPadding();
6441				maxHorizontalLeftPadding = Math.max(maxHorizontalLeftPadding, boxPadding.left);
6442				maxHorizontalRightPadding = Math.max(maxHorizontalRightPadding, boxPadding.right);
6443			}
6444		});
6445
6446		helpers.each(leftBoxes.concat(rightBoxes), function(verticalBox) {
6447			if (verticalBox.getPadding) {
6448				var boxPadding = verticalBox.getPadding();
6449				maxVerticalTopPadding = Math.max(maxVerticalTopPadding, boxPadding.top);
6450				maxVerticalBottomPadding = Math.max(maxVerticalBottomPadding, boxPadding.bottom);
6451			}
6452		});
6453
6454		// At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could
6455		// be if the axes are drawn at their minimum sizes.
6456		// Steps 5 & 6
6457		var totalLeftBoxesWidth = leftPadding;
6458		var totalRightBoxesWidth = rightPadding;
6459		var totalTopBoxesHeight = topPadding;
6460		var totalBottomBoxesHeight = bottomPadding;
6461
6462		// Function to fit a box
6463		function fitBox(box) {
6464			var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minBox) {
6465				return minBox.box === box;
6466			});
6467
6468			if (minBoxSize) {
6469				if (box.isHorizontal()) {
6470					var scaleMargin = {
6471						left: Math.max(totalLeftBoxesWidth, maxHorizontalLeftPadding),
6472						right: Math.max(totalRightBoxesWidth, maxHorizontalRightPadding),
6473						top: 0,
6474						bottom: 0
6475					};
6476
6477					// Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
6478					// on the margin. Sometimes they need to increase in size slightly
6479					box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, chartHeight / 2, scaleMargin);
6480				} else {
6481					box.update(minBoxSize.minSize.width, maxChartAreaHeight);
6482				}
6483			}
6484		}
6485
6486		// Update, and calculate the left and right margins for the horizontal boxes
6487		helpers.each(leftBoxes.concat(rightBoxes), fitBox);
6488
6489		helpers.each(leftBoxes, function(box) {
6490			totalLeftBoxesWidth += box.width;
6491		});
6492
6493		helpers.each(rightBoxes, function(box) {
6494			totalRightBoxesWidth += box.width;
6495		});
6496
6497		// Set the Left and Right margins for the horizontal boxes
6498		helpers.each(topBoxes.concat(bottomBoxes), fitBox);
6499
6500		// Figure out how much margin is on the top and bottom of the vertical boxes
6501		helpers.each(topBoxes, function(box) {
6502			totalTopBoxesHeight += box.height;
6503		});
6504
6505		helpers.each(bottomBoxes, function(box) {
6506			totalBottomBoxesHeight += box.height;
6507		});
6508
6509		function finalFitVerticalBox(box) {
6510			var minBoxSize = helpers.findNextWhere(minBoxSizes, function(minSize) {
6511				return minSize.box === box;
6512			});
6513
6514			var scaleMargin = {
6515				left: 0,
6516				right: 0,
6517				top: totalTopBoxesHeight,
6518				bottom: totalBottomBoxesHeight
6519			};
6520
6521			if (minBoxSize) {
6522				box.update(minBoxSize.minSize.width, maxChartAreaHeight, scaleMargin);
6523			}
6524		}
6525
6526		// Let the left layout know the final margin
6527		helpers.each(leftBoxes.concat(rightBoxes), finalFitVerticalBox);
6528
6529		// Recalculate because the size of each layout might have changed slightly due to the margins (label rotation for instance)
6530		totalLeftBoxesWidth = leftPadding;
6531		totalRightBoxesWidth = rightPadding;
6532		totalTopBoxesHeight = topPadding;
6533		totalBottomBoxesHeight = bottomPadding;
6534
6535		helpers.each(leftBoxes, function(box) {
6536			totalLeftBoxesWidth += box.width;
6537		});
6538
6539		helpers.each(rightBoxes, function(box) {
6540			totalRightBoxesWidth += box.width;
6541		});
6542
6543		helpers.each(topBoxes, function(box) {
6544			totalTopBoxesHeight += box.height;
6545		});
6546		helpers.each(bottomBoxes, function(box) {
6547			totalBottomBoxesHeight += box.height;
6548		});
6549
6550		// We may be adding some padding to account for rotated x axis labels
6551		var leftPaddingAddition = Math.max(maxHorizontalLeftPadding - totalLeftBoxesWidth, 0);
6552		totalLeftBoxesWidth += leftPaddingAddition;
6553		totalRightBoxesWidth += Math.max(maxHorizontalRightPadding - totalRightBoxesWidth, 0);
6554
6555		var topPaddingAddition = Math.max(maxVerticalTopPadding - totalTopBoxesHeight, 0);
6556		totalTopBoxesHeight += topPaddingAddition;
6557		totalBottomBoxesHeight += Math.max(maxVerticalBottomPadding - totalBottomBoxesHeight, 0);
6558
6559		// Figure out if our chart area changed. This would occur if the dataset layout label rotation
6560		// changed due to the application of the margins in step 6. Since we can only get bigger, this is safe to do
6561		// without calling `fit` again
6562		var newMaxChartAreaHeight = height - totalTopBoxesHeight - totalBottomBoxesHeight;
6563		var newMaxChartAreaWidth = width - totalLeftBoxesWidth - totalRightBoxesWidth;
6564
6565		if (newMaxChartAreaWidth !== maxChartAreaWidth || newMaxChartAreaHeight !== maxChartAreaHeight) {
6566			helpers.each(leftBoxes, function(box) {
6567				box.height = newMaxChartAreaHeight;
6568			});
6569
6570			helpers.each(rightBoxes, function(box) {
6571				box.height = newMaxChartAreaHeight;
6572			});
6573
6574			helpers.each(topBoxes, function(box) {
6575				if (!box.fullWidth) {
6576					box.width = newMaxChartAreaWidth;
6577				}
6578			});
6579
6580			helpers.each(bottomBoxes, function(box) {
6581				if (!box.fullWidth) {
6582					box.width = newMaxChartAreaWidth;
6583				}
6584			});
6585
6586			maxChartAreaHeight = newMaxChartAreaHeight;
6587			maxChartAreaWidth = newMaxChartAreaWidth;
6588		}
6589
6590		// Step 7 - Position the boxes
6591		var left = leftPadding + leftPaddingAddition;
6592		var top = topPadding + topPaddingAddition;
6593
6594		function placeBox(box) {
6595			if (box.isHorizontal()) {
6596				box.left = box.fullWidth ? leftPadding : totalLeftBoxesWidth;
6597				box.right = box.fullWidth ? width - rightPadding : totalLeftBoxesWidth + maxChartAreaWidth;
6598				box.top = top;
6599				box.bottom = top + box.height;
6600
6601				// Move to next point
6602				top = box.bottom;
6603
6604			} else {
6605
6606				box.left = left;
6607				box.right = left + box.width;
vendor: 13,547 bytes, lines 6608-7007
6608				box.top = totalTopBoxesHeight;
6609				box.bottom = totalTopBoxesHeight + maxChartAreaHeight;
6610
6611				// Move to next point
6612				left = box.right;
6613			}
6614		}
6615
6616		helpers.each(leftBoxes.concat(topBoxes), placeBox);
6617
6618		// Account for chart width and height
6619		left += maxChartAreaWidth;
6620		top += maxChartAreaHeight;
6621
6622		helpers.each(rightBoxes, placeBox);
6623		helpers.each(bottomBoxes, placeBox);
6624
6625		// Step 8
6626		chart.chartArea = {
6627			left: totalLeftBoxesWidth,
6628			top: totalTopBoxesHeight,
6629			right: totalLeftBoxesWidth + maxChartAreaWidth,
6630			bottom: totalTopBoxesHeight + maxChartAreaHeight
6631		};
6632
6633		// Step 9
6634		helpers.each(chartAreaBoxes, function(box) {
6635			box.left = chart.chartArea.left;
6636			box.top = chart.chartArea.top;
6637			box.right = chart.chartArea.right;
6638			box.bottom = chart.chartArea.bottom;
6639
6640			box.update(maxChartAreaWidth, maxChartAreaHeight);
6641		});
6642	}
6643};
6644
6645},{"45":45}],31:[function(require,module,exports){
6646'use strict';
6647
6648var defaults = require(25);
6649var helpers = require(45);
6650
6651defaults._set('global', {
6652	plugins: {}
6653});
6654
6655/**
6656 * The plugin service singleton
6657 * @namespace Chart.plugins
6658 * @since 2.1.0
6659 */
6660module.exports = {
6661	/**
6662	 * Globally registered plugins.
6663	 * @private
6664	 */
6665	_plugins: [],
6666
6667	/**
6668	 * This identifier is used to invalidate the descriptors cache attached to each chart
6669	 * when a global plugin is registered or unregistered. In this case, the cache ID is
6670	 * incremented and descriptors are regenerated during following API calls.
6671	 * @private
6672	 */
6673	_cacheId: 0,
6674
6675	/**
6676	 * Registers the given plugin(s) if not already registered.
6677	 * @param {Array|Object} plugins plugin instance(s).
6678	 */
6679	register: function(plugins) {
6680		var p = this._plugins;
6681		([]).concat(plugins).forEach(function(plugin) {
6682			if (p.indexOf(plugin) === -1) {
6683				p.push(plugin);
6684			}
6685		});
6686
6687		this._cacheId++;
6688	},
6689
6690	/**
6691	 * Unregisters the given plugin(s) only if registered.
6692	 * @param {Array|Object} plugins plugin instance(s).
6693	 */
6694	unregister: function(plugins) {
6695		var p = this._plugins;
6696		([]).concat(plugins).forEach(function(plugin) {
6697			var idx = p.indexOf(plugin);
6698			if (idx !== -1) {
6699				p.splice(idx, 1);
6700			}
6701		});
6702
6703		this._cacheId++;
6704	},
6705
6706	/**
6707	 * Remove all registered plugins.
6708	 * @since 2.1.5
6709	 */
6710	clear: function() {
6711		this._plugins = [];
6712		this._cacheId++;
6713	},
6714
6715	/**
6716	 * Returns the number of registered plugins?
6717	 * @returns {Number}
6718	 * @since 2.1.5
6719	 */
6720	count: function() {
6721		return this._plugins.length;
6722	},
6723
6724	/**
6725	 * Returns all registered plugin instances.
6726	 * @returns {Array} array of plugin objects.
6727	 * @since 2.1.5
6728	 */
6729	getAll: function() {
6730		return this._plugins;
6731	},
6732
6733	/**
6734	 * Calls enabled plugins for `chart` on the specified hook and with the given args.
6735	 * This method immediately returns as soon as a plugin explicitly returns false. The
6736	 * returned value can be used, for instance, to interrupt the current action.
6737	 * @param {Object} chart - The chart instance for which plugins should be called.
6738	 * @param {String} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
6739	 * @param {Array} [args] - Extra arguments to apply to the hook call.
6740	 * @returns {Boolean} false if any of the plugins return false, else returns true.
6741	 */
6742	notify: function(chart, hook, args) {
6743		var descriptors = this.descriptors(chart);
6744		var ilen = descriptors.length;
6745		var i, descriptor, plugin, params, method;
6746
6747		for (i = 0; i < ilen; ++i) {
6748			descriptor = descriptors[i];
6749			plugin = descriptor.plugin;
6750			method = plugin[hook];
6751			if (typeof method === 'function') {
6752				params = [chart].concat(args || []);
6753				params.push(descriptor.options);
6754				if (method.apply(plugin, params) === false) {
6755					return false;
6756				}
6757			}
6758		}
6759
6760		return true;
6761	},
6762
6763	/**
6764	 * Returns descriptors of enabled plugins for the given chart.
6765	 * @returns {Array} [{ plugin, options }]
6766	 * @private
6767	 */
6768	descriptors: function(chart) {
6769		var cache = chart.$plugins || (chart.$plugins = {});
6770		if (cache.id === this._cacheId) {
6771			return cache.descriptors;
6772		}
6773
6774		var plugins = [];
6775		var descriptors = [];
6776		var config = (chart && chart.config) || {};
6777		var options = (config.options && config.options.plugins) || {};
6778
6779		this._plugins.concat(config.plugins || []).forEach(function(plugin) {
6780			var idx = plugins.indexOf(plugin);
6781			if (idx !== -1) {
6782				return;
6783			}
6784
6785			var id = plugin.id;
6786			var opts = options[id];
6787			if (opts === false) {
6788				return;
6789			}
6790
6791			if (opts === true) {
6792				opts = helpers.clone(defaults.global.plugins[id]);
6793			}
6794
6795			plugins.push(plugin);
6796			descriptors.push({
6797				plugin: plugin,
6798				options: opts || {}
6799			});
6800		});
6801
6802		cache.descriptors = descriptors;
6803		cache.id = this._cacheId;
6804		return descriptors;
6805	},
6806
6807	/**
6808	 * Invalidates cache for the given chart: descriptors hold a reference on plugin option,
6809	 * but in some cases, this reference can be changed by the user when updating options.
6810	 * https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167
6811	 * @private
6812	 */
6813	_invalidate: function(chart) {
6814		delete chart.$plugins;
6815	}
6816};
6817
6818/**
6819 * Plugin extension hooks.
6820 * @interface IPlugin
6821 * @since 2.1.0
6822 */
6823/**
6824 * @method IPlugin#beforeInit
6825 * @desc Called before initializing `chart`.
6826 * @param {Chart.Controller} chart - The chart instance.
6827 * @param {Object} options - The plugin options.
6828 */
6829/**
6830 * @method IPlugin#afterInit
6831 * @desc Called after `chart` has been initialized and before the first update.
6832 * @param {Chart.Controller} chart - The chart instance.
6833 * @param {Object} options - The plugin options.
6834 */
6835/**
6836 * @method IPlugin#beforeUpdate
6837 * @desc Called before updating `chart`. If any plugin returns `false`, the update
6838 * is cancelled (and thus subsequent render(s)) until another `update` is triggered.
6839 * @param {Chart.Controller} chart - The chart instance.
6840 * @param {Object} options - The plugin options.
6841 * @returns {Boolean} `false` to cancel the chart update.
6842 */
6843/**
6844 * @method IPlugin#afterUpdate
6845 * @desc Called after `chart` has been updated and before rendering. Note that this
6846 * hook will not be called if the chart update has been previously cancelled.
6847 * @param {Chart.Controller} chart - The chart instance.
6848 * @param {Object} options - The plugin options.
6849 */
6850/**
6851 * @method IPlugin#beforeDatasetsUpdate
6852 * @desc Called before updating the `chart` datasets. If any plugin returns `false`,
6853 * the datasets update is cancelled until another `update` is triggered.
6854 * @param {Chart.Controller} chart - The chart instance.
6855 * @param {Object} options - The plugin options.
6856 * @returns {Boolean} false to cancel the datasets update.
6857 * @since version 2.1.5
6858*/
6859/**
6860 * @method IPlugin#afterDatasetsUpdate
6861 * @desc Called after the `chart` datasets have been updated. Note that this hook
6862 * will not be called if the datasets update has been previously cancelled.
6863 * @param {Chart.Controller} chart - The chart instance.
6864 * @param {Object} options - The plugin options.
6865 * @since version 2.1.5
6866 */
6867/**
6868 * @method IPlugin#beforeDatasetUpdate
6869 * @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
6870 * returns `false`, the datasets update is cancelled until another `update` is triggered.
6871 * @param {Chart} chart - The chart instance.
6872 * @param {Object} args - The call arguments.
6873 * @param {Number} args.index - The dataset index.
6874 * @param {Object} args.meta - The dataset metadata.
6875 * @param {Object} options - The plugin options.
6876 * @returns {Boolean} `false` to cancel the chart datasets drawing.
6877 */
6878/**
6879 * @method IPlugin#afterDatasetUpdate
6880 * @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
6881 * that this hook will not be called if the datasets update has been previously cancelled.
6882 * @param {Chart} chart - The chart instance.
6883 * @param {Object} args - The call arguments.
6884 * @param {Number} args.index - The dataset index.
6885 * @param {Object} args.meta - The dataset metadata.
6886 * @param {Object} options - The plugin options.
6887 */
6888/**
6889 * @method IPlugin#beforeLayout
6890 * @desc Called before laying out `chart`. If any plugin returns `false`,
6891 * the layout update is cancelled until another `update` is triggered.
6892 * @param {Chart.Controller} chart - The chart instance.
6893 * @param {Object} options - The plugin options.
6894 * @returns {Boolean} `false` to cancel the chart layout.
6895 */
6896/**
6897 * @method IPlugin#afterLayout
6898 * @desc Called after the `chart` has been layed out. Note that this hook will not
6899 * be called if the layout update has been previously cancelled.
6900 * @param {Chart.Controller} chart - The chart instance.
6901 * @param {Object} options - The plugin options.
6902 */
6903/**
6904 * @method IPlugin#beforeRender
6905 * @desc Called before rendering `chart`. If any plugin returns `false`,
6906 * the rendering is cancelled until another `render` is triggered.
6907 * @param {Chart.Controller} chart - The chart instance.
6908 * @param {Object} options - The plugin options.
6909 * @returns {Boolean} `false` to cancel the chart rendering.
6910 */
6911/**
6912 * @method IPlugin#afterRender
6913 * @desc Called after the `chart` has been fully rendered (and animation completed). Note
6914 * that this hook will not be called if the rendering has been previously cancelled.
6915 * @param {Chart.Controller} chart - The chart instance.
6916 * @param {Object} options - The plugin options.
6917 */
6918/**
6919 * @method IPlugin#beforeDraw
6920 * @desc Called before drawing `chart` at every animation frame specified by the given
6921 * easing value. If any plugin returns `false`, the frame drawing is cancelled until
6922 * another `render` is triggered.
6923 * @param {Chart.Controller} chart - The chart instance.
6924 * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
6925 * @param {Object} options - The plugin options.
6926 * @returns {Boolean} `false` to cancel the chart drawing.
6927 */
6928/**
6929 * @method IPlugin#afterDraw
6930 * @desc Called after the `chart` has been drawn for the specific easing value. Note
6931 * that this hook will not be called if the drawing has been previously cancelled.
6932 * @param {Chart.Controller} chart - The chart instance.
6933 * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
6934 * @param {Object} options - The plugin options.
6935 */
6936/**
6937 * @method IPlugin#beforeDatasetsDraw
6938 * @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
6939 * the datasets drawing is cancelled until another `render` is triggered.
6940 * @param {Chart.Controller} chart - The chart instance.
6941 * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
6942 * @param {Object} options - The plugin options.
6943 * @returns {Boolean} `false` to cancel the chart datasets drawing.
6944 */
6945/**
6946 * @method IPlugin#afterDatasetsDraw
6947 * @desc Called after the `chart` datasets have been drawn. Note that this hook
6948 * will not be called if the datasets drawing has been previously cancelled.
6949 * @param {Chart.Controller} chart - The chart instance.
6950 * @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
6951 * @param {Object} options - The plugin options.
6952 */
6953/**
6954 * @method IPlugin#beforeDatasetDraw
6955 * @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
6956 * are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
6957 * is cancelled until another `render` is triggered.
6958 * @param {Chart} chart - The chart instance.
6959 * @param {Object} args - The call arguments.
6960 * @param {Number} args.index - The dataset index.
6961 * @param {Object} args.meta - The dataset metadata.
6962 * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
6963 * @param {Object} options - The plugin options.
6964 * @returns {Boolean} `false` to cancel the chart datasets drawing.
6965 */
6966/**
6967 * @method IPlugin#afterDatasetDraw
6968 * @desc Called after the `chart` datasets at the given `args.index` have been drawn
6969 * (datasets are drawn in the reverse order). Note that this hook will not be called
6970 * if the datasets drawing has been previously cancelled.
6971 * @param {Chart} chart - The chart instance.
6972 * @param {Object} args - The call arguments.
6973 * @param {Number} args.index - The dataset index.
6974 * @param {Object} args.meta - The dataset metadata.
6975 * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
6976 * @param {Object} options - The plugin options.
6977 */
6978/**
6979 * @method IPlugin#beforeTooltipDraw
6980 * @desc Called before drawing the `tooltip`. If any plugin returns `false`,
6981 * the tooltip drawing is cancelled until another `render` is triggered.
6982 * @param {Chart} chart - The chart instance.
6983 * @param {Object} args - The call arguments.
6984 * @param {Object} args.tooltip - The tooltip.
6985 * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
6986 * @param {Object} options - The plugin options.
6987 * @returns {Boolean} `false` to cancel the chart tooltip drawing.
6988 */
6989/**
6990 * @method IPlugin#afterTooltipDraw
6991 * @desc Called after drawing the `tooltip`. Note that this hook will not
6992 * be called if the tooltip drawing has been previously cancelled.
6993 * @param {Chart} chart - The chart instance.
6994 * @param {Object} args - The call arguments.
6995 * @param {Object} args.tooltip - The tooltip.
6996 * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
6997 * @param {Object} options - The plugin options.
6998 */
6999/**
7000 * @method IPlugin#beforeEvent
7001 * @desc Called before processing the specified `event`. If any plugin returns `false`,
7002 * the event will be discarded.
7003 * @param {Chart.Controller} chart - The chart instance.
7004 * @param {IEvent} event - The event object.
7005 * @param {Object} options - The plugin options.
7006 */
7007/**
7008 * @method IPlugin#afterEvent
7009 * @desc Called after the `event` has been consumed. Note that this hook
7010 * will not be called if the `event` has been previously discarded.
7011 * @param {Chart.Controller} chart - The chart instance.
7012 * @param {IEvent} event - The event object.
7013 * @param {Object} options - The plugin options.
7014 */
7015/**
7016 * @method IPlugin#resize
7017 * @desc Called after the chart as been resized.
7018 * @param {Chart.Controller} chart - The chart instance.
7019 * @param {Number} size - The new canvas display size (eq. canvas.style width & height).
7020 * @param {Object} options - The plugin options.
7021 */
7022/**
7023 * @method IPlugin#destroy
7024 * @desc Called after the chart as been destroyed.
7025 * @param {Chart.Controller} chart - The chart instance.
7026 * @param {Object} options - The plugin options.
7027 */
7028
7029},{"25":25,"45":45}],32:[function(require,module,exports){
7030'use strict';
7031
7032var defaults = require(25);
7033var Element = require(26);
7034var helpers = require(45);
7035var Ticks = require(34);
7036
7037defaults._set('scale', {
7038	display: true,
7039	position: 'left',
7040	offset: false,
7041
7042	// grid line settings
7043	gridLines: {
7044		display: true,
7045		color: 'rgba(0, 0, 0, 0.1)',
7046		lineWidth: 1,
7047		drawBorder: true,
7048		drawOnChartArea: true,
7049		drawTicks: true,
7050		tickMarkLength: 10,
7051		zeroLineWidth: 1,
7052		zeroLineColor: 'rgba(0,0,0,0.25)',
7053		zeroLineBorderDash: [],
7054		zeroLineBorderDashOffset: 0.0,
7055		offsetGridLines: false,
7056		borderDash: [],
7057		borderDashOffset: 0.0
7058	},
7059
7060	// scale label
7061	scaleLabel: {
7062		// display property
7063		display: false,
7064
7065		// actual label
7066		labelString: '',
7067
7068		// line height
7069		lineHeight: 1.2,
7070
7071		// top/bottom padding
7072		padding: {
7073			top: 4,
7074			bottom: 4
7075		}
7076	},
7077
7078	// label settings
7079	ticks: {
7080		beginAtZero: false,
7081		minRotation: 0,
7082		maxRotation: 50,
7083		mirror: false,
7084		padding: 0,
7085		reverse: false,
7086		display: true,
7087		autoSkip: true,
7088		autoSkipPadding: 0,
7089		labelOffset: 0,
7090		// We pass through arrays to be rendered as multiline labels, we convert Others to strings here.
7091		callback: Ticks.formatters.values,
7092		minor: {},
7093		major: {}
7094	}
7095});
7096
7097function labelsFromTicks(ticks) {
7098	var labels = [];
7099	var i, ilen;
7100
7101	for (i = 0, ilen = ticks.length; i < ilen; ++i) {
7102		labels.push(ticks[i].label);
7103	}
7104
7105	return labels;
7106}
7107
7108function getLineValue(scale, index, offsetGridLines) {
7109	var lineValue = scale.getPixelForTick(index);
7110
7111	if (offsetGridLines) {
7112		if (index === 0) {
7113			lineValue -= (scale.getPixelForTick(1) - lineValue) / 2;
7114		} else {
7115			lineValue -= (lineValue - scale.getPixelForTick(index - 1)) / 2;
7116		}
7117	}
7118	return lineValue;
7119}
7120
7121module.exports = function(Chart) {
7122
7123	function computeTextSize(context, tick, font) {
7124		return helpers.isArray(tick) ?
7125			helpers.longestText(context, font, tick) :
7126			context.measureText(tick).width;
7127	}
7128
7129	function parseFontOptions(options) {
7130		var valueOrDefault = helpers.valueOrDefault;
7131		var globalDefaults = defaults.global;
7132		var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
7133		var style = valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle);
7134		var family = valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily);
7135
7136		return {
7137			size: size,
7138			style: style,
7139			family: family,
7140			font: helpers.fontString(size, style, family)
7141		};
7142	}
7143
7144	function parseLineHeight(options) {
7145		return helpers.options.toLineHeight(
7146			helpers.valueOrDefault(options.lineHeight, 1.2),
7147			helpers.valueOrDefault(options.fontSize, defaults.global.defaultFontSize));
7148	}
7149
7150	Chart.Scale = Element.extend({
7151		/**
7152		 * Get the padding needed for the scale
7153		 * @method getPadding
7154		 * @private
7155		 * @returns {Padding} the necessary padding
7156		 */
7157		getPadding: function() {
7158			var me = this;
7159			return {
7160				left: me.paddingLeft || 0,
7161				top: me.paddingTop || 0,
7162				right: me.paddingRight || 0,
7163				bottom: me.paddingBottom || 0
7164			};
7165		},
7166
7167		/**
7168		 * Returns the scale tick objects ({label, major})
7169		 * @since 2.7
7170		 */
7171		getTicks: function() {
7172			return this._ticks;
7173		},
7174
7175		// These methods are ordered by lifecyle. Utilities then follow.
7176		// Any function defined here is inherited by all scale types.
7177		// Any function can be extended by the scale type
7178
7179		mergeTicksOptions: function() {
7180			var ticks = this.options.ticks;
7181			if (ticks.minor === false) {
7182				ticks.minor = {
7183					display: false
7184				};
7185			}
7186			if (ticks.major === false) {
7187				ticks.major = {
7188					display: false
7189				};
7190			}
7191			for (var key in ticks) {
7192				if (key !== 'major' && key !== 'minor') {
7193					if (typeof ticks.minor[key] === 'undefined') {
7194						ticks.minor[key] = ticks[key];
7195					}
7196					if (typeof ticks.major[key] === 'undefined') {
7197						ticks.major[key] = ticks[key];
7198					}
7199				}
7200			}
7201		},
7202		beforeUpdate: function() {
7203			helpers.callback(this.options.beforeUpdate, [this]);
7204		},
7205		update: function(maxWidth, maxHeight, margins) {
7206			var me = this;
7207			var i, ilen, labels, label, ticks, tick;
7208
7209			// Update Lifecycle - Probably don't want to ever extend or over
vendor: 4,385 bytes, lines 7209-7369
7209write this function ;)
7210			me.beforeUpdate();
7211
7212			// Absorb the master measurements
7213			me.maxWidth = maxWidth;
7214			me.maxHeight = maxHeight;
7215			me.margins = helpers.extend({
7216				left: 0,
7217				right: 0,
7218				top: 0,
7219				bottom: 0
7220			}, margins);
7221			me.longestTextCache = me.longestTextCache || {};
7222
7223			// Dimensions
7224			me.beforeSetDimensions();
7225			me.setDimensions();
7226			me.afterSetDimensions();
7227
7228			// Data min/max
7229			me.beforeDataLimits();
7230			me.determineDataLimits();
7231			me.afterDataLimits();
7232
7233			// Ticks - `this.ticks` is now DEPRECATED!
7234			// Internal ticks are now stored as objects in the PRIVATE `this._ticks` member
7235			// and must not be accessed directly from outside this class. `this.ticks` being
7236			// around for long time and not marked as private, we can't change its structure
7237			// without unexpected breaking changes. If you need to access the scale ticks,
7238			// use scale.getTicks() instead.
7239
7240			me.beforeBuildTicks();
7241
7242			// New implementations should return an array of objects but for BACKWARD COMPAT,
7243			// we still support no return (`this.ticks` internally set by calling this method).
7244			ticks = me.buildTicks() || [];
7245
7246			me.afterBuildTicks();
7247
7248			me.beforeTickToLabelConversion();
7249
7250			// New implementations should return the formatted tick labels but for BACKWARD
7251			// COMPAT, we still support no return (`this.ticks` internally changed by calling
7252			// this method and supposed to contain only string values).
7253			labels = me.convertTicksToLabels(ticks) || me.ticks;
7254
7255			me.afterTickToLabelConversion();
7256
7257			me.ticks = labels;   // BACKWARD COMPATIBILITY
7258
7259			// IMPORTANT: from this point, we consider that `this.ticks` will NEVER change!
7260
7261			// BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `this.ticks`)
7262			for (i = 0, ilen = labels.length; i < ilen; ++i) {
7263				label = labels[i];
7264				tick = ticks[i];
7265				if (!tick) {
7266					ticks.push(tick = {
7267						label: label,
7268						major: false
7269					});
7270				} else {
7271					tick.label = label;
7272				}
7273			}
7274
7275			me._ticks = ticks;
7276
7277			// Tick Rotation
7278			me.beforeCalculateTickRotation();
7279			me.calculateTickRotation();
7280			me.afterCalculateTickRotation();
7281			// Fit
7282			me.beforeFit();
7283			me.fit();
7284			me.afterFit();
7285			//
7286			me.afterUpdate();
7287
7288			return me.minSize;
7289
7290		},
7291		afterUpdate: function() {
7292			helpers.callback(this.options.afterUpdate, [this]);
7293		},
7294
7295		//
7296
7297		beforeSetDimensions: function() {
7298			helpers.callback(this.options.beforeSetDimensions, [this]);
7299		},
7300		setDimensions: function() {
7301			var me = this;
7302			// Set the unconstrained dimension before label rotation
7303			if (me.isHorizontal()) {
7304				// Reset position before calculating rotation
7305				me.width = me.maxWidth;
7306				me.left = 0;
7307				me.right = me.width;
7308			} else {
7309				me.height = me.maxHeight;
7310
7311				// Reset position before calculating rotation
7312				me.top = 0;
7313				me.bottom = me.height;
7314			}
7315
7316			// Reset padding
7317			me.paddingLeft = 0;
7318			me.paddingTop = 0;
7319			me.paddingRight = 0;
7320			me.paddingBottom = 0;
7321		},
7322		afterSetDimensions: function() {
7323			helpers.callback(this.options.afterSetDimensions, [this]);
7324		},
7325
7326		// Data limits
7327		beforeDataLimits: function() {
7328			helpers.callback(this.options.beforeDataLimits, [this]);
7329		},
7330		determineDataLimits: helpers.noop,
7331		afterDataLimits: function() {
7332			helpers.callback(this.options.afterDataLimits, [this]);
7333		},
7334
7335		//
7336		beforeBuildTicks: function() {
7337			helpers.callback(this.options.beforeBuildTicks, [this]);
7338		},
7339		buildTicks: helpers.noop,
7340		afterBuildTicks: function() {
7341			helpers.callback(this.options.afterBuildTicks, [this]);
7342		},
7343
7344		beforeTickToLabelConversion: function() {
7345			helpers.callback(this.options.beforeTickToLabelConversion, [this]);
7346		},
7347		convertTicksToLabels: function() {
7348			var me = this;
7349			// Convert ticks to strings
7350			var tickOpts = me.options.ticks;
7351			me.ticks = me.ticks.map(tickOpts.userCallback || tickOpts.callback, this);
7352		},
7353		afterTickToLabelConversion: function() {
7354			helpers.callback(this.options.afterTickToLabelConversion, [this]);
7355		},
7356
7357		//
7358
7359		beforeCalculateTickRotation: function() {
7360			helpers.callback(this.options.beforeCalculateTickRotation, [this]);
7361		},
7362		calculateTickRotation: function() {
7363			var me = this;
7364			var context = me.ctx;
7365			var tickOpts = me.options.ticks;
7366			var labels = labelsFromTicks(me._ticks);
7367
7368			// Get the width of each grid by calculating the difference
7369			// between x offsets between 0 and 1.
7370			var tickFont = parseFontOptions(tickOpts);
7371			context.font = tickFont.font;
7372
7373			var labelRotation = tickOpts.minRotation || 0;
7374
7375			if (labels.length && me.options.display && me.isHorizontal()) {
7376				var originalLabelWidth = helpers.longestText(context, tickFont.font, labels, me.longestTextCache);
7377				var labelWidth = originalLabelWidth;
7378				var cosRotation, sinRotation;
7379
7380				// Allow 3 pixels x2 padding either side for label readability
7381				var tickWidth = me.getPixelForTick(1) - me.getPixelForTick(0) - 6;
7382
7383				// Max label rotation can be set or default to 90 - also act as a loop counter
7384				while (labelWidth > tickWidth && labelRotation < tickOpts.maxRotation) {
7385					var angleRadians = helpers.toRadians(labelRotation);
7386					cosRotation = Math.cos(angleRadians);
7387					sinRotation = Math.sin(angleRadians);
7388
7389					if (sinRotation * originalLabelWidth > me.maxHeight) {
7390						// go back one step
7391						labelRotation--;
7392						break;
7393					}
7394
7395					labelRotation++;
7396					labelWidth = cosRotation * originalLabelWidth;
7397				}
7398			}
7399
7400			me.labelRotation = labelRotation;
7401		},
7402		afterCalculateTickRotation: function() {
7403			helpers.callback(this.options.afterCalculateTickRotation, [this]);
7404		},
7405
7406		//
7407
7408		beforeFit: function() {
7409			helpers.callback(this.options.beforeFit, [this]);
7410		},
7411		fit: function() {
7412			var me = this;
7413			// Reset
7414			var minSize = me.minSize = {
7415				width: 0,
7416				height: 0
7417			};
7418
7419			var labels = labelsFromTicks(me._ticks);
7420
7421			var opts = me.options;
7422			var tickOpts = opts.ticks;
7423			var scaleLabelOpts = opts.scaleLabel;
7424			var gridLineOpts = opts.gridLines;
7425			var display = opts.display;
7426			var isHorizontal = me.isHorizontal();
7427
7428			var tickFont = parseFontOptions(tickOpts);
7429			var tickMarkLength = opts.gridLines.tickMarkLength;
7430
7431			// Width
7432			if (isHorizontal) {
7433				// subtract the margins to line up with the chartArea if we are a full width scale
7434				minSize.width = me.isFullWidth() ? me.maxWidth - me.margins.left - me.margins.right : me.maxWidth;
7435			} else {
7436				minSize.width = display && gridLineOpts.drawTicks ? tickMarkLength : 0;
7437			}
7438
7439			// height
7440			if (isHorizontal) {
7441				minSize.height = display && gridLineOpts.drawTicks ? tickMarkLength : 0;
7442			} else {
7443				minSize.height = me.maxHeight; // fill all the height
7444			}
7445
7446			// Are we showing a title for the scale?
7447			if (scaleLabelOpts.display && display) {
7448				var scaleLabelLineHeight = parseLineHeight(scaleLabelOpts);
7449				var scaleLabelPadding = helpers.options.toPadding(scaleLabelOpts.padding);
7450				var deltaHeight = scaleLabelLineHeight + scaleLabelPadding.height;
7451
7452				if (isHorizontal) {
7453					minSize.height += deltaHeight;
7454				} else {
7455					minSize.width += deltaHeight;
7456				}
7457			}
7458
7459			// Don't bother fitting the ticks if we are not showing them
7460			if (tickOpts.display && display) {
7461				var largestTextWidth = helpers.longestText(me.ctx, tickFont.font, labels, me.longestTextCache);
7462				var tallestLabelHeightInLines = helpers.numberOfLabelLines(labels);
7463				var lineSpace = tickFont.size * 0.5;
7464				var tickPadding = me.options.ticks.padding;
7465
7466				if (isHorizontal) {
7467					// A horizontal axis is more constrained by the height.
7468					me.longestLabelWidth = largestTextWidth;
7469
7470					var angleRadians = helpers.toRadians(me.labelRotation);
7471					var cosRotation = Math.cos(angleRadians);
7472					var sinRotation = Math.sin(angleRadians);
7473
7474					// TODO - improve this calculation
7475					var labelHeight = (sinRotation * largestTextWidth)
7476						+ (tickFont.size * tallestLabelHeightInLines)
7477						+ (lineSpace * (tallestLabelHeightInLines - 1))
7478						+ lineSpace; // padding
7479
7480					minSize.height = Math.min(me.maxHeight, minSize.height + labelHeight + tickPadding);
7481
7482					me.ctx.font = tickFont.font;
7483					var firstLabelWidth = computeTextSize(me.ctx, labels[0], tickFont.font);
7484					var lastLabelWidth = computeTextSize(me.ctx, labels[labels.length - 1], tickFont.font);
7485
7486					// Ensure that our ticks are always inside the canvas. When rotated, ticks are right aligned
7487					// which means that the right padding is dominated by the font height
7488					if (me.labelRotation !== 0) {
7489						me.paddingLeft = opts.position === 'bottom' ? (cosRotation * firstLabelWidth) + 3 : (cosRotation * lineSpace) + 3; // add 3 px to move away from canvas edges
7490						me.paddingRight = opts.position === 'bottom' ? (cosRotation * lineSpace) + 3 : (cosRotation * lastLabelWidth) + 3;
7491					} else {
7492						me.paddingLeft = firstLabelWidth / 2 + 3; // add 3 px to move away from canvas edges
7493						me.paddingRight = lastLabelWidth / 2 + 3;
7494					}
7495				} else {
7496					// A vertical axis is more constrained by the width. Labels are the
7497					// dominant factor here, so get that length first and account for padding
7498					if (tickOpts.mirror) {
7499						largestTextWidth = 0;
7500					} else {
7501						// use lineSpace for consistency with horizontal axis
7502						// tickPadding is not implemented for horizontal
7503						largestTextWidth += tickPadding + lineSpace;
7504					}
7505
7506					minSize.width = Math.min(me.maxWidth, minSize.width + largestTextWidth);
7507
7508					me.paddingTop = tickFont.size / 2;
7509					me.paddingBottom = tickFont.size / 2;
7510				}
7511			}
7512
7513			me.handleMargins();
7514
7515			me.width = minSize.width;
7516			me.height = minSize.height;
7517		},
7518
7519		/**
7520		 * Handle margins and padding interactions
7521		 * @private
7522		 */
7523		handleMargins: function() {
7524			var me = this;
7525			if (me.margins) {
7526				me.paddingLeft = Math.max(me.paddingLeft - me.margins.left, 0);
7527				me.paddingTop = Math.max(me.paddingTop - me.margins.top, 0);
7528				me.paddingRight = Math.max(me.paddingRight - me.margins.right, 0);
7529				me.paddingBottom = Math.max(me.paddingBottom - me.margins.bottom, 0);
7530			}
7531		},
7532
7533		afterFit: function() {
7534			helpers.callback(this.options.afterFit, [this]);
7535		},
7536
7537		// Shared Methods
7538		isHorizontal: function() {
7539			return this.options.position === 'top' || this.options.position === 'bottom';
7540		},
7541		isFullWidth: function() {
7542			return (this.options.fullWidth);
7543		},
7544
7545		// Get the correct value. NaN bad inputs, If the value type is object get the x or y based on whether we are horizontal or not
7546		getRightValue: function(rawValue) {
7547			// Null and undefined values first
7548			if (helpers.isNullOrUndef(rawValue)) {
7549				return NaN;
7550			}
7551			// isNaN(object) returns true, so make sure NaN is checking for a number; Discard Infinite values
7552			if (typeof rawValue === 'number' && !isFinite(rawValue)) {
7553				return NaN;
7554			}
7555			// If it is in fact an object, dive in one more level
7556			if (rawValue) {
7557				if (this.isHorizontal()) {
7558					if (rawValue.x !== undefined) {
7559						return this.getRightValue(rawValue.x);
7560					}
7561				} else if (rawValue.y !== undefined) {
7562					return this.getRightValue(rawValue.y);
7563				}
7564			}
7565
7566			// Value is good, return it
7567			return rawValue;
7568		},
7569
7570		/**
7571		 * Used to get the value to display in the tooltip for the data at the given index
7572		 * @param index
7573		 * @param datasetIndex
7574		 */
7575		getLabelForIndex: helpers.noop,
7576
7577		/**
7578		 * Returns the location of the given data point. Value can either be an index or a numerical value
7579		 * The coordinate (0, 0) is at the upper-left corner of the canvas
7580		 * @param value
7581		 * @param index
7582		 * @param datasetIndex
7583		 */
7584		getPixelForValue: helpers.noop,
7585
7586		/**
7587		 * Used to get the data value from a given pixel. This is the inverse of getPixelForValue
7588		 * The coordinate (0, 0) is at the upper-left corner of the canvas
7589		 * @param pixel
7590		 */
7591		getValueForPixel: helpers.noop,
7592
7593		/**
7594		 * Returns the location of the tick at the given index
7595		 * The coordinate (0, 0) is at the upper-left corner of the canvas
7596		 */
7597		getPixelForTick: function(index) {
7598			var me = this;
7599			var offset = me.options.offset;
7600			if (me.isHorizontal()) {
7601				var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
7602				var tickWidth = innerWidth / Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
7603				var pixel = (tickWidth * index) + me.paddingLeft;
7604
7605				if (offset) {
7606					pixel += tickWidth / 2;
7607				}
7608
7609				var finalVal = me.left + Math.round(pixel);
7610				finalVal += me.isFullWidth() ? me.margins.left : 0;
7611				return finalVal;
7612			}
7613			var innerHeight = me.height - (me.paddingTop + me.paddingBottom);
7614			return me.top + (index * (innerHeight / (me._ticks.length - 1)));
7615		},
7616
7617		/**
7618		 * Utility for getting the pixel location of a percentage of scale
7619		 * The coordinate (0, 0) is at the upper-left corner of the canvas
7620		 */
7621		getPixelForDecimal: function(decimal) {
7622			var me = this;
7623			if (me.isHorizontal()) {
7624				var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
7625				var valueOffset = (innerWidth * decimal) + me.paddingLeft;
7626
7627				var finalVal = me.left + Math.round(valueOffset);
7628				finalVal += me.isFullWidth() ? me.margins.left : 0;
7629				return finalVal;
7630			}
7631			return me.top + (decimal * me.height);
7632		},
7633
7634		/**
7635		 * Returns the pixel for the minimum chart value
7636		 * The coordinate (0, 0) is at the upper-left corner of the canvas
7637		 */
7638		getBasePixel: function() {
7639			return this.getPixelForValue(this.getBaseValue());
7640		},
7641
7642		getBaseValue: function() {
7643			var me = this;
7644			var min = me.min;
7645			var max = me.max;
7646
7647			return me.beginAtZero ? 0 :
7648				min < 0 && max < 0 ? max :
7649				min > 0 && max > 0 ? min :
7650				0;
7651		},
7652
7653		/**
7654		 * Returns a subset of ticks to be plotted to avoid overlapping labels.
7655		 * @private
7656		 */
7657		_autoSkip: function(ticks) {
7658			var skipRatio;
7659			var me = this;
7660			var isHorizontal = me.isHorizontal();
7661			var optionTicks = me.options.ticks.minor;
7662			var tickCount = ticks.length;
7663			var labelRotationRadians = helpers.toRadians(me.labelRotation);
7664			var cosRotation = Math.cos(labelRotationRadians);
7665			var longestRotatedLabel = me.longestLabelWidth * cosRotation;
7666			var result = [];
7667			var i, tick, shouldSkip;
7668
7669			// figure out the maximum number of gridlines to show
7670			var maxTicks;
7671			if (optionTicks.maxTicksLimit) {
7672				maxTicks = optionTicks.maxTicksLimit;
7673			}
7674
7675			if (isHorizontal) {
7676				skipRatio = false;
7677
7678				if ((longestRotatedLabel + optionTicks.autoSkipPadding) * tickCount > (me.width - (me.paddingLeft + me.paddingRight))) {
7679					skipRatio = 1 + Math.floor(((longestRotatedLabel + optionTicks.autoSkipPadding) * tickCount) / (me.width - (me.paddingLeft + me.paddingRight)));
7680				}
7681
7682				// if they defined a max number of optionTicks,
7683				// increase skipRatio until that number is met
7684				if (maxTicks && tickCount > maxTicks) {
7685					skipRatio = Math.max(skipRatio, Math.floor(tickCount / maxTicks));
7686				}
7687			}
7688
7689			for (i = 0; i < tickCount; i++) {
7690				tick = ticks[i];
7691
7692				// Since we always show the last tick,we need may need to hide the last shown one before
7693				shouldSkip = (skipRatio > 1 && i % skipRatio > 0) || (i % skipRatio === 0 && i + skipRatio >= tickCount);
7694				if (shouldSkip && i !== tickCount - 1) {
7695					// leave tick in place but make sure it's not displayed (#4635)
7696					delete tick.label;
7697				}
7698				result.push(tick);
7699			}
7700			return result;
7701		},
7702
7703		// Actually draw the scale on the canvas
7704		// @param {rectangle} chartArea : the area of the chart to draw full grid lines on
7705		draw: function(chartArea) {
7706			var me = this;
7707			var options = me.options;
7708			if (!options.display) {
7709				return;
7710			}
7711
7712			var context = me.ctx;
7713			var globalDefaults = defaults.global;
7714			var optionTicks = options.ticks.minor;
7715			var optionMajorTicks = options.ticks.major || optionTicks;
7716			var gridLines = options.gridLines;
7717			var scaleLabel = options.scaleLabel;
7718
7719			var isRotated = me.labelRotation !== 0;
7720			var isHorizontal = me.isHorizontal();
7721
7722			var ticks = optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
7723			var tickFontColor = helpers.valueOrDefault(optionTicks.fontColor, globalDefaults.defaultFontColor);
7724			var tickFont = parseFontOptions(optionTicks);
7725			var majorTickFontColor = helpers.valueOrDefault(optionMajorTicks.fontColor, globalDefaults.defaultFontColor);
7726			var majorTickFont = parseFontOptions(optionMajorTicks);
7727
7728			var tl = gridLines.drawTicks ? gridLines.tickMarkLength : 0;
7729
7730			var scaleLabelFontColor = helpers.valueOrDefault(scaleLabel.fontColor, globalDefaults.defaultFontColor);
7731			var scaleLabelFont = parseFontOptions(scaleLabel);
7732			var scaleLabelPadding = helpers.options.toPadding(scaleLabel.padding);
7733			var labelRotationRadians = helpers.toRadians(me.labelRotation);
7734
7735			var itemsToDraw = [];
7736
7737			var axisWidth = me.options.gridLines.lineWidth;
7738			var xTickStart = options.position === 'right' ? me.right : me.right - axisWidth - tl;
7739			var xTickEnd = options.position === 'right' ? me.right + tl : me.right;
7740			var yTickStart = options.position === 'bottom' ? me.top + axisWidth : me.bottom - tl - axisWidth;
7741			var yTickEnd = options.position === 'bottom' ? me.top + axisWidth + tl : me.bottom + axisWidth;
7742
7743			helpers.each(ticks, function(tick, index) {
7744				// autoskipper skipped this tick (#4635)
7745				if (helpers.isNullOrUndef(tick.label)) {
7746					return;
7747				}
7748
7749				var label = tick.label;
7750				var lineWidth, lineColor, borderDash, borderDashOffset;
7751				if (index === me.zeroLineIndex && options.offset === gridLines.offsetGridLines) {
7752					// Draw the first index specially
7753					lineWidth = gridLines.zeroLineWidth;
7754					lineColor = gridLines.zeroLineColor;
7755					borderDash = gridLines.zeroLineBorderDash;
7756					borderDashOffset = gridLines.zeroLineBorderDashOffset;
7757				} else {
7758					lineWidth = helpers.valueAtIndexOrDefault(gridLines.lineWidth, index);
7759					lineColor = helpers.valueAtIndexOrDefault(gridLines.color, index);
7760					borderDash = helpers.valueOrDefault(gridLines.borderDash, globalDefaults.borderDash);
7761					borderDashOffset = helpers.valueOrDefault(gridLines.borderDashOffset, globalDefaults.borderDashOffset);
7762				}
7763
7764				// Common properties
7765				var tx1, ty1, tx2, ty2, x1, y1, x2, y2, labelX, labelY;
7766				var textAlign = 'middle';
7767				var textBaseline = 'middle';
7768				var tickPadding = optionTicks.padding;
7769
7770				if (isHorizontal) {
7771					var labelYOffset = tl + tickPadding;
7772
7773					if (options.position === 'bottom') {
7774						// bottom
7775						textBaseline = !isRotated ? 'top' : 'middle';
7776						textAlign = !isRotated ? 'center' : 'right';
7777						labelY = me.top + labelYOffset;
7778					} else {
7779						// top
7780						textBaseline = !isRotated ? 'bottom' : 'middle';
7781						textAlign = !isRotated ? 'center' : 'left';
7782						labelY = me.bottom - labelYOffset;
7783					}
7784
7785					var xLineValue = getLineValue(me, index, gridLines.offsetGridLines && ticks.length > 1);
7786					if (xLineValue < me.left) {
7787						lineColor = 'rgba(0,0,0,0)';
7788					}
7789					xLineValue += helpers.aliasPixel(lineWidth);
7790
7791					labelX = me.getPixelForTick(index) + optionTicks.labelOffset; // x values for optionTicks (need to consider offsetLabel option)
7792
7793					tx1 = tx2 = x1 = x2 = xLineValue;
7794					ty1 = yTickStart;
7795					ty2 = yTickEnd;
7796					y1 = chartArea.top;
7797					y2 = chartArea.bottom + axisWidth;
7798				} else {
7799					var isLeft = options.position === 'left';
7800					var labelXOffset;
7801
7802					if (optionTicks.mirror) {
7803						textAlign = isLeft ? 'left' : 'right';
7804						labelXOffset = tickPadding;
7805					} else {
7806						textAlign = isLeft ? 'right' : 'left';
7807						labelXOffset = tl + tickPadding;
7808					}
7809
7810					labelX = isLeft ? me.right - labelXOffset : me.left + labelXOffset;
7811
7812					var yLineValue = getLineValue(me, index, gridLines.offsetGridLines && ticks.length > 1);
7813					if (yLineValue < me.top) {
7814						lineColor = 'rgba(0,0,0,0)';
7815					}
7816					yLineValue += helpers.aliasPixel(lineWidth);
7817
7818					labelY = me.getPixelForTick(index) + optionTicks.labelOffset;
7819
7820					tx1 = xTickStart;
7821					tx2 = xTickEnd;
7822					x1 = chartArea.left;
7823					x2 = chartArea.right + axisWidth;
7824					ty1 = ty2 = y1 = y2 = yLineValue;
7825				}
7826
7827				itemsToDraw.push({
7828					tx1: tx1,
7829					ty1: ty1,
7830					tx2: tx2,
7831					ty2: ty2,
7832					x1: x1,
7833					y1: y1,
7834					x2: x2,
7835					y2: y2,
7836					labelX: labelX,
7837					labelY: labelY,
7838					glWidth: lineWidth,
7839					glColor: lineColor,
7840					glBorderDash: borderDash,
7841					glBorderDashOffset: borderDashOffset,
7842					rotation: -1 * labelRotationRadians,
7843					label: label,
7844					major: tick.major,
7845					textBaseline: textBaseline,
7846					textAlign: textAlign
7847				});
7848			});
7849
7850			// Draw all of the tick labels, tick marks, and grid lines at the correct places
7851			helpers.each(itemsToDraw, function(itemToDraw) {
7852				if (gridLines.display) {
7853					context.save();
7854					context.lineWidth = itemToDraw.glWidth;
7855					context.strokeStyle = itemToDraw.glColor;
7856					if (context.setLineDash) {
7857						context.setLineDash(itemToDraw.glBorderDash);
7858						context.lineDashOffset = itemToDraw.glBorderDashOffset;
7859					}
7860
7861					context.beginPath();
7862
7863					if (gridLines.drawTicks) {
7864						context.moveTo(itemToDraw.tx1, itemToDraw.ty1);
7865						context.lineTo(itemToDraw.tx2, itemToDraw.ty2);
7866					}
7867
7868					if (gridLines.drawOnChartArea) {
7869						context.moveTo(itemToDraw.x1, itemToDraw.y1);
7870						context.lineTo(itemToDraw.x2, itemToDraw.y2);
7871					}
7872
7873					context.stroke();
7874					context.restore();
7875				}
7876
7877				if (optionTicks.display) {
7878					// Make sure we draw text in the correct color and font
7879					context.save();
7880					context.translate(itemToDraw.labelX, itemToDraw.labelY);
7881					context.rotate(itemToDraw.rotation);
7882					context.font = itemToDraw.major ? majorTickFont.font : tickFont.font;
7883					context.fillStyle = itemToDraw.major ? majorTickFontColor : tickFontColor;
7884					context.textBaseline = itemToDraw.textBaseline;
7885					context.textAlign = itemToDraw.textAlign;
7886
7887					var label = itemToDraw.label;
7888					if (helpers.isArray(label)) {
7889						var lineCount = label.length;
7890						var lineHeight = tickFont.size * 1.5;
7891						var y = me.isHorizontal() ? 0 : -lineHeight * (lineCount - 1) / 2;
7892
7893						for (var i = 0; i < lineCount; ++i) {
7894							// We just make sure the multiline element is a string here..
7895							context.fillText('' + label[i], 0, y);
7896							// apply same lineSpacing as calculated @ L#320
7897							y += lineHeight;
7898						}
7899					} else {
7900						context.fillText(label, 0, 0);
7901					}
7902					context.restore();
7903				}
7904			});
7905
7906			if (scaleLabel.display) {
7907				// Draw the scale label
7908				var scaleLabelX;
7909				var scaleLabelY;
7910				var rotation = 0;
7911				var halfLineHeight = parseLineHeight(scaleLabel) / 2;
7912
7913				if (isHorizontal) {
7914					scaleLabelX = me.left + ((me.right - me.left) / 2); // midpoint of the width
7915					scaleLabelY = options.position === 'bottom'
7916						? me.bottom - halfLineHeight - scaleLabelPadding.bottom
7917						: me.top + halfLineHeight + scaleLabelPadding.top;
7918				} else {
7919					var isLeft = options.position === 'left';
7920					scaleLabelX = isLeft
7921						? me.left + halfLineHeight + scaleLabelPadding.top
7922						: me.right - halfLineHeight - scaleLabelPadding.top;
7923					scaleLabelY = me.top + ((me.bottom - me.top) / 2);
7924					rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;
7925				}
7926
7927				context.save();
7928				context.translate(scaleLabelX, scaleLabelY);
7929				context.rotate(rotation);
7930				context.textAlign = 'center';
7931				context.textBaseline = 'middle';
7932				context.fillStyle = scaleLabelFontColor; // render in correct colour
7933				context.font = scaleLabelFont.font;
7934				context.fillText(scaleLabel.labelString, 0, 0);
7935				context.restore();
7936			}
7937
7938			if (gridLines.drawBorder) {
7939				// Draw the line at the edge of the axis
7940				context.lineWidth = helpers.valueAtIndexOrDefault(gridLines.lineWidth, 0);
7941				context.strokeStyle = helpers.valueAtIndexOrDefault(gridLines.color, 0);
7942				var x1 = me.left;
7943				var x2 = me.right + axisWidth;
7944				var y1 = me.top;
7945				var y2 = me.bottom + axisWidth;
7946
7947				var aliasPixel = helpers.aliasPixel(context.lineWidth);
7948				if (isHorizontal) {
7949					y1 = y2 = options.position === 'top' ? me.bottom : me.top;
7950					y1 += aliasPixel;
7951					y2 += aliasPixel;
7952				} else {
7953					x1 = x2 = options.position === 'left' ? me.right : me.left;
7954					x1 += aliasPixel;
7955					x2 += aliasPixel;
7956				}
7957
7958				context.beginPath();
7959				context.moveTo(x1, y1);
7960				context.lineTo(x2, y2);
7961				context.stroke();
7962			}
7963		}
7964	});
7965};
7966
7967},{"25":25,"26":26,"34":34,"45":45}],33:[function(require,module,exports){
7968'use strict';
7969
7970var defaults = require(25);
7971var helpers = require(45);
7972var layouts = require(30);
7973
7974module.exports = function(Chart) {
7975
7976	Chart.scaleService = {
7977		// Scale registration object. Extensions can register new scale types (such as log or DB scales) and then
7978		// use the new chart options to grab the correct scale
7979		constructors: {},
7980		// Use a registration function so that we can move to an ES6 map when we no longer need to support
7981		// old browsers
7982
7983		// Scale config defaults
7984		defaults: {},
7985		registerScaleType: function(type, scaleConstructor, scaleDefaults) {
7986			this.constructors[type] = scaleConstructor;
7987			this.defaults[type] = helpers.clone(scaleDefaults);
7988		},
7989		getScaleConstructor: function(type) {
7990			return this.constructors.hasOwnProperty(type) ? this.constructors[type] : undefined;
7991		},
7992		getScaleDefaults: function(type) {
7993			// Return the scale defaults merged with the global settings so that we always use the latest ones
7994			return this.defaults.hasOwnProperty(type) ? helpers.merge({}, [defaults.scale, this.defaults[type]]) : {};
7995		},
7996		updateScaleDefaults: function(type, additions) {
7997			var me = this;
7998			if (me.defaults.hasOwnProperty(type)) {
7999				me.defaults[type] = helpers.extend(me.defaults[type], additions);
8000			}
8001		},
8002		addScalesToLayout: function(chart) {
8003			// Adds each scale to the chart.boxes array to be sized accordingly
8004			helpers.each(chart.scales, function(scale) {
8005				// Set ILayoutItem parameters for backwards compatibility
8006				scale.fullWidth = scale.options.fullWidth;
8007				scale.position = scale.options.position;
8008				scale.weight = scale.options.weight;
8009				layouts.addBox(chart, scale);
8010			});
8011		}
8012	};
8013};
8014
8015},{"25":25,"30":30,"45":45}],34:[function(require,module,exports){
8016'use strict';
8017
8018var helpers = require(45);
8019
8020/**
8021 * Namespace to hold static tick generation functions
8022 * @namespace Chart.Ticks
8023 */
8024module.exports = {
8025	/**
8026	 * Namespace to hold formatters for different types of ticks
8027	 * @namespace Chart.Ticks.formatters
8028	 */
8029	formatters: {
8030		/**
8031		 * Formatter for value labels
8032		 * @method Chart.Ticks.formatters.values
8033		 * @param value the value to display
8034		 * @return {String|Array} the label to display
8035		 */
8036		values: function(value) {
8037			return helpers.isArray(value) ? value : '' + value;
8038		},
8039
8040		/**
8041		 * Formatter for linear numeric ticks
8042		 * @method Chart.Ticks.formatters.linear
8043		 * @param tickValue {Number} the value to be formatted
8044		 * @param index {Number} the position of the tickValue parameter in the ticks array
8045		 * @param ticks {Array<Number>} the list of ticks being converted
8046		 * @return {String} string representation of the tickValue parameter
8047		 */
8048		linear: function(tickValue, index, ticks) {
8049			// If we have lots of ticks, don't use the ones
8050			var delta = ticks.length > 3 ? ticks[2] - ticks[1] : ticks[1] - ticks[0];
8051
8052			// If we have a number like 2.5 as the delta, figure out how many decimal places we need
8053			if (Math.abs(delta) > 1) {
8054				if (tickValue !== Math.floor(tickValue)) {
8055					// not an integer
8056					delta = tickValue - Math.floor(tickValue);
8057				}
8058			}
8059
8060			var logDelta = helpers.log10(Math.abs(delta));
8061			var tickString = '';
8062
8063			if (tickValue !== 0) {
8064				var numDecimal = -1 * Math.floor(logDelta);
8065				numDecimal = Math.max(Math.min(numDecimal, 20), 0); // toFixed has a max of 20 decimal places
8066				tickString = tickValue.toFixed(numDecimal);
8067			} else {
8068				tickString = '0'; // never show decimal places for 0
8069			}
8070
8071			return tickString;
8072		},
8073
8074		logarithmic: function(tickValue, index, ticks) {
8075			var remain = tickValue / (Math.pow(10, Math.floor(helpers.log10(tickValue))));
8076
8077			if (tickValue === 0) {
8078				return '0';
8079			} else if (remain === 1 || remain === 2 || remain === 5 || index === 0 || index === ticks.length - 1) {
8080				return tickValue.toExponential();
8081			}
8082			return '';
8083		}
8084	}
8085};
8086
8087},{"45":45}],35:[function(require,module,exports){
8088'use strict';
8089
8090var defaults = require(25);
8091var Element = require(26);
8092var helpers = require(45);
8093
8094defaults._set('global', {
8095	tooltips: {
8096		enabled: true,
8097		custom: null,
8098		mode: 'nearest',
8099		position: 'average',
8100		intersect: true,
8101		backgroundColor: 'rgba(0,0,0,0.8)',
8102		titleFontStyle: 'bold',
8103		titleSpacing: 2,
8104		titleMarginBottom: 6,
8105		titleFontColor: '#fff',
8106		titleAlign: 'left',
8107		bodySpacing: 2,
8108		bodyFontColor: '#fff',
8109		bodyAlign: 'left',
8110		footerFontStyle: 'bold',
8111		footerSpacing: 2,
8112		footerMarginTop: 6,
8113		footerFontColor: '#fff',
8114		footerAlign: 'left',
8115		yPadding: 6,
8116		xPadding: 6,
8117		caretPadding: 2,
8118		caretSize: 5,
8119		cornerRadius: 6,
vendor: 11,029 bytes, lines 8120-8494
8120		multiKeyBackground: '#fff',
8121		displayColors: true,
8122		borderColor: 'rgba(0,0,0,0)',
8123		borderWidth: 0,
8124		callbacks: {
8125			// Args are: (tooltipItems, data)
8126			beforeTitle: helpers.noop,
8127			title: function(tooltipItems, data) {
8128				// Pick first xLabel for now
8129				var title = '';
8130				var labels = data.labels;
8131				var labelCount = labels ? labels.length : 0;
8132
8133				if (tooltipItems.length > 0) {
8134					var item = tooltipItems[0];
8135
8136					if (item.xLabel) {
8137						title = item.xLabel;
8138					} else if (labelCount > 0 && item.index < labelCount) {
8139						title = labels[item.index];
8140					}
8141				}
8142
8143				return title;
8144			},
8145			afterTitle: helpers.noop,
8146
8147			// Args are: (tooltipItems, data)
8148			beforeBody: helpers.noop,
8149
8150			// Args are: (tooltipItem, data)
8151			beforeLabel: helpers.noop,
8152			label: function(tooltipItem, data) {
8153				var label = data.datasets[tooltipItem.datasetIndex].label || '';
8154
8155				if (label) {
8156					label += ': ';
8157				}
8158				label += tooltipItem.yLabel;
8159				return label;
8160			},
8161			labelColor: function(tooltipItem, chart) {
8162				var meta = chart.getDatasetMeta(tooltipItem.datasetIndex);
8163				var activeElement = meta.data[tooltipItem.index];
8164				var view = activeElement._view;
8165				return {
8166					borderColor: view.borderColor,
8167					backgroundColor: view.backgroundColor
8168				};
8169			},
8170			labelTextColor: function() {
8171				return this._options.bodyFontColor;
8172			},
8173			afterLabel: helpers.noop,
8174
8175			// Args are: (tooltipItems, data)
8176			afterBody: helpers.noop,
8177
8178			// Args are: (tooltipItems, data)
8179			beforeFooter: helpers.noop,
8180			footer: helpers.noop,
8181			afterFooter: helpers.noop
8182		}
8183	}
8184});
8185
8186module.exports = function(Chart) {
8187
8188	/**
8189 	 * Helper method to merge the opacity into a color
8190 	 */
8191	function mergeOpacity(colorString, opacity) {
8192		var color = helpers.color(colorString);
8193		return color.alpha(opacity * color.alpha()).rgbaString();
8194	}
8195
8196	// Helper to push or concat based on if the 2nd parameter is an array or not
8197	function pushOrConcat(base, toPush) {
8198		if (toPush) {
8199			if (helpers.isArray(toPush)) {
8200				// base = base.concat(toPush);
8201				Array.prototype.push.apply(base, toPush);
8202			} else {
8203				base.push(toPush);
8204			}
8205		}
8206
8207		return base;
8208	}
8209
8210	// Private helper to create a tooltip item model
8211	// @param element : the chart element (point, arc, bar) to create the tooltip item for
8212	// @return : new tooltip item
8213	function createTooltipItem(element) {
8214		var xScale = element._xScale;
8215		var yScale = element._yScale || element._scale; // handle radar || polarArea charts
8216		var index = element._index;
8217		var datasetIndex = element._datasetIndex;
8218
8219		return {
8220			xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '',
8221			yLabel: yScale ? yScale.getLabelForIndex(index, datasetIndex) : '',
8222			index: index,
8223			datasetIndex: datasetIndex,
8224			x: element._model.x,
8225			y: element._model.y
8226		};
8227	}
8228
8229	/**
8230	 * Helper to get the reset model for the tooltip
8231	 * @param tooltipOpts {Object} the tooltip options
8232	 */
8233	function getBaseModel(tooltipOpts) {
8234		var globalDefaults = defaults.global;
8235		var valueOrDefault = helpers.valueOrDefault;
8236
8237		return {
8238			// Positioning
8239			xPadding: tooltipOpts.xPadding,
8240			yPadding: tooltipOpts.yPadding,
8241			xAlign: tooltipOpts.xAlign,
8242			yAlign: tooltipOpts.yAlign,
8243
8244			// Body
8245			bodyFontColor: tooltipOpts.bodyFontColor,
8246			_bodyFontFamily: valueOrDefault(tooltipOpts.bodyFontFamily, globalDefaults.defaultFontFamily),
8247			_bodyFontStyle: valueOrDefault(tooltipOpts.bodyFontStyle, globalDefaults.defaultFontStyle),
8248			_bodyAlign: tooltipOpts.bodyAlign,
8249			bodyFontSize: valueOrDefault(tooltipOpts.bodyFontSize, globalDefaults.defaultFontSize),
8250			bodySpacing: tooltipOpts.bodySpacing,
8251
8252			// Title
8253			titleFontColor: tooltipOpts.titleFontColor,
8254			_titleFontFamily: valueOrDefault(tooltipOpts.titleFontFamily, globalDefaults.defaultFontFamily),
8255			_titleFontStyle: valueOrDefault(tooltipOpts.titleFontStyle, globalDefaults.defaultFontStyle),
8256			titleFontSize: valueOrDefault(tooltipOpts.titleFontSize, globalDefaults.defaultFontSize),
8257			_titleAlign: tooltipOpts.titleAlign,
8258			titleSpacing: tooltipOpts.titleSpacing,
8259			titleMarginBottom: tooltipOpts.titleMarginBottom,
8260
8261			// Footer
8262			footerFontColor: tooltipOpts.footerFontColor,
8263			_footerFontFamily: valueOrDefault(tooltipOpts.footerFontFamily, globalDefaults.defaultFontFamily),
8264			_footerFontStyle: valueOrDefault(tooltipOpts.footerFontStyle, globalDefaults.defaultFontStyle),
8265			footerFontSize: valueOrDefault(tooltipOpts.footerFontSize, globalDefaults.defaultFontSize),
8266			_footerAlign: tooltipOpts.footerAlign,
8267			footerSpacing: tooltipOpts.footerSpacing,
8268			footerMarginTop: tooltipOpts.footerMarginTop,
8269
8270			// Appearance
8271			caretSize: tooltipOpts.caretSize,
8272			cornerRadius: tooltipOpts.cornerRadius,
8273			backgroundColor: tooltipOpts.backgroundColor,
8274			opacity: 0,
8275			legendColorBackground: tooltipOpts.multiKeyBackground,
8276			displayColors: tooltipOpts.displayColors,
8277			borderColor: tooltipOpts.borderColor,
8278			borderWidth: tooltipOpts.borderWidth
8279		};
8280	}
8281
8282	/**
8283	 * Get the size of the tooltip
8284	 */
8285	function getTooltipSize(tooltip, model) {
8286		var ctx = tooltip._chart.ctx;
8287
8288		var height = model.yPadding * 2; // Tooltip Padding
8289		var width = 0;
8290
8291		// Count of all lines in the body
8292		var body = model.body;
8293		var combinedBodyLength = body.reduce(function(count, bodyItem) {
8294			return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length;
8295		}, 0);
8296		combinedBodyLength += model.beforeBody.length + model.afterBody.length;
8297
8298		var titleLineCount = model.title.length;
8299		var footerLineCount = model.footer.length;
8300		var titleFontSize = model.titleFontSize;
8301		var bodyFontSize = model.bodyFontSize;
8302		var footerFontSize = model.footerFontSize;
8303
8304		height += titleLineCount * titleFontSize; // Title Lines
8305		height += titleLineCount ? (titleLineCount - 1) * model.titleSpacing : 0; // Title Line Spacing
8306		height += titleLineCount ? model.titleMarginBottom : 0; // Title's bottom Margin
8307		height += combinedBodyLength * bodyFontSize; // Body Lines
8308		height += combinedBodyLength ? (combinedBodyLength - 1) * model.bodySpacing : 0; // Body Line Spacing
8309		height += footerLineCount ? model.footerMarginTop : 0; // Footer Margin
8310		height += footerLineCount * (footerFontSize); // Footer Lines
8311		height += footerLineCount ? (footerLineCount - 1) * model.footerSpacing : 0; // Footer Line Spacing
8312
8313		// Title width
8314		var widthPadding = 0;
8315		var maxLineWidth = function(line) {
8316			width = Math.max(width, ctx.measureText(line).width + widthPadding);
8317		};
8318
8319		ctx.font = helpers.fontString(titleFontSize, model._titleFontStyle, model._titleFontFamily);
8320		helpers.each(model.title, maxLineWidth);
8321
8322		// Body width
8323		ctx.font = helpers.fontString(bodyFontSize, model._bodyFontStyle, model._bodyFontFamily);
8324		helpers.each(model.beforeBody.concat(model.afterBody), maxLineWidth);
8325
8326		// Body lines may include some extra width due to the color box
8327		widthPadding = model.displayColors ? (bodyFontSize + 2) : 0;
8328		helpers.each(body, function(bodyItem) {
8329			helpers.each(bodyItem.before, maxLineWidth);
8330			helpers.each(bodyItem.lines, maxLineWidth);
8331			helpers.each(bodyItem.after, maxLineWidth);
8332		});
8333
8334		// Reset back to 0
8335		widthPadding = 0;
8336
8337		// Footer width
8338		ctx.font = helpers.fontString(footerFontSize, model._footerFontStyle, model._footerFontFamily);
8339		helpers.each(model.footer, maxLineWidth);
8340
8341		// Add padding
8342		width += 2 * model.xPadding;
8343
8344		return {
8345			width: width,
8346			height: height
8347		};
8348	}
8349
8350	/**
8351	 * Helper to get the alignment of a tooltip given the size
8352	 */
8353	function determineAlignment(tooltip, size) {
8354		var model = tooltip._model;
8355		var chart = tooltip._chart;
8356		var chartArea = tooltip._chart.chartArea;
8357		var xAlign = 'center';
8358		var yAlign = 'center';
8359
8360		if (model.y < size.height) {
8361			yAlign = 'top';
8362		} else if (model.y > (chart.height - size.height)) {
8363			yAlign = 'bottom';
8364		}
8365
8366		var lf, rf; // functions to determine left, right alignment
8367		var olf, orf; // functions to determine if left/right alignment causes tooltip to go outside chart
8368		var yf; // function to get the y alignment if the tooltip goes outside of the left or right edges
8369		var midX = (chartArea.left + chartArea.right) / 2;
8370		var midY = (chartArea.top + chartArea.bottom) / 2;
8371
8372		if (yAlign === 'center') {
8373			lf = function(x) {
8374				return x <= midX;
8375			};
8376			rf = function(x) {
8377				return x > midX;
8378			};
8379		} else {
8380			lf = function(x) {
8381				return x <= (size.width / 2);
8382			};
8383			rf = function(x) {
8384				return x >= (chart.width - (size.width / 2));
8385			};
8386		}
8387
8388		olf = function(x) {
8389			return x + size.width + model.caretSize + model.caretPadding > chart.width;
8390		};
8391		orf = function(x) {
8392			return x - size.width - model.caretSize - model.caretPadding < 0;
8393		};
8394		yf = function(y) {
8395			return y <= midY ? 'top' : 'bottom';
8396		};
8397
8398		if (lf(model.x)) {
8399			xAlign = 'left';
8400
8401			// Is tooltip too wide and goes over the right side of the chart.?
8402			if (olf(model.x)) {
8403				xAlign = 'center';
8404				yAlign = yf(model.y);
8405			}
8406		} else if (rf(model.x)) {
8407			xAlign = 'right';
8408
8409			// Is tooltip too wide and goes outside left edge of canvas?
8410			if (orf(model.x)) {
8411				xAlign = 'center';
8412				yAlign = yf(model.y);
8413			}
8414		}
8415
8416		var opts = tooltip._options;
8417		return {
8418			xAlign: opts.xAlign ? opts.xAlign : xAlign,
8419			yAlign: opts.yAlign ? opts.yAlign : yAlign
8420		};
8421	}
8422
8423	/**
8424	 * @Helper to get the location a tooltip needs to be placed at given the initial position (via the vm) and the size and alignment
8425	 */
8426	function getBackgroundPoint(vm, size, alignment, chart) {
8427		// Background Position
8428		var x = vm.x;
8429		var y = vm.y;
8430
8431		var caretSize = vm.caretSize;
8432		var caretPadding = vm.caretPadding;
8433		var cornerRadius = vm.cornerRadius;
8434		var xAlign = alignment.xAlign;
8435		var yAlign = alignment.yAlign;
8436		var paddingAndSize = caretSize + caretPadding;
8437		var radiusAndPadding = cornerRadius + caretPadding;
8438
8439		if (xAlign === 'right') {
8440			x -= size.width;
8441		} else if (xAlign === 'center') {
8442			x -= (size.width / 2);
8443			if (x + size.width > chart.width) {
8444				x = chart.width - size.width;
8445			}
8446			if (x < 0) {
8447				x = 0;
8448			}
8449		}
8450
8451		if (yAlign === 'top') {
8452			y += paddingAndSize;
8453		} else if (yAlign === 'bottom') {
8454			y -= size.height + paddingAndSize;
8455		} else {
8456			y -= (size.height / 2);
8457		}
8458
8459		if (yAlign === 'center') {
8460			if (xAlign === 'left') {
8461				x += paddingAndSize;
8462			} else if (xAlign === 'right') {
8463				x -= paddingAndSize;
8464			}
8465		} else if (xAlign === 'left') {
8466			x -= radiusAndPadding;
8467		} else if (xAlign === 'right') {
8468			x += radiusAndPadding;
8469		}
8470
8471		return {
8472			x: x,
8473			y: y
8474		};
8475	}
8476
8477	Chart.Tooltip = Element.extend({
8478		initialize: function() {
8479			this._model = getBaseModel(this._options);
8480			this._lastActive = [];
8481		},
8482
8483		// Get the title
8484		// Args are: (tooltipItem, data)
8485		getTitle: function() {
8486			var me = this;
8487			var opts = me._options;
8488			var callbacks = opts.callbacks;
8489
8490			var beforeTitle = callbacks.beforeTitle.apply(me, arguments);
8491			var title = callbacks.title.apply(me, arguments);
8492			var afterTitle = callbacks.afterTitle.apply(me, arguments);
8493
8494			var lines = [];
8495			lines = pushOrConcat(lines, beforeTitle);
8496			lines = pushOrConcat(lines, title);
8497			lines = pushOrConcat(lines, afterTitle);
8498
8499			return lines;
8500		},
8501
8502		// Args are: (tooltipItem, data)
8503		getBeforeBody: function() {
8504			var lines = this._options.callbacks.beforeBody.apply(this, arguments);
8505			return helpers.isArray(lines) ? lines : lines !== undefined ? [lines] : [];
8506		},
8507
8508		// Args are: (tooltipItem, data)
8509		getBody: function(tooltipItems, data) {
8510			var me = this;
8511			var callbacks = me._options.callbacks;
8512			var bodyItems = [];
8513
8514			helpers.each(tooltipItems, function(tooltipItem) {
8515				var bodyItem = {
8516					before: [],
8517					lines: [],
8518					after: []
8519				};
8520				pushOrConcat(bodyItem.before, callbacks.beforeLabel.call(me, tooltipItem, data));
8521				pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data));
8522				pushOrConcat(bodyItem.after, callbacks.afterLabel.call(me, tooltipItem, data));
8523
8524				bodyItems.push(bodyItem);
8525			});
8526
8527			return bodyItems;
8528		},
8529
8530		// Args are: (tooltipItem, data)
8531		getAfterBody: function() {
8532			var lines = this._options.callbacks.afterBody.apply(this, arguments);
8533			return helpers.isArray(lines) ? lines : lines !== undefined ? [lines] : [];
8534		},
8535
8536		// Get the footer and beforeFooter and afterFooter lines
8537		// Args are: (tooltipItem, data)
8538		getFooter: function() {
8539			var me = this;
8540			var callbacks = me._options.callbacks;
8541
8542			var beforeFooter = callbacks.beforeFooter.apply(me, arguments);
8543			var footer = callbacks.footer.apply(me, arguments);
8544			var afterFooter = callbacks.afterFooter.apply(me, arguments);
8545
8546			var lines = [];
8547			lines = pushOrConcat(lines, beforeFooter);
8548			lines = pushOrConcat(lines, footer);
8549			lines = pushOrConcat(lines, afterFooter);
8550
8551			return lines;
8552		},
8553
8554		update: function(changed) {
8555			var me = this;
8556			var opts = me._options;
8557
8558			// Need to regenerate the model because its faster than using extend and it is necessary due to the optimization in Chart.Element.transition
8559			// that does _view = _model if ease === 1. This causes the 2nd tooltip update to set properties in both the view and model at the same time
8560			// which breaks any animations.
8561			var existingModel = me._model;
8562			var model = me._model = getBaseModel(opts);
8563			var active = me._active;
8564
8565			var data = me._data;
8566
8567			// In the case where active.length === 0 we need to keep these at existing values for good animations
8568			var alignment = {
8569				xAlign: existingModel.xAlign,
8570				yAlign: existingModel.yAlign
8571			};
8572			var backgroundPoint = {
8573				x: existingModel.x,
8574				y: existingModel.y
8575			};
8576			var tooltipSize = {
8577				width: existingModel.width,
8578				height: existingModel.height
8579			};
8580			var tooltipPosition = {
8581				x: existingModel.caretX,
8582				y: existingModel.caretY
8583			};
8584
8585			var i, len;
8586
8587			if (active.length) {
8588				model.opacity = 1;
8589
8590				var labelColors = [];
8591				var labelTextColors = [];
8592				tooltipPosition = Chart.Tooltip.positioners[opts.position].call(me, active, me._eventPosition);
8593
8594				var tooltipItems = [];
8595				for (i = 0, len = active.length; i < len; ++i) {
8596					tooltipItems.push(createTooltipItem(active[i]));
8597				}
8598
8599				// If the user provided a filter function, use it to modify the tooltip items
8600				if (opts.filter) {
8601					tooltipItems = tooltipItems.filter(function(a) {
8602						return opts.filter(a, data);
8603					});
8604				}
8605
8606				// If the user provided a sorting function, use it to modify the tooltip items
8607				if (opts.itemSort) {
8608					tooltipItems = tooltipItems.sort(function(a, b) {
8609						return opts.itemSort(a, b, data);
8610					});
8611				}
8612
8613				// Determine colors for boxes
8614				helpers.each(tooltipItems, function(tooltipItem) {
8615					labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, me._chart));
8616					labelTextColors.push(opts.callbacks.labelTextColor.call(me, tooltipItem, me._chart));
8617				});
8618
8619
8620				// Build the Text Lines
8621				model.title = me.getTitle(tooltipItems, data);
8622				model.beforeBody = me.getBeforeBody(tooltipItems, data);
8623				model.body = me.getBody(tooltipItems, data);
8624				model.afterBody = me.getAfterBody(tooltipItems, data);
8625				model.footer = me.getFooter(tooltipItems, data);
8626
8627				// Initial positioning and colors
8628				model.x = Math.round(tooltipPosition.x);
8629				model.y = Math.round(tooltipPosition.y);
8630				model.caretPadding = opts.caretPadding;
8631				model.labelColors = labelColors;
8632				model.labelTextColors = labelTextColors;
8633
8634				// data points
8635				model.dataPoints = tooltipItems;
8636
8637				// We need to determine alignment of the tooltip
8638				tooltipSize = getTooltipSize(this, model);
8639				alignment = determineAlignment(this, tooltipSize);
8640				// Final Size and Position
8641				backgroundPoint = getBackgroundPoint(model, tooltipSize, alignment, me._chart);
8642			} else {
8643				model.opacity = 0;
8644			}
8645
8646			model.xAlign = alignment.xAlign;
8647			model.yAlign = alignment.yAlign;
8648			model.x = backgroundPoint.x;
8649			model.y = backgroundPoint.y;
8650			model.width = tooltipSize.width;
8651			model.height = tooltipSize.height;
8652
8653			// Point where the caret on the tooltip points to
8654			model.caretX = tooltipPosition.x;
8655			model.caretY = tooltipPosition.y;
8656
8657			me._model = model;
8658
8659			if (changed && opts.custom) {
8660				opts.custom.call(me, model);
8661			}
8662
8663			return me;
8664		},
8665		drawCaret: function(tooltipPoint, size) {
8666			var ctx = this._chart.ctx;
8667			var vm = this._view;
8668			var caretPosition = this.getCaretPosition(tooltipPoint, size, vm);
8669
8670			ctx.lineTo(caretPosition.x1, caretPosition.y1);
8671			ctx.lineTo(caretPosition.x2, caretPosition.y2);
8672			ctx.lineTo(caretPosition.x3, caretPosition.y3);
8673		},
8674		getCaretPosition: function(tooltipPoint, size, vm) {
8675			var x1, x2, x3, y1, y2, y3;
8676			var caretSize = vm.caretSize;
8677			var cornerRadius = vm.cornerRadius;
8678			var xAlign = vm.xAlign;
8679			var yAlign = vm.yAlign;
8680			var ptX = tooltipPoint.x;
8681			var ptY = tooltipPoint.y;
8682			var width = size.width;
8683			var height = size.height;
8684
8685			if (yAlign === 'center') {
8686				y2 = ptY + (height / 2);
8687
8688				if (xAlign === 'left') {
8689					x1 = ptX;
8690					x2 = x1 - caretSize;
8691					x3 = x1;
8692
8693					y1 = y2 + caretSize;
8694					y3 = y2 - caretSize;
8695				} else {
8696					x1 = ptX + width;
8697					x2 = x1 + caretSize;
8698					x3 = x1;
8699
8700					y1 = y2 - caretSize;
8701					y3 = y2 + caretSize;
8702				}
8703			} else {
8704				if (xAlign === 'left') {
8705					x2 = ptX + cornerRadius + (caretSize);
8706					x1 = x2 - caretSize;
8707					x3 = x2 + caretSize;
8708				} else if (xAlign === 'right') {
8709					x2 = ptX + width - cornerRadius - caretSize;
8710					x1 = x2 - caretSize;
8711					x3 = x2 + caretSize;
8712				} else {
8713					x2 = vm.caretX;
8714					x1 = x2 - caretSize;
8715					x3 = x2 + caretSize;
8716				}
8717				if (yAlign === 'top') {
8718					y1 = ptY;
8719					y2 = y1 - caretSize;
8720					y3 = y1;
8721				} else {
8722					y1 = ptY + height;
8723					y2 = y1 + caretSize;
8724					y3 = y1;
8725					// invert drawing order
8726					var tmp = x3;
8727					x3 = x1;
8728					x1 = tmp;
8729				}
8730			}
8731			return {x1: x1, x2: x2, x3: x3, y1: y1, y2: y2, y3: y3};
8732		},
8733		drawTitle: function(pt, vm, ctx, opacity) {
8734			var title = vm.title;
8735
8736			if (title.length) {
8737				ctx.textAlign = vm._titleAlign;
8738				ctx.textBaseline = 'top';
8739
8740				var titleFontSize = vm.titleFontSize;
8741				var titleSpacing = vm.titleSpacing;
8742
8743				ctx.fillStyle = mergeOpacity(vm.titleFontColor, opacity);
8744				ctx.font = helpers.fontString(titleFontSize, vm._titleFontStyle, vm._titleFontFamily);
8745
8746				var i, len;
8747				for (i = 0, len = title.length; i < len; ++i) {
8748					ctx.fillText(title[i], pt.x, pt.y);
8749					pt.y += titleFontSize + titleSpacing; // Line Height and spacing
8750
8751					if (i + 1 === title.length) {
8752						pt.y += vm.titleMarginBottom - titleSpacing; // If Last, add margin, remove spacing
8753					}
8754				}
8755			}
8756		},
8757		drawBody: function(pt, vm, ctx, opacity) {
8758			var bodyFontSize = vm.bodyFontSize;
8759			var bodySpacing = vm.bodySpacing;
8760			var body = vm.body;
8761
8762			ctx.textAlign = vm._bodyAlign;
8763			ctx.textBaseline = 'top';
8764			ctx.font = helpers.fontString(bodyFontSize, vm._bodyFontStyle, vm._bodyFontFamily);
8765
8766			// Before Body
8767			var xLinePadding = 0;
8768			var fillLineOfText = function(line) {
8769				ctx.fillText(line, pt.x + xLinePadding, pt.y);
8770				pt.y += bodyFontSize + bodySpacing;
8771			};
8772
8773			// Before body lines
8774			ctx.fillStyle = mergeOpacity(vm.bodyFontColor, opacity);
8775			helpers.each(vm.beforeBody, fillLineOfText);
8776
8777			var drawColorBoxes = vm.displayColors;
8778			xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;
8779
8780			// Draw body lines now
8781			helpers.each(body, function(bodyItem, i) {
8782				var textColor = mergeOpacity(vm.labelTextColors[i], opacity);
8783				ctx.fillStyle = textColor;
8784				helpers.each(bodyItem.before, fillLineOfText);
8785
8786				helpers.each(bodyItem.lines, function(line) {
8787					// Draw Legend-like boxes if needed
8788					if (drawColorBoxes) {
8789						// Fill a white rect so that colours merge nicely if the opacity is < 1
8790						ctx.fillStyle = mergeOpacity(vm.legendColorBackground, opacity);
8791						ctx.fillRect(pt.x, pt.y, bodyFontSize, bodyFontSize);
8792
8793						// Border
8794						ctx.lineWidth = 1;
8795						ctx.strokeStyle = mergeOpacity(vm.labelColors[i].borderColor, opacity);
8796						ctx.strokeRect(pt.x, pt.y, bodyFontSize, bodyFontSize);
8797
8798						// Inner square
8799						ctx.fillStyle = mergeOpacity(vm.labelColors[i].backgroundColor, opacity);
8800						ctx.fillRect(pt.x + 1, pt.y + 1, bodyFontSize - 2, bodyFontSize - 2);
8801						ctx.fillStyle = textColor;
8802					}
8803
8804					fillLineOfText(line);
8805				});
8806
8807				helpers.each(bodyItem.after, fillLineOfText);
8808			});
8809
8810			// Reset back to 0 for after body
8811			xLinePadding = 0;
8812
8813			// After body lines
8814			helpers.each(vm.afterBody, fillLineOfText);
8815			pt.y -= bodySpacing; // Remove last body spacing
8816		},
8817		drawFooter: function(pt, vm, ctx, opacity) {
8818			var footer = vm.footer;
8819
8820			if (footer.length) {
8821				pt.y += vm.footerMarginTop;
8822
8823				ctx.textAlign = vm._footerAlign;
8824				ctx.textBaseline = 'top';
8825
8826				ctx.fillStyle = mergeOpacity(vm.footerFontColor, opacity);
8827				ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);
8828
8829				helpers.each(footer, function(line) {
8830					ctx.fillText(line, pt.x, pt.y);
8831					pt.y += vm.footerFontSize + vm.footerSpacing;
8832				});
8833			}
8834		},
8835		drawBackground: function(pt, vm, ctx, tooltipSize, opacity) {
8836			ctx.fillStyle = mergeOpacity(vm.backgroundColor, opacity);
8837			ctx.strokeStyle = mergeOpacity(vm.borderColor, opacity);
8838			ctx.lineWidth = vm.borderWidth;
8839			var xAlign = vm.xAlign;
8840			var yAlign = vm.yAlign;
8841			var x = pt.x;
8842			var y = pt.y;
8843			var width = tooltipSize.width;
8844			var height = tooltipSize.height;
8845			var radius = vm.cornerRadius;
8846
8847			ctx.beginPath();
8848			ctx.moveTo(x + radius, y);
8849			if (yAlign === 'top') {
8850				this.drawCaret(pt, tooltipSize);
8851			}
8852			ctx.lineTo(x + width - radius, y);
8853			ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
8854			if (yAlign === 'center' && xAlign === 'right') {
8855				this.drawCaret(pt, tooltipSize);
8856			}
8857			ctx.lineTo(x + width, y + height - radius);
8858			ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
8859			if (yAlign === 'bottom') {
8860				this.drawCaret(pt, tooltipSize);
8861			}
8862			ctx.lineTo(x + radius, y + height);
8863			ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
8864			if (yAlign === 'center' && xAlign === 'left') {
8865				this.drawCaret(pt, tooltipSize);
8866			}
8867			ctx.lineTo(x, y + radius);
8868			ctx.quadraticCurveTo(x, y, x + radius, y);
8869			ctx.closePath();
8870
8871			ctx.fill();
8872
8873			if (vm.borderWidth > 0) {
8874				ctx.stroke();
8875			}
8876		},
8877		draw: function() {
8878			var ctx = this._chart.ctx;
8879			var vm = this._view;
8880
8881			if (vm.opacity === 0) {
8882				return;
8883			}
8884
8885			var tooltipSize = {
8886				width: vm.width,
8887				height: vm.height
8888			};
8889			var pt = {
8890				x: vm.x,
8891				y: vm.y
8892			};
8893
8894			// IE11/Edge does not like very small opacities, so snap to 0
8895			var opacity = Math.abs(vm.opacity < 1e-3) ? 0 : vm.opacity;
8896
8897			// Truthy/falsey value for empty tooltip
8898			var hasTooltipContent = vm.title.length || vm.beforeBody.length || vm.body.length || vm.afterBody.length || vm.footer.length;
8899
8900			if (this._options.enabled && hasTooltipContent) {
8901				// Draw Background
8902				this.drawBackground(pt, vm, ctx, tooltipSize, opacity);
8903
8904				// Draw Title, Body, and Footer
8905				pt.x += vm.xPadding;
8906				pt.y += vm.yPadding;
8907
8908				// Titles
8909				this.drawTitle(pt, vm, ctx, opacity);
8910
8911				// Body
8912				this.drawBody(pt, vm, ctx, opacity);
8913
8914				// Footer
8915				this.drawFooter(pt, vm, ctx, opacity);
8916			}
8917		},
8918
8919		/**
8920		 * Handle an event
8921		 * @private
8922		 * @param {IEvent} event - The event to handle
8923		 * @returns {Boolean} true if the tooltip changed
8924		 */
8925		handleEvent: function(e) {
8926			var me = this;
8927			var options = me._options;
8928			var changed = false;
8929
8930			me._lastActive = me._lastActive || [];
8931
8932			// Find Active Elements for tooltips
8933			if (e.type === 'mouseout') {
8934				me._active = [];
8935			} else {
8936				me._active = me._chart.getElementsAtEventForMode(e, options.mode, options);
8937			}
8938
8939			// Remember Last Actives
8940			changed = !helpers.arrayEquals(me._active, me._lastActive);
8941
8942			// Only handle target event on tooltip change
8943			if (changed) {
8944				me._lastActive = me._active;
8945
8946				if (options.enabled || options.custom) {
8947					me._eventPosition = {
8948						x: e.x,
8949						y: e.y
8950					};
8951
8952					me.update(true);
8953					me.pivot();
8954				}
8955			}
8956
8957			return changed;
8958		}
8959	});
8960
8961	/**
8962	 * @namespace Chart.Tooltip.positioners
8963	 */
8964	Chart.Tooltip.positioners = {
8965		/**
8966		 * Average mode places the tooltip at the average position of the elements shown
8967		 * @function Chart.Tooltip.positioners.average
8968		 * @param elements {ChartElement[]} the elements being displayed in the tooltip
8969		 * @returns {Point} tooltip position
8970		 */
8971		average: function(elements) {
8972			if (!elements.length) {
8973				return false;
8974			}
8975
8976			var i, len;
8977			var x = 0;
8978			var y = 0;
8979			var count = 0;
8980
8981			for (i = 0, len = elements.length; i < len; ++i) {
8982				var el = elements[i];
8983				if (el && el.hasValue()) {
8984					var pos = el.tooltipPosition();
8985					x += pos.x;
8986					y += pos.y;
8987					++count;
8988				}
8989			}
8990
8991			return {
8992				x: Math.round(x / count),
8993				y: Math.round(y / count)
8994			};
8995		},
8996
8997		/**
8998		 * Gets the tooltip position nearest of the item nearest to the event position
8999		 * @function Chart.Tooltip.positioners.nearest
9000		 * @param elements {Chart.Element[]} the tooltip elements
9001		 * @param eventPosition {Point} the position of the event in canvas coordinates
9002		 * @returns {Point} the tooltip position
9003		 */
9004		nearest: function(elements, eventPosition) {
9005			var x = eventPosition.x;
9006			var y = eventPosition.y;
9007			var minDistance = Number.POSITIVE_INFINITY;
9008			var i, len, nearestElement;
9009
9010			for (i = 0, len = elements.length; i < len; ++i) {
9011				var el = elements[i];
9012				if (el && el.hasValue()) {
9013					var center = el.getCenterPoint();
9014					var d = helpers.distanceBetweenPoints(eventPosition, center);
9015
9016					if (d < minDistance) {
9017						minDistance = d;
9018						nearestElement = el;
9019					}
9020				}
9021			}
9022
9023			if (nearestElement) {
9024				var tp = nearestElement.tooltipPosition();
9025				x = tp.x;
9026				y = tp.y;
9027			}
9028
9029			return {
9030				x: x,
9031				y: y
9032			};
9033		}
9034	};
9035};
9036
9037},{"25":25,"26":26,"45":45}],36:[function(require,module,exports){
9038'use strict';
9039
9040var defaults = require(25);
9041var Element = require(26);
9042var helpers = require(45);
9043
9044defaults._set('global', {
9045	elements: {
9046		arc: {
9047			backgroundColor: defaults.global.defaultColor,
9048			borderColor: '#fff',
9049			borderWidth: 2
9050		}
9051	}
9052});
9053
9054module.exports = Element.extend({
9055	inLabelRange: function(mouseX) {
9056		var vm = this._view;
9057
9058		if (vm) {
9059			return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2));
9060		}
9061		return false;
9062	},
9063
9064	inRange: function(chartX, chartY) {
9065		var vm = this._view;
9066
9067		if (vm) {
9068			var pointRelativePosition = helpers.getAngleFromPoint(vm, {x: chartX, y: chartY});
9069			var	angle = pointRelativePosition.angle;
9070			var distance = pointRelativePosition.distance;
9071
9072			// Sanitise angle range
9073			var startAngle = vm.startAngle;
9074			var endAngle = vm.endAngle;
9075			while (endAngle < startAngle) {
9076				endAngle += 2.0 * Math.PI;
9077			}
9078			while (angle > endAngle) {
9079				angle -= 2.0 * Math.PI;
9080			}
9081			while (angle < startAngle) {
9082				angle += 2.0 * Math.PI;
9083			}
9084
9085			// Check if within the range of the open/close angle
9086			var betweenAngles = (angle >= startAngle && angle <= endAngle);
9087			var withinRadius = (distance >= vm.innerRadius && distance <= vm.outerRadius);
9088
9089			return (betweenAngles && withinRadius);
9090		}
9091		return false;
9092	},
9093
9094	getCenterPoint: function() {
9095		var vm = this._view;
9096		var halfAngle = (vm.startAngle + vm.endAngle) / 2;
9097		var halfRadius = (vm.innerRadius + vm.outerRadius) / 2;
9098		return {
9099			x: vm.x + Math.cos(halfAngle) * halfRadius,
9100			y: vm.y + Math.sin(halfAngle) * halfRadius
9101		};
9102	},
9103
9104	getArea: function() {
9105		var vm = this._view;
9106		return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math.pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2));
9107	},
9108
9109	tooltipPosition: function() {
9110		var vm = this._view;
9111		var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2);
9112		var rangeFromCentre = (vm.outerRadius - vm.innerRadius) / 2 + vm.innerRadius;
9113
9114		return {
9115			x: vm.x + (Math.cos(centreAngle) * rangeFromCentre),
9116			y: vm.y + (Math.sin(centreAngle) * rangeFromCentre)
9117		};
9118	},
9119
9120	draw: function() {
9121		var ctx = this._chart.ctx;
9122		var vm = this._view;
9123		var sA = vm.startAngle;
9124		var eA = vm.endAngle;
9125
9126		ctx.beginPath();
9127
9128		ctx.arc(vm.x, vm.y, vm.outerRadius, sA, eA);
9129		ctx.arc(vm.x, vm.y, vm.innerRadius, eA, sA, true);
9130
9131		ctx.closePath();
9132		ctx.strokeStyle = vm.borderColor;
9133		ctx.lineWidth = vm.borderWidth;
9134
9135		ctx.fillStyle = vm.backgroundColor;
9136
9137		ctx.fill();
9138		ctx.lineJoin = 'bevel';
9139
9140		if (vm.borderWidth) {
9141			ctx.stroke();
9142		}
9143	}
9144});
9145
9146},{"25":25,"26":26,"45":45}],37:[function(require,module,exports){
9147'use strict';
9148
9149var defaults = require(25);
9150var Element = require(26);
9151var helpers = require(45);
9152
9153var globalDefaults = defaults.global;
9154
9155defaults._set('global', {
9156	elements: {
9157		line: {
9158			tension: 0.4,
9159			backgroundColor: globalDefaults.defaultColor,
9160			borderWidth: 3,
9161			borderColor: globalDefaults.defaultColor,
9162			borderCapStyle: 'butt',
9163			borderDash: [],
9164			borderDashOffset: 0.0,
9165			borderJoinStyle: 'miter',
9166			capBezierPoints: true,
9167			fill: true, // do we fill in the area between the line and its base axis
9168		}
9169	}
9170});
9171
9172module.exports = Element.extend({
9173	draw: function() {
9174		var me = this;
9175		var vm = me._view;
9176		var ctx = me._chart.ctx;
9177		var spanGaps = vm.spanGaps;
9178		var points = me._children.slice(); // clone array
9179		var globalOptionLineElements = globalDefaults.elements.line;
9180		var lastDrawnIndex = -1;
9181		var index, current, previous, currentVM;
9182
9183		// If we are looping, adding the first point again
9184		if (me._loop && points.length) {
9185			points.push(points[0]);
9186		}
9187
9188		ctx.save();
9189
9190		// Stroke Line Options
9191		ctx.lineCap = vm.borderCapStyle || globalOptionLineElements.borderCapStyle;
9192
9193		// IE 9 and 10 do not support line dash
9194		if (ctx.setLineDash) {
9195			ctx.setLineDash(vm.borderDash || globalOptionLineElements.borderDash);
9196		}
9197
9198		ctx.lineDashOffset = vm.borderDashOffset || globalOptionLineElements.borderDashOffset;
9199		ctx.lineJoin = vm.borderJoinStyle || globalOptionLineElements.borderJoinStyle;
9200		ctx.lineWidth = vm.borderWidth || globalOptionLineElements.borderWidth;
9201		ctx.strokeStyle = vm.borderColor || globalDefaults.defaultColor;
9202
9203		// Stroke Line
9204		ctx.beginPath();
9205		lastDrawnIndex = -1;
9206
9207		for (index = 0; index < points.length; ++index) {
9208			current = points[index];
9209			previous = helpers.previousItem(points, index);
9210			currentVM = current._view;
9211
9212			// First point moves to it's starting position no matter what
9213			if (index === 0) {
9214				if (!currentVM.skip) {
9215					ctx.moveTo(currentVM.x, currentVM.y);
9216					lastDrawnIndex = index;
9217				}
9218			} else {
9219				previous = lastDrawnIndex === -1 ? previous : points[lastDrawnIndex];
9220
9221				if (!currentVM.skip) {
9222					if ((lastDrawnIndex !== (index - 1) && !spanGaps) || lastDrawnIndex === -1) {
9223						// There was a gap and this is the first point after the gap
9224						ctx.moveTo(currentVM.x, currentVM.y);
9225					} else {
9226						// Line to next point
9227						helpers.canvas.lineTo(ctx, previous._view, current._view);
9228					}
9229					lastDrawnIndex = index;
9230				}
9231			}
9232		}
9233
9234		ctx.stroke();
9235		ctx.restore();
9236	}
9237});
9238
9239},{"25":25,"26":26,"45":45}],38:[function(require,module,exports){
9240'use strict';
9241
9242var defaults = require(25);
9243var Element = require(26);
9244var helpers = require(45);
9245
9246var defaultColor = defaults.global.defaultColor;
9247
9248defaults._set('global', {
9249	elements: {
9250		point: {
9251			radius: 3,
9252			pointStyle: 'circle',
9253			backgroundColor: defaultColor,
9254			borderColor: defaultColor,
9255			borderWidth: 1,
9256			// Hover
9257			hitRadius: 1,
9258			hoverRadius: 4,
9259			hoverBorderWidth: 1
9260		}
9261	}
9262});
9263
9264function xRange(mouseX) {
9265	var vm = this._view;
9266	return vm ? (Math.abs(mouseX - vm.x) < vm.radius + vm.hitRadius) : false;
9267}
9268
9269function yRange(mouseY) {
9270	var vm = this._view;
9271	return vm ? (Math.abs(mouseY - vm.y) < vm.radius + vm.hitRadius) : false;
9272}
9273
9274module.exports = Element.extend({
9275	inRange: function(mouseX, mouseY) {
9276		var vm = this._view;
9277		return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(vm.hitRadius + vm.radius, 2)) : false;
9278	},
9279
9280	inLabelRange: xRange,
9281	inXRange: xRange,
9282	inYRange: yRange,
9283
9284	getCenterPoint: function() {
9285		var vm = this._view;
9286		return {
9287			x: vm.x,
9288			y: vm.y
9289		};
9290	},
9291
9292	getArea: function() {
9293		return Math.PI * Math.pow(this._view.radius, 2);
9294	},
9295
9296	tooltipPosition: function() {
9297		var vm = this._view;
9298		return {
9299			x: vm.x,
9300			y: vm.y,
9301			padding: vm.radius + vm.borderWidth
9302		};
9303	},
9304
9305	draw: function(chartArea) {
9306		var vm = this._view;
9307		var model = this._model;
9308		var ctx = this._chart.ctx;
9309		var pointStyle = vm.pointStyle;
9310		var radius = vm.radius;
9311		var x = vm.x;
9312		var y = vm.y;
9313		var color = helpers.color;
9314		var errMargin = 1.01; // 1.01 is margin for Accumulated error. (Especially Edge, IE.)
9315		var ratio = 0;
9316
9317		if (vm.skip) {
9318			return;
9319		}
9320
9321		ctx.strokeStyle = vm.borderColor || defaultColor;
9322		ctx.lineWidth = helpers.valueOrDefault(vm.borderWidth, defaults.global.elements.point.borderWidth);
9323		ctx.fillStyle = vm.backgroundColor || defaultColor;
9324
9325		// Cliping for Points.
9326		// going out from inner charArea?
9327		if ((chartArea !== undefined) && ((model.x < chartArea.left) || (chartArea.right * errMargin < model.x) || (model.y < chartArea.top) || (chartArea.bottom * errMargin < model.y))) {
9328			// Point fade out
9329			if (model.x < chartArea.left) {
9330				ratio = (x - model.x) / (chartArea.left - model.x);
9331			} else if (chartArea.right * errMargin < model.x) {
9332				ratio = (model.x - x) / (model.x - chartArea.right);
9333			} else if (model.y < chartArea.top) {
9334				ratio = (y - model.y) / (chartArea.top - model.y);
9335			} else if (chartArea.bottom * errMargin < model.y) {
9336				ratio = (model.y - y) / (model.y - chartArea.bottom);
9337			}
9338			ratio = Math.round(ratio * 100) / 100;
9339			ctx.strokeStyle = color(ctx.strokeStyle).alpha(ratio).rgbString();
9340			ctx.fillStyle = color(ctx.fillStyle).alpha(ratio).rgbString();
9341		}
9342
9343		helpers.canvas.drawPoint(ctx, pointStyle, radius, x, y);
9344	}
9345});
9346
9347},{"25":25,"26":26,"45":45}],39:[function(require,module,exports){
9348'use strict';
9349
9350var defaults = require(25);
9351var Element = require(26);
9352
9353defaults._set('global', {
9354	elements: {
9355		rectangle: {
9356			backgroundColor: defaults.global.defaultColor,
9357			borderColor: defaults.global.defaultColor,
9358			borderSkipped: 'bottom',
9359			borderWidth: 0
9360		}
9361	}
9362});
9363
9364function isVertical(bar) {
9365	return bar._view.width !== undefined;
9366}
9367
9368/**
9369 * Helper function to get the bounds of the bar regardless of the orientation
9370 * @param bar {Chart.Element.Rectangle} the bar
9371 * @return {Bounds} bounds of the bar
9372 * @private
9373 */
9374function getBarBounds(bar) {
9375	var vm = bar._view;
9376	var x1, x2, y1, y2;
9377
9378	if (isVertical(bar)) {
9379		// vertical
9380		var halfWidth = vm.width / 2;
9381		x1 = vm.x - halfWidth;
9382		x2 = vm.x + halfWidth;
9383		y1 = Math.min(vm.y, vm.base);
9384		y2 = Math.max(vm.y, vm.base);
9385	} else {
9386		// horizontal bar
9387		var halfHeight = vm.height / 2;
9388		x1 = Math.min(vm.x, vm.base);
9389		x2 = Math.max(vm.x, vm.base);
9390		y1 = vm.y - halfHeight;
9391		y2 = vm.y + halfHeight;
9392	}
9393
9394	return {
9395		left: x1,
9396		top: y1,
9397		right: x2,
9398		bottom: y2
9399	};
9400}
9401
9402module.exports = Element.extend({
9403	draw: function() {
9404		var ctx = this._chart.ctx;
9405		var vm = this._view;
9406		var left, right, top, bottom, signX, signY, borderSkipped;
9407		var borderWidth = vm.borderWidth;
9408
9409		if (!vm.horizontal) {
9410			// bar
9411			left = vm.x - vm.width / 2;
9412			right = vm.x + vm.width / 2;
9413			top = vm.y;
9414			bottom = vm.base;
9415			signX = 1;
9416			signY = bottom > top ? 1 : -1;
9417			borderSkipped = vm.borderSkipped || 'bottom';
9418		} else {
9419			// horizontal bar
9420			left = vm.base;
9421			right = vm.x;
9422			top = vm.y - vm.height / 2;
9423			bottom = vm.y + vm.height / 2;
9424			signX = right > left ? 1 : -1;
9425			signY = 1;
9426			borderSkipped = vm.borderSkipped || 'left';
9427		}
9428
9429		// Canvas doesn't allow us to stroke inside the width so we can
9430		// adjust the sizes to fit if we're setting a stroke on the line
9431		if (borderWidth) {
9432			// borderWidth shold be less than bar width and bar height.
9433			var barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom));
9434			borderWidth = borderWidth > barSize ? barSize : borderWidth;
9435			var halfStroke = borderWidth / 2;
9436			// Adjust borderWidth when bar top position is near vm.base(zero).
9437			var borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0);
9438			var borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0);
9439			var borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0);
9440			var borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0);
9441			// not become a vertical line?
9442			if (borderLeft !== borderRight) {
9443				top = borderTop;
9444				bottom = borderBottom;
9445			}
9446			// not become a horizontal line?
9447			if (borderTop !== borderBottom) {
9448				left = borderLeft;
9449				right = borderRight;
9450			}
9451		}
9452
9453		ctx.beginPath();
9454		ctx.fillStyle = vm.backgroundColor;
9455		ctx.strokeStyle = vm.borderColor;
9456		ctx.lineWidth = borderWidth;
9457
9458		// Corner points, from bottom-left to bottom-right clockwise
9459		// | 1 2 |
9460		// | 0 3 |
9461		var corners = [
9462			[left, bottom],
9463			[left, top],
9464			[right, top],
9465			[right, bottom]
9466		];
9467
9468		// Find first (starting) corner with fallback to 'bottom'
9469		var borders = ['bottom', 'left', 'top', 'right'];
9470		var startCorner = borders.indexOf(borderSkipped, 0);
9471		if (startCorner === -1) {
9472			startCorner = 0;
9473		}
9474
9475		function cornerAt(index) {
9476			return corners[(startCorner + index) % 4];
9477		}
9478
9479		// Draw rectangle from 'startCorner'
9480		var corner = cornerAt(0);
9481		ctx.moveTo(corner[0], corner[1]);
9482
9483		for (var i = 1; i < 4; i++) {
9484			corner = cornerAt(i);
9485			ctx.lineTo(corner[0], corner[1]);
9486		}
9487
9488		ctx.fill();
9489		if (borderWidth) {
9490			ctx.stroke();
9491		}
9492	},
9493
9494	height: function() {
9495		var vm = this._view;
9496		return vm.base - vm.y;
9497	},
9498
9499	inRange: function(mouseX, mouseY) {
9500		var inRange = false;
9501
9502		if (this._view) {
9503			var bounds = getBarBounds(this);
9504			inRange = mouseX >= bounds.left && mouseX <= bounds.right && mouseY >= bounds.top && mouseY <= bounds.bottom;
9505		}
9506
9507		return inRange;
9508	},
9509
9510	inLabelRange: function(mouseX, mouseY) {
9511		var me = this;
9512		if (!me._view) {
9513			return false;
9514		}
9515
9516		var inRange = false;
9517		var bounds = getBarBounds(me);
9518
9519		if (isVertical(me)) {
9520			inRange = mouseX >= bounds.left && mouseX <= bounds.right;
9521		} else {
9522			inRange = mouseY >= bounds.top && mouseY <= bounds.bottom;
9523		}
9524
9525		return inRange;
9526	},
9527
9528	inXRange: function(mouseX) {
9529		var bounds = getBarBounds(this);
9530		return mouseX >= bounds.left && mouseX <= bounds.right;
9531	},
9532
9533	inYRange: function(mouseY) {
9534		var bounds = getBarBounds(this);
9535		return mouseY >= bounds.top && mouseY <= bounds.bottom;
9536	},
9537
9538	getCenterPoint: function() {
9539		var vm = this._view;
9540		var x, y;
9541		if (isVertical(this)) {
9542			x = vm.x;
9543			y = (vm.y + vm.base) / 2;
9544		} else {
9545			x = (vm.x + vm.base) / 2;
9546			y = vm.y;
9547		}
9548
9549		return {x: x, y: y};
9550	},
9551
9552	getArea: function() {
9553		var vm = this._view;
9554		return vm.width * Math.abs(vm.y - vm.base);
9555	},
9556
9557	tooltipPosition: function() {
9558		var vm = this._view;
9559		return {
9560			x: vm.x,
9561			y: vm.y
9562		};
9563	}
9564});
9565
9566},{"25":25,"26":26}],40:[function(require,module,exports){
9567'use strict';
9568
9569module.exports = {};
9570module.exports.Arc = require(36);
9571module.exports.Line = require(37);
9572module.exports.Point = require(38);
9573module.exports.Rectangle = require(39);
9574
9575},{"36":36,"37":37,"38":38,"39":39}],41:[function(require,module,exports){
9576'use strict';
9577
9578var helpers = require(42);
9579
9580/**
9581 * @namespace Chart.helpers.canvas
9582 */
9583var exports = module.exports = {
9584	/**
9585	 * Clears the entire canvas associated to the given `chart`.
9586	 * @param {Chart} chart - The chart for which to clear the canvas.
9587	 */
9588	clear: function(chart) {
9589		chart.ctx.clearRect(0, 0, chart.width, chart.height);
9590	},
9591
9592	/**
9593	 * Creates a "path" for a rectangle with rounded corners at position (x, y) with a
9594	 * given size (width, height) and the same `radius` for all corners.
9595	 * @param {CanvasRenderingContext2D} ctx - The canvas 2D Context.
9596	 * @param {Number} x - The x axis of the coordinate for the rectangle starting point.
9597	 * @param {Number} y - The y axis of the coordinate for the rectangle starting point.
9598	 * @param {Number} width - The rectangle's width.
9599	 * @param {Number} height - The rectangle's height.
9600	 * @param {Number} radius - The rounded amount (in pixels) for the four corners.
9601	 * @todo handle `radius` as top-left, top-right, bottom-right, bottom-left array/object?
9602	 */
9603	roundedRect: function(ctx, x, y, width, height, radius) {
9604		if (radius) {
9605			var rx = Math.min(radius, width / 2);
9606			var ry = Math.min(radius, height / 2);
9607
9608			ctx.moveTo(x + rx, y);
9609			ctx.lineTo(x + width - rx, y);
9610			ctx.quadraticCurveTo(x + width, y, x + width, y + ry);
9611			ctx.lineTo(x + width, y + height - ry);
9612			ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height);
9613			ctx.lineTo(x + rx, y + height);
9614			ctx.quadraticCurveTo(x, y + height, x, y + height - ry);
9615			ctx.lineTo(x, y + ry);
9616			ctx.quadraticCurveTo(x, y, x + rx, y);
9617		} else {
9618			ctx.rect(x, y, width, height);
9619		}
9620	},
9621
9622	drawPoint: function(ctx, style, radius, x, y) {
9623		var type, edgeLength, xOffset, yOffset, height, size;
9624
9625		if (style && typeof style === 'object') {
9626			type = style.toString();
9627			if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {
9628				ctx.drawImage(style, x - style.width / 2, y - style.height / 2, style.width, style.height);
9629				return;
9630			}
9631		}
9632
9633		if (isNaN(radius) || radius <= 0) {
9634			return;
9635		}
9636
9637		switch (style) {
9638		// Default includes circle
9639		default:
9640			ctx.beginPath();
9641			ctx.arc(x, y, radius, 0, Math.PI * 2);
9642			ctx.closePath();
9643			ctx.fill();
9644			break;
9645		case 'triangle':
9646			ctx.beginPath();
9647			edgeLength = 3 * radius / Math.sqrt(3);
9648			height = edgeLength * Math.sqrt(3) / 2;
9649			ctx.moveTo(x - edgeLength / 2, y + height / 3);
9650			ctx.lineTo(x + edgeLength / 2, y + height / 3);
9651			ctx.lineTo(x, y - 2 * height / 3);
9652			ctx.closePath();
9653			ctx.fill();
9654			break;
9655		case 'rect':
9656			size = 1 / Math.SQRT2 * radius;
9657			ctx.beginPath();
9658			ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
9659			ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
9660			break;
9661		case 'rectRounded':
9662			var offset = radius / Math.SQRT2;
9663			var leftX = x - offset;
9664			var topY = y - offset;
9665			var sideSize = Math.SQRT2 * radius;
9666			ctx.beginPath();
9667			this.roundedRect(ctx, leftX, topY, sideSize, sideSize, radius / 2);
9668			ctx.closePath();
9669			ctx.fill();
9670			break;
9671		case 'rectRot':
9672			size = 1 / Math.SQRT2 * radius;
9673			ctx.beginPath();
9674			ctx.moveTo(x - size, y);
9675			ctx.lineTo(x, y + size);
9676			ctx.lineTo(x + size, y);
9677			ctx.lineTo(x, y - size);
9678			ctx.closePath();
9679			ctx.fill();
9680			break;
9681		case 'cross':
9682			ctx.beginPath();
9683			ctx.moveTo(x, y + radius);
9684			ctx.lineTo(x, y - radius);
9685			ctx.moveTo(x - radius, y);
9686			ctx.lineTo(x + radius, y);
9687			ctx.closePath();
9688			break;
9689		case 'crossRot':
9690			ctx.beginPath();
9691			xOffset = Math.cos(Math.PI / 4) * radius;
9692			yOffset = Math.sin(Math.PI / 4) * radius;
9693			ctx.moveTo(x - xOffset, y - yOffset);
9694			ctx.lineTo(x + xOffset, y + yOffset);
9695			ctx.moveTo(x - xOffset, y + yOffset);
9696			ctx.lineTo(x + xOffset, y - yOffset);
9697			ctx.closePath();
9698			break;
9699		case 'star':
9700			ctx.beginPath();
9701			ctx.moveTo(x, y + radius);
9702			ctx.lineTo(x, y - radius);
9703			ctx.moveTo(x - radius, y);
9704			ctx.lineTo(x + radius, y);
9705			xOffset = Math.cos(Math.PI / 4) * radius;
9706			yOffset = Math.sin(Math.PI / 4) * radius;
9707			ctx.moveTo(x - xOffset, y - yOffset);
9708			ctx.lineTo(x + xOffset, y + yOffset);
9709			ctx.moveTo(x - xOffset, y + yOffset);
9710			ctx.lineTo(x + xOffset, y - yOffset);
9711			ctx.closePath();
9712			break;
9713		case 'line':
9714			ctx.beginPath();
9715			ctx.moveTo(x - radius, y);
9716			ctx.lineTo(x + radius, y);
9717			ctx.closePath();
9718			break;
9719		case 'dash':
9720			ctx.beginPath();
9721			ctx.moveTo(x, y);
9722			ctx.lineTo(x + radius, y);
9723			ctx.closePath();
9724			break;
9725		}
9726
9727		ctx.stroke();
9728	},
9729
9730	clipArea: function(ctx, area) {
9731		ctx.save();
9732		ctx.beginPath();
9733		ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);
9734		ctx.clip();
9735	},
9736
9737	unclipArea: function(ctx) {
9738		ctx.restore();
9739	},
9740
9741	lineTo: function(ctx, previous, target, flip) {
9742		if (target.steppedLine) {
9743			if ((target.steppedLine === 'after' && !flip) || (target.steppedLine !== 'after' && flip)) {
9744				ctx.lineTo(previous.x, target.y);
9745			} else {
9746				ctx.lineTo(target.x, previous.y);
9747			}
9748			ctx.lineTo(target.x, target.y);
9749			return;
9750		}
9751
9752		if (!target.tension) {
9753			ctx.lineTo(target.x, target.y);
9754			return;
9755		}
9756
9757		ctx.bezierCurveTo(
9758			flip ? previous.controlPointPreviousX : previous.controlPointNextX,
9759			flip ? previous.controlPointPreviousY : previous.controlPointNextY,
9760			flip ? target.controlPointNextX : target.controlPointPreviousX,
9761			flip ? target.controlPointNextY : target.controlPointPreviousY,
9762			target.x,
9763			target.y);
9764	}
9765};
9766
9767// DEPRECATIONS
9768
9769/**
9770 * Provided for backward compatibility, use Chart.helpers.canvas.clear instead.
9771 * @namespace Chart.helpers.clear
9772 * @deprecated since version 2.7.0
9773 * @todo remove at version 3
9774 * @private
9775 */
9776helpers.clear = exports.clear;
9777
9778/**
9779 * Provided for backward compatibility, use Chart.helpers.canvas.roundedRect instead.
9780 * @namespace Chart.helpers.drawRoundedRectangle
9781 * @deprecated since version 2.7.0
9782 * @todo remove at version 3
9783 * @private
9784 */
9785helpers.drawRoundedRectangle = function(ctx) {
9786	ctx.beginPath();
9787	exports.roundedRect.apply(exports, arguments);
9788	ctx.closePath();
9789};
9790
9791},{"42":42}],42:[function(require,module,exports){
9792'use strict';
9793
9794/**
9795 * @namespace Chart.helpers
9796 */
9797var helpers = {
9798	/**
9799	 * An empty function that can be used, for example, for optional callback.
9800	 */
9801	noop: function() {},
9802
9803	/**
9804	 * Returns a unique id, sequentially generated from a global variable.
9805	 * @returns {Number}
9806	 * @function
9807	 */
9808	uid: (function() {
9809		var id = 0;
9810		return function() {
9811			return id++;
9812		};
9813	}()),
9814
9815	/**
9816	 * Returns true if `value` is neither null nor undefined, else returns false.
9817	 * @param {*} value - The value to test.
9818	 * @returns {Boolean}
9819	 * @since 2.7.0
9820	 */
9821	isNullOrUndef: function(value) {
9822		return value === null || typeof value === 'undefined';
9823	},
9824
9825	/**
9826	 * Returns true if `value` is an array, else returns false.
9827	 * @param {*} value - The value to test.
9828	 * @returns {Boolean}
9829	 * @function
9830	 */
9831	isArray: Array.isArray ? Array.isArray : function(value) {
9832		return Object.prototype.toString.call(value) === '[object Array]';
9833	},
9834
9835	/**
9836	 * Returns true if `value` is an object (excluding null), else returns false.
9837	 * @param {*} value - The value to test.
9838	 * @returns {Boolean}
9839	 * @since 2.7.0
9840	 */
9841	isObject: function(value) {
9842		return value !== null && Object.prototype.toString.call(value) === '[object Object]';
9843	},
9844
9845	/**
9846	 * Returns `value` if defined, else returns `defaultValue`.
9847	 * @param {*} value - The value to return if defined.
9848	 * @param {*} defaultValue - The value to return if `value` is undefined.
9849	 * @returns {*}
9850	 */
9851	valueOrDefault: function(value, defaultValue) {
9852		return typeof value === 'undefined' ? defaultValue : value;
9853	},
9854
9855	/**
9856	 * Returns value at the given `index` in array if defined, else returns `defaultValue`.
9857	 * @param {Array} value - The array to lookup for value at `index`.
9858	 * @param {Number} index - The index in `value` to lookup for value.
9859	 * @param {*} defaultValue - The value to return if `value[index]` is undefined.
9860	 * @returns {*}
9861	 */
9862	valueAtIndexOrDefault: function(value, index, defaultValue) {
9863		return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue);
9864	},
9865
9866	/**
9867	 * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
9868	 * value returned by `fn`. If `fn` is not a function, this method returns undefined.
9869	 * @param {Function} fn - The function to call.
9870	 * @param {Array|undefined|null} args - The arguments with which `fn` should be called.
9871	 * @param {Object} [thisArg] - The value of `this` provided for the call to `fn`.
9872	 * @returns {*}
9873	 */
9874	callback: function(fn, args, thisArg) {
9875		if (fn && typeof fn.call === 'function') {
9876			return fn.apply(thisArg, args);
9877		}
9878	},
9879
9880	/**
9881	 * Note(SB) for performance sake, this method should only be used when loopable type
9882	 * is unknown or in none intensive code (not called often and small loopable). Else
9883	 * it's preferable to use a regular for() loop and save extra function calls.
9884	 * @param {Object|Array} loopable - The object or array to be iterated.
9885	 * @param {Function} fn - The function to call for each item.
9886	 * @param {Object} [thisArg] - The value of `this` provided for the call to `fn`.
9887	 * @param {Boolean} [reverse] - If true, iterates backward on the loopable.
9888	 */
9889	each: function(loopable, fn, thisArg, reverse) {
9890		var i, len, keys;
9891		if (helpers.isArray(loopable)) {
9892			len = loopable.length;
9893			if (reverse) {
9894				for (i = len - 1; i >= 0; i--) {
9895					fn.call(thisArg, loopable[i], i);
9896				}
9897			} else {
9898				for (i = 0; i < len; i++) {
9899					fn.call(thisArg, loopable[i], i);
9900				}
9901			}
9902		} else if (helpers.isObject(loopable)) {
9903			keys = Object.keys(loopable);
9904			len = keys.length;
9905			for (i = 0; i < len; i++) {
9906				fn.call(thisArg, loopable[keys[i]], keys[i]);
9907			}
9908		}
9909	},
9910
9911	/**
9912	 * Returns true if the `a0` and `a1` arrays have the same content, else returns false.
9913	 * @see http://stackoverflow.com/a/14853974
9914	 * @param {Array} a0 - The array to compare
9915	 * @param {Array} a1 - The array to compare
9916	 * @returns {Boolean}
9917	 */
9918	arrayEquals: function(a0, a1) {
9919		var i, ilen, v0, v1;
9920
9921		if (!a0 || !a1 || a0.length !== a1.length) {
9922			return false;
vendor: 10,367 bytes, lines 9923-10376
9923		}
9924
9925		for (i = 0, ilen = a0.length; i < ilen; ++i) {
9926			v0 = a0[i];
9927			v1 = a1[i];
9928
9929			if (v0 instanceof Array && v1 instanceof Array) {
9930				if (!helpers.arrayEquals(v0, v1)) {
9931					return false;
9932				}
9933			} else if (v0 !== v1) {
9934				// NOTE: two different object instances will never be equal: {x:20} != {x:20}
9935				return false;
9936			}
9937		}
9938
9939		return true;
9940	},
9941
9942	/**
9943	 * Returns a deep copy of `source` without keeping references on objects and arrays.
9944	 * @param {*} source - The value to clone.
9945	 * @returns {*}
9946	 */
9947	clone: function(source) {
9948		if (helpers.isArray(source)) {
9949			return source.map(helpers.clone);
9950		}
9951
9952		if (helpers.isObject(source)) {
9953			var target = {};
9954			var keys = Object.keys(source);
9955			var klen = keys.length;
9956			var k = 0;
9957
9958			for (; k < klen; ++k) {
9959				target[keys[k]] = helpers.clone(source[keys[k]]);
9960			}
9961
9962			return target;
9963		}
9964
9965		return source;
9966	},
9967
9968	/**
9969	 * The default merger when Chart.helpers.merge is called without merger option.
9970	 * Note(SB): this method is also used by configMerge and scaleMerge as fallback.
9971	 * @private
9972	 */
9973	_merger: function(key, target, source, options) {
9974		var tval = target[key];
9975		var sval = source[key];
9976
9977		if (helpers.isObject(tval) && helpers.isObject(sval)) {
9978			helpers.merge(tval, sval, options);
9979		} else {
9980			target[key] = helpers.clone(sval);
9981		}
9982	},
9983
9984	/**
9985	 * Merges source[key] in target[key] only if target[key] is undefined.
9986	 * @private
9987	 */
9988	_mergerIf: function(key, target, source) {
9989		var tval = target[key];
9990		var sval = source[key];
9991
9992		if (helpers.isObject(tval) && helpers.isObject(sval)) {
9993			helpers.mergeIf(tval, sval);
9994		} else if (!target.hasOwnProperty(key)) {
9995			target[key] = helpers.clone(sval);
9996		}
9997	},
9998
9999	/**
10000	 * Recursively deep copies `source` properties into `target` with the given `options`.
10001	 * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
10002	 * @param {Object} target - The target object in which all sources are merged into.
10003	 * @param {Object|Array(Object)} source - Object(s) to merge into `target`.
10004	 * @param {Object} [options] - Merging options:
10005	 * @param {Function} [options.merger] - The merge method (key, target, source, options)
10006	 * @returns {Object} The `target` object.
10007	 */
10008	merge: function(target, source, options) {
10009		var sources = helpers.isArray(source) ? source : [source];
10010		var ilen = sources.length;
10011		var merge, i, keys, klen, k;
10012
10013		if (!helpers.isObject(target)) {
10014			return target;
10015		}
10016
10017		options = options || {};
10018		merge = options.merger || helpers._merger;
10019
10020		for (i = 0; i < ilen; ++i) {
10021			source = sources[i];
10022			if (!helpers.isObject(source)) {
10023				continue;
10024			}
10025
10026			keys = Object.keys(source);
10027			for (k = 0, klen = keys.length; k < klen; ++k) {
10028				merge(keys[k], target, source, options);
10029			}
10030		}
10031
10032		return target;
10033	},
10034
10035	/**
10036	 * Recursively deep copies `source` properties into `target` *only* if not defined in target.
10037	 * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
10038	 * @param {Object} target - The target object in which all sources are merged into.
10039	 * @param {Object|Array(Object)} source - Object(s) to merge into `target`.
10040	 * @returns {Object} The `target` object.
10041	 */
10042	mergeIf: function(target, source) {
10043		return helpers.merge(target, source, {merger: helpers._mergerIf});
10044	},
10045
10046	/**
10047	 * Applies the contents of two or more objects together into the first object.
10048	 * @param {Object} target - The target object in which all objects are merged into.
10049	 * @param {Object} arg1 - Object containing additional properties to merge in target.
10050	 * @param {Object} argN - Additional objects containing properties to merge in target.
10051	 * @returns {Object} The `target` object.
10052	 */
10053	extend: function(target) {
10054		var setFn = function(value, key) {
10055			target[key] = value;
10056		};
10057		for (var i = 1, ilen = arguments.length; i < ilen; ++i) {
10058			helpers.each(arguments[i], setFn);
10059		}
10060		return target;
10061	},
10062
10063	/**
10064	 * Basic javascript inheritance based on the model created in Backbone.js
10065	 */
10066	inherits: function(extensions) {
10067		var me = this;
10068		var ChartElement = (extensions && extensions.hasOwnProperty('constructor')) ? extensions.constructor : function() {
10069			return me.apply(this, arguments);
10070		};
10071
10072		var Surrogate = function() {
10073			this.constructor = ChartElement;
10074		};
10075
10076		Surrogate.prototype = me.prototype;
10077		ChartElement.prototype = new Surrogate();
10078		ChartElement.extend = helpers.inherits;
10079
10080		if (extensions) {
10081			helpers.extend(ChartElement.prototype, extensions);
10082		}
10083
10084		ChartElement.__super__ = me.prototype;
10085		return ChartElement;
10086	}
10087};
10088
10089module.exports = helpers;
10090
10091// DEPRECATIONS
10092
10093/**
10094 * Provided for backward compatibility, use Chart.helpers.callback instead.
10095 * @function Chart.helpers.callCallback
10096 * @deprecated since version 2.6.0
10097 * @todo remove at version 3
10098 * @private
10099 */
10100helpers.callCallback = helpers.callback;
10101
10102/**
10103 * Provided for backward compatibility, use Array.prototype.indexOf instead.
10104 * Array.prototype.indexOf compatibility: Chrome, Opera, Safari, FF1.5+, IE9+
10105 * @function Chart.helpers.indexOf
10106 * @deprecated since version 2.7.0
10107 * @todo remove at version 3
10108 * @private
10109 */
10110helpers.indexOf = function(array, item, fromIndex) {
10111	return Array.prototype.indexOf.call(array, item, fromIndex);
10112};
10113
10114/**
10115 * Provided for backward compatibility, use Chart.helpers.valueOrDefault instead.
10116 * @function Chart.helpers.getValueOrDefault
10117 * @deprecated since version 2.7.0
10118 * @todo remove at version 3
10119 * @private
10120 */
10121helpers.getValueOrDefault = helpers.valueOrDefault;
10122
10123/**
10124 * Provided for backward compatibility, use Chart.helpers.valueAtIndexOrDefault instead.
10125 * @function Chart.helpers.getValueAtIndexOrDefault
10126 * @deprecated since version 2.7.0
10127 * @todo remove at version 3
10128 * @private
10129 */
10130helpers.getValueAtIndexOrDefault = helpers.valueAtIndexOrDefault;
10131
10132},{}],43:[function(require,module,exports){
10133'use strict';
10134
10135var helpers = require(42);
10136
10137/**
10138 * Easing functions adapted from Robert Penner's easing equations.
10139 * @namespace Chart.helpers.easingEffects
10140 * @see http://www.robertpenner.com/easing/
10141 */
10142var effects = {
10143	linear: function(t) {
10144		return t;
10145	},
10146
10147	easeInQuad: function(t) {
10148		return t * t;
10149	},
10150
10151	easeOutQuad: function(t) {
10152		return -t * (t - 2);
10153	},
10154
10155	easeInOutQuad: function(t) {
10156		if ((t /= 0.5) < 1) {
10157			return 0.5 * t * t;
10158		}
10159		return -0.5 * ((--t) * (t - 2) - 1);
10160	},
10161
10162	easeInCubic: function(t) {
10163		return t * t * t;
10164	},
10165
10166	easeOutCubic: function(t) {
10167		return (t = t - 1) * t * t + 1;
10168	},
10169
10170	easeInOutCubic: function(t) {
10171		if ((t /= 0.5) < 1) {
10172			return 0.5 * t * t * t;
10173		}
10174		return 0.5 * ((t -= 2) * t * t + 2);
10175	},
10176
10177	easeInQuart: function(t) {
10178		return t * t * t * t;
10179	},
10180
10181	easeOutQuart: function(t) {
10182		return -((t = t - 1) * t * t * t - 1);
10183	},
10184
10185	easeInOutQuart: function(t) {
10186		if ((t /= 0.5) < 1) {
10187			return 0.5 * t * t * t * t;
10188		}
10189		return -0.5 * ((t -= 2) * t * t * t - 2);
10190	},
10191
10192	easeInQuint: function(t) {
10193		return t * t * t * t * t;
10194	},
10195
10196	easeOutQuint: function(t) {
10197		return (t = t - 1) * t * t * t * t + 1;
10198	},
10199
10200	easeInOutQuint: function(t) {
10201		if ((t /= 0.5) < 1) {
10202			return 0.5 * t * t * t * t * t;
10203		}
10204		return 0.5 * ((t -= 2) * t * t * t * t + 2);
10205	},
10206
10207	easeInSine: function(t) {
10208		return -Math.cos(t * (Math.PI / 2)) + 1;
10209	},
10210
10211	easeOutSine: function(t) {
10212		return Math.sin(t * (Math.PI / 2));
10213	},
10214
10215	easeInOutSine: function(t) {
10216		return -0.5 * (Math.cos(Math.PI * t) - 1);
10217	},
10218
10219	easeInExpo: function(t) {
10220		return (t === 0) ? 0 : Math.pow(2, 10 * (t - 1));
10221	},
10222
10223	easeOutExpo: function(t) {
10224		return (t === 1) ? 1 : -Math.pow(2, -10 * t) + 1;
10225	},
10226
10227	easeInOutExpo: function(t) {
10228		if (t === 0) {
10229			return 0;
10230		}
10231		if (t === 1) {
10232			return 1;
10233		}
10234		if ((t /= 0.5) < 1) {
10235			return 0.5 * Math.pow(2, 10 * (t - 1));
10236		}
10237		return 0.5 * (-Math.pow(2, -10 * --t) + 2);
10238	},
10239
10240	easeInCirc: function(t) {
10241		if (t >= 1) {
10242			return t;
10243		}
10244		return -(Math.sqrt(1 - t * t) - 1);
10245	},
10246
10247	easeOutCirc: function(t) {
10248		return Math.sqrt(1 - (t = t - 1) * t);
10249	},
10250
10251	easeInOutCirc: function(t) {
10252		if ((t /= 0.5) < 1) {
10253			return -0.5 * (Math.sqrt(1 - t * t) - 1);
10254		}
10255		return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
10256	},
10257
10258	easeInElastic: function(t) {
10259		var s = 1.70158;
10260		var p = 0;
10261		var a = 1;
10262		if (t === 0) {
10263			return 0;
10264		}
10265		if (t === 1) {
10266			return 1;
10267		}
10268		if (!p) {
10269			p = 0.3;
10270		}
10271		if (a < 1) {
10272			a = 1;
10273			s = p / 4;
10274		} else {
10275			s = p / (2 * Math.PI) * Math.asin(1 / a);
10276		}
10277		return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
10278	},
10279
10280	easeOutElastic: function(t) {
10281		var s = 1.70158;
10282		var p = 0;
10283		var a = 1;
10284		if (t === 0) {
10285			return 0;
10286		}
10287		if (t === 1) {
10288			return 1;
10289		}
10290		if (!p) {
10291			p = 0.3;
10292		}
10293		if (a < 1) {
10294			a = 1;
10295			s = p / 4;
10296		} else {
10297			s = p / (2 * Math.PI) * Math.asin(1 / a);
10298		}
10299		return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1;
10300	},
10301
10302	easeInOutElastic: function(t) {
10303		var s = 1.70158;
10304		var p = 0;
10305		var a = 1;
10306		if (t === 0) {
10307			return 0;
10308		}
10309		if ((t /= 0.5) === 2) {
10310			return 1;
10311		}
10312		if (!p) {
10313			p = 0.45;
10314		}
10315		if (a < 1) {
10316			a = 1;
10317			s = p / 4;
10318		} else {
10319			s = p / (2 * Math.PI) * Math.asin(1 / a);
10320		}
10321		if (t < 1) {
10322			return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
10323		}
10324		return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * 0.5 + 1;
10325	},
10326	easeInBack: function(t) {
10327		var s = 1.70158;
10328		return t * t * ((s + 1) * t - s);
10329	},
10330
10331	easeOutBack: function(t) {
10332		var s = 1.70158;
10333		return (t = t - 1) * t * ((s + 1) * t + s) + 1;
10334	},
10335
10336	easeInOutBack: function(t) {
10337		var s = 1.70158;
10338		if ((t /= 0.5) < 1) {
10339			return 0.5 * (t * t * (((s *= (1.525)) + 1) * t - s));
10340		}
10341		return 0.5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
10342	},
10343
10344	easeInBounce: function(t) {
10345		return 1 - effects.easeOutBounce(1 - t);
10346	},
10347
10348	easeOutBounce: function(t) {
10349		if (t < (1 / 2.75)) {
10350			return 7.5625 * t * t;
10351		}
10352		if (t < (2 / 2.75)) {
10353			return 7.5625 * (t -= (1.5 / 2.75)) * t + 0.75;
10354		}
10355		if (t < (2.5 / 2.75)) {
10356			return 7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375;
10357		}
10358		return 7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375;
10359	},
10360
10361	easeInOutBounce: function(t) {
10362		if (t < 0.5) {
10363			return effects.easeInBounce(t * 2) * 0.5;
10364		}
10365		return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;
10366	}
10367};
10368
10369module.exports = {
10370	effects: effects
10371};
10372
10373// DEPRECATIONS
10374
10375/**
10376 * Provided for backward compatibility, use Chart.helpers.easing.effects instead.
10377 * @function Chart.helpers.easingEffects
10378 * @deprecated since version 2.7.0
10379 * @todo remove at version 3
10380 * @private
10381 */
10382helpers.easingEffects = effects;
10383
10384},{"42":42}],44:[function(require,module,exports){
10385'use strict';
10386
10387var helpers = require(42);
10388
10389/**
10390 * @alias Chart.helpers.options
10391 * @namespace
10392 */
10393module.exports = {
10394	/**
10395	 * Converts the given line height `value` in pixels for a specific font `size`.
10396	 * @param {Number|String} value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').
10397	 * @param {Number} size - The font size (in pixels) used to resolve relative `value`.
10398	 * @returns {Number} The effective line height in pixels (size * 1.2 if value is invalid).
10399	 * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
10400	 * @since 2.7.0
10401	 */
10402	toLineHeight: function(value, size) {
10403		var matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);
10404		if (!matches || matches[1] === 'normal') {
10405			return size * 1.2;
10406		}
10407
10408		value = +matches[2];
10409
10410		switch (matches[3]) {
10411		case 'px':
10412			return value;
10413		case '%':
10414			value /= 100;
10415			break;
10416		default:
10417			break;
10418		}
10419
10420		return size * value;
10421	},
10422
10423	/**
10424	 * Converts the given value into a padding object with pre-computed width/height.
10425	 * @param {Number|Object} value - If a number, set the value to all TRBL component,
10426	 *  else, if and object, use defined properties and sets undefined ones to 0.
10427	 * @returns {Object} The padding values (top, right, bottom, left, width, height)
10428	 * @since 2.7.0
10429	 */
10430	toPadding: function(value) {
10431		var t, r, b, l;
10432
10433		if (helpers.isObject(value)) {
10434			t = +value.top || 0;
10435			r = +value.right || 0;
10436			b = +value.bottom || 0;
10437			l = +value.left || 0;
10438		} else {
10439			t = r = b = l = +value || 0;
10440		}
10441
10442		return {
10443			top: t,
10444			right: r,
10445			bottom: b,
10446			left: l,
10447			height: t + b,
10448			width: l + r
10449		};
10450	},
10451
10452	/**
10453	 * Evaluates the given `inputs` sequentially and returns the first defined value.
10454	 * @param {Array[]} inputs - An array of values, falling back to the last value.
10455	 * @param {Object} [context] - If defined and the current value is a function, the value
10456	 * is called with `context` as first argument and the result becomes the new input.
10457	 * @param {Number} [index] - If defined and the current value is an array, the value
10458	 * at `index` become the new input.
10459	 * @since 2.7.0
10460	 */
10461	resolve: function(inputs, context, index) {
10462		var i, ilen, value;
10463
10464		for (i = 0, ilen = inputs.length; i < ilen; ++i) {
10465			value = inputs[i];
10466			if (value === undefined) {
10467				continue;
10468			}
10469			if (context !== undefined && typeof value === 'function') {
10470				value = value(context);
10471			}
10472			if (index !== undefined && helpers.isArray(value)) {
10473				value = value[index];
10474			}
10475			if (value !== undefined) {
10476				return value;
10477			}
10478		}
10479	}
10480};
10481
10482},{"42":42}],45:[function(require,module,exports){
10483'use strict';
10484
10485module.exports = require(42);
10486module.exports.easing = require(43);
10487module.exports.canvas = require(41);
10488module.exports.options = require(44);
10489
10490},{"41":41,"42":42,"43":43,"44":44}],46:[function(require,module,exports){
10491/**
10492 * Platform fallback implementation (minimal).
10493 * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939
10494 */
10495
10496module.exports = {
10497	acquireContext: function(item) {
10498		if (item && item.canvas) {
10499			// Support for any object associated to a canvas (including a context2d)
10500			item = item.canvas;
10501		}
10502
10503		return item && item.getContext('2d') || null;
10504	}
10505};
10506
10507},{}],47:[function(require,module,exports){
10508/**
10509 * Chart.Platform implementation for targeting a web browser
10510 */
10511
10512'use strict';
10513
10514var helpers = require(45);
10515
10516var EXPANDO_KEY = '$chartjs';
10517var CSS_PREFIX = 'chartjs-';
10518var CSS_RENDER_MONITOR = CSS_PREFIX + 'render-monitor';
10519var CSS_RENDER_ANIMATION = CSS_PREFIX + 'render-animation';
10520var ANIMATION_START_EVENTS = ['animationstart', 'webkitAnimationStart'];
10521
10522/**
10523 * DOM event types -> Chart.js event types.
10524 * Note: only events with different types are mapped.
10525 * @see https://developer.mozilla.org/en-US/docs/Web/Events
10526 */
10527var EVENT_TYPES = {
10528	touchstart: 'mousedown',
10529	touchmove: 'mousemove',
10530	touchend: 'mouseup',
10531	pointerenter: 'mouseenter',
10532	pointerdown: 'mousedown',
10533	pointermove: 'mousemove',
10534	pointerup: 'mouseup',
10535	pointerleave: 'mouseout',
10536	pointerout: 'mouseout'
10537};
10538
10539/**
10540 * The "used" size is the final value of a dimension property after all calculations have
10541 * been performed. This method uses the computed style of `element` but returns undefined
10542 * if the computed style is not expressed in pixels. That can happen in some cases where
10543 * `element` has a size relative to its parent and this last one is not yet displayed,
10544 * for example because of `display: none` on a parent node.
10545 * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
10546 * @returns {Number} Size in pixels or undefined if unknown.
10547 */
10548function readUsedSize(element, property) {
10549	var value = helpers.getStyle(element, property);
10550	var matches = value && value.match(/^(\d+)(\.\d+)?px$/);
10551	return matches ? Number(matches[1]) : undefined;
10552}
10553
10554/**
10555 * Initializes the canvas style and render size without modifying the canvas display size,
10556 * since responsiveness is handled by the controller.resize() method. The config is used
10557 * to determine the aspect ratio to apply in case no explicit height has been specified.
10558 */
10559function initCanvas(canvas, config) {
10560	var style = canvas.style;
10561
10562	// NOTE(SB) canvas.getAttribute('width') !== canvas.width: in the first case it
10563	// returns null or '' if no explicit value has been set to the canvas attribute.
10564	var renderHeight = canvas.getAttribute('height');
10565	var renderWidth = canvas.getAttribute('width');
10566
10567	// Chart.js modifies some canvas values that we want to restore on de
vendor: 4,559 bytes, lines 10567-10741
10567stroy
10568	canvas[EXPANDO_KEY] = {
10569		initial: {
10570			height: renderHeight,
10571			width: renderWidth,
10572			style: {
10573				display: style.display,
10574				height: style.height,
10575				width: style.width
10576			}
10577		}
10578	};
10579
10580	// Force canvas to display as block to avoid extra space caused by inline
10581	// elements, which would interfere with the responsive resize process.
10582	// https://github.com/chartjs/Chart.js/issues/2538
10583	style.display = style.display || 'block';
10584
10585	if (renderWidth === null || renderWidth === '') {
10586		var displayWidth = readUsedSize(canvas, 'width');
10587		if (displayWidth !== undefined) {
10588			canvas.width = displayWidth;
10589		}
10590	}
10591
10592	if (renderHeight === null || renderHeight === '') {
10593		if (canvas.style.height === '') {
10594			// If no explicit render height and style height, let's apply the aspect ratio,
10595			// which one can be specified by the user but also by charts as default option
10596			// (i.e. options.aspectRatio). If not specified, use canvas aspect ratio of 2.
10597			canvas.height = canvas.width / (config.options.aspectRatio || 2);
10598		} else {
10599			var displayHeight = readUsedSize(canvas, 'height');
10600			if (displayWidth !== undefined) {
10601				canvas.height = displayHeight;
10602			}
10603		}
10604	}
10605
10606	return canvas;
10607}
10608
10609/**
10610 * Detects support for options object argument in addEventListener.
10611 * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
10612 * @private
10613 */
10614var supportsEventListenerOptions = (function() {
10615	var supports = false;
10616	try {
10617		var options = Object.defineProperty({}, 'passive', {
10618			get: function() {
10619				supports = true;
10620			}
10621		});
10622		window.addEventListener('e', null, options);
10623	} catch (e) {
10624		// continue regardless of error
10625	}
10626	return supports;
10627}());
10628
10629// Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
10630// https://github.com/chartjs/Chart.js/issues/4287
10631var eventListenerOptions = supportsEventListenerOptions ? {passive: true} : false;
10632
10633function addEventListener(node, type, listener) {
10634	node.addEventListener(type, listener, eventListenerOptions);
10635}
10636
10637function removeEventListener(node, type, listener) {
10638	node.removeEventListener(type, listener, eventListenerOptions);
10639}
10640
10641function createEvent(type, chart, x, y, nativeEvent) {
10642	return {
10643		type: type,
10644		chart: chart,
10645		native: nativeEvent || null,
10646		x: x !== undefined ? x : null,
10647		y: y !== undefined ? y : null,
10648	};
10649}
10650
10651function fromNativeEvent(event, chart) {
10652	var type = EVENT_TYPES[event.type] || event.type;
10653	var pos = helpers.getRelativePosition(event, chart);
10654	return createEvent(type, chart, pos.x, pos.y, event);
10655}
10656
10657function throttled(fn, thisArg) {
10658	var ticking = false;
10659	var args = [];
10660
10661	return function() {
10662		args = Array.prototype.slice.call(arguments);
10663		thisArg = thisArg || this;
10664
10665		if (!ticking) {
10666			ticking = true;
10667			helpers.requestAnimFrame.call(window, function() {
10668				ticking = false;
10669				fn.apply(thisArg, args);
10670			});
10671		}
10672	};
10673}
10674
10675// Implementation based on https://github.com/marcj/css-element-queries
10676function createResizer(handler) {
10677	var resizer = document.createElement('div');
10678	var cls = CSS_PREFIX + 'size-monitor';
10679	var maxSize = 1000000;
10680	var style =
10681		'position:absolute;' +
10682		'left:0;' +
10683		'top:0;' +
10684		'right:0;' +
10685		'bottom:0;' +
10686		'overflow:hidden;' +
10687		'pointer-events:none;' +
10688		'visibility:hidden;' +
10689		'z-index:-1;';
10690
10691	resizer.style.cssText = style;
10692	resizer.className = cls;
10693	resizer.innerHTML =
10694		'<div class="' + cls + '-expand" style="' + style + '">' +
10695			'<div style="' +
10696				'position:absolute;' +
10697				'width:' + maxSize + 'px;' +
10698				'height:' + maxSize + 'px;' +
10699				'left:0;' +
10700				'top:0">' +
10701			'</div>' +
10702		'</div>' +
10703		'<div class="' + cls + '-shrink" style="' + style + '">' +
10704			'<div style="' +
10705				'position:absolute;' +
10706				'width:200%;' +
10707				'height:200%;' +
10708				'left:0; ' +
10709				'top:0">' +
10710			'</div>' +
10711		'</div>';
10712
10713	var expand = resizer.childNodes[0];
10714	var shrink = resizer.childNodes[1];
10715
10716	resizer._reset = function() {
10717		expand.scrollLeft = maxSize;
10718		expand.scrollTop = maxSize;
10719		shrink.scrollLeft = maxSize;
10720		shrink.scrollTop = maxSize;
10721	};
10722	var onScroll = function() {
10723		resizer._reset();
10724		handler();
10725	};
10726
10727	addEventListener(expand, 'scroll', onScroll.bind(expand, 'expand'));
10728	addEventListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink'));
10729
10730	return resizer;
10731}
10732
10733// https://davidwalsh.name/detect-node-insertion
10734function watchForRender(node, handler) {
10735	var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
10736	var proxy = expando.renderProxy = function(e) {
10737		if (e.animationName === CSS_RENDER_ANIMATION) {
10738			handler();
10739		}
10740	};
10741
10742	helpers.each(ANIMATION_START_EVENTS, function(type) {
10743		addEventListener(node, type, proxy);
10744	});
10745
10746	// #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR class
10747	// is removed then added back immediately (same animation frame?). Accessing the
10748	// `offsetParent` property will force a reflow and re-evaluate the CSS animation.
10749	// https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics
10750	// https://github.com/chartjs/Chart.js/issues/4737
10751	expando.reflow = !!node.offsetParent;
10752
10753	node.classList.add(CSS_RENDER_MONITOR);
10754}
10755
10756function unwatchForRender(node) {
10757	var expando = node[EXPANDO_KEY] || {};
10758	var proxy = expando.renderProxy;
10759
10760	if (proxy) {
10761		helpers.each(ANIMATION_START_EVENTS, function(type) {
10762			removeEventListener(node, type, proxy);
10763		});
10764
10765		delete expando.renderProxy;
10766	}
10767
10768	node.classList.remove(CSS_RENDER_MONITOR);
10769}
10770
10771function addResizeListener(node, listener, chart) {
10772	var expando = node[EXPANDO_KEY] || (node[EXPANDO_KEY] = {});
10773
10774	// Let's keep track of this added resizer and thus avoid DOM query when removing it.
10775	var resizer = expando.resizer = createResizer(throttled(function() {
10776		if (expando.resizer) {
10777			return listener(createEvent('resize', chart));
10778		}
10779	}));
10780
10781	// The resizer needs to be attached to the node parent, so we first need to be
10782	// sure that `node` is attached to the DOM before injecting the resizer element.
10783	watchForRender(node, function() {
10784		if (expando.resizer) {
10785			var container = node.parentNode;
10786			if (container && container !== resizer.parentNode) {
10787				container.insertBefore(resizer, container.firstChild);
10788			}
10789
10790			// The container size might have changed, let's reset the resizer state.
10791			resizer._reset();
10792		}
10793	});
10794}
10795
10796function removeResizeListener(node) {
10797	var expando = node[EXPANDO_KEY] || {};
10798	var resizer = expando.resizer;
10799
10800	delete expando.resizer;
10801	unwatchForRender(node);
10802
10803	if (resizer && resizer.parentNode) {
10804		resizer.parentNode.removeChild(resizer);
10805	}
10806}
10807
10808function injectCSS(platform, css) {
10809	// http://stackoverflow.com/q/3922139
10810	var style = platform._style || document.createElement('style');
10811	if (!platform._style) {
10812		platform._style = style;
10813		css = '/* Chart.js */\n' + css;
10814		style.setAttribute('type', 'text/css');
10815		document.getElementsByTagName('head')[0].appendChild(style);
10816	}
10817
10818	style.appendChild(document.createTextNode(css));
10819}
10820
10821module.exports = {
10822	/**
10823	 * This property holds whether this platform is enabled for the current environment.
10824	 * Currently used by platform.js to select the proper implementation.
10825	 * @private
10826	 */
10827	_enabled: typeof window !== 'undefined' && typeof document !== 'undefined',
10828
10829	initialize: function() {
10830		var keyframes = 'from{opacity:0.99}to{opacity:1}';
10831
10832		injectCSS(this,
10833			// DOM rendering detection
10834			// https://davidwalsh.name/detect-node-insertion
10835			'@-webkit-keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
10836			'@keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
10837			'.' + CSS_RENDER_MONITOR + '{' +
10838				'-webkit-animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
10839				'animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
10840			'}'
10841		);
10842	},
10843
10844	acquireContext: function(item, config) {
10845		if (typeof item === 'string') {
10846			item = document.getElementById(item);
10847		} else if (item.length) {
10848			// Support for array based queries (such as jQuery)
10849			item = item[0];
10850		}
10851
10852		if (item && item.canvas) {
10853			// Support for any object associated to a canvas (including a context2d)
10854			item = item.canvas;
10855		}
10856
10857		// To prevent canvas fingerprinting, some add-ons undefine the getContext
10858		// method, for example: https://github.com/kkapsner/CanvasBlocker
10859		// https://github.com/chartjs/Chart.js/issues/2807
10860		var context = item && item.getContext && item.getContext('2d');
10861
10862		// `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when the item is
10863		// inside an iframe or when running in a protected environment. We could guess the
10864		// types from their toString() value but let's keep things flexible and assume it's
10865		// a sufficient condition if the item has a context2D which has item as `canvas`.
10866		// https://github.com/chartjs/Chart.js/issues/3887
10867		// https://github.com/chartjs/Chart.js/issues/4102
10868		// https://github.com/chartjs/Chart.js/issues/4152
10869		if (context && context.canvas === item) {
10870			initCanvas(item, config);
10871			return context;
10872		}
10873
10874		return null;
10875	},
10876
10877	releaseContext: function(context) {
10878		var canvas = context.canvas;
10879		if (!canvas[EXPANDO_KEY]) {
10880			return;
10881		}
10882
10883		var initial = canvas[EXPANDO_KEY].initial;
10884		['height', 'width'].forEach(function(prop) {
10885			var value = initial[prop];
10886			if (helpers.isNullOrUndef(value)) {
10887				canvas.removeAttribute(prop);
10888			} else {
10889				canvas.setAttribute(prop, value);
10890			}
10891		});
10892
10893		helpers.each(initial.style || {}, function(value, key) {
10894			canvas.style[key] = value;
10895		});
10896
10897		// The canvas render size might have been changed (and thus the state stack discarded),
10898		// we can't use save() and restore() to restore the initial state. So make sure that at
10899		// least the canvas context is reset to the default state by setting the canvas width.
10900		// https://www.w3.org/TR/2011/WD-html5-20110525/the-canvas-element.html
10901		canvas.width = canvas.width;
10902
10903		delete canvas[EXPANDO_KEY];
10904	},
10905
10906	addEventListener: function(chart, type, listener) {
10907		var canvas = chart.canvas;
10908		if (type === 'resize') {
10909			// Note: the resize event is not supported on all browsers.
10910			addResizeListener(canvas, listener, chart);
10911			return;
10912		}
10913
10914		var expando = listener[EXPANDO_KEY] || (listener[EXPANDO_KEY] = {});
10915		var proxies = expando.proxies || (expando.proxies = {});
10916		var proxy = proxies[chart.id + '_' + type] = function(event) {
10917			listener(fromNativeEvent(event, chart));
10918		};
10919
10920		addEventListener(canvas, type, proxy);
10921	},
10922
10923	removeEventListener: function(chart, type, listener) {
10924		var canvas = chart.canvas;
10925		if (type === 'resize') {
10926			// Note: the resize event is not supported on all browsers.
10927			removeResizeListener(canvas, listener);
10928			return;
10929		}
10930
10931		var expando = listener[EXPANDO_KEY] || {};
10932		var proxies = expando.proxies || {};
10933		var proxy = proxies[chart.id + '_' + type];
10934		if (!proxy) {
10935			return;
10936		}
10937
10938		removeEventListener(canvas, type, proxy);
10939	}
10940};
10941
10942// DEPRECATIONS
10943
10944/**
10945 * Provided for backward compatibility, use EventTarget.addEventListener instead.
10946 * EventTarget.addEventListener compatibility: Chrome, Opera 7, Safari, FF1.5+, IE9+
10947 * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
10948 * @function Chart.helpers.addEvent
10949 * @deprecated since version 2.7.0
10950 * @todo remove at version 3
10951 * @private
10952 */
10953helpers.addEvent = addEventListener;
10954
10955/**
10956 * Provided for backward compatibility, use EventTarget.removeEventListener instead.
10957 * EventTarget.removeEventListener compatibility: Chrome, Opera 7, Safari, FF1.5+, IE9+
10958 * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener
10959 * @function Chart.helpers.removeEvent
10960 * @deprecated since version 2.7.0
10961 * @todo remove at version 3
10962 * @private
10963 */
10964helpers.removeEvent = removeEventListener;
10965
10966},{"45":45}],48:[function(require,module,exports){
10967'use strict';
10968
10969var helpers = require(45);
10970var basic = require(46);
10971var dom = require(47);
10972
10973// @TODO Make possible to select another platform at build time.
10974var implementation = dom._enabled ? dom : basic;
10975
10976/**
10977 * @namespace Chart.platform
10978 * @see https://chartjs.gitbooks.io/proposals/content/Platform.html
10979 * @since 2.4.0
10980 */
10981module.exports = helpers.extend({
10982	/**
10983	 * @since 2.7.0
10984	 */
10985	initialize: function() {},
10986
10987	/**
10988	 * Called at chart construction time, returns a context2d instance implementing
10989	 * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
10990	 * @param {*} item - The native item from which to acquire context (platform specific)
10991	 * @param {Object} options - The chart options
10992	 * @returns {CanvasRenderingContext2D} context2d instance
10993	 */
10994	acquireContext: function() {},
10995
10996	/**
10997	 * Called at chart destruction time, releases any resources associated to the context
10998	 * previously returned by the acquireContext() method.
10999	 * @param {CanvasRenderingContext2D} context - The context2d instance
11000	 * @returns {Boolean} true if the method succeeded, else false
11001	 */
11002	releaseContext: function() {},
11003
11004	/**
11005	 * Registers the specified listener on the given chart.
11006	 * @param {Chart} chart - Chart from which to listen for event
11007	 * @param {String} type - The ({@link IEvent}) type to listen for
11008	 * @param {Function} listener - Receives a notification (an object that implements
11009	 * the {@link IEvent} interface) when an event of the specified type occurs.
11010	 */
11011	addEventListener: function() {},
11012
11013	/**
11014	 * Removes the specified listener previously registered with addEventListener.
11015	 * @param {Chart} chart -Chart from which to remove the listener
11016	 * @param {String} type - The ({@link IEvent}) type to remove
11017	 * @param {Function} listener - The listener function to remove from the event target.
11018	 */
11019	removeEventListener: function() {}
11020
11021}, implementation);
11022
11023/**
11024 * @interface IPlatform
11025 * Allows abstracting platform dependencies away from the chart
11026 * @borrows Chart.platform.acquireContext as acquireContext
11027 * @borrows Chart.platform.releaseContext as releaseContext
11028 * @borrows Chart.platform.addEventListener as addEventListener
11029 * @borrows Chart.platform.removeEventListener as removeEventListener
11030 */
11031
11032/**
11033 * @interface IEvent
11034 * @prop {String} type - The event type name, possible values are:
11035 * 'contextmenu', 'mouseenter', 'mousedown', 'mousemove', 'mouseup', 'mouseout',
11036 * 'click', 'dblclick', 'keydown', 'keypress', 'keyup' and 'resize'
11037 * @prop {*} native - The original native event (null for emulated events, e.g. 'resize')
11038 * @prop {Number} x - The mouse x position, relative to the canvas (null for incompatible events)
11039 * @prop {Number} y - The mouse y position, relative to the canvas (null for incompatible events)
11040 */
11041
11042},{"45":45,"46":46,"47":47}],49:[function(require,module,exports){
11043'use strict';
11044
11045module.exports = {};
11046module.exports.filler = require(50);
11047module.exports.legend = require(51);
11048module.exports.title = require(52);
11049
11050},{"50":50,"51":51,"52":52}],50:[function(require,module,exports){
11051/**
11052 * Plugin based on discussion from the following Chart.js issues:
11053 * @see https://github.com/chartjs/Chart.js/issues/2380#issuecomment-279961569
11054 * @see https://github.com/chartjs/Chart.js/issues/2440#issuecomment-256461897
11055 */
11056
11057'use strict';
11058
11059var defaults = require(25);
11060var elements = require(40);
11061var helpers = require(45);
11062
11063defaults._set('global', {
11064	plugins: {
11065		filler: {
11066			propagate: true
11067		}
11068	}
11069});
11070
11071var mappers = {
11072	dataset: function(source) {
11073		var index = source.fill;
11074		var chart = source.chart;
11075		var meta = chart.getDatasetMeta(index);
11076		var visible = meta && chart.isDatasetVisible(index);
11077		var points = (visible && meta.dataset._children) || [];
11078		var length = points.length || 0;
11079
11080		return !length ? null : function(point, i) {
11081			return (i < length && points[i]._view) || null;
11082		};
11083	},
11084
11085	boundary: function(source) {
11086		var boundary = source.boundary;
11087		var x = boundary ? boundary.x : null;
11088		var y = boundary ? boundary.y : null;
11089
11090		return function(point) {
11091			return {
11092				x: x === null ? point.x : x,
11093				y: y === null ? point.y : y,
11094			};
11095		};
11096	}
11097};
11098
11099// @todo if (fill[0] === '#')
11100function decodeFill(el, index, count) {
11101	var model = el._model || {};
11102	var fill = model.fill;
11103	var target;
11104
11105	if (fill === undefined) {
11106		fill = !!model.backgroundColor;
11107	}
11108
11109	if (fill === false || fill === null) {
11110		return false;
11111	}
11112
11113	if (fill === true) {
11114		return 'origin';
11115	}
11116
11117	target = parseFloat(fill, 10);
11118	if (isFinite(target) && Math.floor(target) === target) {
11119		if (fill[0] === '-' || fill[0] === '+') {
11120			target = index + target;
11121		}
11122
11123		if (target === index || target < 0 || target >= count) {
11124			return false;
11125		}
11126
11127		return target;
11128	}
11129
11130	switch (fill) {
11131	// compatibility
11132	case 'bottom':
11133		return 'start';
11134	case 'top':
11135		return 'end';
11136	case 'zero':
11137		return 'origin';
11138	// supported boundaries
11139	case 'origin':
11140	case 'start':
11141	case 'end':
11142		return fill;
11143	// invalid fill values
11144	default:
11145		return false;
11146	}
11147}
11148
11149function computeBoundary(source) {
11150	var model = source.el._model || {};
11151	var scale = source.el._scale || {};
11152	var fill = source.fill;
11153	var target = null;
11154	var horizontal;
11155
11156	if (isFinite(fill)) {
11157		return null;
11158	}
11159
11160	// Backward compatibility: until v3, we still need to support boundary values set on
11161	// the model (scaleTop, scaleBottom and scaleZero) because some external plugins and
11162	// controllers might still use it (e.g. the Smith chart).
11163
11164	if (fill === 'start') {
11165		target = model.scaleBottom === undefined ? scale.bottom : model.scaleBottom;
11166	} else if (fill === 'end') {
11167		target = model.scaleTop === undefined ? scale.top : model.scaleTop;
11168	} else if (model.scaleZero !== undefined) {
11169		target = model.scaleZero;
11170	} else if (scale.getBasePosition) {
11171		target = scale.getBasePosition();
11172	} else if (scale.getBasePixel) {
11173		target = scale.getBasePixel();
11174	}
11175
11176	if (target !== undefined && target !== null) {
11177		if (target.x !== undefined && target.y !== undefined) {
11178			return target;
11179		}
11180
11181		if (typeof target === 'number' && isFinite(target)) {
11182			horizontal = scale.isHorizontal();
11183			return {
11184				x: horizontal ? target : null,
11185				y: horizontal ? null : target
11186			};
11187		}
11188	}
11189
11190	return null;
11191}
11192
11193function resolveTarget(sources, index, propagate) {
11194	var source = sources[index];
11195	var fill = source.fill;
11196	var visited = [index];
11197	var target;
11198
11199	if (!propagate) {
11200		return fill;
11201	}
11202
11203	while (fill !== false && visited.indexOf(fill) === -1) {
11204		if (!isFinite(fill)) {
11205			return fill;
11206		}
11207
11208		target = sources[fill];
11209		if (!target) {
11210			return false;
vendor: 4,184 bytes, lines 11211-11416
11211		}
11212
11213		if (target.visible) {
11214			return fill;
11215		}
11216
11217		visited.push(fill);
11218		fill = target.fill;
11219	}
11220
11221	return false;
11222}
11223
11224function createMapper(source) {
11225	var fill = source.fill;
11226	var type = 'dataset';
11227
11228	if (fill === false) {
11229		return null;
11230	}
11231
11232	if (!isFinite(fill)) {
11233		type = 'boundary';
11234	}
11235
11236	return mappers[type](source);
11237}
11238
11239function isDrawable(point) {
11240	return point && !point.skip;
11241}
11242
11243function drawArea(ctx, curve0, curve1, len0, len1) {
11244	var i;
11245
11246	if (!len0 || !len1) {
11247		return;
11248	}
11249
11250	// building first area curve (normal)
11251	ctx.moveTo(curve0[0].x, curve0[0].y);
11252	for (i = 1; i < len0; ++i) {
11253		helpers.canvas.lineTo(ctx, curve0[i - 1], curve0[i]);
11254	}
11255
11256	// joining the two area curves
11257	ctx.lineTo(curve1[len1 - 1].x, curve1[len1 - 1].y);
11258
11259	// building opposite area curve (reverse)
11260	for (i = len1 - 1; i > 0; --i) {
11261		helpers.canvas.lineTo(ctx, curve1[i], curve1[i - 1], true);
11262	}
11263}
11264
11265function doFill(ctx, points, mapper, view, color, loop) {
11266	var count = points.length;
11267	var span = view.spanGaps;
11268	var curve0 = [];
11269	var curve1 = [];
11270	var len0 = 0;
11271	var len1 = 0;
11272	var i, ilen, index, p0, p1, d0, d1;
11273
11274	ctx.beginPath();
11275
11276	for (i = 0, ilen = (count + !!loop); i < ilen; ++i) {
11277		index = i % count;
11278		p0 = points[index]._view;
11279		p1 = mapper(p0, index, view);
11280		d0 = isDrawable(p0);
11281		d1 = isDrawable(p1);
11282
11283		if (d0 && d1) {
11284			len0 = curve0.push(p0);
11285			len1 = curve1.push(p1);
11286		} else if (len0 && len1) {
11287			if (!span) {
11288				drawArea(ctx, curve0, curve1, len0, len1);
11289				len0 = len1 = 0;
11290				curve0 = [];
11291				curve1 = [];
11292			} else {
11293				if (d0) {
11294					curve0.push(p0);
11295				}
11296				if (d1) {
11297					curve1.push(p1);
11298				}
11299			}
11300		}
11301	}
11302
11303	drawArea(ctx, curve0, curve1, len0, len1);
11304
11305	ctx.closePath();
11306	ctx.fillStyle = color;
11307	ctx.fill();
11308}
11309
11310module.exports = {
11311	id: 'filler',
11312
11313	afterDatasetsUpdate: function(chart, options) {
11314		var count = (chart.data.datasets || []).length;
11315		var propagate = options.propagate;
11316		var sources = [];
11317		var meta, i, el, source;
11318
11319		for (i = 0; i < count; ++i) {
11320			meta = chart.getDatasetMeta(i);
11321			el = meta.dataset;
11322			source = null;
11323
11324			if (el && el._model && el instanceof elements.Line) {
11325				source = {
11326					visible: chart.isDatasetVisible(i),
11327					fill: decodeFill(el, i, count),
11328					chart: chart,
11329					el: el
11330				};
11331			}
11332
11333			meta.$filler = source;
11334			sources.push(source);
11335		}
11336
11337		for (i = 0; i < count; ++i) {
11338			source = sources[i];
11339			if (!source) {
11340				continue;
11341			}
11342
11343			source.fill = resolveTarget(sources, i, propagate);
11344			source.boundary = computeBoundary(source);
11345			source.mapper = createMapper(source);
11346		}
11347	},
11348
11349	beforeDatasetDraw: function(chart, args) {
11350		var meta = args.meta.$filler;
11351		if (!meta) {
11352			return;
11353		}
11354
11355		var ctx = chart.ctx;
11356		var el = meta.el;
11357		var view = el._view;
11358		var points = el._children || [];
11359		var mapper = meta.mapper;
11360		var color = view.backgroundColor || defaults.global.defaultColor;
11361
11362		if (mapper && color && points.length) {
11363			helpers.canvas.clipArea(ctx, chart.chartArea);
11364			doFill(ctx, points, mapper, view, color, el._loop);
11365			helpers.canvas.unclipArea(ctx);
11366		}
11367	}
11368};
11369
11370},{"25":25,"40":40,"45":45}],51:[function(require,module,exports){
11371'use strict';
11372
11373var defaults = require(25);
11374var Element = require(26);
11375var helpers = require(45);
11376var layouts = require(30);
11377
11378var noop = helpers.noop;
11379
11380defaults._set('global', {
11381	legend: {
11382		display: true,
11383		position: 'top',
11384		fullWidth: true,
11385		reverse: false,
11386		weight: 1000,
11387
11388		// a callback that will handle
11389		onClick: function(e, legendItem) {
11390			var index = legendItem.datasetIndex;
11391			var ci = this.chart;
11392			var meta = ci.getDatasetMeta(index);
11393
11394			// See controller.isDatasetVisible comment
11395			meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
11396
11397			// We hid a dataset ... rerender the chart
11398			ci.update();
11399		},
11400
11401		onHover: null,
11402
11403		labels: {
11404			boxWidth: 40,
11405			padding: 10,
11406			// Generates labels shown in the legend
11407			// Valid properties to return:
11408			// text : text to display
11409			// fillStyle : fill of coloured box
11410			// strokeStyle: stroke of coloured box
11411			// hidden : if this legend item refers to a hidden item
11412			// lineCap : cap style for line
11413			// lineDash
11414			// lineDashOffset :
11415			// lineJoin :
11416			// lineWidth :
11417			generateLabels: function(chart) {
11418				var data = chart.data;
11419				return helpers.isArray(data.datasets) ? data.datasets.map(function(dataset, i) {
11420					return {
11421						text: dataset.label,
11422						fillStyle: (!helpers.isArray(dataset.backgroundColor) ? dataset.backgroundColor : dataset.backgroundColor[0]),
11423						hidden: !chart.isDatasetVisible(i),
11424						lineCap: dataset.borderCapStyle,
11425						lineDash: dataset.borderDash,
11426						lineDashOffset: dataset.borderDashOffset,
11427						lineJoin: dataset.borderJoinStyle,
11428						lineWidth: dataset.borderWidth,
11429						strokeStyle: dataset.borderColor,
11430						pointStyle: dataset.pointStyle,
11431
11432						// Below is extra data used for toggling the datasets
11433						datasetIndex: i
11434					};
11435				}, this) : [];
11436			}
11437		}
11438	},
11439
11440	legendCallback: function(chart) {
11441		var text = [];
11442		text.push('<ul class="' + chart.id + '-legend">');
11443		for (var i = 0; i < chart.data.datasets.length; i++) {
11444			text.push('<li><span style="background-color:' + chart.data.datasets[i].backgroundColor + '"></span>');
11445			if (chart.data.datasets[i].label) {
11446				text.push(chart.data.datasets[i].label);
11447			}
11448			text.push('</li>');
11449		}
11450		text.push('</ul>');
11451		return text.join('');
11452	}
11453});
11454
11455/**
11456 * Helper function to get the box width based on the usePointStyle option
11457 * @param labelopts {Object} the label options on the legend
11458 * @param fontSize {Number} the label font size
11459 * @return {Number} width of the color box area
11460 */
11461function getBoxWidth(labelOpts, fontSize) {
11462	return labelOpts.usePointStyle ?
11463		fontSize * Math.SQRT2 :
11464		labelOpts.boxWidth;
11465}
11466
11467/**
11468 * IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required!
11469 */
11470var Legend = Element.extend({
11471
11472	initialize: function(config) {
11473		helpers.extend(this, config);
11474
11475		// Contains hit boxes for each dataset (in dataset order)
11476		this.legendHitBoxes = [];
11477
11478		// Are we in doughnut mode which has a different data type
11479		this.doughnutMode = false;
11480	},
11481
11482	// These methods are ordered by lifecycle. Utilities then follow.
11483	// Any function defined here is inherited by all legend types.
11484	// Any function can be extended by the legend type
11485
11486	beforeUpdate: noop,
11487	update: function(maxWidth, maxHeight, margins) {
11488		var me = this;
11489
11490		// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
11491		me.beforeUpdate();
11492
11493		// Absorb the master measurements
11494		me.maxWidth = maxWidth;
11495		me.maxHeight = maxHeight;
11496		me.margins = margins;
11497
11498		// Dimensions
11499		me.beforeSetDimensions();
11500		me.setDimensions();
11501		me.afterSetDimensions();
11502		// Labels
11503		me.beforeBuildLabels();
11504		me.buildLabels();
11505		me.afterBuildLabels();
11506
11507		// Fit
11508		me.beforeFit();
11509		me.fit();
11510		me.afterFit();
11511		//
11512		me.afterUpdate();
11513
11514		return me.minSize;
11515	},
11516	afterUpdate: noop,
11517
11518	//
11519
11520	beforeSetDimensions: noop,
11521	setDimensions: function() {
11522		var me = this;
11523		// Set the unconstrained dimension before label rotation
11524		if (me.isHorizontal()) {
11525			// Reset position before calculating rotation
11526			me.width = me.maxWidth;
11527			me.left = 0;
11528			me.right = me.width;
11529		} else {
11530			me.height = me.maxHeight;
11531
11532			// Reset position before calculating rotation
11533			me.top = 0;
11534			me.bottom = me.height;
11535		}
11536
11537		// Reset padding
11538		me.paddingLeft = 0;
11539		me.paddingTop = 0;
11540		me.paddingRight = 0;
11541		me.paddingBottom = 0;
11542
11543		// Reset minSize
11544		me.minSize = {
11545			width: 0,
11546			height: 0
11547		};
11548	},
11549	afterSetDimensions: noop,
11550
11551	//
11552
11553	beforeBuildLabels: noop,
11554	buildLabels: function() {
11555		var me = this;
11556		var labelOpts = me.options.labels || {};
11557		var legendItems = helpers.callback(labelOpts.generateLabels, [me.chart], me) || [];
11558
11559		if (labelOpts.filter) {
11560			legendItems = legendItems.filter(function(item) {
11561				return labelOpts.filter(item, me.chart.data);
11562			});
11563		}
11564
11565		if (me.options.reverse) {
11566			legendItems.reverse();
11567		}
11568
11569		me.legendItems = legendItems;
11570	},
11571	afterBuildLabels: noop,
11572
11573	//
11574
11575	beforeFit: noop,
11576	fit: function() {
11577		var me = this;
11578		var opts = me.options;
11579		var labelOpts = opts.labels;
11580		var display = opts.display;
11581
11582		var ctx = me.ctx;
11583
11584		var globalDefault = defaults.global;
11585		var valueOrDefault = helpers.valueOrDefault;
11586		var fontSize = valueOrDefault(labelOpts.fontSize, globalDefault.defaultFontSize);
11587		var fontStyle = valueOrDefault(labelOpts.fontStyle, globalDefault.defaultFontStyle);
11588		var fontFamily = valueOrDefault(labelOpts.fontFamily, globalDefault.defaultFontFamily);
11589		var labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
11590
11591		// Reset hit boxes
11592		var hitboxes = me.legendHitBoxes = [];
11593
11594		var minSize = me.minSize;
11595		var isHorizontal = me.isHorizontal();
11596
11597		if (isHorizontal) {
11598			minSize.width = me.maxWidth; // fill all the width
11599			minSize.height = display ? 10 : 0;
11600		} else {
11601			minSize.width = display ? 10 : 0;
11602			minSize.height = me.maxHeight; // fill all the height
11603		}
11604
11605		// Increase sizes here
11606		if (display) {
11607			ctx.font = labelFont;
11608
11609			if (isHorizontal) {
11610				// Labels
11611
11612				// Width of each line of legend boxes. Labels wrap onto multiple lines when there are too many to fit on one
11613				var lineWidths = me.lineWidths = [0];
11614				var totalHeight = me.legendItems.length ? fontSize + (labelOpts.padding) : 0;
11615
11616				ctx.textAlign = 'left';
11617				ctx.textBaseline = 'top';
11618
11619				helpers.each(me.legendItems, function(legendItem, i) {
11620					var boxWidth = getBoxWidth(labelOpts, fontSize);
11621					var width = boxWidth + (fontSize / 2) + ctx.measureText(legendItem.text).width;
11622
11623					if (lineWidths[lineWidths.length - 1] + width + labelOpts.padding >= me.width) {
11624						totalHeight += fontSize + (labelOpts.padding);
11625						lineWidths[lineWidths.length] = me.left;
11626					}
11627
11628					// Store the hitbox width and height here. Final position will be updated in `draw`
11629					hitboxes[i] = {
11630						left: 0,
11631						top: 0,
11632						width: width,
11633						height: fontSize
11634					};
11635
11636					lineWidths[lineWidths.length - 1] += width + labelOpts.padding;
11637				});
11638
11639				minSize.height += totalHeight;
11640
11641			} else {
11642				var vPadding = labelOpts.padding;
11643				var columnWidths = me.columnWidths = [];
11644				var totalWidth = labelOpts.padding;
11645				var currentColWidth = 0;
11646				var currentColHeight = 0;
11647				var itemHeight = fontSize + vPadding;
11648
11649				helpers.each(me.legendItems, function(legendItem, i) {
11650					var boxWidth = getBoxWidth(labelOpts, fontSize);
11651					var itemWidth = boxWidth + (fontSize / 2) + ctx.measureText(legendItem.text).width;
11652
11653					// If too tall, go to new column
11654					if (currentColHeight + itemHeight > minSize.height) {
11655						totalWidth += currentColWidth + labelOpts.padding;
11656						columnWidths.push(currentColWidth); // previous column width
11657
11658						currentColWidth = 0;
11659						currentColHeight = 0;
11660					}
11661
11662					// Get max width
11663					currentColWidth = Math.max(currentColWidth, itemWidth);
11664					currentColHeight += itemHeight;
11665
11666					// Store the hitbox width and height here. Final position will be updated in `draw`
11667					hitboxes[i] = {
11668						left: 0,
11669						top: 0,
11670						width: itemWidth,
11671						height: fontSize
11672					};
11673				});
11674
11675				totalWidth += currentColWidth;
11676				columnWidths.push(currentColWidth);
11677				minSize.width += totalWidth;
11678			}
11679		}
11680
11681		me.width = minSize.width;
11682		me.height = minSize.height;
11683	},
11684	afterFit: noop,
11685
11686	// Shared Methods
11687	isHorizontal: function() {
11688		return this.options.position === 'top' || this.options.position === 'bottom';
11689	},
11690
11691	// Actually draw the legend on the canvas
11692	draw: function() {
11693		var me = this;
11694		var opts = me.options;
11695		var labelOpts = opts.labels;
11696		var globalDefault = defaults.global;
11697		var lineDefault = globalDefault.elements.line;
11698		var legendWidth = me.width;
11699		var lineWidths = me.lineWidths;
11700
11701		if (opts.display) {
11702			var ctx = me.ctx;
11703			var valueOrDefault = helpers.valueOrDefault;
11704			var fontColor = valueOrDefault(labelOpts.fontColor, globalDefault.defaultFontColor);
11705			var fontSize = valueOrDefault(labelOpts.fontSize, globalDefault.defaultFontSize);
11706			var fontStyle = valueOrDefault(labelOpts.fontStyle, globalDefault.defaultFontStyle);
11707			var fontFamily = valueOrDefault(labelOpts.fontFamily, globalDefault.defaultFontFamily);
11708			var labelFont = helpers.fontString(fontSize, fontStyle, fontFamily);
11709			var cursor;
11710
11711			// Canvas setup
11712			ctx.textAlign = 'left';
11713			ctx.textBaseline = 'middle';
11714			ctx.lineWidth = 0.5;
11715			ctx.strokeStyle = fontColor; // for strikethrough effect
11716			ctx.fillStyle = fontColor; // render in correct colour
11717			ctx.font = labelFont;
11718
11719			var boxWidth = getBoxWidth(labelOpts, fontSize);
11720			var hitboxes = me.legendHitBoxes;
11721
11722			// current position
11723			var drawLegendBox = function(x, y, legendItem) {
11724				if (isNaN(boxWidth) || boxWidth <= 0) {
11725					return;
11726				}
11727
11728				// Set the ctx for the box
11729				ctx.save();
11730
11731				ctx.fillStyle = valueOrDefault(legendItem.fillStyle, globalDefault.defaultColor);
11732				ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle);
11733				ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset);
11734				ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle);
11735				ctx.lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth);
11736				ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, globalDefault.defaultColor);
11737				var isLineWidthZero = (valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth) === 0);
11738
11739				if (ctx.setLineDash) {
11740					// IE 9 and 10 do not support line dash
11741					ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash));
11742				}
11743
11744				if (opts.labels && opts.labels.usePointStyle) {
11745					// Recalculate x and y for drawPoint() because its expecting
11746					// x and y to be center of figure (instead of top left)
11747					var radius = fontSize * Math.SQRT2 / 2;
11748					var offSet = radius / Math.SQRT2;
11749					var centerX = x + offSet;
11750					var centerY = y + offSet;
11751
11752					// Draw pointStyle as legend symbol
11753					helpers.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY);
11754				} else {
11755					// Draw box as legend symbol
11756					if (!isLineWidthZero) {
11757						ctx.strokeRect(x, y, boxWidth, fontSize);
11758					}
11759					ctx.fillRect(x, y, boxWidth, fontSize);
11760				}
11761
11762				ctx.restore();
11763			};
11764			var fillText = function(x, y, legendItem, textWidth) {
11765				var halfFontSize = fontSize / 2;
11766				var xLeft = boxWidth + halfFontSize + x;
11767				var yMiddle = y + halfFontSize;
11768
11769				ctx.fillText(legendItem.text, xLeft, yMiddle);
11770
11771				if (legendItem.hidden) {
11772					// Strikethrough the text if hidden
11773					ctx.beginPath();
11774					ctx.lineWidth = 2;
11775					ctx.moveTo(xLeft, yMiddle);
11776					ctx.lineTo(xLeft + textWidth, yMiddle);
11777					ctx.stroke();
11778				}
11779			};
11780
11781			// Horizontal
11782			var isHorizontal = me.isHorizontal();
11783			if (isHorizontal) {
11784				cursor = {
11785					x: me.left + ((legendWidth - lineWidths[0]) / 2),
11786					y: me.top + labelOpts.padding,
11787					line: 0
11788				};
11789			} else {
11790				cursor = {
11791					x: me.left + labelOpts.padding,
11792					y: me.top + labelOpts.padding,
11793					line: 0
11794				};
11795			}
11796
11797			var itemHeight = fontSize + labelOpts.padding;
11798			helpers.each(me.legendItems, function(legendItem, i) {
11799				var textWidth = ctx.measureText(legendItem.text).width;
11800				var width = boxWidth + (fontSize / 2) + textWidth;
11801				var x = cursor.x;
11802				var y = cursor.y;
11803
11804				if (isHorizontal) {
11805					if (x + width >= legendWidth) {
11806						y = cursor.y += itemHeight;
11807						cursor.line++;
11808						x = cursor.x = me.left + ((legendWidth - lineWidths[cursor.line]) / 2);
11809					}
11810				} else if (y + itemHeight > me.bottom) {
11811					x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding;
11812					y = cursor.y = me.top + labelOpts.padding;
11813					cursor.line++;
11814				}
11815
11816				drawLegendBox(x, y, legendItem);
11817
11818				hitboxes[i].left = x;
11819				hitboxes[i].top = y;
11820
11821				// Fill the actual label
11822				fillText(x, y, legendItem, textWidth);
11823
11824				if (isHorizontal) {
11825					cursor.x += width + (labelOpts.padding);
11826				} else {
11827					cursor.y += itemHeight;
11828				}
11829
11830			});
11831		}
11832	},
11833
11834	/**
11835	 * Handle an event
11836	 * @private
11837	 * @param {IEvent} event - The event to handle
11838	 * @return {Boolean} true if a change occured
11839	 */
11840	handleEvent: function(e) {
11841		var me = this;
11842		var opts = me.options;
11843		var type = e.type === 'mouseup' ? 'click' : e.type;
11844		var changed = false;
11845
11846		if (type === 'mousemove') {
11847			if (!opts.onHover) {
11848				return;
11849			}
11850		} else if (type === 'click') {
11851			if (!opts.onClick) {
11852				return;
11853			}
11854		} else {
11855			return;
11856		}
11857
11858		// Chart event already has relative position in it
11859		var x = e.x;
11860		var y = e.y;
11861
11862		if (x >= me.left && x <= me.right && y >= me.top && y <= me.bottom) {
11863			// See if we are touching one of the dataset boxes
11864			var lh = me.legendHitBoxes;
11865			for (var i = 0; i < lh.length; ++i) {
11866				var hitBox = lh[i];
11867
11868				if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) {
11869					// Touching an element
11870					if (type === 'click') {
11871						// use e.native for backwards compatibility
11872						opts.onClick.call(me, e.native, me.legendItems[i]);
11873						changed = true;
11874						break;
11875					} else if (type === 'mousemove') {
11876						// use e.native for backwards compatibility
11877						opts.onHover.call(me, e.native, me.legendItems[i]);
11878						changed = true;
11879						break;
11880					}
11881				}
11882			}
11883		}
11884
11885		return changed;
11886	}
11887});
11888
11889function createNewLegendAndAttach(chart, legendOpts) {
11890	var legend = new Legend({
11891		ctx: chart.ctx,
11892		options: legendOpts,
11893		chart: chart
11894	});
11895
11896	layouts.configure(chart, legend, legendOpts);
11897	layouts.addBox(chart, legend);
11898	chart.legend = legend;
11899}
11900
11901module.exports = {
11902	id: 'legend',
11903
11904	/**
11905	 * Backward compatibility: since 2.1.5, the legend is registered as a plugin, making
11906	 * Chart.Legend obsolete. To avoid a breaking change, we export the Legend as part of
11907	 * the plugin, which one will be re-exposed in the chart.js file.
11908	 * https://github.com/chartjs/Chart.js/pull/2640
11909	 * @private
11910	 */
11911	_element: Legend,
11912
11913	beforeInit: function(chart) {
11914		var legendOpts = chart.options.legend;
11915
11916		if (legendOpts) {
11917			createNewLegendAndAttach(chart, legendOpts);
11918		}
11919	},
11920
11921	beforeUpdate: function(chart) {
11922		var legendOpts = chart.options.legend;
11923		var legend = chart.legend;
11924
11925		if (legendOpts) {
11926			helpers.mergeIf(legendOpts, defaults.global.legend);
11927
11928			if (legend) {
11929				layouts.configure(chart, legend, legendOpts);
11930				legend.options = legendOpts;
11931			} else {
11932				createNewLegendAndAttach(chart, legendOpts);
11933			}
11934		} else if (legend) {
11935			layouts.removeBox(chart, legend);
11936			delete chart.legend;
11937		}
11938	},
11939
vendor: 4,952 bytes, lines 11940-12144
11940	afterEvent: function(chart, e) {
11941		var legend = chart.legend;
11942		if (legend) {
11943			legend.handleEvent(e);
11944		}
11945	}
11946};
11947
11948},{"25":25,"26":26,"30":30,"45":45}],52:[function(require,module,exports){
11949'use strict';
11950
11951var defaults = require(25);
11952var Element = require(26);
11953var helpers = require(45);
11954var layouts = require(30);
11955
11956var noop = helpers.noop;
11957
11958defaults._set('global', {
11959	title: {
11960		display: false,
11961		fontStyle: 'bold',
11962		fullWidth: true,
11963		lineHeight: 1.2,
11964		padding: 10,
11965		position: 'top',
11966		text: '',
11967		weight: 2000         // by default greater than legend (1000) to be above
11968	}
11969});
11970
11971/**
11972 * IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required!
11973 */
11974var Title = Element.extend({
11975	initialize: function(config) {
11976		var me = this;
11977		helpers.extend(me, config);
11978
11979		// Contains hit boxes for each dataset (in dataset order)
11980		me.legendHitBoxes = [];
11981	},
11982
11983	// These methods are ordered by lifecycle. Utilities then follow.
11984
11985	beforeUpdate: noop,
11986	update: function(maxWidth, maxHeight, margins) {
11987		var me = this;
11988
11989		// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
11990		me.beforeUpdate();
11991
11992		// Absorb the master measurements
11993		me.maxWidth = maxWidth;
11994		me.maxHeight = maxHeight;
11995		me.margins = margins;
11996
11997		// Dimensions
11998		me.beforeSetDimensions();
11999		me.setDimensions();
12000		me.afterSetDimensions();
12001		// Labels
12002		me.beforeBuildLabels();
12003		me.buildLabels();
12004		me.afterBuildLabels();
12005
12006		// Fit
12007		me.beforeFit();
12008		me.fit();
12009		me.afterFit();
12010		//
12011		me.afterUpdate();
12012
12013		return me.minSize;
12014
12015	},
12016	afterUpdate: noop,
12017
12018	//
12019
12020	beforeSetDimensions: noop,
12021	setDimensions: function() {
12022		var me = this;
12023		// Set the unconstrained dimension before label rotation
12024		if (me.isHorizontal()) {
12025			// Reset position before calculating rotation
12026			me.width = me.maxWidth;
12027			me.left = 0;
12028			me.right = me.width;
12029		} else {
12030			me.height = me.maxHeight;
12031
12032			// Reset position before calculating rotation
12033			me.top = 0;
12034			me.bottom = me.height;
12035		}
12036
12037		// Reset padding
12038		me.paddingLeft = 0;
12039		me.paddingTop = 0;
12040		me.paddingRight = 0;
12041		me.paddingBottom = 0;
12042
12043		// Reset minSize
12044		me.minSize = {
12045			width: 0,
12046			height: 0
12047		};
12048	},
12049	afterSetDimensions: noop,
12050
12051	//
12052
12053	beforeBuildLabels: noop,
12054	buildLabels: noop,
12055	afterBuildLabels: noop,
12056
12057	//
12058
12059	beforeFit: noop,
12060	fit: function() {
12061		var me = this;
12062		var valueOrDefault = helpers.valueOrDefault;
12063		var opts = me.options;
12064		var display = opts.display;
12065		var fontSize = valueOrDefault(opts.fontSize, defaults.global.defaultFontSize);
12066		var minSize = me.minSize;
12067		var lineCount = helpers.isArray(opts.text) ? opts.text.length : 1;
12068		var lineHeight = helpers.options.toLineHeight(opts.lineHeight, fontSize);
12069		var textSize = display ? (lineCount * lineHeight) + (opts.padding * 2) : 0;
12070
12071		if (me.isHorizontal()) {
12072			minSize.width = me.maxWidth; // fill all the width
12073			minSize.height = textSize;
12074		} else {
12075			minSize.width = textSize;
12076			minSize.height = me.maxHeight; // fill all the height
12077		}
12078
12079		me.width = minSize.width;
12080		me.height = minSize.height;
12081
12082	},
12083	afterFit: noop,
12084
12085	// Shared Methods
12086	isHorizontal: function() {
12087		var pos = this.options.position;
12088		return pos === 'top' || pos === 'bottom';
12089	},
12090
12091	// Actually draw the title block on the canvas
12092	draw: function() {
12093		var me = this;
12094		var ctx = me.ctx;
12095		var valueOrDefault = helpers.valueOrDefault;
12096		var opts = me.options;
12097		var globalDefaults = defaults.global;
12098
12099		if (opts.display) {
12100			var fontSize = valueOrDefault(opts.fontSize, globalDefaults.defaultFontSize);
12101			var fontStyle = valueOrDefault(opts.fontStyle, globalDefaults.defaultFontStyle);
12102			var fontFamily = valueOrDefault(opts.fontFamily, globalDefaults.defaultFontFamily);
12103			var titleFont = helpers.fontString(fontSize, fontStyle, fontFamily);
12104			var lineHeight = helpers.options.toLineHeight(opts.lineHeight, fontSize);
12105			var offset = lineHeight / 2 + opts.padding;
12106			var rotation = 0;
12107			var top = me.top;
12108			var left = me.left;
12109			var bottom = me.bottom;
12110			var right = me.right;
12111			var maxWidth, titleX, titleY;
12112
12113			ctx.fillStyle = valueOrDefault(opts.fontColor, globalDefaults.defaultFontColor); // render in correct colour
12114			ctx.font = titleFont;
12115
12116			// Horizontal
12117			if (me.isHorizontal()) {
12118				titleX = left + ((right - left) / 2); // midpoint of the width
12119				titleY = top + offset;
12120				maxWidth = right - left;
12121			} else {
12122				titleX = opts.position === 'left' ? left + offset : right - offset;
12123				titleY = top + ((bottom - top) / 2);
12124				maxWidth = bottom - top;
12125				rotation = Math.PI * (opts.position === 'left' ? -0.5 : 0.5);
12126			}
12127
12128			ctx.save();
12129			ctx.translate(titleX, titleY);
12130			ctx.rotate(rotation);
12131			ctx.textAlign = 'center';
12132			ctx.textBaseline = 'middle';
12133
12134			var text = opts.text;
12135			if (helpers.isArray(text)) {
12136				var y = 0;
12137				for (var i = 0; i < text.length; ++i) {
12138					ctx.fillText(text[i], 0, y, maxWidth);
12139					y += lineHeight;
12140				}
12141			} else {
12142				ctx.fillText(text, 0, 0, maxWidth);
12143			}
12144
12145			ctx.restore();
12146		}
12147	}
12148});
12149
12150function createNewTitleBlockAndAttach(chart, titleOpts) {
12151	var title = new Title({
12152		ctx: chart.ctx,
12153		options: titleOpts,
12154		chart: chart
12155	});
12156
12157	layouts.configure(chart, title, titleOpts);
12158	layouts.addBox(chart, title);
12159	chart.titleBlock = title;
12160}
12161
12162module.exports = {
12163	id: 'title',
12164
12165	/**
12166	 * Backward compatibility: since 2.1.5, the title is registered as a plugin, making
12167	 * Chart.Title obsolete. To avoid a breaking change, we export the Title as part of
12168	 * the plugin, which one will be re-exposed in the chart.js file.
12169	 * https://github.com/chartjs/Chart.js/pull/2640
12170	 * @private
12171	 */
12172	_element: Title,
12173
12174	beforeInit: function(chart) {
12175		var titleOpts = chart.options.title;
12176
12177		if (titleOpts) {
12178			createNewTitleBlockAndAttach(chart, titleOpts);
12179		}
12180	},
12181
12182	beforeUpdate: function(chart) {
12183		var titleOpts = chart.options.title;
12184		var titleBlock = chart.titleBlock;
12185
12186		if (titleOpts) {
12187			helpers.mergeIf(titleOpts, defaults.global.title);
12188
12189			if (titleBlock) {
12190				layouts.configure(chart, titleBlock, titleOpts);
12191				titleBlock.options = titleOpts;
12192			} else {
12193				createNewTitleBlockAndAttach(chart, titleOpts);
12194			}
12195		} else if (titleBlock) {
12196			layouts.removeBox(chart, titleBlock);
12197			delete chart.titleBlock;
12198		}
12199	}
12200};
12201
12202},{"25":25,"26":26,"30":30,"45":45}],53:[function(require,module,exports){
12203'use strict';
12204
12205module.exports = function(Chart) {
12206
12207	// Default config for a category scale
12208	var defaultConfig = {
12209		position: 'bottom'
12210	};
12211
12212	var DatasetScale = Chart.Scale.extend({
12213		/**
12214		* Internal function to get the correct labels. If data.xLabels or data.yLabels are defined, use those
12215		* else fall back to data.labels
12216		* @private
12217		*/
12218		getLabels: function() {
12219			var data = this.chart.data;
12220			return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
12221		},
12222
12223		determineDataLimits: function() {
12224			var me = this;
12225			var labels = me.getLabels();
12226			me.minIndex = 0;
12227			me.maxIndex = labels.length - 1;
12228			var findIndex;
12229
12230			if (me.options.ticks.min !== undefined) {
12231				// user specified min value
12232				findIndex = labels.indexOf(me.options.ticks.min);
12233				me.minIndex = findIndex !== -1 ? findIndex : me.minIndex;
12234			}
12235
12236			if (me.options.ticks.max !== undefined) {
12237				// user specified max value
12238				findIndex = labels.indexOf(me.options.ticks.max);
12239				me.maxIndex = findIndex !== -1 ? findIndex : me.maxIndex;
12240			}
12241
12242			me.min = labels[me.minIndex];
12243			me.max = labels[me.maxIndex];
12244		},
12245
12246		buildTicks: function() {
12247			var me = this;
12248			var labels = me.getLabels();
12249			// If we are viewing some subset of labels, slice the original array
12250			me.ticks = (me.minIndex === 0 && me.maxIndex === labels.length - 1) ? labels : labels.slice(me.minIndex, me.maxIndex + 1);
12251		},
12252
12253		getLabelForIndex: function(index, datasetIndex) {
12254			var me = this;
12255			var data = me.chart.data;
12256			var isHorizontal = me.isHorizontal();
12257
12258			if (data.yLabels && !isHorizontal) {
12259				return me.getRightValue(data.datasets[datasetIndex].data[index]);
12260			}
12261			return me.ticks[index - me.minIndex];
12262		},
12263
12264		// Used to get data value locations.  Value can either be an index or a numerical value
12265		getPixelForValue: function(value, index) {
12266			var me = this;
12267			var offset = me.options.offset;
12268			// 1 is added because we need the length but we have the indexes
12269			var offsetAmt = Math.max((me.maxIndex + 1 - me.minIndex - (offset ? 0 : 1)), 1);
12270
12271			// If value is a data object, then index is the index in the data array,
12272			// not the index of the scale. We need to change that.
12273			var valueCategory;
12274			if (value !== undefined && value !== null) {
12275				valueCategory = me.isHorizontal() ? value.x : value.y;
12276			}
12277			if (valueCategory !== undefined || (value !== undefined && isNaN(index))) {
12278				var labels = me.getLabels();
12279				value = valueCategory || value;
12280				var idx = labels.indexOf(value);
12281				index = idx !== -1 ? idx : index;
12282			}
12283
12284			if (me.isHorizontal()) {
12285				var valueWidth = me.width / offsetAmt;
12286				var widthOffset = (valueWidth * (index - me.minIndex));
12287
12288				if (offset) {
12289					widthOffset += (valueWidth / 2);
12290				}
12291
12292				return me.left + Math.round(widthOffset);
12293			}
12294			var valueHeight = me.height / offsetAmt;
12295			var heightOffset = (valueHeight * (index - me.minIndex));
12296
12297			if (offset) {
12298				heightOffset += (valueHeight / 2);
12299			}
12300
12301			return me.top + Math.round(heightOffset);
12302		},
12303		getPixelForTick: function(index) {
12304			return this.getPixelForValue(this.ticks[index], index + this.minIndex, null);
12305		},
12306		getValueForPixel: function(pixel) {
12307			var me = this;
12308			var offset = me.options.offset;
12309			var value;
12310			var offsetAmt = Math.max((me._ticks.length - (offset ? 0 : 1)), 1);
12311			var horz = me.isHorizontal();
12312			var valueDimension = (horz ? me.width : me.height) / offsetAmt;
12313
12314			pixel -= horz ? me.left : me.top;
12315
12316			if (offset) {
12317				pixel -= (valueDimension / 2);
12318			}
12319
12320			if (pixel <= 0) {
12321				value = 0;
12322			} else {
12323				value = Math.round(pixel / valueDimension);
12324			}
12325
12326			return value + me.minIndex;
12327		},
12328		getBasePixel: function() {
12329			return this.bottom;
12330		}
12331	});
12332
12333	Chart.scaleService.registerScaleType('category', DatasetScale, defaultConfig);
12334
12335};
12336
12337},{}],54:[function(require,module,exports){
12338'use strict';
12339
12340var defaults = require(25);
12341var helpers = require(45);
12342var Ticks = require(34);
12343
12344module.exports = function(Chart) {
12345
12346	var defaultConfig = {
12347		position: 'left',
12348		ticks: {
12349			callback: Ticks.formatters.linear
12350		}
12351	};
12352
12353	var LinearScale = Chart.LinearScaleBase.extend({
12354
12355		determineDataLimits: function() {
12356			var me = this;
12357			var opts = me.options;
12358			var chart = me.chart;
12359			var data = chart.data;
12360			var datasets = data.datasets;
12361			var isHorizontal = me.isHorizontal();
12362			var DEFAULT_MIN = 0;
12363			var DEFAULT_MAX = 1;
12364
12365			function IDMatches(meta) {
12366				return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
12367			}
12368
12369			// First Calculate the range
12370			me.min = null;
12371			me.max = null;
12372
12373			var hasStacks = opts.stacked;
12374			if (hasStacks === undefined) {
12375				helpers.each(datasets, function(dataset, datasetIndex) {
12376					if (hasStacks) {
12377						return;
12378					}
12379
12380					var meta = chart.getDatasetMeta(datasetIndex);
12381					if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&
12382						meta.stack !== undefined) {
12383						hasStacks = true;
12384					}
12385				});
12386			}
12387
12388			if (opts.stacked || hasStacks) {
12389				var valuesPerStack = {};
12390
12391				helpers.each(datasets, function(dataset, datasetIndex) {
12392					var meta = chart.getDatasetMeta(datasetIndex);
12393					var key = [
12394						meta.type,
12395						// we have a separate stack for stack=undefined datasets when the opts.stacked is undefined
12396						((opts.stacked === undefined && meta.stack === undefined) ? datasetIndex : ''),
12397						meta.stack
12398					].join('.');
12399
12400					if (valuesPerStack[key] === undefined) {
12401						valuesPerStack[key] = {
12402							positiveValues: [],
12403							negativeValues: []
12404						};
12405					}
12406
12407					// Store these per type
12408					var positiveValues = valuesPerStack[key].positiveValues;
12409					var negativeValues = valuesPerStack[key].negativeValues;
12410
12411					if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
12412						helpers.each(dataset.data, function(rawValue, index) {
12413							var value = +me.getRightValue(rawValue);
12414							if (isNaN(value) || meta.data[index].hidden) {
12415								return;
12416							}
12417
12418							positiveValues[index] = positiveValues[index] || 0;
12419							negativeValues[index] = negativeValues[index] || 0;
12420
12421							if (opts.relativePoints) {
12422								positiveValues[index] = 100;
12423							} else if (value < 0) {
12424								negativeValues[index] += value;
12425							} else {
12426								positiveValues[index] += value;
12427							}
12428						});
12429					}
12430				});
12431
12432				helpers.each(valuesPerStack, function(valuesForType) {
12433					var values = valuesForType.positiveValues.concat(valuesForType.negativeValues);
12434					var minVal = helpers.min(values);
12435					var maxVal = helpers.max(values);
12436					me.min = me.min === null ? minVal : Math.min(me.min, minVal);
12437					me.max = me.max === null ? maxVal : Math.max(me.max, maxVal);
12438				});
12439
12440			} else {
12441				helpers.each(datasets, function(dataset, datasetIndex) {
12442					var meta = chart.getDatasetMeta(datasetIndex);
12443					if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
12444						helpers.each(dataset.data, function(rawValue, index) {
12445							var value = +me.getRightValue(rawValue);
12446							if (isNaN(value) || meta.data[index].hidden) {
12447								return;
12448							}
12449
12450							if (me.min === null) {
12451								me.min = value;
12452							} else if (value < me.min) {
12453								me.min = value;
12454							}
12455
12456							if (me.max === null) {
12457								me.max = value;
12458							} else if (value > me.max) {
12459								me.max = value;
12460							}
12461						});
12462					}
12463				});
12464			}
12465
12466			me.min = isFinite(me.min) && !isNaN(me.min) ? me.min : DEFAULT_MIN;
12467			me.max = isFinite(me.max) && !isNaN(me.max) ? me.max : DEFAULT_MAX;
12468
12469			// Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
12470			this.handleTickRangeOptions();
12471		},
12472		getTickLimit: function() {
12473			var maxTicks;
12474			var me = this;
12475			var tickOpts = me.options.ticks;
12476
12477			if (me.isHorizontal()) {
12478				maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.width / 50));
12479			} else {
12480				// The factor of 2 used to scale the font size has been experimentally determined.
12481				var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, defaults.global.defaultFontSize);
12482				maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.height / (2 * tickFontSize)));
12483			}
12484
12485			return maxTicks;
12486		},
12487		// Called after the ticks are built. We need
12488		handleDirectionalChanges: function() {
12489			if (!this.isHorizontal()) {
12490				// We are in a vertical orientation. The top value is the highest. So reverse the array
12491				this.ticks.reverse();
12492			}
12493		},
12494		getLabelForIndex: function(index, datasetIndex) {
12495			return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
12496		},
12497		// Utils
12498		getPixelForValue: function(value) {
12499			// This must be called after fit has been run so that
12500			// this.left, this.top, this.right, and this.bottom have been defined
12501			var me = this;
12502			var start = me.start;
12503
12504			var rightValue = +me.getRightValue(value);
12505			var pixel;
12506			var range = me.end - start;
12507
12508			if (me.isHorizontal()) {
12509				pixel = me.left + (me.width / range * (rightValue - start));
12510			} else {
12511				pixel = me.bottom - (me.height / range * (rightValue - start));
12512			}
12513			return pixel;
12514		},
12515		getValueForPixel: function(pixel) {
12516			var me = this;
12517			var isHorizontal = me.isHorizontal();
12518			var innerDimension = isHorizontal ? me.width : me.height;
12519			var offset = (isHorizontal ? pixel - me.left : me.bottom - pixel) / innerDimension;
12520			return me.start + ((me.end - me.start) * offset);
12521		},
12522		getPixelForTick: function(index) {
12523			return this.getPixelForValue(this.ticksAsNumbers[index]);
12524		}
12525	});
12526	Chart.scaleService.registerScaleType('linear', LinearScale, defaultConfig);
12527
12528};
12529
12530},{"25":25,"34":34,"45":45}],55:[function(require,module,exports){
12531'use strict';
12532
12533var helpers = require(45);
12534
12535/**
12536 * Generate a set of linear ticks
12537 * @param generationOptions the options used to generate the ticks
12538 * @param dataRange the range of the data
12539 * @returns {Array<Number>} array of tick values
12540 */
12541function generateTicks(generationOptions, dataRange) {
12542	var ticks = [];
12543	// To get a "nice" value for the tick spacing, we will use the appropriately named
12544	// "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
12545	// for details.
12546
12547	var spacing;
12548	if (generationOptions.stepSize && generationOptions.stepSize > 0) {
12549		spacing = generationOptions.stepSize;
12550	} else {
12551		var niceRange = helpers.niceNum(dataRange.max - dataRange.min, false);
12552		spacing = helpers.niceNum(niceRange / (generationOptions.maxTicks - 1), true);
12553	}
12554	var niceMin = Math.floor(dataRange.min / spacing) * spacing;
12555	var niceMax = Math.ceil(dataRange.max / spacing) * spacing;
12556
12557	// If min, max and stepSize is set and they make an evenly spaced scale use it.
12558	if (generationOptions.min && generationOptions.max && generationOptions.stepSize) {
12559		// If very close to our whole number, use it.
12560		if (helpers.almostWhole((generationOptions.max - generationOptions.min) / generationOptions.stepSize, spacing / 1000)) {
12561			niceMin = generationOptions.min;
12562			niceMax = generationOptions.max;
12563		}
12564	}
12565
12566	var numSpaces = (niceMax - niceMin) / spacing;
12567	// If very close to our rounded value, use it.
12568	if (helpers.almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) {
12569		numSpaces = Math.round(numSpaces);
12570	} else {
12571		numSpaces = Math.ceil(numSpaces);
12572	}
12573
12574	var precision = 1;
12575	if (spacing < 1) {
12576		precision = Math.pow(10, spacing.toString().length - 2);
12577		niceMin = Math.round(niceMin * precision) / precision;
12578		niceMax = Math.round(niceMax * precision) / precision;
12579	}
12580	ticks.push(generationOptions.min !== undefined ? generationOptions.min : niceMin);
12581	for (var j = 1; j < numSpaces; ++j) {
12582		ticks.push(Math.round((niceMin + j * spacing) * precision) / precision);
12583	}
12584	ticks.push(generationOptions.max !== undefined ? generationOptions.max : niceMax);
12585
12586	return ticks;
12587}
12588
12589
12590module.exports = function(Chart) {
12591
12592	var noop = helpers.noop;
12593
12594	Chart.LinearScaleBase = Chart.Scale.extend({
12595		getRightValue: function(value) {
12596			if (typeof value === 'string') {
12597				return +value;
12598			}
12599			return Chart.Scale.prototype.getRightValue.call(this, value);
12600		},
12601
12602		handleTickRangeOptions: function() {
12603			var me = this;
12604			var opts = me.options;
12605			var tickOpts = opts.ticks;
12606
12607			// If we are forcing it to begin at 0, but 0 will already be rendered on the chart,
12608			// do nothing since that would make the chart weird. If the user really wants a weird chart
12609			// axis, they can manually override it
12610			if (tickOpts.beginAtZero) {
12611				var minSign = helpers.sign(me.min);
12612				var maxSign = helpers.sign(me.max);
12613
12614				if (minSign < 0 && maxSign < 0) {
12615					// move the top up to 0
12616					me.max = 0;
12617				} else if (minSign > 0 && maxSign > 0) {
12618					// move the bottom down to 0
12619					me.min = 0;
12620				}
12621			}
12622
12623			var setMin = tickOpts.min !== undefined || tickOpts.suggestedMin !== undefined;
12624			var setMax = tickOpts.max !== undefined || tickOpts.suggestedMax !== undefined;
12625
12626			if (tickOpts.min !== undefined) {
12627				me.min = tickOpts.min;
12628			} else if (tickOpts.suggestedMin !== undefined) {
12629				if (me.min === null) {
12630					me.min = tickOpts.suggestedMin;
12631				} else {
12632					me.min = Math.min(me.min, tickOpts.suggestedMin);
12633				}
12634			}
12635
12636			if (tickOpts.max !== undefined) {
12637				me.max = tickOpts.max;
12638			} else if (tickOpts.suggestedMax !== undefined) {
12639				if (me.max === null) {
12640					me.max = tickOpts.suggestedMax;
12641				} else {
12642					me.max = Math.max(me.max, tickOpts.suggestedMax);
12643				}
12644			}
12645
12646			if (setMin !== setMax) {
12647				// We set the min or the max but not both.
12648				// So ensure that our range is good
12649				// Inverted or 0 length range can happen when
12650				// ticks.min is set, and no datasets are visible
12651				if (me.min >= me.max) {
12652					if (setMin) {
12653						me.max = me.min + 1;
12654					} else {
12655						me.min = me.max - 1;
12656					}
12657				}
12658			}
12659
12660			if (me.min === me.max) {
12661				me.max++;
12662
12663				if (!tickOpts.beginAtZero) {
12664					me.min--;
12665				}
12666			}
12667		},
12668		getTickLimit: noop,
12669		handleDirectionalChanges: noop,
12670
12671		buildTicks: function() {
12672			var me = this;
12673			var opts = me.options;
12674			var tickOpts = opts.ticks;
12675
12676			// Figure out what the max number of ticks we can support it is based on the size of
12677			// the axis area. For now, we say that the minimum tick spacing in pixels must be 50
12678			// We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
12679			// the graph. Make sure we always have at least 2 ticks
12680			var maxTicks = me.getTickLimit();
12681			maxTicks = Math.max(2, maxTicks);
12682
12683			var numericGeneratorOptions = {
12684				maxTicks: maxTicks,
12685				min: tickOpts.min,
12686				max: tickOpts.max,
12687				stepSize: helpers.valueOrDefault(tickOpts.fixedStepSize, tickOpts.stepSize)
12688			};
12689			var ticks = me.ticks = generateTicks(numericGeneratorOptions, me);
12690
12691			me.handleDirectionalChanges();
12692
12693			// At this point, we need to update our max and min given the tick values since we have expanded the
12694			// range of the scale
12695			me.max = helpers.max(ticks);
12696			me.min = helpers.min(ticks);
12697
12698			if (tickOpts.reverse) {
12699				ticks.reverse();
12700
12701				me.start = me.max;
12702				me.end = me.min;
12703			} else {
12704				me.start = me.min;
12705				me.end = me.max;
12706			}
12707		},
12708		convertTicksToLabels: function() {
12709			var me = this;
12710			me.ticksAsNumbers = me.ticks.slice();
12711			me.zeroLineIndex = me.ticks.indexOf(0);
12712
12713			Chart.Scale.prototype.convertTicksToLabels.call(me);
12714		}
12715	});
12716};
12717
12718},{"45":45}],56:[function(require,module,exports){
12719'use strict';
12720
12721var helpers = require(45);
12722var Ticks = require(34);
12723
12724/**
12725 * Generate a set of logarithmic ticks
12726 * @param generationOptions the options used to generate the ticks
12727 * @param dataRange the range of the data
12728 * @returns {Array<Number>} array of tick values
12729 */
12730function generateTicks(generationOptions, dataRange) {
12731	var ticks = [];
12732	var valueOrDefault = helpers.valueOrDefault;
12733
12734	// Figure out what the max number of ticks we can support it is based on the size of
12735	// the axis area. For now, we say that the minimum tick spacing in pixels must be 50
12736	// We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
12737	// the graph
12738	var tickVal = valueOrDefault(generationOptions.min, Math.pow(10, Math.floor(helpers.log10(dataRange.min))));
12739
12740	var endExp = Math.floor(helpers.log10(dataRange.max));
12741	var endSignificand = Math.ceil(dataRange.max / Math.pow(10, endExp));
12742	var exp, significand;
12743
12744	if (tickVal === 0) {
12745		exp = Math.floor(helpers.log10(dataRange.minNotZero));
12746		significand = Math.floor(dataRange.minNotZero / Math.pow(10, exp));
12747
12748		ticks.push(tickVal);
12749		tickVal = significand * Math.pow(10, exp);
12750	} else {
12751		exp = Math.floor(helpers.log10(tickVal));
12752		significand = Math.floor(tickVal / Math.pow(10, exp));
12753	}
12754	var precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1;
12755
12756	do {
12757		ticks.push(tickVal);
12758
12759		++significand;
12760		if (significand === 10) {
12761			significand = 1;
12762			++exp;
12763			precision = exp >= 0 ? 1 : precision;
12764		}
12765
12766		tickVal = Math.round(significand * Math.pow(10, exp) * precision) / precision;
12767	} while (exp < endExp || (exp === endExp && significand < endSignificand));
12768
12769	var lastTick = valueOrDefault(generationOptions.max, tickVal);
12770	ticks.push(lastTick);
12771
12772	return ticks;
12773}
12774
12775
12776module.exports = function(Chart) {
12777
12778	var defaultConfig = {
12779		position: 'left',
12780
12781		// label settings
12782		ticks: {
12783			callback: Ticks.formatters.logarithmic
12784		}
12785	};
12786
12787	var LogarithmicScale = Chart.Scale.extend({
12788		determineDataLimits: function() {
12789			var me = this;
12790			var opts = me.options;
12791			var chart = me.chart;
12792			var data = chart.data;
12793			var datasets = data.datasets;
12794			var isHorizontal = me.isHorizontal();
12795			function IDMatches(meta) {
12796				return isHorizontal ? meta.xAxisID === me.id : meta.yAxisID === me.id;
12797			}
12798
12799			// Calculate Range
12800			me.min = null;
12801			me.max = null;
12802			me.minNotZero = null;
12803
12804			var hasStacks = opts.stacked;
12805			if (hasStacks === undefined) {
12806				helpers.each(datasets, function(dataset, datasetIndex) {
12807					if (hasStacks) {
12808						return;
12809					}
12810
12811					var meta = chart.getDatasetMeta(datasetIndex);
12812					if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&
12813						meta.stack !== undefined) {
12814						hasStacks = true;
12815					}
12816				});
12817			}
12818
12819			if (opts.stacked || hasStacks) {
12820				var valuesPerStack = {};
12821
12822				helpers.each(datasets, function(dataset, datasetIndex) {
12823					var meta = chart.getDatasetMeta(datasetIndex);
12824					var key = [
12825						meta.type,
12826						// we have a separate stack for stack=undefined datasets when the opts.stacked is undefined
12827						((opts.stacked === undefined && meta.stack === undefined) ? datasetIndex : ''),
12828						meta.stack
12829					].join('.');
12830
12831					if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
12832						if (valuesPerStack[key] === undefined) {
12833							valuesPerStack[key] = [];
12834						}
12835
12836						helpers.each(dataset.data, function(rawValue, index) {
12837							var values = valuesPerStack[key];
12838							var value = +me.getRightValue(rawValue);
12839							// invalid, hidden and negative values are ignored
12840							if (isNaN(value) || meta.data[index].hidden || value < 0) {
12841								return;
12842							}
12843							values[index] = values[index] || 0;
12844							values[index] += value;
12845						});
12846					}
12847				});
12848
12849				helpers.each(valuesPerStack, function(valuesForType) {
12850					if (valuesForType.length > 0) {
12851						var minVal = helpers.min(valuesForType);
12852						var maxVal = helpers.max(valuesForType);
12853						me.min = me.min === null ? minVal : Math.min(me.min, minVal);
12854						me.max = me.max === null ? maxVal : Math.max(me.max, maxVal);
12855					}
12856				});
12857
12858			} else {
12859				helpers.each(datasets, function(dataset, datasetIndex) {
12860					var meta = chart.getDatasetMeta(datasetIndex);
12861					if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {
12862						helpers.each(dataset.data, function(rawValue, index) {
12863							var value = +me.getRightValue(rawValue);
12864							// invalid, hidden and negative values are ignored
12865							if (isNaN(value) || meta.data[index].hidden || value < 0) {
12866								return;
12867							}
12868
12869							if (me.min === null) {
12870								me.min = value;
12871							} else if (value < me.min) {
12872								me.min = value;
12873							}
12874
12875							if (me.max === null) {
12876								me.max = value;
12877							} else if (value > me.max) {
12878								me.max = value;
12879							}
12880
12881							if (value !== 0 && (me.minNotZero === null || value < me.minNotZero)) {
12882								me.minNotZero = value;
12883							}
12884						});
12885					}
12886				});
12887			}
12888
12889			// Common base implementation to handle ticks.min, ticks.max
12890			this.handleTickRangeOptions();
12891		},
12892		handleTickRangeOptions: function() {
12893			var me = this;
12894			var opts = me.options;
12895			var tickOpts = opts.ticks;
12896			var valueOrDefault = helpers.valueOrDefault;
12897			var DEFAULT_MIN = 1;
12898			var DEFAULT_MAX = 10;
12899
12900			me.min = valueOrDefault(tickOpts.min, me.min);
12901			me.max = valueOrDefault(tickOpts.max, me.max);
12902
12903			if (me.min === me.max) {
12904				if (me.min !== 0 && me.min !== null) {
12905					me.min = Math.pow(10, Math.floor(helpers.log10(me.min)) - 1);
12906					me.max = Math.pow(10, Math.floor(helpers.log10(me.max)) + 1);
12907				} else {
12908					me.min = DEFAULT_MIN;
12909					me.max = DEFAULT_MAX;
12910				}
12911			}
12912			if (me.min === null) {
12913				me.min = Math.pow(10, Math.floor(helpers.log10(me.max)) - 1);
12914			}
12915			if (me.max === null) {
12916				me.max = me.min !== 0
12917					? Math.pow(10, Math.floor(helpers.log10(me.min)) + 1)
12918					: DEFAULT_MAX;
12919			}
12920			if (me.minNotZero === null) {
12921				if (me.min > 0) {
12922					me.minNotZero = me.min;
12923				} else if (me.max < 1) {
12924					me.minNotZero = Math.pow(10, Math.floor(helpers.log10(me.max)));
12925				} else {
12926					me.minNotZero = DEFAULT_MIN;
12927				}
12928			}
12929		},
12930		buildTicks: function() {
12931			var me = this;
12932			var opts = me.options;
12933			var tickOpts = opts.ticks;
12934			var reverse = !me.isHorizontal();
12935
12936			var generationOptions = {
12937				min: tickOpts.min,
12938				max: tickOpts.max
12939			};
12940			var ticks = me.ticks = generateTicks(generationOptions, me);
12941
12942			// At this point, we need to update our max and min given the tick values since we have expanded the
12943			// range of the scale
12944			me.max = helpers.max(ticks);
12945			me.min = helpers.min(ticks);
12946
12947			if (tickOpts.reverse) {
12948				reverse = !reverse;
12949				me.start = me.max;
12950				me.end = me.min;
12951			} else {
12952				me.start = me.min;
12953				me.end = me.max;
12954			}
12955			if (reverse) {
12956				ticks.reverse();
12957			}
12958		},
12959		convertTicksToLabels: function() {
12960			this.tickValues = this.ticks.slice();
12961
12962			Chart.Scale.prototype.convertTicksToLabels.call(this);
12963		},
12964		// Get the correct tooltip label
12965		getLabelForIndex: function(index, datasetIndex) {
12966			return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
12967		},
12968		getPixelForTick: function(index) {
12969			return this.getPixelForValue(this.tickValues[index]);
12970		},
12971		/**
12972		 * Returns the value of the first tick.
12973		 * @param {Number} value - The minimum not zero value.
12974		 * @return {Number} The first tick value.
12975		 * @private
12976		 */
12977		_getFirstTickValue: function(value) {
12978			var exp = Math.floor(helpers.log10(value));
12979			var significand = Math.floor(value / Math.pow(10, exp));
12980
12981			return significand * Math.pow(10, exp);
12982		},
12983		getPixelForValue: function(value) {
12984			var me = this;
12985			var reverse = me.options.ticks.reverse;
12986			var log10 = helpers.log10;
12987			var firstTickValue = me._getFirstTickValue(me.minNotZero);
12988			var offset = 0;
12989			var innerDimension, pixel, start, end, sign;
12990
12991			value = +me.getRightValue(value);
12992			if (reverse) {
12993				start = me.end;
12994				end = me.start;
12995				sign = -1;
12996			} else {
12997				start = me.start;
12998				end = me.end;
12999				sign = 1;
13000			}
13001			if (me.isHorizontal()) {
13002				innerDimension = me.width;
13003				pixel = reverse ? me.right : me.left;
13004			} else {
13005				innerDimension = me.height;
13006				sign *= -1; // invert, since the upper-left corner of the canvas is at pixel (0, 0)
13007				pixel = reverse ? me.top : me.bottom;
13008			}
13009			if (value !== start) {
13010				if (start === 0) { // include zero tick
13011					offset = helpers.getValueOrDefault(
13012						me.options.ticks.fontSize,
13013						Chart.defaults.global.defaultFontSize
13014					);
13015					innerDimension -= offset;
13016					start = firstTickValue;
13017				}
13018				if (value !== 0) {
13019					offset += innerDimension / (log10(end) - log10(start)) * (log10(value) - log10(start));
13020				}
13021				pixel += sign * offset;
13022			}
13023			return pixel;
13024		},
13025		getValueForPixel: function(pixel) {
13026			var me = this;
13027			var reverse = me.options.ticks.reverse;
13028			var log10 = helpers.log10;
13029			var firstTickValue = me._getFirstTickValue(me.minNotZero);
13030			var innerDimension, start, end, value;
13031
13032			if (reverse) {
13033				start = me.end;
13034				end = me.start;
13035			} else {
13036				start = me.start;
13037				end = me.end;
13038			}
13039			if (me.isHorizontal()) {
13040				innerDimension = me.width;
13041				value = reverse ? me.right - pixel : pixel - me.left;
13042			} else {
13043				innerDimension = me.height;
13044				value = reverse ? pixel - me.top : me.bottom - pixel;
13045			}
13046			if (value !== start) {
13047				if (start === 0) { // include zero tick
13048					var offset = helpers.getValueOrDefault(
13049						me.options.ticks.fontSize,
13050						Chart.defaults.global.defaultFontSize
13051					);
13052					value -= offset;
13053					innerDimension -= offset;
13054					start = firstTickValue;
13055				}
13056				value *= log10(end) - log10(start);
13057				value /= innerDimension;
13058				value = Math.pow(10, log10(start) + value);
13059			}
13060			return value;
13061		}
13062	});
13063	Chart.scaleService.registerScaleType('logarithmic', LogarithmicScale, defaultConfig);
13064
13065};
13066
13067},{"34":34,"45":45}],57:[function(require,module,exports){
13068'use strict';
13069
13070var defaults = require(25);
13071var helpers = require(45);
13072var Ticks = require(34);
13073
13074module.exports = function(Chart) {
13075
13076	var globalDefaults = defaults.global;
13077
13078	var defaultConfig = {
13079		display: true,
13080
13081		// Boolean - Whether to animate scaling the chart from the centre
13082		animate: true,
13083		position: 'chartArea',
13084
13085		angleLines: {
13086			display: true,
13087			color: 'rgba(0, 0, 0, 0.1)',
13088			lineWidth: 1
13089		},
13090
13091		gridLines: {
13092			circular: false
13093		},
13094
13095		// label settings
13096		ticks: {
13097			// Boolean - Show a backdrop to the scale label
13098			showLabelBackdrop: true,
13099
13100			// String - The colour of the label backdrop
13101			backdropColor: 'rgba(255,255,255,0.75)',
13102
13103			// Number - The backdrop padding above & below the label in pixels
13104			backdropPaddingY: 2,
13105
13106			// Number - The backdrop padding to the side of the label in pixels
13107			backdropPaddingX: 2,
13108
13109			callback: Ticks.formatters.linear
13110		},
13111
13112		pointLabels: {
13113			// Boolean - if true, show point labels
13114			display: true,
13115
13116			// Number - Point label font size in pixels
13117			fontSize: 10,
13118
13119			// Function - Used to convert point labels
13120			callback: function(label) {
13121				return label;
13122			}
13123		}
13124	};
13125
13126	function getValueCount(scale) {
13127		var opts = scale.options;
13128		return opts.angleLines.display || opts.pointLabels.display ? scale.chart.data.labels.length : 0;
13129	}
13130
13131	function getPointLabelFontOptions(scale) {
13132		var pointLabelOptions = scale.options.pointLabels;
13133		var fontSize = helpers.valueOrDefault(pointLabelOptions.fontSize, globalDefaults.defaultFontSize);
13134		var fontStyle = helpers.valueOrDefault(pointLabelOptions.fontStyle, globalDefaults.defaultFontStyle);
13135		var fontFamily = helpers.valueOrDefault(pointLabelOptions.fontFamily, globalDefaults.defaultFontFamily);
13136		var font = helpers.fontString(fontSize, fontStyle, fontFamily);
13137
13138		return {
13139			size: fontSize,
13140			style: fontStyle,
13141			family: fontFamily,
13142			font: font
13143		};
13144	}
13145
13146	function measureLabelSize(ctx, fontSize, label) {
13147		if (helpers.isArray(label)) {
13148			return {
13149				w: helpers.longestText(ctx, ctx.font, label),
13150				h: (label.length * fontSize) + ((label.length - 1) * 1.5 * fontSize)
13151			};
13152		}
13153
13154		return {
13155			w: ctx.measureText(label).width,
13156			h: fontSize
13157		};
13158	}
13159
13160	function determineLimits(angle, pos, size, min, max) {
13161		if (angle === min || angle === max) {
13162			return {
13163				start: pos - (size / 2),
13164				end: pos + (size / 2)
13165			};
13166		} else if (angle < min || angle > max) {
13167			return {
13168				start: pos - size - 5,
13169				end: pos
13170			};
13171		}
13172
13173		return {
13174			start: pos,
13175			end: pos + size + 5
13176		};
13177	}
13178
13179	/**
13180	 * Helper function to fit a radial linear scale with point labels
13181	 */
13182	function fitWithPointLabels(scale) {
13183		/*
13184		 * Right, this is really confusing and there is a lot of maths going on here
13185		 * The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
13186		 *
13187		 * Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
13188		 *
13189		 * Solution:
13190		 *
13191		 * We assume the radius of the polygon is half the size of the canvas at first
13192		 * at each index we check if the text overlaps.
13193		 *
13194		 * Where it does, we store that angle and that index.
13195		 *
13196		 * After finding the largest index and angle we calculate how much we need to remove
13197		 * from the shape radius to move the point inwards by that x.
13198		 *
13199		 * We average the left and right distances to get the maximum shape radius that can fit in the box
13200		 * along with labels.
13201		 *
13202		 * Once we have that, we can find the centre point for the chart, by taking the x text protrusion
13203		 * on each side, removing that from the size, halving it and adding the left x protrusion width.
13204		 *
13205		 * This will mean we have a shape fitted to the canvas, as large as it can be with the labels
13206		 * and position it in the most space efficient manner
13207		 *
13208		 * https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
13209		 */
13210
13211		var plFont = getPointLabelFontOptions(scale);
13212
13213		// Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
13214		// Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
13215		var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
13216		var furthestLimits = {
13217			r: scale.width,
13218			l: 0,
13219			t: scale.height,
13220			b: 0
13221		};
13222		var furthestAngles = {};
13223		var i, textSize, pointPosition;
13224
13225		scale.ctx.font = plFont.font;
13226		scale._pointLabelSizes = [];
13227
13228		var valueCount = getValueCount(scale);
13229		for (i = 0; i < valueCount; i++) {
13230			pointPosition = scale.getPointPosition(i, largestPossibleRadius);
13231			textSize = measureLabelSize(scale.ctx, plFont.size, scale.pointLabels[i] || '');
13232			scale._pointLabelSizes[i] = textSize;
13233
13234			// Add quarter circle to make degree 0 mean top of circle
13235			var angleRadians = scale.getIndexAngle(i);
13236			var angle = helpers.toDegrees(angleRadians) % 360;
13237			var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
13238			var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
13239
13240			if (hLimits.start < furthestLimits.l) {
13241				furthestLimits.l = hLimits.start;
13242				furthestAngles.l = angleRadians;
13243			}
13244
13245			if (hLimits.end > furthestLimits.r) {
13246				furthestLimits.r = hLimits.end;
13247				furthestAngles.r = angleRadians;
13248			}
13249
13250			if (vLimits.start < furthestLimits.t) {
13251				furthestLimits.t = vLimits.start;
13252				furthestAngles.t = angleRadians;
13253			}
13254
13255			if (vLimits.end > furthestLimits.b) {
13256				furthestLimits.b = vLimits.end;
13257				furthestAngles.b = angleRadians;
13258			}
13259		}
13260
13261		scale.setReductions(largestPossibleRadius, furthestLimits, furthestAngles);
13262	}
13263
13264	/**
13265	 * Helper function to fit a radial linear scale with no point labels
13266	 */
13267	function fit(scale) {
13268		var largestPossibleRadius = Math.min(scale.height / 2, scale.width / 2);
13269		scale.drawingArea = Math.round(largestPossibleRadius);
13270		scale.setCenterPoint(0, 0, 0, 0);
13271	}
13272
13273	function getTextAlignForAngle(angle) {
13274		if (angle === 0 || angle === 180) {
13275			return 'center';
13276		} else if (angle < 180) {
13277			return 'left';
13278		}
13279
13280		return 'right';
13281	}
13282
13283	function fillText(ctx, text, position, fontSize) {
13284		if (helpers.isArray(text)) {
13285			var y = position.y;
13286			var spacing = 1.5 * fontSize;
13287
13288			for (var i = 0; i < text.length; ++i) {
13289				ctx.fillText(text[i], position.x, y);
13290				y += spacing;
13291			}
13292		} else {
13293			ctx.fillText(text, position.x, position.y);
13294		}
13295	}
13296
13297	function adjustPointPositionForLabelHeight(angle, textSize, position) {
13298		if (angle === 90 || angle === 270) {
13299			position.y -= (textSize.h / 2);
13300		} else if (angle > 270 || angle < 90) {
13301			position.y -= textSize.h;
13302		}
13303	}
13304
13305	function drawPointLabels(scale) {
13306		var ctx = scale.ctx;
13307		var opts = scale.options;
13308		var angleLineOpts = opts.angleLines;
13309		var pointLabelOpts = opts.pointLabels;
13310
13311		ctx.lineWidth = angleLineOpts.lineWidth;
13312		ctx.strokeStyle = angleLineOpts.color;
13313
13314		var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.reverse ? scale.min : scale.max);
13315
13316		// Point Label Font
13317		var plFont = getPointLabelFontOptions(scale);
13318
13319		ctx.textBaseline = 'top';
13320
13321		for (var i = getValueCount(scale) - 1; i >= 0; i--) {
13322			if (angleLineOpts.display) {
13323				var outerPosition = scale.getPointPosition(i, outerDistance);
13324				ctx.beginPath();
13325				ctx.moveTo(scale.xCenter, scale.yCenter);
13326				ctx.lineTo(outerPosition.x, outerPosition.y);
13327				ctx.stroke();
13328				ctx.closePath();
13329			}
13330
13331			if (pointLabelOpts.display) {
13332				// Extra 3px out for some label spacing
13333				var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
13334
13335				// Keep this in loop since we may support array properties here
13336				var pointLabelFontColor = helpers.valueAtIndexOrDefault(pointLabelOpts.fontColor, i, globalDefaults.defaultFontColor);
13337				ctx.font = plFont.font;
13338				ctx.fillStyle = pointLabelFontColor;
13339
13340				var angleRadians = scale.getIndexAngle(i);
13341				var angle = helpers.toDegrees(angleRadians);
13342				ctx.textAlign = getTextAlignForAngle(angle);
13343				adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition);
13344				fillText(ctx, scale.pointLabels[i] || '', pointLabelPosition, plFont.size);
13345			}
13346		}
13347	}
13348
13349	function drawRadiusLine(scale, gridLineOpts, radius, index) {
13350		var ctx = scale.ctx;
13351		ctx.strokeStyle = helpers.valueAtIndexOrDefault(gridLineOpts.color, index - 1);
13352		ctx.lineWidth = helpers.valueAtIndexOrDefault(gridLineOpts.lineWidth, index - 1);
13353
13354		if (scale.options.gridLines.circular) {
13355			// Draw circular arcs between the points
13356			ctx.beginPath();
13357			ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2);
13358			ctx.closePath();
13359			ctx.stroke();
13360		} else {
13361			// Draw straight lines connecting each index
13362			var valueCount = getValueCount(scale);
13363
13364			if (valueCount === 0) {
13365				return;
13366			}
13367
13368			ctx.beginPath();
13369			var pointPosition = scale.getPointPosition(0, radius);
13370			ctx.moveTo(pointPosition.x, pointPosition.y);
13371
13372			for (var i = 1; i < valueCount; i++) {
13373				pointPosition = scale.getPointPosition(i, radius);
13374				ctx.lineTo(pointPosition.x, pointPosition.y);
13375			}
13376
13377			ctx.closePath();
13378			ctx.stroke();
13379		}
13380	}
13381
13382	function numberOrZero(param) {
13383		return helpers.isNumber(param) ? param : 0;
13384	}
13385
13386	var LinearRadialScale = Chart.LinearScaleBase.extend({
13387		setDimensions: function() {
13388			var me = this;
13389			var opts = me.options;
13390			var tickOpts = opts.ticks;
13391			// Set the unconstrained dimension before label rotation
13392			me.width = me.maxWidth;
13393			me.height = me.maxHeight;
13394			me.xCenter = Math.round(me.width / 2);
13395			me.yCenter = Math.round(me.height / 2);
13396
13397			var minSize = helpers.min([me.height, me.width]);
13398			var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
13399			me.drawingArea = opts.display ? (minSize / 2) - (tickFontSize / 2 + tickOpts.backdropPaddingY) : (minSize / 2);
13400		},
13401		determineDataLimits: function() {
13402			var me = this;
13403			var chart = me.chart;
13404			var min = Number.POSITIVE_INFINITY;
13405			var max = Number.NEGATIVE_INFINITY;
13406
13407			helpers.each(chart.data.datasets, function(dataset, datasetIndex) {
13408				if (chart.isDatasetVisible(datasetIndex)) {
13409					var meta = chart.getDatasetMeta(datasetIndex);
13410
13411					helpers.each(dataset.data, function(rawValue, index) {
13412						var value = +me.getRightValue(rawValue);
13413						if (isNaN(value) || meta.data[index].hidden) {
13414							return;
13415						}
13416
13417						min = Math.min(value, min);
13418						max = Math.max(value, max);
13419					});
13420				}
13421			});
13422
13423			me.min = (min === Number.POSITIVE_INFINITY ? 0 : min);
13424			me.max = (max === Number.NEGATIVE_INFINITY ? 0 : max);
13425
13426			// Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
13427			me.handleTickRangeOptions();
13428		},
13429		getTickLimit: function() {
13430			var tickOpts = this.options.ticks;
13431			var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
13432			return Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(this.drawingArea / (1.5 * tickFontSize)));
13433		},
13434		convertTicksToLabels: function() {
13435			var me = this;
13436
13437			Chart.LinearScaleBase.prototype.convertTicksToLabels.call(me);
13438
13439			// Point labels
13440			me.pointLabels = me.chart.data.labels.map(me.options.pointLabels.callback, me);
13441		},
13442		getLabelForIndex: function(index, datasetIndex) {
13443			return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[index]);
13444		},
13445		fit: function() {
13446			if (this.options.pointLabels.display) {
13447				fitWithPointLabels(this);
13448			} else {
13449				fit(this);
13450			}
13451		},
13452		/**
13453		 * Set radius reductions and determine new radius and center point
13454		 * @private
13455		 */
13456		setReductions: function(largestPossibleRadius, furthestLimits, furthestAngles) {
13457			var me = this;
13458			var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
13459			var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
13460			var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t);
13461			var radiusReductionBottom = -Math.max(furthestLimits.b - me.height, 0) / Math.cos(furthestAngles.b);
13462
13463			radiusReductionLeft = numberOrZero(radiusReductionLeft);
13464			radiusReductionRight = numberOrZero(radiusReductionRight);
13465			radiusReductionTop = numberOrZero(radiusReductionTop);
13466			radiusReductionBottom = numberOrZero(radiusReductionBottom);
13467
13468			me.drawingArea = Math.min(
13469				Math.round(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
13470				Math.round(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
13471			me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
13472		},
13473		setCenterPoint: function(leftMovement, rightMovement, topMovement, bottomMovement) {
13474			var me = this;
13475			var maxRight = me.width - rightMovement - me.drawingArea;
13476			var maxLeft = leftMovement + me.drawingArea;
13477			var maxTop = topMovement + me.drawingArea;
13478			var maxBottom = me.height - bottomMovement - me.drawingArea;
13479
13480			me.xCenter = Math.round(((maxLeft + maxRight) / 2) + me.left);
13481			me.yCenter = Math.round(((maxTop + maxBottom) / 2) + me.top);
13482		},
13483
13484		getIndexAngle: function(index) {
13485			var angleMultiplier = (Math.PI * 2) / getValueCount(this);
13486			var startAngle = this.chart.options && this.chart.options.startAngle ?
13487				this.chart.options.startAngle :
13488				0;
13489
13490			var startAngleRadians = startAngle * Math.PI * 2 / 360;
13491
13492			// Start from the top instead of right, so remove a quarter of the circle
13493			return index * angleMultiplier + startAngleRadians;
13494		},
13495		getDistanceFromCenterForValue: function(value) {
13496			var me = this;
13497
13498			if (value === null) {
13499				return 0; // null always in center
13500			}
13501
13502			// Take into account half font size + the yPadding of the top value
13503			var scalingFactor = me.drawingArea / (me.max - me.min);
13504			if (me.options.ticks.reverse) {
13505				return (me.max - value) * scalingFactor;
13506			}
13507			return (value - me.min) * scalingFactor;
13508		},
13509		getPointPosition: function(index, distanceFromCenter) {
13510			var me = this;
13511			var thisAngle = me.getIndexAngle(index) - (Math.PI / 2);
13512			return {
13513				x: Math.round(Math.cos(thisAngle) * distanceFromCenter) + me.xCenter,
13514				y: Math.round(Math.sin(thisAngle) * distanceFromCenter) + me.yCenter
13515			};
13516		},
13517		getPointPositionForValue: function(index, value) {
13518			return this.getPointPosition(index, this.getDistanceFromCenterForValue(value));
13519		},
13520
13521		getBasePosition: function() {
13522			var me = this;
13523			var min = me.min;
13524			var max = me.max;
13525
13526			return me.getPointPositionForValue(0,
13527				me.beginAtZero ? 0 :
13528				min < 0 && max < 0 ? max :
13529				min > 0 && max > 0 ? min :
13530				0);
13531		},
13532
13533		draw: function() {
13534			var me = this;
13535			var opts = me.options;
13536			var gridLineOpts = opts.gridLines;
13537			var tickOpts = opts.ticks;
13538			var valueOrDefault = helpers.valueOrDefault;
13539
13540			if (opts.display) {
13541				var ctx = me.ctx;
13542				var startAngle = this.getIndexAngle(0);
13543
13544				// Tick Font
13545				var tickFontSize = valueOrDefault(tickOpts.fontSize, globalDefaults.defaultFontSize);
13546				var tickFontStyle = valueOrDefault(tickOpts.fontStyle, globalDefaults.defaultFontStyle);
13547				var tickFontFamily = valueOrDefault(tickOpts.fontFamily, globalDefaults.defaultFontFamily);
13548				var tickLabelFont = helpers.fontString(tickFontSize, tickFontStyle, tickFontFamily);
13549
13550				helpers.each(me.ticks, function(label, index) {
13551					// Don't draw a centre value (if it is minimum)
13552					if (index > 0 || tickOpts.reverse) {
13553						var yCenterOffset = me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]);
13554
13555						// Draw circular lines around the scale
13556						if (gridLineOpts.display && index !== 0) {
13557							drawRadiusLine(me, gridLineOpts, yCenterOffset, index);
13558						}
13559
13560						if (tickOpts.display) {
13561							var tickFontColor = valueOrDefault(tickOpts.fontColor, globalDefaults.defaultFontColor);
13562							ctx.font = tickLabelFont;
13563
13564							ctx.save();
13565							ctx.translate(me.xCenter, me.yCenter);
13566							ctx.rotate(startAngle);
13567
13568							if (tickOpts.showLabelBackdrop) {
13569								var labelWidth = ctx.measureText(label).width;
13570								ctx.fillStyle = tickOpts.backdropColor;
13571								ctx.fillRect(
13572									-labelWidth / 2 - tickOpts.backdropPaddingX,
13573									-yCenterOffset - tickFontSize / 2 - tickOpts.backdropPaddingY,
13574									labelWidth + tickOpts.backdropPaddingX * 2,
13575									tickFontSize + tickOpts.backdropPaddingY * 2
13576								);
13577							}
13578
13579							ctx.textAlign = 'center';
13580							ctx.textBaseline = 'middle';
13581							ctx.fillStyle = tickFontColor;
13582							ctx.fillText(label, 0, -yCenterOffset);
13583							ctx.restore();
13584						}
13585					}
13586				});
13587
13588				if (opts.angleLines.display || opts.pointLabels.display) {
13589					drawPointLabels(me);
13590				}
13591			}
13592		}
13593	});
13594	Chart.scaleService.registerScaleType('radialLinear', LinearRadialScale, defaultConfig);
13595
13596};
13597
13598},{"25":25,"34":34,"45":45}],58:[function(require,module,exports){
13599/* global window: false */
13600'use strict';
13601
13602var moment = require(1);
13603moment = typeof moment === 'function' ? moment : window.moment;
13604
13605var defaults = require(25);
13606var helpers = require(45);
13607
13608// Integer constants are from the ES6 spec.
13609var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
13610var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
13611
13612var INTERVALS = {
13613	millisecond: {
13614		common: true,
13615		size: 1,
13616		steps: [1, 2, 5, 10, 20, 50, 100, 250, 500]
13617	},
13618	second: {
13619		common: true,
13620		size: 1000,
13621		steps: [1, 2, 5, 10, 30]
13622	},
13623	minute: {
13624		common: true,
13625		size: 60000,
13626		steps: [1, 2, 5, 10, 30]
13627	},
13628	hour: {
13629		common: true,
13630		size: 3600000,
13631		steps: [1, 2, 3, 6, 12]
13632	},
13633	day: {
13634		common: true,
13635		size: 86400000,
13636		steps: [1, 2, 5]
13637	},
13638	week: {
13639		common: false,
13640		size: 604800000,
13641		steps: [1, 2, 3, 4]
13642	},
13643	month: {
13644		common: true,
13645		size: 2.628e9,
13646		steps: [1, 2, 3]
13647	},
13648	quarter: {
13649		common: false,
13650		size: 7.884e9,
13651		steps: [1, 2, 3, 4]
13652	},
13653	year: {
13654		common: true,
13655		size: 3.154e10
13656	}
13657};
13658
13659var UNITS = Object.keys(INTERVALS);
13660
13661function sorter(a, b) {
13662	return a - b;
13663}
13664
13665function arrayUnique(items) {
13666	var hash = {};
13667	var out = [];
13668	var i, ilen, item;
13669
13670	for (i = 0, ilen = items.length; i < ilen; ++i) {
13671		item = items[i];
13672		if (!hash[item]) {
13673			hash[item] = true;
13674			out.push(item);
13675		}
13676	}
13677
13678	return out;
13679}
13680
13681/**
13682 * Returns an array of {time, pos} objects used to interpolate a specific `time` or position
13683 * (`pos`) on the scale, by searching entries before and after the requested value. `pos` is
13684 * a decimal between 0 and 1: 0 being the start of the scale (left or top) and 1 the other
13685 * extremity (left + width or top + height). Note that it would be more optimized to directly
13686 * store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
13687 * to create the lookup table. The table ALWAYS contains at least two items: min and max.
13688 *
13689 * @param {Number[]} timestamps - timestamps sorted from lowest to highest.
13690 * @param {String} distribution - If 'linear', timestamps will be spread linearly along the min
13691 * and max range, so basically, the table will contains only two items: {min, 0} and {max, 1}.
13692 * If 'series', timestamps will be positioned at the same distance from each other. In this
13693 * case, only timestamps that break the time linearity are registered, meaning that in the
13694 * best case, all timestamps are linear, the table contains only min and max.
13695 */
13696function buildLookupTable(timestamps, min, max, distribution) {
13697	if (distribution === 'linear' || !timestamps.length) {
13698		return [
13699			{time: min, pos: 0},
13700			{time: max, pos: 1}
13701		];
13702	}
13703
13704	var table = [];
13705	var items = [min];
13706	var i, ilen, prev, curr, next;
13707
13708	for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
13709		curr = timestamps[i];
13710		if (curr > min && curr < max) {
13711			items.push(curr);
13712		}
13713	}
13714
13715	items.push(max);
13716
13717	for (i = 0, ilen = items.length; i < ilen; ++i) {
13718		next = items[i + 1];
13719		prev = items[i - 1];
13720		curr = items[i];
13721
13722		// only add points that breaks the scale linearity
13723		if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) {
13724			table.push({time: curr, pos: i / (ilen - 1)});
13725		}
13726	}
13727
13728	return table;
13729}
13730
13731// @see adapted from http://www.anujgakhar.com/2014/03/01/binary-search-in-javascript/
13732function lookup(table, key, value) {
13733	var lo = 0;
13734	var hi = table.length - 1;
13735	var mid, i0, i1;
13736
13737	while (lo >= 0 && lo <= hi) {
13738		mid = (lo + hi) >> 1;
13739		i0 = table[mid - 1] || null;
13740		i1 = table[mid];
13741
13742		if (!i0) {
13743			// given value is outside table (before first item)
13744			return {lo: null, hi: i1};
13745		} else if (i1[key] < value) {
13746			lo = mid + 1;
13747		} else if (i0[key] > value) {
13748			hi = mid - 1;
13749		} else {
13750			return {lo: i0, hi: i1};
13751		}
13752	}
13753
13754	// given value is outside table (after last item)
13755	return {lo: i1, hi: null};
13756}
13757
13758/**
13759 * Linearly interpolates the given source `value` using the table items `skey` values and
13760 * returns the associated `tkey` value. For example, interpolate(table, 'time', 42, 'pos')
13761 * returns the position for a timestamp equal to 42. If value is out of bounds, values at
13762 * index [0, 1] or [n - 1, n] are used for the interpolation.
13763 */
13764function interpolate(table, skey, sval, tkey) {
13765	var range = lookup(table, skey, sval);
13766
13767	// Note: the lookup table ALWAYS contains at least 2 items (min and max)
13768	var prev = !range.lo ? table[0] : !range.hi ? table[table.length - 2] : range.lo;
13769	var next = !range.lo ? table[1] : !range.hi ? table[table.length - 1] : range.hi;
13770
13771	var span = next[skey] - prev[skey];
13772	var ratio = span ? (sval - prev[skey]) / span : 0;
13773	var offset = (next[tkey] - prev[tkey]) * ratio;
13774
13775	return prev[tkey] + offset;
13776}
13777
13778/**
13779 * Convert the given value to a moment object using the given time options.
13780 * @see http://momentjs.com/docs/#/parsing/
13781 */
13782function momentify(value, options) {
13783	var parser = options.parser;
13784	var format = options.parser || options.format;
13785
13786	if (typeof parser === 'function') {
13787		return parser(value);
13788	}
13789
13790	if (typeof value === 'string' && typeof format === 'string') {
13791		return moment(value, format);
13792	}
13793
13794	if (!(value instanceof moment)) {
13795		value = moment(value);
13796	}
13797
13798	if (value.isValid()) {
13799		return value;
13800	}
13801
13802	// Labels are in an incompatible moment format and no `parser` has been provided.
13803	// The user might still use the deprecated `format` option to convert his inputs.
13804	if (typeof format === 'function') {
13805		return format(value);
13806	}
13807
13808	return value;
13809}
13810
13811function parse(input, scale) {
13812	if (helpers.isNullOrUndef(input)) {
13813		return null;
13814	}
13815
13816	var options = scale.options.time;
13817	var value = momentify(scale.getRightValue(input), options);
13818	if (!value.isValid()) {
13819		return null;
13820	}
13821
13822	if (options.round) {
13823		value.startOf(options.round);
13824	}
13825
13826	return value.valueOf();
13827}
13828
13829/**
13830 * Returns the number of unit to skip to be able to display up to `capacity` number of ticks
13831 * in `unit` for the given `min` / `max` range and respecting the interval steps constraints.
13832 */
13833function determineStepSize(min, max, unit, capacity) {
13834	var range = max - min;
13835	var interval = INTERVALS[unit];
13836	var milliseconds = interval.size;
13837	var steps = interval.steps;
13838	var i, ilen, factor;
13839
13840	if (!steps) {
13841		return Math.ceil(range / (capacity * milliseconds));
13842	}
13843
13844	for (i = 0, ilen = steps.length; i < ilen; ++i) {
13845		factor = steps[i];
13846		if (Math.ceil(range / (milliseconds * factor)) <= capacity) {
13847			break;
13848		}
13849	}
13850
13851	return factor;
13852}
13853
13854/**
13855 * Figures out what unit results in an appropriate number of auto-generated ticks
13856 */
13857function determineUnitForAutoTicks(minUnit, min, max, capacity) {
13858	var ilen = UNITS.length;
13859	var i, interval, factor;
13860
13861	for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
13862		interval = INTERVALS[UNITS[i]];
13863		factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
13864
13865		if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
13866			return UNITS[i];
13867		}
13868	}
13869
13870	return UNITS[ilen - 1];
13871}
13872
13873/**
13874 * Figures out what unit to format a set of ticks with
13875 */
13876function determineUnitForFormatting(ticks, minUnit, min, max) {
13877	var duration = moment.duration(moment(max).diff(moment(min)));
13878	var ilen = UNITS.length;
13879	var i, unit;
13880
13881	for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
13882		unit = UNITS[i];
13883		if (INTERVALS[unit].common && duration.as(unit) >= ticks.length) {
13884			return unit;
13885		}
13886	}
13887
13888	return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];
13889}
13890
13891function determineMajorUnit(unit) {
13892	for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {
13893		if (INTERVALS[UNITS[i]].common) {
13894			return UNITS[i];
13895		}
13896	}
13897}
13898
13899/**
13900 * Generates a maximum of `capacity` timestamps between min and max, rounded to the
13901 * `minor` unit, aligned on the `major` unit and using the given scale time `options`.
13902 * Important: this method can return ticks outside the min and max range, it's the
13903 * responsibility of the calling code to clamp values if needed.
13904 */
13905function generate(min, max, capacity, options) {
13906	var timeOpts = options.time;
13907	var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, capacity);
13908	var major = determineMajorUnit(minor);
13909	var stepSize = helpers.valueOrDefault(timeOpts.stepSize, timeOpts.unitStepSize);
13910	var weekday = minor === 'week' ? timeOpts.isoWeekday : false;
13911	var majorTicksEnabled = options.ticks.major.enabled;
13912	var interval = INTERVALS[minor];
13913	var first = moment(min);
13914	var last = moment(max);
13915	var ticks = [];
13916	var time;
13917
13918	if (!stepSize) {
13919		stepSize = determineStepSize(min, max, minor, capacity);
13920	}
13921
13922	// For 'week' unit, handle the first day of week option
13923	if (weekday) {
13924		first = first.isoWeekday(weekday);
13925		last = last.isoWeekday(weekday);
13926	}
13927
13928	// Align first/last ticks on unit
13929	first = first.startOf(weekday ? 'day' : minor);
13930	last = last.startOf(weekday ? 'day' : minor);
13931
13932	// Make sure that the last tick include max
13933	if (last < max) {
13934		last.add(1, minor);
13935	}
13936
13937	time = moment(first);
13938
13939	if (majorTicksEnabled && major && !weekday && !timeOpts.round) {
13940		// Align the first tick on the previous `minor` unit aligned on the `major` unit:
13941		// we first aligned time on the previous `major` unit then add the number of full
13942		// stepSize there is between first and the previous major time.
13943		time.startOf(major);
13944		time.add(~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
13945	}
13946
13947	for (; time < last; time.add(stepSize, minor)) {
13948		ticks.push(+time);
13949	}
13950
13951	ticks.push(+time);
13952
13953	return ticks;
13954}
13955
13956/**
13957 * Returns the right and left offsets from edges in the form of {left, right}.
13958 * Offsets are added when the `offset` option is true.
13959 */
13960function computeOffsets(table, ticks, min, max, options) {
13961	var left = 0;
13962	var right = 0;
13963	var upper, lower;
13964
13965	if (options.offset && ticks.length) {
13966		if (!options.time.min) {
13967			upper = ticks.length > 1 ? ticks[1] : max;
13968			lower = ticks[0];
13969			left = (
13970				interpolate(table, 'time', upper, 'pos') -
13971				interpolate(table, 'time', lower, 'pos')
13972			) / 2;
13973		}
13974		if (!options.time.max) {
13975			upper = ticks[ticks.length - 1];
13976			lower = ticks.length > 1 ? ticks[ticks.length - 2] : min;
13977			right = (
13978				interpolate(table, 'time', upper, 'pos') -
13979				interpolate(table, 'time', lower, 'pos')
13980			) / 2;
13981		}
13982	}
13983
13984	return {left: left, right: right};
13985}
13986
13987function ticksFromTimestamps(values, majorUnit) {
13988	var ticks = [];
13989	var i, ilen, value, major;
13990
13991	for (i = 0, ilen = values.length; i < ilen; ++i) {
13992		value = values[i];
13993		major = majorUnit ? value === +moment(value).startOf(majorUnit) : false;
13994
13995		ticks.push({
13996			value: value,
13997			major: major
13998		});
13999	}
14000
14001	return ticks;
14002}
14003
14004function determineLabelFormat(data, timeOpts) {
14005	var i, momentDate, hasTime;
14006	var ilen = data.length;
14007
14008	// find the label with the most parts (milliseconds, minutes, etc.)
14009	// format all labels with the same level of detail as the most specific label
14010	for (i = 0; i < ilen; i++) {
14011		momentDate = momentify(data[i], timeOpts);
14012		if (momentDate.millisecond() !== 0) {
14013			return 'MMM D, YYYY h:mm:ss.SSS a';
14014		}
14015		if (momentDate.second() !== 0 || momentDate.minute() !== 0 || momentDate.hour() !== 0) {
14016			hasTime = true;
14017		}
14018	}
14019	if (hasTime) {
14020		return 'MMM D, YYYY h:mm:ss a';
14021	}
14022	return 'MMM D, YYYY';
14023}
14024
14025module.exports = function(Chart) {
14026
14027	var defaultConfig = {
14028		position: 'bottom',
14029
14030		/**
14031		 * Data distribution along the scale:
14032		 * - 'linear': data are spread according to their time (distances can vary),
14033		 * - 'series': data are spread at the same distance from each other.
14034		 * @see https://github.com/chartjs/Chart.js/pull/4507
14035		 * @since 2.7.0
14036		 */
14037		distribution: 'linear',
14038
14039		/**
14040		 * Scale boundary strategy (bypassed by min/max time options)
14041		 * - `data`: make sure data are fully visible, ticks outside are removed
14042		 * - `ticks`: make sure ticks are fully visible, data outside are truncated
14043		 * @see https://github.com/chartjs/Chart.js/pull/4556
14044		 * @since 2.7.0
14045		 */
14046		bounds: 'data',
14047
14048		time: {
14049			parser: false, // false == a pattern string from http://momentjs.com/docs/#/parsing/string-format/ or a custom callback that converts its argument to a moment
14050			format: false, // DEPRECATED false == date objects, moment object, callback or a pattern string from http://momentjs.com/docs/#/parsing/string-format/
14051			unit: false, // false == automatic or override with week, month, year, etc.
14052			round: false, // none, or override with week, month, year, etc.
14053			displayFormat: false, // DEPRECATED
14054			isoWeekday: false, // override week start day - see http://momentjs.com/docs/#/get-set/iso-weekday/
14055			minUnit: 'millisecond',
14056
14057			// defaults to unit's corresponding unitFormat below or override using pattern string from http://momentjs.com/docs/#/displaying/format/
14058			displayFormats: {
14059				millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM,
14060				second: 'h:mm:ss a', // 11:20:01 AM
14061				minute: 'h:mm a', // 11:20 AM
14062				hour: 'hA', // 5PM
14063				day: 'MMM D', // Sep 4
14064				week: 'll', // Week 46, or maybe "[W]WW - YYYY" ?
14065				month: 'MMM YYYY', // Sept 2015
14066				quarter: '[Q]Q - YYYY', // Q3
14067				year: 'YYYY' // 2015
14068			},
14069		},
14070		ticks: {
14071			autoSkip: false,
14072
14073			/**
14074			 * Ticks generation input values:
14075			 * - 'auto': generates "optimal" ticks based on scale size and time options.
14076			 * - 'data': generates ticks from data (including labels from data {t|x|y} objects).
14077			 * - 'labels': generates ticks from user given `data.labels` values ONLY.
14078			 * @see https://github.com/chartjs/Chart.js/pull/4507
14079			 * @since 2.7.0
14080			 */
14081			source: 'auto',
14082
14083			major: {
14084				enabled: false
14085			}
14086		}
14087	};
14088
14089	var TimeScale = Chart.Scale.extend({
14090		initialize: function() {
14091			if (!moment) {
14092				throw new Error('Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com');
14093			}
14094
14095			this.mergeTicksOptions();
14096
14097			Chart.Scale.prototype.initialize.call(this);
14098		},
14099
14100		update: function() {
14101			var me = this;
14102			var options = me.options;
14103
14104			// DEPRECATIONS: output a message only one time per update
14105			if (options.time && options.time.format) {
14106				console.warn('options.time.format is deprecated and replaced by options.time.parser.');
14107			}
14108
14109			return Chart.Scale.prototype.update.apply(me, arguments);
14110		},
14111
14112		/**
14113		 * Allows data to be referenced via 't' attribute
14114		 */
14115		getRightValue: function(rawValue) {
14116			if (rawValue && rawValue.t !== undefined) {
14117				rawValue = rawValue.t;
14118			}
14119			return Chart.Scale.prototype.getRightValue.call(this, rawValue);
14120		},
14121
14122		determineDataLimits: function() {
14123			var me = this;
14124			var chart = me.chart;
14125			var timeOpts = me.options.time;
14126			var unit = timeOpts.unit || 'day';
14127			var min = MAX_INTEGER;
14128			var max = MIN_INTEGER;
14129			var timestamps = [];
14130			var datasets = [];
14131			var labels = [];
14132			var i, j, ilen, jlen, data, timestamp;
14133
14134			// Convert labels to timestamps
14135			for (i = 0, ilen = chart.data.labels.length; i < ilen; ++i) {
14136				labels.push(parse(chart.data.labels[i], me));
14137			}
14138
14139			// Convert data to timestamps
14140			for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {
14141				if (chart.isDatasetVisible(i)) {
14142					data = chart.data.datasets[i].data;
14143
14144					// Let's consider that all data have the same format.
14145					if (helpers.isObject(data[0])) {
14146						datasets[i] = [];
14147
14148						for (j = 0, jlen = data.length; j < jlen; ++j) {
14149							timestamp = parse(data[j], me);
14150							timestamps.push(timestamp);
14151							datasets[i][j] = timestamp;
14152						}
14153					} else {
14154						timestamps.push.apply(timestamps, labels);
14155						datasets[i] = labels.slice(0);
14156					}
14157				} else {
14158					datasets[i] = [];
14159				}
14160			}
14161
14162			if (labels.length) {
14163				// Sort labels **after** data have been converted
14164				labels = arrayUnique(labels).sort(sorter);
14165				min = Math.min(min, labels[0]);
14166				max = Math.max(max, labels[labels.length - 1]);
14167			}
14168
14169			if (timestamps.length) {
14170				timestamps = arrayUnique(timestamps).sort(sorter);
14171				min = Math.min(min, timestamps[0]);
14172				max = Math.max(max, timestamps[timestamps.length - 1]);
14173			}
14174
14175			min = parse(timeOpts.min, me) || min;
14176			max = parse(timeOpts.max, me) || max;
14177
14178			// In case there is no valid min/max, set limits based on unit time option
14179			min = min === MAX_INTEGER ? +moment().startOf(unit) : min;
14180			max = max === MIN_INTEGER ? +moment().endOf(unit) + 1 : max;
14181
14182			// Make sure that max is strictly higher than min (required by the lookup table)
14183			me.min = Math.min(min, max);
14184			me.max = Math.max(min + 1, max);
14185
14186			// PRIVATE
14187			me._horizontal = me.isHorizontal();
14188			me._table = [];
14189			me._timestamps = {
14190				data: timestamps,
14191				datasets: datasets,
14192				labels: labels
14193			};
14194		},
14195
14196		buildTicks: function() {
14197			var me = this;
14198			var min = me.min;
14199			var max = me.max;
14200			var options = me.options;
14201			var timeOpts = options.time;
14202			var timestamps = [];
14203			var ticks = [];
14204			var i, ilen, timestamp;
14205
14206			switch (options.ticks.source) {
14207			case 'data':
14208				timestamps = me._timestamps.data;
14209				break;
14210			case 'labels':
14211				timestamps = me._timestamps.labels;
14212				break;
14213			case 'auto':
14214			default:
14215				timestamps = generate(min, max, me.getLabelCapacity(min), options);
14216			}
14217
14218			if (options.bounds === 'ticks' && timestamps.length) {
14219				min = timestamps[0];
14220				max = timestamps[timestamps.length - 1];
14221			}
14222
14223			// Enforce limits with user min/max options
14224			min = parse(timeOpts.min, me) || min;
14225			max = parse(timeOpts.max, me) || max;
14226
14227			// Remove ticks outside the min/max range
14228			for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
14229				timestamp = timestamps[i];
14230				if (timestamp >= min && timestamp <= max) {
14231					ticks.push(timestamp);
14232				}
14233			}
14234
14235			me.min = min;
14236			me.max = max;
14237
14238			// PRIVATE
14239			me._unit = timeOpts.unit || determineUnitForFormatting(ticks, timeOpts.minUnit, me.min, me.max);
14240			me._majorUnit = determineMajorUnit(me._unit);
14241			me._table = buildLookupTable(me._timestamps.data, min, max, options.distribution);
14242			me._offsets = computeOffsets(me._table, ticks, min, max, options);
14243			me._labelFormat = determineLabelFormat(me._timestamps.data, timeOpts);
14244
14245			return ticksFromTimestamps(ticks, me._majorUnit);
14246		},
14247
14248		getLabelForIndex: function(index, datasetIndex) {
14249			var me = this;
14250			var data = me.chart.data;
14251			var timeOpts = me.options.time;
14252			var label = data.labels && index < data.labels.length ? data.labels[index] : '';
14253			var value = data.datasets[datasetIndex].data[index];
14254
14255			if (helpers.isObject(value)) {
14256				label = me.getRightValue(value);
14257			}
14258			if (timeOpts.tooltipFormat) {
14259				return momentify(label, timeOpts).format(timeOpts.tooltipFormat);
14260			}
14261			if (typeof label === 'string') {
14262				return label;
14263			}
14264
14265			return momentify(label, timeOpts).format(me._labelFormat);
14266		},
14267
14268		/**
14269		 * Function to format an individual tick mark
14270		 * @private
14271		 */
14272		tickFormatFunction: function(tick, index, ticks, formatOverride) {
14273			var me = this;
14274			var options = me.options;
14275			var time = tick.valueOf();
14276			var formats = options.time.displayFormats;
14277			var minorFormat = formats[me._unit];
14278			var majorUnit = me._majorUnit;
14279			var majorFormat = formats[majorUnit];
14280			var majorTime = tick.clone().startOf(majorUnit).valueOf();
14281			var majorTickOpts = options.ticks.major;
14282			var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
14283			var label = tick.format(formatOverride ? formatOverride : major ? majorFormat : minorFormat);
14284			var tickOpts = major ? majorTickOpts : options.ticks.minor;
14285			var formatter = helpers.valueOrDefault(tickOpts.callback, tickOpts.userCallback);
14286
14287			return formatter ? formatter(label, index, ticks) : label;
14288		},
14289
14290		convertTicksToLabels: function(ticks) {
14291			var labels = [];
14292			var i, ilen;
14293
14294			for (i = 0, ilen = ticks.length; i < ilen; ++i) {
14295				labels.push(this.tickFormatFunction(moment(ticks[i].value), i, ticks));
14296			}
14297
14298			return labels;
14299		},
14300
14301		/**
14302		 * @private
14303		 */
14304		getPixelForOffset: function(time) {
14305			var me = this;
14306			var size = me._horizontal ? me.width : me.height;
14307			var start = me._horizontal ? me.left : me.top;
14308			var pos = interpolate(me._table, 'time', time, 'pos');
14309
14310			return start + size * (me._offsets.left + pos) / (me._offsets.left + 1 + me._offsets.right);
14311		},
14312
14313		getPixelForValue: function(value, index, datasetIndex) {
14314			var me = this;
14315			var time = null;
14316
14317			if (index !== undefined && datasetIndex !== undefined) {
14318				time = me._timestamps.datasets[datasetIndex][index];
14319			}
14320
14321			if (time === null) {
14322				time = parse(value, me);
14323			}
14324
14325			if (time !== null) {
14326				return me.getPixelForOffset(time);
14327			}
14328		},
14329
14330		getPixelForTick: function(index) {
14331			var ticks = this.getTicks();
14332			return index >= 0 && index < ticks.length ?
14333				this.getPixelForOffset(ticks[index].value) :
14334				null;
14335		},
14336
14337		getValueForPixel: function(pixel) {
14338			var me = this;
14339			var size = me._horizontal ? me.width : me.height;
14340			var start = me._horizontal ? me.left : me.top;
14341			var pos = (size ? (pixel - start) / size : 0) * (me._offsets.left + 1 + me._offsets.left) - me._offsets.right;
14342			var time = interpolate(me._table, 'pos', pos, 'time');
14343
14344			return moment(time);
14345		},
14346
14347		/**
14348		 * Crude approximation of what the label width might be
14349		 * @private
14350		 */
14351		getLabelWidth: function(label) {
14352			var me = this;
14353			var ticksOpts = me.options.ticks;
14354			var tickLabelWidth = me.ctx.measureText(label).width;
14355			var angle = helpers.toRadians(ticksOpts.maxRotation);
14356			var cosRotation = Math.cos(angle);
14357			var sinRotation = Math.sin(angle);
14358			var tickFontSize = helpers.valueOrDefault(ticksOpts.fontSize, defaults.global.defaultFontSize);
14359
14360			return (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation);
14361		},
14362
14363		/**
14364		 * @private
14365		 */
14366		getLabelCapacity: function(exampleTime) {
14367			var me = this;
14368
14369			var formatOverride = me.options.time.displayFormats.millisecond;	// Pick the longest format for guestimation
14370
14371			var exampleLabel = me.tickFormatFunction(moment(exampleTime), 0, [], formatOverride);
14372			var tickLabelWidth = me.getLabelWidth(exampleLabel);
14373			var innerWidth = me.isHorizontal() ? me.width : me.height;
14374
14375			var capacity = Math.floor(innerWidth / tickLabelWidth);
14376			return capacity > 0 ? capacity : 1;
14377		}
14378	});
14379
14380	Chart.scaleService.registerScaleType('time', TimeScale, defaultConfig);
14381};
14382
14383},{"1":1,"25":25,"45":45}]},{},[7])(7)
14384});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.