diff --git a/bower.json b/bower.json index 63408aea..7f139af8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "chartist", - "version": "0.3.1", + "version": "0.4.0", "main": [ "./libdist/chartist.min.js", "./libdist/chartist.min.css" diff --git a/libdist/chartist.js b/libdist/chartist.js index 9ab8810c..ee7fc6cd 100644 --- a/libdist/chartist.js +++ b/libdist/chartist.js @@ -10,7 +10,7 @@ } }(this, function() { - /* Chartist.js 0.3.1 + /* Chartist.js 0.4.0 * Copyright © 2014 Gion Kunz * Free to use under the WTFPL license. * http://www.wtfpl.net/ @@ -71,17 +71,34 @@ }; /** - * Converts a string to a number while removing the unit px if present. If a number is passed then this will be returned unmodified. + * Converts a string to a number while removing the unit if present. If a number is passed then this will be returned unmodified. * - * @param {String|Number} length - * @returns {Number} Returns the pixel as number or NaN if the passed length could not be converted to pixel + * @memberof Chartist.Core + * @param {String|Number} value + * @returns {Number} Returns the string as number or NaN if the passed length could not be converted to pixel + */ + Chartist.stripUnit = function(value) { + if(typeof value === 'string') { + value = value.replace(/[^0-9\+-\.]/, ''); + } + + return +value; + }; + + /** + * Converts a number to a string with a unit. If a string is passed then this will be returned unmodified. + * + * @memberof Chartist.Core + * @param {Number} value + * @param {String} unit + * @returns {String} Returns the passed number value with unit. */ - Chartist.getPixelLength = function(length) { - if(typeof length === 'string') { - length = length.replace(/px/i, ''); + Chartist.ensureUnit = function(value, unit) { + if(typeof value === 'number') { + value = value + unit; } - return +length; + return value; }; /** @@ -111,30 +128,21 @@ width = width || '100%'; height = height || '100%'; - // If already contains our svg object we clear it, set width / height and return - if (container.chartistSvg !== undefined) { - svg = container.chartistSvg.attr({ - width: width, - height: height - }).removeAllClasses().addClass(className).attr({ - style: 'width: ' + width + '; height: ' + height + ';' - }); - // Clear the draw if its already used before so we start fresh - svg.empty(); + svg = container.querySelector('svg'); + if(svg) { + container.removeChild(svg); + } - } else { - // Create svg object with width and height or use 100% as default - svg = Chartist.Svg('svg').attr({ - width: width, - height: height - }).addClass(className).attr({ - style: 'width: ' + width + '; height: ' + height + ';' - }); + // Create svg object with width and height or use 100% as default + svg = new Chartist.Svg('svg').attr({ + width: width, + height: height + }).addClass(className).attr({ + style: 'width: ' + width + '; height: ' + height + ';' + }); - // Add the DOM node to our container - container.appendChild(svg._node); - container.chartistSvg = svg; - } + // Add the DOM node to our container + container.appendChild(svg._node); return svg; }; @@ -221,7 +229,7 @@ * @return {Number} The height of the area in the chart for the data series */ Chartist.getAvailableHeight = function (svg, options) { - return Math.max((Chartist.getPixelLength(options.height) || svg.height()) - (options.chartPadding * 2) - options.axisX.offset, 0); + return Math.max((Chartist.stripUnit(options.height) || svg.height()) - (options.chartPadding * 2) - options.axisX.offset, 0); }; /** @@ -329,7 +337,7 @@ newMin += bounds.step; } - if (i - bounds.step > bounds.high) { + if (i - bounds.step >= bounds.high) { newMax -= bounds.step; } } @@ -378,8 +386,8 @@ return { x1: options.chartPadding + yOffset, - y1: Math.max((Chartist.getPixelLength(options.height) || svg.height()) - options.chartPadding - xOffset, options.chartPadding), - x2: Math.max((Chartist.getPixelLength(options.width) || svg.width()) - options.chartPadding, options.chartPadding + yOffset), + y1: Math.max((Chartist.stripUnit(options.height) || svg.height()) - options.chartPadding - xOffset, options.chartPadding), + x2: Math.max((Chartist.stripUnit(options.width) || svg.width()) - options.chartPadding, options.chartPadding + yOffset), y2: options.chartPadding, width: function () { return this.x2 - this.x1; @@ -655,6 +663,81 @@ }; }; + //TODO: For arrays it would be better to take the sequence into account and try to minimize modify deltas + /** + * This method will analyze deltas recursively in two objects. The returned object will contain a __delta__ property + * where deltas for specific object properties can be found for the given object nesting level. For nested objects the + * resulting delta descriptor object will contain properties to reflect the nesting. Nested descriptor objects also + * contain a __delta__ property with the deltas of their level. + * + * @param {Object|Array} a Object that should be used to analyzed delta to object b + * @param {Object|Array} b The second object where the deltas from a should be analyzed + * @returns {Object} Delta descriptor object or null + */ + Chartist.deltaDescriptor = function(a, b) { + var summary = { + added: 0, + removed: 0, + modified: 0 + }; + + function findDeltasRecursively(a, b) { + var descriptor = { + __delta__: {} + }; + + // First check for removed and modified properties + Object.keys(a).forEach(function(property) { + if(!b.hasOwnProperty(property)) { + descriptor.__delta__[property] = { + type: 'remove', + property: property, + ours: a[property] + }; + summary.removed++; + } else { + if(typeof a[property] === 'object') { + var subDescriptor = findDeltasRecursively(a[property], b[property]); + if(subDescriptor) { + descriptor[property] = subDescriptor; + } + } else { + if(a[property] !== b[property]) { + descriptor.__delta__[property] = { + type: 'modify', + property: property, + ours: a[property], + theirs: b[property] + }; + summary.modified++; + } + } + } + }); + + // Check for added properties + Object.keys(b).forEach(function(property) { + if(!a.hasOwnProperty(property)) { + descriptor.__delta__[property] = { + type: 'added', + property: property, + theirs: b[property] + }; + summary.added++; + } + }); + + return (Object.keys(descriptor).length !== 1 || Object.keys(descriptor.__delta__).length > 0) ? descriptor : null; + } + + var delta = findDeltasRecursively(a, b); + if(delta) { + delta.__delta__.summary = summary; + } + + return delta; + }; + //http://schepers.cc/getting-to-the-point Chartist.catmullRom2bezier = function (crp, z) { var d = []; @@ -696,7 +779,8 @@ return d; }; - }(window, document, Chartist));;/** + }(window, document, Chartist)); + ;/** * A very basic event module that helps to generate and catch events. * * @module Chartist.Event @@ -757,6 +841,13 @@ handler(data); }); } + + // Emit event to star event handlers + if(handlers['*']) { + handlers['*'].forEach(function(starHandler) { + starHandler(event, data); + }); + } } return { @@ -766,7 +857,8 @@ }; }; - }(window, document, Chartist));;/** + }(window, document, Chartist)); + ;/** * This module provides some basic prototype inheritance utilities. * * @module Chartist.Class @@ -821,7 +913,7 @@ * var banana = new Banana(20, 40); * console.log('banana instanceof Fruit', banana instanceof Fruit); * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana)); - * console.log('bananas\'s prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype); + * console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype); * console.log(banana.sugar); * console.log(banana.eat().sugar); * console.log(banana.color); @@ -889,7 +981,7 @@ * var banana = new Banana(20, 40); * console.log('banana instanceof Fruit', banana instanceof Fruit); * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana)); - * console.log('bananas\'s prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype); + * console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype); * console.log(banana.sugar); * console.log(banana.eat().sugar); * console.log(banana.color); @@ -931,7 +1023,7 @@ * var banana = new Banana(20, 40); * console.log('banana instanceof Fruit', banana instanceof Fruit); * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana)); - * console.log('bananas\'s prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype); + * console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype); * console.log(banana.sugar); * console.log(banana.eat().sugar); * console.log(banana.color); @@ -982,7 +1074,8 @@ cloneDefinitions: cloneDefinitions }; - }(window, document, Chartist));;/** + }(window, document, Chartist)); + ;/** * Base for all chart types. The methods in Chartist.Base are inherited to all chart types. * * @module Chartist.Base @@ -1012,7 +1105,7 @@ * @memberof Chartist.Base */ function detach() { - window.removeEventListener('resize', this.update); + window.removeEventListener('resize', this.resizeListener); this.optionsProvider.removeMediaQueryListeners(); } @@ -1054,8 +1147,21 @@ this.responsiveOptions = responsiveOptions; this.eventEmitter = Chartist.EventEmitter(); this.supportsForeignObject = Chartist.Svg.isSupported('Extensibility'); + this.supportsAnimations = Chartist.Svg.isSupported('AnimationEventsAttribute'); + this.resizeListener = function resizeListener(){ + this.update(); + }.bind(this); + + if(this.container) { + // If chartist was already initialized in this container we are detaching all event listeners first + if(this.container.__chartist__) { + this.container.__chartist__.detach(); + } + + this.container.__chartist__ = this; + } - window.addEventListener('resize', this.update.bind(this)); + window.addEventListener('resize', this.resizeListener); // Using event loop for first draw to make it possible to register event listeners in the same call stack where // the chart was created. @@ -1086,7 +1192,8 @@ supportsForeignObject: false }); - }(window, document, Chartist));;/** + }(window, document, Chartist)); + ;/** * Chartist SVG module for simple SVG DOM abstraction * * @module Chartist.Svg @@ -1095,6 +1202,10 @@ (function(window, document, Chartist) { 'use strict'; + var svgNs = 'http://www.w3.org/2000/svg', + xmlNs = 'http://www.w3.org/2000/xmlns/', + xhtmlNs = 'http://www.w3.org/1999/xhtml'; + Chartist.xmlNs = { qualifiedName: 'xmlns:ct', prefix: 'ct', @@ -1112,301 +1223,395 @@ * @param {Boolean} insertFirst If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data */ - Chartist.Svg = function(name, attributes, className, parent, insertFirst) { - - var svgNs = 'http://www.w3.org/2000/svg', - xmlNs = 'http://www.w3.org/2000/xmlns/', - xhtmlNs = 'http://www.w3.org/1999/xhtml'; + function Svg(name, attributes, className, parent, insertFirst) { + this._node = document.createElementNS(svgNs, name); - /** - * Set attributes on the current SVG element of the wrapper you're currently working on. - * - * @memberof Chartist.Svg - * @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added. - * @param {String} ns If specified, the attributes will be set as namespace attributes with ns as prefix. - * @returns {Object} The current wrapper object will be returned so it can be used for chaining. - */ - function attr(node, attributes, ns) { - Object.keys(attributes).forEach(function(key) { - // If the attribute value is undefined we can skip this one - if(attributes[key] === undefined) { - return; - } - - if(ns) { - node.setAttributeNS(ns, [Chartist.xmlNs.prefix, ':', key].join(''), attributes[key]); - } else { - node.setAttribute(key, attributes[key]); - } - }); + // If this is an SVG element created then custom namespace + if(name === 'svg') { + this._node.setAttributeNS(xmlNs, Chartist.xmlNs.qualifiedName, Chartist.xmlNs.uri); + } - return node; + if(attributes) { + this.attr(attributes); } - /** - * Create a new SVG element whose wrapper object will be selected for further operations. This way you can also create nested groups easily. - * - * @memberof Chartist.Svg - * @param {String} name The name of the SVG element that should be created as child element of the currently selected element wrapper - * @param {Object} [attributes] An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added. - * @param {String} [className] This class or class list will be added to the SVG element - * @param {Boolean} [insertFirst] If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element - * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data - */ - function elem(name, attributes, className, parentNode, insertFirst) { - var node = document.createElementNS(svgNs, name); + if(className) { + this.addClass(className); + } - // If this is an SVG element created then custom namespace - if(name === 'svg') { - node.setAttributeNS(xmlNs, Chartist.xmlNs.qualifiedName, Chartist.xmlNs.uri); + if(parent) { + if (insertFirst && parent._node.firstChild) { + parent._node.insertBefore(this._node, parent._node.firstChild); + } else { + parent._node.appendChild(this._node); } - if(parentNode) { - if(insertFirst && parentNode.firstChild) { - parentNode.insertBefore(node, parentNode.firstChild); - } else { - parentNode.appendChild(node); - } - } + this._parent = parent; + } + } - if(attributes) { - attr(node, attributes); + /** + * Set attributes on the current SVG element of the wrapper you're currently working on. + * + * @memberof Chartist.Svg + * @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added. + * @param {String} ns If specified, the attributes will be set as namespace attributes with ns as prefix. + * @returns {Object} The current wrapper object will be returned so it can be used for chaining. + */ + function attr(attributes, ns) { + Object.keys(attributes).forEach(function(key) { + // If the attribute value is undefined we can skip this one + if(attributes[key] === undefined) { + return; } - if(className) { - addClass(node, className); + if(ns) { + this._node.setAttributeNS(ns, [Chartist.xmlNs.prefix, ':', key].join(''), attributes[key]); + } else { + this._node.setAttribute(key, attributes[key]); } + }.bind(this)); + + return this; + } + + /** + * Create a new SVG element whose wrapper object will be selected for further operations. This way you can also create nested groups easily. + * + * @memberof Chartist.Svg + * @param {String} name The name of the SVG element that should be created as child element of the currently selected element wrapper + * @param {Object} [attributes] An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added. + * @param {String} [className] This class or class list will be added to the SVG element + * @param {Boolean} [insertFirst] If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element + * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data + */ + function elem(name, attributes, className, insertFirst) { + return new Chartist.Svg(name, attributes, className, this, insertFirst); + } - return node; + /** + * This method creates a foreignObject (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject) that allows to embed HTML content into a SVG graphic. With the help of foreignObjects you can enable the usage of regular HTML elements inside of SVG where they are subject for SVG positioning and transformation but the Browser will use the HTML rendering capabilities for the containing DOM. + * + * @memberof Chartist.Svg + * @param {Node|String} content The DOM Node, or HTML string that will be converted to a DOM Node, that is then placed into and wrapped by the foreignObject + * @param {String} [attributes] An object with properties that will be added as attributes to the foreignObject element that is created. Attributes with undefined values will not be added. + * @param {String} [className] This class or class list will be added to the SVG element + * @param {Boolean} [insertFirst] Specifies if the foreignObject should be inserted as first child + * @returns {Object} New wrapper object that wraps the foreignObject element + */ + function foreignObject(content, attributes, className, insertFirst) { + // If content is string then we convert it to DOM + // TODO: Handle case where content is not a string nor a DOM Node + if(typeof content === 'string') { + var container = document.createElement('div'); + container.innerHTML = content; + content = container.firstChild; } - /** - * This method creates a foreignObject (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject) that allows to embed HTML content into a SVG graphic. With the help of foreignObjects you can enable the usage of regular HTML elements inside of SVG where they are subject for SVG positioning and transformation but the Browser will use the HTML rendering capabilities for the containing DOM. - * - * @memberof Chartist.Svg - * @param {Node|String} content The DOM Node, or HTML string that will be converted to a DOM Node, that is then placed into and wrapped by the foreignObject - * @param {String} [attributes] An object with properties that will be added as attributes to the foreignObject element that is created. Attributes with undefined values will not be added. - * @param {String} [className] This class or class list will be added to the SVG element - * @param {Boolean} [insertFirst] Specifies if the foreignObject should be inserted as first child - * @returns {Object} New wrapper object that wraps the foreignObject element - */ - function foreignObject(content, attributes, className, parent, insertFirst) { - // If content is string then we convert it to DOM - // TODO: Handle case where content is not a string nor a DOM Node - if(typeof content === 'string') { - var container = document.createElement('div'); - container.innerHTML = content; - content = container.firstChild; - } + // Adding namespace to content element + content.setAttribute('xmlns', xhtmlNs); - // Adding namespace to content element - content.setAttribute('xmlns', xhtmlNs); + // Creating the foreignObject without required extension attribute (as described here + // http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement) + var fnObj = this.elem('foreignObject', attributes, className, insertFirst); - // Creating the foreignObject without required extension attribute (as described here - // http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement) - var fnObj = parent.elem('foreignObject', attributes, className, insertFirst); + // Add content to foreignObjectElement + fnObj._node.appendChild(content); - // Add content to foreignObjectElement - fnObj._node.appendChild(content); + return fnObj; + } - return fnObj; - } + /** + * This method adds a new text element to the current Chartist.Svg wrapper. + * + * @memberof Chartist.Svg + * @param {String} t The text that should be added to the text element that is created + * @returns {Object} The same wrapper object that was used to add the newly created element + */ + function text(t) { + this._node.appendChild(document.createTextNode(t)); + return this; + } - /** - * This method adds a new text element to the current Chartist.Svg wrapper. - * - * @memberof Chartist.Svg - * @param {String} t The text that should be added to the text element that is created - * @returns {Object} The same wrapper object that was used to add the newly created element - */ - function text(node, t) { - node.appendChild(document.createTextNode(t)); + /** + * This method will clear all child nodes of the current wrapper object. + * + * @memberof Chartist.Svg + * @returns {Object} The same wrapper object that got emptied + */ + function empty() { + while (this._node.firstChild) { + this._node.removeChild(this._node.firstChild); } - /** - * This method will clear all child nodes of the current wrapper object. - * - * @memberof Chartist.Svg - * @returns {Object} The same wrapper object that got emptied - */ - function empty(node) { - while (node.firstChild) { - node.removeChild(node.firstChild); - } - } + return this; + } - /** - * This method will cause the current wrapper to remove itself from its parent wrapper. Use this method if you'd like to get rid of an element in a given DOM structure. - * - * @memberof Chartist.Svg - * @returns {Object} The parent wrapper object of the element that got removed - */ - function remove(node) { - node.parentNode.removeChild(node); - } + /** + * This method will cause the current wrapper to remove itself from its parent wrapper. Use this method if you'd like to get rid of an element in a given DOM structure. + * + * @memberof Chartist.Svg + * @returns {Object} The parent wrapper object of the element that got removed + */ + function remove() { + this._node.parentNode.removeChild(this._node); + return this._parent; + } - /** - * This method will replace the element with a new element that can be created outside of the current DOM. - * - * @memberof Chartist.Svg - * @param {Object} newElement The new wrapper object that will be used to replace the current wrapper object - * @returns {Object} The wrapper of the new element - */ - function replace(node, newChild) { - node.parentNode.replaceChild(newChild, node); - } + /** + * This method will replace the element with a new element that can be created outside of the current DOM. + * + * @memberof Chartist.Svg + * @param {Object} newElement The new Chartist.Svg object that will be used to replace the current wrapper object + * @returns {Object} The wrapper of the new element + */ + function replace(newElement) { + this._node.parentNode.replaceChild(newElement._node, this._node); + newElement._parent = this._parent; + this._parent = null; + return newElement; + } - /** - * This method will append an element to the current element as a child. - * - * @memberof Chartist.Svg - * @param {Object} element The element that should be added as a child - * @param {Boolean} [insertFirst] Specifies if the element should be inserted as first child - * @returns {Object} The wrapper of the appended object - */ - function append(node, child, insertFirst) { - if(insertFirst && node.firstChild) { - node.insertBefore(child, node.firstChild); - } else { - node.appendChild(child); - } + /** + * This method will append an element to the current element as a child. + * + * @memberof Chartist.Svg + * @param {Object} element The Chartist.Svg element that should be added as a child + * @param {Boolean} [insertFirst] Specifies if the element should be inserted as first child + * @returns {Object} The wrapper of the appended object + */ + function append(element, insertFirst) { + if(insertFirst && this._node.firstChild) { + this._node.insertBefore(element._node, this._node.firstChild); + } else { + this._node.appendChild(element._node); } - /** - * Returns an array of class names that are attached to the current wrapper element. This method can not be chained further. - * - * @memberof Chartist.Svg - * @returns {Array} A list of classes or an empty array if there are no classes on the current element - */ - function classes(node) { - return node.getAttribute('class') ? node.getAttribute('class').trim().split(/\s+/) : []; - } + return this; + } - /** - * Adds one or a space separated list of classes to the current element and ensures the classes are only existing once. - * - * @memberof Chartist.Svg - * @param {String} names A white space separated list of class names - * @returns {Object} The wrapper of the current element - */ - function addClass(node, names) { - node.setAttribute('class', - classes(node) - .concat(names.trim().split(/\s+/)) - .filter(function(elem, pos, self) { - return self.indexOf(elem) === pos; - }).join(' ') - ); - } + /** + * Returns an array of class names that are attached to the current wrapper element. This method can not be chained further. + * + * @memberof Chartist.Svg + * @returns {Array} A list of classes or an empty array if there are no classes on the current element + */ + function classes() { + return this._node.getAttribute('class') ? this._node.getAttribute('class').trim().split(/\s+/) : []; + } - /** - * Removes one or a space separated list of classes from the current element. - * - * @memberof Chartist.Svg - * @param {String} names A white space separated list of class names - * @returns {Object} The wrapper of the current element - */ - function removeClass(node, names) { - var removedClasses = names.trim().split(/\s+/); + /** + * Adds one or a space separated list of classes to the current element and ensures the classes are only existing once. + * + * @memberof Chartist.Svg + * @param {String} names A white space separated list of class names + * @returns {Object} The wrapper of the current element + */ + function addClass(names) { + this._node.setAttribute('class', + this.classes(this._node) + .concat(names.trim().split(/\s+/)) + .filter(function(elem, pos, self) { + return self.indexOf(elem) === pos; + }).join(' ') + ); + + return this; + } - node.setAttribute('class', classes(node).filter(function(name) { - return removedClasses.indexOf(name) === -1; - }).join(' ')); - } + /** + * Removes one or a space separated list of classes from the current element. + * + * @memberof Chartist.Svg + * @param {String} names A white space separated list of class names + * @returns {Object} The wrapper of the current element + */ + function removeClass(names) { + var removedClasses = names.trim().split(/\s+/); - /** - * Removes all classes from the current element. - * - * @memberof Chartist.Svg - * @returns {Object} The wrapper of the current element - */ - function removeAllClasses(node) { - node.setAttribute('class', ''); - } + this._node.setAttribute('class', this.classes(this._node).filter(function(name) { + return removedClasses.indexOf(name) === -1; + }).join(' ')); - /** - * Get element height with fallback to svg BoundingBox or parent container dimensions: - * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985) - * - * @memberof Chartist.Svg - * @return {Number} The elements height in pixels - */ - function height(node) { - return node.clientHeight || Math.round(node.getBBox().height) || node.parentNode.clientHeight; - } + return this; + } - /** - * Get element width with fallback to svg BoundingBox or parent container dimensions: - * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985) - * - * @memberof Chartist.Core - * @return {Number} The elements width in pixels - */ - function width(node) { - return node.clientWidth || Math.round(node.getBBox().width) || node.parentNode.clientWidth; + /** + * Removes all classes from the current element. + * + * @memberof Chartist.Svg + * @returns {Object} The wrapper of the current element + */ + function removeAllClasses() { + this._node.setAttribute('class', ''); + } + + /** + * Get element height with fallback to svg BoundingBox or parent container dimensions: + * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985) + * + * @memberof Chartist.Svg + * @return {Number} The elements height in pixels + */ + function height() { + return this._node.clientHeight || Math.round(this._node.getBBox().height) || this._node.parentNode.clientHeight; + } + + /** + * Get element width with fallback to svg BoundingBox or parent container dimensions: + * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985) + * + * @memberof Chartist.Core + * @return {Number} The elements width in pixels + */ + function width() { + return this._node.clientWidth || Math.round(this._node.getBBox().width) || this._node.parentNode.clientWidth; + } + + /** + * The animate function lets you animate the current element with SMIL animations. You can add animations for multiple attributes at the same time by using an animation definition object. This object should contain SMIL animation attributes. Please refer to http://www.w3.org/TR/SVG/animate.html for a detailed specification about the available animation attributes. Additionally an easing property can be passed in the animation definition object. This can be a string with a name of an easing function in `Chartist.Svg.Easing` or an array with four values specifying a cubic Bézier curve. + * **An animations object could look like this:** + * ```javascript + * element.animate({ + * opacity: { + * dur: 1000, + * from: 0, + * to: 1 + * }, + * x1: { + * dur: '1000ms', + * from: 100, + * to: 200, + * easing: 'easeOutQuart' + * }, + * y1: { + * dur: '2s', + * from: 0, + * to: 100 + * } + * }); + * ``` + * **Automatic unit conversion** + * For the `dur` and the `begin` animate attribute you can also omit a unit by passing a number. The number will automatically be converted to milli seconds. + * **Guided mode** + * The default behavior of SMIL animations with offset using the `begin` attribute, is that the attribute will keep it's original value until the animation starts. Mostly this behavior is not desired as you'd like to have your element attributes already initialized with the animation `from` value even before the animation starts. Also if you don't specify `fill="freeze"` on an animate element or if you delete the animation after it's done (which is done in guided mode) the attribute will switch back to the initial value. This behavior is also not desired when performing simple one-time animations. If you're using multiple SMIL definition objects for an attribute (in an array), guided mode will be disabled for this attribute, even if you explicitly enabled it. + * If guided mode is enabled the following behavior is added: + * - Before the animation starts (even when delayed with `begin`) the animated attribute will be set already to the `from` value of the animation + * - The animate element will be forced to use `fill="freeze"` + * - After the animation the element attribute value will be set to the `to` value of the animation + * - The animate element is deleted from the DOM + * + * @memberof Chartist.Svg + * @param {Object} animations An animations object where the property keys are the attributes you'd like to animate. The properties should be objects again that contain the SMIL animation attributes (usually begin, dur, from, and to). The property begin and dur is auto converted (see Automatic unit conversion). You can also schedule multiple animations for the same attribute by passing an Array of SMIL definition objects. Attributes that contain an array of SMIL definition objects will not be executed in guided mode. + * @param {Boolean} guided Specify if guided mode should be activated for this animation (see Guided mode). If not otherwise specified, guided mode will be activated. + * @param {Object} eventEmitter If specified, this event emitter will be notified when an animation starts or ends. + * @returns {Object} The current element where the animation was added + */ + function animate(animations, guided, eventEmitter) { + if(guided === undefined) { + guided = true; } - return { - _node: elem(name, attributes, className, parent ? parent._node : undefined, insertFirst), - _parent: parent, - parent: function() { - return this._parent; - }, - attr: function(attributes, ns) { - attr(this._node, attributes, ns); - return this; - }, - empty: function() { - empty(this._node); - return this; - }, - remove: function() { - remove(this._node); - return this.parent(); - }, - replace: function(newElement) { - newElement._parent = this._parent; - replace(this._node, newElement._node); - return newElement; - }, - append: function(element, insertFirst) { - element._parent = this; - append(this._node, element._node, insertFirst); - return element; - }, - elem: function(name, attributes, className, insertFirst) { - return Chartist.Svg(name, attributes, className, this, insertFirst); - }, - foreignObject: function(content, attributes, className, insertFirst) { - return foreignObject(content, attributes, className, this, insertFirst); - }, - text: function(t) { - text(this._node, t); - return this; - }, - addClass: function(names) { - addClass(this._node, names); - return this; - }, - removeClass: function(names) { - removeClass(this._node, names); - return this; - }, - removeAllClasses: function() { - removeAllClasses(this._node); - return this; - }, - classes: function() { - return classes(this._node); - }, - height: function() { - return height(this._node); - }, - width: function() { - return width(this._node); + Object.keys(animations).forEach(function createAnimateForAttributes(attribute) { + + function createAnimate(animationDefinition, guided) { + var attributeProperties = {}, + animate, + easing; + + // Check if an easing is specified in the definition object and delete it from the object as it will not + // be part of the animate element attributes. + if(animationDefinition.easing) { + // If already an easing Bézier curve array we take it or we lookup a easing array in the Easing object + easing = animationDefinition.easing instanceof Array ? + animationDefinition.easing : + Chartist.Svg.Easing[animationDefinition.easing]; + delete animationDefinition.easing; + } + + // Adding "fill: freeze" if we are in guided mode and set initial attribute values + if(guided) { + animationDefinition.fill = 'freeze'; + // Animated property on our element should already be set to the animation from value in guided mode + attributeProperties[attribute] = animationDefinition.from; + this.attr(attributeProperties); + } + + if(easing) { + animationDefinition.calcMode = 'spline'; + animationDefinition.keySplines = easing.join(' '); + animationDefinition.keyTimes = '0;1'; + } + + // If numeric dur or begin was provided we assume milli seconds + animationDefinition.begin = Chartist.ensureUnit(animationDefinition.begin, 'ms'); + animationDefinition.dur = Chartist.ensureUnit(animationDefinition.dur, 'ms'); + + animate = this.elem('animate', Chartist.extend({ + attributeName: attribute + }, animationDefinition)); + + if(eventEmitter) { + animate._node.addEventListener('beginEvent', function handleBeginEvent() { + eventEmitter.emit('animationBegin', { + element: this, + animate: animate._node, + params: animationDefinition + }); + }.bind(this)); + } + + animate._node.addEventListener('endEvent', function handleEndEvent() { + if(eventEmitter) { + eventEmitter.emit('animationEnd', { + element: this, + animate: animate._node, + params: animationDefinition + }); + } + + if(guided) { + // Set animated attribute to current animated value + attributeProperties[attribute] = animationDefinition.to; + this.attr(attributeProperties); + // Remove the animate element as it's no longer required + animate.remove(); + } + }.bind(this)); + } + + // If current attribute is an array of definition objects we create an animate for each and disable guided mode + if(animations[attribute] instanceof Array) { + animations[attribute].forEach(function(animationDefinition) { + createAnimate.bind(this)(animationDefinition, false); + }.bind(this)); + } else { + createAnimate.bind(this)(animations[attribute], guided); } - }; - }; + + }.bind(this)); + + return this; + } + + Chartist.Svg = Chartist.Class.extend({ + constructor: Svg, + attr: attr, + elem: elem, + foreignObject: foreignObject, + text: text, + empty: empty, + remove: remove, + replace: replace, + append: append, + classes: classes, + addClass: addClass, + removeClass: removeClass, + removeAllClasses: removeAllClasses, + height: height, + width: width, + animate: animate + }); /** * This method checks for support of a given SVG feature like Extensibility, SVG-animation or the like. Check http://www.w3.org/TR/SVG11/feature for a detailed list. @@ -1419,7 +1624,42 @@ return document.implementation.hasFeature('www.http://w3.org/TR/SVG11/feature#' + feature, '1.1'); }; - }(window, document, Chartist));;/** + /** + * This Object contains some standard easing cubic bezier curves. Then can be used with their name in the `Chartist.Svg.animate`. You can also extend the list and use your own name in the `animate` function. Click the show code button to see the available bezier functions. + * + * @memberof Chartist.Svg + */ + var easingCubicBeziers = { + easeInSine: [0.47, 0, 0.745, 0.715], + easeOutSine: [0.39, 0.575, 0.565, 1], + easeInOutSine: [0.445, 0.05, 0.55, 0.95], + easeInQuad: [0.55, 0.085, 0.68, 0.53], + easeOutQuad: [0.25, 0.46, 0.45, 0.94], + easeInOutQuad: [0.455, 0.03, 0.515, 0.955], + easeInCubic: [0.55, 0.055, 0.675, 0.19], + easeOutCubic: [0.215, 0.61, 0.355, 1], + easeInOutCubic: [0.645, 0.045, 0.355, 1], + easeInQuart: [0.895, 0.03, 0.685, 0.22], + easeOutQuart: [0.165, 0.84, 0.44, 1], + easeInOutQuart: [0.77, 0, 0.175, 1], + easeInQuint: [0.755, 0.05, 0.855, 0.06], + easeOutQuint: [0.23, 1, 0.32, 1], + easeInOutQuint: [0.86, 0, 0.07, 1], + easeInExpo: [0.95, 0.05, 0.795, 0.035], + easeOutExpo: [0.19, 1, 0.22, 1], + easeInOutExpo: [1, 0, 0, 1], + easeInCirc: [0.6, 0.04, 0.98, 0.335], + easeOutCirc: [0.075, 0.82, 0.165, 1], + easeInOutCirc: [0.785, 0.135, 0.15, 0.86], + easeInBack: [0.6, -0.28, 0.735, 0.045], + easeOutBack: [0.175, 0.885, 0.32, 1.275], + easeInOutBack: [0.68, -0.55, 0.265, 1.55] + }; + + Chartist.Svg.Easing = easingCubicBeziers; + + }(window, document, Chartist)); + ;/** * The Chartist line chart can be used to draw Line or Scatter charts. If used in the browser you can access the global `Chartist` namespace where you find the `Line` function as a main entry point. * * For examples on how to use the line chart please check the examples of the `Chartist.Line` method. @@ -1450,7 +1690,7 @@ showLabel: true, showGrid: true, labelInterpolationFnc: Chartist.noop, - scaleMinSpace: 30 + scaleMinSpace: 20 }, width: undefined, height: undefined, @@ -1565,7 +1805,7 @@ if(options.showArea) { // If areaBase is outside the chart area (< low or > high) we need to set it respectively so that // the area is not drawn outside the chart area. - var areaBase = Math.max(Math.min(options.areaBase, bounds.high), bounds.low); + var areaBase = Math.max(Math.min(options.areaBase, bounds.max), bounds.min); // If we need to draw area shapes we just make a copy of our pathElements SVG path array var areaPathElements = pathElements.slice(); @@ -1578,22 +1818,45 @@ areaPathElements.push('L' + pathCoordinates[pathCoordinates.length - 2] + ',' + areaBaseProjected.y); // Create the new path for the area shape with the area class from the options - seriesGroups[i].elem('path', { + var area = seriesGroups[i].elem('path', { d: areaPathElements.join('') }, options.classNames.area, true).attr({ 'values': normalizedData[i] }, Chartist.xmlNs.uri); + + this.eventEmitter.emit('draw', { + type: 'area', + values: normalizedData[i], + index: i, + group: seriesGroups[i], + element: area + }); } if(options.showLine) { - seriesGroups[i].elem('path', { + var line = seriesGroups[i].elem('path', { d: pathElements.join('') }, options.classNames.line, true).attr({ 'values': normalizedData[i] }, Chartist.xmlNs.uri); + + this.eventEmitter.emit('draw', { + type: 'line', + values: normalizedData[i], + index: i, + group: seriesGroups[i], + element: line + }); } } } + + this.eventEmitter.emit('created', { + bounds: bounds, + chartRect: chartRect, + svg: this.svg, + options: options + }); } /** @@ -1778,7 +2041,7 @@ showLabel: true, showGrid: true, labelInterpolationFnc: Chartist.noop, - scaleMinSpace: 30 + scaleMinSpace: 20 }, width: undefined, height: undefined, @@ -1871,6 +2134,13 @@ }); } } + + this.eventEmitter.emit('created', { + bounds: bounds, + chartRect: chartRect, + svg: this.svg, + options: options + }); } /** @@ -2173,6 +2443,12 @@ // (except for last slice) startAngle = endAngle; } + + this.eventEmitter.emit('created', { + chartRect: chartRect, + svg: this.svg, + options: options + }); } /** diff --git a/libdist/chartist.min.css b/libdist/chartist.min.css index dd341785..b19d6893 100644 --- a/libdist/chartist.min.css +++ b/libdist/chartist.min.css @@ -1,4 +1,4 @@ -/* Chartist.js 0.3.1 +/* Chartist.js 0.4.0 * Copyright © 2014 Gion Kunz * Free to use under the WTFPL license. * http://www.wtfpl.net/ diff --git a/libdist/chartist.min.js b/libdist/chartist.min.js index 0167b46f..2c4c9b55 100644 --- a/libdist/chartist.min.js +++ b/libdist/chartist.min.js @@ -1,8 +1,8 @@ -/* Chartist.js 0.3.1 +/* Chartist.js 0.4.0 * Copyright © 2014 Gion Kunz * Free to use under the WTFPL license. * http://www.wtfpl.net/ */ -!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define([],b):a.Chartist=b()}(this,function(){var a={};return a.version="0.3.1",function(a,b,c){"use strict";c.noop=function(a){return a},c.alphaNumerate=function(a){return String.fromCharCode(97+a%26)},c.extend=function(a,b){a=a||{};for(var d in b)a[d]="object"==typeof b[d]?c.extend(a[d],b[d]):b[d];return a},c.getPixelLength=function(a){return"string"==typeof a&&(a=a.replace(/px/i,"")),+a},c.querySelector=function(a){return a instanceof Node?a:b.querySelector(a)},c.createSvg=function(a,b,d,e){var f;return b=b||"100%",d=d||"100%",void 0!==a.chartistSvg?(f=a.chartistSvg.attr({width:b,height:d}).removeAllClasses().addClass(e).attr({style:"width: "+b+"; height: "+d+";"}),f.empty()):(f=c.Svg("svg").attr({width:b,height:d}).addClass(e).attr({style:"width: "+b+"; height: "+d+";"}),a.appendChild(f._node),a.chartistSvg=f),f},c.getDataArray=function(a){for(var b=[],c=0;cd;d++)a[c][d]=0;return a},c.orderOfMagnitude=function(a){return Math.floor(Math.log(Math.abs(a))/Math.LN10)},c.projectLength=function(a,b,d,e){var f=c.getAvailableHeight(a,e);return b/d.range*f},c.getAvailableHeight=function(a,b){return Math.max((c.getPixelLength(b.height)||a.height())-2*b.chartPadding-b.axisX.offset,0)},c.getHighLow=function(a){var b,c,d={high:-Number.MAX_VALUE,low:Number.MAX_VALUE};for(b=0;bd.high&&(d.high=a[b][c]),a[b][c]=d.axisY.scaleMinSpace))break;i.step/=2}for(g=i.min,h=i.max,f=i.min;f<=i.max;f+=i.step)f+i.stepi.high&&(h-=i.step);for(i.min=g,i.max=h,i.range=i.max-i.min,i.values=[],f=i.min;f<=i.max;f+=i.step)i.values.push(f);return i},c.polarToCartesian=function(a,b,c,d){var e=(d-90)*Math.PI/180;return{x:a+c*Math.cos(e),y:b+c*Math.sin(e)}},c.createChartRect=function(a,b){var d=b.axisY?b.axisY.offset:0,e=b.axisX?b.axisX.offset:0;return{x1:b.chartPadding+d,y1:Math.max((c.getPixelLength(b.height)||a.height())-b.chartPadding-e,b.chartPadding),x2:Math.max((c.getPixelLength(b.width)||a.width())-b.chartPadding,b.chartPadding+d),y2:b.chartPadding,width:function(){return this.x2-this.x1},height:function(){return this.y1-this.y2}}},c.createLabel=function(a,b,c,d,e){if(e){var f=''+b+"";return a.foreignObject(f,c)}return a.elem("text",c,d).text(b)},c.createXAxis=function(b,d,e,f,g,h,i){d.labels.forEach(function(j,k){var l=g.axisX.labelInterpolationFnc(j,k),m=b.width()/d.labels.length,n=g.axisX.offset,o=b.x1+m*k;if(l||0===l){if(g.axisX.showGrid){var p=e.elem("line",{x1:o,y1:b.y1,x2:o,y2:b.y2},[g.classNames.grid,g.classNames.horizontal].join(" "));h.emit("draw",{type:"grid",axis:"x",index:k,group:e,element:p,x1:o,y1:b.y1,x2:o,y2:b.y2})}if(g.axisX.showLabel){var q={x:o+g.axisX.labelOffset.x,y:b.y1+g.axisX.labelOffset.y+(i?5:20)},r=c.createLabel(f,""+l,{x:q.x,y:q.y,width:m,height:n,style:"overflow: visible;"},[g.classNames.label,g.classNames.horizontal].join(" "),i);h.emit("draw",{type:"label",axis:"x",index:k,group:f,element:r,text:""+l,x:q.x,y:q.y,width:m,height:n,get space(){return a.console.warn("EventEmitter: space is deprecated, use width or height instead."),this.width}})}}})},c.createYAxis=function(b,d,e,f,g,h,i){d.values.forEach(function(j,k){var l=g.axisY.labelInterpolationFnc(j,k),m=g.axisY.offset,n=b.height()/d.values.length,o=b.y1-n*k;if(l||0===l){if(g.axisY.showGrid){var p=e.elem("line",{x1:b.x1,y1:o,x2:b.x2,y2:o},[g.classNames.grid,g.classNames.vertical].join(" "));h.emit("draw",{type:"grid",axis:"y",index:k,group:e,element:p,x1:b.x1,y1:o,x2:b.x2,y2:o})}if(g.axisY.showLabel){var q={x:g.chartPadding+g.axisY.labelOffset.x+(i?-10:0),y:o+g.axisY.labelOffset.y+(i?-15:0)},r=c.createLabel(f,""+l,{x:q.x,y:q.y,width:m,height:n,style:"overflow: visible;"},[g.classNames.label,g.classNames.vertical].join(" "),i);h.emit("draw",{type:"label",axis:"y",index:k,group:f,element:r,text:""+l,x:q.x,y:q.y,width:m,height:n,get space(){return a.console.warn("EventEmitter: space is deprecated, use width or height instead."),this.height}})}}})},c.projectPoint=function(a,b,c,d){return{x:a.x1+a.width()/c.length*d,y:a.y1-a.height()*(c[d]-b.min)/(b.range+b.step)}},c.optionsProvider=function(b,d,e,f){function g(){var b=i;if(i=c.extend({},k),e)for(j=0;jd;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4===d?f[3]={x:+a[0],y:+a[1]}:e-2===d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4===d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push([(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}}(window,document,a),function(a,b,c){"use strict";c.EventEmitter=function(){function a(a,b){d[a]=d[a]||[],d[a].push(b)}function b(a,b){d[a]&&(b?(d[a].splice(d[a].indexOf(b),1),0===d[a].length&&delete d[a]):delete d[a])}function c(a,b){d[a]&&d[a].forEach(function(a){a(b)})}var d=[];return{addEventHandler:a,removeEventHandler:b,emit:c}}}(window,document,a),function(a,b,c){"use strict";function d(a){var b=[];if(a.length)for(var c=0;c4)for(var o=c.catmullRom2bezier(l),p=0;pa.x;return d&&"explode"===c||!d&&"implode"===c?"start":d&&"implode"===c||!d&&"explode"===c?"end":"middle"}function e(a){var b,e,f,g,h=[],i=a.startAngle,j=c.getDataArray(this.data);this.svg=c.createSvg(this.container,a.width,a.height,a.classNames.chart),b=c.createChartRect(this.svg,a,0,0),e=Math.min(b.width()/2,b.height()/2),g=a.total||j.reduce(function(a,b){return a+b},0),e-=a.donut?a.donutWidth/2:0,f=a.donut?e:e/2,f+=a.labelOffset;for(var k={x:b.x1+b.width()/2,y:b.y2+b.height()/2},l=1===this.data.series.filter(function(a){return 0!==a}).length,m=0;m=n-i?"0":"1",r=["M",p.x,p.y,"A",e,e,0,q,0,o.x,o.y];a.donut===!1&&r.push("L",k.x,k.y);var s=h[m].elem("path",{d:r.join(" ")},a.classNames.slice+(a.donut?" "+a.classNames.donut:""));if(s.attr({value:j[m]},c.xmlNs.uri),a.donut===!0&&s.attr({style:"stroke-width: "+ +a.donutWidth+"px"}),this.eventEmitter.emit("draw",{type:"slice",value:j[m],totalDataSum:g,index:m,group:h[m],element:s,center:k,radius:e,startAngle:i,endAngle:n}),a.showLabel){var t=c.polarToCartesian(k.x,k.y,f,i+(n-i)/2),u=a.labelInterpolationFnc(this.data.labels?this.data.labels[m]:j[m],m),v=h[m].elem("text",{dx:t.x,dy:t.y,"text-anchor":d(k,t,a.labelDirection)},a.classNames.label).text(""+u);this.eventEmitter.emit("draw",{type:"label",index:m,group:h[m],element:v,text:""+u,x:t.x,y:t.y})}i=n}}function f(a,b,d,e){c.Pie.super.constructor.call(this,a,b,c.extend(c.extend({},g),d),e)}var g={width:void 0,height:void 0,chartPadding:5,classNames:{chart:"ct-chart-pie",series:"ct-series",slice:"ct-slice",donut:"ct-donut",label:"ct-label"},startAngle:0,total:void 0,donut:!1,donutWidth:60,showLabel:!0,labelOffset:0,labelInterpolationFnc:c.noop,labelOverflow:!1,labelDirection:"neutral"};c.Pie=c.Base.extend({constructor:f,createChart:e,determineAnchorPosition:d})}(window,document,a),a}); +!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define([],b):a.Chartist=b()}(this,function(){var a={};return a.version="0.3.1",function(a,b,c){"use strict";c.noop=function(a){return a},c.alphaNumerate=function(a){return String.fromCharCode(97+a%26)},c.extend=function(a,b){a=a||{};for(var d in b)a[d]="object"==typeof b[d]?c.extend(a[d],b[d]):b[d];return a},c.stripUnit=function(a){return"string"==typeof a&&(a=a.replace(/[^0-9\+-\.]/,"")),+a},c.ensureUnit=function(a,b){return"number"==typeof a&&(a+=b),a},c.querySelector=function(a){return a instanceof Node?a:b.querySelector(a)},c.createSvg=function(a,b,d,e){var f;return b=b||"100%",d=d||"100%",f=a.querySelector("svg"),f&&a.removeChild(f),f=new c.Svg("svg").attr({width:b,height:d}).addClass(e).attr({style:"width: "+b+"; height: "+d+";"}),a.appendChild(f._node),f},c.getDataArray=function(a){for(var b=[],c=0;cd;d++)a[c][d]=0;return a},c.orderOfMagnitude=function(a){return Math.floor(Math.log(Math.abs(a))/Math.LN10)},c.projectLength=function(a,b,d,e){var f=c.getAvailableHeight(a,e);return b/d.range*f},c.getAvailableHeight=function(a,b){return Math.max((c.stripUnit(b.height)||a.height())-2*b.chartPadding-b.axisX.offset,0)},c.getHighLow=function(a){var b,c,d={high:-Number.MAX_VALUE,low:Number.MAX_VALUE};for(b=0;bd.high&&(d.high=a[b][c]),a[b][c]=d.axisY.scaleMinSpace))break;i.step/=2}for(g=i.min,h=i.max,f=i.min;f<=i.max;f+=i.step)f+i.step=i.high&&(h-=i.step);for(i.min=g,i.max=h,i.range=i.max-i.min,i.values=[],f=i.min;f<=i.max;f+=i.step)i.values.push(f);return i},c.polarToCartesian=function(a,b,c,d){var e=(d-90)*Math.PI/180;return{x:a+c*Math.cos(e),y:b+c*Math.sin(e)}},c.createChartRect=function(a,b){var d=b.axisY?b.axisY.offset:0,e=b.axisX?b.axisX.offset:0;return{x1:b.chartPadding+d,y1:Math.max((c.stripUnit(b.height)||a.height())-b.chartPadding-e,b.chartPadding),x2:Math.max((c.stripUnit(b.width)||a.width())-b.chartPadding,b.chartPadding+d),y2:b.chartPadding,width:function(){return this.x2-this.x1},height:function(){return this.y1-this.y2}}},c.createLabel=function(a,b,c,d,e){if(e){var f=''+b+"";return a.foreignObject(f,c)}return a.elem("text",c,d).text(b)},c.createXAxis=function(b,d,e,f,g,h,i){d.labels.forEach(function(j,k){var l=g.axisX.labelInterpolationFnc(j,k),m=b.width()/d.labels.length,n=g.axisX.offset,o=b.x1+m*k;if(l||0===l){if(g.axisX.showGrid){var p=e.elem("line",{x1:o,y1:b.y1,x2:o,y2:b.y2},[g.classNames.grid,g.classNames.horizontal].join(" "));h.emit("draw",{type:"grid",axis:"x",index:k,group:e,element:p,x1:o,y1:b.y1,x2:o,y2:b.y2})}if(g.axisX.showLabel){var q={x:o+g.axisX.labelOffset.x,y:b.y1+g.axisX.labelOffset.y+(i?5:20)},r=c.createLabel(f,""+l,{x:q.x,y:q.y,width:m,height:n,style:"overflow: visible;"},[g.classNames.label,g.classNames.horizontal].join(" "),i);h.emit("draw",{type:"label",axis:"x",index:k,group:f,element:r,text:""+l,x:q.x,y:q.y,width:m,height:n,get space(){return a.console.warn("EventEmitter: space is deprecated, use width or height instead."),this.width}})}}})},c.createYAxis=function(b,d,e,f,g,h,i){d.values.forEach(function(j,k){var l=g.axisY.labelInterpolationFnc(j,k),m=g.axisY.offset,n=b.height()/d.values.length,o=b.y1-n*k;if(l||0===l){if(g.axisY.showGrid){var p=e.elem("line",{x1:b.x1,y1:o,x2:b.x2,y2:o},[g.classNames.grid,g.classNames.vertical].join(" "));h.emit("draw",{type:"grid",axis:"y",index:k,group:e,element:p,x1:b.x1,y1:o,x2:b.x2,y2:o})}if(g.axisY.showLabel){var q={x:g.chartPadding+g.axisY.labelOffset.x+(i?-10:0),y:o+g.axisY.labelOffset.y+(i?-15:0)},r=c.createLabel(f,""+l,{x:q.x,y:q.y,width:m,height:n,style:"overflow: visible;"},[g.classNames.label,g.classNames.vertical].join(" "),i);h.emit("draw",{type:"label",axis:"y",index:k,group:f,element:r,text:""+l,x:q.x,y:q.y,width:m,height:n,get space(){return a.console.warn("EventEmitter: space is deprecated, use width or height instead."),this.height}})}}})},c.projectPoint=function(a,b,c,d){return{x:a.x1+a.width()/c.length*d,y:a.y1-a.height()*(c[d]-b.min)/(b.range+b.step)}},c.optionsProvider=function(b,d,e,f){function g(){var b=i;if(i=c.extend({},k),e)for(j=0;j0?e:null}var d={added:0,removed:0,modified:0},e=c(a,b);return e&&(e.__delta__.summary=d),e},c.catmullRom2bezier=function(a,b){for(var c=[],d=0,e=a.length;e-2*!b>d;d+=2){var f=[{x:+a[d-2],y:+a[d-1]},{x:+a[d],y:+a[d+1]},{x:+a[d+2],y:+a[d+3]},{x:+a[d+4],y:+a[d+5]}];b?d?e-4===d?f[3]={x:+a[0],y:+a[1]}:e-2===d&&(f[2]={x:+a[0],y:+a[1]},f[3]={x:+a[2],y:+a[3]}):f[0]={x:+a[e-2],y:+a[e-1]}:e-4===d?f[3]=f[2]:d||(f[0]={x:+a[d],y:+a[d+1]}),c.push([(-f[0].x+6*f[1].x+f[2].x)/6,(-f[0].y+6*f[1].y+f[2].y)/6,(f[1].x+6*f[2].x-f[3].x)/6,(f[1].y+6*f[2].y-f[3].y)/6,f[2].x,f[2].y])}return c}}(window,document,a),function(a,b,c){"use strict";c.EventEmitter=function(){function a(a,b){d[a]=d[a]||[],d[a].push(b)}function b(a,b){d[a]&&(b?(d[a].splice(d[a].indexOf(b),1),0===d[a].length&&delete d[a]):delete d[a])}function c(a,b){d[a]&&d[a].forEach(function(a){a(b)}),d["*"]&&d["*"].forEach(function(c){c(a,b)})}var d=[];return{addEventHandler:a,removeEventHandler:b,emit:c}}}(window,document,a),function(a,b,c){"use strict";function d(a){var b=[];if(a.length)for(var c=0;c4)for(var o=c.catmullRom2bezier(l),p=0;pa.x;return d&&"explode"===c||!d&&"implode"===c?"start":d&&"implode"===c||!d&&"explode"===c?"end":"middle"}function e(a){var b,e,f,g,h=[],i=a.startAngle,j=c.getDataArray(this.data);this.svg=c.createSvg(this.container,a.width,a.height,a.classNames.chart),b=c.createChartRect(this.svg,a,0,0),e=Math.min(b.width()/2,b.height()/2),g=a.total||j.reduce(function(a,b){return a+b},0),e-=a.donut?a.donutWidth/2:0,f=a.donut?e:e/2,f+=a.labelOffset;for(var k={x:b.x1+b.width()/2,y:b.y2+b.height()/2},l=1===this.data.series.filter(function(a){return 0!==a}).length,m=0;m=n-i?"0":"1",r=["M",p.x,p.y,"A",e,e,0,q,0,o.x,o.y];a.donut===!1&&r.push("L",k.x,k.y);var s=h[m].elem("path",{d:r.join(" ")},a.classNames.slice+(a.donut?" "+a.classNames.donut:""));if(s.attr({value:j[m]},c.xmlNs.uri),a.donut===!0&&s.attr({style:"stroke-width: "+ +a.donutWidth+"px"}),this.eventEmitter.emit("draw",{type:"slice",value:j[m],totalDataSum:g,index:m,group:h[m],element:s,center:k,radius:e,startAngle:i,endAngle:n}),a.showLabel){var t=c.polarToCartesian(k.x,k.y,f,i+(n-i)/2),u=a.labelInterpolationFnc(this.data.labels?this.data.labels[m]:j[m],m),v=h[m].elem("text",{dx:t.x,dy:t.y,"text-anchor":d(k,t,a.labelDirection)},a.classNames.label).text(""+u);this.eventEmitter.emit("draw",{type:"label",index:m,group:h[m],element:v,text:""+u,x:t.x,y:t.y})}i=n}this.eventEmitter.emit("created",{chartRect:b,svg:this.svg,options:a})}function f(a,b,d,e){c.Pie.super.constructor.call(this,a,b,c.extend(c.extend({},g),d),e)}var g={width:void 0,height:void 0,chartPadding:5,classNames:{chart:"ct-chart-pie",series:"ct-series",slice:"ct-slice",donut:"ct-donut",label:"ct-label"},startAngle:0,total:void 0,donut:!1,donutWidth:60,showLabel:!0,labelOffset:0,labelInterpolationFnc:c.noop,labelOverflow:!1,labelDirection:"neutral"};c.Pie=c.Base.extend({constructor:f,createChart:e,determineAnchorPosition:d})}(window,document,a),a}); //# sourceMappingURL=chartist.min.map \ No newline at end of file diff --git a/libdist/chartist.min.map b/libdist/chartist.min.map index 6fce0ca2..098ef2c8 100644 --- a/libdist/chartist.min.map +++ b/libdist/chartist.min.map @@ -1 +1 @@ -{"version":3,"file":"chartist.min.js","sources":["chartist.js"],"names":["root","factory","exports","module","define","amd","this","Chartist","version","window","document","noop","n","alphaNumerate","String","fromCharCode","extend","target","source","prop","getPixelLength","length","replace","querySelector","query","Node","createSvg","container","width","height","className","svg","undefined","chartistSvg","attr","removeAllClasses","addClass","style","empty","Svg","appendChild","_node","getDataArray","data","array","i","series","j","normalizeDataArray","dataArray","orderOfMagnitude","value","Math","floor","log","abs","LN10","projectLength","bounds","options","availableHeight","getAvailableHeight","range","max","chartPadding","axisX","offset","getHighLow","highLow","high","Number","MAX_VALUE","low","getBounds","normalizedData","referenceValue","newMin","newMax","min","valueRange","oom","pow","ceil","step","numberOfSteps","round","scaleUp","axisY","scaleMinSpace","values","push","polarToCartesian","centerX","centerY","radius","angleInDegrees","angleInRadians","PI","x","cos","y","sin","createChartRect","yOffset","xOffset","x1","y1","x2","y2","createLabel","parent","text","attributes","supportsForeignObject","content","foreignObject","elem","createXAxis","chartRect","grid","labels","eventEmitter","forEach","index","interpolatedValue","labelInterpolationFnc","pos","showGrid","gridElement","classNames","horizontal","join","emit","type","axis","group","element","showLabel","labelPosition","labelOffset","labelElement","label",{"end":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":18727,"pos":18722,"col":16,"line":485,"value":"space","type":"name"},"start":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":18727,"pos":18722,"col":16,"line":485,"value":"space","type":"name"},"name":"space"},"space","console","warn","createYAxis","vertical","projectPoint","optionsProvider","defaultOptions","responsiveOptions","updateCurrentOptions","previousOptions","currentOptions","baseOptions","mql","matchMedia","matches","removeMediaQueryListeners","mediaQueryListeners","removeListener","addListener","catmullRom2bezier","crp","z","d","iLen","p","EventEmitter","addEventHandler","event","handler","handlers","removeEventHandler","splice","indexOf","listToArray","list","arr","properties","superProtoOverride","superProto","prototype","Class","proto","Object","create","cloneDefinitions","constr","instance","fn","constructor","apply","Array","slice","call","arguments","super","mix","mixProtoArr","Error","superPrototypes","concat","map","Function","mixedSuperProto","args","getOwnPropertyNames","propName","defineProperty","getOwnPropertyDescriptor","update","createChart","detach","removeEventListener","on","off","Base","isSupported","addEventListener","bind","setTimeout","xmlNs","qualifiedName","prefix","uri","name","insertFirst","node","ns","keys","key","setAttributeNS","setAttribute","parentNode","createElementNS","svgNs","firstChild","insertBefore","createElement","innerHTML","xhtmlNs","fnObj","t","createTextNode","removeChild","remove","newChild","replaceChild","append","child","classes","getAttribute","trim","split","names","filter","self","removeClass","removedClasses","clientHeight","getBBox","clientWidth","_parent","newElement","feature","implementation","hasFeature","seriesGroups","chart","series-name","point","pathCoordinates","showPoint","showLine","showArea","pathElements","lineSmooth","cr","k","l","areaBase","areaPathElements","areaBaseProjected","area","line","Line","zeroPoint","biPol","periodHalfWidth","bar","seriesBarDistance","Bar","determineAnchorPosition","center","direction","toTheRight","labelRadius","totalDataSum","startAngle","total","reduce","previousValue","currentValue","donut","donutWidth","hasSingleValInSeries","val","endAngle","start","end","arcSweep","path","dx","dy","text-anchor","labelDirection","Pie","labelOverflow"],"mappings":";;;;;;CAAC,SAASA,EAAMC,GACU,gBAAZC,SACNC,OAAOD,QAAUD,IAEK,kBAAXG,SAAyBA,OAAOC,IAC3CD,UAAWH,GAGXD,EAAe,SAAIC,KAEzBK,KAAM,WAYN,GAAIC,KA6sEJ,OA5sEAA,GAASC,QAAU,QAElB,SAAUC,EAAQC,EAAUH,GAC3B,YASAA,GAASI,KA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AGvCtH,MAAKmH,aAAaW,KAAK,QACrBC,KAAM,QACNV,MAAO9E,EACP0F,MAAOsI,EAAahO,GACpB2F,QAASI,EACT7B,KAAM,GAAKa,EACX1B,EAAGwC,EAAcxC,EACjBE,EAAGsC,EAActC,IAMrBwM,EAAaS,GAoFjB,QAASS,GAAItS,EAAOmB,EAAMgB,EAAS4F,GACjChJ,EAASuT,IAAIxH,MAAMN,YAAYI,KAAK9L,KAClCkB,EACAmB,EACApC,EAASS,OAAOT,EAASS,UAAWsI,GAAiB3F,GACrD4F,GAzQJ,GAAID,IACF1H,MAAOI,OACPH,OAAQG,OACRgC,aAAc,EACdiE,YACE6I,MAAO,eACPhO,OAAQ,YACRqJ,MAAO,WACP8G,MAAO,WACPpK,MAAO,YAET+J,WAAY,EACZC,MAAO7Q,OACPiR,OAAO,EACPC,WAAY,GACZzK,WAAW,EACXE,YAAa,EACbd,sBAAuBtH,EAASI,KAChCoT,eAAe,EACfF,eAAgB,UA0PlBtT,GAASuT,IAAMvT,EAASmN,KAAK1M,QAC3BgL,YAAa8H,EACbzG,YAAaA,EACbiF,wBAAyBA,KAG3B7R,OAAQC,SAAUH,GAGbA","sourcesContent":["(function(root, factory) {\n if(typeof exports === 'object') {\n module.exports = factory();\n }\n else if(typeof define === 'function' && define.amd) {\n define([], factory);\n }\n else {\n root['Chartist'] = factory();\n }\n}(this, function() {\n\n /* Chartist.js 0.3.1\n * Copyright © 2014 Gion Kunz\n * Free to use under the WTFPL license.\n * http://www.wtfpl.net/\n */\n /**\n * The core module of Chartist that is mainly providing static functions and higher level functions for chart modules.\n *\n * @module Chartist.Core\n */\n var Chartist = {};\n Chartist.version = '0.3.1';\n\n (function (window, document, Chartist) {\n 'use strict';\n\n /**\n * Helps to simplify functional style code\n *\n * @memberof Chartist.Core\n * @param {*} n This exact value will be returned by the noop function\n * @return {*} The same value that was provided to the n parameter\n */\n Chartist.noop = function (n) {\n return n;\n };\n\n /**\n * Generates a-z from a number 0 to 26\n *\n * @memberof Chartist.Core\n * @param {Number} n A number from 0 to 26 that will result in a letter a-z\n * @return {String} A character from a-z based on the input number n\n */\n Chartist.alphaNumerate = function (n) {\n // Limit to a-z\n return String.fromCharCode(97 + n % 26);\n };\n\n // TODO: Make it possible to call extend with var args\n /**\n * Simple recursive object extend\n *\n * @memberof Chartist.Core\n * @param {Object} target Target object where the source will be merged into\n * @param {Object} source This object will be merged into target and then target is returned\n * @return {Object} An object that has the same reference as target but is extended and merged with the properties of source\n */\n Chartist.extend = function (target, source) {\n target = target || {};\n for (var prop in source) {\n if (typeof source[prop] === 'object') {\n target[prop] = Chartist.extend(target[prop], source[prop]);\n } else {\n target[prop] = source[prop];\n }\n }\n return target;\n };\n\n /**\n * Converts a string to a number while removing the unit px if present. If a number is passed then this will be returned unmodified.\n *\n * @param {String|Number} length\n * @returns {Number} Returns the pixel as number or NaN if the passed length could not be converted to pixel\n */\n Chartist.getPixelLength = function(length) {\n if(typeof length === 'string') {\n length = length.replace(/px/i, '');\n }\n\n return +length;\n };\n\n /**\n * This is a wrapper around document.querySelector that will return the query if it's already of type Node\n *\n * @memberof Chartist.Core\n * @param {String|Node} query The query to use for selecting a Node or a DOM node that will be returned directly\n * @return {Node}\n */\n Chartist.querySelector = function(query) {\n return query instanceof Node ? query : document.querySelector(query);\n };\n\n /**\n * Create or reinitialize the SVG element for the chart\n *\n * @memberof Chartist.Core\n * @param {Node} container The containing DOM Node object that will be used to plant the SVG element\n * @param {String} width Set the width of the SVG element. Default is 100%\n * @param {String} height Set the height of the SVG element. Default is 100%\n * @param {String} className Specify a class to be added to the SVG element\n * @return {Object} The created/reinitialized SVG element\n */\n Chartist.createSvg = function (container, width, height, className) {\n var svg;\n\n width = width || '100%';\n height = height || '100%';\n\n // If already contains our svg object we clear it, set width / height and return\n if (container.chartistSvg !== undefined) {\n svg = container.chartistSvg.attr({\n width: width,\n height: height\n }).removeAllClasses().addClass(className).attr({\n style: 'width: ' + width + '; height: ' + height + ';'\n });\n // Clear the draw if its already used before so we start fresh\n svg.empty();\n\n } else {\n // Create svg object with width and height or use 100% as default\n svg = Chartist.Svg('svg').attr({\n width: width,\n height: height\n }).addClass(className).attr({\n style: 'width: ' + width + '; height: ' + height + ';'\n });\n\n // Add the DOM node to our container\n container.appendChild(svg._node);\n container.chartistSvg = svg;\n }\n\n return svg;\n };\n\n /**\n * Convert data series into plain array\n *\n * @memberof Chartist.Core\n * @param {Object} data The series object that contains the data to be visualized in the chart\n * @return {Array} A plain array that contains the data to be visualized in the chart\n */\n Chartist.getDataArray = function (data) {\n var array = [];\n\n for (var i = 0; i < data.series.length; i++) {\n // If the series array contains an object with a data property we will use the property\n // otherwise the value directly (array or number)\n array[i] = typeof(data.series[i]) === 'object' && data.series[i].data !== undefined ?\n data.series[i].data : data.series[i];\n\n // Convert values to number\n for (var j = 0; j < array[i].length; j++) {\n array[i][j] = +array[i][j];\n }\n }\n\n return array;\n };\n\n /**\n * Adds missing values at the end of the array. This array contains the data, that will be visualized in the chart\n *\n * @memberof Chartist.Core\n * @param {Array} dataArray The array that contains the data to be visualized in the chart. The array in this parameter will be modified by function.\n * @param {Number} length The length of the x-axis data array.\n * @return {Array} The array that got updated with missing values.\n */\n Chartist.normalizeDataArray = function (dataArray, length) {\n for (var i = 0; i < dataArray.length; i++) {\n if (dataArray[i].length === length) {\n continue;\n }\n\n for (var j = dataArray[i].length; j < length; j++) {\n dataArray[i][j] = 0;\n }\n }\n\n return dataArray;\n };\n\n /**\n * Calculate the order of magnitude for the chart scale\n *\n * @memberof Chartist.Core\n * @param {Number} value The value Range of the chart\n * @return {Number} The order of magnitude\n */\n Chartist.orderOfMagnitude = function (value) {\n return Math.floor(Math.log(Math.abs(value)) / Math.LN10);\n };\n\n /**\n * Project a data length into screen coordinates (pixels)\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Number} length Single data value from a series array\n * @param {Object} bounds All the values to set the bounds of the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @return {Number} The projected data length in pixels\n */\n Chartist.projectLength = function (svg, length, bounds, options) {\n var availableHeight = Chartist.getAvailableHeight(svg, options);\n return (length / bounds.range * availableHeight);\n };\n\n /**\n * Get the height of the area in the chart for the data series\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @return {Number} The height of the area in the chart for the data series\n */\n Chartist.getAvailableHeight = function (svg, options) {\n return Math.max((Chartist.getPixelLength(options.height) || svg.height()) - (options.chartPadding * 2) - options.axisX.offset, 0);\n };\n\n /**\n * Get highest and lowest value of data array. This Array contains the data that will be visualized in the chart.\n *\n * @memberof Chartist.Core\n * @param {Array} dataArray The array that contains the data to be visualized in the chart\n * @return {Array} The array that contains the highest and lowest value that will be visualized on the chart.\n */\n Chartist.getHighLow = function (dataArray) {\n var i,\n j,\n highLow = {\n high: -Number.MAX_VALUE,\n low: Number.MAX_VALUE\n };\n\n for (i = 0; i < dataArray.length; i++) {\n for (j = 0; j < dataArray[i].length; j++) {\n if (dataArray[i][j] > highLow.high) {\n highLow.high = dataArray[i][j];\n }\n\n if (dataArray[i][j] < highLow.low) {\n highLow.low = dataArray[i][j];\n }\n }\n }\n\n return highLow;\n };\n\n // Find the highest and lowest values in a two dimensional array and calculate scale based on order of magnitude\n /**\n * Calculate and retrieve all the bounds for the chart and return them in one array\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Array} normalizedData The array that got updated with missing values.\n * @param {Object} options The Object that contains all the optional values for the chart\n * @param {Number} referenceValue The reference value for the chart.\n * @return {Object} All the values to set the bounds of the chart\n */\n Chartist.getBounds = function (svg, normalizedData, options, referenceValue) {\n var i,\n newMin,\n newMax,\n bounds = Chartist.getHighLow(normalizedData);\n\n // Overrides of high / low from settings\n bounds.high = +options.high || (options.high === 0 ? 0 : bounds.high);\n bounds.low = +options.low || (options.low === 0 ? 0 : bounds.low);\n\n // If high and low are the same because of misconfiguration or flat data (only the same value) we need\n // to set the high or low to 0 depending on the polarity\n if(bounds.high === bounds.low) {\n // If both values are 0 we set high to 1\n if(bounds.low === 0) {\n bounds.high = 1;\n } else if(bounds.low < 0) {\n // If we have the same negative value for the bounds we set bounds.high to 0\n bounds.high = 0;\n } else {\n // If we have the same positive value for the bounds we set bounds.low to 0\n bounds.low = 0;\n }\n }\n\n // Overrides of high / low based on reference value, it will make sure that the invisible reference value is\n // used to generate the chart. This is useful when the chart always needs to contain the position of the\n // invisible reference value in the view i.e. for bipolar scales.\n if (referenceValue || referenceValue === 0) {\n bounds.high = Math.max(referenceValue, bounds.high);\n bounds.low = Math.min(referenceValue, bounds.low);\n }\n\n bounds.valueRange = bounds.high - bounds.low;\n bounds.oom = Chartist.orderOfMagnitude(bounds.valueRange);\n bounds.min = Math.floor(bounds.low / Math.pow(10, bounds.oom)) * Math.pow(10, bounds.oom);\n bounds.max = Math.ceil(bounds.high / Math.pow(10, bounds.oom)) * Math.pow(10, bounds.oom);\n bounds.range = bounds.max - bounds.min;\n bounds.step = Math.pow(10, bounds.oom);\n bounds.numberOfSteps = Math.round(bounds.range / bounds.step);\n\n // Optimize scale step by checking if subdivision is possible based on horizontalGridMinSpace\n // If we are already below the scaleMinSpace value we will scale up\n var length = Chartist.projectLength(svg, bounds.step, bounds, options),\n scaleUp = length < options.axisY.scaleMinSpace;\n\n while (true) {\n if (scaleUp && Chartist.projectLength(svg, bounds.step, bounds, options) <= options.axisY.scaleMinSpace) {\n bounds.step *= 2;\n } else if (!scaleUp && Chartist.projectLength(svg, bounds.step / 2, bounds, options) >= options.axisY.scaleMinSpace) {\n bounds.step /= 2;\n } else {\n break;\n }\n }\n\n // Narrow min and max based on new step\n newMin = bounds.min;\n newMax = bounds.max;\n for (i = bounds.min; i <= bounds.max; i += bounds.step) {\n if (i + bounds.step < bounds.low) {\n newMin += bounds.step;\n }\n\n if (i - bounds.step > bounds.high) {\n newMax -= bounds.step;\n }\n }\n bounds.min = newMin;\n bounds.max = newMax;\n bounds.range = bounds.max - bounds.min;\n\n bounds.values = [];\n for (i = bounds.min; i <= bounds.max; i += bounds.step) {\n bounds.values.push(i);\n }\n\n return bounds;\n };\n\n /**\n * Calculate cartesian coordinates of polar coordinates\n *\n * @memberof Chartist.Core\n * @param {Number} centerX X-axis coordinates of center point of circle segment\n * @param {Number} centerY X-axis coordinates of center point of circle segment\n * @param {Number} radius Radius of circle segment\n * @param {Number} angleInDegrees Angle of circle segment in degrees\n * @return {Number} Coordinates of point on circumference\n */\n Chartist.polarToCartesian = function (centerX, centerY, radius, angleInDegrees) {\n var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;\n\n return {\n x: centerX + (radius * Math.cos(angleInRadians)),\n y: centerY + (radius * Math.sin(angleInRadians))\n };\n };\n\n /**\n * Initialize chart drawing rectangle (area where chart is drawn) x1,y1 = bottom left / x2,y2 = top right\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @return {Object} The chart rectangles coordinates inside the svg element plus the rectangles measurements\n */\n Chartist.createChartRect = function (svg, options) {\n var yOffset = options.axisY ? options.axisY.offset : 0,\n xOffset = options.axisX ? options.axisX.offset : 0;\n\n return {\n x1: options.chartPadding + yOffset,\n y1: Math.max((Chartist.getPixelLength(options.height) || svg.height()) - options.chartPadding - xOffset, options.chartPadding),\n x2: Math.max((Chartist.getPixelLength(options.width) || svg.width()) - options.chartPadding, options.chartPadding + yOffset),\n y2: options.chartPadding,\n width: function () {\n return this.x2 - this.x1;\n },\n height: function () {\n return this.y1 - this.y2;\n }\n };\n };\n\n /**\n * Creates a label with text and based on support of SVG1.1 extensibility will use a foreignObject with a SPAN element or a fallback to a regular SVG text element.\n *\n * @param {Object} parent The SVG element where the label should be created as a child\n * @param {String} text The label text\n * @param {Object} attributes An object with all attributes that should be set on the label element\n * @param {String} className The class names that should be set for this element\n * @param {Boolean} supportsForeignObject If this is true then a foreignObject will be used instead of a text element\n * @returns {Object} The newly created SVG element\n */\n Chartist.createLabel = function(parent, text, attributes, className, supportsForeignObject) {\n if(supportsForeignObject) {\n var content = '' + text + '';\n return parent.foreignObject(content, attributes);\n } else {\n return parent.elem('text', attributes, className).text(text);\n }\n };\n\n /**\n * Generate grid lines and labels for the x-axis into grid and labels group SVG elements\n *\n * @memberof Chartist.Core\n * @param {Object} chartRect The rectangle that sets the bounds for the chart in the svg element\n * @param {Object} data The Object that contains the data to be visualized in the chart\n * @param {Object} grid Chartist.Svg wrapper object to be filled with the grid lines of the chart\n * @param {Object} labels Chartist.Svg wrapper object to be filled with the lables of the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @param {Object} eventEmitter The passed event emitter will be used to emit draw events for labels and gridlines\n * @param {Boolean} supportsForeignObject If this is true then a foreignObject will be used instead of a text element\n */\n Chartist.createXAxis = function (chartRect, data, grid, labels, options, eventEmitter, supportsForeignObject) {\n // Create X-Axis\n data.labels.forEach(function (value, index) {\n var interpolatedValue = options.axisX.labelInterpolationFnc(value, index),\n width = chartRect.width() / data.labels.length,\n height = options.axisX.offset,\n pos = chartRect.x1 + width * index;\n\n // If interpolated value returns falsey (except 0) we don't draw the grid line\n if (!interpolatedValue && interpolatedValue !== 0) {\n return;\n }\n\n if (options.axisX.showGrid) {\n var gridElement = grid.elem('line', {\n x1: pos,\n y1: chartRect.y1,\n x2: pos,\n y2: chartRect.y2\n }, [options.classNames.grid, options.classNames.horizontal].join(' '));\n\n // Event for grid draw\n eventEmitter.emit('draw', {\n type: 'grid',\n axis: 'x',\n index: index,\n group: grid,\n element: gridElement,\n x1: pos,\n y1: chartRect.y1,\n x2: pos,\n y2: chartRect.y2\n });\n }\n\n if (options.axisX.showLabel) {\n var labelPosition = {\n x: pos + options.axisX.labelOffset.x,\n y: chartRect.y1 + options.axisX.labelOffset.y + (supportsForeignObject ? 5 : 20)\n };\n\n var labelElement = Chartist.createLabel(labels, '' + interpolatedValue, {\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n style: 'overflow: visible;'\n }, [options.classNames.label, options.classNames.horizontal].join(' '), supportsForeignObject);\n\n eventEmitter.emit('draw', {\n type: 'label',\n axis: 'x',\n index: index,\n group: labels,\n element: labelElement,\n text: '' + interpolatedValue,\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n // TODO: Remove in next major release\n get space() {\n window.console.warn('EventEmitter: space is deprecated, use width or height instead.');\n return this.width;\n }\n });\n }\n });\n };\n\n /**\n * Generate grid lines and labels for the y-axis into grid and labels group SVG elements\n *\n * @memberof Chartist.Core\n * @param {Object} chartRect The rectangle that sets the bounds for the chart in the svg element\n * @param {Object} bounds All the values to set the bounds of the chart\n * @param {Object} grid Chartist.Svg wrapper object to be filled with the grid lines of the chart\n * @param {Object} labels Chartist.Svg wrapper object to be filled with the lables of the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @param {Object} eventEmitter The passed event emitter will be used to emit draw events for labels and gridlines\n * @param {Boolean} supportsForeignObject If this is true then a foreignObject will be used instead of a text element\n */\n Chartist.createYAxis = function (chartRect, bounds, grid, labels, options, eventEmitter, supportsForeignObject) {\n // Create Y-Axis\n bounds.values.forEach(function (value, index) {\n var interpolatedValue = options.axisY.labelInterpolationFnc(value, index),\n width = options.axisY.offset,\n height = chartRect.height() / bounds.values.length,\n pos = chartRect.y1 - height * index;\n\n // If interpolated value returns falsey (except 0) we don't draw the grid line\n if (!interpolatedValue && interpolatedValue !== 0) {\n return;\n }\n\n if (options.axisY.showGrid) {\n var gridElement = grid.elem('line', {\n x1: chartRect.x1,\n y1: pos,\n x2: chartRect.x2,\n y2: pos\n }, [options.classNames.grid, options.classNames.vertical].join(' '));\n\n // Event for grid draw\n eventEmitter.emit('draw', {\n type: 'grid',\n axis: 'y',\n index: index,\n group: grid,\n element: gridElement,\n x1: chartRect.x1,\n y1: pos,\n x2: chartRect.x2,\n y2: pos\n });\n }\n\n if (options.axisY.showLabel) {\n var labelPosition = {\n x: options.chartPadding + options.axisY.labelOffset.x + (supportsForeignObject ? -10 : 0),\n y: pos + options.axisY.labelOffset.y + (supportsForeignObject ? -15 : 0)\n };\n\n var labelElement = Chartist.createLabel(labels, '' + interpolatedValue, {\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n style: 'overflow: visible;'\n }, [options.classNames.label, options.classNames.vertical].join(' '), supportsForeignObject);\n\n eventEmitter.emit('draw', {\n type: 'label',\n axis: 'y',\n index: index,\n group: labels,\n element: labelElement,\n text: '' + interpolatedValue,\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n // TODO: Remove in next major release\n get space() {\n window.console.warn('EventEmitter: space is deprecated, use width or height instead.');\n return this.height;\n }\n });\n }\n });\n };\n\n /**\n * Determine the current point on the svg element to draw the data series\n *\n * @memberof Chartist.Core\n * @param {Object} chartRect The rectangle that sets the bounds for the chart in the svg element\n * @param {Object} bounds All the values to set the bounds of the chart\n * @param {Array} data The array that contains the data to be visualized in the chart\n * @param {Number} index The index of the current project point\n * @return {Object} The coordinates object of the current project point containing an x and y number property\n */\n Chartist.projectPoint = function (chartRect, bounds, data, index) {\n return {\n x: chartRect.x1 + chartRect.width() / data.length * index,\n y: chartRect.y1 - chartRect.height() * (data[index] - bounds.min) / (bounds.range + bounds.step)\n };\n };\n\n // TODO: With multiple media queries the handleMediaChange function is triggered too many times, only need one\n /**\n * Provides options handling functionality with callback for options changes triggered by responsive options and media query matches\n *\n * @memberof Chartist.Core\n * @param {Object} defaultOptions Default options from Chartist\n * @param {Object} options Options set by user\n * @param {Array} responsiveOptions Optional functions to add responsive behavior to chart\n * @param {Object} eventEmitter The event emitter that will be used to emit the options changed events\n * @return {Object} The consolidated options object from the defaults, base and matching responsive options\n */\n Chartist.optionsProvider = function (defaultOptions, options, responsiveOptions, eventEmitter) {\n var baseOptions = Chartist.extend(Chartist.extend({}, defaultOptions), options),\n currentOptions,\n mediaQueryListeners = [],\n i;\n\n function updateCurrentOptions() {\n var previousOptions = currentOptions;\n currentOptions = Chartist.extend({}, baseOptions);\n\n if (responsiveOptions) {\n for (i = 0; i < responsiveOptions.length; i++) {\n var mql = window.matchMedia(responsiveOptions[i][0]);\n if (mql.matches) {\n currentOptions = Chartist.extend(currentOptions, responsiveOptions[i][1]);\n }\n }\n }\n\n if(eventEmitter) {\n eventEmitter.emit('optionsChanged', {\n previousOptions: previousOptions,\n currentOptions: currentOptions\n });\n }\n }\n\n function removeMediaQueryListeners() {\n mediaQueryListeners.forEach(function(mql) {\n mql.removeListener(updateCurrentOptions);\n });\n }\n\n if (!window.matchMedia) {\n throw 'window.matchMedia not found! Make sure you\\'re using a polyfill.';\n } else if (responsiveOptions) {\n\n for (i = 0; i < responsiveOptions.length; i++) {\n var mql = window.matchMedia(responsiveOptions[i][0]);\n mql.addListener(updateCurrentOptions);\n mediaQueryListeners.push(mql);\n }\n }\n // Execute initially so we get the correct options\n updateCurrentOptions();\n\n return {\n get currentOptions() {\n return Chartist.extend({}, currentOptions);\n },\n removeMediaQueryListeners: removeMediaQueryListeners\n };\n };\n\n //http://schepers.cc/getting-to-the-point\n Chartist.catmullRom2bezier = function (crp, z) {\n var d = [];\n for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {\n var p = [\n {x: +crp[i - 2], y: +crp[i - 1]},\n {x: +crp[i], y: +crp[i + 1]},\n {x: +crp[i + 2], y: +crp[i + 3]},\n {x: +crp[i + 4], y: +crp[i + 5]}\n ];\n if (z) {\n if (!i) {\n p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};\n } else if (iLen - 4 === i) {\n p[3] = {x: +crp[0], y: +crp[1]};\n } else if (iLen - 2 === i) {\n p[2] = {x: +crp[0], y: +crp[1]};\n p[3] = {x: +crp[2], y: +crp[3]};\n }\n } else {\n if (iLen - 4 === i) {\n p[3] = p[2];\n } else if (!i) {\n p[0] = {x: +crp[i], y: +crp[i + 1]};\n }\n }\n d.push(\n [\n (-p[0].x + 6 * p[1].x + p[2].x) / 6,\n (-p[0].y + 6 * p[1].y + p[2].y) / 6,\n (p[1].x + 6 * p[2].x - p[3].x) / 6,\n (p[1].y + 6 * p[2].y - p[3].y) / 6,\n p[2].x,\n p[2].y\n ]\n );\n }\n\n return d;\n };\n\n }(window, document, Chartist));;/**\n * A very basic event module that helps to generate and catch events.\n *\n * @module Chartist.Event\n */\n /* global Chartist */\n (function (window, document, Chartist) {\n 'use strict';\n\n Chartist.EventEmitter = function () {\n var handlers = [];\n\n /**\n * Add an event handler for a specific event\n *\n * @memberof Chartist.Event\n * @param {String} event The event name\n * @param {Function} handler A event handler function\n */\n function addEventHandler(event, handler) {\n handlers[event] = handlers[event] || [];\n handlers[event].push(handler);\n }\n\n /**\n * Remove an event handler of a specific event name or remove all event handlers for a specific event.\n *\n * @memberof Chartist.Event\n * @param {String} event The event name where a specific or all handlers should be removed\n * @param {Function} [handler] An optional event handler function. If specified only this specific handler will be removed and otherwise all handlers are removed.\n */\n function removeEventHandler(event, handler) {\n // Only do something if there are event handlers with this name existing\n if(handlers[event]) {\n // If handler is set we will look for a specific handler and only remove this\n if(handler) {\n handlers[event].splice(handlers[event].indexOf(handler), 1);\n if(handlers[event].length === 0) {\n delete handlers[event];\n }\n } else {\n // If no handler is specified we remove all handlers for this event\n delete handlers[event];\n }\n }\n }\n\n /**\n * Use this function to emit an event. All handlers that are listening for this event will be triggered with the data parameter.\n *\n * @memberof Chartist.Event\n * @param {String} event The event name that should be triggered\n * @param {*} data Arbitrary data that will be passed to the event handler callback functions\n */\n function emit(event, data) {\n // Only do something if there are event handlers with this name existing\n if(handlers[event]) {\n handlers[event].forEach(function(handler) {\n handler(data);\n });\n }\n }\n\n return {\n addEventHandler: addEventHandler,\n removeEventHandler: removeEventHandler,\n emit: emit\n };\n };\n\n }(window, document, Chartist));;/**\n * This module provides some basic prototype inheritance utilities.\n *\n * @module Chartist.Class\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n function listToArray(list) {\n var arr = [];\n if (list.length) {\n for (var i = 0; i < list.length; i++) {\n arr.push(list[i]);\n }\n }\n return arr;\n }\n\n /**\n * Method to extend from current prototype.\n *\n * @memberof Chartist.Class\n * @param {Object} properties The object that serves as definition for the prototype that gets created for the new class. This object should always contain a constructor property that is the desired constructor for the newly created class.\n * @param {Object} [superProtoOverride] By default extens will use the current class prototype or Chartist.class. With this parameter you can specify any super prototype that will be used.\n * @returns {Function} Constructor function of the new class\n *\n * @example\n * var Fruit = Class.extend({\n * color: undefined,\n * sugar: undefined,\n *\n * constructor: function(color, sugar) {\n * this.color = color;\n * this.sugar = sugar;\n * },\n *\n * eat: function() {\n * this.sugar = 0;\n * return this;\n * }\n * });\n *\n * var Banana = Fruit.extend({\n * length: undefined,\n *\n * constructor: function(length, sugar) {\n * Banana.super.constructor.call(this, 'Yellow', sugar);\n * this.length = length;\n * }\n * });\n *\n * var banana = new Banana(20, 40);\n * console.log('banana instanceof Fruit', banana instanceof Fruit);\n * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));\n * console.log('bananas\\'s prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);\n * console.log(banana.sugar);\n * console.log(banana.eat().sugar);\n * console.log(banana.color);\n */\n function extend(properties, superProtoOverride) {\n var superProto = superProtoOverride || this.prototype || Chartist.Class;\n var proto = Object.create(superProto);\n\n Chartist.Class.cloneDefinitions(proto, properties);\n\n var constr = function() {\n var fn = proto.constructor || function () {},\n instance;\n\n // If this is linked to the Chartist namespace the constructor was not called with new\n // To provide a fallback we will instantiate here and return the instance\n instance = this === Chartist ? Object.create(proto) : this;\n fn.apply(instance, Array.prototype.slice.call(arguments, 0));\n\n // If this constructor was not called with new we need to return the instance\n // This will not harm when the constructor has been called with new as the returned value is ignored\n return instance;\n };\n\n constr.prototype = proto;\n constr.super = superProto;\n constr.extend = this.extend;\n\n return constr;\n }\n\n /**\n * Creates a mixin from multiple super prototypes.\n *\n * @memberof Chartist.Class\n * @param {Array} mixProtoArr An array of super prototypes or an array of super prototype constructors.\n * @param {Object} properties The object that serves as definition for the prototype that gets created for the new class. This object should always contain a constructor property that is the desired constructor for the newly created class.\n * @returns {Function} Constructor function of the newly created mixin class\n *\n * @example\n * var Fruit = Class.extend({\n * color: undefined,\n * sugar: undefined,\n *\n * constructor: function(color, sugar) {\n * this.color = color;\n * this.sugar = sugar;\n * },\n *\n * eat: function() {\n * this.sugar = 0;\n * return this;\n * }\n * });\n *\n * var Banana = Fruit.extend({\n * length: undefined,\n *\n * constructor: function(length, sugar) {\n * Banana.super.constructor.call(this, 'Yellow', sugar);\n * this.length = length;\n * }\n * });\n *\n * var banana = new Banana(20, 40);\n * console.log('banana instanceof Fruit', banana instanceof Fruit);\n * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));\n * console.log('bananas\\'s prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);\n * console.log(banana.sugar);\n * console.log(banana.eat().sugar);\n * console.log(banana.color);\n *\n *\n * var KCal = Class.extend({\n * sugar: 0,\n *\n * constructor: function(sugar) {\n * this.sugar = sugar;\n * },\n *\n * get kcal() {\n * return [this.sugar * 4, 'kcal'].join('');\n * }\n * });\n *\n * var Nameable = Class.extend({\n * name: undefined,\n *\n * constructor: function(name) {\n * this.name = name;\n * }\n * });\n *\n * var NameableKCalBanana = Class.mix([Banana, KCal, Nameable], {\n * constructor: function(name, length, sugar) {\n * Nameable.prototype.constructor.call(this, name);\n * Banana.prototype.constructor.call(this, length, sugar);\n * },\n *\n * toString: function() {\n * return [this.name, 'with', this.length + 'cm', 'and', this.kcal].join(' ');\n * }\n * });\n *\n *\n *\n * var banana = new Banana(20, 40);\n * console.log('banana instanceof Fruit', banana instanceof Fruit);\n * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));\n * console.log('bananas\\'s prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);\n * console.log(banana.sugar);\n * console.log(banana.eat().sugar);\n * console.log(banana.color);\n *\n * var superBanana = new NameableKCalBanana('Super Mixin Banana', 30, 80);\n * console.log(superBanana.toString());\n *\n */\n function mix(mixProtoArr, properties) {\n if(this !== Chartist.Class) {\n throw new Error('Chartist.Class.mix should only be called on the type and never on an instance!');\n }\n\n // Make sure our mixin prototypes are the class objects and not the constructors\n var superPrototypes = [{}]\n .concat(mixProtoArr)\n .map(function (prototype) {\n return prototype instanceof Function ? prototype.prototype : prototype;\n });\n\n var mixedSuperProto = Chartist.Class.cloneDefinitions.apply(undefined, superPrototypes);\n // Delete the constructor if present because we don't want to invoke a constructor on a mixed prototype\n delete mixedSuperProto.constructor;\n return this.extend(properties, mixedSuperProto);\n }\n\n // Variable argument list clones args > 0 into args[0] and retruns modified args[0]\n function cloneDefinitions() {\n var args = listToArray(arguments);\n var target = args[0];\n\n args.splice(1, args.length - 1).forEach(function (source) {\n Object.getOwnPropertyNames(source).forEach(function (propName) {\n // If this property already exist in target we delete it first\n delete target[propName];\n // Define the property with the descriptor from source\n Object.defineProperty(target, propName,\n Object.getOwnPropertyDescriptor(source, propName));\n });\n });\n\n return target;\n }\n\n Chartist.Class = {\n extend: extend,\n mix: mix,\n cloneDefinitions: cloneDefinitions\n };\n\n }(window, document, Chartist));;/**\n * Base for all chart types. The methods in Chartist.Base are inherited to all chart types.\n *\n * @module Chartist.Base\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n // TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance.\n // This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not\n // work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage.\n // See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html\n // Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj\n // The problem is with the label offsets that can't be converted into percentage and affecting the chart container\n /**\n * Updates the chart which currently does a full reconstruction of the SVG DOM\n *\n * @memberof Chartist.Base\n */\n function update() {\n this.createChart(this.optionsProvider.currentOptions);\n }\n\n /**\n * This method can be called on the API object of each chart and will un-register all event listeners that were added to other components. This currently includes a window.resize listener as well as media query listeners if any responsive options have been provided. Use this function if you need to destroy and recreate Chartist charts dynamically.\n *\n * @memberof Chartist.Base\n */\n function detach() {\n window.removeEventListener('resize', this.update);\n this.optionsProvider.removeMediaQueryListeners();\n }\n\n /**\n * Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop.\n *\n * @memberof Chartist.Base\n * @param {String} event Name of the event. Check the examples for supported events.\n * @param {Function} handler The handler function that will be called when an event with the given name was emitted. This function will receive a data argument which contains event data. See the example for more details.\n */\n function on(event, handler) {\n this.eventEmitter.addEventHandler(event, handler);\n }\n\n /**\n * Use this function to un-register event handlers. If the handler function parameter is omitted all handlers for the given event will be un-registered.\n *\n * @memberof Chartist.Base\n * @param {String} event Name of the event for which a handler should be removed\n * @param {Function} [handler] The handler function that that was previously used to register a new event handler. This handler will be removed from the event handler list. If this parameter is omitted then all event handlers for the given event are removed from the list.\n */\n function off(event, handler) {\n this.eventEmitter.removeEventHandler(event, handler);\n }\n\n /**\n * Constructor of chart base class.\n *\n * @param query\n * @param data\n * @param options\n * @param responsiveOptions\n * @constructor\n */\n function Base(query, data, options, responsiveOptions) {\n this.container = Chartist.querySelector(query);\n this.data = data;\n this.options = options;\n this.responsiveOptions = responsiveOptions;\n this.eventEmitter = Chartist.EventEmitter();\n this.supportsForeignObject = Chartist.Svg.isSupported('Extensibility');\n\n window.addEventListener('resize', this.update.bind(this));\n\n // Using event loop for first draw to make it possible to register event listeners in the same call stack where\n // the chart was created.\n setTimeout(function() {\n // Obtain current options based on matching media queries (if responsive options are given)\n // This will also register a listener that is re-creating the chart based on media changes\n // TODO: Remove default options parameter from optionsProvider\n this.optionsProvider = Chartist.optionsProvider({}, this.options, this.responsiveOptions, this.eventEmitter);\n this.createChart(this.optionsProvider.currentOptions);\n }.bind(this), 0);\n }\n\n // Creating the chart base class\n Chartist.Base = Chartist.Class.extend({\n constructor: Base,\n optionsProvider: undefined,\n container: undefined,\n svg: undefined,\n eventEmitter: undefined,\n createChart: function() {\n throw new Error('Base chart type can\\'t be instantiated!');\n },\n update: update,\n detach: detach,\n on: on,\n off: off,\n version: Chartist.version,\n supportsForeignObject: false\n });\n\n }(window, document, Chartist));;/**\n * Chartist SVG module for simple SVG DOM abstraction\n *\n * @module Chartist.Svg\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n Chartist.xmlNs = {\n qualifiedName: 'xmlns:ct',\n prefix: 'ct',\n uri: 'http://gionkunz.github.com/chartist-js/ct'\n };\n\n /**\n * Chartist.Svg creates a new SVG object wrapper with a starting element. You can use the wrapper to fluently create sub-elements and modify them.\n *\n * @memberof Chartist.Svg\n * @param {String} name The name of the SVG element to create\n * @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.\n * @param {String} className This class or class list will be added to the SVG element\n * @param {Object} parent The parent SVG wrapper object where this newly created wrapper and it's element will be attached to as child\n * @param {Boolean} insertFirst If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element\n * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data\n */\n Chartist.Svg = function(name, attributes, className, parent, insertFirst) {\n\n var svgNs = 'http://www.w3.org/2000/svg',\n xmlNs = 'http://www.w3.org/2000/xmlns/',\n xhtmlNs = 'http://www.w3.org/1999/xhtml';\n\n /**\n * Set attributes on the current SVG element of the wrapper you're currently working on.\n *\n * @memberof Chartist.Svg\n * @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.\n * @param {String} ns If specified, the attributes will be set as namespace attributes with ns as prefix.\n * @returns {Object} The current wrapper object will be returned so it can be used for chaining.\n */\n function attr(node, attributes, ns) {\n Object.keys(attributes).forEach(function(key) {\n // If the attribute value is undefined we can skip this one\n if(attributes[key] === undefined) {\n return;\n }\n\n if(ns) {\n node.setAttributeNS(ns, [Chartist.xmlNs.prefix, ':', key].join(''), attributes[key]);\n } else {\n node.setAttribute(key, attributes[key]);\n }\n });\n\n return node;\n }\n\n /**\n * Create a new SVG element whose wrapper object will be selected for further operations. This way you can also create nested groups easily.\n *\n * @memberof Chartist.Svg\n * @param {String} name The name of the SVG element that should be created as child element of the currently selected element wrapper\n * @param {Object} [attributes] An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.\n * @param {String} [className] This class or class list will be added to the SVG element\n * @param {Boolean} [insertFirst] If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element\n * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data\n */\n function elem(name, attributes, className, parentNode, insertFirst) {\n var node = document.createElementNS(svgNs, name);\n\n // If this is an SVG element created then custom namespace\n if(name === 'svg') {\n node.setAttributeNS(xmlNs, Chartist.xmlNs.qualifiedName, Chartist.xmlNs.uri);\n }\n\n if(parentNode) {\n if(insertFirst && parentNode.firstChild) {\n parentNode.insertBefore(node, parentNode.firstChild);\n } else {\n parentNode.appendChild(node);\n }\n }\n\n if(attributes) {\n attr(node, attributes);\n }\n\n if(className) {\n addClass(node, className);\n }\n\n return node;\n }\n\n /**\n * This method creates a foreignObject (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject) that allows to embed HTML content into a SVG graphic. With the help of foreignObjects you can enable the usage of regular HTML elements inside of SVG where they are subject for SVG positioning and transformation but the Browser will use the HTML rendering capabilities for the containing DOM.\n *\n * @memberof Chartist.Svg\n * @param {Node|String} content The DOM Node, or HTML string that will be converted to a DOM Node, that is then placed into and wrapped by the foreignObject\n * @param {String} [attributes] An object with properties that will be added as attributes to the foreignObject element that is created. Attributes with undefined values will not be added.\n * @param {String} [className] This class or class list will be added to the SVG element\n * @param {Boolean} [insertFirst] Specifies if the foreignObject should be inserted as first child\n * @returns {Object} New wrapper object that wraps the foreignObject element\n */\n function foreignObject(content, attributes, className, parent, insertFirst) {\n // If content is string then we convert it to DOM\n // TODO: Handle case where content is not a string nor a DOM Node\n if(typeof content === 'string') {\n var container = document.createElement('div');\n container.innerHTML = content;\n content = container.firstChild;\n }\n\n // Adding namespace to content element\n content.setAttribute('xmlns', xhtmlNs);\n\n // Creating the foreignObject without required extension attribute (as described here\n // http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement)\n var fnObj = parent.elem('foreignObject', attributes, className, insertFirst);\n\n // Add content to foreignObjectElement\n fnObj._node.appendChild(content);\n\n return fnObj;\n }\n\n /**\n * This method adds a new text element to the current Chartist.Svg wrapper.\n *\n * @memberof Chartist.Svg\n * @param {String} t The text that should be added to the text element that is created\n * @returns {Object} The same wrapper object that was used to add the newly created element\n */\n function text(node, t) {\n node.appendChild(document.createTextNode(t));\n }\n\n /**\n * This method will clear all child nodes of the current wrapper object.\n *\n * @memberof Chartist.Svg\n * @returns {Object} The same wrapper object that got emptied\n */\n function empty(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n }\n\n /**\n * This method will cause the current wrapper to remove itself from its parent wrapper. Use this method if you'd like to get rid of an element in a given DOM structure.\n *\n * @memberof Chartist.Svg\n * @returns {Object} The parent wrapper object of the element that got removed\n */\n function remove(node) {\n node.parentNode.removeChild(node);\n }\n\n /**\n * This method will replace the element with a new element that can be created outside of the current DOM.\n *\n * @memberof Chartist.Svg\n * @param {Object} newElement The new wrapper object that will be used to replace the current wrapper object\n * @returns {Object} The wrapper of the new element\n */\n function replace(node, newChild) {\n node.parentNode.replaceChild(newChild, node);\n }\n\n /**\n * This method will append an element to the current element as a child.\n *\n * @memberof Chartist.Svg\n * @param {Object} element The element that should be added as a child\n * @param {Boolean} [insertFirst] Specifies if the element should be inserted as first child\n * @returns {Object} The wrapper of the appended object\n */\n function append(node, child, insertFirst) {\n if(insertFirst && node.firstChild) {\n node.insertBefore(child, node.firstChild);\n } else {\n node.appendChild(child);\n }\n }\n\n /**\n * Returns an array of class names that are attached to the current wrapper element. This method can not be chained further.\n *\n * @memberof Chartist.Svg\n * @returns {Array} A list of classes or an empty array if there are no classes on the current element\n */\n function classes(node) {\n return node.getAttribute('class') ? node.getAttribute('class').trim().split(/\\s+/) : [];\n }\n\n /**\n * Adds one or a space separated list of classes to the current element and ensures the classes are only existing once.\n *\n * @memberof Chartist.Svg\n * @param {String} names A white space separated list of class names\n * @returns {Object} The wrapper of the current element\n */\n function addClass(node, names) {\n node.setAttribute('class',\n classes(node)\n .concat(names.trim().split(/\\s+/))\n .filter(function(elem, pos, self) {\n return self.indexOf(elem) === pos;\n }).join(' ')\n );\n }\n\n /**\n * Removes one or a space separated list of classes from the current element.\n *\n * @memberof Chartist.Svg\n * @param {String} names A white space separated list of class names\n * @returns {Object} The wrapper of the current element\n */\n function removeClass(node, names) {\n var removedClasses = names.trim().split(/\\s+/);\n\n node.setAttribute('class', classes(node).filter(function(name) {\n return removedClasses.indexOf(name) === -1;\n }).join(' '));\n }\n\n /**\n * Removes all classes from the current element.\n *\n * @memberof Chartist.Svg\n * @returns {Object} The wrapper of the current element\n */\n function removeAllClasses(node) {\n node.setAttribute('class', '');\n }\n\n /**\n * Get element height with fallback to svg BoundingBox or parent container dimensions:\n * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985)\n *\n * @memberof Chartist.Svg\n * @return {Number} The elements height in pixels\n */\n function height(node) {\n return node.clientHeight || Math.round(node.getBBox().height) || node.parentNode.clientHeight;\n }\n\n /**\n * Get element width with fallback to svg BoundingBox or parent container dimensions:\n * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985)\n *\n * @memberof Chartist.Core\n * @return {Number} The elements width in pixels\n */\n function width(node) {\n return node.clientWidth || Math.round(node.getBBox().width) || node.parentNode.clientWidth;\n }\n\n return {\n _node: elem(name, attributes, className, parent ? parent._node : undefined, insertFirst),\n _parent: parent,\n parent: function() {\n return this._parent;\n },\n attr: function(attributes, ns) {\n attr(this._node, attributes, ns);\n return this;\n },\n empty: function() {\n empty(this._node);\n return this;\n },\n remove: function() {\n remove(this._node);\n return this.parent();\n },\n replace: function(newElement) {\n newElement._parent = this._parent;\n replace(this._node, newElement._node);\n return newElement;\n },\n append: function(element, insertFirst) {\n element._parent = this;\n append(this._node, element._node, insertFirst);\n return element;\n },\n elem: function(name, attributes, className, insertFirst) {\n return Chartist.Svg(name, attributes, className, this, insertFirst);\n },\n foreignObject: function(content, attributes, className, insertFirst) {\n return foreignObject(content, attributes, className, this, insertFirst);\n },\n text: function(t) {\n text(this._node, t);\n return this;\n },\n addClass: function(names) {\n addClass(this._node, names);\n return this;\n },\n removeClass: function(names) {\n removeClass(this._node, names);\n return this;\n },\n removeAllClasses: function() {\n removeAllClasses(this._node);\n return this;\n },\n classes: function() {\n return classes(this._node);\n },\n height: function() {\n return height(this._node);\n },\n width: function() {\n return width(this._node);\n }\n };\n };\n\n /**\n * This method checks for support of a given SVG feature like Extensibility, SVG-animation or the like. Check http://www.w3.org/TR/SVG11/feature for a detailed list.\n *\n * @memberof Chartist.Svg\n * @param {String} feature The SVG 1.1 feature that should be checked for support.\n * @returns {Boolean} True of false if the feature is supported or not\n */\n Chartist.Svg.isSupported = function(feature) {\n return document.implementation.hasFeature('www.http://w3.org/TR/SVG11/feature#' + feature, '1.1');\n };\n\n }(window, document, Chartist));;/**\n * The Chartist line chart can be used to draw Line or Scatter charts. If used in the browser you can access the global `Chartist` namespace where you find the `Line` function as a main entry point.\n *\n * For examples on how to use the line chart please check the examples of the `Chartist.Line` method.\n *\n * @module Chartist.Line\n */\n /* global Chartist */\n (function(window, document, Chartist){\n 'use strict';\n\n var defaultOptions = {\n axisX: {\n offset: 30,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 40,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop,\n scaleMinSpace: 30\n },\n width: undefined,\n height: undefined,\n showLine: true,\n showPoint: true,\n showArea: false,\n areaBase: 0,\n lineSmooth: true,\n low: undefined,\n high: undefined,\n chartPadding: 5,\n classNames: {\n chart: 'ct-chart-line',\n label: 'ct-label',\n series: 'ct-series',\n line: 'ct-line',\n point: 'ct-point',\n area: 'ct-area',\n grid: 'ct-grid',\n vertical: 'ct-vertical',\n horizontal: 'ct-horizontal'\n }\n };\n\n function createChart(options) {\n var seriesGroups = [],\n bounds,\n normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(this.data), this.data.labels.length);\n\n // Create new svg object\n this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);\n\n // initialize bounds\n bounds = Chartist.getBounds(this.svg, normalizedData, options);\n\n var chartRect = Chartist.createChartRect(this.svg, options);\n // Start drawing\n var labels = this.svg.elem('g'),\n grid = this.svg.elem('g');\n\n Chartist.createXAxis(chartRect, this.data, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n Chartist.createYAxis(chartRect, bounds, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < this.data.series.length; i++) {\n seriesGroups[i] = this.svg.elem('g');\n\n // If the series is an object and contains a name we add a custom attribute\n if(this.data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': this.data.series[i].name\n }, Chartist.xmlNs.uri);\n }\n\n // Use series class from series data or if not set generate one\n seriesGroups[i].addClass([\n options.classNames.series,\n (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i))\n ].join(' '));\n\n var p,\n pathCoordinates = [],\n point;\n\n for (var j = 0; j < normalizedData[i].length; j++) {\n p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j);\n pathCoordinates.push(p.x, p.y);\n\n //If we should show points we need to create them now to avoid secondary loop\n // Small offset for Firefox to render squares correctly\n if (options.showPoint) {\n point = seriesGroups[i].elem('line', {\n x1: p.x,\n y1: p.y,\n x2: p.x + 0.01,\n y2: p.y\n }, options.classNames.point).attr({\n 'value': normalizedData[i][j]\n }, Chartist.xmlNs.uri);\n\n this.eventEmitter.emit('draw', {\n type: 'point',\n value: normalizedData[i][j],\n index: j,\n group: seriesGroups[i],\n element: point,\n x: p.x,\n y: p.y\n });\n }\n }\n\n // TODO: Nicer handling of conditions, maybe composition?\n if (options.showLine || options.showArea) {\n // TODO: We should add a path API in the SVG library for easier path creation\n var pathElements = ['M' + pathCoordinates[0] + ',' + pathCoordinates[1]];\n\n // If smoothed path and path has more than two points then use catmull rom to bezier algorithm\n if (options.lineSmooth && pathCoordinates.length > 4) {\n\n var cr = Chartist.catmullRom2bezier(pathCoordinates);\n for(var k = 0; k < cr.length; k++) {\n pathElements.push('C' + cr[k].join());\n }\n } else {\n for(var l = 3; l < pathCoordinates.length; l += 2) {\n pathElements.push('L' + pathCoordinates[l - 1] + ',' + pathCoordinates[l]);\n }\n }\n\n if(options.showArea) {\n // If areaBase is outside the chart area (< low or > high) we need to set it respectively so that\n // the area is not drawn outside the chart area.\n var areaBase = Math.max(Math.min(options.areaBase, bounds.high), bounds.low);\n\n // If we need to draw area shapes we just make a copy of our pathElements SVG path array\n var areaPathElements = pathElements.slice();\n\n // We project the areaBase value into screen coordinates\n var areaBaseProjected = Chartist.projectPoint(chartRect, bounds, [areaBase], 0);\n // And splice our new area path array to add the missing path elements to close the area shape\n areaPathElements.splice(0, 0, 'M' + areaBaseProjected.x + ',' + areaBaseProjected.y);\n areaPathElements[1] = 'L' + pathCoordinates[0] + ',' + pathCoordinates[1];\n areaPathElements.push('L' + pathCoordinates[pathCoordinates.length - 2] + ',' + areaBaseProjected.y);\n\n // Create the new path for the area shape with the area class from the options\n seriesGroups[i].elem('path', {\n d: areaPathElements.join('')\n }, options.classNames.area, true).attr({\n 'values': normalizedData[i]\n }, Chartist.xmlNs.uri);\n }\n\n if(options.showLine) {\n seriesGroups[i].elem('path', {\n d: pathElements.join('')\n }, options.classNames.line, true).attr({\n 'values': normalizedData[i]\n }, Chartist.xmlNs.uri);\n }\n }\n }\n }\n\n /**\n * This method creates a new line chart.\n *\n * @memberof Chartist.Line\n * @param {String|Node} query A selector query string or directly a DOM element\n * @param {Object} data The data object that needs to consist of a labels and a series array\n * @param {Object} [options] The options object with options that override the default options. Check the examples for a detailed list.\n * @param {Array} [responsiveOptions] Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]\n * @return {Object} An object which exposes the API for the created chart\n *\n * @example\n * // These are the default options of the line chart\n * var options = {\n * // Options for X-Axis\n * axisX: {\n * // The offset of the labels to the chart area\n * offset: 30,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;}\n * },\n * // Options for Y-Axis\n * axisY: {\n * // The offset of the labels to the chart area\n * offset: 40,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;},\n * // This value specifies the minimum height in pixel of the scale steps\n * scaleMinSpace: 30\n * },\n * // Specify a fixed width for the chart as a string (i.e. '100px' or '50%')\n * width: undefined,\n * // Specify a fixed height for the chart as a string (i.e. '100px' or '50%')\n * height: undefined,\n * // If the line should be drawn or not\n * showLine: true,\n * // If dots should be drawn or not\n * showPoint: true,\n * // If the line chart should draw an area\n * showArea: false,\n * // The base for the area chart that will be used to close the area shape (is normally 0)\n * areaBase: 0,\n * // Specify if the lines should be smoothed (Catmull-Rom-Splines will be used)\n * lineSmooth: true,\n * // Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value\n * low: undefined,\n * // Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value\n * high: undefined,\n * // Padding of the chart drawing area to the container element and labels\n * chartPadding: 5,\n * // Override the class names that get used to generate the SVG structure of the chart\n * classNames: {\n * chart: 'ct-chart-line',\n * label: 'ct-label',\n * series: 'ct-series',\n * line: 'ct-line',\n * point: 'ct-point',\n * area: 'ct-area',\n * grid: 'ct-grid',\n * vertical: 'ct-vertical',\n * horizontal: 'ct-horizontal'\n * }\n * };\n *\n * @example\n * // Create a simple line chart\n * var data = {\n * // A labels array that can contain any sort of values\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * // Our series array that contains series objects or in this case series data arrays\n * series: [\n * [5, 2, 4, 2, 0]\n * ]\n * };\n *\n * // As options we currently only set a static size of 300x200 px\n * var options = {\n * width: '300px',\n * height: '200px'\n * };\n *\n * // In the global name space Chartist we call the Line function to initialize a line chart. As a first parameter we pass in a selector where we would like to get our chart created. Second parameter is the actual data object and as a third parameter we pass in our options\n * new Chartist.Line('.ct-chart', data, options);\n *\n * @example\n * // Create a line chart with responsive options\n *\n * var data = {\n * // A labels array that can contain any sort of values\n * labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],\n * // Our series array that contains series objects or in this case series data arrays\n * series: [\n * [5, 2, 4, 2, 0]\n * ]\n * };\n *\n * // In adition to the regular options we specify responsive option overrides that will override the default configutation based on the matching media queries.\n * var responsiveOptions = [\n * ['screen and (min-width: 641px) and (max-width: 1024px)', {\n * showPoint: false,\n * axisX: {\n * labelInterpolationFnc: function(value) {\n * // Will return Mon, Tue, Wed etc. on medium screens\n * return value.slice(0, 3);\n * }\n * }\n * }],\n * ['screen and (max-width: 640px)', {\n * showLine: false,\n * axisX: {\n * labelInterpolationFnc: function(value) {\n * // Will return M, T, W etc. on small screens\n * return value[0];\n * }\n * }\n * }]\n * ];\n *\n * new Chartist.Line('.ct-chart', data, null, responsiveOptions);\n *\n */\n function Line(query, data, options, responsiveOptions) {\n Chartist.Line.super.constructor.call(this,\n query,\n data,\n Chartist.extend(Chartist.extend({}, defaultOptions), options),\n responsiveOptions);\n }\n\n // Creating line chart type in Chartist namespace\n Chartist.Line = Chartist.Base.extend({\n constructor: Line,\n createChart: createChart\n });\n\n }(window, document, Chartist));\n ;/**\n * The bar chart module of Chartist that can be used to draw unipolar or bipolar bar and grouped bar charts.\n *\n * @module Chartist.Bar\n */\n /* global Chartist */\n (function(window, document, Chartist){\n 'use strict';\n\n var defaultOptions = {\n axisX: {\n offset: 30,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 40,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop,\n scaleMinSpace: 30\n },\n width: undefined,\n height: undefined,\n high: undefined,\n low: undefined,\n chartPadding: 5,\n seriesBarDistance: 15,\n classNames: {\n chart: 'ct-chart-bar',\n label: 'ct-label',\n series: 'ct-series',\n bar: 'ct-bar',\n grid: 'ct-grid',\n vertical: 'ct-vertical',\n horizontal: 'ct-horizontal'\n }\n };\n\n function createChart(options) {\n var seriesGroups = [],\n bounds,\n normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(this.data), this.data.labels.length);\n\n // Create new svg element\n this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);\n\n // initialize bounds\n bounds = Chartist.getBounds(this.svg, normalizedData, options, 0);\n\n var chartRect = Chartist.createChartRect(this.svg, options);\n // Start drawing\n var labels = this.svg.elem('g'),\n grid = this.svg.elem('g'),\n // Projected 0 point\n zeroPoint = Chartist.projectPoint(chartRect, bounds, [0], 0);\n\n Chartist.createXAxis(chartRect, this.data, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n Chartist.createYAxis(chartRect, bounds, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < this.data.series.length; i++) {\n // Calculating bi-polar value of index for seriesOffset. For i = 0..4 biPol will be -1.5, -0.5, 0.5, 1.5 etc.\n var biPol = i - (this.data.series.length - 1) / 2,\n // Half of the period with between vertical grid lines used to position bars\n periodHalfWidth = chartRect.width() / normalizedData[i].length / 2;\n\n seriesGroups[i] = this.svg.elem('g');\n\n // If the series is an object and contains a name we add a custom attribute\n if(this.data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': this.data.series[i].name\n }, Chartist.xmlNs.uri);\n }\n\n // Use series class from series data or if not set generate one\n seriesGroups[i].addClass([\n options.classNames.series,\n (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i))\n ].join(' '));\n\n for(var j = 0; j < normalizedData[i].length; j++) {\n var p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j),\n bar;\n\n // Offset to center bar between grid lines and using bi-polar offset for multiple series\n // TODO: Check if we should really be able to add classes to the series. Should be handles with Sass and semantic / specific selectors\n p.x += periodHalfWidth + (biPol * options.seriesBarDistance);\n\n bar = seriesGroups[i].elem('line', {\n x1: p.x,\n y1: zeroPoint.y,\n x2: p.x,\n y2: p.y\n }, options.classNames.bar).attr({\n 'value': normalizedData[i][j]\n }, Chartist.xmlNs.uri);\n\n this.eventEmitter.emit('draw', {\n type: 'bar',\n value: normalizedData[i][j],\n index: j,\n group: seriesGroups[i],\n element: bar,\n x1: p.x,\n y1: zeroPoint.y,\n x2: p.x,\n y2: p.y\n });\n }\n }\n }\n\n /**\n * This method creates a new bar chart and returns API object that you can use for later changes.\n *\n * @memberof Chartist.Bar\n * @param {String|Node} query A selector query string or directly a DOM element\n * @param {Object} data The data object that needs to consist of a labels and a series array\n * @param {Object} [options] The options object with options that override the default options. Check the examples for a detailed list.\n * @param {Array} [responsiveOptions] Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]\n * @return {Object} An object which exposes the API for the created chart\n *\n * @example\n * // These are the default options of the bar chart\n * var options = {\n * // Options for X-Axis\n * axisX: {\n * // The offset of the chart drawing area to the border of the container\n * offset: 30,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;}\n * },\n * // Options for Y-Axis\n * axisY: {\n * // The offset of the chart drawing area to the border of the container\n * offset: 40,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;},\n * // This value specifies the minimum height in pixel of the scale steps\n * scaleMinSpace: 30\n * },\n * // Specify a fixed width for the chart as a string (i.e. '100px' or '50%')\n * width: undefined,\n * // Specify a fixed height for the chart as a string (i.e. '100px' or '50%')\n * height: undefined,\n * // Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value\n * low: undefined,\n * // Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value\n * high: undefined,\n * // Padding of the chart drawing area to the container element and labels\n * chartPadding: 5,\n * // Specify the distance in pixel of bars in a group\n * seriesBarDistance: 15,\n * // Override the class names that get used to generate the SVG structure of the chart\n * classNames: {\n * chart: 'ct-chart-bar',\n * label: 'ct-label',\n * series: 'ct-series',\n * bar: 'ct-bar',\n * grid: 'ct-grid',\n * vertical: 'ct-vertical',\n * horizontal: 'ct-horizontal'\n * }\n * };\n *\n * @example\n * // Create a simple bar chart\n * var data = {\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * series: [\n * [5, 2, 4, 2, 0]\n * ]\n * };\n *\n * // In the global name space Chartist we call the Bar function to initialize a bar chart. As a first parameter we pass in a selector where we would like to get our chart created and as a second parameter we pass our data object.\n * new Chartist.Bar('.ct-chart', data);\n *\n * @example\n * // This example creates a bipolar grouped bar chart where the boundaries are limitted to -10 and 10\n * new Chartist.Bar('.ct-chart', {\n * labels: [1, 2, 3, 4, 5, 6, 7],\n * series: [\n * [1, 3, 2, -5, -3, 1, -6],\n * [-5, -2, -4, -1, 2, -3, 1]\n * ]\n * }, {\n * seriesBarDistance: 12,\n * low: -10,\n * high: 10\n * });\n *\n */\n function Bar(query, data, options, responsiveOptions) {\n Chartist.Bar.super.constructor.call(this,\n query,\n data,\n Chartist.extend(Chartist.extend({}, defaultOptions), options),\n responsiveOptions);\n }\n\n // Creating bar chart type in Chartist namespace\n Chartist.Bar = Chartist.Base.extend({\n constructor: Bar,\n createChart: createChart\n });\n\n }(window, document, Chartist));\n ;/**\n * The pie chart module of Chartist that can be used to draw pie, donut or gauge charts\n *\n * @module Chartist.Pie\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n var defaultOptions = {\n width: undefined,\n height: undefined,\n chartPadding: 5,\n classNames: {\n chart: 'ct-chart-pie',\n series: 'ct-series',\n slice: 'ct-slice',\n donut: 'ct-donut',\n label: 'ct-label'\n },\n startAngle: 0,\n total: undefined,\n donut: false,\n donutWidth: 60,\n showLabel: true,\n labelOffset: 0,\n labelInterpolationFnc: Chartist.noop,\n labelOverflow: false,\n labelDirection: 'neutral'\n };\n\n function determineAnchorPosition(center, label, direction) {\n var toTheRight = label.x > center.x;\n\n if(toTheRight && direction === 'explode' ||\n !toTheRight && direction === 'implode') {\n return 'start';\n } else if(toTheRight && direction === 'implode' ||\n !toTheRight && direction === 'explode') {\n return 'end';\n } else {\n return 'middle';\n }\n }\n\n function createChart(options) {\n var seriesGroups = [],\n chartRect,\n radius,\n labelRadius,\n totalDataSum,\n startAngle = options.startAngle,\n dataArray = Chartist.getDataArray(this.data);\n\n // Create SVG.js draw\n this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);\n // Calculate charting rect\n chartRect = Chartist.createChartRect(this.svg, options, 0, 0);\n // Get biggest circle radius possible within chartRect\n radius = Math.min(chartRect.width() / 2, chartRect.height() / 2);\n // Calculate total of all series to get reference value or use total reference from optional options\n totalDataSum = options.total || dataArray.reduce(function(previousValue, currentValue) {\n return previousValue + currentValue;\n }, 0);\n\n // If this is a donut chart we need to adjust our radius to enable strokes to be drawn inside\n // Unfortunately this is not possible with the current SVG Spec\n // See this proposal for more details: http://lists.w3.org/Archives/Public/www-svg/2003Oct/0000.html\n radius -= options.donut ? options.donutWidth / 2 : 0;\n\n // If a donut chart then the label position is at the radius, if regular pie chart it's half of the radius\n // see https://github.com/gionkunz/chartist-js/issues/21\n labelRadius = options.donut ? radius : radius / 2;\n // Add the offset to the labelRadius where a negative offset means closed to the center of the chart\n labelRadius += options.labelOffset;\n\n // Calculate end angle based on total sum and current data value and offset with padding\n var center = {\n x: chartRect.x1 + chartRect.width() / 2,\n y: chartRect.y2 + chartRect.height() / 2\n };\n\n // Check if there is only one non-zero value in the series array.\n var hasSingleValInSeries = this.data.series.filter(function(val) {\n return val !== 0;\n }).length === 1;\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < this.data.series.length; i++) {\n seriesGroups[i] = this.svg.elem('g', null, null, true);\n\n // If the series is an object and contains a name we add a custom attribute\n if(this.data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': this.data.series[i].name\n }, Chartist.xmlNs.uri);\n }\n\n // Use series class from series data or if not set generate one\n seriesGroups[i].addClass([\n options.classNames.series,\n (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i))\n ].join(' '));\n\n var endAngle = startAngle + dataArray[i] / totalDataSum * 360;\n // If we need to draw the arc for all 360 degrees we need to add a hack where we close the circle\n // with Z and use 359.99 degrees\n if(endAngle - startAngle === 360) {\n endAngle -= 0.01;\n }\n\n var start = Chartist.polarToCartesian(center.x, center.y, radius, startAngle - (i === 0 || hasSingleValInSeries ? 0 : 0.2)),\n end = Chartist.polarToCartesian(center.x, center.y, radius, endAngle),\n arcSweep = endAngle - startAngle <= 180 ? '0' : '1',\n d = [\n // Start at the end point from the cartesian coordinates\n 'M', end.x, end.y,\n // Draw arc\n 'A', radius, radius, 0, arcSweep, 0, start.x, start.y\n ];\n\n // If regular pie chart (no donut) we add a line to the center of the circle for completing the pie\n if(options.donut === false) {\n d.push('L', center.x, center.y);\n }\n\n // Create the SVG path\n // If this is a donut chart we add the donut class, otherwise just a regular slice\n var path = seriesGroups[i].elem('path', {\n d: d.join(' ')\n }, options.classNames.slice + (options.donut ? ' ' + options.classNames.donut : ''));\n\n // Adding the pie series value to the path\n path.attr({\n 'value': dataArray[i]\n }, Chartist.xmlNs.uri);\n\n // If this is a donut, we add the stroke-width as style attribute\n if(options.donut === true) {\n path.attr({\n 'style': 'stroke-width: ' + (+options.donutWidth) + 'px'\n });\n }\n\n // Fire off draw event\n this.eventEmitter.emit('draw', {\n type: 'slice',\n value: dataArray[i],\n totalDataSum: totalDataSum,\n index: i,\n group: seriesGroups[i],\n element: path,\n center: center,\n radius: radius,\n startAngle: startAngle,\n endAngle: endAngle\n });\n\n // If we need to show labels we need to add the label for this slice now\n if(options.showLabel) {\n // Position at the labelRadius distance from center and between start and end angle\n var labelPosition = Chartist.polarToCartesian(center.x, center.y, labelRadius, startAngle + (endAngle - startAngle) / 2),\n interpolatedValue = options.labelInterpolationFnc(this.data.labels ? this.data.labels[i] : dataArray[i], i);\n\n var labelElement = seriesGroups[i].elem('text', {\n dx: labelPosition.x,\n dy: labelPosition.y,\n 'text-anchor': determineAnchorPosition(center, labelPosition, options.labelDirection)\n }, options.classNames.label).text('' + interpolatedValue);\n\n // Fire off draw event\n this.eventEmitter.emit('draw', {\n type: 'label',\n index: i,\n group: seriesGroups[i],\n element: labelElement,\n text: '' + interpolatedValue,\n x: labelPosition.x,\n y: labelPosition.y\n });\n }\n\n // Set next startAngle to current endAngle. Use slight offset so there are no transparent hairline issues\n // (except for last slice)\n startAngle = endAngle;\n }\n }\n\n /**\n * This method creates a new pie chart and returns an object that can be used to redraw the chart.\n *\n * @memberof Chartist.Pie\n * @param {String|Node} query A selector query string or directly a DOM element\n * @param {Object} data The data object in the pie chart needs to have a series property with a one dimensional data array. The values will be normalized against each other and don't necessarily need to be in percentage.\n * @param {Object} [options] The options object with options that override the default options. Check the examples for a detailed list.\n * @param {Array} [responsiveOptions] Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]\n * @return {Object} An object with a version and an update method to manually redraw the chart\n *\n * @example\n * // Default options of the pie chart\n * var defaultOptions = {\n * // Specify a fixed width for the chart as a string (i.e. '100px' or '50%')\n * width: undefined,\n * // Specify a fixed height for the chart as a string (i.e. '100px' or '50%')\n * height: undefined,\n * // Padding of the chart drawing area to the container element and labels\n * chartPadding: 5,\n * // Override the class names that get used to generate the SVG structure of the chart\n * classNames: {\n * chart: 'ct-chart-pie',\n * series: 'ct-series',\n * slice: 'ct-slice',\n * donut: 'ct-donut',\n label: 'ct-label'\n * },\n * // The start angle of the pie chart in degrees where 0 points north. A higher value offsets the start angle clockwise.\n * startAngle: 0,\n * // An optional total you can specify. By specifying a total value, the sum of the values in the series must be this total in order to draw a full pie. You can use this parameter to draw only parts of a pie or gauge charts.\n * total: undefined,\n * // If specified the donut CSS classes will be used and strokes will be drawn instead of pie slices.\n * donut: false,\n * // Specify the donut stroke width, currently done in javascript for convenience. May move to CSS styles in the future.\n * donutWidth: 60,\n * // If a label should be shown or not\n * showLabel: true,\n * // Label position offset from the standard position which is half distance of the radius. This value can be either positive or negative. Positive values will position the label away from the center.\n * labelOffset: 0,\n * // An interpolation function for the label value\n * labelInterpolationFnc: function(value, index) {return value;},\n * // Label direction can be 'neutral', 'explode' or 'implode'. The labels anchor will be positioned based on those settings as well as the fact if the labels are on the right or left side of the center of the chart. Usually explode is useful when labels are positioned far away from the center.\n * labelDirection: 'neutral'\n * };\n *\n * @example\n * // Simple pie chart example with four series\n * new Chartist.Pie('.ct-chart', {\n * series: [10, 2, 4, 3]\n * });\n *\n * @example\n * // Drawing a donut chart\n * new Chartist.Pie('.ct-chart', {\n * series: [10, 2, 4, 3]\n * }, {\n * donut: true\n * });\n *\n * @example\n * // Using donut, startAngle and total to draw a gauge chart\n * new Chartist.Pie('.ct-chart', {\n * series: [20, 10, 30, 40]\n * }, {\n * donut: true,\n * donutWidth: 20,\n * startAngle: 270,\n * total: 200\n * });\n *\n * @example\n * // Drawing a pie chart with padding and labels that are outside the pie\n * new Chartist.Pie('.ct-chart', {\n * series: [20, 10, 30, 40]\n * }, {\n * chartPadding: 30,\n * labelOffset: 50,\n * labelDirection: 'explode'\n * });\n */\n function Pie(query, data, options, responsiveOptions) {\n Chartist.Pie.super.constructor.call(this,\n query,\n data,\n Chartist.extend(Chartist.extend({}, defaultOptions), options),\n responsiveOptions);\n }\n\n // Creating pie chart type in Chartist namespace\n Chartist.Pie = Chartist.Base.extend({\n constructor: Pie,\n createChart: createChart,\n determineAnchorPosition: determineAnchorPosition\n });\n\n }(window, document, Chartist));\n\n\n return Chartist;\n\n}));\n"]} \ No newline at end of file +{"version":3,"file":"chartist.min.js","sources":["chartist.js"],"names":["root","factory","exports","module","define","amd","this","Chartist","version","window","document","noop","n","alphaNumerate","String","fromCharCode","extend","target","source","prop","stripUnit","value","replace","ensureUnit","unit","querySelector","query","Node","createSvg","container","width","height","className","svg","removeChild","Svg","attr","addClass","style","appendChild","_node","getDataArray","data","array","i","series","length","undefined","j","normalizeDataArray","dataArray","orderOfMagnitude","Math","floor","log","abs","LN10","projectLength","bounds","options","availableHeight","getAvailableHeight","range","max","chartPadding","axisX","offset","getHighLow","highLow","high","Number","MAX_VALUE","low","getBounds","normalizedData","referenceValue","newMin","newMax","min","valueRange","oom","pow","ceil","step","numberOfSteps","round","scaleUp","axisY","scaleMinSpace","values","push","polarToCartesian","centerX","centerY","radius","angleInDegrees","angleInRadians","PI","x","cos","y","sin","createChartRect","yOffset","xOffset","x1","y1","x2","y2","createLabel","parent","text","attributes","supportsForeignObject","content","foreignObject","elem","createXAxis","chartRect","grid","labels","eventEmitter","forEach","index","interpolatedValue","labelInterpolationFnc","pos","showGrid","gridElement","classNames","horizontal","join","emit","type","axis","group","element","showLabel","labelPosition","labelOffset","labelElement","label",{"end":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":18760,"pos":18755,"col":16,"line":493,"value":"space","type":"name"},"start":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":18760,"pos":18755,"col":16,"line":493,"value":"space","type":"name"},"name":"space"},"space","console","warn","createYAxis","vertical","projectPoint","optionsProvider","defaultOptions","responsiveOptions","updateCurrentOptions","previousOptions","currentOptions","baseOptions","mql","matchMedia","matches","removeMediaQueryListeners","mediaQueryListeners","removeListener","addListener","deltaDescriptor","a","b","findDeltasRecursively","descriptor","__delta__","Object","keys","property","hasOwnProperty","subDescriptor","ours","theirs","summary","modified","removed","added","delta","catmullRom2bezier","crp","z","d","iLen","p","EventEmitter","addEventHandler","event","handler","handlers","removeEventHandler","splice","indexOf","starHandler","listToArray","list","arr","properties","superProtoOverride","superProto","prototype","Class","proto","create","cloneDefinitions","constr","instance","fn","constructor","apply","Array","slice","call","arguments","super","mix","mixProtoArr","Error","superPrototypes","concat","map","Function","mixedSuperProto","args","getOwnPropertyNames","propName","defineProperty","getOwnPropertyDescriptor","update","createChart","detach","removeEventListener","resizeListener","on","off","Base","isSupported","supportsAnimations","bind","__chartist__","addEventListener","setTimeout","name","insertFirst","createElementNS","svgNs","setAttributeNS","xmlNs","qualifiedName","uri","firstChild","insertBefore","_parent","ns","key","prefix","setAttribute","createElement","innerHTML","xhtmlNs","fnObj","t","createTextNode","empty","remove","parentNode","newElement","replaceChild","append","classes","getAttribute","trim","split","names","filter","self","removeClass","removedClasses","removeAllClasses","clientHeight","getBBox","clientWidth","animate","animations","guided","attribute","createAnimate","animationDefinition","easing","attributeProperties","Easing","fill","from","calcMode","keySplines","keyTimes","begin","dur","attributeName","params","to","feature","implementation","hasFeature","easingCubicBeziers","easeInSine","easeOutSine","easeInOutSine","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","seriesGroups","chart","series-name","point","pathCoordinates","showPoint","showLine","showArea","pathElements","lineSmooth","cr","k","l","areaBase","areaPathElements","areaBaseProjected","area","line","Line","zeroPoint","biPol","periodHalfWidth","bar","seriesBarDistance","Bar","determineAnchorPosition","center","direction","toTheRight","labelRadius","totalDataSum","startAngle","total","reduce","previousValue","currentValue","donut","donutWidth","hasSingleValInSeries","val","endAngle","start","end","arcSweep","path","dx","dy","text-anchor","labelDirection","Pie","labelOverflow"],"mappings":";;;;;;CAAC,SAASA,EAAMC,GACU,gBAAZC,SACNC,OAAOD,QAAUD,IAEK,kBAAXG,SAAyBA,OAAOC,IAC3CD,UAAWH,GAGXD,EAAe,SAAIC,KAEzBK,KAAM,WAYN,GAAIC,KAi+EJ,OAh+EAA,GAASC,QAAU,QAElB,SAAUC,EAAQC,EAAUH,GAC3B,YASAA,GAASI,KAAO,SAAUC,GACxB,MAAOA,IAUTL,EAASM,cAAgB,SAAUD,GAEjC,MAAOE,QAAOC,aAAa,GAAKH,EAAI,KAYtCL,EAASS,OAAS,SAAUC,EAAQC,GAClCD,EAASA,KACT,KAAK,GAAIE,KAAQD,GAEbD,EAAOE,GADmB,gBAAjBD,GAAOC,GACDZ,EAASS,OAAOC,EAAOE,GAAOD,EAAOC,IAErCD,EAAOC,EAG1B,OAAOF,IAUTV,EAASa,UAAY,SAASC,GAK5B,MAJoB,gBAAVA,KACRA,EAAQA,EAAMC,QAAQ,cAAe,MAG/BD,GAWVd,EAASgB,WAAa,SAASF,EAAOG,GAKpC,MAJoB,gBAAVH,KACRA,GAAgBG,GAGXH,GAUTd,EAASkB,cAAgB,SAASC,GAChC,MAAOA,aAAiBC,MAAOD,EAAQhB,EAASe,cAAcC,IAahEnB,EAASqB,UAAY,SAAUC,EAAWC,EAAOC,EAAQC,GACvD,GAAIC,EAqBJ,OAnBAH,GAAQA,GAAS,OACjBC,EAASA,GAAU,OAEnBE,EAAMJ,EAAUJ,cAAc,OAC3BQ,GACDJ,EAAUK,YAAYD,GAIxBA,EAAM,GAAI1B,GAAS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AAQ3N,EAAe/E,EAAQgU,iBACrEhU,EAAQsE,WAAWY,OAAO9B,KAAK,GAAKa,EAGvCtH,MAAKmH,aAAaW,KAAK,QACrBC,KAAM,QACNV,MAAO/E,EACP2F,MAAOoM,EAAa/R,GACpB4F,QAASI,EACT7B,KAAM,GAAKa,EACX1B,EAAGwC,EAAcxC,EACjBE,EAAGsC,EAActC,IAMrBsQ,EAAaS,EAGf7W,KAAKmH,aAAaW,KAAK,WACrBd,UAAWA,EACXrF,IAAK3B,KAAK2B,IACV0B,QAASA,IAoFb,QAASiU,GAAIlW,EAAOgB,EAAMiB,EAAS4F,GACjChJ,EAASqX,IAAIpK,MAAMN,YAAYI,KAAKhN,KAClCoB,EACAgB,EACAnC,EAASS,OAAOT,EAASS,UAAWsI,GAAiB3F,GACrD4F,GA/QJ,GAAID,IACFxH,MAAOiB,OACPhB,OAAQgB,OACRiB,aAAc,EACdiE,YACE2M,MAAO,eACP/R,OAAQ,YACRwK,MAAO,WACP0J,MAAO,WACPlO,MAAO,YAET6N,WAAY,EACZC,MAAO5T,OACPgU,OAAO,EACPC,WAAY,GACZvO,WAAW,EACXE,YAAa,EACbd,sBAAuBtH,EAASI,KAChCkX,eAAe,EACfF,eAAgB,UAgQlBpX,GAASqX,IAAMrX,EAASsO,KAAK7N,QAC3BkM,YAAa0K,EACbrJ,YAAaA,EACb6H,wBAAyBA,KAG3B3V,OAAQC,SAAUH,GAGbA","sourcesContent":["(function(root, factory) {\n if(typeof exports === 'object') {\n module.exports = factory();\n }\n else if(typeof define === 'function' && define.amd) {\n define([], factory);\n }\n else {\n root['Chartist'] = factory();\n }\n}(this, function() {\n\n /* Chartist.js 0.4.0\n * Copyright © 2014 Gion Kunz\n * Free to use under the WTFPL license.\n * http://www.wtfpl.net/\n */\n /**\n * The core module of Chartist that is mainly providing static functions and higher level functions for chart modules.\n *\n * @module Chartist.Core\n */\n var Chartist = {};\n Chartist.version = '0.3.1';\n\n (function (window, document, Chartist) {\n 'use strict';\n\n /**\n * Helps to simplify functional style code\n *\n * @memberof Chartist.Core\n * @param {*} n This exact value will be returned by the noop function\n * @return {*} The same value that was provided to the n parameter\n */\n Chartist.noop = function (n) {\n return n;\n };\n\n /**\n * Generates a-z from a number 0 to 26\n *\n * @memberof Chartist.Core\n * @param {Number} n A number from 0 to 26 that will result in a letter a-z\n * @return {String} A character from a-z based on the input number n\n */\n Chartist.alphaNumerate = function (n) {\n // Limit to a-z\n return String.fromCharCode(97 + n % 26);\n };\n\n // TODO: Make it possible to call extend with var args\n /**\n * Simple recursive object extend\n *\n * @memberof Chartist.Core\n * @param {Object} target Target object where the source will be merged into\n * @param {Object} source This object will be merged into target and then target is returned\n * @return {Object} An object that has the same reference as target but is extended and merged with the properties of source\n */\n Chartist.extend = function (target, source) {\n target = target || {};\n for (var prop in source) {\n if (typeof source[prop] === 'object') {\n target[prop] = Chartist.extend(target[prop], source[prop]);\n } else {\n target[prop] = source[prop];\n }\n }\n return target;\n };\n\n /**\n * Converts a string to a number while removing the unit if present. If a number is passed then this will be returned unmodified.\n *\n * @memberof Chartist.Core\n * @param {String|Number} value\n * @returns {Number} Returns the string as number or NaN if the passed length could not be converted to pixel\n */\n Chartist.stripUnit = function(value) {\n if(typeof value === 'string') {\n value = value.replace(/[^0-9\\+-\\.]/, '');\n }\n\n return +value;\n };\n\n /**\n * Converts a number to a string with a unit. If a string is passed then this will be returned unmodified.\n *\n * @memberof Chartist.Core\n * @param {Number} value\n * @param {String} unit\n * @returns {String} Returns the passed number value with unit.\n */\n Chartist.ensureUnit = function(value, unit) {\n if(typeof value === 'number') {\n value = value + unit;\n }\n\n return value;\n };\n\n /**\n * This is a wrapper around document.querySelector that will return the query if it's already of type Node\n *\n * @memberof Chartist.Core\n * @param {String|Node} query The query to use for selecting a Node or a DOM node that will be returned directly\n * @return {Node}\n */\n Chartist.querySelector = function(query) {\n return query instanceof Node ? query : document.querySelector(query);\n };\n\n /**\n * Create or reinitialize the SVG element for the chart\n *\n * @memberof Chartist.Core\n * @param {Node} container The containing DOM Node object that will be used to plant the SVG element\n * @param {String} width Set the width of the SVG element. Default is 100%\n * @param {String} height Set the height of the SVG element. Default is 100%\n * @param {String} className Specify a class to be added to the SVG element\n * @return {Object} The created/reinitialized SVG element\n */\n Chartist.createSvg = function (container, width, height, className) {\n var svg;\n\n width = width || '100%';\n height = height || '100%';\n\n svg = container.querySelector('svg');\n if(svg) {\n container.removeChild(svg);\n }\n\n // Create svg object with width and height or use 100% as default\n svg = new Chartist.Svg('svg').attr({\n width: width,\n height: height\n }).addClass(className).attr({\n style: 'width: ' + width + '; height: ' + height + ';'\n });\n\n // Add the DOM node to our container\n container.appendChild(svg._node);\n\n return svg;\n };\n\n /**\n * Convert data series into plain array\n *\n * @memberof Chartist.Core\n * @param {Object} data The series object that contains the data to be visualized in the chart\n * @return {Array} A plain array that contains the data to be visualized in the chart\n */\n Chartist.getDataArray = function (data) {\n var array = [];\n\n for (var i = 0; i < data.series.length; i++) {\n // If the series array contains an object with a data property we will use the property\n // otherwise the value directly (array or number)\n array[i] = typeof(data.series[i]) === 'object' && data.series[i].data !== undefined ?\n data.series[i].data : data.series[i];\n\n // Convert values to number\n for (var j = 0; j < array[i].length; j++) {\n array[i][j] = +array[i][j];\n }\n }\n\n return array;\n };\n\n /**\n * Adds missing values at the end of the array. This array contains the data, that will be visualized in the chart\n *\n * @memberof Chartist.Core\n * @param {Array} dataArray The array that contains the data to be visualized in the chart. The array in this parameter will be modified by function.\n * @param {Number} length The length of the x-axis data array.\n * @return {Array} The array that got updated with missing values.\n */\n Chartist.normalizeDataArray = function (dataArray, length) {\n for (var i = 0; i < dataArray.length; i++) {\n if (dataArray[i].length === length) {\n continue;\n }\n\n for (var j = dataArray[i].length; j < length; j++) {\n dataArray[i][j] = 0;\n }\n }\n\n return dataArray;\n };\n\n /**\n * Calculate the order of magnitude for the chart scale\n *\n * @memberof Chartist.Core\n * @param {Number} value The value Range of the chart\n * @return {Number} The order of magnitude\n */\n Chartist.orderOfMagnitude = function (value) {\n return Math.floor(Math.log(Math.abs(value)) / Math.LN10);\n };\n\n /**\n * Project a data length into screen coordinates (pixels)\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Number} length Single data value from a series array\n * @param {Object} bounds All the values to set the bounds of the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @return {Number} The projected data length in pixels\n */\n Chartist.projectLength = function (svg, length, bounds, options) {\n var availableHeight = Chartist.getAvailableHeight(svg, options);\n return (length / bounds.range * availableHeight);\n };\n\n /**\n * Get the height of the area in the chart for the data series\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @return {Number} The height of the area in the chart for the data series\n */\n Chartist.getAvailableHeight = function (svg, options) {\n return Math.max((Chartist.stripUnit(options.height) || svg.height()) - (options.chartPadding * 2) - options.axisX.offset, 0);\n };\n\n /**\n * Get highest and lowest value of data array. This Array contains the data that will be visualized in the chart.\n *\n * @memberof Chartist.Core\n * @param {Array} dataArray The array that contains the data to be visualized in the chart\n * @return {Array} The array that contains the highest and lowest value that will be visualized on the chart.\n */\n Chartist.getHighLow = function (dataArray) {\n var i,\n j,\n highLow = {\n high: -Number.MAX_VALUE,\n low: Number.MAX_VALUE\n };\n\n for (i = 0; i < dataArray.length; i++) {\n for (j = 0; j < dataArray[i].length; j++) {\n if (dataArray[i][j] > highLow.high) {\n highLow.high = dataArray[i][j];\n }\n\n if (dataArray[i][j] < highLow.low) {\n highLow.low = dataArray[i][j];\n }\n }\n }\n\n return highLow;\n };\n\n // Find the highest and lowest values in a two dimensional array and calculate scale based on order of magnitude\n /**\n * Calculate and retrieve all the bounds for the chart and return them in one array\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Array} normalizedData The array that got updated with missing values.\n * @param {Object} options The Object that contains all the optional values for the chart\n * @param {Number} referenceValue The reference value for the chart.\n * @return {Object} All the values to set the bounds of the chart\n */\n Chartist.getBounds = function (svg, normalizedData, options, referenceValue) {\n var i,\n newMin,\n newMax,\n bounds = Chartist.getHighLow(normalizedData);\n\n // Overrides of high / low from settings\n bounds.high = +options.high || (options.high === 0 ? 0 : bounds.high);\n bounds.low = +options.low || (options.low === 0 ? 0 : bounds.low);\n\n // If high and low are the same because of misconfiguration or flat data (only the same value) we need\n // to set the high or low to 0 depending on the polarity\n if(bounds.high === bounds.low) {\n // If both values are 0 we set high to 1\n if(bounds.low === 0) {\n bounds.high = 1;\n } else if(bounds.low < 0) {\n // If we have the same negative value for the bounds we set bounds.high to 0\n bounds.high = 0;\n } else {\n // If we have the same positive value for the bounds we set bounds.low to 0\n bounds.low = 0;\n }\n }\n\n // Overrides of high / low based on reference value, it will make sure that the invisible reference value is\n // used to generate the chart. This is useful when the chart always needs to contain the position of the\n // invisible reference value in the view i.e. for bipolar scales.\n if (referenceValue || referenceValue === 0) {\n bounds.high = Math.max(referenceValue, bounds.high);\n bounds.low = Math.min(referenceValue, bounds.low);\n }\n\n bounds.valueRange = bounds.high - bounds.low;\n bounds.oom = Chartist.orderOfMagnitude(bounds.valueRange);\n bounds.min = Math.floor(bounds.low / Math.pow(10, bounds.oom)) * Math.pow(10, bounds.oom);\n bounds.max = Math.ceil(bounds.high / Math.pow(10, bounds.oom)) * Math.pow(10, bounds.oom);\n bounds.range = bounds.max - bounds.min;\n bounds.step = Math.pow(10, bounds.oom);\n bounds.numberOfSteps = Math.round(bounds.range / bounds.step);\n\n // Optimize scale step by checking if subdivision is possible based on horizontalGridMinSpace\n // If we are already below the scaleMinSpace value we will scale up\n var length = Chartist.projectLength(svg, bounds.step, bounds, options),\n scaleUp = length < options.axisY.scaleMinSpace;\n\n while (true) {\n if (scaleUp && Chartist.projectLength(svg, bounds.step, bounds, options) <= options.axisY.scaleMinSpace) {\n bounds.step *= 2;\n } else if (!scaleUp && Chartist.projectLength(svg, bounds.step / 2, bounds, options) >= options.axisY.scaleMinSpace) {\n bounds.step /= 2;\n } else {\n break;\n }\n }\n\n // Narrow min and max based on new step\n newMin = bounds.min;\n newMax = bounds.max;\n for (i = bounds.min; i <= bounds.max; i += bounds.step) {\n if (i + bounds.step < bounds.low) {\n newMin += bounds.step;\n }\n\n if (i - bounds.step >= bounds.high) {\n newMax -= bounds.step;\n }\n }\n bounds.min = newMin;\n bounds.max = newMax;\n bounds.range = bounds.max - bounds.min;\n\n bounds.values = [];\n for (i = bounds.min; i <= bounds.max; i += bounds.step) {\n bounds.values.push(i);\n }\n\n return bounds;\n };\n\n /**\n * Calculate cartesian coordinates of polar coordinates\n *\n * @memberof Chartist.Core\n * @param {Number} centerX X-axis coordinates of center point of circle segment\n * @param {Number} centerY X-axis coordinates of center point of circle segment\n * @param {Number} radius Radius of circle segment\n * @param {Number} angleInDegrees Angle of circle segment in degrees\n * @return {Number} Coordinates of point on circumference\n */\n Chartist.polarToCartesian = function (centerX, centerY, radius, angleInDegrees) {\n var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;\n\n return {\n x: centerX + (radius * Math.cos(angleInRadians)),\n y: centerY + (radius * Math.sin(angleInRadians))\n };\n };\n\n /**\n * Initialize chart drawing rectangle (area where chart is drawn) x1,y1 = bottom left / x2,y2 = top right\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @return {Object} The chart rectangles coordinates inside the svg element plus the rectangles measurements\n */\n Chartist.createChartRect = function (svg, options) {\n var yOffset = options.axisY ? options.axisY.offset : 0,\n xOffset = options.axisX ? options.axisX.offset : 0;\n\n return {\n x1: options.chartPadding + yOffset,\n y1: Math.max((Chartist.stripUnit(options.height) || svg.height()) - options.chartPadding - xOffset, options.chartPadding),\n x2: Math.max((Chartist.stripUnit(options.width) || svg.width()) - options.chartPadding, options.chartPadding + yOffset),\n y2: options.chartPadding,\n width: function () {\n return this.x2 - this.x1;\n },\n height: function () {\n return this.y1 - this.y2;\n }\n };\n };\n\n /**\n * Creates a label with text and based on support of SVG1.1 extensibility will use a foreignObject with a SPAN element or a fallback to a regular SVG text element.\n *\n * @param {Object} parent The SVG element where the label should be created as a child\n * @param {String} text The label text\n * @param {Object} attributes An object with all attributes that should be set on the label element\n * @param {String} className The class names that should be set for this element\n * @param {Boolean} supportsForeignObject If this is true then a foreignObject will be used instead of a text element\n * @returns {Object} The newly created SVG element\n */\n Chartist.createLabel = function(parent, text, attributes, className, supportsForeignObject) {\n if(supportsForeignObject) {\n var content = '' + text + '';\n return parent.foreignObject(content, attributes);\n } else {\n return parent.elem('text', attributes, className).text(text);\n }\n };\n\n /**\n * Generate grid lines and labels for the x-axis into grid and labels group SVG elements\n *\n * @memberof Chartist.Core\n * @param {Object} chartRect The rectangle that sets the bounds for the chart in the svg element\n * @param {Object} data The Object that contains the data to be visualized in the chart\n * @param {Object} grid Chartist.Svg wrapper object to be filled with the grid lines of the chart\n * @param {Object} labels Chartist.Svg wrapper object to be filled with the lables of the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @param {Object} eventEmitter The passed event emitter will be used to emit draw events for labels and gridlines\n * @param {Boolean} supportsForeignObject If this is true then a foreignObject will be used instead of a text element\n */\n Chartist.createXAxis = function (chartRect, data, grid, labels, options, eventEmitter, supportsForeignObject) {\n // Create X-Axis\n data.labels.forEach(function (value, index) {\n var interpolatedValue = options.axisX.labelInterpolationFnc(value, index),\n width = chartRect.width() / data.labels.length,\n height = options.axisX.offset,\n pos = chartRect.x1 + width * index;\n\n // If interpolated value returns falsey (except 0) we don't draw the grid line\n if (!interpolatedValue && interpolatedValue !== 0) {\n return;\n }\n\n if (options.axisX.showGrid) {\n var gridElement = grid.elem('line', {\n x1: pos,\n y1: chartRect.y1,\n x2: pos,\n y2: chartRect.y2\n }, [options.classNames.grid, options.classNames.horizontal].join(' '));\n\n // Event for grid draw\n eventEmitter.emit('draw', {\n type: 'grid',\n axis: 'x',\n index: index,\n group: grid,\n element: gridElement,\n x1: pos,\n y1: chartRect.y1,\n x2: pos,\n y2: chartRect.y2\n });\n }\n\n if (options.axisX.showLabel) {\n var labelPosition = {\n x: pos + options.axisX.labelOffset.x,\n y: chartRect.y1 + options.axisX.labelOffset.y + (supportsForeignObject ? 5 : 20)\n };\n\n var labelElement = Chartist.createLabel(labels, '' + interpolatedValue, {\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n style: 'overflow: visible;'\n }, [options.classNames.label, options.classNames.horizontal].join(' '), supportsForeignObject);\n\n eventEmitter.emit('draw', {\n type: 'label',\n axis: 'x',\n index: index,\n group: labels,\n element: labelElement,\n text: '' + interpolatedValue,\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n // TODO: Remove in next major release\n get space() {\n window.console.warn('EventEmitter: space is deprecated, use width or height instead.');\n return this.width;\n }\n });\n }\n });\n };\n\n /**\n * Generate grid lines and labels for the y-axis into grid and labels group SVG elements\n *\n * @memberof Chartist.Core\n * @param {Object} chartRect The rectangle that sets the bounds for the chart in the svg element\n * @param {Object} bounds All the values to set the bounds of the chart\n * @param {Object} grid Chartist.Svg wrapper object to be filled with the grid lines of the chart\n * @param {Object} labels Chartist.Svg wrapper object to be filled with the lables of the chart\n * @param {Object} options The Object that contains all the optional values for the chart\n * @param {Object} eventEmitter The passed event emitter will be used to emit draw events for labels and gridlines\n * @param {Boolean} supportsForeignObject If this is true then a foreignObject will be used instead of a text element\n */\n Chartist.createYAxis = function (chartRect, bounds, grid, labels, options, eventEmitter, supportsForeignObject) {\n // Create Y-Axis\n bounds.values.forEach(function (value, index) {\n var interpolatedValue = options.axisY.labelInterpolationFnc(value, index),\n width = options.axisY.offset,\n height = chartRect.height() / bounds.values.length,\n pos = chartRect.y1 - height * index;\n\n // If interpolated value returns falsey (except 0) we don't draw the grid line\n if (!interpolatedValue && interpolatedValue !== 0) {\n return;\n }\n\n if (options.axisY.showGrid) {\n var gridElement = grid.elem('line', {\n x1: chartRect.x1,\n y1: pos,\n x2: chartRect.x2,\n y2: pos\n }, [options.classNames.grid, options.classNames.vertical].join(' '));\n\n // Event for grid draw\n eventEmitter.emit('draw', {\n type: 'grid',\n axis: 'y',\n index: index,\n group: grid,\n element: gridElement,\n x1: chartRect.x1,\n y1: pos,\n x2: chartRect.x2,\n y2: pos\n });\n }\n\n if (options.axisY.showLabel) {\n var labelPosition = {\n x: options.chartPadding + options.axisY.labelOffset.x + (supportsForeignObject ? -10 : 0),\n y: pos + options.axisY.labelOffset.y + (supportsForeignObject ? -15 : 0)\n };\n\n var labelElement = Chartist.createLabel(labels, '' + interpolatedValue, {\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n style: 'overflow: visible;'\n }, [options.classNames.label, options.classNames.vertical].join(' '), supportsForeignObject);\n\n eventEmitter.emit('draw', {\n type: 'label',\n axis: 'y',\n index: index,\n group: labels,\n element: labelElement,\n text: '' + interpolatedValue,\n x: labelPosition.x,\n y: labelPosition.y,\n width: width,\n height: height,\n // TODO: Remove in next major release\n get space() {\n window.console.warn('EventEmitter: space is deprecated, use width or height instead.');\n return this.height;\n }\n });\n }\n });\n };\n\n /**\n * Determine the current point on the svg element to draw the data series\n *\n * @memberof Chartist.Core\n * @param {Object} chartRect The rectangle that sets the bounds for the chart in the svg element\n * @param {Object} bounds All the values to set the bounds of the chart\n * @param {Array} data The array that contains the data to be visualized in the chart\n * @param {Number} index The index of the current project point\n * @return {Object} The coordinates object of the current project point containing an x and y number property\n */\n Chartist.projectPoint = function (chartRect, bounds, data, index) {\n return {\n x: chartRect.x1 + chartRect.width() / data.length * index,\n y: chartRect.y1 - chartRect.height() * (data[index] - bounds.min) / (bounds.range + bounds.step)\n };\n };\n\n // TODO: With multiple media queries the handleMediaChange function is triggered too many times, only need one\n /**\n * Provides options handling functionality with callback for options changes triggered by responsive options and media query matches\n *\n * @memberof Chartist.Core\n * @param {Object} defaultOptions Default options from Chartist\n * @param {Object} options Options set by user\n * @param {Array} responsiveOptions Optional functions to add responsive behavior to chart\n * @param {Object} eventEmitter The event emitter that will be used to emit the options changed events\n * @return {Object} The consolidated options object from the defaults, base and matching responsive options\n */\n Chartist.optionsProvider = function (defaultOptions, options, responsiveOptions, eventEmitter) {\n var baseOptions = Chartist.extend(Chartist.extend({}, defaultOptions), options),\n currentOptions,\n mediaQueryListeners = [],\n i;\n\n function updateCurrentOptions() {\n var previousOptions = currentOptions;\n currentOptions = Chartist.extend({}, baseOptions);\n\n if (responsiveOptions) {\n for (i = 0; i < responsiveOptions.length; i++) {\n var mql = window.matchMedia(responsiveOptions[i][0]);\n if (mql.matches) {\n currentOptions = Chartist.extend(currentOptions, responsiveOptions[i][1]);\n }\n }\n }\n\n if(eventEmitter) {\n eventEmitter.emit('optionsChanged', {\n previousOptions: previousOptions,\n currentOptions: currentOptions\n });\n }\n }\n\n function removeMediaQueryListeners() {\n mediaQueryListeners.forEach(function(mql) {\n mql.removeListener(updateCurrentOptions);\n });\n }\n\n if (!window.matchMedia) {\n throw 'window.matchMedia not found! Make sure you\\'re using a polyfill.';\n } else if (responsiveOptions) {\n\n for (i = 0; i < responsiveOptions.length; i++) {\n var mql = window.matchMedia(responsiveOptions[i][0]);\n mql.addListener(updateCurrentOptions);\n mediaQueryListeners.push(mql);\n }\n }\n // Execute initially so we get the correct options\n updateCurrentOptions();\n\n return {\n get currentOptions() {\n return Chartist.extend({}, currentOptions);\n },\n removeMediaQueryListeners: removeMediaQueryListeners\n };\n };\n\n //TODO: For arrays it would be better to take the sequence into account and try to minimize modify deltas\n /**\n * This method will analyze deltas recursively in two objects. The returned object will contain a __delta__ property\n * where deltas for specific object properties can be found for the given object nesting level. For nested objects the\n * resulting delta descriptor object will contain properties to reflect the nesting. Nested descriptor objects also\n * contain a __delta__ property with the deltas of their level.\n *\n * @param {Object|Array} a Object that should be used to analyzed delta to object b\n * @param {Object|Array} b The second object where the deltas from a should be analyzed\n * @returns {Object} Delta descriptor object or null\n */\n Chartist.deltaDescriptor = function(a, b) {\n var summary = {\n added: 0,\n removed: 0,\n modified: 0\n };\n\n function findDeltasRecursively(a, b) {\n var descriptor = {\n __delta__: {}\n };\n\n // First check for removed and modified properties\n Object.keys(a).forEach(function(property) {\n if(!b.hasOwnProperty(property)) {\n descriptor.__delta__[property] = {\n type: 'remove',\n property: property,\n ours: a[property]\n };\n summary.removed++;\n } else {\n if(typeof a[property] === 'object') {\n var subDescriptor = findDeltasRecursively(a[property], b[property]);\n if(subDescriptor) {\n descriptor[property] = subDescriptor;\n }\n } else {\n if(a[property] !== b[property]) {\n descriptor.__delta__[property] = {\n type: 'modify',\n property: property,\n ours: a[property],\n theirs: b[property]\n };\n summary.modified++;\n }\n }\n }\n });\n\n // Check for added properties\n Object.keys(b).forEach(function(property) {\n if(!a.hasOwnProperty(property)) {\n descriptor.__delta__[property] = {\n type: 'added',\n property: property,\n theirs: b[property]\n };\n summary.added++;\n }\n });\n\n return (Object.keys(descriptor).length !== 1 || Object.keys(descriptor.__delta__).length > 0) ? descriptor : null;\n }\n\n var delta = findDeltasRecursively(a, b);\n if(delta) {\n delta.__delta__.summary = summary;\n }\n\n return delta;\n };\n\n //http://schepers.cc/getting-to-the-point\n Chartist.catmullRom2bezier = function (crp, z) {\n var d = [];\n for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {\n var p = [\n {x: +crp[i - 2], y: +crp[i - 1]},\n {x: +crp[i], y: +crp[i + 1]},\n {x: +crp[i + 2], y: +crp[i + 3]},\n {x: +crp[i + 4], y: +crp[i + 5]}\n ];\n if (z) {\n if (!i) {\n p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};\n } else if (iLen - 4 === i) {\n p[3] = {x: +crp[0], y: +crp[1]};\n } else if (iLen - 2 === i) {\n p[2] = {x: +crp[0], y: +crp[1]};\n p[3] = {x: +crp[2], y: +crp[3]};\n }\n } else {\n if (iLen - 4 === i) {\n p[3] = p[2];\n } else if (!i) {\n p[0] = {x: +crp[i], y: +crp[i + 1]};\n }\n }\n d.push(\n [\n (-p[0].x + 6 * p[1].x + p[2].x) / 6,\n (-p[0].y + 6 * p[1].y + p[2].y) / 6,\n (p[1].x + 6 * p[2].x - p[3].x) / 6,\n (p[1].y + 6 * p[2].y - p[3].y) / 6,\n p[2].x,\n p[2].y\n ]\n );\n }\n\n return d;\n };\n\n }(window, document, Chartist));\n ;/**\n * A very basic event module that helps to generate and catch events.\n *\n * @module Chartist.Event\n */\n /* global Chartist */\n (function (window, document, Chartist) {\n 'use strict';\n\n Chartist.EventEmitter = function () {\n var handlers = [];\n\n /**\n * Add an event handler for a specific event\n *\n * @memberof Chartist.Event\n * @param {String} event The event name\n * @param {Function} handler A event handler function\n */\n function addEventHandler(event, handler) {\n handlers[event] = handlers[event] || [];\n handlers[event].push(handler);\n }\n\n /**\n * Remove an event handler of a specific event name or remove all event handlers for a specific event.\n *\n * @memberof Chartist.Event\n * @param {String} event The event name where a specific or all handlers should be removed\n * @param {Function} [handler] An optional event handler function. If specified only this specific handler will be removed and otherwise all handlers are removed.\n */\n function removeEventHandler(event, handler) {\n // Only do something if there are event handlers with this name existing\n if(handlers[event]) {\n // If handler is set we will look for a specific handler and only remove this\n if(handler) {\n handlers[event].splice(handlers[event].indexOf(handler), 1);\n if(handlers[event].length === 0) {\n delete handlers[event];\n }\n } else {\n // If no handler is specified we remove all handlers for this event\n delete handlers[event];\n }\n }\n }\n\n /**\n * Use this function to emit an event. All handlers that are listening for this event will be triggered with the data parameter.\n *\n * @memberof Chartist.Event\n * @param {String} event The event name that should be triggered\n * @param {*} data Arbitrary data that will be passed to the event handler callback functions\n */\n function emit(event, data) {\n // Only do something if there are event handlers with this name existing\n if(handlers[event]) {\n handlers[event].forEach(function(handler) {\n handler(data);\n });\n }\n\n // Emit event to star event handlers\n if(handlers['*']) {\n handlers['*'].forEach(function(starHandler) {\n starHandler(event, data);\n });\n }\n }\n\n return {\n addEventHandler: addEventHandler,\n removeEventHandler: removeEventHandler,\n emit: emit\n };\n };\n\n }(window, document, Chartist));\n ;/**\n * This module provides some basic prototype inheritance utilities.\n *\n * @module Chartist.Class\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n function listToArray(list) {\n var arr = [];\n if (list.length) {\n for (var i = 0; i < list.length; i++) {\n arr.push(list[i]);\n }\n }\n return arr;\n }\n\n /**\n * Method to extend from current prototype.\n *\n * @memberof Chartist.Class\n * @param {Object} properties The object that serves as definition for the prototype that gets created for the new class. This object should always contain a constructor property that is the desired constructor for the newly created class.\n * @param {Object} [superProtoOverride] By default extens will use the current class prototype or Chartist.class. With this parameter you can specify any super prototype that will be used.\n * @returns {Function} Constructor function of the new class\n *\n * @example\n * var Fruit = Class.extend({\n * color: undefined,\n * sugar: undefined,\n *\n * constructor: function(color, sugar) {\n * this.color = color;\n * this.sugar = sugar;\n * },\n *\n * eat: function() {\n * this.sugar = 0;\n * return this;\n * }\n * });\n *\n * var Banana = Fruit.extend({\n * length: undefined,\n *\n * constructor: function(length, sugar) {\n * Banana.super.constructor.call(this, 'Yellow', sugar);\n * this.length = length;\n * }\n * });\n *\n * var banana = new Banana(20, 40);\n * console.log('banana instanceof Fruit', banana instanceof Fruit);\n * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));\n * console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);\n * console.log(banana.sugar);\n * console.log(banana.eat().sugar);\n * console.log(banana.color);\n */\n function extend(properties, superProtoOverride) {\n var superProto = superProtoOverride || this.prototype || Chartist.Class;\n var proto = Object.create(superProto);\n\n Chartist.Class.cloneDefinitions(proto, properties);\n\n var constr = function() {\n var fn = proto.constructor || function () {},\n instance;\n\n // If this is linked to the Chartist namespace the constructor was not called with new\n // To provide a fallback we will instantiate here and return the instance\n instance = this === Chartist ? Object.create(proto) : this;\n fn.apply(instance, Array.prototype.slice.call(arguments, 0));\n\n // If this constructor was not called with new we need to return the instance\n // This will not harm when the constructor has been called with new as the returned value is ignored\n return instance;\n };\n\n constr.prototype = proto;\n constr.super = superProto;\n constr.extend = this.extend;\n\n return constr;\n }\n\n /**\n * Creates a mixin from multiple super prototypes.\n *\n * @memberof Chartist.Class\n * @param {Array} mixProtoArr An array of super prototypes or an array of super prototype constructors.\n * @param {Object} properties The object that serves as definition for the prototype that gets created for the new class. This object should always contain a constructor property that is the desired constructor for the newly created class.\n * @returns {Function} Constructor function of the newly created mixin class\n *\n * @example\n * var Fruit = Class.extend({\n * color: undefined,\n * sugar: undefined,\n *\n * constructor: function(color, sugar) {\n * this.color = color;\n * this.sugar = sugar;\n * },\n *\n * eat: function() {\n * this.sugar = 0;\n * return this;\n * }\n * });\n *\n * var Banana = Fruit.extend({\n * length: undefined,\n *\n * constructor: function(length, sugar) {\n * Banana.super.constructor.call(this, 'Yellow', sugar);\n * this.length = length;\n * }\n * });\n *\n * var banana = new Banana(20, 40);\n * console.log('banana instanceof Fruit', banana instanceof Fruit);\n * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));\n * console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);\n * console.log(banana.sugar);\n * console.log(banana.eat().sugar);\n * console.log(banana.color);\n *\n *\n * var KCal = Class.extend({\n * sugar: 0,\n *\n * constructor: function(sugar) {\n * this.sugar = sugar;\n * },\n *\n * get kcal() {\n * return [this.sugar * 4, 'kcal'].join('');\n * }\n * });\n *\n * var Nameable = Class.extend({\n * name: undefined,\n *\n * constructor: function(name) {\n * this.name = name;\n * }\n * });\n *\n * var NameableKCalBanana = Class.mix([Banana, KCal, Nameable], {\n * constructor: function(name, length, sugar) {\n * Nameable.prototype.constructor.call(this, name);\n * Banana.prototype.constructor.call(this, length, sugar);\n * },\n *\n * toString: function() {\n * return [this.name, 'with', this.length + 'cm', 'and', this.kcal].join(' ');\n * }\n * });\n *\n *\n *\n * var banana = new Banana(20, 40);\n * console.log('banana instanceof Fruit', banana instanceof Fruit);\n * console.log('Fruit is prototype of banana', Fruit.prototype.isPrototypeOf(banana));\n * console.log('bananas prototype is Fruit', Object.getPrototypeOf(banana) === Fruit.prototype);\n * console.log(banana.sugar);\n * console.log(banana.eat().sugar);\n * console.log(banana.color);\n *\n * var superBanana = new NameableKCalBanana('Super Mixin Banana', 30, 80);\n * console.log(superBanana.toString());\n *\n */\n function mix(mixProtoArr, properties) {\n if(this !== Chartist.Class) {\n throw new Error('Chartist.Class.mix should only be called on the type and never on an instance!');\n }\n\n // Make sure our mixin prototypes are the class objects and not the constructors\n var superPrototypes = [{}]\n .concat(mixProtoArr)\n .map(function (prototype) {\n return prototype instanceof Function ? prototype.prototype : prototype;\n });\n\n var mixedSuperProto = Chartist.Class.cloneDefinitions.apply(undefined, superPrototypes);\n // Delete the constructor if present because we don't want to invoke a constructor on a mixed prototype\n delete mixedSuperProto.constructor;\n return this.extend(properties, mixedSuperProto);\n }\n\n // Variable argument list clones args > 0 into args[0] and retruns modified args[0]\n function cloneDefinitions() {\n var args = listToArray(arguments);\n var target = args[0];\n\n args.splice(1, args.length - 1).forEach(function (source) {\n Object.getOwnPropertyNames(source).forEach(function (propName) {\n // If this property already exist in target we delete it first\n delete target[propName];\n // Define the property with the descriptor from source\n Object.defineProperty(target, propName,\n Object.getOwnPropertyDescriptor(source, propName));\n });\n });\n\n return target;\n }\n\n Chartist.Class = {\n extend: extend,\n mix: mix,\n cloneDefinitions: cloneDefinitions\n };\n\n }(window, document, Chartist));\n ;/**\n * Base for all chart types. The methods in Chartist.Base are inherited to all chart types.\n *\n * @module Chartist.Base\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n // TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance.\n // This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not\n // work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage.\n // See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html\n // Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj\n // The problem is with the label offsets that can't be converted into percentage and affecting the chart container\n /**\n * Updates the chart which currently does a full reconstruction of the SVG DOM\n *\n * @memberof Chartist.Base\n */\n function update() {\n this.createChart(this.optionsProvider.currentOptions);\n }\n\n /**\n * This method can be called on the API object of each chart and will un-register all event listeners that were added to other components. This currently includes a window.resize listener as well as media query listeners if any responsive options have been provided. Use this function if you need to destroy and recreate Chartist charts dynamically.\n *\n * @memberof Chartist.Base\n */\n function detach() {\n window.removeEventListener('resize', this.resizeListener);\n this.optionsProvider.removeMediaQueryListeners();\n }\n\n /**\n * Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop.\n *\n * @memberof Chartist.Base\n * @param {String} event Name of the event. Check the examples for supported events.\n * @param {Function} handler The handler function that will be called when an event with the given name was emitted. This function will receive a data argument which contains event data. See the example for more details.\n */\n function on(event, handler) {\n this.eventEmitter.addEventHandler(event, handler);\n }\n\n /**\n * Use this function to un-register event handlers. If the handler function parameter is omitted all handlers for the given event will be un-registered.\n *\n * @memberof Chartist.Base\n * @param {String} event Name of the event for which a handler should be removed\n * @param {Function} [handler] The handler function that that was previously used to register a new event handler. This handler will be removed from the event handler list. If this parameter is omitted then all event handlers for the given event are removed from the list.\n */\n function off(event, handler) {\n this.eventEmitter.removeEventHandler(event, handler);\n }\n\n /**\n * Constructor of chart base class.\n *\n * @param query\n * @param data\n * @param options\n * @param responsiveOptions\n * @constructor\n */\n function Base(query, data, options, responsiveOptions) {\n this.container = Chartist.querySelector(query);\n this.data = data;\n this.options = options;\n this.responsiveOptions = responsiveOptions;\n this.eventEmitter = Chartist.EventEmitter();\n this.supportsForeignObject = Chartist.Svg.isSupported('Extensibility');\n this.supportsAnimations = Chartist.Svg.isSupported('AnimationEventsAttribute');\n this.resizeListener = function resizeListener(){\n this.update();\n }.bind(this);\n\n if(this.container) {\n // If chartist was already initialized in this container we are detaching all event listeners first\n if(this.container.__chartist__) {\n this.container.__chartist__.detach();\n }\n\n this.container.__chartist__ = this;\n }\n\n window.addEventListener('resize', this.resizeListener);\n\n // Using event loop for first draw to make it possible to register event listeners in the same call stack where\n // the chart was created.\n setTimeout(function() {\n // Obtain current options based on matching media queries (if responsive options are given)\n // This will also register a listener that is re-creating the chart based on media changes\n // TODO: Remove default options parameter from optionsProvider\n this.optionsProvider = Chartist.optionsProvider({}, this.options, this.responsiveOptions, this.eventEmitter);\n this.createChart(this.optionsProvider.currentOptions);\n }.bind(this), 0);\n }\n\n // Creating the chart base class\n Chartist.Base = Chartist.Class.extend({\n constructor: Base,\n optionsProvider: undefined,\n container: undefined,\n svg: undefined,\n eventEmitter: undefined,\n createChart: function() {\n throw new Error('Base chart type can\\'t be instantiated!');\n },\n update: update,\n detach: detach,\n on: on,\n off: off,\n version: Chartist.version,\n supportsForeignObject: false\n });\n\n }(window, document, Chartist));\n ;/**\n * Chartist SVG module for simple SVG DOM abstraction\n *\n * @module Chartist.Svg\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n var svgNs = 'http://www.w3.org/2000/svg',\n xmlNs = 'http://www.w3.org/2000/xmlns/',\n xhtmlNs = 'http://www.w3.org/1999/xhtml';\n\n Chartist.xmlNs = {\n qualifiedName: 'xmlns:ct',\n prefix: 'ct',\n uri: 'http://gionkunz.github.com/chartist-js/ct'\n };\n\n /**\n * Chartist.Svg creates a new SVG object wrapper with a starting element. You can use the wrapper to fluently create sub-elements and modify them.\n *\n * @memberof Chartist.Svg\n * @param {String} name The name of the SVG element to create\n * @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.\n * @param {String} className This class or class list will be added to the SVG element\n * @param {Object} parent The parent SVG wrapper object where this newly created wrapper and it's element will be attached to as child\n * @param {Boolean} insertFirst If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element\n * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data\n */\n function Svg(name, attributes, className, parent, insertFirst) {\n this._node = document.createElementNS(svgNs, name);\n\n // If this is an SVG element created then custom namespace\n if(name === 'svg') {\n this._node.setAttributeNS(xmlNs, Chartist.xmlNs.qualifiedName, Chartist.xmlNs.uri);\n }\n\n if(attributes) {\n this.attr(attributes);\n }\n\n if(className) {\n this.addClass(className);\n }\n\n if(parent) {\n if (insertFirst && parent._node.firstChild) {\n parent._node.insertBefore(this._node, parent._node.firstChild);\n } else {\n parent._node.appendChild(this._node);\n }\n\n this._parent = parent;\n }\n }\n\n /**\n * Set attributes on the current SVG element of the wrapper you're currently working on.\n *\n * @memberof Chartist.Svg\n * @param {Object} attributes An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.\n * @param {String} ns If specified, the attributes will be set as namespace attributes with ns as prefix.\n * @returns {Object} The current wrapper object will be returned so it can be used for chaining.\n */\n function attr(attributes, ns) {\n Object.keys(attributes).forEach(function(key) {\n // If the attribute value is undefined we can skip this one\n if(attributes[key] === undefined) {\n return;\n }\n\n if(ns) {\n this._node.setAttributeNS(ns, [Chartist.xmlNs.prefix, ':', key].join(''), attributes[key]);\n } else {\n this._node.setAttribute(key, attributes[key]);\n }\n }.bind(this));\n\n return this;\n }\n\n /**\n * Create a new SVG element whose wrapper object will be selected for further operations. This way you can also create nested groups easily.\n *\n * @memberof Chartist.Svg\n * @param {String} name The name of the SVG element that should be created as child element of the currently selected element wrapper\n * @param {Object} [attributes] An object with properties that will be added as attributes to the SVG element that is created. Attributes with undefined values will not be added.\n * @param {String} [className] This class or class list will be added to the SVG element\n * @param {Boolean} [insertFirst] If this param is set to true in conjunction with a parent element the newly created element will be added as first child element in the parent element\n * @returns {Object} Returns a Chartist.Svg wrapper object that can be used to modify the containing SVG data\n */\n function elem(name, attributes, className, insertFirst) {\n return new Chartist.Svg(name, attributes, className, this, insertFirst);\n }\n\n /**\n * This method creates a foreignObject (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject) that allows to embed HTML content into a SVG graphic. With the help of foreignObjects you can enable the usage of regular HTML elements inside of SVG where they are subject for SVG positioning and transformation but the Browser will use the HTML rendering capabilities for the containing DOM.\n *\n * @memberof Chartist.Svg\n * @param {Node|String} content The DOM Node, or HTML string that will be converted to a DOM Node, that is then placed into and wrapped by the foreignObject\n * @param {String} [attributes] An object with properties that will be added as attributes to the foreignObject element that is created. Attributes with undefined values will not be added.\n * @param {String} [className] This class or class list will be added to the SVG element\n * @param {Boolean} [insertFirst] Specifies if the foreignObject should be inserted as first child\n * @returns {Object} New wrapper object that wraps the foreignObject element\n */\n function foreignObject(content, attributes, className, insertFirst) {\n // If content is string then we convert it to DOM\n // TODO: Handle case where content is not a string nor a DOM Node\n if(typeof content === 'string') {\n var container = document.createElement('div');\n container.innerHTML = content;\n content = container.firstChild;\n }\n\n // Adding namespace to content element\n content.setAttribute('xmlns', xhtmlNs);\n\n // Creating the foreignObject without required extension attribute (as described here\n // http://www.w3.org/TR/SVG/extend.html#ForeignObjectElement)\n var fnObj = this.elem('foreignObject', attributes, className, insertFirst);\n\n // Add content to foreignObjectElement\n fnObj._node.appendChild(content);\n\n return fnObj;\n }\n\n /**\n * This method adds a new text element to the current Chartist.Svg wrapper.\n *\n * @memberof Chartist.Svg\n * @param {String} t The text that should be added to the text element that is created\n * @returns {Object} The same wrapper object that was used to add the newly created element\n */\n function text(t) {\n this._node.appendChild(document.createTextNode(t));\n return this;\n }\n\n /**\n * This method will clear all child nodes of the current wrapper object.\n *\n * @memberof Chartist.Svg\n * @returns {Object} The same wrapper object that got emptied\n */\n function empty() {\n while (this._node.firstChild) {\n this._node.removeChild(this._node.firstChild);\n }\n\n return this;\n }\n\n /**\n * This method will cause the current wrapper to remove itself from its parent wrapper. Use this method if you'd like to get rid of an element in a given DOM structure.\n *\n * @memberof Chartist.Svg\n * @returns {Object} The parent wrapper object of the element that got removed\n */\n function remove() {\n this._node.parentNode.removeChild(this._node);\n return this._parent;\n }\n\n /**\n * This method will replace the element with a new element that can be created outside of the current DOM.\n *\n * @memberof Chartist.Svg\n * @param {Object} newElement The new Chartist.Svg object that will be used to replace the current wrapper object\n * @returns {Object} The wrapper of the new element\n */\n function replace(newElement) {\n this._node.parentNode.replaceChild(newElement._node, this._node);\n newElement._parent = this._parent;\n this._parent = null;\n return newElement;\n }\n\n /**\n * This method will append an element to the current element as a child.\n *\n * @memberof Chartist.Svg\n * @param {Object} element The Chartist.Svg element that should be added as a child\n * @param {Boolean} [insertFirst] Specifies if the element should be inserted as first child\n * @returns {Object} The wrapper of the appended object\n */\n function append(element, insertFirst) {\n if(insertFirst && this._node.firstChild) {\n this._node.insertBefore(element._node, this._node.firstChild);\n } else {\n this._node.appendChild(element._node);\n }\n\n return this;\n }\n\n /**\n * Returns an array of class names that are attached to the current wrapper element. This method can not be chained further.\n *\n * @memberof Chartist.Svg\n * @returns {Array} A list of classes or an empty array if there are no classes on the current element\n */\n function classes() {\n return this._node.getAttribute('class') ? this._node.getAttribute('class').trim().split(/\\s+/) : [];\n }\n\n /**\n * Adds one or a space separated list of classes to the current element and ensures the classes are only existing once.\n *\n * @memberof Chartist.Svg\n * @param {String} names A white space separated list of class names\n * @returns {Object} The wrapper of the current element\n */\n function addClass(names) {\n this._node.setAttribute('class',\n this.classes(this._node)\n .concat(names.trim().split(/\\s+/))\n .filter(function(elem, pos, self) {\n return self.indexOf(elem) === pos;\n }).join(' ')\n );\n\n return this;\n }\n\n /**\n * Removes one or a space separated list of classes from the current element.\n *\n * @memberof Chartist.Svg\n * @param {String} names A white space separated list of class names\n * @returns {Object} The wrapper of the current element\n */\n function removeClass(names) {\n var removedClasses = names.trim().split(/\\s+/);\n\n this._node.setAttribute('class', this.classes(this._node).filter(function(name) {\n return removedClasses.indexOf(name) === -1;\n }).join(' '));\n\n return this;\n }\n\n /**\n * Removes all classes from the current element.\n *\n * @memberof Chartist.Svg\n * @returns {Object} The wrapper of the current element\n */\n function removeAllClasses() {\n this._node.setAttribute('class', '');\n }\n\n /**\n * Get element height with fallback to svg BoundingBox or parent container dimensions:\n * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985)\n *\n * @memberof Chartist.Svg\n * @return {Number} The elements height in pixels\n */\n function height() {\n return this._node.clientHeight || Math.round(this._node.getBBox().height) || this._node.parentNode.clientHeight;\n }\n\n /**\n * Get element width with fallback to svg BoundingBox or parent container dimensions:\n * See [bugzilla.mozilla.org](https://bugzilla.mozilla.org/show_bug.cgi?id=530985)\n *\n * @memberof Chartist.Core\n * @return {Number} The elements width in pixels\n */\n function width() {\n return this._node.clientWidth || Math.round(this._node.getBBox().width) || this._node.parentNode.clientWidth;\n }\n\n /**\n * The animate function lets you animate the current element with SMIL animations. You can add animations for multiple attributes at the same time by using an animation definition object. This object should contain SMIL animation attributes. Please refer to http://www.w3.org/TR/SVG/animate.html for a detailed specification about the available animation attributes. Additionally an easing property can be passed in the animation definition object. This can be a string with a name of an easing function in `Chartist.Svg.Easing` or an array with four values specifying a cubic Bézier curve.\n * **An animations object could look like this:**\n * ```javascript\n * element.animate({\n * opacity: {\n * dur: 1000,\n * from: 0,\n * to: 1\n * },\n * x1: {\n * dur: '1000ms',\n * from: 100,\n * to: 200,\n * easing: 'easeOutQuart'\n * },\n * y1: {\n * dur: '2s',\n * from: 0,\n * to: 100\n * }\n * });\n * ```\n * **Automatic unit conversion**\n * For the `dur` and the `begin` animate attribute you can also omit a unit by passing a number. The number will automatically be converted to milli seconds.\n * **Guided mode**\n * The default behavior of SMIL animations with offset using the `begin` attribute, is that the attribute will keep it's original value until the animation starts. Mostly this behavior is not desired as you'd like to have your element attributes already initialized with the animation `from` value even before the animation starts. Also if you don't specify `fill=\"freeze\"` on an animate element or if you delete the animation after it's done (which is done in guided mode) the attribute will switch back to the initial value. This behavior is also not desired when performing simple one-time animations. If you're using multiple SMIL definition objects for an attribute (in an array), guided mode will be disabled for this attribute, even if you explicitly enabled it.\n * If guided mode is enabled the following behavior is added:\n * - Before the animation starts (even when delayed with `begin`) the animated attribute will be set already to the `from` value of the animation\n * - The animate element will be forced to use `fill=\"freeze\"`\n * - After the animation the element attribute value will be set to the `to` value of the animation\n * - The animate element is deleted from the DOM\n *\n * @memberof Chartist.Svg\n * @param {Object} animations An animations object where the property keys are the attributes you'd like to animate. The properties should be objects again that contain the SMIL animation attributes (usually begin, dur, from, and to). The property begin and dur is auto converted (see Automatic unit conversion). You can also schedule multiple animations for the same attribute by passing an Array of SMIL definition objects. Attributes that contain an array of SMIL definition objects will not be executed in guided mode.\n * @param {Boolean} guided Specify if guided mode should be activated for this animation (see Guided mode). If not otherwise specified, guided mode will be activated.\n * @param {Object} eventEmitter If specified, this event emitter will be notified when an animation starts or ends.\n * @returns {Object} The current element where the animation was added\n */\n function animate(animations, guided, eventEmitter) {\n if(guided === undefined) {\n guided = true;\n }\n\n Object.keys(animations).forEach(function createAnimateForAttributes(attribute) {\n\n function createAnimate(animationDefinition, guided) {\n var attributeProperties = {},\n animate,\n easing;\n\n // Check if an easing is specified in the definition object and delete it from the object as it will not\n // be part of the animate element attributes.\n if(animationDefinition.easing) {\n // If already an easing Bézier curve array we take it or we lookup a easing array in the Easing object\n easing = animationDefinition.easing instanceof Array ?\n animationDefinition.easing :\n Chartist.Svg.Easing[animationDefinition.easing];\n delete animationDefinition.easing;\n }\n\n // Adding \"fill: freeze\" if we are in guided mode and set initial attribute values\n if(guided) {\n animationDefinition.fill = 'freeze';\n // Animated property on our element should already be set to the animation from value in guided mode\n attributeProperties[attribute] = animationDefinition.from;\n this.attr(attributeProperties);\n }\n\n if(easing) {\n animationDefinition.calcMode = 'spline';\n animationDefinition.keySplines = easing.join(' ');\n animationDefinition.keyTimes = '0;1';\n }\n\n // If numeric dur or begin was provided we assume milli seconds\n animationDefinition.begin = Chartist.ensureUnit(animationDefinition.begin, 'ms');\n animationDefinition.dur = Chartist.ensureUnit(animationDefinition.dur, 'ms');\n\n animate = this.elem('animate', Chartist.extend({\n attributeName: attribute\n }, animationDefinition));\n\n if(eventEmitter) {\n animate._node.addEventListener('beginEvent', function handleBeginEvent() {\n eventEmitter.emit('animationBegin', {\n element: this,\n animate: animate._node,\n params: animationDefinition\n });\n }.bind(this));\n }\n\n animate._node.addEventListener('endEvent', function handleEndEvent() {\n if(eventEmitter) {\n eventEmitter.emit('animationEnd', {\n element: this,\n animate: animate._node,\n params: animationDefinition\n });\n }\n\n if(guided) {\n // Set animated attribute to current animated value\n attributeProperties[attribute] = animationDefinition.to;\n this.attr(attributeProperties);\n // Remove the animate element as it's no longer required\n animate.remove();\n }\n }.bind(this));\n }\n\n // If current attribute is an array of definition objects we create an animate for each and disable guided mode\n if(animations[attribute] instanceof Array) {\n animations[attribute].forEach(function(animationDefinition) {\n createAnimate.bind(this)(animationDefinition, false);\n }.bind(this));\n } else {\n createAnimate.bind(this)(animations[attribute], guided);\n }\n\n }.bind(this));\n\n return this;\n }\n\n Chartist.Svg = Chartist.Class.extend({\n constructor: Svg,\n attr: attr,\n elem: elem,\n foreignObject: foreignObject,\n text: text,\n empty: empty,\n remove: remove,\n replace: replace,\n append: append,\n classes: classes,\n addClass: addClass,\n removeClass: removeClass,\n removeAllClasses: removeAllClasses,\n height: height,\n width: width,\n animate: animate\n });\n\n /**\n * This method checks for support of a given SVG feature like Extensibility, SVG-animation or the like. Check http://www.w3.org/TR/SVG11/feature for a detailed list.\n *\n * @memberof Chartist.Svg\n * @param {String} feature The SVG 1.1 feature that should be checked for support.\n * @returns {Boolean} True of false if the feature is supported or not\n */\n Chartist.Svg.isSupported = function(feature) {\n return document.implementation.hasFeature('www.http://w3.org/TR/SVG11/feature#' + feature, '1.1');\n };\n\n /**\n * This Object contains some standard easing cubic bezier curves. Then can be used with their name in the `Chartist.Svg.animate`. You can also extend the list and use your own name in the `animate` function. Click the show code button to see the available bezier functions.\n *\n * @memberof Chartist.Svg\n */\n var easingCubicBeziers = {\n easeInSine: [0.47, 0, 0.745, 0.715],\n easeOutSine: [0.39, 0.575, 0.565, 1],\n easeInOutSine: [0.445, 0.05, 0.55, 0.95],\n easeInQuad: [0.55, 0.085, 0.68, 0.53],\n easeOutQuad: [0.25, 0.46, 0.45, 0.94],\n easeInOutQuad: [0.455, 0.03, 0.515, 0.955],\n easeInCubic: [0.55, 0.055, 0.675, 0.19],\n easeOutCubic: [0.215, 0.61, 0.355, 1],\n easeInOutCubic: [0.645, 0.045, 0.355, 1],\n easeInQuart: [0.895, 0.03, 0.685, 0.22],\n easeOutQuart: [0.165, 0.84, 0.44, 1],\n easeInOutQuart: [0.77, 0, 0.175, 1],\n easeInQuint: [0.755, 0.05, 0.855, 0.06],\n easeOutQuint: [0.23, 1, 0.32, 1],\n easeInOutQuint: [0.86, 0, 0.07, 1],\n easeInExpo: [0.95, 0.05, 0.795, 0.035],\n easeOutExpo: [0.19, 1, 0.22, 1],\n easeInOutExpo: [1, 0, 0, 1],\n easeInCirc: [0.6, 0.04, 0.98, 0.335],\n easeOutCirc: [0.075, 0.82, 0.165, 1],\n easeInOutCirc: [0.785, 0.135, 0.15, 0.86],\n easeInBack: [0.6, -0.28, 0.735, 0.045],\n easeOutBack: [0.175, 0.885, 0.32, 1.275],\n easeInOutBack: [0.68, -0.55, 0.265, 1.55]\n };\n\n Chartist.Svg.Easing = easingCubicBeziers;\n\n }(window, document, Chartist));\n ;/**\n * The Chartist line chart can be used to draw Line or Scatter charts. If used in the browser you can access the global `Chartist` namespace where you find the `Line` function as a main entry point.\n *\n * For examples on how to use the line chart please check the examples of the `Chartist.Line` method.\n *\n * @module Chartist.Line\n */\n /* global Chartist */\n (function(window, document, Chartist){\n 'use strict';\n\n var defaultOptions = {\n axisX: {\n offset: 30,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 40,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop,\n scaleMinSpace: 20\n },\n width: undefined,\n height: undefined,\n showLine: true,\n showPoint: true,\n showArea: false,\n areaBase: 0,\n lineSmooth: true,\n low: undefined,\n high: undefined,\n chartPadding: 5,\n classNames: {\n chart: 'ct-chart-line',\n label: 'ct-label',\n series: 'ct-series',\n line: 'ct-line',\n point: 'ct-point',\n area: 'ct-area',\n grid: 'ct-grid',\n vertical: 'ct-vertical',\n horizontal: 'ct-horizontal'\n }\n };\n\n function createChart(options) {\n var seriesGroups = [],\n bounds,\n normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(this.data), this.data.labels.length);\n\n // Create new svg object\n this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);\n\n // initialize bounds\n bounds = Chartist.getBounds(this.svg, normalizedData, options);\n\n var chartRect = Chartist.createChartRect(this.svg, options);\n // Start drawing\n var labels = this.svg.elem('g'),\n grid = this.svg.elem('g');\n\n Chartist.createXAxis(chartRect, this.data, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n Chartist.createYAxis(chartRect, bounds, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < this.data.series.length; i++) {\n seriesGroups[i] = this.svg.elem('g');\n\n // If the series is an object and contains a name we add a custom attribute\n if(this.data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': this.data.series[i].name\n }, Chartist.xmlNs.uri);\n }\n\n // Use series class from series data or if not set generate one\n seriesGroups[i].addClass([\n options.classNames.series,\n (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i))\n ].join(' '));\n\n var p,\n pathCoordinates = [],\n point;\n\n for (var j = 0; j < normalizedData[i].length; j++) {\n p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j);\n pathCoordinates.push(p.x, p.y);\n\n //If we should show points we need to create them now to avoid secondary loop\n // Small offset for Firefox to render squares correctly\n if (options.showPoint) {\n point = seriesGroups[i].elem('line', {\n x1: p.x,\n y1: p.y,\n x2: p.x + 0.01,\n y2: p.y\n }, options.classNames.point).attr({\n 'value': normalizedData[i][j]\n }, Chartist.xmlNs.uri);\n\n this.eventEmitter.emit('draw', {\n type: 'point',\n value: normalizedData[i][j],\n index: j,\n group: seriesGroups[i],\n element: point,\n x: p.x,\n y: p.y\n });\n }\n }\n\n // TODO: Nicer handling of conditions, maybe composition?\n if (options.showLine || options.showArea) {\n // TODO: We should add a path API in the SVG library for easier path creation\n var pathElements = ['M' + pathCoordinates[0] + ',' + pathCoordinates[1]];\n\n // If smoothed path and path has more than two points then use catmull rom to bezier algorithm\n if (options.lineSmooth && pathCoordinates.length > 4) {\n\n var cr = Chartist.catmullRom2bezier(pathCoordinates);\n for(var k = 0; k < cr.length; k++) {\n pathElements.push('C' + cr[k].join());\n }\n } else {\n for(var l = 3; l < pathCoordinates.length; l += 2) {\n pathElements.push('L' + pathCoordinates[l - 1] + ',' + pathCoordinates[l]);\n }\n }\n\n if(options.showArea) {\n // If areaBase is outside the chart area (< low or > high) we need to set it respectively so that\n // the area is not drawn outside the chart area.\n var areaBase = Math.max(Math.min(options.areaBase, bounds.max), bounds.min);\n\n // If we need to draw area shapes we just make a copy of our pathElements SVG path array\n var areaPathElements = pathElements.slice();\n\n // We project the areaBase value into screen coordinates\n var areaBaseProjected = Chartist.projectPoint(chartRect, bounds, [areaBase], 0);\n // And splice our new area path array to add the missing path elements to close the area shape\n areaPathElements.splice(0, 0, 'M' + areaBaseProjected.x + ',' + areaBaseProjected.y);\n areaPathElements[1] = 'L' + pathCoordinates[0] + ',' + pathCoordinates[1];\n areaPathElements.push('L' + pathCoordinates[pathCoordinates.length - 2] + ',' + areaBaseProjected.y);\n\n // Create the new path for the area shape with the area class from the options\n var area = seriesGroups[i].elem('path', {\n d: areaPathElements.join('')\n }, options.classNames.area, true).attr({\n 'values': normalizedData[i]\n }, Chartist.xmlNs.uri);\n\n this.eventEmitter.emit('draw', {\n type: 'area',\n values: normalizedData[i],\n index: i,\n group: seriesGroups[i],\n element: area\n });\n }\n\n if(options.showLine) {\n var line = seriesGroups[i].elem('path', {\n d: pathElements.join('')\n }, options.classNames.line, true).attr({\n 'values': normalizedData[i]\n }, Chartist.xmlNs.uri);\n\n this.eventEmitter.emit('draw', {\n type: 'line',\n values: normalizedData[i],\n index: i,\n group: seriesGroups[i],\n element: line\n });\n }\n }\n }\n\n this.eventEmitter.emit('created', {\n bounds: bounds,\n chartRect: chartRect,\n svg: this.svg,\n options: options\n });\n }\n\n /**\n * This method creates a new line chart.\n *\n * @memberof Chartist.Line\n * @param {String|Node} query A selector query string or directly a DOM element\n * @param {Object} data The data object that needs to consist of a labels and a series array\n * @param {Object} [options] The options object with options that override the default options. Check the examples for a detailed list.\n * @param {Array} [responsiveOptions] Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]\n * @return {Object} An object which exposes the API for the created chart\n *\n * @example\n * // These are the default options of the line chart\n * var options = {\n * // Options for X-Axis\n * axisX: {\n * // The offset of the labels to the chart area\n * offset: 30,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;}\n * },\n * // Options for Y-Axis\n * axisY: {\n * // The offset of the labels to the chart area\n * offset: 40,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;},\n * // This value specifies the minimum height in pixel of the scale steps\n * scaleMinSpace: 30\n * },\n * // Specify a fixed width for the chart as a string (i.e. '100px' or '50%')\n * width: undefined,\n * // Specify a fixed height for the chart as a string (i.e. '100px' or '50%')\n * height: undefined,\n * // If the line should be drawn or not\n * showLine: true,\n * // If dots should be drawn or not\n * showPoint: true,\n * // If the line chart should draw an area\n * showArea: false,\n * // The base for the area chart that will be used to close the area shape (is normally 0)\n * areaBase: 0,\n * // Specify if the lines should be smoothed (Catmull-Rom-Splines will be used)\n * lineSmooth: true,\n * // Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value\n * low: undefined,\n * // Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value\n * high: undefined,\n * // Padding of the chart drawing area to the container element and labels\n * chartPadding: 5,\n * // Override the class names that get used to generate the SVG structure of the chart\n * classNames: {\n * chart: 'ct-chart-line',\n * label: 'ct-label',\n * series: 'ct-series',\n * line: 'ct-line',\n * point: 'ct-point',\n * area: 'ct-area',\n * grid: 'ct-grid',\n * vertical: 'ct-vertical',\n * horizontal: 'ct-horizontal'\n * }\n * };\n *\n * @example\n * // Create a simple line chart\n * var data = {\n * // A labels array that can contain any sort of values\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * // Our series array that contains series objects or in this case series data arrays\n * series: [\n * [5, 2, 4, 2, 0]\n * ]\n * };\n *\n * // As options we currently only set a static size of 300x200 px\n * var options = {\n * width: '300px',\n * height: '200px'\n * };\n *\n * // In the global name space Chartist we call the Line function to initialize a line chart. As a first parameter we pass in a selector where we would like to get our chart created. Second parameter is the actual data object and as a third parameter we pass in our options\n * new Chartist.Line('.ct-chart', data, options);\n *\n * @example\n * // Create a line chart with responsive options\n *\n * var data = {\n * // A labels array that can contain any sort of values\n * labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],\n * // Our series array that contains series objects or in this case series data arrays\n * series: [\n * [5, 2, 4, 2, 0]\n * ]\n * };\n *\n * // In adition to the regular options we specify responsive option overrides that will override the default configutation based on the matching media queries.\n * var responsiveOptions = [\n * ['screen and (min-width: 641px) and (max-width: 1024px)', {\n * showPoint: false,\n * axisX: {\n * labelInterpolationFnc: function(value) {\n * // Will return Mon, Tue, Wed etc. on medium screens\n * return value.slice(0, 3);\n * }\n * }\n * }],\n * ['screen and (max-width: 640px)', {\n * showLine: false,\n * axisX: {\n * labelInterpolationFnc: function(value) {\n * // Will return M, T, W etc. on small screens\n * return value[0];\n * }\n * }\n * }]\n * ];\n *\n * new Chartist.Line('.ct-chart', data, null, responsiveOptions);\n *\n */\n function Line(query, data, options, responsiveOptions) {\n Chartist.Line.super.constructor.call(this,\n query,\n data,\n Chartist.extend(Chartist.extend({}, defaultOptions), options),\n responsiveOptions);\n }\n\n // Creating line chart type in Chartist namespace\n Chartist.Line = Chartist.Base.extend({\n constructor: Line,\n createChart: createChart\n });\n\n }(window, document, Chartist));\n ;/**\n * The bar chart module of Chartist that can be used to draw unipolar or bipolar bar and grouped bar charts.\n *\n * @module Chartist.Bar\n */\n /* global Chartist */\n (function(window, document, Chartist){\n 'use strict';\n\n var defaultOptions = {\n axisX: {\n offset: 30,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 40,\n labelOffset: {\n x: 0,\n y: 0\n },\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop,\n scaleMinSpace: 20\n },\n width: undefined,\n height: undefined,\n high: undefined,\n low: undefined,\n chartPadding: 5,\n seriesBarDistance: 15,\n classNames: {\n chart: 'ct-chart-bar',\n label: 'ct-label',\n series: 'ct-series',\n bar: 'ct-bar',\n grid: 'ct-grid',\n vertical: 'ct-vertical',\n horizontal: 'ct-horizontal'\n }\n };\n\n function createChart(options) {\n var seriesGroups = [],\n bounds,\n normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(this.data), this.data.labels.length);\n\n // Create new svg element\n this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);\n\n // initialize bounds\n bounds = Chartist.getBounds(this.svg, normalizedData, options, 0);\n\n var chartRect = Chartist.createChartRect(this.svg, options);\n // Start drawing\n var labels = this.svg.elem('g'),\n grid = this.svg.elem('g'),\n // Projected 0 point\n zeroPoint = Chartist.projectPoint(chartRect, bounds, [0], 0);\n\n Chartist.createXAxis(chartRect, this.data, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n Chartist.createYAxis(chartRect, bounds, grid, labels, options, this.eventEmitter, this.supportsForeignObject);\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < this.data.series.length; i++) {\n // Calculating bi-polar value of index for seriesOffset. For i = 0..4 biPol will be -1.5, -0.5, 0.5, 1.5 etc.\n var biPol = i - (this.data.series.length - 1) / 2,\n // Half of the period with between vertical grid lines used to position bars\n periodHalfWidth = chartRect.width() / normalizedData[i].length / 2;\n\n seriesGroups[i] = this.svg.elem('g');\n\n // If the series is an object and contains a name we add a custom attribute\n if(this.data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': this.data.series[i].name\n }, Chartist.xmlNs.uri);\n }\n\n // Use series class from series data or if not set generate one\n seriesGroups[i].addClass([\n options.classNames.series,\n (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i))\n ].join(' '));\n\n for(var j = 0; j < normalizedData[i].length; j++) {\n var p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j),\n bar;\n\n // Offset to center bar between grid lines and using bi-polar offset for multiple series\n // TODO: Check if we should really be able to add classes to the series. Should be handles with Sass and semantic / specific selectors\n p.x += periodHalfWidth + (biPol * options.seriesBarDistance);\n\n bar = seriesGroups[i].elem('line', {\n x1: p.x,\n y1: zeroPoint.y,\n x2: p.x,\n y2: p.y\n }, options.classNames.bar).attr({\n 'value': normalizedData[i][j]\n }, Chartist.xmlNs.uri);\n\n this.eventEmitter.emit('draw', {\n type: 'bar',\n value: normalizedData[i][j],\n index: j,\n group: seriesGroups[i],\n element: bar,\n x1: p.x,\n y1: zeroPoint.y,\n x2: p.x,\n y2: p.y\n });\n }\n }\n\n this.eventEmitter.emit('created', {\n bounds: bounds,\n chartRect: chartRect,\n svg: this.svg,\n options: options\n });\n }\n\n /**\n * This method creates a new bar chart and returns API object that you can use for later changes.\n *\n * @memberof Chartist.Bar\n * @param {String|Node} query A selector query string or directly a DOM element\n * @param {Object} data The data object that needs to consist of a labels and a series array\n * @param {Object} [options] The options object with options that override the default options. Check the examples for a detailed list.\n * @param {Array} [responsiveOptions] Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]\n * @return {Object} An object which exposes the API for the created chart\n *\n * @example\n * // These are the default options of the bar chart\n * var options = {\n * // Options for X-Axis\n * axisX: {\n * // The offset of the chart drawing area to the border of the container\n * offset: 30,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;}\n * },\n * // Options for Y-Axis\n * axisY: {\n * // The offset of the chart drawing area to the border of the container\n * offset: 40,\n * // Allows you to correct label positioning on this axis by positive or negative x and y offset.\n * labelOffset: {\n * x: 0,\n * y: 0\n * },\n * // If labels should be shown or not\n * showLabel: true,\n * // If the axis grid should be drawn or not\n * showGrid: true,\n * // Interpolation function that allows you to intercept the value from the axis label\n * labelInterpolationFnc: function(value){return value;},\n * // This value specifies the minimum height in pixel of the scale steps\n * scaleMinSpace: 30\n * },\n * // Specify a fixed width for the chart as a string (i.e. '100px' or '50%')\n * width: undefined,\n * // Specify a fixed height for the chart as a string (i.e. '100px' or '50%')\n * height: undefined,\n * // Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value\n * low: undefined,\n * // Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value\n * high: undefined,\n * // Padding of the chart drawing area to the container element and labels\n * chartPadding: 5,\n * // Specify the distance in pixel of bars in a group\n * seriesBarDistance: 15,\n * // Override the class names that get used to generate the SVG structure of the chart\n * classNames: {\n * chart: 'ct-chart-bar',\n * label: 'ct-label',\n * series: 'ct-series',\n * bar: 'ct-bar',\n * grid: 'ct-grid',\n * vertical: 'ct-vertical',\n * horizontal: 'ct-horizontal'\n * }\n * };\n *\n * @example\n * // Create a simple bar chart\n * var data = {\n * labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n * series: [\n * [5, 2, 4, 2, 0]\n * ]\n * };\n *\n * // In the global name space Chartist we call the Bar function to initialize a bar chart. As a first parameter we pass in a selector where we would like to get our chart created and as a second parameter we pass our data object.\n * new Chartist.Bar('.ct-chart', data);\n *\n * @example\n * // This example creates a bipolar grouped bar chart where the boundaries are limitted to -10 and 10\n * new Chartist.Bar('.ct-chart', {\n * labels: [1, 2, 3, 4, 5, 6, 7],\n * series: [\n * [1, 3, 2, -5, -3, 1, -6],\n * [-5, -2, -4, -1, 2, -3, 1]\n * ]\n * }, {\n * seriesBarDistance: 12,\n * low: -10,\n * high: 10\n * });\n *\n */\n function Bar(query, data, options, responsiveOptions) {\n Chartist.Bar.super.constructor.call(this,\n query,\n data,\n Chartist.extend(Chartist.extend({}, defaultOptions), options),\n responsiveOptions);\n }\n\n // Creating bar chart type in Chartist namespace\n Chartist.Bar = Chartist.Base.extend({\n constructor: Bar,\n createChart: createChart\n });\n\n }(window, document, Chartist));\n ;/**\n * The pie chart module of Chartist that can be used to draw pie, donut or gauge charts\n *\n * @module Chartist.Pie\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n var defaultOptions = {\n width: undefined,\n height: undefined,\n chartPadding: 5,\n classNames: {\n chart: 'ct-chart-pie',\n series: 'ct-series',\n slice: 'ct-slice',\n donut: 'ct-donut',\n label: 'ct-label'\n },\n startAngle: 0,\n total: undefined,\n donut: false,\n donutWidth: 60,\n showLabel: true,\n labelOffset: 0,\n labelInterpolationFnc: Chartist.noop,\n labelOverflow: false,\n labelDirection: 'neutral'\n };\n\n function determineAnchorPosition(center, label, direction) {\n var toTheRight = label.x > center.x;\n\n if(toTheRight && direction === 'explode' ||\n !toTheRight && direction === 'implode') {\n return 'start';\n } else if(toTheRight && direction === 'implode' ||\n !toTheRight && direction === 'explode') {\n return 'end';\n } else {\n return 'middle';\n }\n }\n\n function createChart(options) {\n var seriesGroups = [],\n chartRect,\n radius,\n labelRadius,\n totalDataSum,\n startAngle = options.startAngle,\n dataArray = Chartist.getDataArray(this.data);\n\n // Create SVG.js draw\n this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart);\n // Calculate charting rect\n chartRect = Chartist.createChartRect(this.svg, options, 0, 0);\n // Get biggest circle radius possible within chartRect\n radius = Math.min(chartRect.width() / 2, chartRect.height() / 2);\n // Calculate total of all series to get reference value or use total reference from optional options\n totalDataSum = options.total || dataArray.reduce(function(previousValue, currentValue) {\n return previousValue + currentValue;\n }, 0);\n\n // If this is a donut chart we need to adjust our radius to enable strokes to be drawn inside\n // Unfortunately this is not possible with the current SVG Spec\n // See this proposal for more details: http://lists.w3.org/Archives/Public/www-svg/2003Oct/0000.html\n radius -= options.donut ? options.donutWidth / 2 : 0;\n\n // If a donut chart then the label position is at the radius, if regular pie chart it's half of the radius\n // see https://github.com/gionkunz/chartist-js/issues/21\n labelRadius = options.donut ? radius : radius / 2;\n // Add the offset to the labelRadius where a negative offset means closed to the center of the chart\n labelRadius += options.labelOffset;\n\n // Calculate end angle based on total sum and current data value and offset with padding\n var center = {\n x: chartRect.x1 + chartRect.width() / 2,\n y: chartRect.y2 + chartRect.height() / 2\n };\n\n // Check if there is only one non-zero value in the series array.\n var hasSingleValInSeries = this.data.series.filter(function(val) {\n return val !== 0;\n }).length === 1;\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < this.data.series.length; i++) {\n seriesGroups[i] = this.svg.elem('g', null, null, true);\n\n // If the series is an object and contains a name we add a custom attribute\n if(this.data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': this.data.series[i].name\n }, Chartist.xmlNs.uri);\n }\n\n // Use series class from series data or if not set generate one\n seriesGroups[i].addClass([\n options.classNames.series,\n (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i))\n ].join(' '));\n\n var endAngle = startAngle + dataArray[i] / totalDataSum * 360;\n // If we need to draw the arc for all 360 degrees we need to add a hack where we close the circle\n // with Z and use 359.99 degrees\n if(endAngle - startAngle === 360) {\n endAngle -= 0.01;\n }\n\n var start = Chartist.polarToCartesian(center.x, center.y, radius, startAngle - (i === 0 || hasSingleValInSeries ? 0 : 0.2)),\n end = Chartist.polarToCartesian(center.x, center.y, radius, endAngle),\n arcSweep = endAngle - startAngle <= 180 ? '0' : '1',\n d = [\n // Start at the end point from the cartesian coordinates\n 'M', end.x, end.y,\n // Draw arc\n 'A', radius, radius, 0, arcSweep, 0, start.x, start.y\n ];\n\n // If regular pie chart (no donut) we add a line to the center of the circle for completing the pie\n if(options.donut === false) {\n d.push('L', center.x, center.y);\n }\n\n // Create the SVG path\n // If this is a donut chart we add the donut class, otherwise just a regular slice\n var path = seriesGroups[i].elem('path', {\n d: d.join(' ')\n }, options.classNames.slice + (options.donut ? ' ' + options.classNames.donut : ''));\n\n // Adding the pie series value to the path\n path.attr({\n 'value': dataArray[i]\n }, Chartist.xmlNs.uri);\n\n // If this is a donut, we add the stroke-width as style attribute\n if(options.donut === true) {\n path.attr({\n 'style': 'stroke-width: ' + (+options.donutWidth) + 'px'\n });\n }\n\n // Fire off draw event\n this.eventEmitter.emit('draw', {\n type: 'slice',\n value: dataArray[i],\n totalDataSum: totalDataSum,\n index: i,\n group: seriesGroups[i],\n element: path,\n center: center,\n radius: radius,\n startAngle: startAngle,\n endAngle: endAngle\n });\n\n // If we need to show labels we need to add the label for this slice now\n if(options.showLabel) {\n // Position at the labelRadius distance from center and between start and end angle\n var labelPosition = Chartist.polarToCartesian(center.x, center.y, labelRadius, startAngle + (endAngle - startAngle) / 2),\n interpolatedValue = options.labelInterpolationFnc(this.data.labels ? this.data.labels[i] : dataArray[i], i);\n\n var labelElement = seriesGroups[i].elem('text', {\n dx: labelPosition.x,\n dy: labelPosition.y,\n 'text-anchor': determineAnchorPosition(center, labelPosition, options.labelDirection)\n }, options.classNames.label).text('' + interpolatedValue);\n\n // Fire off draw event\n this.eventEmitter.emit('draw', {\n type: 'label',\n index: i,\n group: seriesGroups[i],\n element: labelElement,\n text: '' + interpolatedValue,\n x: labelPosition.x,\n y: labelPosition.y\n });\n }\n\n // Set next startAngle to current endAngle. Use slight offset so there are no transparent hairline issues\n // (except for last slice)\n startAngle = endAngle;\n }\n\n this.eventEmitter.emit('created', {\n chartRect: chartRect,\n svg: this.svg,\n options: options\n });\n }\n\n /**\n * This method creates a new pie chart and returns an object that can be used to redraw the chart.\n *\n * @memberof Chartist.Pie\n * @param {String|Node} query A selector query string or directly a DOM element\n * @param {Object} data The data object in the pie chart needs to have a series property with a one dimensional data array. The values will be normalized against each other and don't necessarily need to be in percentage.\n * @param {Object} [options] The options object with options that override the default options. Check the examples for a detailed list.\n * @param {Array} [responsiveOptions] Specify an array of responsive option arrays which are a media query and options object pair => [[mediaQueryString, optionsObject],[more...]]\n * @return {Object} An object with a version and an update method to manually redraw the chart\n *\n * @example\n * // Default options of the pie chart\n * var defaultOptions = {\n * // Specify a fixed width for the chart as a string (i.e. '100px' or '50%')\n * width: undefined,\n * // Specify a fixed height for the chart as a string (i.e. '100px' or '50%')\n * height: undefined,\n * // Padding of the chart drawing area to the container element and labels\n * chartPadding: 5,\n * // Override the class names that get used to generate the SVG structure of the chart\n * classNames: {\n * chart: 'ct-chart-pie',\n * series: 'ct-series',\n * slice: 'ct-slice',\n * donut: 'ct-donut',\n label: 'ct-label'\n * },\n * // The start angle of the pie chart in degrees where 0 points north. A higher value offsets the start angle clockwise.\n * startAngle: 0,\n * // An optional total you can specify. By specifying a total value, the sum of the values in the series must be this total in order to draw a full pie. You can use this parameter to draw only parts of a pie or gauge charts.\n * total: undefined,\n * // If specified the donut CSS classes will be used and strokes will be drawn instead of pie slices.\n * donut: false,\n * // Specify the donut stroke width, currently done in javascript for convenience. May move to CSS styles in the future.\n * donutWidth: 60,\n * // If a label should be shown or not\n * showLabel: true,\n * // Label position offset from the standard position which is half distance of the radius. This value can be either positive or negative. Positive values will position the label away from the center.\n * labelOffset: 0,\n * // An interpolation function for the label value\n * labelInterpolationFnc: function(value, index) {return value;},\n * // Label direction can be 'neutral', 'explode' or 'implode'. The labels anchor will be positioned based on those settings as well as the fact if the labels are on the right or left side of the center of the chart. Usually explode is useful when labels are positioned far away from the center.\n * labelDirection: 'neutral'\n * };\n *\n * @example\n * // Simple pie chart example with four series\n * new Chartist.Pie('.ct-chart', {\n * series: [10, 2, 4, 3]\n * });\n *\n * @example\n * // Drawing a donut chart\n * new Chartist.Pie('.ct-chart', {\n * series: [10, 2, 4, 3]\n * }, {\n * donut: true\n * });\n *\n * @example\n * // Using donut, startAngle and total to draw a gauge chart\n * new Chartist.Pie('.ct-chart', {\n * series: [20, 10, 30, 40]\n * }, {\n * donut: true,\n * donutWidth: 20,\n * startAngle: 270,\n * total: 200\n * });\n *\n * @example\n * // Drawing a pie chart with padding and labels that are outside the pie\n * new Chartist.Pie('.ct-chart', {\n * series: [20, 10, 30, 40]\n * }, {\n * chartPadding: 30,\n * labelOffset: 50,\n * labelDirection: 'explode'\n * });\n */\n function Pie(query, data, options, responsiveOptions) {\n Chartist.Pie.super.constructor.call(this,\n query,\n data,\n Chartist.extend(Chartist.extend({}, defaultOptions), options),\n responsiveOptions);\n }\n\n // Creating pie chart type in Chartist namespace\n Chartist.Pie = Chartist.Base.extend({\n constructor: Pie,\n createChart: createChart,\n determineAnchorPosition: determineAnchorPosition\n });\n\n }(window, document, Chartist));\n\n\n return Chartist;\n\n}));\n"]} \ No newline at end of file diff --git a/package.json b/package.json index e6307bff..9d3a3f7e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "chartist", "title": "Chartist.js", "description": "Simple, responsive charts", - "version": "0.3.1", + "version": "0.4.0", "author": "Gion Kunz", "homepage": "https://gionkunz.github.io/chartist-js", "repository": {