/* Widget: q4.chart Version: 1.2.0 Compiled: 2017-03-24 */ !function(a){a.widget("q4.chart",{options:{url:"",usePublic:!1,apiKey:"",stocks:[],lockStock:!1,legend:!0,showSymbolInLegend:!0,stockLimit:1500,volume:!1,volumeHeight:40,news:!0,newsColor:"#006fba",newsBorderColor:"#006fba",newsOnLoad:!1,newsLimit:200,newsLength:75,newsCategory:"00000000-0000-0000-0000-000000000000",newsTags:[],events:!1,eventsOnLoad:!1,eventsLimit:100,eventsTags:[],stockOpts:{},volumeOpts:{},newsOpts:{},eventsOpts:{},highstockOpts:{},highchartsOpts:{},appendTable:!1,onComplete:function(){}},startDate:null,chart:null,_setDefaults:function(){var a=this,b=this.options;this.highchartsDefaults={global:{useUTC:!1}},this.highstockDefaults={colors:["#006fba"],chart:{height:450,marginTop:b.legend?60:0,backgroundColor:"transparent"},legend:{enabled:b.legend,borderRadius:3,backgroundColor:"rgba(0, 0, 0, 0.1)",align:"left",verticalAlign:"top",floating:!0,itemStyle:{color:"#333"}},rangeSelector:{enabled:!0,selected:1},xAxis:{gridLineColor:"rgba(0, 0, 0, 0.1)",lineColor:"transparent"},yAxis:{gridLineColor:"rgba(0, 0, 0, 0.1)",lineColor:"transparent",labels:{y:-25}},scrollbar:{barBackgroundColor:"#006fba",barBorderWidth:1,barBorderColor:"#006fba",buttonBackgroundColor:"rgba(0, 0, 0, 0.1)",rifleColor:"#fff",buttonBorderWidth:0,trackBorderColor:"#006fba",trackBorderWidth:0},navigator:{outlineColor:"rgba(0, 0, 0, 0.1)",outlineWidth:1,maskFill:"rgba(0, 111, 186, 0.65)",series:{type:"spline",fillOpacity:.05,lineWidth:1,marker:{enabled:!1}}},credits:{enabled:!1}},this.stockDefaults={type:"spline",showInLegend:b.showSymbolInLegend,turboThreshold:0,tooltip:{valueDecimals:2},events:{legendItemClick:function(){a._toggleStock(this)}}},this.volumeDefaults={type:"column",turboThreshold:0,showInLegend:!1,yAxis:1},this.newsDefaults={type:"flags",name:"News Releases",id:"news",onSeries:"price0",shape:"circlepin",fillColor:b.newsColor,color:b.newsBorderColor,width:3,height:3,y:-20,turboThreshold:0,visible:b.newsOnLoad,point:{events:{click:function(){window.location=this.url}}},events:{legendItemClick:function(){a._toggleFlags(this)}}},this.eventsDefaults={type:"flags",name:"Events",id:"events",onSeries:"price0",shape:"circlepin",width:3,height:3,y:-25,turboThreshold:0,visible:b.eventsOnLoad,point:{events:{click:function(){window.location=this.url}}},events:{legendItemClick:function(){a._toggleFlags(this)}}}},_create:function(){var b=this,c=this.options;this.element;c.url=c.url.replace(/\/$/,""),c.stocks.length?b._setIndice(c.stocks[0]):b._getStockIndice().done(function(d){a.each(d.GetLookupListResult,function(a,b){c.stocks.push(b.Value)}),b._setIndice(c.stocks[0])})},_setIndice:function(a){var b=this,c=b.options,d=this.element;b._getStockData(a).done(function(e){return e.GetStockQuoteHistoricalListResult.length?(c.appendTable&&b._buildStockTable(a,e),void b._initChart(e)):void d.html("There is currently no stock data, please check back later.")})},_initChart:function(b){var c=this,d=this.options,e=this.element,f=this._parseStockData(b);this._setDefaults(),Highcharts.setOptions(a.extend(!0,{},this.highchartsDefaults,d.highchartsOpts));var g=a.extend(!0,{},this.highstockDefaults,d.highstockOpts);if(g.series=this._buildSeries(),g.series[0].data=f[0],d.volume&&(g.series[1].data=f[1],g.yAxis=[g.yAxis||{},{}]),this.chart=e.highcharts("StockChart",g).highcharts(),d.volume){var h=this.chart.yAxis[1].getExtremes();this.chart.yAxis[1].setExtremes(0,100*h.max/d.volumeHeight,!0,!1)}d.news&&d.newsOnLoad&&this._getNewsData().done(function(a){c.chart.get("news").setData(c._parseNewsData(a))}),d.events&&d.eventsOnLoad&&this._getEventsData().done(function(a){c.chart.get("events").setData(c._parseEventsData(a))}),this._trigger("onComplete")},_buildSeries:function(){var b=this,c=b.options,d=[];return a.each(c.stocks,function(e,f){"string"==typeof f&&(f=[f]);var g=f[0].split(":"),h=g[0],i=(g[1],f.length>1&&f[1]?f[1]:f[0]);d.push(a.extend(!0,{},b.stockDefaults,{name:i,id:"price"+e,visible:0==e},c.stockOpts)),c.volume&&d.push(a.extend(!0,{},b.volumeDefaults,{name:h+":Volume",id:"volume"+e},c.volumeOpts))}),c.news&&d.push(a.extend(!0,{},this.newsDefaults,c.newsOpts)),c.events&&d.push(a.extend(!0,{},this.eventsDefaults,c.eventsOpts)),d},_getStockIndice:function(a){var b=this.options;return b.usePublic?this._getData("/feed/Lookup.svc/GetLookupList",{lookupType:"indices"}):this._getData("/Services/LookupService.svc/GetLookupList",{lookupType:"indices"})},_getStockData:function(a){var b=this.options;"string"==typeof a&&(a=[a]);var c=a[0].split(":");return b.usePublic?this._getData("/feed/StockQuote.svc/GetStockQuoteHistoricalList",{exchange:c[0],symbol:c[1]},b.stockLimit):this._getData("/Services/StockQuoteService.svc/GetStockQuoteHistoricalList",{exchange:c[0],symbol:c[1]},b.stockLimit)},_getNewsData:function(){var a=this.options;return a.usePublic?this._getData("/feed/PressRelease.svc/GetPressReleaseList",{pressReleaseDateFilter:3,categoryId:a.categoryId,tagList:a.newsTags.join("|")},a.newsLimit):this._getData("/Services/PressReleaseService.svc/GetPressReleaseList",{serviceDto:{TagList:a.newsTags,IncludeTags:!0},pressReleaseSelection:3,pressReleaseCategoryWorkflowId:a.categoryId},a.newsLimit)},_getEventsData:function(){var a=this.options;return a.usePublic?this._getData("/feed/Event.svc/GetEventList",{eventDateFilter:3,tagList:a.eventsTags.join("|")},a.eventsLimit):this._getData("/Services/EventService.svc/GetEventList",{serviceDto:{TagList:a.eventsTags,IncludeTags:!0},eventSelection:3},a.eventsLimit)},_getData:function(b,c,d){var e,f=this.options;return e=f.usePublic?{type:"GET",url:f.url+b,dataType:"jsonp",contentType:"application/json; charset=utf-8",data:a.extend(!0,{apiKey:f.apiKey,pageSize:d},c)}:{type:"POST",url:f.url+b,dataType:"json",contentType:"application/json; charset=utf-8",data:JSON.stringify(a.extend(!0,{serviceDto:{ViewType:GetViewType(),ViewDate:GetViewDate(),RevisionNumber:GetRevisionNumber(),LanguageId:GetLanguageId(),Signature:GetSignature(),StartIndex:0,ItemCount:d}},c))},a.ajax(e)},_buildStockTable:function(b,c){var d="";a.each(c.GetStockQuoteHistoricalListResult,function(b,c){return!(b>100)&&void(d+="