/*
    *
    * Wijmo Library 5.20173.409
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
System.register(["wijmo/wijmo","wijmo/wijmo.chart","wijmo/wijmo.chart.finance"],function(t,e){"use strict";function i(t){return u.asNumber(t,!0,!1),t>0?Math.floor(t):Math.ceil(t)}function n(t){return arguments.length>1&&(t=Array.prototype.slice.call(arguments)),u.asArray(t,!1),t.reduce(function(t,e){return t+u.asNumber(e)},0)}function a(t){return arguments.length>1&&(t=Array.prototype.slice.call(arguments)),u.asArray(t,!1),n(t)/t.length}function s(t){arguments.length>1&&(t=Array.prototype.slice.call(arguments)),u.asArray(t,!1);var e=a(t);return a(t.map(function(t){return Math.pow(t-e,2)}))}function r(t,e,i,n){void 0===n&&(n=14),u.asArray(t,!1),u.asArray(e,!1),u.asArray(i,!1),u.asInt(n,!1,!0);var s=o(t,e,i,n),r=Math.min(t.length,e.length,i.length,s.length),l=[];u.assert(r>n&&n>1,"Average True Range period must be an integer less than the length of the data and greater than one.");for(var h=0;h<r;h++)u.asNumber(t[h],!1),u.asNumber(e[h],!1),u.asNumber(i[h],!1),u.asNumber(s[h],!1),h+1===n?l.push(a(s.slice(0,n))):h+1>n&&l.push(((n-1)*l[l.length-1]+s[h])/n);return l}function o(t,e,i,n){void 0===n&&(n=14),u.asArray(t,!1),u.asArray(e,!1),u.asArray(i,!1),u.asInt(n,!1,!0);var a=Math.min(t.length,e.length,i.length),s=[];u.assert(a>n&&n>1,"True Range period must be an integer less than the length of the data and greater than one.");for(var r=0;r<a;r++)u.asNumber(t[r],!1),u.asNumber(e[r],!1),u.asNumber(i[r],!1),0===r?s.push(t[r]-e[r]):s.push(Math.max(t[r]-e[r],Math.abs(t[r]-i[r-1]),Math.abs(e[r]-i[r-1])));return s}function l(t,e){u.asArray(t,!1),u.asNumber(e,!1,!0),u.assert(t.length>e&&e>1,"Simple Moving Average period must be an integer less than the length of the data and greater than one.");for(var i=[],n=e;n<=t.length;n++)i.push(a(t.slice(n-e,n)));return i}var h=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();e&&e.id;t("_trunc",i),t("_sum",n),t("_average",a),t("_minimum",function(t){return arguments.length>1&&(t=Array.prototype.slice.call(arguments)),u.asArray(t,!1),Math.min.apply(null,t)}),t("_maximum",function(t){return arguments.length>1&&(t=Array.prototype.slice.call(arguments)),u.asArray(t,!1),Math.max.apply(null,t)}),t("_variance",s),t("_stdDeviation",function(t){return arguments.length>1&&(t=Array.prototype.slice.call(arguments)),u.asArray(t,!1),Math.sqrt(s(t))}),t("_avgTrueRng",r),t("_trueRng",o),t("_sma",l),t("_ema",function(t,e){u.asArray(t,!1),u.asNumber(e,!1,!0),u.assert(t.length>e&&e>1,"Exponential Moving Average period must be an integer less than the length of the data and greater than one.");var i=[],n=2/(e+1),a=l(t,e);t=t.slice(e-1);for(var s=0;s<t.length;s++)0===s?i.push(a[0]):i.push((t[s]-i[s-1])*n+i[s-1]);return i}),t("_range",function(t,e,i){void 0===i&&(i=1),u.asNumber(t,!1),u.asNumber(e,!1),u.asNumber(i,!1),u.assert(t<e,"begin argument must be less than end argument.");for(var n=[],a=t;a<=e;a+=i)n.push(a);return n});var u,c,_,g,p,d,f,m,y,v,w,b,x,k,V,P,C,L,A,M,S;return{setters:[function(t){u=t},function(t){c=t},function(t){_=t}],execute:function(){window.wijmo=window.wijmo||{},window.wijmo.chart=window.wijmo.chart||{},window.wijmo.chart.finance=_,function(t){t[t.Column=0]="Column",t[t.Scatter=1]="Scatter",t[t.Line=2]="Line",t[t.LineSymbols=3]="LineSymbols",t[t.Area=4]="Area",t[t.Candlestick=5]="Candlestick",t[t.HighLowOpenClose=6]="HighLowOpenClose",t[t.HeikinAshi=7]="HeikinAshi",t[t.LineBreak=8]="LineBreak",t[t.Renko=9]="Renko",t[t.Kagi=10]="Kagi",t[t.ColumnVolume=11]="ColumnVolume",t[t.EquiVolume=12]="EquiVolume",t[t.CandleVolume=13]="CandleVolume",t[t.ArmsCandleVolume=14]="ArmsCandleVolume",t[t.PointAndFigure=15]="PointAndFigure"}(g||(g={})),t("FinancialChartType",g),p=function(t){function e(e,i){var n=t.call(this,e,null)||this;return n._chartType=g.Line,n.__heikinAshiPlotter=null,n.__lineBreakPlotter=null,n.__renkoPlotter=null,n.__kagiPlotter=null,n.__pfPlotter=null,n.initialize(i),n}return h(e,t),Object.defineProperty(e.prototype,"chartType",{get:function(){return this._chartType},set:function(t){t!=this._chartType&&(this._chartType=u.asEnum(t,g),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(t){t!=this._options&&(this._options=t,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_heikinAshiPlotter",{get:function(){return null===this.__heikinAshiPlotter&&(this.__heikinAshiPlotter=new x,this._initPlotter(this.__heikinAshiPlotter)),this.__heikinAshiPlotter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_lineBreakPlotter",{get:function(){return null===this.__lineBreakPlotter&&(this.__lineBreakPlotter=new C,this._initPlotter(this.__lineBreakPlotter)),this.__lineBreakPlotter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_renkoPlotter",{get:function(){return null===this.__renkoPlotter&&(this.__renkoPlotter=new L,this._initPlotter(this.__renkoPlotter)),this.__renkoPlotter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_kagiPlotter",{get:function(){return null===this.__kagiPlotter&&(this.__kagiPlotter=new A,this._initPlotter(this.__kagiPlotter)),this.__kagiPlotter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_pfPlotter",{get:function(){return null===this.__pfPlotter&&(this.__pfPlotter=new S,this._initPlotter(this.__pfPlotter)),this.__pfPlotter},enumerable:!0,configurable:!0}),e.prototype._getChartType=function(){var t=null;switch(this.chartType){case g.Area:t=c.ChartType.Area;break;case g.Line:case g.Kagi:case g.PointAndFigure:t=c.ChartType.Line;break;case g.Column:case g.ColumnVolume:t=c.ChartType.Column;break;case g.LineSymbols:t=c.ChartType.LineSymbols;break;case g.Scatter:t=c.ChartType.Scatter;break;case g.Candlestick:case g.Renko:case g.HeikinAshi:case g.LineBreak:case g.EquiVolume:case g.CandleVolume:case g.ArmsCandleVolume:t=c.ChartType.Candlestick;break;case g.HighLowOpenClose:t=c.ChartType.HighLowOpenClose}return t},e.prototype._getPlotter=function(e){var i=this.chartType,n=null;if(e){var a=e.chartType;a&&!u.isUndefined(a)&&a!=i&&(i=a,!0)}switch(i){case g.HeikinAshi:n=this._heikinAshiPlotter;break;case g.LineBreak:n=this._lineBreakPlotter;break;case g.Renko:n=this._renkoPlotter;break;case g.Kagi:n=this._kagiPlotter;break;case g.ColumnVolume:(n=t.prototype._getPlotter.call(this,e)).isVolume=!0,n.width=1;break;case g.EquiVolume:(n=t.prototype._getPlotter.call(this,e)).isEqui=!0,n.isCandle=!1,n.isArms=!1,n.isVolume=!0,n.symbolWidth="100%";break;case g.CandleVolume:(n=t.prototype._getPlotter.call(this,e)).isEqui=!1,n.isCandle=!0,n.isArms=!1,n.isVolume=!0,n.symbolWidth="100%";break;case g.ArmsCandleVolume:(n=t.prototype._getPlotter.call(this,e)).isEqui=!1,n.isCandle=!1,n.isArms=!0,n.isVolume=!0,n.symbolWidth="100%";break;case g.PointAndFigure:n=this._pfPlotter;break;default:n=t.prototype._getPlotter.call(this,e)}return n},e.prototype._createSeries=function(){return new d},e}(c.FlexChartCore),t("FinancialChart",p),d=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),Object.defineProperty(e.prototype,"chartType",{get:function(){return this._finChartType},set:function(t){t!=this._finChartType&&(this._finChartType=u.asEnum(t,g,!0),this._invalidate())},enumerable:!0,configurable:!0}),e.prototype._getChartType=function(){var t=null;switch(this.chartType){case g.Area:t=c.ChartType.Area;break;case g.Line:case g.Kagi:case g.PointAndFigure:t=c.ChartType.Line;break;case g.Column:case g.ColumnVolume:t=c.ChartType.Column;break;case g.LineSymbols:t=c.ChartType.LineSymbols;break;case g.Scatter:t=c.ChartType.Scatter;break;case g.Candlestick:case g.Renko:case g.HeikinAshi:case g.LineBreak:case g.EquiVolume:case g.CandleVolume:case g.ArmsCandleVolume:t=c.ChartType.Candlestick;break;case g.HighLowOpenClose:t=c.ChartType.HighLowOpenClose}return t},e}(c.SeriesBase),t("FinancialSeries",d),f=function(){function t(t,e,i,n){this.highs=t,this.lows=e,this.opens=i,this.closes=n}return t.prototype.calculate=function(){},t}(),t("_BaseCalculator",f),m=function(t){function e(e,i,n,a){return t.call(this,e,i,n,a)||this}return h(e,t),e.prototype.calculate=function(){var t,e,i,n,s=Math.min(this.highs.length,this.lows.length,this.opens.length,this.closes.length),r=[];if(s<=0)return r;for(var o=0;o<s;o++)n=a(this.highs[o],this.lows[o],this.opens[o],this.closes[o]),0===o?(i=a(this.opens[o],this.closes[o]),t=this.highs[o],e=this.lows[o]):(i=a(r[o-1].open,r[o-1].close),t=Math.max(this.highs[o],i,n),e=Math.min(this.lows[o],i,n)),r.push({high:t,low:e,close:n,open:i,pointIndex:o,x:null});return r},e}(f),t("_HeikinAshiCalculator",m),y=function(t){function e(e,i,n,a,s,r,o,l){var h=t.call(this,e,i,n,a)||this;return h.xs=s,h.size=r,h.unit=o,h.fields=l,h}return h(e,t),e.prototype._getValues=function(){var t,e=[],i=Math.min(this.highs.length,this.lows.length,this.opens.length,this.closes.length);switch(this.fields){case V.High:e=this.highs;break;case V.Low:e=this.lows;break;case V.Open:e=this.opens;break;case V.HL2:for(t=0;t<i;t++)e.push(a(this.highs[t],this.lows[t]));break;case V.HLC3:for(t=0;t<i;t++)e.push(a(this.highs[t],this.lows[t],this.closes[t]));break;case V.HLOC4:for(t=0;t<i;t++)e.push(a(this.highs[t],this.lows[t],this.opens[t],this.closes[t]));break;case V.Close:default:e=this.closes}return e},e.prototype._getSize=function(){var t=this.unit===P.ATR?r(this.highs,this.lows,this.closes,this.size):null;return this.unit===P.ATR?t[t.length-1]:this.size},e}(f),t("_BaseRangeCalculator",y),v=function(t){function e(e,i,n,a,s,r){return t.call(this,e,i,n,a,s,r)||this}return h(e,t),e.prototype.calculate=function(){var t=null!==this.xs&&this.xs.length>0,e=this.closes.length,i=[],n=[[],[]];if(e<=0)return i;for(var a,s,r,o,l,h,u,c=[],_=1;_<e;_++){if(o=i.length,l=o-1,s=t?this.xs[_]:_,r=this.closes[_],-1===l){if((a=this.closes[0])===r)continue}else if(c=this._trendExists(n)||1===this.size?n[0].slice(-this.size).concat(n[1].slice(-this.size)):n[0].slice(1-this.size).concat(n[1].slice(1-this.size)),h=Math.max.apply(null,c),u=Math.min.apply(null,c),r>h)a=Math.max(n[0][l],n[1][l]);else{if(!(r<u))continue;a=Math.min(n[0][l],n[1][l])}n[0].push(a),n[1].push(r),i.push({high:Math.max(a,r),low:Math.min(a,r),open:a,close:r,x:s,pointIndex:_})}return i},e.prototype._trendExists=function(t){if(t[1].length<this.size)return!1;var e,i=!1,n=t[1].slice(-this.size);for(e=1;e<this.size&&(i=n[e]>n[e-1]);e++);if(!i)for(e=1;e<this.size&&(i=n[e]<n[e-1]);e++);return i},e}(y),t("_LineBreakCalculator",v),w=function(t){function e(e,i,n,a,s,r,o,l){return t.call(this,e,i,n,a,s,r,o,l)||this}return h(e,t),e.prototype.calculate=function(){var t=this._getSize(),e=Math.min(this.highs.length,this.lows.length,this.opens.length,this.closes.length),i=this._getValues(),n=null!==this.xs&&this.xs.length>0,a=[],s=[[],[]];if(e<=0)return a;for(var r,o,l,h,u,c,_,g,p,d,f=1;f<e;f++){if(h=a.length,u=h-1,o=n?this.xs[f]:f,d=f,p=!1,this.fields===V.HighLow)if(-1===u)if(this.highs[f]>this.highs[0])l=this.highs[f];else{if(!(this.lows[f]<this.lows[0]))continue;l=this.lows[f]}else if((g=s[1][u]-s[0][u])>0)if(this.highs[f]>s[1][u])l=this.highs[f];else{if(!(this.lows[f]<s[1][u]))continue;l=this.lows[f]}else if(this.lows[f]<s[1][u])l=this.lows[f];else{if(!(this.highs[f]>s[1][u]))continue;l=this.highs[f]}else l=i[f];if(this.unit===P.Percentage&&(t=l*this.size),-1===u){if(o=n?this.xs[0]:0,d=0,r=this.fields===V.HighLow?null==this.highs[0]?this.highs[this.highs.length-1]:this.highs[0]:null==i[0]?i[i.length-1]:i[0],(g=Math.abs(r-l)||0)<t)continue}else if(g=s[1][u]-s[0][u],_=Math.max(s[0][u],s[1][u]),c=Math.min(s[0][u],s[1][u]),g>0)if(l>_)p=!0;else{if(!((g=_-l)>=t))continue;r=_}else if(l<c)p=!0;else{if(!((g=l-c)>=t))continue;r=c}p?(s[1][u]=l,a[u].close=l,a[u].high=Math.max(a[u].open,a[u].close),a[u].low=Math.min(a[u].open,a[u].close)):(s[0].push(r),s[1].push(l),a.push({high:Math.max(r,l),low:Math.min(r,l),open:r,close:l,x:o,pointIndex:d}))}return a},e}(y),t("_KagiCalculator",w),b=function(t){function e(e,i,n,a,s,r,o,l,h){void 0===h&&(h=!1);var u=t.call(this,e,i,n,a,s,r,o,l)||this;return u.rounding=h,u}return h(e,t),e.prototype.calculate=function(){var t=this._getSize(),e=Math.min(this.highs.length,this.lows.length,this.opens.length,this.closes.length),n=null!==this.xs&&this.xs.length>0,a=this._getValues(),s=[],r=[[],[]];if(e<=0)return s;for(var o,l,h,u,c,_,g,p,d=1;d<e;d++){if(u=s.length,c=u-1,l=n?this.xs[d]:d,this.fields===V.HighLow)if(-1===c)if(this.highs[d]-this.highs[0]>t)o=this.highs[0],h=this.highs[d];else{if(!(this.lows[0]-this.lows[d]>t))continue;o=this.lows[0],h=this.lows[d]}else if(_=Math.min(r[0][c],r[1][c]),g=Math.max(r[0][c],r[1][c]),this.highs[d]-g>t)o=g,h=this.highs[d];else{if(!(_-this.lows[d]>t))continue;o=_,h=this.lows[d]}else if(h=a[d],-1===c)o=a[0];else if(_=Math.min(r[0][c],r[1][c]),g=Math.max(r[0][c],r[1][c]),h>g)o=g;else{if(!(h<_))continue;o=_}if(p=h-o,!(Math.abs(p)<t)){p=i(p/t);for(var f=0;f<Math.abs(p);f++){var m={};this.rounding&&(o=this._round(o,t)),r[0].push(o),m.open=o,o=p>0?o+t:o-t,r[1].push(o),m.close=o,m.x=l,m.pointIndex=d,m.high=Math.max(m.open,m.close),m.low=Math.min(m.open,m.close),s.push(m)}}}return s},e.prototype._round=function(t,e){return Math.round(t/e)*e},e}(y),t("_RenkoCalculator",b),x=function(t){function e(){var e=t.call(this)||this;return e._symFactor=.7,e.clear(),e}return h(e,t),e.prototype.clear=function(){t.prototype.clear.call(this),this._haValues=null,this._calculator=null},e.prototype.plotSeries=function(t,e,i,n,a,s,r){var o=this;this._calculate(n);var l=u.asType(n,c.SeriesBase),h=this.chart.series.indexOf(n),_=n.getValues(1),g=this._symFactor,p=this._haValues.length,d=!0;if(_){var f=this.dataInfo.getDeltaX();f>0&&(g*=f)}else _=this.dataInfo.getXVals();_?p=Math.min(p,_.length):(d=!1,_=new Array(p));var m=this._DEFAULT_WIDTH,y=l._getSymbolFill(h),v=l._getAltSymbolFill(h)||"transparent",w=l._getSymbolStroke(h),b=l._getAltSymbolStroke(h)||w,x=g,k=n.getDataType(1)||n.chart._xDataType;t.strokeWidth=m;for(var V,P,C,L,A,M,S,T,D=e.actualMin,B=e.actualMax,F=0,H=0;H<p;H++)if(C=d?_[H]:H,c._DataInfo.isValid(C)&&D<=C&&C<=B){if(A=this._haValues[H].high,M=this._haValues[H].low,S=this._haValues[H].open,T=this._haValues[H].close,V=S<T?v:y,P=S<T?b:w,t.fill=V,t.stroke=P,t.startGroup(),L=this._getDataPoint(h,H,C,n),this.chart.itemFormatter){var O=new c.HitTestInfo(this.chart,new u.Point(e.convert(C),i.convert(A)),c.ChartElement.SeriesSymbol);O._setData(l,H),O._setDataPoint(L),this.chart.itemFormatter(t,O,function(){o._drawSymbol(t,e,i,h,H,V,x,C,A,M,S,T,L,k)})}else this._drawSymbol(t,e,i,h,H,V,x,C,A,M,S,T,L,k);t.endGroup(),n._setPointIndex(H,F),F++}},e.prototype._drawSymbol=function(t,e,i,n,a,s,r,o,l,h,_,g,p,d){var f,m=null,y=null,v=null,w=null,b=d===u.DataType.Date?432e5:.5;if(v=e.convert(o-b*r),w=e.convert(o+b*r),v>w){var x=v;v=w,w=x}o=e.convert(o),c._DataInfo.isValid(_)&&c._DataInfo.isValid(g)&&(_=i.convert(_),g=i.convert(g),y=(m=Math.min(_,g))+Math.abs(_-g),t.drawRect(v,m,w-v,y-m),(f=new c._RectArea(new u.Rect(v,m,w-v,y-m))).tag=p,this.hitTester.add(f,n)),c._DataInfo.isValid(l)&&(l=i.convert(l),null!==m&&t.drawLine(o,m,o,l)),c._DataInfo.isValid(h)&&(h=i.convert(h),null!==y&&t.drawLine(o,y,o,h))},e.prototype._getDataPoint=function(t,e,i,n){var a=new c._DataPoint(t,e,i,this._haValues[e].high),s=n._getItem(e),r=n._getBinding(0),o=n._getBinding(1),l=n._getBinding(2),h=n._getBinding(3),u=n._getAxisY();return a.item=c._BasePlotter.cloneStyle(s,[]),a.item[r]=this._haValues[e].high,a.item[o]=this._haValues[e].low,a.item[l]=this._haValues[e].open,a.item[h]=this._haValues[e].close,a.y=this._haValues[e].high,a.yfmt=u._formatValue(this._haValues[e].high),a},e.prototype._calculate=function(t){var e=t._getBindingValues(0),i=t._getBindingValues(1),n=t._getBindingValues(2),a=t._getBindingValues(3);this._calculator=new m(e,i,n,a),this._haValues=this._calculator.calculate(),(null===this._haValues||u.isUndefined(this._haValues))&&this._init()},e.prototype._init=function(){this._haValues=[]},e}(c._FinancePlotter),t("_HeikinAshiPlotter",x),k=function(t){function e(){var e=t.call(this)||this;return e._symFactor=.7,e.clear(),e}return h(e,t),e.prototype.clear=function(){t.prototype.clear.call(this),this._rangeValues=null,this._rangeXLabels=null,this._calculator=null},e.prototype.unload=function(){t.prototype.unload.call(this);for(var e,i,n=0;n<this.chart.series.length;n++)(e=this.chart.series[n])&&(i=e._getAxisX())&&i.itemsSource&&(i.itemsSource=null)},e.prototype.adjustLimits=function(t,e){var i,n,a,s=0,r=0,o=0,l=0,h=this.chart._xDataType===u.DataType.Date?.5:0;u.assert(this.chart.series.length<=1,"Current FinancialChartType only supports a single series");for(var c=0;c<this.chart.series.length;c++)i=this.chart.series[c],this._calculate(i),this._rangeValues.length<=0||this._rangeXLabels.length<=0||((n=this._rangeValues.map(function(t){return t.open})).push.apply(n,this._rangeValues.map(function(t){return t.close})),a=this._rangeXLabels.map(function(t){return t.value}),o=Math.min.apply(null,n),l=Math.max.apply(null,n),s=Math.min.apply(null,a),r=Math.max.apply(null,a),i._getAxisX().itemsSource=this._rangeXLabels);return s-=h,new u.Rect(s,o,r-s+h,l-o)},e.prototype.plotSeries=function(t,e,i,n,a,s,r){var o=this;this._calculate(n);var l=this.chart.series.indexOf(n),h=this._rangeValues.length,_=e.actualMin,g=e.actualMax,p=this._DEFAULT_WIDTH,d=this._symFactor,f=n._getSymbolFill(l),m=n._getAltSymbolFill(l)||"transparent",y=n._getSymbolStroke(l),v=n._getAltSymbolStroke(l)||y;t.strokeWidth=p;for(var w,b,x,k,V=0,P=0;P<h;P++)if(w=P,c._DataInfo.isValid(w)&&_<=w&&w<=g){if(b=this._rangeValues[P].open,x=this._rangeValues[P].close,t.fill=b>x?f:m,t.stroke=b>x?y:v,k=this._getDataPoint(l,P,n,Math.max(b,x)),t.startGroup(),this.chart.itemFormatter){var C=new c.HitTestInfo(this.chart,new u.Point(e.convert(w),i.convert(x)),c.ChartElement.SeriesSymbol);C._setData(n,P),C._setDataPoint(k),this.chart.itemFormatter(t,C,function(){o._drawSymbol(t,e,i,l,V,d,w,b,x,k)})}else this._drawSymbol(t,e,i,l,V,d,w,b,x,k);t.endGroup(),n._setPointIndex(P,V),V++}},e.prototype._drawSymbol=function(t,e,i,n,a,s,r,o,l,h){var _,g,p,d,f;if(p=e.convert(r-.5*s),d=e.convert(r+.5*s),p>d){var m=p;p=d,d=m}c._DataInfo.isValid(o)&&c._DataInfo.isValid(l)&&(o=i.convert(o),l=i.convert(l),g=(_=Math.min(o,l))+Math.abs(o-l),t.drawRect(p,_,d-p,g-_),(f=new c._RectArea(new u.Rect(p,_,d-p,g-_))).tag=h,this.hitTester.add(f,n))},e.prototype._getDataPoint=function(t,e,i,n){var a=e,s=new c._DataPoint(t,e,a,n),r=i._getItem(this._rangeValues[e].pointIndex),o=i.bindingX||this.chart.bindingX,l=i._getBinding(0),h=i._getBinding(1),u=i._getBinding(2),_=i._getBinding(3),g=i._getAxisY();return s.item=c._BasePlotter.cloneStyle(r,[]),s.item[l]=this._rangeValues[e].high,s.item[h]=this._rangeValues[e].low,s.item[u]=this._rangeValues[e].open,s.item[_]=this._rangeValues[e].close,s.y=this._rangeValues[e].close,s.yfmt=g._formatValue(this._rangeValues[e].close),s.x=s.item[o],s.xfmt=this._rangeXLabels[e]._text,s},e.prototype._init=function(){this._rangeValues=[],this._rangeXLabels=[]},e.prototype._calculate=function(t){},e.prototype._generateXLabels=function(t){var e,i=this,n=t._getAxisX(),a=t.getDataType(1)||this.chart._xDataType;this._rangeValues.forEach(function(t,s){var r=t.x;e=a===u.DataType.Date?u.Globalize.format(c.FlexChart._fromOADate(r),n.format||"d"):a===u.DataType.Number?n._formatValue(r):null!==a&&a!==u.DataType.String||!i.chart._xlabels?r.toString():i.chart._xlabels[r],i._rangeXLabels.push({value:s,text:e,_text:e})},this)},e}(c._BasePlotter),t("_BaseRangePlotter",k),function(t){t[t.Close=0]="Close",t[t.High=1]="High",t[t.Low=2]="Low",t[t.Open=3]="Open",t[t.HighLow=4]="HighLow",t[t.HL2=5]="HL2",t[t.HLC3=6]="HLC3",t[t.HLOC4=7]="HLOC4"}(V||(V={})),t("DataFields",V),function(t){t[t.Fixed=0]="Fixed",t[t.ATR=1]="ATR",t[t.Percentage=2]="Percentage"}(P||(P={})),t("RangeMode",P),C=function(t){function e(){return t.call(this)||this}return h(e,t),e.prototype.clear=function(){t.prototype.clear.call(this),this._newLineBreaks=null},e.prototype._calculate=function(t){this._init();var e=t._getBindingValues(3),i=t.getValues(1)||this.chart._xvals;this._calculator=new v(null,null,null,e,i,this._newLineBreaks),this._rangeValues=this._calculator.calculate(),(null===this._rangeValues||u.isUndefined(this._rangeValues))&&(this._rangeValues=[]),this._generateXLabels(t)},e.prototype._init=function(){t.prototype._init.call(this),this._newLineBreaks=u.asInt(this.getNumOption("newLineBreaks","lineBreak"),!0,!0)||3,u.assert(this._newLineBreaks>=1,"Value must be greater than 1")},e}(k),t("_LineBreakPlotter",C),L=function(t){function e(){return t.call(this)||this}return h(e,t),e.prototype.clear=function(){t.prototype.clear.call(this),this._boxSize=null,this._rangeMode=null},e.prototype._calculate=function(t){this._init();var e=t._getBindingValues(0),i=t._getBindingValues(1),n=t._getBindingValues(2),a=t._getBindingValues(3),s=t.getValues(1)||this.chart._xvals;this._calculator=new b(e,i,n,a,s,this._boxSize,this._rangeMode,this._fields,this._rounding),this._rangeValues=this._calculator.calculate(),(null===this._rangeValues||u.isUndefined(this._rangeValues))&&(this._rangeValues=[]),this._generateXLabels(t)},e.prototype._init=function(){t.prototype._init.call(this),this._boxSize=this.getNumOption("boxSize","renko")||14,this._rangeMode=this.getOption("rangeMode","renko")||P.Fixed,this._rangeMode=u.asEnum(this._rangeMode,P,!0),u.assert(this._rangeMode!==P.Percentage,"RangeMode.Percentage is not supported"),this._fields=this.getOption("fields","renko")||V.Close,this._fields=u.asEnum(this._fields,V,!0),u.assert(this._fields!==V.HighLow,"DataFields.HighLow is not supported"),this._rounding=u.asBoolean(this.getOption("rounding","renko"),!0)},e.prototype._generateXLabels=function(e){var i=this;t.prototype._generateXLabels.call(this,e),this._rangeXLabels.forEach(function(t,e){e>0&&i._rangeXLabels[e-1]._text===t.text&&(t.text="")},this)},e}(k),t("_RenkoPlotter",L),A=function(t){function e(){return t.call(this)||this}return h(e,t),e.prototype._calculate=function(t){this._init();var e=t._getBindingValues(0),i=t._getBindingValues(1),n=t._getBindingValues(2),a=t._getBindingValues(3),s=t.getValues(1)||this.chart._xvals;this._calculator=new w(e,i,n,a,s,this._reversalAmount,this._rangeMode,this._fields),this._rangeValues=this._calculator.calculate(),(null===this._rangeValues||u.isUndefined(this._rangeValues))&&(this._rangeValues=[]),this._generateXLabels(t)},e.prototype.plotSeries=function(t,e,i,n,a,s,r){this._calculate(n);var o=this.chart.series.indexOf(n),l=this._rangeValues.length,h=e.actualMin,_=e.actualMax,g=this._DEFAULT_WIDTH,p=n._getSymbolStroke(o),d=n._getAltSymbolStroke(o)||p,f=[],m=[];t.stroke=p,t.strokeWidth=g;var y,v,w,b,x,k,V,P=0;t.startGroup();for(var C=0;C<l;C++)y=C,c._DataInfo.isValid(y)&&h<=y&&y<=_&&(v=this._rangeValues[C].open,w=this._rangeValues[C].close,0===C?(b=Math.min(v,w),x=Math.max(v,w),t.strokeWidth=v>w?g:2*g,t.stroke=v>w?p:d,t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(w)),t.drawLine(e.convert(y-1)-t.strokeWidth/2,i.convert(v),e.convert(y)+t.strokeWidth/2,i.convert(v))):t.strokeWidth===g?w>v?(w>x?(t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(x)),t.strokeWidth=2*g,t.stroke=d,t.drawLine(e.convert(y),i.convert(x),e.convert(y),i.convert(w)),b=v):t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(w)),x=w):t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(w)):t.strokeWidth/2===g&&(w<v?(w<b?(t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(b)),t.strokeWidth=g,t.stroke=p,t.drawLine(e.convert(y),i.convert(b),e.convert(y),i.convert(w)),x=v):t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(w)),b=w):t.drawLine(e.convert(y),i.convert(v),e.convert(y),i.convert(w))),C<l-1&&t.drawLine(e.convert(y)-t.strokeWidth/2,i.convert(w),e.convert(y+1)+t.strokeWidth/2,i.convert(w)),V=this._getDataPoint(o,C,n,w),(k=new c._CircleArea(new u.Point(e.convert(y),i.convert(w)),.5*t.strokeWidth)).tag=V,this.hitTester.add(k,o),n._setPointIndex(C,P),P++,f.push(e.convert(y)),m.push(i.convert(v)),f.push(e.convert(y)),m.push(i.convert(w)));t.endGroup(),this.hitTester.add(new c._LinesArea(f,m),o)},e.prototype._init=function(){t.prototype._init.call(this),this._reversalAmount=this.getNumOption("reversalAmount","kagi")||14,this._rangeMode=this.getOption("rangeMode","kagi")||P.Fixed,this._rangeMode=u.asEnum(this._rangeMode,P,!0),this._fields=this.getOption("fields","kagi")||V.Close,this._fields=u.asEnum(this._fields,V,!0)},e.prototype.clear=function(){t.prototype.clear.call(this),this._reversalAmount=null,this._rangeMode=null},e}(k),t("_KagiPlotter",A),function(t){t[t.Traditional=0]="Traditional",t[t.Fixed=1]="Fixed",t[t.Dynamic=2]="Dynamic"}(M||(M={})),t("PointAndFigureScaling",M),S=function(t){function e(){return t.call(this)||this}return h(e,t),e.prototype.clear=function(){t.prototype.clear.call(this),this._boxSize=null,this._fields=null,this._reversal=null,this._scaling=null},e.prototype.unload=function(){t.prototype.unload.call(this),this.chart.axisX.itemsSource=this._xlbls},e.prototype._init=function(){this._boxSize=this.getNumOption("boxSize","pointAndFigure")||1,this._reversal=this.getNumOption("reversal","pointAndFigure")||3,this._period=this.getNumOption("period","pointAndFigure")||20,this._fields=this.getOption("fields","pointAndFigure")||V.Close,this._fields=u.asEnum(this._fields,V,!0),u.assert(this._fields==V.Close||this._fields==V.HighLow,"Only DataFields.Close and DataFields.HighLow are supported"),this._scaling=this.getOption("scaling","pointAndFigure")||M.Traditional,this._scaling=u.asEnum(this._scaling,M,!0),this._xlbls=[]},e.prototype.adjustLimits=function(t,e){this._init(),this.hitTester.clear();var i=new u.Rect(0,0,0,0),n=this.chart.series.length;if(u.assert(n<=1,"Current FinancialChartType only supports a single series"),n>0){var a=this.chart.series[0],s=this._reversal,r=a.collectionView?a.collectionView:this.chart.collectionView,o=r?r.items:null;if(o&&o.length>0){var l=a._getBinding(0),h=a._getBinding(1),c=a._getBinding(2),_=a._getBinding(3);this._fields==V.Close&&(_?l=_:c&&(l=c),h=l);var g=a.bindingX?a.bindingX:this.chart.bindingX,p=this._actualBoxSize=this.calcBoxSize(o,l,h);if(this._pfdata=this.calcPFHiLo2(o,l,h,g,p,s),this._pfdata&&this._pfdata.length>0){var d=this._pfdata.reduce(function(t,e){return Math.max(t,e.max)},this._pfdata[0].max),f=this._pfdata.reduce(function(t,e){return Math.min(t,e.min)},this._pfdata[0].min);i=new u.Rect(-.5,f-.5*p,this._pfdata.length,d-f+p);for(var m=1;m<this._pfdata.length;m++){var y=this._pfdata[m-1],v=this._pfdata[m];u.isDate(v.date)&&u.isDate(y.date)&&v.date.getYear()!=y.date.getYear()&&this._xlbls.push({value:m,text:u.Globalize.formatNumber(v.date.getFullYear()%100,"d2")})}}}}return 0==this._xlbls.length&&this._xlbls.push({value:0}),this.chart.axisY.majorGrid=!1,this.chart.axisX.itemsSource=this._xlbls,i},e.prototype.plotSeries=function(t,e,i,n,a,s,r){if(this._pfdata&&this._pfdata.length>0){var o=this._actualBoxSize;this.renderGrid(t,this._pfdata,o),this.renderData(this.chart,t,this._pfdata,o)}},e.prototype.calcBoxSize=function(t,e,i){var n=t.reduce(function(t,i){return Math.max(t,i[e])},t[0][e]),a=t.reduce(function(t,e){return Math.min(t,e[i])},t[0][i]),s=this._boxSize,o=n-a;switch(this._scaling){case M.Traditional:o<.25?s=.0625:o>=.25&&o<1?s=.125:o>=1&&o<5?s=.25:o>=5&&o<20?s=.5:o>=20&&o<100?s=1:o>=100&&o<200?s=2:o>=200&&o<500?s=4:o>=500&&o<1e3?s=5:o>=1e3&&o<25e3?s=50:o>-25e3&&(s=500);break;case M.Dynamic:var l=this.chart.series[0],h=l._getBindingValues(0),u=l._getBindingValues(1),c=(l._getBindingValues(2),r(h,u,l._getBindingValues(3),this._period));s=c[c.length-1];break;case M.Fixed:}return s},e.prototype.calcPFHiLo2=function(t,e,i,n,a,s){for(var r=[],o=0;o<t.length;o++){var l=t[o][e],h=t[o][i];u.assert(l>=h,"'High' value must be larger than 'low' value.");var c=t[o][n];if(0==r.length)r.push({min:this.roundDown(h,a),max:this.roundDown(l,a),rise:!1,date:c});else{var _=r[r.length-1];if(_.rise){var g=_.max+a,p=_.max-s*a;this.roundUp(l,a)>=g?_.max=this.roundUp(l,a):h<=p&&r.push({min:this.roundDown(h,a),max:_.max-a,rise:!1,date:c})}else{var g=_.min-a,p=_.min+s*a;this.roundDown(h,a)<=g?_.min=this.roundDown(h,a):l>=p&&r.push({min:_.min+a,max:this.roundUp(l,a),rise:!0,date:c})}}}if(r.length>0){var d=r[0];d.min==d.max&&r.splice(0,1)}return r},e.prototype.roundUp=function(t,e){return Math.ceil(t/e-.999999)*e},e.prototype.roundDown=function(t,e){return Math.floor(t/e+.999999)*e},e.prototype.renderGrid=function(t,e,i){if(this._pfdata){for(var n=this._pfdata.reduce(function(t,e){return Math.max(t,e.max)},this._pfdata[0].max),a=this._pfdata.reduce(function(t,e){return Math.min(t,e.min)},this._pfdata[0].min),s=this.chart,r=this._pfdata.length,o=a-.5*i;o<=n+i;o+=i){h=new u.Point(-.5,o);h=s.dataToPoint(h);_=new u.Point(r,o);_=s.dataToPoint(_),t.stroke=c.FlexChart._FG,t.strokeWidth=1,t.drawLine(h.x,h.y,_.x,_.y,c.FlexChart._CSS_GRIDLINE)}for(var l=-.5;l<=r;l+=1){var h=new u.Point(l,this.chart.axisY.actualMin);h=s.dataToPoint(h);var _=new u.Point(l,this.chart.axisY.actualMax);_=s.dataToPoint(_),t.stroke=c.FlexChart._FG,t.strokeWidth=1,t.drawLine(h.x,h.y,_.x,_.y,c.FlexChart._CSS_GRIDLINE)}}},e.prototype.renderData=function(t,e,i,n){for(var a=t.series[0],s=a._getSymbolStroke(0),r=a._getAltSymbolStroke(0)||s,o=0;o<i.length;o++){var l=i[o],h=(i[o].max-i[o].min)/n;if(0!=h){var _=new u.Point(o-.5,l.min);_=t.dataToPoint(_);var g=new u.Point(o+.5,l.max);g=t.dataToPoint(g),e.fill="transparent";for(var p=(g.y-_.y)/h,d=0;d<h+1;d++)if(e.strokeWidth=1.5,l.rise?(e.stroke=s,e.drawLine(_.x,_.y+(d-.5)*p,g.x,_.y+(d+.5)*p),e.drawLine(g.x,_.y+(d-.5)*p,_.x,_.y+(d+.5)*p)):(e.stroke=r,e.drawEllipse(.5*(_.x+g.x),_.y+d*p,.5*Math.abs(_.x-g.x),.5*Math.abs(p))),this.hitTester){var f=l.min+d*n,m=new c._DataPoint(0,o,l.date,f);m.y=f,m.yfmt=this.chart.axisY._formatValue(f),u.isDate(l.date)&&(m.x=l.date,m.xfmt=u.Globalize.formatDate(l.date,"d"));var y=new u.Rect(Math.min(_.x,g.x),_.y+d*p-.5*p,Math.abs(g.x-_.x),p);y.height<0&&(y.top+=p,y.height=-y.height);var v=new c._RectArea(y);v.tag=m,this.hitTester.add(v,0)}}}},e}(c._BasePlotter),t("_PointAndFigurePlotter",S)}}});