From a326908fc64c5abfc739d1980ed1bdf8b0ee5710 Mon Sep 17 00:00:00 2001 From: Gion Kunz Date: Sat, 18 Oct 2014 14:58:25 +0200 Subject: [PATCH] Libdist of 0.2.4 --- libdist/chartist.js | 1585 ++++++++++++++++++++------------------ libdist/chartist.min.css | 2 +- libdist/chartist.min.js | 4 +- libdist/chartist.min.map | 2 +- 4 files changed, 859 insertions(+), 734 deletions(-) diff --git a/libdist/chartist.js b/libdist/chartist.js index 79e29cdd..9f951c7a 100644 --- a/libdist/chartist.js +++ b/libdist/chartist.js @@ -10,7 +10,7 @@ } }(this, function() { - /* Chartist.js 0.2.3 + /* Chartist.js 0.2.4 * Copyright © 2014 Gion Kunz * Free to use under the WTFPL license. * http://www.wtfpl.net/ @@ -21,7 +21,7 @@ * @module Chartist.Core */ var Chartist = {}; - Chartist.version = '0.2.3'; + Chartist.version = '0.2.4'; (function (window, document, Chartist) { 'use strict'; @@ -49,6 +49,7 @@ return String.fromCharCode(97 + n % 26); }; + // TODO: Make it possible to call extend with var args /** * Simple recursive object extend * @@ -755,6 +756,324 @@ }; }; + }(window, document, Chartist));;/** + * This module provides some basic prototype inheritance utilities. + * + * @module Chartist.Class + */ + /* global Chartist */ + (function(window, document, Chartist) { + 'use strict'; + + function listToArray(list) { + var arr = []; + if (list.length) { + for (var i = 0; i < list.length; i++) { + arr.push(list[i]); + } + } + return arr; + } + + /** + * Method to extend from current prototype. + * + * @memberof Chartist.Class + * @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. + * @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. + * @returns {Function} Constructor function of the new class + * + * @example + * var Fruit = Class.extend({ + * color: undefined, + * sugar: undefined, + * + * constructor: function(color, sugar) { + * this.color = color; + * this.sugar = sugar; + * }, + * + * eat: function() { + * this.sugar = 0; + * return this; + * } + * }); + * + * var Banana = Fruit.extend({ + * length: undefined, + * + * constructor: function(length, sugar) { + * Banana.super.constructor.call(this, 'Yellow', sugar); + * this.length = length; + * } + * }); + * + * 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(banana.sugar); + * console.log(banana.eat().sugar); + * console.log(banana.color); + */ + function extend(properties, superProtoOverride) { + var superProto = superProtoOverride || this.prototype || Chartist.Class; + var proto = Object.create(superProto); + + Chartist.Class.cloneDefinitions(proto, properties); + + var constr = function() { + var fn = proto.constructor || function () {}, + instance; + + // If this is linked to the Chartist namespace the constructor was not called with new + // To provide a fallback we will instantiate here and return the instance + instance = this === Chartist ? Object.create(proto) : this; + fn.apply(instance, Array.prototype.slice.call(arguments, 0)); + + // If this constructor was not called with new we need to return the instance + // This will not harm when the constructor has been called with new as the returned value is ignored + return instance; + }; + + constr.prototype = proto; + constr.super = superProto; + constr.extend = this.extend; + + return constr; + } + + /** + * Creates a mixin from multiple super prototypes. + * + * @memberof Chartist.Class + * @param {Array} mixProtoArr An array of super prototypes or an array of super prototype constructors. + * @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. + * @returns {Function} Constructor function of the newly created mixin class + * + * @example + * var Fruit = Class.extend({ + * color: undefined, + * sugar: undefined, + * + * constructor: function(color, sugar) { + * this.color = color; + * this.sugar = sugar; + * }, + * + * eat: function() { + * this.sugar = 0; + * return this; + * } + * }); + * + * var Banana = Fruit.extend({ + * length: undefined, + * + * constructor: function(length, sugar) { + * Banana.super.constructor.call(this, 'Yellow', sugar); + * this.length = length; + * } + * }); + * + * 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(banana.sugar); + * console.log(banana.eat().sugar); + * console.log(banana.color); + * + * + * var KCal = Class.extend({ + * sugar: 0, + * + * constructor: function(sugar) { + * this.sugar = sugar; + * }, + * + * get kcal() { + * return [this.sugar * 4, 'kcal'].join(''); + * } + * }); + * + * var Nameable = Class.extend({ + * name: undefined, + * + * constructor: function(name) { + * this.name = name; + * } + * }); + * + * var NameableKCalBanana = Class.mix([Banana, KCal, Nameable], { + * constructor: function(name, length, sugar) { + * Nameable.prototype.constructor.call(this, name); + * Banana.prototype.constructor.call(this, length, sugar); + * }, + * + * toString: function() { + * return [this.name, 'with', this.length + 'cm', 'and', this.kcal].join(' '); + * } + * }); + * + * + * + * 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(banana.sugar); + * console.log(banana.eat().sugar); + * console.log(banana.color); + * + * var superBanana = new NameableKCalBanana('Super Mixin Banana', 30, 80); + * console.log(superBanana.toString()); + * + */ + function mix(mixProtoArr, properties) { + if(this !== Chartist.Class) { + throw new Error('Chartist.Class.mix should only be called on the type and never on an instance!'); + } + + // Make sure our mixin prototypes are the class objects and not the constructors + var superPrototypes = [{}] + .concat(mixProtoArr) + .map(function (prototype) { + return prototype instanceof Function ? prototype.prototype : prototype; + }); + + var mixedSuperProto = Chartist.Class.cloneDefinitions.apply(undefined, superPrototypes); + // Delete the constructor if present because we don't want to invoke a constructor on a mixed prototype + delete mixedSuperProto.constructor; + return this.extend(properties, mixedSuperProto); + } + + // Variable argument list clones args > 0 into args[0] and retruns modified args[0] + function cloneDefinitions() { + var args = listToArray(arguments); + var target = args[0]; + + args.splice(1, args.length - 1).forEach(function (source) { + Object.getOwnPropertyNames(source).forEach(function (propName) { + // If this property already exist in target we delete it first + delete target[propName]; + // Define the property with the descriptor from source + Object.defineProperty(target, propName, + Object.getOwnPropertyDescriptor(source, propName)); + }); + }); + + return target; + } + + Chartist.Class = { + extend: extend, + mix: mix, + cloneDefinitions: cloneDefinitions + }; + + }(window, document, Chartist));;/** + * Base for all chart classes. + * + * @module Chartist.Base + */ + /* global Chartist */ + (function(window, document, Chartist) { + 'use strict'; + + // TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance. + // This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not + // work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage. + // See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html + // Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj + // The problem is with the label offsets that can't be converted into percentage and affecting the chart container + /** + * Updates the chart which currently does a full reconstruction of the SVG DOM + * + * @memberof Chartist.Line + */ + function update() { + this.createChart(this.optionsProvider.currentOptions); + } + + /** + * 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. + * + * @memberof Chartist.Line + */ + function detach() { + window.removeEventListener('resize', this.update); + this.optionsProvider.removeMediaQueryListeners(); + } + + /** + * Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop. + * + * @memberof Chartist.Line + * @param {String} event Name of the event. Check the examples for supported events. + * @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. + */ + function on(event, handler) { + this.eventEmitter.addEventHandler(event, handler); + } + + /** + * 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. + * + * @memberof Chartist.Line + * @param {String} event Name of the event for which a handler should be removed + * @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. + */ + function off(event, handler) { + this.eventEmitter.removeEventHandler(event, handler); + } + + /** + * Constructor of chart base class. + * + * @param query + * @param data + * @param options + * @param responsiveOptions + * @constructor + */ + function Base(query, data, options, responsiveOptions) { + this.container = Chartist.querySelector(query); + this.data = data; + this.options = options; + this.responsiveOptions = responsiveOptions; + this.eventEmitter = Chartist.EventEmitter(); + + window.addEventListener('resize', this.update.bind(this)); + + // Using event loop for first draw to make it possible to register event listeners in the same call stack where + // the chart was created. + setTimeout(function() { + // Obtain current options based on matching media queries (if responsive options are given) + // This will also register a listener that is re-creating the chart based on media changes + // TODO: Remove default options parameter from optionsProvider + this.optionsProvider = Chartist.optionsProvider({}, this.options, this.responsiveOptions, this.eventEmitter); + this.createChart(this.optionsProvider.currentOptions); + }.bind(this), 0); + } + + // Creating the chart base class + Chartist.Base = Chartist.Class.extend({ + constructor: Base, + optionsProvider: undefined, + container: undefined, + svg: undefined, + eventEmitter: undefined, + createChart: function() { + throw new Error('Base chart type can\'t be instantiated!'); + }, + update: update, + detach: detach, + on: on, + off: off, + version: Chartist.version + }); + }(window, document, Chartist));;/** * Chartist SVG module for simple SVG DOM abstraction * @@ -1096,8 +1415,191 @@ (function(window, document, Chartist){ 'use strict'; + var defaultOptions = { + axisX: { + offset: 10, + showLabel: true, + showGrid: true, + labelInterpolationFnc: Chartist.noop + }, + axisY: { + offset: 15, + showLabel: true, + showGrid: true, + labelAlign: 'right', + labelInterpolationFnc: Chartist.noop, + scaleMinSpace: 30 + }, + width: undefined, + height: undefined, + showLine: true, + showPoint: true, + showArea: false, + areaBase: 0, + lineSmooth: true, + low: undefined, + high: undefined, + chartPadding: 5, + classNames: { + chart: 'ct-chart-line', + label: 'ct-label', + series: 'ct-series', + line: 'ct-line', + point: 'ct-point', + area: 'ct-area', + grid: 'ct-grid', + vertical: 'ct-vertical', + horizontal: 'ct-horizontal' + } + }; + + function createChart(options) { + var xAxisOffset, + yAxisOffset, + seriesGroups = [], + bounds, + normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(this.data), this.data.labels.length); + + // Create new svg object + this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart); + + // initialize bounds + bounds = Chartist.getBounds(this.svg, normalizedData, options); + + xAxisOffset = options.axisX.offset; + if (options.axisX.showLabel) { + xAxisOffset += Chartist.calculateLabelOffset( + this.svg, + this.data.labels, + [options.classNames.label, options.classNames.horizontal].join(' '), + options.axisX.labelInterpolationFnc, + 'height' + ); + } + + yAxisOffset = options.axisY.offset; + if (options.axisY.showLabel) { + yAxisOffset += Chartist.calculateLabelOffset( + this.svg, + bounds.values, + [options.classNames.label, options.classNames.horizontal].join(' '), + options.axisY.labelInterpolationFnc, + 'width' + ); + } + + var chartRect = Chartist.createChartRect(this.svg, options, xAxisOffset, yAxisOffset); + // Start drawing + var labels = this.svg.elem('g'), + grid = this.svg.elem('g'); + + Chartist.createXAxis(chartRect, this.data, grid, labels, options, this.eventEmitter); + Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, this.eventEmitter); + + // Draw the series + // initialize series groups + for (var i = 0; i < this.data.series.length; i++) { + seriesGroups[i] = this.svg.elem('g'); + + // If the series is an object and contains a name we add a custom attribute + if(this.data.series[i].name) { + seriesGroups[i].attr({ + 'series-name': this.data.series[i].name + }, Chartist.xmlNs.uri); + } + + // Use series class from series data or if not set generate one + seriesGroups[i].addClass([ + options.classNames.series, + (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i)) + ].join(' ')); + + var p, + pathCoordinates = [], + point; + + for (var j = 0; j < normalizedData[i].length; j++) { + p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j); + pathCoordinates.push(p.x, p.y); + + //If we should show points we need to create them now to avoid secondary loop + // Small offset for Firefox to render squares correctly + if (options.showPoint) { + point = seriesGroups[i].elem('line', { + x1: p.x, + y1: p.y, + x2: p.x + 0.01, + y2: p.y + }, options.classNames.point).attr({ + 'value': normalizedData[i][j] + }, Chartist.xmlNs.uri); + + this.eventEmitter.emit('draw', { + type: 'point', + value: normalizedData[i][j], + index: j, + group: seriesGroups[i], + element: point, + x: p.x, + y: p.y + }); + } + } + + // TODO: Nicer handling of conditions, maybe composition? + if (options.showLine || options.showArea) { + // TODO: We should add a path API in the SVG library for easier path creation + var pathElements = ['M' + pathCoordinates[0] + ',' + pathCoordinates[1]]; + + // If smoothed path and path has more than two points then use catmull rom to bezier algorithm + if (options.lineSmooth && pathCoordinates.length > 4) { + + var cr = Chartist.catmullRom2bezier(pathCoordinates); + for(var k = 0; k < cr.length; k++) { + pathElements.push('C' + cr[k].join()); + } + } else { + for(var l = 3; l < pathCoordinates.length; l += 2) { + pathElements.push('L' + pathCoordinates[l - 1] + ',' + pathCoordinates[l]); + } + } + + 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); + + // If we need to draw area shapes we just make a copy of our pathElements SVG path array + var areaPathElements = pathElements.slice(); + + // We project the areaBase value into screen coordinates + var areaBaseProjected = Chartist.projectPoint(chartRect, bounds, [areaBase], 0); + // And splice our new area path array to add the missing path elements to close the area shape + areaPathElements.splice(0, 0, 'M' + areaBaseProjected.x + ',' + areaBaseProjected.y); + areaPathElements[1] = 'L' + pathCoordinates[0] + ',' + pathCoordinates[1]; + 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', { + d: areaPathElements.join('') + }, options.classNames.area, true).attr({ + 'values': normalizedData[i] + }, Chartist.xmlNs.uri); + } + + if(options.showLine) { + seriesGroups[i].elem('path', { + d: pathElements.join('') + }, options.classNames.line, true).attr({ + 'values': normalizedData[i] + }, Chartist.xmlNs.uri); + } + } + } + } + /** - * This method creates a new line chart and returns API object that you can use for later changes. + * This method creates a new line chart. * * @memberof Chartist.Line * @param {String|Node} query A selector query string or directly a DOM element @@ -1187,7 +1689,7 @@ * }; * * // 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 - * Chartist.Line('.ct-chart', data, options); + * new Chartist.Line('.ct-chart', data, options); * * @example * // Create a line chart with responsive options @@ -1223,270 +1725,22 @@ * }] * ]; * - * Chartist.Line('.ct-chart', data, null, responsiveOptions); + * new Chartist.Line('.ct-chart', data, null, responsiveOptions); * */ - Chartist.Line = function (query, data, options, responsiveOptions) { - - var defaultOptions = { - axisX: { - offset: 10, - showLabel: true, - showGrid: true, - labelInterpolationFnc: Chartist.noop - }, - axisY: { - offset: 15, - showLabel: true, - showGrid: true, - labelAlign: 'right', - labelInterpolationFnc: Chartist.noop, - scaleMinSpace: 30 - }, - width: undefined, - height: undefined, - showLine: true, - showPoint: true, - showArea: false, - areaBase: 0, - lineSmooth: true, - low: undefined, - high: undefined, - chartPadding: 5, - classNames: { - chart: 'ct-chart-line', - label: 'ct-label', - series: 'ct-series', - line: 'ct-line', - point: 'ct-point', - area: 'ct-area', - grid: 'ct-grid', - vertical: 'ct-vertical', - horizontal: 'ct-horizontal' - } - }, - optionsProvider, - container = Chartist.querySelector(query), - svg, - eventEmitter = Chartist.EventEmitter(); - - function createChart(options) { - var xAxisOffset, - yAxisOffset, - seriesGroups = [], - bounds, - normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(data), data.labels.length); - - // Create new svg object - svg = Chartist.createSvg(container, options.width, options.height, options.classNames.chart); - - // initialize bounds - bounds = Chartist.getBounds(svg, normalizedData, options); - - xAxisOffset = options.axisX.offset; - if (options.axisX.showLabel) { - xAxisOffset += Chartist.calculateLabelOffset( - svg, - data.labels, - [options.classNames.label, options.classNames.horizontal].join(' '), - options.axisX.labelInterpolationFnc, - 'height' - ); - } - - yAxisOffset = options.axisY.offset; - if (options.axisY.showLabel) { - yAxisOffset += Chartist.calculateLabelOffset( - svg, - bounds.values, - [options.classNames.label, options.classNames.horizontal].join(' '), - options.axisY.labelInterpolationFnc, - 'width' - ); - } - - var chartRect = Chartist.createChartRect(svg, options, xAxisOffset, yAxisOffset); - // Start drawing - var labels = svg.elem('g'), - grid = svg.elem('g'); - - Chartist.createXAxis(chartRect, data, grid, labels, options, eventEmitter); - Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, eventEmitter); - - // Draw the series - // initialize series groups - for (var i = 0; i < data.series.length; i++) { - seriesGroups[i] = svg.elem('g'); - - // If the series is an object and contains a name we add a custom attribute - if(data.series[i].name) { - seriesGroups[i].attr({ - 'series-name': data.series[i].name - }, Chartist.xmlNs.uri); - } - - // Use series class from series data or if not set generate one - seriesGroups[i].addClass([ - options.classNames.series, - (data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i)) - ].join(' ')); - - var p, - pathCoordinates = [], - point; - - for (var j = 0; j < normalizedData[i].length; j++) { - p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j); - pathCoordinates.push(p.x, p.y); - - //If we should show points we need to create them now to avoid secondary loop - // Small offset for Firefox to render squares correctly - if (options.showPoint) { - point = seriesGroups[i].elem('line', { - x1: p.x, - y1: p.y, - x2: p.x + 0.01, - y2: p.y - }, options.classNames.point).attr({ - 'value': normalizedData[i][j] - }, Chartist.xmlNs.uri); - - eventEmitter.emit('draw', { - type: 'point', - value: normalizedData[i][j], - index: j, - group: seriesGroups[i], - element: point, - x: p.x, - y: p.y - }); - } - } - - // TODO: Nicer handling of conditions, maybe composition? - if (options.showLine || options.showArea) { - // TODO: We should add a path API in the SVG library for easier path creation - var pathElements = ['M' + pathCoordinates[0] + ',' + pathCoordinates[1]]; - - // If smoothed path and path has more than two points then use catmull rom to bezier algorithm - if (options.lineSmooth && pathCoordinates.length > 4) { - - var cr = Chartist.catmullRom2bezier(pathCoordinates); - for(var k = 0; k < cr.length; k++) { - pathElements.push('C' + cr[k].join()); - } - } else { - for(var l = 3; l < pathCoordinates.length; l += 2) { - pathElements.push('L' + pathCoordinates[l - 1] + ',' + pathCoordinates[l]); - } - } - - 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); - - // If we need to draw area shapes we just make a copy of our pathElements SVG path array - var areaPathElements = pathElements.slice(); - - // We project the areaBase value into screen coordinates - var areaBaseProjected = Chartist.projectPoint(chartRect, bounds, [areaBase], 0); - // And splice our new area path array to add the missing path elements to close the area shape - areaPathElements.splice(0, 0, 'M' + areaBaseProjected.x + ',' + areaBaseProjected.y); - areaPathElements[1] = 'L' + pathCoordinates[0] + ',' + pathCoordinates[1]; - 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', { - d: areaPathElements.join('') - }, options.classNames.area, true).attr({ - 'values': normalizedData[i] - }, Chartist.xmlNs.uri); - } - - if(options.showLine) { - seriesGroups[i].elem('path', { - d: pathElements.join('') - }, options.classNames.line, true).attr({ - 'values': normalizedData[i] - }, Chartist.xmlNs.uri); - } - } - } - } - - // TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance. - // This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not - // work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage. - // See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html - // Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj - // The problem is with the label offsets that can't be converted into percentage and affecting the chart container - /** - * Updates the chart which currently does a full reconstruction of the SVG DOM - * - * @memberof Chartist.Line - */ - function update() { - createChart(optionsProvider.currentOptions); - } - - /** - * 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. - * - * @memberof Chartist.Line - */ - function detach() { - window.removeEventListener('resize', update); - optionsProvider.removeMediaQueryListeners(); - } - - /** - * Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop. - * - * @memberof Chartist.Line - * @param {String} event Name of the event. Check the examples for supported events. - * @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. - */ - function on(event, handler) { - eventEmitter.addEventHandler(event, handler); - } - - /** - * 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. - * - * @memberof Chartist.Line - * @param {String} event Name of the event for which a handler should be removed - * @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. - */ - function off(event, handler) { - eventEmitter.removeEventHandler(event, handler); - } - - // Initialization of the chart - - window.addEventListener('resize', update); - - // Obtain current options based on matching media queries (if responsive options are given) - // This will also register a listener that is re-creating the chart based on media changes - optionsProvider = Chartist.optionsProvider(defaultOptions, options, responsiveOptions, eventEmitter); - // Using event loop for first draw to make it possible to register event listeners in the same call stack where - // the chart was created. - setTimeout(function() { - createChart(optionsProvider.currentOptions); - }, 0); - - // Public members of the module (revealing module pattern style) - var api = { - version: Chartist.version, - update: update, - on: on, - off: off, - detach: detach - }; + function Line(query, data, options, responsiveOptions) { + Chartist.Line.super.constructor.call(this, + query, + data, + Chartist.extend(Chartist.extend({}, defaultOptions), options), + responsiveOptions); + } - container.chartist = api; - return api; - }; + // Creating line chart type in Chartist namespace + Chartist.Line = Chartist.Base.extend({ + constructor: Line, + createChart: createChart + }); }(window, document, Chartist)); ;/** @@ -1498,6 +1752,140 @@ (function(window, document, Chartist){ 'use strict'; + var defaultOptions = { + axisX: { + offset: 10, + showLabel: true, + showGrid: true, + labelInterpolationFnc: Chartist.noop + }, + axisY: { + offset: 15, + showLabel: true, + showGrid: true, + labelAlign: 'right', + labelInterpolationFnc: Chartist.noop, + scaleMinSpace: 40 + }, + width: undefined, + height: undefined, + high: undefined, + low: undefined, + chartPadding: 5, + seriesBarDistance: 15, + classNames: { + chart: 'ct-chart-bar', + label: 'ct-label', + series: 'ct-series', + bar: 'ct-bar', + thin: 'ct-thin', + thick: 'ct-thick', + grid: 'ct-grid', + vertical: 'ct-vertical', + horizontal: 'ct-horizontal' + } + }; + + function createChart(options) { + var xAxisOffset, + yAxisOffset, + seriesGroups = [], + bounds, + normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(this.data), this.data.labels.length); + + // Create new svg element + this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart); + + // initialize bounds + bounds = Chartist.getBounds(this.svg, normalizedData, options, 0); + + xAxisOffset = options.axisX.offset; + if (options.axisX.showLabel) { + xAxisOffset += Chartist.calculateLabelOffset( + this.svg, + this.data.labels, + [options.classNames.label, options.classNames.horizontal].join(' '), + options.axisX.labelInterpolationFnc, + 'height' + ); + } + + yAxisOffset = options.axisY.offset; + if (options.axisY.showLabel) { + yAxisOffset += Chartist.calculateLabelOffset( + this.svg, + bounds.values, + [options.classNames.label, options.classNames.horizontal].join(' '), + options.axisY.labelInterpolationFnc, + 'width' + ); + } + + var chartRect = Chartist.createChartRect(this.svg, options, xAxisOffset, yAxisOffset); + // Start drawing + var labels = this.svg.elem('g'), + grid = this.svg.elem('g'), + // Projected 0 point + zeroPoint = Chartist.projectPoint(chartRect, bounds, [0], 0); + + Chartist.createXAxis(chartRect, this.data, grid, labels, options, this.eventEmitter); + Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, this.eventEmitter); + + // Draw the series + // initialize series groups + for (var i = 0; i < this.data.series.length; i++) { + // Calculating bi-polar value of index for seriesOffset. For i = 0..4 biPol will be -1.5, -0.5, 0.5, 1.5 etc. + var biPol = i - (this.data.series.length - 1) / 2, + // Half of the period with between vertical grid lines used to position bars + periodHalfWidth = chartRect.width() / normalizedData[i].length / 2; + + seriesGroups[i] = this.svg.elem('g'); + + // If the series is an object and contains a name we add a custom attribute + if(this.data.series[i].name) { + seriesGroups[i].attr({ + 'series-name': this.data.series[i].name + }, Chartist.xmlNs.uri); + } + + // Use series class from series data or if not set generate one + seriesGroups[i].addClass([ + options.classNames.series, + (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i)) + ].join(' ')); + + for(var j = 0; j < normalizedData[i].length; j++) { + var p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j), + bar; + + // Offset to center bar between grid lines and using bi-polar offset for multiple series + // TODO: Check if we should really be able to add classes to the series. Should be handles with Sass and semantic / specific selectors + p.x += periodHalfWidth + (biPol * options.seriesBarDistance); + + bar = seriesGroups[i].elem('line', { + x1: p.x, + y1: zeroPoint.y, + x2: p.x, + y2: p.y + }, options.classNames.bar).attr({ + 'value': normalizedData[i][j] + }, Chartist.xmlNs.uri); + + this.eventEmitter.emit('draw', { + type: 'bar', + value: normalizedData[i][j], + index: j, + group: seriesGroups[i], + element: bar, + x1: p.x, + y1: zeroPoint.y, + x2: p.x, + y2: p.y + }); + } + } + } + /** * This method creates a new bar chart and returns API object that you can use for later changes. * @@ -1578,11 +1966,11 @@ * }; * * // 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. - * Chartist.Bar('.ct-chart', data); + * new Chartist.Bar('.ct-chart', data); * * @example * // This example creates a bipolar grouped bar chart where the boundaries are limitted to -10 and 10 - * Chartist.Bar('.ct-chart', { + * new Chartist.Bar('.ct-chart', { * labels: [1, 2, 3, 4, 5, 6, 7], * series: [ * [1, 3, 2, -5, -3, 1, -6], @@ -1595,228 +1983,209 @@ * }); * */ - Chartist.Bar = function (query, data, options, responsiveOptions) { - - var defaultOptions = { - axisX: { - offset: 10, - showLabel: true, - showGrid: true, - labelInterpolationFnc: Chartist.noop - }, - axisY: { - offset: 15, - showLabel: true, - showGrid: true, - labelAlign: 'right', - labelInterpolationFnc: Chartist.noop, - scaleMinSpace: 40 - }, - width: undefined, - height: undefined, - high: undefined, - low: undefined, - chartPadding: 5, - seriesBarDistance: 15, - classNames: { - chart: 'ct-chart-bar', - label: 'ct-label', - series: 'ct-series', - bar: 'ct-bar', - thin: 'ct-thin', - thick: 'ct-thick', - grid: 'ct-grid', - vertical: 'ct-vertical', - horizontal: 'ct-horizontal' - } - }, - optionsProvider, - container = Chartist.querySelector(query), - svg, - eventEmitter = Chartist.EventEmitter(); - - function createChart(options) { - var xAxisOffset, - yAxisOffset, - seriesGroups = [], - bounds, - normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(data), data.labels.length); + function Bar(query, data, options, responsiveOptions) { + Chartist.Bar.super.constructor.call(this, + query, + data, + Chartist.extend(Chartist.extend({}, defaultOptions), options), + responsiveOptions); + } - // Create new svg element - svg = Chartist.createSvg(container, options.width, options.height, options.classNames.chart); + // Creating bar chart type in Chartist namespace + Chartist.Bar = Chartist.Base.extend({ + constructor: Bar, + createChart: createChart + }); - // initialize bounds - bounds = Chartist.getBounds(svg, normalizedData, options, 0); + }(window, document, Chartist)); + ;/** + * The pie chart module of Chartist that can be used to draw pie, donut or gauge charts + * + * @module Chartist.Pie + */ + /* global Chartist */ + (function(window, document, Chartist) { + 'use strict'; - xAxisOffset = options.axisX.offset; - if (options.axisX.showLabel) { - xAxisOffset += Chartist.calculateLabelOffset( - svg, - data.labels, - [options.classNames.label, options.classNames.horizontal].join(' '), - options.axisX.labelInterpolationFnc, - 'height' - ); - } + var defaultOptions = { + width: undefined, + height: undefined, + chartPadding: 5, + classNames: { + chart: 'ct-chart-pie', + series: 'ct-series', + slice: 'ct-slice', + donut: 'ct-donut', + label: 'ct-label' + }, + startAngle: 0, + total: undefined, + donut: false, + donutWidth: 60, + showLabel: true, + labelOffset: 0, + labelInterpolationFnc: Chartist.noop, + labelOverflow: false, + labelDirection: 'neutral' + }; - yAxisOffset = options.axisY.offset; - if (options.axisY.showLabel) { - yAxisOffset += Chartist.calculateLabelOffset( - svg, - bounds.values, - [options.classNames.label, options.classNames.horizontal].join(' '), - options.axisY.labelInterpolationFnc, - 'width' - ); - } + function determineAnchorPosition(center, label, direction) { + var toTheRight = label.x > center.x; - var chartRect = Chartist.createChartRect(svg, options, xAxisOffset, yAxisOffset); - // Start drawing - var labels = svg.elem('g'), - grid = svg.elem('g'), - // Projected 0 point - zeroPoint = Chartist.projectPoint(chartRect, bounds, [0], 0); - - Chartist.createXAxis(chartRect, data, grid, labels, options, eventEmitter); - Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, eventEmitter); - - // Draw the series - // initialize series groups - for (var i = 0; i < data.series.length; i++) { - // Calculating bi-polar value of index for seriesOffset. For i = 0..4 biPol will be -1.5, -0.5, 0.5, 1.5 etc. - var biPol = i - (data.series.length - 1) / 2, - // Half of the period with between vertical grid lines used to position bars - periodHalfWidth = chartRect.width() / normalizedData[i].length / 2; - - seriesGroups[i] = svg.elem('g'); - - // If the series is an object and contains a name we add a custom attribute - if(data.series[i].name) { - seriesGroups[i].attr({ - 'series-name': data.series[i].name - }, Chartist.xmlNs.uri); - } + if(toTheRight && direction === 'explode' || + !toTheRight && direction === 'implode') { + return 'start'; + } else if(toTheRight && direction === 'implode' || + !toTheRight && direction === 'explode') { + return 'end'; + } else { + return 'middle'; + } + } - // Use series class from series data or if not set generate one - seriesGroups[i].addClass([ - options.classNames.series, - (data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i)) - ].join(' ')); + function createChart(options) { + var seriesGroups = [], + chartRect, + radius, + labelRadius, + totalDataSum, + startAngle = options.startAngle, + dataArray = Chartist.getDataArray(this.data); + + // Create SVG.js draw + this.svg = Chartist.createSvg(this.container, options.width, options.height, options.classNames.chart); + // Calculate charting rect + chartRect = Chartist.createChartRect(this.svg, options, 0, 0); + // Get biggest circle radius possible within chartRect + radius = Math.min(chartRect.width() / 2, chartRect.height() / 2); + // Calculate total of all series to get reference value or use total reference from optional options + totalDataSum = options.total || dataArray.reduce(function(previousValue, currentValue) { + return previousValue + currentValue; + }, 0); - for(var j = 0; j < normalizedData[i].length; j++) { - var p = Chartist.projectPoint(chartRect, bounds, normalizedData[i], j), - bar; + // If this is a donut chart we need to adjust our radius to enable strokes to be drawn inside + // Unfortunately this is not possible with the current SVG Spec + // See this proposal for more details: http://lists.w3.org/Archives/Public/www-svg/2003Oct/0000.html + radius -= options.donut ? options.donutWidth / 2 : 0; + + // If a donut chart then the label position is at the radius, if regular pie chart it's half of the radius + // see https://github.com/gionkunz/chartist-js/issues/21 + labelRadius = options.donut ? radius : radius / 2; + // Add the offset to the labelRadius where a negative offset means closed to the center of the chart + labelRadius += options.labelOffset; + + // Calculate end angle based on total sum and current data value and offset with padding + var center = { + x: chartRect.x1 + chartRect.width() / 2, + y: chartRect.y2 + chartRect.height() / 2 + }; - // Offset to center bar between grid lines and using bi-polar offset for multiple series - // TODO: Check if we should really be able to add classes to the series. Should be handles with Sass and semantic / specific selectors - p.x += periodHalfWidth + (biPol * options.seriesBarDistance); + // Check if there is only one non-zero value in the series array. + var hasSingleValInSeries = this.data.series.filter(function(val) { + return val !== 0; + }).length === 1; - bar = seriesGroups[i].elem('line', { - x1: p.x, - y1: zeroPoint.y, - x2: p.x, - y2: p.y - }, options.classNames.bar).attr({ - 'value': normalizedData[i][j] - }, Chartist.xmlNs.uri); + // Draw the series + // initialize series groups + for (var i = 0; i < this.data.series.length; i++) { + seriesGroups[i] = this.svg.elem('g', null, null, true); - eventEmitter.emit('draw', { - type: 'bar', - value: normalizedData[i][j], - index: j, - group: seriesGroups[i], - element: bar, - x1: p.x, - y1: zeroPoint.y, - x2: p.x, - y2: p.y - }); - } + // If the series is an object and contains a name we add a custom attribute + if(this.data.series[i].name) { + seriesGroups[i].attr({ + 'series-name': this.data.series[i].name + }, Chartist.xmlNs.uri); } - } - // TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance. - // This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not - // work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage. - // See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html - // Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj - // The problem is with the label offsets that can't be converted into percentage and affecting the chart container - /** - * Updates the chart which currently does a full reconstruction of the SVG DOM - * - * @memberof Chartist.Bar - */ - function update() { - createChart(optionsProvider.currentOptions); - } + // Use series class from series data or if not set generate one + seriesGroups[i].addClass([ + options.classNames.series, + (this.data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i)) + ].join(' ')); + + var endAngle = startAngle + dataArray[i] / totalDataSum * 360; + // If we need to draw the arc for all 360 degrees we need to add a hack where we close the circle + // with Z and use 359.99 degrees + if(endAngle - startAngle === 360) { + endAngle -= 0.01; + } - /** - * 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. - * - * @memberof Chartist.Bar - */ - function detach() { - window.removeEventListener('resize', update); - optionsProvider.removeMediaQueryListeners(); - } + var start = Chartist.polarToCartesian(center.x, center.y, radius, startAngle - (i === 0 || hasSingleValInSeries ? 0 : 0.2)), + end = Chartist.polarToCartesian(center.x, center.y, radius, endAngle), + arcSweep = endAngle - startAngle <= 180 ? '0' : '1', + d = [ + // Start at the end point from the cartesian coordinates + 'M', end.x, end.y, + // Draw arc + 'A', radius, radius, 0, arcSweep, 0, start.x, start.y + ]; + + // If regular pie chart (no donut) we add a line to the center of the circle for completing the pie + if(options.donut === false) { + d.push('L', center.x, center.y); + } - /** - * Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop. - * - * @memberof Chartist.Bar - * @param {String} event Name of the event. Check the examples for supported events. - * @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. - */ - function on(event, handler) { - eventEmitter.addEventHandler(event, handler); - } + // Create the SVG path + // If this is a donut chart we add the donut class, otherwise just a regular slice + var path = seriesGroups[i].elem('path', { + d: d.join(' ') + }, options.classNames.slice + (options.donut ? ' ' + options.classNames.donut : '')); - /** - * 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. - * - * @memberof Chartist.Bar - * @param {String} event Name of the event for which a handler should be removed - * @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. - */ - function off(event, handler) { - eventEmitter.removeEventHandler(event, handler); - } + // Adding the pie series value to the path + path.attr({ + 'value': dataArray[i] + }, Chartist.xmlNs.uri); - // Initialization of the chart + // If this is a donut, we add the stroke-width as style attribute + if(options.donut === true) { + path.attr({ + 'style': 'stroke-width: ' + (+options.donutWidth) + 'px' + }); + } - window.addEventListener('resize', update); + // Fire off draw event + this.eventEmitter.emit('draw', { + type: 'slice', + value: dataArray[i], + totalDataSum: totalDataSum, + index: i, + group: seriesGroups[i], + element: path, + center: center, + radius: radius, + startAngle: startAngle, + endAngle: endAngle + }); - // Obtain current options based on matching media queries (if responsive options are given) - // This will also register a listener that is re-creating the chart based on media changes - optionsProvider = Chartist.optionsProvider(defaultOptions, options, responsiveOptions, eventEmitter); - // Using event loop for first draw to make it possible to register event listeners in the same call stack where - // the chart was created. - setTimeout(function() { - createChart(optionsProvider.currentOptions); - }, 0); + // If we need to show labels we need to add the label for this slice now + if(options.showLabel) { + // Position at the labelRadius distance from center and between start and end angle + var labelPosition = Chartist.polarToCartesian(center.x, center.y, labelRadius, startAngle + (endAngle - startAngle) / 2), + interpolatedValue = options.labelInterpolationFnc(this.data.labels ? this.data.labels[i] : dataArray[i], i); - // Public members of the module (revealing module pattern style) - var api = { - version: Chartist.version, - update: update, - on: on, - off: off, - detach: detach - }; + var labelElement = seriesGroups[i].elem('text', { + dx: labelPosition.x, + dy: labelPosition.y, + 'text-anchor': determineAnchorPosition(center, labelPosition, options.labelDirection) + }, options.classNames.label).text('' + interpolatedValue); - container.chartist = api; - return api; - }; + // Fire off draw event + this.eventEmitter.emit('draw', { + type: 'label', + index: i, + group: seriesGroups[i], + element: labelElement, + text: '' + interpolatedValue, + x: labelPosition.x, + y: labelPosition.y + }); + } - }(window, document, Chartist)); - ;/** - * The pie chart module of Chartist that can be used to draw pie, donut or gauge charts - * - * @module Chartist.Pie - */ - /* global Chartist */ - (function(window, document, Chartist) { - 'use strict'; + // Set next startAngle to current endAngle. Use slight offset so there are no transparent hairline issues + // (except for last slice) + startAngle = endAngle; + } + } /** * This method creates a new pie chart and returns an object that can be used to redraw the chart. @@ -1865,13 +2234,13 @@ * * @example * // Simple pie chart example with four series - * Chartist.Pie('.ct-chart', { + * new Chartist.Pie('.ct-chart', { * series: [10, 2, 4, 3] * }); * * @example * // Drawing a donut chart - * Chartist.Pie('.ct-chart', { + * new Chartist.Pie('.ct-chart', { * series: [10, 2, 4, 3] * }, { * donut: true @@ -1879,7 +2248,7 @@ * * @example * // Using donut, startAngle and total to draw a gauge chart - * Chartist.Pie('.ct-chart', { + * new Chartist.Pie('.ct-chart', { * series: [20, 10, 30, 40] * }, { * donut: true, @@ -1890,7 +2259,7 @@ * * @example * // Drawing a pie chart with padding and labels that are outside the pie - * Chartist.Pie('.ct-chart', { + * new Chartist.Pie('.ct-chart', { * series: [20, 10, 30, 40] * }, { * chartPadding: 30, @@ -1898,268 +2267,24 @@ * labelDirection: 'explode' * }); */ - Chartist.Pie = function (query, data, options, responsiveOptions) { - - var defaultOptions = { - width: undefined, - height: undefined, - chartPadding: 5, - classNames: { - chart: 'ct-chart-pie', - series: 'ct-series', - slice: 'ct-slice', - donut: 'ct-donut', - label: 'ct-label' - }, - startAngle: 0, - total: undefined, - donut: false, - donutWidth: 60, - showLabel: true, - labelOffset: 0, - labelInterpolationFnc: Chartist.noop, - labelOverflow: false, - labelDirection: 'neutral' - }, - optionsProvider, - container = Chartist.querySelector(query), - svg, - eventEmitter = Chartist.EventEmitter(); - - function determineAnchorPosition(center, label, direction) { - var toTheRight = label.x > center.x; - - if(toTheRight && direction === 'explode' || - !toTheRight && direction === 'implode') { - return 'start'; - } else if(toTheRight && direction === 'implode' || - !toTheRight && direction === 'explode') { - return 'end'; - } else { - return 'middle'; - } - } - - function createChart(options) { - var seriesGroups = [], - chartRect, - radius, - labelRadius, - totalDataSum, - startAngle = options.startAngle, - dataArray = Chartist.getDataArray(data); - - // Create SVG.js draw - svg = Chartist.createSvg(container, options.width, options.height, options.classNames.chart); - // Calculate charting rect - chartRect = Chartist.createChartRect(svg, options, 0, 0); - // Get biggest circle radius possible within chartRect - radius = Math.min(chartRect.width() / 2, chartRect.height() / 2); - // Calculate total of all series to get reference value or use total reference from optional options - totalDataSum = options.total || dataArray.reduce(function(previousValue, currentValue) { - return previousValue + currentValue; - }, 0); - - // If this is a donut chart we need to adjust our radius to enable strokes to be drawn inside - // Unfortunately this is not possible with the current SVG Spec - // See this proposal for more details: http://lists.w3.org/Archives/Public/www-svg/2003Oct/0000.html - radius -= options.donut ? options.donutWidth / 2 : 0; - - // If a donut chart then the label position is at the radius, if regular pie chart it's half of the radius - // see https://github.com/gionkunz/chartist-js/issues/21 - labelRadius = options.donut ? radius : radius / 2; - // Add the offset to the labelRadius where a negative offset means closed to the center of the chart - labelRadius += options.labelOffset; - - // Calculate end angle based on total sum and current data value and offset with padding - var center = { - x: chartRect.x1 + chartRect.width() / 2, - y: chartRect.y2 + chartRect.height() / 2 - }; - - // Check if there is only one non-zero value in the series array. - var hasSingleValInSeries = data.series.filter(function(val) { - return val !== 0; - }).length === 1; - - // Draw the series - // initialize series groups - for (var i = 0; i < data.series.length; i++) { - seriesGroups[i] = svg.elem('g', null, null, true); - - // If the series is an object and contains a name we add a custom attribute - if(data.series[i].name) { - seriesGroups[i].attr({ - 'series-name': data.series[i].name - }, Chartist.xmlNs.uri); - } - - // Use series class from series data or if not set generate one - seriesGroups[i].addClass([ - options.classNames.series, - (data.series[i].className || options.classNames.series + '-' + Chartist.alphaNumerate(i)) - ].join(' ')); - - var endAngle = startAngle + dataArray[i] / totalDataSum * 360; - // If we need to draw the arc for all 360 degrees we need to add a hack where we close the circle - // with Z and use 359.99 degrees - if(endAngle - startAngle === 360) { - endAngle -= 0.01; - } - - var start = Chartist.polarToCartesian(center.x, center.y, radius, startAngle - (i === 0 || hasSingleValInSeries ? 0 : 0.2)), - end = Chartist.polarToCartesian(center.x, center.y, radius, endAngle), - arcSweep = endAngle - startAngle <= 180 ? '0' : '1', - d = [ - // Start at the end point from the cartesian coordinates - 'M', end.x, end.y, - // Draw arc - 'A', radius, radius, 0, arcSweep, 0, start.x, start.y - ]; - - // If regular pie chart (no donut) we add a line to the center of the circle for completing the pie - if(options.donut === false) { - d.push('L', center.x, center.y); - } - - // Create the SVG path - // If this is a donut chart we add the donut class, otherwise just a regular slice - var path = seriesGroups[i].elem('path', { - d: d.join(' ') - }, options.classNames.slice + (options.donut ? ' ' + options.classNames.donut : '')); - - // Adding the pie series value to the path - path.attr({ - 'value': dataArray[i] - }, Chartist.xmlNs.uri); - - // If this is a donut, we add the stroke-width as style attribute - if(options.donut === true) { - path.attr({ - 'style': 'stroke-width: ' + (+options.donutWidth) + 'px' - }); - } - - // Fire off draw event - eventEmitter.emit('draw', { - type: 'slice', - value: dataArray[i], - totalDataSum: totalDataSum, - index: i, - group: seriesGroups[i], - element: path, - center: center, - radius: radius, - startAngle: startAngle, - endAngle: endAngle - }); - - // If we need to show labels we need to add the label for this slice now - if(options.showLabel) { - // Position at the labelRadius distance from center and between start and end angle - var labelPosition = Chartist.polarToCartesian(center.x, center.y, labelRadius, startAngle + (endAngle - startAngle) / 2), - interpolatedValue = options.labelInterpolationFnc(data.labels ? data.labels[i] : dataArray[i], i); - - var labelElement = seriesGroups[i].elem('text', { - dx: labelPosition.x, - dy: labelPosition.y, - 'text-anchor': determineAnchorPosition(center, labelPosition, options.labelDirection) - }, options.classNames.label).text('' + interpolatedValue); - - // Fire off draw event - eventEmitter.emit('draw', { - type: 'label', - index: i, - group: seriesGroups[i], - element: labelElement, - text: '' + interpolatedValue, - x: labelPosition.x, - y: labelPosition.y - }); - } - - // Set next startAngle to current endAngle. Use slight offset so there are no transparent hairline issues - // (except for last slice) - startAngle = endAngle; - } - } - - // TODO: Currently we need to re-draw the chart on window resize. This is usually very bad and will affect performance. - // This is done because we can't work with relative coordinates when drawing the chart because SVG Path does not - // work with relative positions yet. We need to check if we can do a viewBox hack to switch to percentage. - // See http://mozilla.6506.n7.nabble.com/Specyfing-paths-with-percentages-unit-td247474.html - // Update: can be done using the above method tested here: http://codepen.io/gionkunz/pen/KDvLj - // The problem is with the label offsets that can't be converted into percentage and affecting the chart container - /** - * Updates the chart which currently does a full reconstruction of the SVG DOM - * - * @memberof Chartist.Pie - * - */ - function update() { - createChart(optionsProvider.currentOptions); - } - - /** - * This method will detach the chart from any event listeners that have been added. This includes window.resize and media query listeners for the responsive options. Call this method in order to de-initialize dynamically created / removed charts. - * - * @memberof Chartist.Pie - */ - function detach() { - window.removeEventListener('resize', update); - optionsProvider.removeMediaQueryListeners(); - } - - /** - * Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop. - * - * @memberof Chartist.Pie - * @param {String} event Name of the event. Check the examples for supported events. - * @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. - */ - function on(event, handler) { - eventEmitter.addEventHandler(event, handler); - } - - /** - * 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. - * - * @memberof Chartist.Pie - * @param {String} event Name of the event for which a handler should be removed - * @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. - */ - function off(event, handler) { - eventEmitter.removeEventHandler(event, handler); - } - - // Initialization of the chart - - window.addEventListener('resize', update); - - // Obtain current options based on matching media queries (if responsive options are given) - // This will also register a listener that is re-creating the chart based on media changes - optionsProvider = Chartist.optionsProvider(defaultOptions, options, responsiveOptions, eventEmitter); - // Using event loop for first draw to make it possible to register event listeners in the same call stack where - // the chart was created. - setTimeout(function() { - createChart(optionsProvider.currentOptions); - }, 0); - - // Public members of the module (revealing module pattern style) - var api = { - version: Chartist.version, - update: update, - on: on, - off: off, - detach: detach - }; + function Pie(query, data, options, responsiveOptions) { + Chartist.Pie.super.constructor.call(this, + query, + data, + Chartist.extend(Chartist.extend({}, defaultOptions), options), + responsiveOptions); + } - container.chartist = api; - return api; - }; + // Creating pie chart type in Chartist namespace + Chartist.Pie = Chartist.Base.extend({ + constructor: Pie, + createChart: createChart, + determineAnchorPosition: determineAnchorPosition + }); }(window, document, Chartist)); + return Chartist; })); diff --git a/libdist/chartist.min.css b/libdist/chartist.min.css index be412b9a..1939712b 100644 --- a/libdist/chartist.min.css +++ b/libdist/chartist.min.css @@ -1,4 +1,4 @@ -/* Chartist.js 0.2.3 +/* Chartist.js 0.2.4 * 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 4fe9bcbf..57ff58b7 100644 --- a/libdist/chartist.min.js +++ b/libdist/chartist.min.js @@ -1,8 +1,8 @@ -/* Chartist.js 0.2.3 +/* Chartist.js 0.2.4 * 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.2.3",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 a.height()-2*b.chartPadding-b.axisX.offset},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.calculateLabelOffset=function(a,b,c,d,e){for(var f=0,g=0;gd;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";c.xmlNs={qualifiedName:"xmlns:ct",prefix:"ct",uri:"http://gionkunz.github.com/chartist-js/ct"},c.Svg=function(a,d,e,f,g){function h(a,b,d){return Object.keys(b).forEach(function(e){void 0!==b[e]&&(d?a.setAttributeNS(d,[c.xmlNs.prefix,":",e].join(""),b[e]):a.setAttribute(e,b[e]))}),a}function i(a,d,e,f,g){var i=b.createElementNS(v,a);return"svg"===a&&i.setAttributeNS(w,c.xmlNs.qualifiedName,c.xmlNs.uri),f&&(g&&f.firstChild?f.insertBefore(i,f.firstChild):f.appendChild(i)),d&&h(i,d),e&&q(i,e),i}function j(a,d,e,f,g,h,i,j){if("string"==typeof a){var k=b.createElement("div");k.innerHTML=a,a=k.firstChild}a.setAttribute("xmlns",x);var l=c.Svg("foreignObject",{x:d,y:e,width:f,height:g},h,i,j);return l._node.appendChild(a),l}function k(a,c){a.appendChild(b.createTextNode(c))}function l(a){for(;a.firstChild;)a.removeChild(a.firstChild)}function m(a){a.parentNode.removeChild(a)}function n(a,b){a.parentNode.replaceChild(b,a)}function o(a,b,c){c&&a.firstChild?a.insertBefore(b,a.firstChild):a.appendChild(b)}function p(a){return a.getAttribute("class")?a.getAttribute("class").trim().split(/\s+/):[]}function q(a,b){a.setAttribute("class",p(a).concat(b.trim().split(/\s+/)).filter(function(a,b,c){return c.indexOf(a)===b}).join(" "))}function r(a,b){var c=b.trim().split(/\s+/);a.setAttribute("class",p(a).filter(function(a){return-1===c.indexOf(a)}).join(" "))}function s(a){a.setAttribute("class","")}function t(a){return a.clientHeight||Math.round(a.getBBox().height)||a.parentNode.clientHeight}function u(a){return a.clientWidth||Math.round(a.getBBox().width)||a.parentNode.clientWidth}var v="http://www.w3.org/2000/svg",w="http://www.w3.org/2000/xmlns/",x="http://www.w3.org/1999/xhtml";return{_node:i(a,d,e,f?f._node:void 0,g),_parent:f,parent:function(){return this._parent},attr:function(a,b){return h(this._node,a,b),this},empty:function(){return l(this._node),this},remove:function(){return m(this._node),this.parent()},replace:function(a){return a._parent=this._parent,n(this._node,a._node),a},append:function(a,b){return a._parent=this,o(this._node,a._node,b),a},elem:function(a,b,d,e){return c.Svg(a,b,d,this,e)},foreignObject:function(a,b,c,d,e,f,g){return j(a,b,c,d,e,f,this,g)},text:function(a){return k(this._node,a),this},addClass:function(a){return q(this._node,a),this},removeClass:function(a){return r(this._node,a),this},removeAllClasses:function(){return s(this._node),this},classes:function(){return p(this._node)},height:function(){return t(this._node)},width:function(){return u(this._node)}}}}(window,document,a),function(a,b,c){"use strict";c.Line=function(b,d,e,f){function g(a){var b,e,f,g=[],h=c.normalizeDataArray(c.getDataArray(d),d.labels.length);m=c.createSvg(o,a.width,a.height,a.classNames.chart),f=c.getBounds(m,h,a),b=a.axisX.offset,a.axisX.showLabel&&(b+=c.calculateLabelOffset(m,d.labels,[a.classNames.label,a.classNames.horizontal].join(" "),a.axisX.labelInterpolationFnc,"height")),e=a.axisY.offset,a.axisY.showLabel&&(e+=c.calculateLabelOffset(m,f.values,[a.classNames.label,a.classNames.horizontal].join(" "),a.axisY.labelInterpolationFnc,"width"));var i=c.createChartRect(m,a,b,e),j=m.elem("g"),k=m.elem("g");c.createXAxis(i,d,k,j,a,p),c.createYAxis(i,f,k,j,e,a,p);for(var l=0;l4)for(var u=c.catmullRom2bezier(r),v=0;va.x;return d&&"explode"===c||!d&&"implode"===c?"start":d&&"implode"===c||!d&&"explode"===c?"end":"middle"}function h(a){var b,e,f,h,i=[],j=a.startAngle,k=c.getDataArray(d);n=c.createSvg(p,a.width,a.height,a.classNames.chart),b=c.createChartRect(n,a,0,0),e=Math.min(b.width()/2,b.height()/2),h=a.total||k.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 l={x:b.x1+b.width()/2,y:b.y2+b.height()/2},m=1===d.series.filter(function(a){return 0!==a}).length,o=0;o=r-j?"0":"1",v=["M",t.x,t.y,"A",e,e,0,u,0,s.x,s.y];a.donut===!1&&v.push("L",l.x,l.y);var w=i[o].elem("path",{d:v.join(" ")},a.classNames.slice+(a.donut?" "+a.classNames.donut:""));if(w.attr({value:k[o]},c.xmlNs.uri),a.donut===!0&&w.attr({style:"stroke-width: "+ +a.donutWidth+"px"}),q.emit("draw",{type:"slice",value:k[o],totalDataSum:h,index:o,group:i[o],element:w,center:l,radius:e,startAngle:j,endAngle:r}),a.showLabel){var x=c.polarToCartesian(l.x,l.y,f,j+(r-j)/2),y=a.labelInterpolationFnc(d.labels?d.labels[o]:k[o],o),z=i[o].elem("text",{dx:x.x,dy:x.y,"text-anchor":g(l,x,a.labelDirection)},a.classNames.label).text(""+y);q.emit("draw",{type:"label",index:o,group:i[o],element:z,text:""+y,x:x.x,y:x.y})}j=r}}function i(){h(m.currentOptions)}function j(){a.removeEventListener("resize",i),m.removeMediaQueryListeners()}function k(a,b){q.addEventHandler(a,b)}function l(a,b){q.removeEventHandler(a,b)}var m,n,o={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"},p=c.querySelector(b),q=c.EventEmitter();a.addEventListener("resize",i),m=c.optionsProvider(o,e,f,q),setTimeout(function(){h(m.currentOptions)},0);var r={version:c.version,update:i,on:k,off:l,detach:j};return p.chartist=r,r}}(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.2.4",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 a.height()-2*b.chartPadding-b.axisX.offset},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.calculateLabelOffset=function(a,b,c,d,e){for(var f=0,g=0;gd;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 q=c.catmullRom2bezier(n),r=0;ra.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}); //# sourceMappingURL=chartist.min.map \ No newline at end of file diff --git a/libdist/chartist.min.map b/libdist/chartist.min.map index da920476..0f33e73d 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","normalizeDataArray","dataArray","j","orderOfMagnitude","value","Math","floor","log","abs","LN10","projectLength","bounds","options","availableHeight","getAvailableHeight","range","chartPadding","axisX","offset","getHighLow","highLow","high","Number","MAX_VALUE","low","getBounds","normalizedData","referenceValue","newMin","newMax","max","min","valueRange","oom","pow","ceil","step","numberOfSteps","round","axisY","scaleMinSpace","values","push","calculateLabelOffset","labelClass","labelInterpolationFnc","offsetFnc","interpolated","label","elem","dx","dy","text","remove","polarToCartesian","centerX","centerY","radius","angleInDegrees","angleInRadians","PI","x","cos","y","sin","createChartRect","xAxisOffset","yAxisOffset","x1","y1","x2","y2","createXAxis","chartRect","grid","labels","eventEmitter","forEach","index","interpolatedValue","space","pos","showGrid","gridElement","classNames","horizontal","join","emit","type","axis","group","element","showLabel","labelPos","labelElement","createYAxis","vertical","labelAlign","text-anchor","projectPoint","optionsProvider","defaultOptions","responsiveOptions","updateCurrentOptions","previousOptions","currentOptions","baseOptions","mql","matchMedia","matches","removeMediaQueryListeners","mediaQueryListeners","removeListener","addListener",{"end":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":24405,"pos":24391,"col":12,"line":640,"value":"currentOptions","type":"name"},"start":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":24405,"pos":24391,"col":12,"line":640,"value":"currentOptions","type":"name"},"name":"currentOptions"},"catmullRom2bezier","crp","z","d","iLen","p","EventEmitter","addEventHandler","event","handler","handlers","removeEventHandler","splice","indexOf","xmlNs","qualifiedName","prefix","uri","name","attributes","parent","insertFirst","node","ns","Object","keys","key","setAttributeNS","setAttribute","parentNode","createElementNS","svgNs","firstChild","insertBefore","foreignObject","content","createElement","innerHTML","xhtmlNs","fnObj","t","createTextNode","removeChild","newChild","replaceChild","append","child","classes","getAttribute","trim","split","names","concat","filter","self","removeClass","removedClasses","clientHeight","getBBox","clientWidth","_parent","newElement","Line","createChart","seriesGroups","chart","series-name","point","pathCoordinates","showPoint","showLine","showArea","pathElements","lineSmooth","cr","k","l","areaBase","areaPathElements","slice","areaBaseProjected","area","line","update","detach","removeEventListener","on","off","addEventListener","setTimeout","api","chartist","Bar","zeroPoint","biPol","periodHalfWidth","bar","seriesBarDistance","thin","thick","Pie","determineAnchorPosition","center","direction","toTheRight","labelRadius","totalDataSum","startAngle","total","reduce","previousValue","currentValue","donut","donutWidth","labelOffset","hasSingleValInSeries","val","endAngle","start","end","arcSweep","path","labelPosition","labelDirection","labelOverflow"],"mappings":";;;;;;CAAC,SAASA,EAAMC,GACU,gBAAZC,SACNC,OAAOD,QAAUD,IAEK,kBAAXG,SAAyBA,OAAOC,IAC3CD,UAAWH,GAGXD,EAAe,SAAIC,KAEzBK,KAAM,WAYN,GAAIC,KA4lEJ,OA3lEAA,GAASC,QAAU,QAElB,SAAUC,EAAQC,EAAUH,GAC3B,YASAA,GAASI,KAAO,SAAUC,GACxB,MAAOA,IAUTL,EAASM,cAAgB,SAAUD,GAEjC,MAAOE,QAAOC,aAAa,GAAKH,EAAI,KAWtCL,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,IASTV,EAASa,eAAiB,SAASC,GAKjC,MAJqB,gBAAXA,KACRA,EAAS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AAKA,EACLH,OAAQA,EAIV,OADA3N,GAAUkO,SAAWD,EACdA,IAGTnP,OAAQC,SAAUH,GAEbA","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.2.3\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.2.3';\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 /**\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\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 svg.height() - (options.chartPadding * 2) - options.axisX.offset;\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 while (true) {\n var length = Chartist.projectLength(svg, bounds.step / 2, bounds, options);\n if (length >= 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 the needed offset to fit in the labels\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Array} data The array that contains the data to be visualized in the chart\n * @param {Object} labelClass All css classes of the label\n * @param {Function} labelInterpolationFnc The function that interpolates the label value\n * @param {String} offsetFnc width or height. Will be used to call function on SVG element to get length\n * @return {Number} The number that represents the label offset in pixels\n */\n Chartist.calculateLabelOffset = function (svg, data, labelClass, labelInterpolationFnc, offsetFnc) {\n var offset = 0;\n for (var i = 0; i < data.length; i++) {\n // If interpolation function returns falsy value we skipp this label\n var interpolated = labelInterpolationFnc(data[i], i);\n if (!interpolated && interpolated !== 0) {\n continue;\n }\n\n var label = svg.elem('text', {\n dx: 0,\n dy: 0\n }, labelClass).text('' + interpolated);\n\n // Check if this is the largest label and update offset\n offset = Math.max(offset, label[offsetFnc]());\n // Remove label after offset Calculation\n label.remove();\n }\n\n return offset;\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 * @param {Number} xAxisOffset The offset of the x-axis to the border of the svg element\n * @param {Number} yAxisOffset The offset of the y-axis to the border of the svg element\n * @return {Object} The chart rectangles coordinates inside the svg element plus the rectangles measurements\n */\n Chartist.createChartRect = function (svg, options, xAxisOffset, yAxisOffset) {\n return {\n x1: options.chartPadding + yAxisOffset,\n y1: (Chartist.getPixelLength(options.height) || svg.height()) - options.chartPadding - xAxisOffset,\n x2: (Chartist.getPixelLength(options.width) || svg.width()) - options.chartPadding,\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 * 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 */\n Chartist.createXAxis = function (chartRect, data, grid, labels, options, eventEmitter) {\n // Create X-Axis\n data.labels.forEach(function (value, index) {\n var interpolatedValue = options.axisX.labelInterpolationFnc(value, index),\n space = chartRect.width() / data.labels.length,\n pos = chartRect.x1 + space * 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 // Use config offset for setting labels of\n var labelPos = {\n x: pos + 2,\n y: 0\n };\n\n var labelElement = labels.elem('text', {\n dx: labelPos.x\n }, [options.classNames.label, options.classNames.horizontal].join(' ')).text('' + interpolatedValue);\n\n // TODO: should use 'alignment-baseline': 'hanging' but not supported in firefox. Instead using calculated height to offset y pos\n labelPos.y = chartRect.y1 + labelElement.height() + options.axisX.offset;\n labelElement.attr({\n dy: labelPos.y\n });\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: labelPos.x,\n y: labelPos.y,\n space: space\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 {Number} offset Offset for the y-axis\n * @param {Object} options The Object that contains all the optional values for the chart\n */\n Chartist.createYAxis = function (chartRect, bounds, grid, labels, offset, options, eventEmitter) {\n // Create Y-Axis\n bounds.values.forEach(function (value, index) {\n var interpolatedValue = options.axisY.labelInterpolationFnc(value, index),\n space = chartRect.height() / bounds.values.length,\n pos = chartRect.y1 - space * 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 // Use calculated offset and include padding for label x position\n // TODO: Review together with possibilities to style labels. Maybe we should start using fixed label width which is easier and also makes multi line labels with foreignObjects easier\n var labelPos = {\n x: options.axisY.labelAlign === 'right' ? offset - options.axisY.offset + options.chartPadding : options.chartPadding,\n y: pos - 2\n };\n\n var labelElement = labels.elem('text', {\n dx: options.axisY.labelAlign === 'right' ? offset - options.axisY.offset + options.chartPadding : options.chartPadding,\n dy: pos - 2,\n 'text-anchor': options.axisY.labelAlign === 'right' ? 'end' : 'start'\n }, [options.classNames.label, options.classNames.vertical].join(' ')).text('' + interpolatedValue);\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: labelPos.x,\n y: labelPos.y,\n space: space\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 * 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} [x] The X position where the foreignObject will be placed relative to the next higher ViewBox\n * @param {String} [y] The Y position where the foreignObject will be placed relative to the next higher ViewBox\n * @param {String} [width] The width of the foreignElement\n * @param {String} [height] The height of the foreignElement\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, x, y, width, height, 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 = Chartist.Svg('foreignObject', {\n x: x,\n y: y,\n width: width,\n height: height\n }, className, parent, 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, x, y, width, height, className, insertFirst) {\n return foreignObject(content, x, y, width, height, 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 }(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 /**\n * This method creates a new line chart and returns API object that you can use for later changes.\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: 10,\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: 15,\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 * // For the Y-Axis you can set a label alignment property of right or left\n * labelAlign: 'right',\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 * 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 * Chartist.Line('.ct-chart', data, null, responsiveOptions);\n *\n */\n Chartist.Line = function (query, data, options, responsiveOptions) {\n\n var defaultOptions = {\n axisX: {\n offset: 10,\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 15,\n showLabel: true,\n showGrid: true,\n labelAlign: 'right',\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 optionsProvider,\n container = Chartist.querySelector(query),\n svg,\n eventEmitter = Chartist.EventEmitter();\n\n function createChart(options) {\n var xAxisOffset,\n yAxisOffset,\n seriesGroups = [],\n bounds,\n normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(data), data.labels.length);\n\n // Create new svg object\n svg = Chartist.createSvg(container, options.width, options.height, options.classNames.chart);\n\n // initialize bounds\n bounds = Chartist.getBounds(svg, normalizedData, options);\n\n xAxisOffset = options.axisX.offset;\n if (options.axisX.showLabel) {\n xAxisOffset += Chartist.calculateLabelOffset(\n svg,\n data.labels,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisX.labelInterpolationFnc,\n 'height'\n );\n }\n\n yAxisOffset = options.axisY.offset;\n if (options.axisY.showLabel) {\n yAxisOffset += Chartist.calculateLabelOffset(\n svg,\n bounds.values,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisY.labelInterpolationFnc,\n 'width'\n );\n }\n\n var chartRect = Chartist.createChartRect(svg, options, xAxisOffset, yAxisOffset);\n // Start drawing\n var labels = svg.elem('g'),\n grid = svg.elem('g');\n\n Chartist.createXAxis(chartRect, data, grid, labels, options, eventEmitter);\n Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, eventEmitter);\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < data.series.length; i++) {\n seriesGroups[i] = svg.elem('g');\n\n // If the series is an object and contains a name we add a custom attribute\n if(data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': 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 (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 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 // 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.Line\n */\n function update() {\n createChart(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.Line\n */\n function detach() {\n window.removeEventListener('resize', update);\n 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.Line\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 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.Line\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 eventEmitter.removeEventHandler(event, handler);\n }\n\n // Initialization of the chart\n\n window.addEventListener('resize', update);\n\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 optionsProvider = Chartist.optionsProvider(defaultOptions, options, responsiveOptions, eventEmitter);\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 createChart(optionsProvider.currentOptions);\n }, 0);\n\n // Public members of the module (revealing module pattern style)\n var api = {\n version: Chartist.version,\n update: update,\n on: on,\n off: off,\n detach: detach\n };\n\n container.chartist = api;\n return api;\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 /**\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 line chart\n * var options = {\n * // Options for X-Axis\n * axisX: {\n * // The offset of the labels to the chart area\n * offset: 10,\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: 15,\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 * // For the Y-Axis you can set a label alignment property of right or left\n * labelAlign: 'right',\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 * // 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 * // 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 * point: 'ct-point',\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 * 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 * 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 * heigh: 10\n * });\n *\n */\n Chartist.Bar = function (query, data, options, responsiveOptions) {\n\n var defaultOptions = {\n axisX: {\n offset: 10,\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 15,\n showLabel: true,\n showGrid: true,\n labelAlign: 'right',\n labelInterpolationFnc: Chartist.noop,\n scaleMinSpace: 40\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 thin: 'ct-thin',\n thick: 'ct-thick',\n grid: 'ct-grid',\n vertical: 'ct-vertical',\n horizontal: 'ct-horizontal'\n }\n },\n optionsProvider,\n container = Chartist.querySelector(query),\n svg,\n eventEmitter = Chartist.EventEmitter();\n\n function createChart(options) {\n var xAxisOffset,\n yAxisOffset,\n seriesGroups = [],\n bounds,\n normalizedData = Chartist.normalizeDataArray(Chartist.getDataArray(data), data.labels.length);\n\n // Create new svg element\n svg = Chartist.createSvg(container, options.width, options.height, options.classNames.chart);\n\n // initialize bounds\n bounds = Chartist.getBounds(svg, normalizedData, options, 0);\n\n xAxisOffset = options.axisX.offset;\n if (options.axisX.showLabel) {\n xAxisOffset += Chartist.calculateLabelOffset(\n svg,\n data.labels,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisX.labelInterpolationFnc,\n 'height'\n );\n }\n\n yAxisOffset = options.axisY.offset;\n if (options.axisY.showLabel) {\n yAxisOffset += Chartist.calculateLabelOffset(\n svg,\n bounds.values,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisY.labelInterpolationFnc,\n 'width'\n );\n }\n\n var chartRect = Chartist.createChartRect(svg, options, xAxisOffset, yAxisOffset);\n // Start drawing\n var labels = svg.elem('g'),\n grid = svg.elem('g'),\n // Projected 0 point\n zeroPoint = Chartist.projectPoint(chartRect, bounds, [0], 0);\n\n Chartist.createXAxis(chartRect, data, grid, labels, options, eventEmitter);\n Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, eventEmitter);\n\n // Draw the series\n // initialize series groups\n for (var i = 0; i < 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 - (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] = svg.elem('g');\n\n // If the series is an object and contains a name we add a custom attribute\n if(data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': 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 (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 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 // 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.Bar\n */\n function update() {\n createChart(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.Bar\n */\n function detach() {\n window.removeEventListener('resize', update);\n 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.Bar\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 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.Bar\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 eventEmitter.removeEventHandler(event, handler);\n }\n\n // Initialization of the chart\n\n window.addEventListener('resize', update);\n\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 optionsProvider = Chartist.optionsProvider(defaultOptions, options, responsiveOptions, eventEmitter);\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 createChart(optionsProvider.currentOptions);\n }, 0);\n\n // Public members of the module (revealing module pattern style)\n var api = {\n version: Chartist.version,\n update: update,\n on: on,\n off: off,\n detach: detach\n };\n\n container.chartist = api;\n return api;\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 /**\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 * Chartist.Pie('.ct-chart', {\n * series: [10, 2, 4, 3]\n * });\n *\n * @example\n * // Drawing a donut chart\n * 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 * 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 * Chartist.Pie('.ct-chart', {\n * series: [20, 10, 30, 40]\n * }, {\n * chartPadding: 30,\n * labelOffset: 50,\n * labelDirection: 'explode'\n * });\n */\n Chartist.Pie = function (query, data, options, responsiveOptions) {\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 optionsProvider,\n container = Chartist.querySelector(query),\n svg,\n eventEmitter = Chartist.EventEmitter();\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(data);\n\n // Create SVG.js draw\n svg = Chartist.createSvg(container, options.width, options.height, options.classNames.chart);\n // Calculate charting rect\n chartRect = Chartist.createChartRect(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 = 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 < data.series.length; i++) {\n seriesGroups[i] = 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(data.series[i].name) {\n seriesGroups[i].attr({\n 'series-name': 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 (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 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(data.labels ? 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 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 // 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.Pie\n *\n */\n function update() {\n createChart(optionsProvider.currentOptions);\n }\n\n /**\n * This method will detach the chart from any event listeners that have been added. This includes window.resize and media query listeners for the responsive options. Call this method in order to de-initialize dynamically created / removed charts.\n *\n * @memberof Chartist.Pie\n */\n function detach() {\n window.removeEventListener('resize', update);\n 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.Pie\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 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.Pie\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 eventEmitter.removeEventHandler(event, handler);\n }\n\n // Initialization of the chart\n\n window.addEventListener('resize', update);\n\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 optionsProvider = Chartist.optionsProvider(defaultOptions, options, responsiveOptions, eventEmitter);\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 createChart(optionsProvider.currentOptions);\n }, 0);\n\n // Public members of the module (revealing module pattern style)\n var api = {\n version: Chartist.version,\n update: update,\n on: on,\n off: off,\n detach: detach\n };\n\n container.chartist = api;\n return api;\n };\n\n }(window, document, Chartist));\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","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","normalizeDataArray","dataArray","j","orderOfMagnitude","value","Math","floor","log","abs","LN10","projectLength","bounds","options","availableHeight","getAvailableHeight","range","chartPadding","axisX","offset","getHighLow","highLow","high","Number","MAX_VALUE","low","getBounds","normalizedData","referenceValue","newMin","newMax","max","min","valueRange","oom","pow","ceil","step","numberOfSteps","round","axisY","scaleMinSpace","values","push","calculateLabelOffset","labelClass","labelInterpolationFnc","offsetFnc","interpolated","label","elem","dx","dy","text","remove","polarToCartesian","centerX","centerY","radius","angleInDegrees","angleInRadians","PI","x","cos","y","sin","createChartRect","xAxisOffset","yAxisOffset","x1","y1","x2","y2","createXAxis","chartRect","grid","labels","eventEmitter","forEach","index","interpolatedValue","space","pos","showGrid","gridElement","classNames","horizontal","join","emit","type","axis","group","element","showLabel","labelPos","labelElement","createYAxis","vertical","labelAlign","text-anchor","projectPoint","optionsProvider","defaultOptions","responsiveOptions","updateCurrentOptions","previousOptions","currentOptions","baseOptions","mql","matchMedia","matches","removeMediaQueryListeners","mediaQueryListeners","removeListener","addListener",{"end":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":24464,"pos":24450,"col":12,"line":641,"value":"currentOptions","type":"name"},"start":{"file":"chartist.js","comments_before":[],"nlb":false,"endpos":24464,"pos":24450,"col":12,"line":641,"value":"currentOptions","type":"name"},"name":"currentOptions"},"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","addEventListener","bind","setTimeout","xmlNs","qualifiedName","prefix","uri","name","attributes","parent","insertFirst","node","ns","keys","key","setAttributeNS","setAttribute","parentNode","createElementNS","svgNs","firstChild","insertBefore","foreignObject","content","createElement","innerHTML","xhtmlNs","fnObj","t","createTextNode","removeChild","newChild","replaceChild","append","child","classes","getAttribute","trim","split","names","filter","self","removeClass","removedClasses","clientHeight","getBBox","clientWidth","_parent","newElement","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","thin","thick","determineAnchorPosition","center","direction","toTheRight","labelRadius","totalDataSum","startAngle","total","reduce","previousValue","currentValue","donut","donutWidth","labelOffset","hasSingleValInSeries","val","endAngle","start","end","arcSweep","path","labelPosition","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,KAytEJ,OAxtEAA,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,IASTV,EAASa,eAAiB,SAASC,GAKjC,MAJqB,gBAAXA,KACRA,EAASA,EAAOC,QAAQ,MAAO,MAGzBD,GAUVd,EAASgB,cAAgB,SAASC,GAChC,MAAOA,aAAiBC,MAAOD,EAAQd,EAASa,cAAcC,IAahEjB,EAASmB,UAAY,SAAUC,EAAWC,EAAOC,EAAQC,GACvD,GAAIC,EA8BJ,OA5BAH,GAAQA,GAAS,OACjBC,EAASA,GAAU,OAGWG,SAA1BL,EAAUM,aACZF,EAAMJ,EAAUM,YAAYC,MAC1BN,MAAOA,EACPC,OAAQA,IACPM,mBAAmBC,SAASN,GAAWI,MACxCG,MAAO,UAAYT,EAAQ,aAAeC,EAAS,MAGrDE,EAAIO,UAIJP,EAAMxB,EAASgC,IAAI,OAAOL,MACxBN,MAAOA,EACPC,OAAQA,IACPO,SAASN,GAAWI,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UH,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.2.4\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.2.4';\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\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 svg.height() - (options.chartPadding * 2) - options.axisX.offset;\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 while (true) {\n var length = Chartist.projectLength(svg, bounds.step / 2, bounds, options);\n if (length >= 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 the needed offset to fit in the labels\n *\n * @memberof Chartist.Core\n * @param {Object} svg The svg element for the chart\n * @param {Array} data The array that contains the data to be visualized in the chart\n * @param {Object} labelClass All css classes of the label\n * @param {Function} labelInterpolationFnc The function that interpolates the label value\n * @param {String} offsetFnc width or height. Will be used to call function on SVG element to get length\n * @return {Number} The number that represents the label offset in pixels\n */\n Chartist.calculateLabelOffset = function (svg, data, labelClass, labelInterpolationFnc, offsetFnc) {\n var offset = 0;\n for (var i = 0; i < data.length; i++) {\n // If interpolation function returns falsy value we skipp this label\n var interpolated = labelInterpolationFnc(data[i], i);\n if (!interpolated && interpolated !== 0) {\n continue;\n }\n\n var label = svg.elem('text', {\n dx: 0,\n dy: 0\n }, labelClass).text('' + interpolated);\n\n // Check if this is the largest label and update offset\n offset = Math.max(offset, label[offsetFnc]());\n // Remove label after offset Calculation\n label.remove();\n }\n\n return offset;\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 * @param {Number} xAxisOffset The offset of the x-axis to the border of the svg element\n * @param {Number} yAxisOffset The offset of the y-axis to the border of the svg element\n * @return {Object} The chart rectangles coordinates inside the svg element plus the rectangles measurements\n */\n Chartist.createChartRect = function (svg, options, xAxisOffset, yAxisOffset) {\n return {\n x1: options.chartPadding + yAxisOffset,\n y1: (Chartist.getPixelLength(options.height) || svg.height()) - options.chartPadding - xAxisOffset,\n x2: (Chartist.getPixelLength(options.width) || svg.width()) - options.chartPadding,\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 * 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 */\n Chartist.createXAxis = function (chartRect, data, grid, labels, options, eventEmitter) {\n // Create X-Axis\n data.labels.forEach(function (value, index) {\n var interpolatedValue = options.axisX.labelInterpolationFnc(value, index),\n space = chartRect.width() / data.labels.length,\n pos = chartRect.x1 + space * 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 // Use config offset for setting labels of\n var labelPos = {\n x: pos + 2,\n y: 0\n };\n\n var labelElement = labels.elem('text', {\n dx: labelPos.x\n }, [options.classNames.label, options.classNames.horizontal].join(' ')).text('' + interpolatedValue);\n\n // TODO: should use 'alignment-baseline': 'hanging' but not supported in firefox. Instead using calculated height to offset y pos\n labelPos.y = chartRect.y1 + labelElement.height() + options.axisX.offset;\n labelElement.attr({\n dy: labelPos.y\n });\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: labelPos.x,\n y: labelPos.y,\n space: space\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 {Number} offset Offset for the y-axis\n * @param {Object} options The Object that contains all the optional values for the chart\n */\n Chartist.createYAxis = function (chartRect, bounds, grid, labels, offset, options, eventEmitter) {\n // Create Y-Axis\n bounds.values.forEach(function (value, index) {\n var interpolatedValue = options.axisY.labelInterpolationFnc(value, index),\n space = chartRect.height() / bounds.values.length,\n pos = chartRect.y1 - space * 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 // Use calculated offset and include padding for label x position\n // TODO: Review together with possibilities to style labels. Maybe we should start using fixed label width which is easier and also makes multi line labels with foreignObjects easier\n var labelPos = {\n x: options.axisY.labelAlign === 'right' ? offset - options.axisY.offset + options.chartPadding : options.chartPadding,\n y: pos - 2\n };\n\n var labelElement = labels.elem('text', {\n dx: options.axisY.labelAlign === 'right' ? offset - options.axisY.offset + options.chartPadding : options.chartPadding,\n dy: pos - 2,\n 'text-anchor': options.axisY.labelAlign === 'right' ? 'end' : 'start'\n }, [options.classNames.label, options.classNames.vertical].join(' ')).text('' + interpolatedValue);\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: labelPos.x,\n y: labelPos.y,\n space: space\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 classes.\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.Line\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.Line\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.Line\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.Line\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\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 });\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} [x] The X position where the foreignObject will be placed relative to the next higher ViewBox\n * @param {String} [y] The Y position where the foreignObject will be placed relative to the next higher ViewBox\n * @param {String} [width] The width of the foreignElement\n * @param {String} [height] The height of the foreignElement\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, x, y, width, height, 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 = Chartist.Svg('foreignObject', {\n x: x,\n y: y,\n width: width,\n height: height\n }, className, parent, 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, x, y, width, height, className, insertFirst) {\n return foreignObject(content, x, y, width, height, 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 }(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: 10,\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 15,\n showLabel: true,\n showGrid: true,\n labelAlign: 'right',\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 xAxisOffset,\n yAxisOffset,\n 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 xAxisOffset = options.axisX.offset;\n if (options.axisX.showLabel) {\n xAxisOffset += Chartist.calculateLabelOffset(\n this.svg,\n this.data.labels,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisX.labelInterpolationFnc,\n 'height'\n );\n }\n\n yAxisOffset = options.axisY.offset;\n if (options.axisY.showLabel) {\n yAxisOffset += Chartist.calculateLabelOffset(\n this.svg,\n bounds.values,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisY.labelInterpolationFnc,\n 'width'\n );\n }\n\n var chartRect = Chartist.createChartRect(this.svg, options, xAxisOffset, yAxisOffset);\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);\n Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, this.eventEmitter);\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: 10,\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: 15,\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 * // For the Y-Axis you can set a label alignment property of right or left\n * labelAlign: 'right',\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: 10,\n showLabel: true,\n showGrid: true,\n labelInterpolationFnc: Chartist.noop\n },\n axisY: {\n offset: 15,\n showLabel: true,\n showGrid: true,\n labelAlign: 'right',\n labelInterpolationFnc: Chartist.noop,\n scaleMinSpace: 40\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 thin: 'ct-thin',\n thick: 'ct-thick',\n grid: 'ct-grid',\n vertical: 'ct-vertical',\n horizontal: 'ct-horizontal'\n }\n };\n\n function createChart(options) {\n var xAxisOffset,\n yAxisOffset,\n 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 xAxisOffset = options.axisX.offset;\n if (options.axisX.showLabel) {\n xAxisOffset += Chartist.calculateLabelOffset(\n this.svg,\n this.data.labels,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisX.labelInterpolationFnc,\n 'height'\n );\n }\n\n yAxisOffset = options.axisY.offset;\n if (options.axisY.showLabel) {\n yAxisOffset += Chartist.calculateLabelOffset(\n this.svg,\n bounds.values,\n [options.classNames.label, options.classNames.horizontal].join(' '),\n options.axisY.labelInterpolationFnc,\n 'width'\n );\n }\n\n var chartRect = Chartist.createChartRect(this.svg, options, xAxisOffset, yAxisOffset);\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);\n Chartist.createYAxis(chartRect, bounds, grid, labels, yAxisOffset, options, this.eventEmitter);\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 line chart\n * var options = {\n * // Options for X-Axis\n * axisX: {\n * // The offset of the labels to the chart area\n * offset: 10,\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: 15,\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 * // For the Y-Axis you can set a label alignment property of right or left\n * labelAlign: 'right',\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 * // 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 * // 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 * point: 'ct-point',\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 * heigh: 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