{"version":3,"sources":["chartist-plugin-pointlabels.js"],"names":["root","factory","define","amd","Chartist","returnExportsGlobal","exports","module","require","this","window","document","defaultOptions","labelClass","labelOffset","x","y","textAnchor","align","labelInterpolationFnc","noop","labelPositionCalculation","point","data","bar","left","x1","y1","center","x2","right","plugins","ctPointLabels","options","addLabel","position","value","undefined","group","elem","style","text","extend","chart","constructor","name","on","positonCalculator","type"],"mappings":";;;;;;CAAC,SAAUA,EAAMC,GACO,kBAAXC,SAAyBA,OAAOC,IAEzCD,QAAQ,YAAa,SAAUE,GAC7B,MAAQJ,GAAKK,oBAAsBJ,EAAQG,KAEjB,gBAAZE,SAIhBC,OAAOD,QAAUL,EAAQO,QAAQ,aAEjCR,EAAK,kCAAoCC,EAAQG,WAEnDK,KAAM,SAAUL,GAoFhB,MA7EC,UAASM,EAAQC,EAAUP,GAC1B,YAEA,IAAIQ,IACFC,WAAY,WACZC,aACEC,EAAG,EACHC,GAAI,IAENC,WAAY,SACZC,MAAO,SACPC,sBAAuBf,EAASgB,MAG9BC,GACFC,MAAO,SAASC,GACd,OACER,EAAGQ,EAAKR,EACRC,EAAGO,EAAKP,IAGZQ,KACEC,KAAM,SAASF,GACb,OACER,EAAGQ,EAAKG,GACRV,EAAGO,EAAKI,KAGZC,OAAQ,SAASL,GACf,OACER,EAAGQ,EAAKG,IAAMH,EAAKM,GAAKN,EAAKG,IAAM,EACnCV,EAAGO,EAAKI,KAGZG,MAAO,SAASP,GACd,OACER,EAAGQ,EAAKM,GACRb,EAAGO,EAAKI,MAMhBvB,GAAS2B,QAAU3B,EAAS2B,YAC5B3B,EAAS2B,QAAQC,cAAgB,SAASC,GAIxC,QAASC,GAASC,EAAUZ,GAE1B,GAAIa,OAAyBC,KAAjBd,EAAKa,MAAMrB,GAAmBQ,EAAKa,MAAMpB,EAClDO,EAAKa,MAAMrB,EAAI,KAAOQ,EAAKa,MAAMpB,EAClCO,EAAKa,MAAMpB,GAAKO,EAAKa,MAAMrB,CAE7BQ,GAAKe,MAAMC,KAAK,QACdxB,EAAGoB,EAASpB,EAAIkB,EAAQnB,YAAYC,EACpCC,EAAGmB,EAASnB,EAAIiB,EAAQnB,YAAYE,EACpCwB,MAAO,gBAAkBP,EAAQhB,YAChCgB,EAAQpB,YAAY4B,KAAKR,EAAQd,sBAAsBiB,IAG5D,MAfAH,GAAU7B,EAASsC,UAAW9B,EAAgBqB,GAevC,SAAuBU,GAC5B,OAAQA,EAAMC,YAAYC,MACxB,IAAK,OACL,IAAK,MACLF,EAAMG,GAAG,OAAQ,SAASvB,GACxB,GAAIwB,GAAoB1B,EAAyBE,EAAKyB,OAAS3B,EAAyBE,EAAKyB,MAAMf,EAAQf,QAAUG,EAAyBE,EAAKyB,KAC/ID,IACFb,EAASa,EAAkBxB,GAAOA,SAO5Cb,OAAQC,SAAUP,GAEbA,EAAS2B,QAAQC","file":"chartist-plugin-pointlabels.min.js","sourcesContent":["(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define([\"chartist\"], function (Chartist) {\n return (root.returnExportsGlobal = factory(Chartist));\n });\n } else if (typeof exports === 'object') {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like enviroments that support module.exports,\n // like Node.\n module.exports = factory(require(\"chartist\"));\n } else {\n root['Chartist.plugins.ctPointLabels'] = factory(Chartist);\n }\n}(this, function (Chartist) {\n\n /**\n * Chartist.js plugin to display a data label on top of the points in a line chart.\n *\n */\n /* global Chartist */\n (function(window, document, Chartist) {\n 'use strict';\n\n var defaultOptions = {\n labelClass: 'ct-label',\n labelOffset: {\n x: 0,\n y: -10\n },\n textAnchor: 'middle',\n align: 'center',\n labelInterpolationFnc: Chartist.noop\n };\n\n var labelPositionCalculation = {\n point: function(data) {\n return {\n x: data.x,\n y: data.y\n };\n },\n bar: {\n left: function(data) {\n return {\n x: data.x1,\n y: data.y1\n };\n },\n center: function(data) {\n return {\n x: data.x1 + (data.x2 - data.x1) / 2,\n y: data.y1\n };\n },\n right: function(data) {\n return {\n x: data.x2,\n y: data.y1\n };\n }\n }\n };\n\n Chartist.plugins = Chartist.plugins || {};\n Chartist.plugins.ctPointLabels = function(options) {\n\n options = Chartist.extend({}, defaultOptions, options);\n\n function addLabel(position, data) {\n // if x and y exist concat them otherwise output only the existing value\n var value = data.value.x !== undefined && data.value.y ?\n (data.value.x + ', ' + data.value.y) :\n data.value.y || data.value.x;\n\n data.group.elem('text', {\n x: position.x + options.labelOffset.x,\n y: position.y + options.labelOffset.y,\n style: 'text-anchor: ' + options.textAnchor\n }, options.labelClass).text(options.labelInterpolationFnc(value));\n }\n\n return function ctPointLabels(chart) {\n switch (chart.constructor.name) {\n case 'Line':\n case 'Bar':\n chart.on('draw', function(data) {\n var positonCalculator = labelPositionCalculation[data.type] && labelPositionCalculation[data.type][options.align] || labelPositionCalculation[data.type];\n if (positonCalculator) {\n addLabel(positonCalculator(data), data);\n }\n });\n }\n };\n };\n\n }(window, document, Chartist));\n\n return Chartist.plugins.ctPointLabels;\n\n}));\n"]}