// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/declare dijit/_WidgetBase dojo/_base/lang dojo/_base/html dojo/Evented libs/echarts/echarts jimu/utils ./_chartUtils ./_Gauge ./_ChartOptionFactory libs/echarts/light libs/echarts/dark".split(" "),function(e,f,d,g,h,k,l,m,n,p){return e([f,h],{baseClass:"jimu-dijit-chart",templateString:"\x3cdiv\x3e\x3c/div\x3e",declaredClass:"jimu.dijit.chart",config:null,postCreate:function(){this.inherited(arguments);this._initChart()},updateConfig:function(a){if(!a||!this.chart)return!1;var b=
this.chart.getOption(),c=this._isSameNumberSeriesItems(b,a);b=!this.preview&&c?this.getDatazoomRatio(b):null;this.config=a;this._specialThemeByConfig(a);c=this._chartFactory(a);this.chart.setOption(c,!0);this._settingByGrid(a,c,b);return!0},_settingByGrid:function(a,b,c){if("gauge"===a.type)return this._resetGaugePosition(a);var q=this.chartUtils.getAxisZeroPosition();a.layout=this.chartUtils.calcDefaultLayout(a);this.chartUtils.isAxisChart(a)&&(b=this.chartUtils.settingGrid(b,a),b=this.chartUtils.settingDataZoom(b,
a,q,c));b=this.chartUtils.settingChartLayout(b,a);this.chart.setOption(b,!1)},_resetGaugePosition:function(a){this._resetGaugeGrid(a);this._resetGaugeGraphic(a)},setConfig:function(a){if(!a)return!1;this.config=a;this._specialThemeByConfig(this.config);this.clear();var b=this._chartFactory(this.config);this.chart.setOption(b,!0);this._setAixsGrid(a,b);this._resetGaugePosition(a,b);return!0},destroy:function(){this._offEvents();this.clear();this.inherited(arguments)},_chartFactory:function(a){return this.option=
this.chartOptionFactory.produceOption(a)},bindEvents:function(a){this.chart&&a.events&&a.events.length&&(this._offEvents(),a.events.forEach(d.hitch(this,function(b){this.chart.on(b.name,b.callback)})))},_offEvents:function(){this.config.events&&this.config.events[0]&&this.config.events.forEach(d.hitch(this,function(a){this.chart.off(a.name)}))},getDataURL:function(){if(this.chart)return this.chart.getDataURL()},clear:function(){this.chart&&this.chart.clear()},resize:function(a,b){this.chart&&(g.setStyle(this.domNode,
{width:a||"100%",height:b||"100%"}),this.chart.resize(),this._resetGaugePosition(this.config))},getDatazoomRatio:function(a){return(a=a&&a.dataZoom&&a.dataZoom[0])?[a.start,a.end]:null},_isSameNumberSeriesItems:function(a,b){return(a&&a.series&&a.series[0]&&a.series[0].data&&a.series[0].data.length)===(b&&b.series&&b.series[0]&&b.series[0].data&&b.series[0].data.length)},_resizeDataZoom:function(){var a=this.option,b=this.config;if(a&&b){var c=this.chartUtils.getAxisZeroPosition();a=this.chartUtils.settingDataZoom(a,
b,c);this.chart.setOption(a)}},_setAixsGrid:function(a,b){this.chartUtils.isAxisChart(a)&&(b=this.chartUtils.settingGrid(b,a),this.chart.setOption(b,!1))},_resetGaugeGraphic:function(a){"gauge"===a.type&&this.gauge.resetGraphic(a)},_resetGaugeGrid:function(a){"gauge"===a.type&&this.gauge.resetGrid(a)},_specialChartTheme:function(){this.chart&&(this.chart._theme.tooltip.axisPointer={type:"cross",label:{show:!0,precision:2,formatter:function(a){return"number"===typeof a.value?(a=parseFloat(a.value).toFixed(2),
this.chartUtils.tryLocaleNumber(a)):a.value}.bind(this)},lineStyle:{color:"#27727B",type:"dashed"},crossStyle:{color:"#27727B"},shadowStyle:{color:"rgba(200,200,200,0.3)"}},this.chart._theme.valueAxis||(this.chart._theme.valueAxis={}),this.chart._theme.valueAxis.axisLabel||(this.chart._theme.valueAxis.axisLabel={}),this.chart._theme.valueAxis.axisLabel.formatter=function(a){return l.localizeNumber(a)})},_specialThemeByConfig:function(a){this._initChartTheme();a.color&&a.color[0]&&(this.chart._theme.color=
a.color);this.chart._theme.tooltip.confine=!0;var b="percent"===a.stack;this.chart._theme.tooltip.formatter=function(c){return this.chartUtils.handleToolTip(c,null,!1,b)}.bind(this)},_initChartTheme:function(){this.chart&&(this.chart._theme||(this.chart._theme={}),this.chart._theme.tooltip||(this.chart._theme.tooltip={}),this.chart._theme.valueAxis||(this.chart._theme.valueAxis={}),this.chart._theme.valueAxis.axisLabel||(this.chart._theme.valueAxis.axisLabel={}))},_initChart:function(){this.chart=
k.init(this.domNode,this.config&&this.config.theme||"light");this.chartUtils=new m({chart:this.chart});this.gauge=new n({chart:this.chart,chartUtils:this.chartUtils});this.chartOptionFactory=new p({chart:this.chart,gauge:this.gauge,chartUtils:this.chartUtils});this._specialChartTheme(this.config)}})});