{"version":3,"sources":["chartist-plugin-fill-donut.js"],"names":["root","factory","define","amd","exports","module","require","Chartist","this","document","defaultOptions","fillClass","label","html","class","items","plugins","fillDonut","options","extend","chart","Pie","$chart","container","style","position","$svg","drawDonut","data","type","index","querySelector","$clone","group","_node","cloneNode","split","forEach","className","setAttribute","getAttribute","call","querySelectorAll","el","node","parentNode","removeChild","removeAttribute","insertBefore","childNodes","on","itemIndex","fillDonutOptions","thisItem","$wrapper","createElement","classList","add","item","id","content","offsetY","offsetX","length","insertAdjacentHTML","appendChild","cWidth","Math","ceil","offsetWidth","cHeight","clientHeight","wWidth","wHeight","bottom","left","top","right","center"],"mappings":"CAAE,SAASA,EAAMC,GACO,kBAAXC,SAAyBA,OAAOC,IACzCD,QAAQ,YAAaD,GACO,gBAAZG,SAChBC,OAAOD,QAAUH,EAAQK,QAAQ,aAEjCN,EAAK,8BAAgCC,EAAQD,EAAKO,WAEpDC,KAAM,SAASD,GAwIjB,MAjIC,UAAUE,EAAUF,GACjB,YAEA,IAAIG,IACAC,UAAW,gBACXC,OACIC,KAAM,MACNC,QAAO,uBAEXC,WAGJR,GAASS,QAAUT,EAASS,YAC5BT,EAASS,QAAQC,UAAY,SAAUC,GAEnC,MADAA,GAAUX,EAASY,UAAWT,EAAgBQ,GACvC,SAAmBE,GACtB,GAAIA,YAAiBb,GAASc,IAAK,CAC/B,GAAIC,GAASF,EAAMG,SACnBD,GAAOE,MAAMC,SAAW,UACxB,IAAIC,GAEAC,EAAY,SAASC,GACrB,GAAkB,UAAdA,EAAKC,KAAkB,CACJ,IAAfD,EAAKE,QACLJ,EAAOJ,EAAOS,cAAc,OAGhC,IAAIC,GAASJ,EAAKK,MAAMC,MAAMC,WAAU,EACxCjB,GAAQP,UAAUyB,MAAM,KAAKC,QAAQ,SAAUC,GAC3CN,EAAOO,aAAa,QAASP,EAAOQ,aAAa,SAAW,IAAMF,QAGnED,QAAQI,KAAKT,EAAOU,iBAAiB,QAAS,SAAUC,MACpDN,QAAQI,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/C,GACAkD,QACIA,OAAQ,EAAIhB,EAAKG,QAAU,KAC3Bc,KAAOT,EAASM,EAAUd,EAAKI,QAAU,MAE7Cc,KACIA,IAAK,EAAIlB,EAAKG,QAAU,KACxBc,KAAOT,EAASM,EAAUd,EAAKI,QAAU,MAE7Ca,MACIC,IAAMN,EAAUG,EAAWf,EAAKG,QAAU,KAC1Cc,KAAM,EAAIjB,EAAKI,QAAU,MAE7Be,OACID,IAAMN,EAAUG,EAAWf,EAAKG,QAAU,KAC1CgB,MAAO,EAAInB,EAAKI,QAAU,MAE9BgB,QACIF,IAAMN,EAAUG,EAAWf,EAAKG,QAAU,KAC1Cc,KAAOT,EAASM,EAAUd,EAAKI,QAAU,MAIjDvD,GAASY,OAAOmC,EAAS9B,MAAOA,EAAMkC,EAAKjC,mBAMjEhB,SAAUF,GAELA,EAASS,QAAQC","file":"chartist-plugin-fill-donut.min.js","sourcesContent":[";(function(root, factory) {\r\n if (typeof define === 'function' && define.amd) {\r\n define(['chartist'], factory);\r\n } else if (typeof exports === 'object') {\r\n module.exports = factory(require('chartist'));\r\n } else {\r\n root['Chartist.plugins.fillDonut'] = factory(root.Chartist);\r\n }\r\n}(this, function(Chartist) {\r\n/**\r\n * Chartist.js plugin to pre fill donuts with animations\r\n * author: moxx\r\n * author-url: https://github.com/moxx/chartist-plugin-fill-donut\r\n *\r\n */\r\n(function (document, Chartist) {\r\n 'use strict';\r\n\r\n var defaultOptions = {\r\n fillClass: 'ct-fill-donut',\r\n label: {\r\n html: 'div',\r\n class: 'ct-fill-donut-label'\r\n },\r\n items: [{}]\r\n };\r\n\r\n Chartist.plugins = Chartist.plugins || {};\r\n Chartist.plugins.fillDonut = function (options) {\r\n options = Chartist.extend({}, defaultOptions, options);\r\n return function fillDonut(chart) {\r\n if (chart instanceof Chartist.Pie) {\r\n var $chart = chart.container;\r\n $chart.style.position = 'relative';\r\n var $svg;\r\n\r\n var drawDonut = function(data) {\r\n if (data.type === 'slice') {\r\n if (data.index === 0) {\r\n $svg = $chart.querySelector('svg');\r\n }\r\n\r\n var $clone = data.group._node.cloneNode(true);\r\n options.fillClass.split(\" \").forEach(function (className) {\r\n $clone.setAttribute('class', $clone.getAttribute('class') + ' ' + className);\r\n });\r\n\r\n [].forEach.call($clone.querySelectorAll('path'), function (el) {\r\n [].forEach.call(el.querySelectorAll('animate'), function (node) {\r\n node.parentNode.removeChild(node);\r\n });\r\n\r\n el.removeAttribute('stroke-dashoffset');\r\n });\r\n\r\n $svg.insertBefore($clone, $svg.childNodes[0]);\r\n\r\n }\r\n };\r\n\r\n chart.on('draw', function (data) {\r\n drawDonut(data);\r\n });\r\n\r\n chart.on('created', function (data) {\r\n var itemIndex = 0;\r\n\r\n if (chart.options.fillDonutOptions) {\r\n options = Chartist.extend({}, options, chart.options.fillDonutOptions);\r\n drawDonut(data);\r\n }\r\n\r\n [].forEach.call(options.items, function (thisItem) {\r\n var $wrapper = document.createElement(options.label.html);\r\n options.label.class.split(\" \").forEach(function (className) {\r\n if ($wrapper.classList) {\r\n $wrapper.classList.add(className);\r\n } else {\r\n $wrapper.className += ' ' + className;\r\n }\r\n });\r\n var item = Chartist.extend({}, {\r\n class: '',\r\n id: '',\r\n content: 'fillText',\r\n position: 'center', //bottom, top, left, right\r\n offsetY: 0, //top, bottom in px\r\n offsetX: 0 //left, right in px\r\n }, thisItem);\r\n\r\n\r\n if (item.id.length > 0) {\r\n $wrapper.setAttribute('id', item.id);\r\n }\r\n if (item.class.length > 0) {\r\n $wrapper.setAttribute('class', item.class);\r\n }\r\n\r\n [].forEach.call($chart.querySelectorAll('*[data-fill-index$=\"fdid-' + itemIndex + '\"]'), function (node) {\r\n node.parentNode.removeChild(node);\r\n });\r\n $wrapper.setAttribute('data-fill-index', 'fdid-' + itemIndex);\r\n itemIndex += 1;\r\n\r\n $wrapper.insertAdjacentHTML('beforeend', item.content);\r\n $wrapper.style.position = 'absolute';\r\n $chart.appendChild($wrapper);\r\n\r\n var cWidth = Math.ceil($chart.offsetWidth / 2);\r\n var cHeight = Math.ceil($chart.clientHeight / 2);\r\n var wWidth = Math.ceil($wrapper.offsetWidth / 2);\r\n var wHeight = Math.ceil($wrapper.clientHeight / 2);\r\n\r\n var style = {\r\n bottom: {\r\n bottom: 0 + item.offsetY + \"px\",\r\n left: (cWidth - wWidth) + item.offsetX + \"px\"\r\n },\r\n top: {\r\n top: 0 + item.offsetY + \"px\",\r\n left: (cWidth - wWidth) + item.offsetX + \"px\"\r\n },\r\n left: {\r\n top: (cHeight - wHeight) + item.offsetY + \"px\",\r\n left: 0 + item.offsetX + \"px\"\r\n },\r\n right: {\r\n top: (cHeight - wHeight) + item.offsetY + \"px\",\r\n right: 0 + item.offsetX + \"px\"\r\n },\r\n center: {\r\n top: (cHeight - wHeight) + item.offsetY + \"px\",\r\n left: (cWidth - wWidth) + item.offsetX + \"px\"\r\n }\r\n };\r\n\r\n Chartist.extend($wrapper.style, style[item.position]);\r\n });\r\n });\r\n }\r\n };\r\n };\r\n}(document, Chartist)); // jshint ignore:line\r\n\r\nreturn Chartist.plugins.fillDonut;\r\n}));\r\n"]}