/*
  Highcharts JS v7.0.3 (2019-02-06)

 Data grouping module

 (c) 2010-2019 Torstein Hnsi

 License: www.highcharts.com/license
*/
(function(e){"object"===typeof module&&module.exports?(e["default"]=e,module.exports=e):"function"===typeof define&&define.amd?define(function(){return e}):e("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(e){return function(d){var e=d.addEvent,H=d.arrayMax,I=d.arrayMin,v=d.Axis,J=d.defaultPlotOptions,C=d.defined,K=d.extend,L=d.format,n=d.isNumber,D=d.merge,w=d.pick,M=d.Point,x=d.Series,N=d.Tooltip,h=d.approximations={sum:function(a){var c=a.length,b;if(!c&&a.hasNulls)b=null;else if(c)for(b=
0;c--;)b+=a[c];return b},average:function(a){var c=a.length;a=h.sum(a);n(a)&&c&&(a/=c);return a},averages:function(){var a=[];[].forEach.call(arguments,function(c){a.push(h.average(c))});return void 0===a[0]?void 0:a},open:function(a){return a.length?a[0]:a.hasNulls?null:void 0},high:function(a){return a.length?H(a):a.hasNulls?null:void 0},low:function(a){return a.length?I(a):a.hasNulls?null:void 0},close:function(a){return a.length?a[a.length-1]:a.hasNulls?null:void 0},ohlc:function(a,c,b,k){a=h.open(a);
c=h.high(c);b=h.low(b);k=h.close(k);if(n(a)||n(c)||n(b)||n(k))return[a,c,b,k]},range:function(a,c){a=h.low(a);c=h.high(c);if(n(a)||n(c))return[a,c];if(null===a&&null===c)return null}},F=function(a,c,b,k){var f=this,d=f.data,r=f.options&&f.options.data,E=[],l=[],p=[],m=a.length,g,e,t=!!c,u=[],y=f.pointArrayMap,v=y&&y.length,z=["x"].concat(y||["y"]),A=0,w=0,x,q;k="function"===typeof k?k:h[k]?h[k]:h[f.getDGApproximation&&f.getDGApproximation()||"average"];v?y.forEach(function(){u.push([])}):u.push([]);
x=v||1;for(q=0;q<=m&&!(a[q]>=b[0]);q++);for(q;q<=m;q++){for(;void 0!==b[A+1]&&a[q]>=b[A+1]||q===m;){g=b[A];f.dataGroupInfo={start:f.cropStart+w,length:u[0].length};e=k.apply(f,u);f.pointClass&&!C(f.dataGroupInfo.options)&&(f.dataGroupInfo.options=D(f.pointClass.prototype.optionsToObject.call({series:f},f.options.data[f.cropStart+w])),z.forEach(function(a){delete f.dataGroupInfo.options[a]}));void 0!==e&&(E.push(g),l.push(e),p.push(f.dataGroupInfo));w=q;for(g=0;g<x;g++)u[g].length=0,u[g].hasNulls=
!1;A+=1;if(q===m)break}if(q===m)break;if(y){g=f.cropStart+q;e=d&&d[g]||f.pointClass.prototype.applyOptions.apply({series:f},[r[g]]);var B;for(g=0;g<v;g++)B=e[y[g]],n(B)?u[g].push(B):null===B&&(u[g].hasNulls=!0)}else g=t?c[q]:null,n(g)?u[0].push(g):null===g&&(u[0].hasNulls=!0)}return{groupedXData:E,groupedYData:l,groupMap:p}},O={approximations:h,groupData:F},t=x.prototype,P=t.processData,Q=t.generatePoints,z={groupPixelWidth:2,dateTimeLabelFormats:{millisecond:["%A, %b %e, %H:%M:%S.%L","%A, %b %e, %H:%M:%S.%L",
"-%H:%M:%S.%L"],second:["%A, %b %e, %H:%M:%S","%A, %b %e, %H:%M:%S","-%H:%M:%S"],minute:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],hour:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],day:["%A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],week:["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],month:["%B %Y","%B","-%B %Y"],year:["%Y","%Y","-%Y"]}},G={line:{},spline:{},area:{},areaspline:{},column:{groupPixelWidth:10},columnrange:{groupPixelWidth:10},candlestick:{groupPixelWidth:10},ohlc:{groupPixelWidth:5}},
R=d.defaultDataGroupingUnits=[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1]],["week",[1]],["month",[1,3,6]],["year",null]];t.getDGApproximation=function(){return d.seriesTypes.arearange&&this instanceof d.seriesTypes.arearange?"range":d.seriesTypes.ohlc&&this instanceof d.seriesTypes.ohlc?"ohlc":d.seriesTypes.column&&this instanceof d.seriesTypes.column?"sum":"average"};t.groupData=F;t.processData=function(){var a=
this.chart,c=this.options.dataGrouping,b=!1!==this.allowDG&&c&&w(c.enabled,a.options.isStock),k=this.visible||!a.options.chart.ignoreHiddenSeries,f,d=this.currentDataGrouping,r,e=!1;this.forceCrop=b;this.groupPixelWidth=null;this.hasProcessed=!0;b&&!this.requireSorting&&(this.requireSorting=e=!0);b=!1===P.apply(this,arguments)||!b;e&&(this.requireSorting=!1);if(!b){this.destroyGroupedData();var l,b=c.groupAll?this.xData:this.processedXData,p=c.groupAll?this.yData:this.processedYData,m=a.plotSizeX,
a=this.xAxis,g=a.options.ordinal,h=this.groupPixelWidth=a.getGroupPixelWidth&&a.getGroupPixelWidth();if(h){this.isDirty=f=!0;this.points=null;e=a.getExtremes();r=e.min;var e=e.max,g=g&&a.getGroupIntervalFactor(r,e,this)||1,h=h*(e-r)/m*g,m=a.getTimeTicks(a.normalizeTimeTickInterval(h,c.units||R),Math.min(r,b[0]),Math.max(e,b[b.length-1]),a.options.startOfWeek,b,this.closestPointRange),p=t.groupData.apply(this,[b,p,m,c.approximation]),b=p.groupedXData,g=p.groupedYData,n=0;if(c.smoothed&&b.length){l=
b.length-1;for(b[l]=Math.min(b[l],e);l--&&0<l;)b[l]+=h/2;b[0]=Math.max(b[0],r)}for(l=1;l<m.length;l++)m.info.segmentStarts&&-1!==m.info.segmentStarts.indexOf(l)||(n=Math.max(m[l]-m[l-1],n));r=m.info;r.gapSize=n;this.closestPointRange=m.info.totalRange;this.groupMap=p.groupMap;if(C(b[0])&&b[0]<a.dataMin&&k){if(!C(a.options.min)&&a.min<=a.dataMin||a.min===a.dataMin)a.min=b[0];a.dataMin=b[0]}c.groupAll&&(c=this.cropData(b,g,a.min,a.max,1),b=c.xData,g=c.yData);this.processedXData=b;this.processedYData=
g}else this.groupMap=null;this.hasGroupedData=f;this.currentDataGrouping=r;this.preventGraphAnimation=(d&&d.totalRange)!==(r&&r.totalRange)}};t.destroyGroupedData=function(){var a=this.groupedData;(a||[]).forEach(function(c,b){c&&(a[b]=c.destroy?c.destroy():null)});this.groupedData=null};t.generatePoints=function(){Q.apply(this);this.destroyGroupedData();this.groupedData=this.hasGroupedData?this.points:null};e(M,"update",function(){if(this.dataGroup)return d.error(24,!1,this.series.chart),!1});e(N,
"headerFormatter",function(a){var c=this.chart.time,b=a.labelConfig,k=b.series,f=k.tooltipOptions,e=k.options.dataGrouping,d=f.xDateFormat,h,l=k.xAxis,p,m=f[(a.isFooter?"footer":"header")+"Format"];l&&"datetime"===l.options.type&&e&&n(b.key)&&(p=k.currentDataGrouping,e=e.dateTimeLabelFormats||z.dateTimeLabelFormats,p?(f=e[p.unitName],1===p.count?d=f[0]:(d=f[1],h=f[2])):!d&&e&&(d=this.getXDateFormat(b,f,l)),d=c.dateFormat(d,b.key),h&&(d+=c.dateFormat(h,b.key+p.totalRange-1)),k.chart.styledMode&&(m=
this.styledModeFormat(m)),a.text=L(m,{point:K(b.point,{key:d}),series:k},c),a.preventDefault())});e(x,"destroy",t.destroyGroupedData);e(x,"afterSetOptions",function(a){a=a.options;var c=this.type,b=this.chart.options.plotOptions,d=J[c].dataGrouping,f=this.useCommonDataGrouping&&z;if(G[c]||f)d||(d=D(z,G[c])),a.dataGrouping=D(f,d,b.series&&b.series.dataGrouping,b[c].dataGrouping,this.userOptions.dataGrouping)});e(v,"afterSetScale",function(){this.series.forEach(function(a){a.hasProcessed=!1})});v.prototype.getGroupPixelWidth=
function(){var a=this.series,c=a.length,b,d=0,f=!1,e;for(b=c;b--;)(e=a[b].options.dataGrouping)&&(d=Math.max(d,w(e.groupPixelWidth,z.groupPixelWidth)));for(b=c;b--;)(e=a[b].options.dataGrouping)&&a[b].hasProcessed&&(c=(a[b].processedXData||a[b].data).length,a[b].groupPixelWidth||c>this.chart.plotSizeX/d||c&&e.forced)&&(f=!0);return f?d:0};v.prototype.setDataGrouping=function(a,c){var b;c=w(c,!0);a||(a={forced:!1,units:null});if(this instanceof v)for(b=this.series.length;b--;)this.series[b].update({dataGrouping:a},
!1);else this.chart.options.series.forEach(function(b){b.dataGrouping=a},!1);this.ordinalSlope=null;c&&this.chart.redraw()};return d.dataGrouping=O}(e)});
//# sourceMappingURL=datagrouping.js.map
