vue-chartkick
Advanced tools
Comparing version
@@ -0,1 +1,6 @@ | ||
## 0.5.0 [unreleased] | ||
- Updated Chartkick.js to 3.0.0 | ||
- Removed `xtype` option | ||
## 0.4.0 | ||
@@ -2,0 +7,0 @@ |
@@ -5,3 +5,3 @@ /* | ||
* https://github.com/ankane/vue-chartkick | ||
* v0.4.0 | ||
* v0.5.0 | ||
* MIT License | ||
@@ -20,3 +20,3 @@ */ | ||
"legend", "library", "max", "messages", "min", "points", "prefix", "refresh", | ||
"stacked", "suffix", "thousands", "title", "xtitle", "xtype", "ytitle" | ||
"stacked", "suffix", "thousands", "title", "xtitle", "ytitle" | ||
]; | ||
@@ -119,3 +119,3 @@ Vue.component(tagName, { | ||
var VueChartkick = { | ||
version: "0.4.0", | ||
version: "0.5.0", | ||
install: function(Vue, options) { | ||
@@ -122,0 +122,0 @@ if (options && options.adapter) { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueChartkick=e()}(this,function(){"use strict";function t(t){return"[object Array]"===Object.prototype.toString.call(t)}function e(t){return t instanceof Function}function r(t){return!e(t)&&t instanceof Object}function n(e,o){var a;for(a in o)r(o[a])||t(o[a])?(r(o[a])&&!r(e[a])&&(e[a]={}),t(o[a])&&!t(e[a])&&(e[a]=[]),n(e[a],o[a])):void 0!==o[a]&&(e[a]=o[a])}function o(t,e){var r={};return n(r,t),n(r,e),r}var a=/^(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)$/i,i=/(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)?(:)?(\d\d)?([.,]\d+)?($|Z|([+-])(\d\d)(:)?(\d\d)?)/i,s=String(1.5).charAt(1);function c(t){return""+t}function l(t){return parseFloat(t)}function p(t){var e,r,n,o;if("object"!=typeof t)if("number"==typeof t)t=new Date(1e3*t);else{if(e=(t=c(t)).match(a))return r=parseInt(e[1],10),n=parseInt(e[3],10)-1,o=parseInt(e[5],10),new Date(r,n,o);t=function(t){var e,r,n,o,a,c,l,p,u,d,h;return"[object Date]"===(d=Object.prototype.toString.call(t))?t:"[object String]"===d&&(n=t.match(i))?(h=parseInt(n[1],10),c=parseInt(n[3],10)-1,e=parseInt(n[5],10),r=parseInt(n[7],10),a=n[9]?parseInt(n[9],10):0,u=n[11]?parseInt(n[11],10):0,o=n[12]?1e3*parseFloat(s+n[12].slice(1)):0,p=Date.UTC(h,c,e,r,a,u,o),n[13]&&n[14]&&(l=60*n[15],n[17]&&(l+=parseInt(n[17],10)),p-=60*(l*="-"===n[14]?-1:1)*1e3),new Date(p)):void 0}(t.replace(/ /,"T").replace(" ","").replace("UTC","Z"))||new Date(t)}return t}function u(e){if(!t(e)){var r,n=[];for(r in e)e.hasOwnProperty(r)&&n.push([r,e[r]]);e=n}return e}function d(t,e,r,n,a,i,s,c){return function(l,p,u){var d=l.data,h=o({},t);return h=o(h,u||{}),(l.hideLegend||"legend"in p)&&e(h,p.legend,l.hideLegend),p.title&&r(h,p.title),"min"in p?n(h,p.min):function(t){var e,r,n;for(e=0;e<t.length;e++)for(n=t[e].data,r=0;r<n.length;r++)if(n[r][1]<0)return!0;return!1}(d)||n(h,0),p.max&&a(h,p.max),"stacked"in p&&i(h,p.stacked),p.colors&&(h.colors=p.colors),p.xtitle&&s(h,p.xtitle),p.ytitle&&c(h,p.ytitle),h=o(h,p.library||{})}}function h(t,e){return t[0].getTime()-e[0].getTime()}function f(t,e){return t[0]-e[0]}function y(t,e){return t-e}function m(t){return 0===t.getMilliseconds()&&0===t.getSeconds()}function g(t){return m(t)&&0===t.getMinutes()}function b(t){return g(t)&&0===t.getHours()}function v(t,e){return b(t)&&t.getDay()===e}function z(t){return b(t)&&1===t.getDate()}function M(t){return z(t)&&0===t.getMonth()}function x(t,e,r){if(t=t||"",r.prefix&&(e<0&&(e*=-1,t+="-"),t+=r.prefix),r.thousands||r.decimal){var n=(e=c(e)).split(".");e=n[0],r.thousands&&(e=e.replace(/\B(?=(\d{3})+(?!\d))/g,r.thousands)),n.length>1&&(e+=(r.decimal||".")+n[1])}return t+e+(r.suffix||"")}var w={maintainAspectRatio:!1,animation:!1,tooltips:{displayColors:!1,callbacks:{}},legend:{},title:{fontSize:20,fontColor:"#333"}},C={scales:{yAxes:[{ticks:{maxTicksLimit:4},scaleLabel:{fontSize:16,fontColor:"#333"}}],xAxes:[{gridLines:{drawOnChartArea:!1},scaleLabel:{fontSize:16,fontColor:"#333"},time:{},ticks:{}}]}},A=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#651067"],_=function(t,e,r){void 0!==e?(t.legend.display=!!e,e&&!0!==e&&(t.legend.position=e)):r&&(t.legend.display=!1)},S=function(t,e){t.title.display=!0,t.title.text=e},k=function(t,e){null!==e&&(t.scales.xAxes[0].ticks.min=l(e))},O=function(t,e){t.scales.xAxes[0].ticks.max=l(e)},T=function(t,e){t.scales.xAxes[0].stacked=!!e,t.scales.yAxes[0].stacked=!!e},D=function(t,e){t.scales.xAxes[0].scaleLabel.display=!0,t.scales.xAxes[0].scaleLabel.labelString=e},j=function(t,e){t.scales.yAxes[0].scaleLabel.display=!0,t.scales.yAxes[0].scaleLabel.labelString=e},L=function(t,e){var r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return r?"rgba("+parseInt(r[1],16)+", "+parseInt(r[2],16)+", "+parseInt(r[3],16)+", "+e+")":t},E=function(e,r,n){var o={prefix:e.options.prefix,suffix:e.options.suffix,thousands:e.options.thousands,decimal:e.options.decimal};if(o.prefix||o.suffix||o.thousands||o.decimal){if("pie"!==n){var a=r.scales.yAxes;"bar"===n&&(a=r.scales.xAxes),a[0].ticks.callback||(a[0].ticks.callback=function(t){return x("",t,o)})}if(!r.tooltips.callbacks.label)if("pie"!==n){var i="bar"===n?"xLabel":"yLabel";r.tooltips.callbacks.label=function(t,e){var r=e.datasets[t.datasetIndex].label||"";return r&&(r+=": "),x(r,t[i],o)}}else r.tooltips.callbacks.label=function(e,r){var n=r.labels[e.index];return t(n)?(n=n.slice())[0]+=": ":n+=": ",x(n,r.datasets[e.datasetIndex].data[e.index],o)}}},I=d(o(w,C),_,S,function(t,e){null!==e&&(t.scales.yAxes[0].ticks.min=l(e))},function(t,e){t.scales.yAxes[0].ticks.max=l(e)},T,D,j),B=function(t,e,r){var n,a,i,s,c,p,u=[],d=[],h=t.options.colors||A,f=!0,x=!0,w=!0,C=!0,_=!0,S=!0,k=("line"===r||"area"===r)&&!t.discrete,O=t.data,T=[],D=[];for(a=0;a<O.length;a++)for(s=O[a],i=0;i<s.data.length;i++)c=s.data[i],D[p=k?c[0].getTime():c[0]]||(D[p]=new Array(O.length)),D[p][a]=l(c[1]),-1===T.indexOf(p)&&T.push(p);(k||"number"===t.options.xtype)&&T.sort(y);var j,E,I=[];for(i=0;i<O.length;i++)I.push([]);for(E=0;E<T.length;E++)for(a=T[E],k?(j=new Date(l(a)),f=f&&b(j),n||(n=j.getDay()),x=x&&v(j,n),w=w&&z(j),C=C&&M(j),_=_&&g(j),S=S&&m(j)):j=a,d.push(j),i=0;i<O.length;i++)I[i].push(void 0===D[a][i]?null:D[a][i]);for(a=0;a<O.length;a++){var B=(s=O[a]).color||h[a],F="line"!==r?L(B,.5):B,N={label:s.name,data:I[a],fill:"area"===r,borderColor:B,backgroundColor:F,pointBackgroundColor:B,pointHoverBackgroundColor:B,borderWidth:2};s.stack&&(N.stack=s.stack),!1===t.options.curve&&(N.lineTension=0),!1===t.options.points&&(N.pointRadius=0,N.pointHitRadius=5),N=o(N=o(N=o(N,t.options.dataset||{}),s.library||{}),s.dataset||{}),u.push(N)}if(k&&d.length>0){var H=d[0].getTime(),R=d[0].getTime();for(a=1;a<d.length;a++)(j=d[a].getTime())<H&&(H=j),j>R&&(R=j);var P,U=(R-H)/864e5;if(!e.scales.xAxes[0].time.unit)if(C||U>3650?(e.scales.xAxes[0].time.unit="year",P=365):w||U>300?(e.scales.xAxes[0].time.unit="month",P=30):f||U>10?(e.scales.xAxes[0].time.unit="day",P=1):_||U>.5?(e.scales.xAxes[0].time.displayFormats={hour:"MMM D, h a"},e.scales.xAxes[0].time.unit="hour",P=1/24):S&&(e.scales.xAxes[0].time.displayFormats={minute:"h:mm a"},e.scales.xAxes[0].time.unit="minute",P=1/24/60),P&&U>0){var W=Math.ceil(U/P/(t.element.offsetWidth/100));x&&1===P&&(W=7*Math.ceil(W/7)),e.scales.xAxes[0].time.unitStepSize=W}e.scales.xAxes[0].time.tooltipFormat||(f?e.scales.xAxes[0].time.tooltipFormat="ll":_?e.scales.xAxes[0].time.tooltipFormat="MMM D, h a":S&&(e.scales.xAxes[0].time.tooltipFormat="h:mm a"))}return{labels:d,datasets:u}},F=function(t){this.name="chartjs",this.library=t};F.prototype.renderLineChart=function(t,e){if("number"===t.options.xtype)return this.renderScatterChart(t,e,!0);var r={};!t.options.max&&function(t){var e,r,n;for(e=0;e<t.length;e++)for(n=t[e].data,r=0;r<n.length;r++)if(0!=n[r][1])return!1;return!0}(t.data)&&(r.max=1);var n=I(t,o(r,t.options));E(t,n,e);var a=B(t,n,e||"line");n.scales.xAxes[0].type=t.discrete?"category":"time",this.drawChart(t,"line",a,n)},F.prototype.renderPieChart=function(t){var e=o({},w);t.options.donut&&(e.cutoutPercentage=50),"legend"in t.options&&_(e,t.options.legend),t.options.title&&S(e,t.options.title),e=o(e,t.options.library||{}),E(t,e,"pie");for(var r=[],n=[],a=0;a<t.data.length;a++){var i=t.data[a];r.push(i[0]),n.push(i[1])}var s={data:n,backgroundColor:t.options.colors||A},c={labels:r,datasets:[s=o(s,t.options.dataset||{})]};this.drawChart(t,"pie",c,e)},F.prototype.renderColumnChart=function(t,e){var r;r="bar"===e?d(o(w,C),_,S,k,O,T,D,j)(t,t.options):I(t,t.options),E(t,r,e);var n=B(t,r,"column");"bar"!==e&&function(t,e,r){var n=Math.ceil(t.element.offsetWidth/4/e.labels.length);n>25&&(n=25),r.scales.xAxes[0].ticks.callback=function(t){return(t=c(t)).length>n?t.substring(0,n-2)+"...":t}}(t,n,r),this.drawChart(t,"bar"===e?"horizontalBar":"bar",n,r)},F.prototype.renderAreaChart=function(t){this.renderLineChart(t,"area")},F.prototype.renderBarChart=function(t){this.renderColumnChart(t,"bar")},F.prototype.renderScatterChart=function(t,e,r){e=e||"line";var n=I(t,t.options);r||E(t,n,e);for(var o=t.options.colors||A,a=[],i=t.data,s=0;s<i.length;s++){for(var c=i[s],p=[],u=0;u<c.data.length;u++){var d={x:l(c.data[u][0]),y:l(c.data[u][1])};"bubble"===e&&(d.r=l(c.data[u][2])),p.push(d)}var h=c.color||o[s],f="area"===e?L(h,.5):h;a.push({label:c.name,showLine:r||!1,data:p,borderColor:h,backgroundColor:f,pointBackgroundColor:h,fill:"area"===e})}"area"===e&&(e="line");var y={datasets:a};n.scales.xAxes[0].type="linear",n.scales.xAxes[0].position="bottom",this.drawChart(t,e,y,n)},F.prototype.renderBubbleChart=function(t){this.renderScatterChart(t,"bubble")},F.prototype.destroy=function(t){t.chart&&t.chart.destroy()},F.prototype.drawChart=function(t,e,r,n){this.destroy(t),t.element.innerHTML="<canvas></canvas>";var o=t.element.getElementsByTagName("CANVAS")[0];t.chart=new this.library(o,{type:e,data:r,options:n})};var N={chart:{},xAxis:{title:{text:null},labels:{style:{fontSize:"12px"}}},yAxis:{title:{text:null},labels:{style:{fontSize:"12px"}}},title:{text:null},credits:{enabled:!1},legend:{borderWidth:0},tooltip:{style:{fontSize:"12px"}},plotOptions:{areaspline:{},series:{marker:{}}}},H=function(t,e,r){void 0!==e?(t.legend.enabled=!!e,e&&!0!==e&&("top"===e||"bottom"===e?t.legend.verticalAlign=e:(t.legend.layout="vertical",t.legend.verticalAlign="middle",t.legend.align=e))):r&&(t.legend.enabled=!1)},R=function(t,e){t.title.text=e},P=d(N,H,R,function(t,e){t.yAxis.min=e},function(t,e){t.yAxis.max=e},function(t,e){t.plotOptions.series.stacking=e?!0===e?"normal":e:null},function(t,e){t.xAxis.title.text=e},function(t,e){t.yAxis.title.text=e}),U=function(t,e,r){var n={prefix:t.options.prefix,suffix:t.options.suffix,thousands:t.options.thousands,decimal:t.options.decimal};(n.prefix||n.suffix||n.thousands||n.decimal)&&("pie"===r||e.yAxis.labels.formatter||(e.yAxis.labels.formatter=function(){return x("",this.value,n)}),e.tooltip.pointFormatter||(e.tooltip.pointFormatter=function(){return'<span style="color:'+this.color+">ā</span> "+x(this.series.name+": <b>",this.y,n)+"</b><br/>"}))},W=function(t){this.name="highcharts",this.library=t};W.prototype.renderLineChart=function(t,e){var r={};"areaspline"===(e=e||"spline")&&(r={plotOptions:{areaspline:{stacking:"normal"},area:{stacking:"normal"},series:{marker:{enabled:!1}}}}),!1===t.options.curve&&("areaspline"===e?e="area":"spline"===e&&(e="line"));var n,o,a,i=P(t,t.options,r);i.xAxis.type=t.discrete?"category":"datetime",i.chart.type||(i.chart.type=e),U(t,i,e);var s=t.data;for(o=0;o<s.length;o++){if(n=s[o].data,!t.discrete)for(a=0;a<n.length;a++)n[a][0]=n[a][0].getTime();s[o].marker={symbol:"circle"},!1===t.options.points&&(s[o].marker.enabled=!1)}this.drawChart(t,s,i)},W.prototype.renderScatterChart=function(t){var e=P(t,t.options,{});e.chart.type="scatter",this.drawChart(t,t.data,e)},W.prototype.renderPieChart=function(t){var e=o(N,{});t.options.colors&&(e.colors=t.options.colors),t.options.donut&&(e.plotOptions={pie:{innerSize:"50%"}}),"legend"in t.options&&H(e,t.options.legend),t.options.title&&R(e,t.options.title);var r=o(e,t.options.library||{});U(t,r,"pie");var n=[{type:"pie",name:t.options.label||"Value",data:t.data}];this.drawChart(t,n,r)},W.prototype.renderColumnChart=function(t,e){e=e||"column";var r,n,o,a,i=t.data,s=P(t,t.options),c=[],l=[];for(s.chart.type=e,U(t,s,e),r=0;r<i.length;r++)for(o=i[r],n=0;n<o.data.length;n++)c[(a=o.data[n])[0]]||(c[a[0]]=new Array(i.length),l.push(a[0])),c[a[0]][r]=a[1];"number"===t.options.xtype&&l.sort(y),s.xAxis.categories=l;var p,u=[];for(r=0;r<i.length;r++){for(a=[],n=0;n<l.length;n++)a.push(c[l[n]][r]||0);p={name:i[r].name,data:a},i[r].stack&&(p.stack=i[r].stack),u.push(p)}this.drawChart(t,u,s)},W.prototype.renderBarChart=function(t){this.renderColumnChart(t,"bar")},W.prototype.renderAreaChart=function(t){this.renderLineChart(t,"areaspline")},W.prototype.destroy=function(t){t.chart&&t.chart.destroy()},W.prototype.drawChart=function(t,e,r){this.destroy(t),r.chart.renderTo=t.element.id,r.series=e,t.chart=new this.library.Chart(r)};var V={},Q=[],G={chartArea:{},fontName:"'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif",pointSize:6,legend:{textStyle:{fontSize:12,color:"#444"},alignment:"center",position:"right"},curveType:"function",hAxis:{textStyle:{color:"#666",fontSize:12},titleTextStyle:{},gridlines:{color:"transparent"},baselineColor:"#ccc",viewWindow:{}},vAxis:{textStyle:{color:"#666",fontSize:12},titleTextStyle:{},baselineColor:"#ccc",viewWindow:{}},tooltip:{textStyle:{color:"#666",fontSize:12}}},J=function(t,e,r){var n;void 0!==e?(n=e?!0===e?"right":e:"none",t.legend.position=n):r&&(t.legend.position="none")},K=function(t,e){t.title=e,t.titleTextStyle={color:"#333",fontSize:"20px"}},X=function(t,e){t.hAxis.viewWindow.min=e},Y=function(t,e){t.hAxis.viewWindow.max=e},Z=function(t,e){t.isStacked=e||!1},$=function(t,e){t.hAxis.title=e,t.hAxis.titleTextStyle.italic=!1},q=function(t,e){t.vAxis.title=e,t.vAxis.titleTextStyle.italic=!1},tt=d(G,J,K,function(t,e){t.vAxis.viewWindow.min=e},function(t,e){t.vAxis.viewWindow.max=e},Z,$,q),et=function(t){this.name="google",this.library=t};et.prototype.renderLineChart=function(t){var e=this;this.waitForLoaded(t,function(){var r={};!1===t.options.curve&&(r.curveType="none"),!1===t.options.points&&(r.pointSize=0);var n=tt(t,t.options,r),o=t.discrete?"string":"datetime";"number"===t.options.xtype&&(o="number");var a=e.createDataTable(t.data,o);e.drawChart(t,e.library.visualization.LineChart,a,n)})},et.prototype.renderPieChart=function(t){var e=this;this.waitForLoaded(t,function(){var r={chartArea:{top:"10%",height:"80%"},legend:{}};t.options.colors&&(r.colors=t.options.colors),t.options.donut&&(r.pieHole=.5),"legend"in t.options&&J(r,t.options.legend),t.options.title&&K(r,t.options.title);var n=o(o(G,r),t.options.library||{}),a=new e.library.visualization.DataTable;a.addColumn("string",""),a.addColumn("number","Value"),a.addRows(t.data),e.drawChart(t,e.library.visualization.PieChart,a,n)})},et.prototype.renderColumnChart=function(t){var e=this;this.waitForLoaded(t,function(){var r=tt(t,t.options),n=e.createDataTable(t.data,"string",t.options.xtype);e.drawChart(t,e.library.visualization.ColumnChart,n,r)})},et.prototype.renderBarChart=function(t){var e=this;this.waitForLoaded(t,function(){var r=d(G,J,K,X,Y,Z,$,q)(t,t.options,{hAxis:{gridlines:{color:"#ccc"}}}),n=e.createDataTable(t.data,"string",t.options.xtype);e.drawChart(t,e.library.visualization.BarChart,n,r)})},et.prototype.renderAreaChart=function(t){var e=this;this.waitForLoaded(t,function(){var r=tt(t,t.options,{isStacked:!0,pointSize:0,areaOpacity:.5}),n=t.discrete?"string":"datetime";"number"===t.options.xtype&&(n="number");var o=e.createDataTable(t.data,n);e.drawChart(t,e.library.visualization.AreaChart,o,r)})},et.prototype.renderGeoChart=function(t){var e=this;this.waitForLoaded(t,function(){var r={legend:"none",colorAxis:{colors:t.options.colors||["#f6c7b6","#ce502d"]}},n=o(o(G,r),t.options.library||{}),a=new e.library.visualization.DataTable;a.addColumn("string",""),a.addColumn("number",t.options.label||"Value"),a.addRows(t.data),e.drawChart(t,e.library.visualization.GeoChart,a,n)})},et.prototype.renderScatterChart=function(t){var e=this;this.waitForLoaded(t,function(){var r,n,o,a,i=tt(t,t.options,{}),s=t.data,c=[];for(r=0;r<s.length;r++)for(a=s[r].data,n=0;n<a.length;n++){var l=new Array(s.length+1);l[0]=a[n][0],l[r+1]=a[n][1],c.push(l)}for((o=new e.library.visualization.DataTable).addColumn("number",""),r=0;r<s.length;r++)o.addColumn("number",s[r].name);o.addRows(c),e.drawChart(t,e.library.visualization.ScatterChart,o,i)})},et.prototype.renderTimeline=function(t){var e=this;this.waitForLoaded(t,"timeline",function(){var r={legend:"none"};t.options.colors&&(r.colors=t.options.colors);var n=o(o(G,r),t.options.library||{}),a=new e.library.visualization.DataTable;a.addColumn({type:"string",id:"Name"}),a.addColumn({type:"date",id:"Start"}),a.addColumn({type:"date",id:"End"}),a.addRows(t.data),t.element.style.lineHeight="normal",e.drawChart(t,e.library.visualization.Timeline,a,n)})},et.prototype.destroy=function(t){t.chart&&t.chart.clearChart()},et.prototype.drawChart=function(t,e,r,n){var o;this.destroy(t),t.chart=new e(t.element),o=function(){t.chart.draw(r,n)},window.attachEvent?window.attachEvent("onresize",o):window.addEventListener&&window.addEventListener("resize",o,!0),o()},et.prototype.waitForLoaded=function(t,e,r){var n=this;if(r||(r=e,e="corechart"),Q.push({pack:e,callback:r}),V[e])this.runCallbacks();else{V[e]=!0;var o={packages:[e],callback:function(){n.runCallbacks()}},a=t.__config();a.language&&(o.language=a.language),"corechart"===e&&a.mapsApiKey&&(o.mapsApiKey=a.mapsApiKey),this.library.setOnLoadCallback?this.library.load("visualization","1",o):this.library.charts.load("current",o)}},et.prototype.runCallbacks=function(){for(var t,e=0;e<Q.length;e++)t=Q[e],this.library.visualization&&("corechart"===t.pack&&this.library.visualization.LineChart||"timeline"===t.pack&&this.library.visualization.Timeline)&&(t.callback(),Q.splice(e,1),e--)},et.prototype.createDataTable=function(t,e,r){var n,o,a,i,s,p=[],u=[];for(n=0;n<t.length;n++)for(a=t[n],o=0;o<a.data.length;o++)i=a.data[o],p[s="datetime"===e?i[0].getTime():i[0]]||(p[s]=new Array(t.length),u.push(s)),p[s][n]=l(i[1]);var d,y=[],m=!0;for(o=0;o<u.length;o++)n=u[o],"datetime"===e?(d=new Date(l(n)),m=m&&b(d)):d="number"===e?l(n):n,y.push([d].concat(p[n]));if("datetime"===e?y.sort(h):"number"===e&&y.sort(f),"number"===r)for(y.sort(f),n=0;n<y.length;n++)y[n][0]=c(y[n][0]);var g=new this.library.visualization.DataTable;for(e="datetime"===e&&m?"date":e,g.addColumn(e,""),n=0;n<t.length;n++)g.addColumn("number",t[n].name);return g.addRows(y),g};var rt=[],nt=0,ot=4;function at(){if(nt<ot){var t=rt.shift();t&&(nt++,e=t[0],r=t[1],n=t[2],function(t,e,r){var n=window.jQuery||window.Zepto||window.$;if(n)n.ajax({dataType:"json",url:t,success:e,error:r,complete:it});else{var o=new XMLHttpRequest;o.open("GET",t,!0),o.setRequestHeader("Content-Type","application/json"),o.onload=function(){it(),200===o.status?e(JSON.parse(o.responseText),o.statusText,o):r(o,"error",o.statusText)},o.send()}}(e,r,function(t,e,r){var o="string"==typeof r?r:r.message;n(o)}),at())}var e,r,n}function it(){nt--,at()}var st="undefined"!=typeof window&&window.Chartkick||{},ct=[];function lt(t,e){document.body.innerText?t.innerText=e:t.textContent=e}function pt(t,e){lt(t,"Error Loading Chart: "+e),t.style.color="#ff0000"}function ut(t){try{t.__render()}catch(e){throw pt(t.element,e.message),e}}function dt(t,e){var r,n,o;"string"==typeof e?(r=e,n=function(e){t.rawData=e,ut(t)},o=function(e){pt(t.element,e)},rt.push([r,n,o]),at()):(t.rawData=e,ut(t))}function ht(t,e,r){if(t.addEventListener)return t.addEventListener(e,r,!1),r;var n=function(){return r.call(t,window.event)};return t.attachEvent("on"+e,n),n}function ft(t,e,r){t.removeEventListener?t.removeEventListener(e,r,!1):t.detachEvent("on"+e,r)}function yt(t,e){if(t===e)return!1;for(;e&&e!==t;)e=e.parentNode;return e===t}function mt(t){var r=new(function(t){if(t){if("Highcharts"===t.product)return W;if(t.setOnLoadCallback||t.charts)return et;if(e(t))return F}throw new Error("Unknown adapter")}(t))(t);-1===ct.indexOf(r)&&ct.push(r)}function gt(t,r){r.options.messages&&r.options.messages.empty&&function(t,e){if("PieChart"===e||"GeoChart"===e||"Timeline"===e)return 0===t.length;for(var r=0;r<t.length;r++)if(t[r].data.length>0)return!1;return!0}(r.data,t)?lt(r.element,r.options.messages.empty):(function(t,r){var n,o,a,i;for((a="render"+t,i=r.options.adapter,"Chart"in window&&mt(window.Chart),"Highcharts"in window&&mt(window.Highcharts),window.google&&(window.google.setOnLoadCallback||window.google.charts)&&mt(window.google),n=0);n<ct.length;n++)if(o=ct[n],(!i||i===o.name)&&e(o[a]))return r.adapter=o.name,r.__adapterObject=o,o[a](r);throw ct.length>0?new Error("No charting library found for "+t):new Error("No charting libraries found - be sure to include one before your charts")}(t,r),r.options.download&&!r.__downloadAttached&&"chartjs"===r.adapter&&function(t){var e=t.element,r=document.createElement("a");r.download=!0===t.options.download?"chart.png":t.options.download,r.style.position="absolute",r.style.top="20px",r.style.right="20px",r.style.zIndex=1e3,r.style.lineHeight="20px",r.target="_blank";var n=document.createElement("img");n.alt="Download",n.style.border="none",n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABCFBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMywEsqxAAAAV3RSTlMAAQIDBggJCgsMDQ4PERQaHB0eISIjJCouLzE0OTo/QUJHSUpLTU5PUllhYmltcHh5foWLjI+SlaCio6atr7S1t7m6vsHHyM7R2tze5Obo7fHz9ff5+/1hlxK2AAAA30lEQVQYGUXBhVYCQQBA0TdYWAt2d3d3YWAHyur7/z9xgD16Lw0DW+XKx+1GgX+FRzM3HWQWrHl5N/oapW5RPe0PkBu+UYeICvozTWZVK23Ao04B79oJrOsJDOoxkZoQPWgX29pHpCZEk7rEvQYiNSFq1UMqvlCjJkRBS1R8hb00Vb/TajtBL7nTHE1X1vyMQF732dQhyF2o6SAwrzP06iUQzvwsArlnzcOdrgBhJyHa1QOgO9U1GsKuvjUTjavliZYQ8nNPapG6sap/3nrIdJ6bOWzmX/fy0XVpfzZP3S8OJT3g9EEiJwAAAABJRU5ErkJggg==",r.appendChild(n),e.style.position="relative",t.__downloadAttached=!0,t.__enterEvent=ht(e,"mouseover",function(n){var o=n.relatedTarget;o&&(o===this||yt(this,o))||!t.options.download||(r.href=t.toImage(),e.appendChild(r))}),t.__leaveEvent=ht(e,"mouseout",function(t){var e=t.relatedTarget;e&&(e===this||yt(this,e))||r.parentNode&&r.parentNode.removeChild(r)})}(r))}var bt=function(t,e){return t="number"===e?l(t):"datetime"===e?p(t):c(t)},vt=function(t,e){var r,n,o=[];for(n=0;n<t.length;n++)"bubble"===e?o.push([l(t[n][0]),l(t[n][1]),l(t[n][2])]):(r=bt(t[n][0],e),o.push([r,l(t[n][1])]));return"datetime"===e?o.sort(h):"number"===e&&o.sort(f),o};function zt(e,r){var n,o=e.options,a=e.rawData;for(!t(a)||"object"!=typeof a[0]||t(a[0])?(a=[{name:o.label||"Value",data:a}],e.hideLegend=!0):e.hideLegend=!1,null!==o.discrete&&void 0!==o.discrete||"bubble"===r||"number"===r?e.discrete=o.discrete:e.discrete=function(t){var e,r,n,o;for(e=0;e<t.length;e++)for(n=u(t[e].data),r=0;r<n.length;r++)if(o=n[r][0],isNaN(p(o))||!(c(o).length>=6))return!0;return!1}(a),e.discrete&&(r="string"),e.options.xtype&&(r=e.options.xtype),a=function(t){var e,r,n=[];for(e=0;e<t.length;e++){var o={};for(r in t[e])t[e].hasOwnProperty(r)&&(o[r]=t[e][r]);n.push(o)}return n}(a),n=0;n<a.length;n++)a[n].data=vt(u(a[n].data),r);return a}function Mt(t){var e,r=u(t.rawData);for(e=0;e<r.length;e++)r[e]=[c(r[e][0]),l(r[e][1])];return r}var xt=function(t,e,r){var n;if("string"==typeof t&&(n=t,!(t=document.getElementById(t))))throw new Error("No element with id "+n);this.element=t,this.options=o(wt.options,r||{}),this.dataSource=e,wt.charts[t.id]=this,dt(this,e),this.options.refresh&&this.startRefresh()};xt.prototype.getElement=function(){return this.element},xt.prototype.getDataSource=function(){return this.dataSource},xt.prototype.getData=function(){return this.data},xt.prototype.getOptions=function(){return this.options},xt.prototype.getChartObject=function(){return this.chart},xt.prototype.getAdapter=function(){return this.adapter},xt.prototype.updateData=function(t,e){this.dataSource=t,e&&this.__updateOptions(e),dt(this,t)},xt.prototype.setOptions=function(t){this.__updateOptions(t),this.redraw()},xt.prototype.redraw=function(){dt(this,this.rawData)},xt.prototype.refreshData=function(){if("string"==typeof this.dataSource){var t=-1===this.dataSource.indexOf("?")?"?":"&";dt(this,this.dataSource+t+"_="+(new Date).getTime())}},xt.prototype.startRefresh=function(){var t=this,e=this.options.refresh;if(!this.intervalId){if(!e)throw new Error("No refresh interval");this.intervalId=setInterval(function(){t.refreshData()},1e3*e)}},xt.prototype.stopRefresh=function(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)},xt.prototype.toImage=function(){return"chartjs"===this.adapter?this.chart.toBase64Image():null},xt.prototype.destroy=function(){this.__adapterObject&&this.__adapterObject.destroy(this),this.__enterEvent&&ft(this.element,"mouseover",this.__enterEvent),this.__leaveEvent&&ft(this.element,"mouseout",this.__leaveEvent)},xt.prototype.__updateOptions=function(t){var e=t.refresh&&t.refresh!==this.options.refresh;this.options=o(wt.options,t),e&&(this.stopRefresh(),this.startRefresh())},xt.prototype.__render=function(){this.data=this.__processData(),gt(this.__chartName(),this)},xt.prototype.__config=function(){return st};var wt={LineChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return zt(this,"datetime")},e.prototype.__chartName=function(){return"LineChart"},e}(xt),PieChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return Mt(this)},e.prototype.__chartName=function(){return"PieChart"},e}(xt),ColumnChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return zt(this,"string")},e.prototype.__chartName=function(){return"ColumnChart"},e}(xt),BarChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return zt(this,"string")},e.prototype.__chartName=function(){return"BarChart"},e}(xt),AreaChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return zt(this,"datetime")},e.prototype.__chartName=function(){return"AreaChart"},e}(xt),GeoChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return Mt(this)},e.prototype.__chartName=function(){return"GeoChart"},e}(xt),ScatterChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return zt(this,"number")},e.prototype.__chartName=function(){return"ScatterChart"},e}(xt),BubbleChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return zt(this,"bubble")},e.prototype.__chartName=function(){return"BubbleChart"},e}(xt),Timeline:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){var t,e=this.rawData;for(t=0;t<e.length;t++)e[t][1]=p(e[t][1]),e[t][2]=p(e[t][2]);return e},e.prototype.__chartName=function(){return"Timeline"},e}(xt),charts:{},configure:function(t){for(var e in t)t.hasOwnProperty(e)&&(st[e]=t[e])},eachChart:function(t){for(var e in wt.charts)wt.charts.hasOwnProperty(e)&&t(wt.charts[e])},config:st,options:{},adapters:ct,addAdapter:mt};function Ct(t,e){return t(e={exports:{}},e.exports),e.exports}var At=Ct(function(t,e){function r(t){var e=[];for(var r in t)e.push(r);return e}(t.exports="function"==typeof Object.keys?Object.keys:r).shim=r}),_t=(At.shim,Ct(function(t,e){var r="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();function n(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function o(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}(e=t.exports=r?n:o).supported=n,e.unsupported=o})),St=(_t.supported,_t.unsupported,Ct(function(t){var e=Array.prototype.slice,r=t.exports=function(t,a,i){return i||(i={}),t===a||(t instanceof Date&&a instanceof Date?t.getTime()===a.getTime():!t||!a||"object"!=typeof t&&"object"!=typeof a?i.strict?t===a:t==a:function(t,a,i){var s,c;if(n(t)||n(a))return!1;if(t.prototype!==a.prototype)return!1;if(_t(t))return!!_t(a)&&(t=e.call(t),a=e.call(a),r(t,a,i));if(o(t)){if(!o(a))return!1;if(t.length!==a.length)return!1;for(s=0;s<t.length;s++)if(t[s]!==a[s])return!1;return!0}try{var l=At(t),p=At(a)}catch(t){return!1}if(l.length!=p.length)return!1;for(l.sort(),p.sort(),s=l.length-1;s>=0;s--)if(l[s]!=p[s])return!1;for(s=l.length-1;s>=0;s--)if(c=l[s],!r(t[c],a[c],i))return!1;return typeof t==typeof a}(t,a,i))};function n(t){return null===t||void 0===t}function o(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}})),kt=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===Ot}(t)}(t)};var Ot="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function Tt(t,e){return!1!==e.clone&&e.isMergeableObject(t)?jt((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function Dt(t,e,r){return t.concat(e).map(function(t){return Tt(t,r)})}function jt(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||Dt,r.isMergeableObject=r.isMergeableObject||kt;var n=Array.isArray(e);return n===Array.isArray(t)?n?r.arrayMerge(t,e,r):function(t,e,r){var n={};return r.isMergeableObject(t)&&Object.keys(t).forEach(function(e){n[e]=Tt(t[e],r)}),Object.keys(e).forEach(function(o){r.isMergeableObject(e[o])&&t[o]?n[o]=jt(t[o],e[o],r):n[o]=Tt(e[o],r)}),n}(t,e,r):Tt(e,r)}jt.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return jt(t,r,e)},{})};var Lt=jt,Et=1,It=function(t,e,r){var n=["colors","curve","dataset","decimal","discrete","donut","download","label","legend","library","max","messages","min","points","prefix","refresh","stacked","suffix","thousands","title","xtitle","xtype","ytitle"];t.component(e,{props:["data","id","width","height"].concat(n),render:function(t){return t("div",{attrs:{id:this.chartId},style:this.chartStyle},["Loading..."])},data:function(){return{chartId:null}},computed:{chartStyle:function(){return this.data,this.chartOptions,{height:this.height||"300px",lineHeight:this.height||"300px",width:this.width||"100%",textAlign:"center",color:"#999",fontSize:"14px",fontFamily:"'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif"}},chartOptions:function(){for(var t={},e=n,r=0;r<e.length;r++){var o=e[r];void 0!==this[o]&&(t[o]=this[o])}return t}},created:function(){this.chartId=this.chartId||this.id||"chart-"+Et++},mounted:function(){this.updateChart(),this.savedState=this.currentState()},updated:function(){var t=this.currentState();St(t,this.savedState)||(this.updateChart(),this.savedState=t)},beforeDestroy:function(){this.chart&&this.chart.destroy()},methods:{updateChart:function(){null!==this.data?this.chart?this.chart.updateData(this.data,this.chartOptions):this.chart=new r(this.chartId,this.data,this.chartOptions):this.chart&&(this.chart.destroy(),this.chart=null,this.$el.innerText="Loading...")},currentState:function(){return Lt({},{data:this.data,chartOptions:this.chartOptions})}}})},Bt={version:"0.4.0",install:function(t,e){e&&e.adapter&&wt.addAdapter(e.adapter),It(t,"line-chart",wt.LineChart),It(t,"pie-chart",wt.PieChart),It(t,"column-chart",wt.ColumnChart),It(t,"bar-chart",wt.BarChart),It(t,"area-chart",wt.AreaChart),It(t,"scatter-chart",wt.ScatterChart),It(t,"geo-chart",wt.GeoChart),It(t,"timeline",wt.Timeline)},addAdapter:function(t){wt.addAdapter(t)}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(Bt),Bt}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueChartkick=e()}(this,function(){"use strict";function t(t){return"[object Array]"===Object.prototype.toString.call(t)}function e(t){return t instanceof Function}function r(t){return!e(t)&&t instanceof Object}function n(e,a){var o;for(o in a)r(a[o])||t(a[o])?(r(a[o])&&!r(e[o])&&(e[o]={}),t(a[o])&&!t(e[o])&&(e[o]=[]),n(e[o],a[o])):void 0!==a[o]&&(e[o]=a[o])}function a(t,e){var r={};return n(r,t),n(r,e),r}var o=/^(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)$/i,i=/(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)?(:)?(\d\d)?([.,]\d+)?($|Z|([+-])(\d\d)(:)?(\d\d)?)/i,s=String(1.5).charAt(1);function c(t){return""+t}function l(t){return parseFloat(t)}function p(t){var e,r,n,a;if("object"!=typeof t)if("number"==typeof t)t=new Date(1e3*t);else{if(e=(t=c(t)).match(o))return r=parseInt(e[1],10),n=parseInt(e[3],10)-1,a=parseInt(e[5],10),new Date(r,n,a);t=function(t){var e,r,n,a,o,c,l,p,u,d,h;return"[object Date]"===(d=Object.prototype.toString.call(t))?t:"[object String]"===d&&(n=t.match(i))?(h=parseInt(n[1],10),c=parseInt(n[3],10)-1,e=parseInt(n[5],10),r=parseInt(n[7],10),o=n[9]?parseInt(n[9],10):0,u=n[11]?parseInt(n[11],10):0,a=n[12]?1e3*parseFloat(s+n[12].slice(1)):0,p=Date.UTC(h,c,e,r,o,u,a),n[13]&&n[14]&&(l=60*n[15],n[17]&&(l+=parseInt(n[17],10)),p-=60*(l*="-"===n[14]?-1:1)*1e3),new Date(p)):void 0}(t.replace(/ /,"T").replace(" ","").replace("UTC","Z"))||new Date(t)}return t}function u(e){if(!t(e)){var r,n=[];for(r in e)e.hasOwnProperty(r)&&n.push([r,e[r]]);e=n}return e}function d(t,e,r,n,o,i,s,c){return function(l,p,u){var d=l.data,h=a({},t);return h=a(h,u||{}),(l.hideLegend||"legend"in p)&&e(h,p.legend,l.hideLegend),p.title&&r(h,p.title),"min"in p?n(h,p.min):function(t){var e,r,n;for(e=0;e<t.length;e++)for(n=t[e].data,r=0;r<n.length;r++)if(n[r][1]<0)return!0;return!1}(d)||n(h,0),p.max&&o(h,p.max),"stacked"in p&&i(h,p.stacked),p.colors&&(h.colors=p.colors),p.xtitle&&s(h,p.xtitle),p.ytitle&&c(h,p.ytitle),h=a(h,p.library||{})}}function h(t,e){return t[0].getTime()-e[0].getTime()}function f(t,e){return t[0]-e[0]}function y(t,e){return t-e}function g(t){return 0===t.getMilliseconds()&&0===t.getSeconds()}function m(t){return g(t)&&0===t.getMinutes()}function b(t){return m(t)&&0===t.getHours()}function v(t,e){return b(t)&&t.getDay()===e}function z(t){return b(t)&&1===t.getDate()}function M(t){return z(t)&&0===t.getMonth()}function x(t){return!isNaN(p(t))&&c(t).length>=6}function w(t){return"number"==typeof t}function A(t,e,r){if(t=t||"",r.prefix&&(e<0&&(e*=-1,t+="-"),t+=r.prefix),r.thousands||r.decimal){var n=(e=c(e)).split(".");e=n[0],r.thousands&&(e=e.replace(/\B(?=(\d{3})+(?!\d))/g,r.thousands)),n.length>1&&(e+=(r.decimal||".")+n[1])}return t+e+(r.suffix||"")}var C={maintainAspectRatio:!1,animation:!1,tooltips:{displayColors:!1,callbacks:{}},legend:{},title:{fontSize:20,fontColor:"#333"}},_={scales:{yAxes:[{ticks:{maxTicksLimit:4},scaleLabel:{fontSize:16,fontColor:"#333"}}],xAxes:[{gridLines:{drawOnChartArea:!1},scaleLabel:{fontSize:16,fontColor:"#333"},time:{},ticks:{}}]}},S=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#651067"],O=function(t,e,r){void 0!==e?(t.legend.display=!!e,e&&!0!==e&&(t.legend.position=e)):r&&(t.legend.display=!1)},k=function(t,e){t.title.display=!0,t.title.text=e},T=function(t,e){null!==e&&(t.scales.xAxes[0].ticks.min=l(e))},D=function(t,e){t.scales.xAxes[0].ticks.max=l(e)},j=function(t,e){t.scales.xAxes[0].stacked=!!e,t.scales.yAxes[0].stacked=!!e},L=function(t,e){t.scales.xAxes[0].scaleLabel.display=!0,t.scales.xAxes[0].scaleLabel.labelString=e},E=function(t,e){t.scales.yAxes[0].scaleLabel.display=!0,t.scales.yAxes[0].scaleLabel.labelString=e},I=function(e,r,n){var a={prefix:e.options.prefix,suffix:e.options.suffix,thousands:e.options.thousands,decimal:e.options.decimal};if("pie"!==n){var o=r.scales.yAxes;"bar"===n&&(o=r.scales.xAxes),o[0].ticks.callback||(o[0].ticks.callback=function(t){return A("",t,a)})}if(!r.tooltips.callbacks.label)if("scatter"===n)r.tooltips.callbacks.label=function(t,e){var r=e.datasets[t.datasetIndex].label||"";return r&&(r+=": "),r+"("+t.xLabel+", "+t.yLabel+")"};else if("bubble"===n)r.tooltips.callbacks.label=function(t,e){var r=e.datasets[t.datasetIndex].label||"";r&&(r+=": ");var n=e.datasets[t.datasetIndex].data[t.index];return r+"("+t.xLabel+", "+t.yLabel+", "+n.v+")"};else if("pie"===n)r.tooltips.callbacks.label=function(e,r){var n=r.labels[e.index];return t(n)?(n=n.slice())[0]+=": ":n+=": ",A(n,r.datasets[e.datasetIndex].data[e.index],a)};else{var i="bar"===n?"xLabel":"yLabel";r.tooltips.callbacks.label=function(t,e){var r=e.datasets[t.datasetIndex].label||"";return r&&(r+=": "),A(r,t[i],a)}}},B=d(a(C,_),O,k,function(t,e){null!==e&&(t.scales.yAxes[0].ticks.min=l(e))},function(t,e){t.scales.yAxes[0].ticks.max=l(e)},j,L,E),N=function(t,e,r){var n,o=[],i=[],s=t.options.colors||S,c=!0,p=!0,u=!0,d=!0,h=!0,f=!0,x=t.data,w=0;if("bubble"===r)for(var A=0;A<x.length;A++)for(var C=x[A],_=0;_<C.data.length;_++)C.data[_][2]>w&&(w=C.data[_][2]);var O,k,T,D,j,L,E,I,B=[],N=[];if("number"===t.xtype||"bubble"===r)for(var F=0;F<x.length;F++){for(var H=x[F],R=[],P=0;P<H.data.length;P++){var V={x:l(H.data[P][0]),y:l(H.data[P][1])};"bubble"===r&&(V.r=20*l(H.data[P][2])/w,V.v=H.data[P][2]),R.push(V)}N.push(R)}else{var U,W,Q=[];for(O=0;O<x.length;O++)for(T=x[O],k=0;k<T.data.length;k++)D=T.data[k],B[j="datetime"==t.xtype?D[0].getTime():D[0]]||(B[j]=new Array(x.length)),B[j][O]=l(D[1]),-1===Q.indexOf(j)&&Q.push(j);for("datetime"===t.xtype&&Q.sort(y),k=0;k<x.length;k++)N.push([]);for(W=0;W<Q.length;W++)for(O=Q[W],"datetime"===t.xtype?(U=new Date(l(O)),c=c&&b(U),n||(n=U.getDay()),p=p&&v(U,n),u=u&&z(U),d=d&&M(U),h=h&&m(U),f=f&&g(U)):U=O,i.push(U),k=0;k<x.length;k++)N[k].push(void 0===B[O][k]?null:B[O][k])}for(O=0;O<x.length;O++){var J=(T=x[O]).color||s[O],G="line"!==r?(E=.5,void 0,(I=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(L=J))?"rgba("+parseInt(I[1],16)+", "+parseInt(I[2],16)+", "+parseInt(I[3],16)+", "+E+")":L):J,K={label:T.name,data:N[O],fill:"area"===r,borderColor:J,backgroundColor:G,pointBackgroundColor:J,borderWidth:2,pointHoverBackgroundColor:J};"scatter"!==r&&"bubble"!==r||(K.showLine=!1),T.stack&&(K.stack=T.stack),!1===t.options.curve&&(K.lineTension=0),!1===t.options.points&&(K.pointRadius=0,K.pointHitRadius=5),K=a(K=a(K=a(K,t.options.dataset||{}),T.library||{}),T.dataset||{}),o.push(K)}if("datetime"===t.xtype&&i.length>0){var X=i[0].getTime(),Y=i[0].getTime();for(O=1;O<i.length;O++){var Z=i[O].getTime();Z<X&&(X=Z),Z>Y&&(Y=Z)}var $,q=(Y-X)/864e5;if(!e.scales.xAxes[0].time.unit)if(d||q>3650?(e.scales.xAxes[0].time.unit="year",$=365):u||q>300?(e.scales.xAxes[0].time.unit="month",$=30):c||q>10?(e.scales.xAxes[0].time.unit="day",$=1):h||q>.5?(e.scales.xAxes[0].time.displayFormats={hour:"MMM D, h a"},e.scales.xAxes[0].time.unit="hour",$=1/24):f&&(e.scales.xAxes[0].time.displayFormats={minute:"h:mm a"},e.scales.xAxes[0].time.unit="minute",$=1/24/60),$&&q>0){var tt=Math.ceil(q/$/(t.element.offsetWidth/100));p&&1===$&&(tt=7*Math.ceil(tt/7)),e.scales.xAxes[0].time.unitStepSize=tt}e.scales.xAxes[0].time.tooltipFormat||(c?e.scales.xAxes[0].time.tooltipFormat="ll":h?e.scales.xAxes[0].time.tooltipFormat="MMM D, h a":f&&(e.scales.xAxes[0].time.tooltipFormat="h:mm a"))}return{labels:i,datasets:o}},F=function(t){this.name="chartjs",this.library=t};F.prototype.renderLineChart=function(t,e){var r={};!t.options.max&&function(t){var e,r,n;for(e=0;e<t.length;e++)for(n=t[e].data,r=0;r<n.length;r++)if(0!=n[r][1])return!1;return!0}(t.data)&&(r.max=1);var n=B(t,a(r,t.options));I(t,n,e);var o=N(t,n,e||"line");n.scales.xAxes[0].type="string"===t.xtype?"category":"number"==t.xtype?"linear":"time",this.drawChart(t,"line",o,n)},F.prototype.renderPieChart=function(t){var e=a({},C);t.options.donut&&(e.cutoutPercentage=50),"legend"in t.options&&O(e,t.options.legend),t.options.title&&k(e,t.options.title),e=a(e,t.options.library||{}),I(t,e,"pie");for(var r=[],n=[],o=0;o<t.data.length;o++){var i=t.data[o];r.push(i[0]),n.push(i[1])}var s={data:n,backgroundColor:t.options.colors||S},c={labels:r,datasets:[s=a(s,t.options.dataset||{})]};this.drawChart(t,"pie",c,e)},F.prototype.renderColumnChart=function(t,e){var r;r="bar"===e?d(a(C,_),O,k,T,D,j,L,E)(t,t.options):B(t,t.options),I(t,r,e);var n=N(t,r,"column");"bar"!==e&&function(t,e,r){var n=Math.ceil(t.element.offsetWidth/4/e.labels.length);n>25?n=25:n<10&&(n=10),r.scales.xAxes[0].ticks.callback||(r.scales.xAxes[0].ticks.callback=function(t){return(t=c(t)).length>n?t.substring(0,n-2)+"...":t})}(t,n,r),this.drawChart(t,"bar"===e?"horizontalBar":"bar",n,r)},F.prototype.renderAreaChart=function(t){this.renderLineChart(t,"area")},F.prototype.renderBarChart=function(t){this.renderColumnChart(t,"bar")},F.prototype.renderScatterChart=function(t,e){e=e||"scatter";var r=B(t,t.options);I(t,r,e);var n=N(t,r,e);r.scales.xAxes[0].type="linear",r.scales.xAxes[0].position="bottom",this.drawChart(t,e,n,r)},F.prototype.renderBubbleChart=function(t){this.renderScatterChart(t,"bubble")},F.prototype.destroy=function(t){t.chart&&t.chart.destroy()},F.prototype.drawChart=function(t,e,r,n){this.destroy(t);var a={type:e,data:r,options:n};t.options.code&&window.console.log("new Chart(ctx, "+JSON.stringify(a)+");"),t.element.innerHTML="<canvas></canvas>";var o=t.element.getElementsByTagName("CANVAS")[0];t.chart=new this.library(o,a)};var H={chart:{},xAxis:{title:{text:null},labels:{style:{fontSize:"12px"}}},yAxis:{title:{text:null},labels:{style:{fontSize:"12px"}}},title:{text:null},credits:{enabled:!1},legend:{borderWidth:0},tooltip:{style:{fontSize:"12px"}},plotOptions:{areaspline:{},series:{marker:{}}}},R=function(t,e,r){void 0!==e?(t.legend.enabled=!!e,e&&!0!==e&&("top"===e||"bottom"===e?t.legend.verticalAlign=e:(t.legend.layout="vertical",t.legend.verticalAlign="middle",t.legend.align=e))):r&&(t.legend.enabled=!1)},P=function(t,e){t.title.text=e},V=d(H,R,P,function(t,e){t.yAxis.min=e},function(t,e){t.yAxis.max=e},function(t,e){t.plotOptions.series.stacking=e?!0===e?"normal":e:null},function(t,e){t.xAxis.title.text=e},function(t,e){t.yAxis.title.text=e}),U=function(t,e,r){var n={prefix:t.options.prefix,suffix:t.options.suffix,thousands:t.options.thousands,decimal:t.options.decimal};"pie"===r||e.yAxis.labels.formatter||(e.yAxis.labels.formatter=function(){return A("",this.value,n)}),e.tooltip.pointFormatter||(e.tooltip.pointFormatter=function(){return'<span style="color:'+this.color+">ā</span> "+A(this.series.name+": <b>",this.y,n)+"</b><br/>"})},W=function(t){this.name="highcharts",this.library=t};W.prototype.renderLineChart=function(t,e){var r={};"areaspline"===(e=e||"spline")&&(r={plotOptions:{areaspline:{stacking:"normal"},area:{stacking:"normal"},series:{marker:{enabled:!1}}}}),!1===t.options.curve&&("areaspline"===e?e="area":"spline"===e&&(e="line"));var n,a,o,i=V(t,t.options,r);i.xAxis.type="string"===t.xtype?"category":"number"===t.xtype?"linear":"datetime",i.chart.type||(i.chart.type=e),U(t,i,e);var s=t.data;for(a=0;a<s.length;a++){if(s[a].name=s[a].name||"Value",n=s[a].data,"datetime"===t.xtype)for(o=0;o<n.length;o++)n[o][0]=n[o][0].getTime();s[a].marker={symbol:"circle"},!1===t.options.points&&(s[a].marker.enabled=!1)}this.drawChart(t,s,i)},W.prototype.renderScatterChart=function(t){var e=V(t,t.options,{});e.chart.type="scatter",this.drawChart(t,t.data,e)},W.prototype.renderPieChart=function(t){var e=a(H,{});t.options.colors&&(e.colors=t.options.colors),t.options.donut&&(e.plotOptions={pie:{innerSize:"50%"}}),"legend"in t.options&&R(e,t.options.legend),t.options.title&&P(e,t.options.title);var r=a(e,t.options.library||{});U(t,r,"pie");var n=[{type:"pie",name:t.options.label||"Value",data:t.data}];this.drawChart(t,n,r)},W.prototype.renderColumnChart=function(t,e){e=e||"column";var r,n,a,o,i=t.data,s=V(t,t.options),c=[],l=[];for(s.chart.type=e,U(t,s,e),r=0;r<i.length;r++)for(a=i[r],n=0;n<a.data.length;n++)c[(o=a.data[n])[0]]||(c[o[0]]=new Array(i.length),l.push(o[0])),c[o[0]][r]=o[1];"number"===t.xtype&&l.sort(y),s.xAxis.categories=l;var p,u=[];for(r=0;r<i.length;r++){for(o=[],n=0;n<l.length;n++)o.push(c[l[n]][r]||0);p={name:i[r].name||"Value",data:o},i[r].stack&&(p.stack=i[r].stack),u.push(p)}this.drawChart(t,u,s)},W.prototype.renderBarChart=function(t){this.renderColumnChart(t,"bar")},W.prototype.renderAreaChart=function(t){this.renderLineChart(t,"areaspline")},W.prototype.destroy=function(t){t.chart&&t.chart.destroy()},W.prototype.drawChart=function(t,e,r){this.destroy(t),r.chart.renderTo=t.element.id,r.series=e,t.options.code&&window.console.log("new Highcharts.Chart("+JSON.stringify(r)+");"),t.chart=new this.library.Chart(r)};var Q={},J=[],G={chartArea:{},fontName:"'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif",pointSize:6,legend:{textStyle:{fontSize:12,color:"#444"},alignment:"center",position:"right"},curveType:"function",hAxis:{textStyle:{color:"#666",fontSize:12},titleTextStyle:{},gridlines:{color:"transparent"},baselineColor:"#ccc",viewWindow:{}},vAxis:{textStyle:{color:"#666",fontSize:12},titleTextStyle:{},baselineColor:"#ccc",viewWindow:{}},tooltip:{textStyle:{color:"#666",fontSize:12}}},K=function(t,e,r){var n;void 0!==e?(n=e?!0===e?"right":e:"none",t.legend.position=n):r&&(t.legend.position="none")},X=function(t,e){t.title=e,t.titleTextStyle={color:"#333",fontSize:"20px"}},Y=function(t,e){t.hAxis.viewWindow.min=e},Z=function(t,e){t.hAxis.viewWindow.max=e},$=function(t,e){t.isStacked=e||!1},q=function(t,e){t.hAxis.title=e,t.hAxis.titleTextStyle.italic=!1},tt=function(t,e){t.vAxis.title=e,t.vAxis.titleTextStyle.italic=!1},et=d(G,K,X,function(t,e){t.vAxis.viewWindow.min=e},function(t,e){t.vAxis.viewWindow.max=e},$,q,tt),rt=function(t){this.name="google",this.library=t};rt.prototype.renderLineChart=function(t){var e=this;this.waitForLoaded(t,function(){var r={};!1===t.options.curve&&(r.curveType="none"),!1===t.options.points&&(r.pointSize=0);var n=et(t,t.options,r),a=e.createDataTable(t.data,t.xtype);e.drawChart(t,"LineChart",a,n)})},rt.prototype.renderPieChart=function(t){var e=this;this.waitForLoaded(t,function(){var r={chartArea:{top:"10%",height:"80%"},legend:{}};t.options.colors&&(r.colors=t.options.colors),t.options.donut&&(r.pieHole=.5),"legend"in t.options&&K(r,t.options.legend),t.options.title&&X(r,t.options.title);var n=a(a(G,r),t.options.library||{}),o=new e.library.visualization.DataTable;o.addColumn("string",""),o.addColumn("number","Value"),o.addRows(t.data),e.drawChart(t,"PieChart",o,n)})},rt.prototype.renderColumnChart=function(t){var e=this;this.waitForLoaded(t,function(){var r=et(t,t.options),n=e.createDataTable(t.data,t.xtype);e.drawChart(t,"ColumnChart",n,r)})},rt.prototype.renderBarChart=function(t){var e=this;this.waitForLoaded(t,function(){var r=d(G,K,X,Y,Z,$,q,tt)(t,t.options,{hAxis:{gridlines:{color:"#ccc"}}}),n=e.createDataTable(t.data,t.xtype);e.drawChart(t,"BarChart",n,r)})},rt.prototype.renderAreaChart=function(t){var e=this;this.waitForLoaded(t,function(){var r=et(t,t.options,{isStacked:!0,pointSize:0,areaOpacity:.5}),n=e.createDataTable(t.data,t.xtype);e.drawChart(t,"AreaChart",n,r)})},rt.prototype.renderGeoChart=function(t){var e=this;this.waitForLoaded(t,function(){var r={legend:"none",colorAxis:{colors:t.options.colors||["#f6c7b6","#ce502d"]}},n=a(a(G,r),t.options.library||{}),o=new e.library.visualization.DataTable;o.addColumn("string",""),o.addColumn("number",t.options.label||"Value"),o.addRows(t.data),e.drawChart(t,"GeoChart",o,n)})},rt.prototype.renderScatterChart=function(t){var e=this;this.waitForLoaded(t,function(){var r,n,a,o,i=et(t,t.options,{}),s=t.data,c=[];for(r=0;r<s.length;r++)for(s[r].name=s[r].name||"Value",o=s[r].data,n=0;n<o.length;n++){var l=new Array(s.length+1);l[0]=o[n][0],l[r+1]=o[n][1],c.push(l)}for((a=new e.library.visualization.DataTable).addColumn("number",""),r=0;r<s.length;r++)a.addColumn("number",s[r].name);a.addRows(c),e.drawChart(t,"ScatterChart",a,i)})},rt.prototype.renderTimeline=function(t){var e=this;this.waitForLoaded(t,"timeline",function(){var r={legend:"none"};t.options.colors&&(r.colors=t.options.colors);var n=a(a(G,r),t.options.library||{}),o=new e.library.visualization.DataTable;o.addColumn({type:"string",id:"Name"}),o.addColumn({type:"date",id:"Start"}),o.addColumn({type:"date",id:"End"}),o.addRows(t.data),t.element.style.lineHeight="normal",e.drawChart(t,"Timeline",o,n)})},rt.prototype.destroy=function(t){t.chart&&t.chart.clearChart()},rt.prototype.drawChart=function(t,e,r,n){var a;this.destroy(t),t.options.code&&window.console.log("var data = new google.visualization.DataTable("+r.toJSON()+");\nvar chart = new google.visualization."+e+"(element);\nchart.draw(data, "+JSON.stringify(n)+");"),t.chart=new this.library.visualization[e](t.element),a=function(){t.chart.draw(r,n)},window.attachEvent?window.attachEvent("onresize",a):window.addEventListener&&window.addEventListener("resize",a,!0),a()},rt.prototype.waitForLoaded=function(t,e,r){var n=this;if(r||(r=e,e="corechart"),J.push({pack:e,callback:r}),Q[e])this.runCallbacks();else{Q[e]=!0;var a={packages:[e],callback:function(){n.runCallbacks()}},o=t.__config();o.language&&(a.language=o.language),"corechart"===e&&o.mapsApiKey&&(a.mapsApiKey=o.mapsApiKey),this.library.charts.load("current",a)}},rt.prototype.runCallbacks=function(){for(var t,e=0;e<J.length;e++)t=J[e],this.library.visualization&&("corechart"===t.pack&&this.library.visualization.LineChart||"timeline"===t.pack&&this.library.visualization.Timeline)&&(t.callback(),J.splice(e,1),e--)},rt.prototype.createDataTable=function(t,e){var r,n,a,o,i,s=[],p=[];for(r=0;r<t.length;r++)for(a=t[r],t[r].name=t[r].name||"Value",n=0;n<a.data.length;n++)o=a.data[n],s[i="datetime"===e?o[0].getTime():o[0]]||(s[i]=new Array(t.length),p.push(i)),s[i][r]=l(o[1]);var u,d=[],y=!0;for(n=0;n<p.length;n++)r=p[n],"datetime"===e?(u=new Date(l(r)),y=y&&b(u)):u="number"===e?l(r):r,d.push([u].concat(s[r]));if("datetime"===e)d.sort(h);else if("number"===e){for(d.sort(f),r=0;r<d.length;r++)d[r][0]=c(d[r][0]);e="string"}var g=new this.library.visualization.DataTable;for(e="datetime"===e&&y?"date":e,g.addColumn(e,""),r=0;r<t.length;r++)g.addColumn("number",t[r].name);return g.addRows(d),g};var nt=[],at=0,ot=4;function it(){if(at<ot){var t=nt.shift();t&&(at++,e=t[0],r=t[1],n=t[2],function(t,e,r){var n=window.jQuery||window.Zepto||window.$;if(n)n.ajax({dataType:"json",url:t,success:e,error:r,complete:st});else{var a=new XMLHttpRequest;a.open("GET",t,!0),a.setRequestHeader("Content-Type","application/json"),a.onload=function(){st(),200===a.status?e(JSON.parse(a.responseText),a.statusText,a):r(a,"error",a.statusText)},a.send()}}(e,r,function(t,e,r){var a="string"==typeof r?r:r.message;n(a)}),it())}var e,r,n}function st(){at--,it()}var ct={},lt=[];function pt(t,e){document.body.innerText?t.innerText=e:t.textContent=e}function ut(t,e){pt(t,"Error Loading Chart: "+e),t.style.color="#ff0000"}function dt(t){try{t.__render()}catch(e){throw ut(t.element,e.message),e}}function ht(t,e){var r,n,a;"string"==typeof e?(r=e,n=function(e){t.rawData=e,dt(t)},a=function(e){ut(t.element,e)},nt.push([r,n,a]),it()):(t.rawData=e,dt(t))}function ft(t,e,r){if(t.addEventListener)return t.addEventListener(e,r,!1),r;var n=function(){return r.call(t,window.event)};return t.attachEvent("on"+e,n),n}function yt(t,e,r){t.removeEventListener?t.removeEventListener(e,r,!1):t.detachEvent("on"+e,r)}function gt(t,e){if(t===e)return!1;for(;e&&e!==t;)e=e.parentNode;return e===t}function mt(t){var r=new(function(t){if(t){if("Highcharts"===t.product)return W;if(t.charts)return rt;if(e(t))return F}throw new Error("Unknown adapter")}(t))(t);-1===lt.indexOf(r)&<.push(r)}function bt(t,r){r.options.messages&&r.options.messages.empty&&function(t,e){if("PieChart"===e||"GeoChart"===e||"Timeline"===e)return 0===t.length;for(var r=0;r<t.length;r++)if(t[r].data.length>0)return!1;return!0}(r.data,t)?pt(r.element,r.options.messages.empty):(function(t,r){var n,a,o,i;for((o="render"+t,i=r.options.adapter,"Chart"in window&&mt(window.Chart),"Highcharts"in window&&mt(window.Highcharts),window.google&&window.google.charts&&mt(window.google),n=0);n<lt.length;n++)if(a=lt[n],(!i||i===a.name)&&e(a[o]))return r.adapter=a.name,r.__adapterObject=a,a[o](r);throw lt.length>0?new Error("No charting library found for "+t):new Error("No charting libraries found - be sure to include one before your charts")}(t,r),r.options.download&&!r.__downloadAttached&&"chartjs"===r.adapter&&function(t){var e=t.element,r=document.createElement("a");r.download=!0===t.options.download?"chart.png":t.options.download,r.style.position="absolute",r.style.top="20px",r.style.right="20px",r.style.zIndex=1e3,r.style.lineHeight="20px",r.target="_blank";var n=document.createElement("img");n.alt="Download",n.style.border="none",n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABCFBMVEUAAADMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMywEsqxAAAAV3RSTlMAAQIDBggJCgsMDQ4PERQaHB0eISIjJCouLzE0OTo/QUJHSUpLTU5PUllhYmltcHh5foWLjI+SlaCio6atr7S1t7m6vsHHyM7R2tze5Obo7fHz9ff5+/1hlxK2AAAA30lEQVQYGUXBhVYCQQBA0TdYWAt2d3d3YWAHyur7/z9xgD16Lw0DW+XKx+1GgX+FRzM3HWQWrHl5N/oapW5RPe0PkBu+UYeICvozTWZVK23Ao04B79oJrOsJDOoxkZoQPWgX29pHpCZEk7rEvQYiNSFq1UMqvlCjJkRBS1R8hb00Vb/TajtBL7nTHE1X1vyMQF732dQhyF2o6SAwrzP06iUQzvwsArlnzcOdrgBhJyHa1QOgO9U1GsKuvjUTjavliZYQ8nNPapG6sap/3nrIdJ6bOWzmX/fy0XVpfzZP3S8OJT3g9EEiJwAAAABJRU5ErkJggg==",r.appendChild(n),e.style.position="relative",t.__downloadAttached=!0,t.__enterEvent=ft(e,"mouseover",function(n){var a=n.relatedTarget;a&&(a===this||gt(this,a))||!t.options.download||(r.href=t.toImage(),e.appendChild(r))}),t.__leaveEvent=ft(e,"mouseout",function(t){var e=t.relatedTarget;e&&(e===this||gt(this,e))||r.parentNode&&r.parentNode.removeChild(r)})}(r))}var vt=function(t,e){return t="number"===e?l(t):"datetime"===e?p(t):c(t)},zt=function(t,e){var r,n,a=[];for(n=0;n<t.length;n++)"bubble"===e?a.push([l(t[n][0]),l(t[n][1]),l(t[n][2])]):(r=vt(t[n][0],e),a.push([r,l(t[n][1])]));return"datetime"===e?a.sort(h):"number"===e&&a.sort(f),a};function Mt(t,e){var r,n,a;for(r=0;r<t.length;r++)for(a=u(t[r].data),n=0;n<a.length;n++)if(!e(a[n][0]))return!1;return!0}function xt(e,r,n){var a,o=e.options,i=e.rawData;for(!t(i)||"object"!=typeof i[0]||t(i[0])?(i=[{name:o.label,data:i}],e.hideLegend=!0):e.hideLegend=!1,e.xtype=r||(o.discrete?"string":function(t,e){return Mt(t,w)?"number":!e&&Mt(t,x)?"datetime":"string"}(i,n)),i=function(t){var e,r,n=[];for(e=0;e<t.length;e++){var a={};for(r in t[e])t[e].hasOwnProperty(r)&&(a[r]=t[e][r]);n.push(a)}return n}(i),a=0;a<i.length;a++)i[a].data=zt(u(i[a].data),e.xtype);return i}function wt(t){var e,r=u(t.rawData);for(e=0;e<r.length;e++)r[e]=[c(r[e][0]),l(r[e][1])];return r}var At=function(t,e,r){var n;if("string"==typeof t&&(n=t,!(t=document.getElementById(t))))throw new Error("No element with id "+n);this.element=t,this.options=a(Ct.options,r||{}),this.dataSource=e,Ct.charts[t.id]=this,ht(this,e),this.options.refresh&&this.startRefresh()};At.prototype.getElement=function(){return this.element},At.prototype.getDataSource=function(){return this.dataSource},At.prototype.getData=function(){return this.data},At.prototype.getOptions=function(){return this.options},At.prototype.getChartObject=function(){return this.chart},At.prototype.getAdapter=function(){return this.adapter},At.prototype.updateData=function(t,e){this.dataSource=t,e&&this.__updateOptions(e),ht(this,t)},At.prototype.setOptions=function(t){this.__updateOptions(t),this.redraw()},At.prototype.redraw=function(){ht(this,this.rawData)},At.prototype.refreshData=function(){if("string"==typeof this.dataSource){var t=-1===this.dataSource.indexOf("?")?"?":"&";ht(this,this.dataSource+t+"_="+(new Date).getTime())}},At.prototype.startRefresh=function(){var t=this,e=this.options.refresh;if(!this.intervalId){if(!e)throw new Error("No refresh interval");this.intervalId=setInterval(function(){t.refreshData()},1e3*e)}},At.prototype.stopRefresh=function(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)},At.prototype.toImage=function(){return"chartjs"===this.adapter?this.chart.toBase64Image():null},At.prototype.destroy=function(){this.__adapterObject&&this.__adapterObject.destroy(this),this.__enterEvent&&yt(this.element,"mouseover",this.__enterEvent),this.__leaveEvent&&yt(this.element,"mouseout",this.__leaveEvent)},At.prototype.__updateOptions=function(t){var e=t.refresh&&t.refresh!==this.options.refresh;this.options=a(Ct.options,t),e&&(this.stopRefresh(),this.startRefresh())},At.prototype.__render=function(){this.data=this.__processData(),bt(this.__chartName(),this)},At.prototype.__config=function(){return ct};var Ct={LineChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return xt(this)},e.prototype.__chartName=function(){return"LineChart"},e}(At),PieChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return wt(this)},e.prototype.__chartName=function(){return"PieChart"},e}(At),ColumnChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return xt(this,null,!0)},e.prototype.__chartName=function(){return"ColumnChart"},e}(At),BarChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return xt(this,null,!0)},e.prototype.__chartName=function(){return"BarChart"},e}(At),AreaChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return xt(this)},e.prototype.__chartName=function(){return"AreaChart"},e}(At),GeoChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return wt(this)},e.prototype.__chartName=function(){return"GeoChart"},e}(At),ScatterChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return xt(this,"number")},e.prototype.__chartName=function(){return"ScatterChart"},e}(At),BubbleChart:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){return xt(this,"bubble")},e.prototype.__chartName=function(){return"BubbleChart"},e}(At),Timeline:function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__processData=function(){var t,e=this.rawData;for(t=0;t<e.length;t++)e[t][1]=p(e[t][1]),e[t][2]=p(e[t][2]);return e},e.prototype.__chartName=function(){return"Timeline"},e}(At),charts:{},configure:function(t){for(var e in t)t.hasOwnProperty(e)&&(ct[e]=t[e])},eachChart:function(t){for(var e in Ct.charts)Ct.charts.hasOwnProperty(e)&&t(Ct.charts[e])},config:ct,options:{},adapters:lt,addAdapter:mt};function _t(t,e){return t(e={exports:{}},e.exports),e.exports}var St=_t(function(t,e){function r(t){var e=[];for(var r in t)e.push(r);return e}(t.exports="function"==typeof Object.keys?Object.keys:r).shim=r}),Ot=(St.shim,_t(function(t,e){var r="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();function n(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function a(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}(e=t.exports=r?n:a).supported=n,e.unsupported=a})),kt=(Ot.supported,Ot.unsupported,_t(function(t){var e=Array.prototype.slice,r=t.exports=function(t,o,i){return i||(i={}),t===o||(t instanceof Date&&o instanceof Date?t.getTime()===o.getTime():!t||!o||"object"!=typeof t&&"object"!=typeof o?i.strict?t===o:t==o:function(t,o,i){var s,c;if(n(t)||n(o))return!1;if(t.prototype!==o.prototype)return!1;if(Ot(t))return!!Ot(o)&&(t=e.call(t),o=e.call(o),r(t,o,i));if(a(t)){if(!a(o))return!1;if(t.length!==o.length)return!1;for(s=0;s<t.length;s++)if(t[s]!==o[s])return!1;return!0}try{var l=St(t),p=St(o)}catch(t){return!1}if(l.length!=p.length)return!1;for(l.sort(),p.sort(),s=l.length-1;s>=0;s--)if(l[s]!=p[s])return!1;for(s=l.length-1;s>=0;s--)if(c=l[s],!r(t[c],o[c],i))return!1;return typeof t==typeof o}(t,o,i))};function n(t){return null===t||void 0===t}function a(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}})),Tt=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===Dt}(t)}(t)};var Dt="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function jt(t,e){return!1!==e.clone&&e.isMergeableObject(t)?Et((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function Lt(t,e,r){return t.concat(e).map(function(t){return jt(t,r)})}function Et(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||Lt,r.isMergeableObject=r.isMergeableObject||Tt;var n=Array.isArray(e);return n===Array.isArray(t)?n?r.arrayMerge(t,e,r):function(t,e,r){var n={};return r.isMergeableObject(t)&&Object.keys(t).forEach(function(e){n[e]=jt(t[e],r)}),Object.keys(e).forEach(function(a){r.isMergeableObject(e[a])&&t[a]?n[a]=Et(t[a],e[a],r):n[a]=jt(e[a],r)}),n}(t,e,r):jt(e,r)}Et.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return Et(t,r,e)},{})};var It=Et,Bt=1,Nt=function(t,e,r){var n=["colors","curve","dataset","decimal","discrete","donut","download","label","legend","library","max","messages","min","points","prefix","refresh","stacked","suffix","thousands","title","xtitle","ytitle"];t.component(e,{props:["data","id","width","height"].concat(n),render:function(t){return t("div",{attrs:{id:this.chartId},style:this.chartStyle},["Loading..."])},data:function(){return{chartId:null}},computed:{chartStyle:function(){return this.data,this.chartOptions,{height:this.height||"300px",lineHeight:this.height||"300px",width:this.width||"100%",textAlign:"center",color:"#999",fontSize:"14px",fontFamily:"'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif"}},chartOptions:function(){for(var t={},e=n,r=0;r<e.length;r++){var a=e[r];void 0!==this[a]&&(t[a]=this[a])}return t}},created:function(){this.chartId=this.chartId||this.id||"chart-"+Bt++},mounted:function(){this.updateChart(),this.savedState=this.currentState()},updated:function(){var t=this.currentState();kt(t,this.savedState)||(this.updateChart(),this.savedState=t)},beforeDestroy:function(){this.chart&&this.chart.destroy()},methods:{updateChart:function(){null!==this.data?this.chart?this.chart.updateData(this.data,this.chartOptions):this.chart=new r(this.chartId,this.data,this.chartOptions):this.chart&&(this.chart.destroy(),this.chart=null,this.$el.innerText="Loading...")},currentState:function(){return It({},{data:this.data,chartOptions:this.chartOptions})}}})},Ft={version:"0.5.0",install:function(t,e){e&&e.adapter&&Ct.addAdapter(e.adapter),Nt(t,"line-chart",Ct.LineChart),Nt(t,"pie-chart",Ct.PieChart),Nt(t,"column-chart",Ct.ColumnChart),Nt(t,"bar-chart",Ct.BarChart),Nt(t,"area-chart",Ct.AreaChart),Nt(t,"scatter-chart",Ct.ScatterChart),Nt(t,"geo-chart",Ct.GeoChart),Nt(t,"timeline",Ct.Timeline)},addAdapter:function(t){Ct.addAdapter(t)}};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(Ft),Ft}); |
{ | ||
"name": "vue-chartkick", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Create beautiful JavaScript charts with one line of Vue", | ||
@@ -34,3 +34,3 @@ "main": "dist/vue-chartkick.js", | ||
"dependencies": { | ||
"chartkick": "^2.3.6", | ||
"chartkick": "^3.0.0", | ||
"deep-equal": "^1.0.1", | ||
@@ -37,0 +37,0 @@ "deepmerge": "^2.1.1" |
@@ -193,3 +193,3 @@ # Vue Chartkick | ||
To customize datasets in Chart.js, use: [master] | ||
To customize datasets in Chart.js, use: | ||
@@ -202,2 +202,8 @@ ```vue | ||
Use [dynamic components](https://vuejs.org/v2/guide/components.html#Dynamic-Components) to make the chart type dynamic: | ||
```vue | ||
<component is="column-chart"></component> | ||
``` | ||
### Data | ||
@@ -303,3 +309,3 @@ | ||
<script src="https://unpkg.com/chart.js@2.7.2/dist/Chart.bundle.js"></script> | ||
<script src="https://unpkg.com/vue-chartkick@0.4.0"></script> | ||
<script src="https://unpkg.com/vue-chartkick@0.5.0"></script> | ||
``` | ||
@@ -306,0 +312,0 @@ |
Sorry, the diff of this file is too big to display
118197
0.98%2448
0.62%344
1.78%+ Added
- Removed
Updated