{"version":3,"sources":["chartist-plugin-axistitle.js"],"names":["root","factory","define","amd","Chartist","returnExportsGlobal","exports","module","require","this","axisDefaults","axisTitle","axisClass","offset","x","y","textAnchor","flipTitle","defaultOptions","axisX","axisY","getTitle","title","Function","getClasses","classes","plugins","ctAxisTitle","options","extend","chart","on","data","Error","xPos","yPos","chartPadding","normalizePadding","axisLength","left","top","position","Svg","addClass","text","attr","text-anchor","svg","append","transform"],"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,gCAAkCC,EAAQG,WAEjDK,KAAM,SAAUL,GAkIhB,MA1HA,UAAUA,GACR,YAEA,IAAIM,IACFC,UAAW,GACXC,UAAW,gBACXC,QACEC,EAAG,EACHC,EAAG,GAELC,WAAY,SACZC,WAAW,GAGTC,GACFC,MAAOT,EACPU,MAAOV,GAGLW,EAAW,SAASC,GACtB,MAAIA,aAAiBC,UACZD,IAEFA,GAGLE,EAAa,SAASC,GACxB,MAAIA,aAAmBF,UACdE,IAEFA,EAGTrB,GAASsB,QAAUtB,EAASsB,YAC5BtB,EAASsB,QAAQC,YAAc,SAASC,GAGtC,MAFAA,GAAUxB,EAASyB,UAAWX,EAAgBU,GAEvC,SAAqBE,GAC1BA,EAAMC,GAAG,UAAW,SAASC,GAC3B,IAAKJ,EAAQT,MAAMR,YAAciB,EAAQR,MAAMT,UAC7C,KAAM,IAAIsB,OACR,gEAEG,KAAKD,EAAKb,QAAUa,EAAKZ,MAC9B,KAAM,IAAIa,OACR,4EAIJ,IAAIC,GACFC,EACAb,EACAc,EAAehC,EAASiC,iBAAiBL,EAAKJ,QAAQQ,aAgCxD,IA7BIR,EAAQT,MAAMR,WAAaqB,EAAKb,QAClCe,EACEF,EAAKb,MAAMmB,WAAa,EACx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esContent":["(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.ctAxisTitle'] = factory(Chartist);\n }\n}(this, function (Chartist) {\n\n /**\n * Chartist.js plugin to display a title for 1 or 2 axes.\n * version 0.0.7\n * author: alex stanbury\n */\n /* global Chartist */\n (function(Chartist) {\n \"use strict\";\n\n var axisDefaults = {\n axisTitle: \"\",\n axisClass: \"ct-axis-title\",\n offset: {\n x: 0,\n y: 0\n },\n textAnchor: \"middle\",\n flipTitle: false\n };\n\n var defaultOptions = {\n axisX: axisDefaults,\n axisY: axisDefaults\n };\n\n var getTitle = function(title) {\n if (title instanceof Function) {\n return title();\n }\n return title;\n };\n\n var getClasses = function(classes) {\n if (classes instanceof Function) {\n return classes();\n }\n return classes;\n };\n\n Chartist.plugins = Chartist.plugins || {};\n Chartist.plugins.ctAxisTitle = function(options) {\n options = Chartist.extend({}, defaultOptions, options);\n\n return function ctAxisTitle(chart) {\n chart.on(\"created\", function(data) {\n if (!options.axisX.axisTitle && !options.axisY.axisTitle) {\n throw new Error(\n \"ctAxisTitle plugin - You must provide at least one axis title\"\n );\n } else if (!data.axisX && !data.axisY) {\n throw new Error(\n \"ctAxisTitle plugin can only be used on charts that have at least one axis\"\n );\n }\n\n var xPos,\n yPos,\n title,\n chartPadding = Chartist.normalizePadding(data.options.chartPadding); // normalize the padding in case the full padding object was not passed into the options\n\n //position axis X title\n if (options.axisX.axisTitle && data.axisX) {\n xPos =\n data.axisX.axisLength / 2 +\n data.options.axisY.offset +\n chartPadding.left;\n\n yPos = chartPadding.top;\n\n if (data.options.axisY.position === \"end\") {\n xPos -= data.options.axisY.offset;\n }\n\n if (data.options.axisX.position === \"end\") {\n yPos += data.axisY.axisLength;\n }\n\n title = new Chartist.Svg(\"text\");\n title.addClass(getClasses(options.axisX.axisClass));\n title.text(getTitle(options.axisX.axisTitle));\n title.attr({\n x: xPos + options.axisX.offset.x,\n y: yPos + options.axisX.offset.y,\n \"text-anchor\": options.axisX.textAnchor\n });\n\n data.svg.append(title, true);\n }\n\n //position axis Y title\n if (options.axisY.axisTitle && data.axisY) {\n xPos = 0;\n\n yPos = data.axisY.axisLength / 2 + chartPadding.top;\n\n if (data.options.axisX.position === \"start\") {\n yPos += data.options.axisX.offset;\n }\n\n if (data.options.axisY.position === \"end\") {\n xPos = data.axisX.axisLength;\n }\n\n var transform =\n \"rotate(\" +\n (options.axisY.flipTitle ? -90 : 90) +\n \", \" +\n xPos +\n \", \" +\n yPos +\n \")\";\n\n title = new Chartist.Svg(\"text\");\n title.addClass(getClasses(options.axisY.axisClass));\n title.text(getTitle(options.axisY.axisTitle));\n title.attr({\n x: xPos + options.axisY.offset.x,\n y: yPos + options.axisY.offset.y,\n transform: transform,\n \"text-anchor\": options.axisY.textAnchor\n });\n data.svg.append(title, true);\n }\n });\n };\n };\n })(Chartist);\n\n return Chartist.plugins.ctAxisTitle;\n\n}));\n"]}