{"version":3,"sources":["components/chart.js"],"names":["dmx","Component","attributes","width","type","Number","default","height","responsive","Boolean","String","colors","Array","legend","data","labels","nogrid","points","point-style","point-size","smooth","thickness","dashed","stacked","multicolor","cutout","noanimation","fullbar","colors1","colors2","colors3","colors4","colors5","colors6","colors7","colors8","colors9","render","node","this","$node","document","createElement","setAttribute","props","id","name","dom","replace","datasets","getDatasets","update","options","layout","padding","display","animation","duration","hover","animationDuration","position","scales","xAxes","gridLines","yAxes","ticks","beginAtZero","forEach","dataset","i","color","Object","assign","fill","lineTension","backgroundColor","Color","alpha","rgbaString","borderWidth","borderColor","borderDash","pointStyle","pointBackgroundColor","pointBorderColor","pointBorderWidth","pointHitRadius","pointRadius","pointHoverRadius","map","barPercentage","categoryPercentage","scale","cutoutPercentage","JSON","stringify","clone","getData","chart","destroy","Chart","needUpdate","length","prop","hasAttribute","push","label","getAttribute","dataExpression","items","repeatItems","parse","DataScope","getLabels","index"],"mappings":";;;;;;AAAAA,IAAAC,UAAA,QAAA,CAEAC,WAAA,CACAC,MAAA,CACAC,KAAAC,OACAC,QAAA,KAGAC,OAAA,CACAH,KAAAC,OACAC,QAAA,KAGAE,WAAA,CACAJ,KAAAK,QACAH,SAAA,GAGAF,KAAA,CACAA,KAAAM,OACAJ,QAAA,QAGAK,OAAA,CACAP,KAAA,CAAAM,OAAAE,OACAN,QAAA,WAGAO,OAAA,CACAT,KAAAM,OACAJ,QAAA,IAGAQ,KAAA,CACAV,KAAAQ,MACAN,QAAA,IAGAS,OAAA,CACAX,KAAAM,OACAJ,QAAA,IAGAU,OAAA,CACAZ,KAAAK,QACAH,SAAA,GAGAW,OAAA,CACAb,KAAAK,QACAH,SAAA,GAGAY,cAAA,CACAd,KAAAM,OACAJ,QAAA,UAGAa,aAAA,CACAf,KAAAM,OACAJ,QAAA,GAGAc,OAAA,CACAhB,KAAAK,QACAH,SAAA,GAGAe,UAAA,CACAjB,KAAAC,OACAC,QAAA,GAGAgB,OAAA,CACAlB,KAAAK,Q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component('chart', {\r\n\r\n attributes: {\r\n width: {\r\n type: Number,\r\n default: 800\r\n },\r\n\r\n height: {\r\n type: Number,\r\n default: 600\r\n },\r\n\r\n responsive: {\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n type: {\r\n type: String,\r\n default: 'line' // line/area/bar/horizontalBar/pie/doughnut/radar/polarArea\r\n },\r\n\r\n colors: {\r\n type: [String, Array],\r\n default: 'default'\r\n },\r\n\r\n legend: {\r\n type: String,\r\n default: ''\r\n },\r\n\r\n data: {\r\n type: Array,\r\n default: []\r\n },\r\n\r\n labels: {\r\n type: String,\r\n default: ''\r\n },\r\n\r\n nogrid: {\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n points: { // line/area/radar\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n 'point-style': { // line/area/radar\r\n type: String,\r\n default: 'circle' //'circle','cross','crossRot','dash','line','rect','rectRounded','rectRot','star','triangle'\r\n },\r\n\r\n 'point-size': { // line/area/radar\r\n type: String,\r\n default: 3\r\n },\r\n\r\n smooth: { // line/area/radar (smooth lines)\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n thickness: { // all\r\n type: Number,\r\n default: 1\r\n },\r\n\r\n dashed: { // line/area/radar\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n stacked: { // line/area/bar/horizontalBar\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n multicolor: { // bar/horizontalBar\r\n type: Boolean,\r\n default: false\r\n },\r\n\r\n cutout: { // doughnut\r\n type: Number,\r\n default: 50 // percent\r\n },\r\n\r\n noanimation: { // all\r\n type: Boolean,\r\n default: false // disable animations\r\n },\r\n\r\n fullbar: { // bar/horizontalBar\r\n type: Boolean,\r\n default: false // make bars full size\r\n }\r\n },\r\n\r\n colors: {\r\n default: ['#1c9f8d', '#d94712', '#2d81b9', '#1aa042', '#ad1999', '#d89515', '#d83148', '#7e2dad', '#828280', '#ad312f', '#1c9f8d', '#d94712', '#2d81b9', '#1aa042', '#ad1999', '#d89515', '#d83148', '#7e2dad', '#828280', '#ad312f'],\r\n colors1: ['#5DA5DA', '#FAA43A', '#60BD68', '#F17CB0', '#B2912F', '#B276B2', '#DECF3F', '#F15854', '#4D4D4D', '#5DA5DA', '#FAA43A', '#60BD68', '#F17CB0', '#B2912F', '#B276B2', '#DECF3F', '#F15854', '#4D4D4D'],\r\n colors2: ['#5cbae6', '#b6d957', '#fac364', '#d998cb', '#f2d249', '#93b9c6', '#ccc5a8', '#52bacc', '#98aafb', '#5cbae6', '#b6d957', '#fac364', '#d998cb', '#f2d249', '#93b9c6', '#ccc5a8', '#52bacc', '#98aafb'],\r\n colors3: ['#3678b3', '#f47d0d', '#479f2f', '#ca2227', '#9068bc', '#87564b', '#da77c1' ,'#7f7f7f' ,'#bbbc26' ,'#4bbfcf', '#3678b3', '#f47d0d', '#479f2f', '#ca2227', '#9068bc', '#87564b', '#da77c1' ,'#7f7f7f' ,'#bbbc26' ,'#4bbfcf'],\r\n colors4: ['#b1c7e8', '#f8b978', '#a2df8b', '#f69795', '#c3b0d5', '#bf9b94', '#f1b5d2' ,'#c7c7c7' ,'#dbda8e' ,'#a6dae5', '#b1c7e8', '#f8b978', '#a2df8b', '#f69795', '#c3b0d5', '#bf9b94', '#f1b5d2' ,'#c7c7c7' ,'#dbda8e' ,'#a6dae5'],\r\n colors5: ['#3a3d79', '#66793a', '#886c32', '#7e3c39', '#764273', '#4383bd', '#db520a', '#4ba355', '#746cb0', '#636363', '#3a3d79', '#66793a', '#886c32', '#7e3c39', '#764273', '#4383bd', '#db520a', '#4ba355', '#746cb0', '#636363'],\r\n colors6: ['#5356a2', '#8ea153', '#b99d3b', '#a5484a', '#9e5293', '#76afd6', '#f38b3c', '#80c377', '#9e9ac8', '#969696', '#5356a2', '#8ea153', '#b99d3b', '#a5484a', '#9e5293', '#76afd6', '#f38b3c', '#80c377', '#9e9ac8', '#969696'],\r\n colors7: ['#6c70ce', '#b8ce6c', '#e2b853', '#cc606b', '#c66ebc', '#a4cae1', '#f5ac6b', '#a8d99b', '#bcbddc', '#bdbdbd', '#6c70ce', '#b8ce6c', '#e2b853', '#cc606b', '#c66ebc', '#a4cae1', '#f5ac6b', '#a8d99b', '#bcbddc', '#bdbdbd'],\r\n colors8: ['#9c9fde', '#cfda9c', '#e4ca94', '#df959b', '#d89ed5', '#c9dbef', '#f8cfa2', '#cbe9c0', '#dadaeb', '#d9d9d9', '#9c9fde', '#cfda9c', '#e4ca94', '#df959b', '#d89ed5', '#c9dbef', '#f8cfa2', '#cbe9c0', '#dadaeb', '#d9d9d9'],\r\n colors9: ['#f44336', '#8bc34a', '#03a9f4', '#ffc107', '#e91e63', '#cddc39', '#00bcd4', '#ff9800', '#9c27b0', '#009688', '#f44336', '#8bc34a', '#03a9f4', '#ffc107', '#e91e63', '#cddc39', '#00bcd4', '#ff9800', '#9c27b0', '#009688']\r\n },\r\n\r\n render: function(node) {\r\n this.$node = document.createElement('canvas');\r\n this.$node.setAttribute('width', this.props.width);\r\n this.$node.setAttribute('height', this.props.height);\r\n this.$node.id = this.name;\r\n\r\n dmx.dom.replace(node, this.$node);\r\n\r\n if (typeof this.props.colors == 'string') {\r\n this.props.colors = this.colors[this.props.colors] || this.colors.default;\r\n }\r\n\r\n this.datasets = this.getDatasets(node);\r\n\r\n this.update({});\r\n },\r\n\r\n update: function(props) {\r\n var options = {\r\n type: this.props.type == 'area' ? 'line' : this.props.type,\r\n options: {\r\n responsive: this.props.responsive,\r\n layout: { padding: 5 },\r\n legend: { display: false }\r\n }\r\n };\r\n\r\n if (typeof this.props.colors == 'string') {\r\n this.props.colors = this.colors[this.props.colors] || this.colors.default;\r\n }\r\n\r\n if (this.props.noanimation) {\r\n options.options.animation = { duration: 0 };\r\n options.options.hover = { animationDuration: 0 };\r\n }\r\n\r\n if (this.props.legend) {\r\n options.options.legend.display = true;\r\n options.options.legend.position = this.props.legend;\r\n }\r\n\r\n if (this.props.type == 'line' || this.props.type == 'area') {\r\n options.options.scales = {\r\n xAxes: [{ gridLines: { display: !this.props.nogrid }}],\r\n yAxes: [{ gridLines: { display: !this.props.nogrid }, stacked: this.props.stacked, ticks: { beginAtZero: true }}]\r\n };\r\n\r\n this.datasets.forEach(function(dataset, i) {\r\n var color = this.props.colors[i];\r\n\r\n Object.assign(dataset, {\r\n fill: this.props.type == 'area',\r\n lineTension: this.props.smooth ? 0.4 : 0,\r\n backgroundColor: Color(color).alpha(0.5).rgbaString(),\r\n borderWidth: +this.props.thickness,\r\n borderColor: color,\r\n borderDash: this.props.dashed ? [5,5] : [],\r\n pointStyle: this.props['point-style'],\r\n pointBackgroundColor: color,\r\n pointBorderColor: color,\r\n pointBorderWidth: 1,\r\n pointHitRadius: 10,\r\n pointRadius: this.props.points ? +this.props['point-size'] : 0,\r\n pointHoverRadius: +this.props['point-size']\r\n });\r\n }, this);\r\n }\r\n\r\n if (this.props.type == 'bar' || this.props.type == 'horizontalBar') {\r\n options.options.scales = {\r\n xAxes: [{\r\n gridLines: { display: !this.props.nogrid },\r\n stacked: this.props.stacked,\r\n ticks: { beginAtZero: true }\r\n }],\r\n yAxes: [{\r\n gridLines: { display: !this.props.nogrid },\r\n stacked: this.props.stacked,\r\n ticks: { beginAtZero: true }\r\n }]\r\n };\r\n\r\n this.datasets.forEach(function(dataset, i) {\r\n var color = this.props.colors[i];\r\n\r\n Object.assign(dataset, {\r\n backgroundColor: this.props.multicolor ? this.props.colors.map(function(color) { return Color(color).alpha(0.5).rgbaString(); }) : Color(color).alpha(0.5).rgbaString(),\r\n borderColor: this.props.multicolor ? this.props.colors : color,\r\n borderDash: this.props.dashed ? [5,5] : [],\r\n borderWidth: +this.props.thickness,\r\n barPercentage: this.props.fullbar ? 1 : .9,\r\n categoryPercentage: this.props.fullbar ? 1 : .8\r\n });\r\n }, this);\r\n }\r\n\r\n if (this.props.type == 'polarArea' || this.props.type == 'radar') {\r\n options.options.scale = { gridLines: { display: !this.props.nogrid }, ticks: { beginAtZero: true } };\r\n\r\n this.datasets.forEach(function(dataset, i) {\r\n var color = this.props.colors[i];\r\n\r\n Object.assign(dataset, {\r\n fill: true,\r\n lineTension: this.props.smooth ? 0.4 : 0,\r\n borderWidth: +this.props.thickness,\r\n borderDash: this.props.dashed ? [5,5] : [],\r\n borderColor: this.props.type == 'polarArea' ? this.props.colors : color,\r\n backgroundColor: this.props.type == 'polarArea' ? this.props.colors.map(function(color) { return Color(color).alpha(0.3).rgbaString(); }) : Color(color).alpha(0.3).rgbaString(),\r\n pointStyle: this.props['point-style'],\r\n pointBackgroundColor: this.props.type == 'polarArea' ? this.props.colors : color,\r\n pointBorderColor: this.props.type == 'polarArea' ? this.props.colors : color,\r\n pointBorderWidth: 1,\r\n pointHitRadius: 10,\r\n pointRadius: this.props.points ? +this.props['point-size'] : 0,\r\n pointHoverRadius: +this.props['point-size']\r\n });\r\n }, this);\r\n }\r\n\r\n if (this.props.type == 'pie' || this.props.type == 'doughnut') {\r\n this.datasets.forEach(function(dataset, i) {\r\n var color = this.props.colors[i];\r\n\r\n Object.assign(dataset, {\r\n backgroundColor: this.props.colors.map(function(color) { return Color(color).alpha(0.5).rgbaString() }),\r\n borderColor: this.props.colors,\r\n borderWidth: +this.props.thickness,\r\n });\r\n }, this);\r\n }\r\n\r\n if (this.props.type == 'doughnut') {\r\n options.options.cutoutPercentage = this.props.cutout;\r\n }\r\n\r\n if (JSON.stringify(options) != JSON.stringify(this.options)) {\r\n if (this.props.type) {\r\n this.options = dmx.clone(options);\r\n\r\n options.data = this.getData();\r\n\r\n if (this.chart) this.chart.destroy();\r\n this.chart = new Chart(this.$node, dmx.clone(options));\r\n }\r\n } else if (this.chart) {\r\n var data = this.getData();\r\n var needUpdate = false;\r\n\r\n if (JSON.stringify(this.chart.data.labels) != JSON.stringify(data.labels)) {\r\n this.chart.data.labels = data.labels;\r\n needUpdate = true;\r\n }\r\n\r\n if (data.datasets.length != this.chart.data.datasets.length) {\r\n this.chart.data.datasets = data.datasets;\r\n needUpdate = true;\r\n } else {\r\n data.datasets.forEach(function(dataset, i) {\r\n ['label', 'backgroundColor', 'borderColor', 'borderWidth', 'dataExpression', 'data'].forEach(function(prop) {\r\n if (JSON.stringify(this.chart.data.datasets[i][prop]) != JSON.stringify(dataset[prop])) {\r\n this.chart.data.datasets[i][prop] = dataset[prop];\r\n needUpdate = true;\r\n }\r\n }, this);\r\n }, this);\r\n }\r\n\r\n if (needUpdate) {\r\n this.chart.update();\r\n }\r\n }\r\n },\r\n\r\n getDatasets: function(node) {\r\n var datasets = [];\r\n\r\n for (var i = 1; i <= 20; i++) {\r\n if (node.hasAttribute('dataset-' + i + ':value')) {\r\n datasets.push({\r\n label: node.hasAttribute('dataset-' + i + ':label') ? node.getAttribute('dataset-' + i + ':label') : 'dataset ' + i,\r\n backgroundColor: this.props.colors.map(function(color) { return Color(color).alpha(0.5).rgbaString() }),\r\n borderColor: this.props.colors,\r\n borderWidth: 1,\r\n dataExpression: node.getAttribute('dataset-' + i + ':value'),\r\n data: []\r\n });\r\n }\r\n }\r\n\r\n return datasets;\r\n },\r\n\r\n getData: function() {\r\n this.datasets.map(function(dataset) {\r\n var items = dmx.repeatItems(this.props.data);\r\n\r\n dataset.data = items.map(function(data) {\r\n return +dmx.parse(dataset.dataExpression, new dmx.DataScope(data, this));\r\n }, this);\r\n\r\n return [];\r\n }, this);\r\n\r\n return {\r\n labels: this.getLabels(),\r\n datasets: this.datasets\r\n };\r\n },\r\n\r\n getLabels: function() {\r\n var items = dmx.repeatItems(this.props.data);\r\n\r\n return items.map(function(data, index) {\r\n if (this.props.labels) {\r\n return dmx.parse(this.props.labels, new dmx.DataScope(data, this));\r\n } else {\r\n return 'value ' + (index + 1);\r\n }\r\n }, this);\r\n }\r\n\r\n});\r\n"]}