(function(){"use strict";u8.Base.Charts=function(e){$.extend(this,u8.Base.Charts.defaults,e);this.renderers=u8.Base.Charts.renderers};u8.Base.Charts.defaults={};u8.Base.Charts.renderers={};u8.Base.Charts.defaultChartTypes=[];$.extend(u8.Base.Charts.prototype,{draw:function(e,t){var r=e?$w(e):u8.application.getWorkWindow();if(!e){var s=r.$;var a=r.$(r.document);var i=Math.max(160,a.width()*.9);var n=Math.max(100,a.height()*.9);s("<div />").css({position:"absolute",width:i,height:n,left:0,top:0,zIndex:100}).appendTo(r.document.body)}u8.widget("ChartView",e,{parent:$p(e),renderer:this.createRenderer(t),dataProvider:new u8.Base.Charts.StaticDataProvider(t)})},createChart:function(e,t,r){if(e.update){e.update(t)}return r&&r(this,{chart:{options:e.getOptions(t)||{},series:e.getSeries(t)||[],values:e.getValues(t)}})},createRenderer:function(e,t){if(e&&typeof e=="object"){t=e;e=t.name}var r=this.renderers[e]||this.renderers["fusion"];if(!r){for(e in this.renderers){break}r=this.renderers[e]}$assert(r,"Invalid or unsupported chart renderer.");return new r.ctor($.extend({},t,r.options))},getChartTypes:function(e){if(this._chartTypes){return e&&e(this,{chartTypes:this._chartTypes})}var t=this._chartTypesLoading;if(t){this._chartTypesLoading.done(e);return}this._chartTypesLoading=$.Deferred();this._chartTypesLoading.done(e);var r=this;u8.request("ConfigurationChannel.GetChartTypes",null,function(e,t){if(r._isDisposed){return}r._chartTypes=t.response&&t.response.chartTypes||u8.Base.Charts.defaultChartTypes;for(var s=0;s<r._chartTypes.length;s++){var a=r._chartTypes[s];if(typeof a.options=="string"){a.options=evalValue(a.options)}if(typeof a.rendererOptions=="string"){a.rendererOptions=evalValue(a.rendererOptions)}}r._chartTypesLoading.resolve(r,t.error?{error:t.error,chartTypes:r._chartTypes}:{chartTypes:r._chartTypes});r._chartTypesLoading=null},true)}});u8.services.add({name:"charts",scope:"Application",ctor:u8.Base.Charts});u8.Base.Charts.StaticDataProvider=function(e){$.extend(this,e);if("value"in this){this.series=[{values:[this.value]}];delete this.value}};$.extend(u8.Base.Charts.StaticDataProvider.prototype,{update:function(e){$.extend(this,e)},getOptions:function(){return this.options},getSeries:function(){return this.series},getValues:function(){return this.values}})})();