whychdw
2019-09-05 a021b459247a5cf825c2a132f3da1e5d31e8037c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 Highstock JS v7.1.3 (2019-08-14)
 
 Data grouping module
 
 (c) 2010-2019 Torstein Hnsi
 
 License: www.highcharts.com/license
*/
(function(d){"object"===typeof module&&module.exports?(d["default"]=d,module.exports=d):"function"===typeof define&&define.amd?define("highcharts/modules/datagrouping",["highcharts"],function(u){d(u);d.Highcharts=u;return d}):d("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(d){function u(e,d,u,l){e.hasOwnProperty(d)||(e[d]=l.apply(null,u))}d=d?d._modules:{};u(d,"parts/DataGrouping.js",[d["parts/Globals.js"],d["parts/Utilities.js"]],function(e,d){var u=d.defined,l=d.isNumber;d=e.addEvent;
var I=e.arrayMax,J=e.arrayMin,z=e.Axis,K=e.correctFloat,L=e.defaultPlotOptions,M=e.extend,N=e.format,C=e.merge,y=e.pick,O=e.Point,A=e.Series,P=e.Tooltip,f=e.approximations={sum:function(a){var c=a.length;if(!c&&a.hasNulls)var b=null;else if(c)for(b=0;c--;)b+=a[c];return b},average:function(a){var c=a.length;a=f.sum(a);l(a)&&c&&(a=K(a/c));return a},averages:function(){var a=[];[].forEach.call(arguments,function(c){a.push(f.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?I(a):a.hasNulls?null:void 0},low:function(a){return a.length?J(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,v){a=f.open(a);c=f.high(c);b=f.low(b);v=f.close(v);if(l(a)||l(c)||l(b)||l(v))return[a,c,b,v]},range:function(a,c){a=f.low(a);c=f.high(c);if(l(a)||l(c))return[a,c];if(null===a&&null===c)return null}},F=function(a,c,b,v){var g=this,d=g.data,e=g.options&&g.options.data,
E=[],m=[],p=[],q=a.length,Q=!!c,r=[],h=g.pointArrayMap,n=h&&h.length,z=["x"].concat(h||["y"]),x=0,y=0,t;v="function"===typeof v?v:f[v]?f[v]:f[g.getDGApproximation&&g.getDGApproximation()||"average"];n?h.forEach(function(){r.push([])}):r.push([]);var A=n||1;for(t=0;t<=q&&!(a[t]>=b[0]);t++);for(t;t<=q;t++){for(;void 0!==b[x+1]&&a[t]>=b[x+1]||t===q;){var k=b[x];g.dataGroupInfo={start:g.cropStart+y,length:r[0].length};var B=v.apply(g,r);g.pointClass&&!u(g.dataGroupInfo.options)&&(g.dataGroupInfo.options=
C(g.pointClass.prototype.optionsToObject.call({series:g},g.options.data[g.cropStart+y])),z.forEach(function(a){delete g.dataGroupInfo.options[a]}));void 0!==B&&(E.push(k),m.push(B),p.push(g.dataGroupInfo));y=t;for(k=0;k<A;k++)r[k].length=0,r[k].hasNulls=!1;x+=1;if(t===q)break}if(t===q)break;if(h)for(k=g.cropStart+t,B=d&&d[k]||g.pointClass.prototype.applyOptions.apply({series:g},[e[k]]),k=0;k<n;k++){var D=B[h[k]];l(D)?r[k].push(D):null===D&&(r[k].hasNulls=!0)}else k=Q?c[t]:null,l(k)?r[0].push(k):null===
k&&(r[0].hasNulls=!0)}return{groupedXData:E,groupedYData:m,groupMap:p}},G={approximations:f,groupData:F},n=A.prototype,R=n.processData,S=n.generatePoints,x={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"]}},H={line:{},spline:{},area:{},areaspline:{},column:{groupPixelWidth:10},columnrange:{groupPixelWidth:10},candlestick:{groupPixelWidth:10},ohlc:{groupPixelWidth:5}},T=e.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]];n.getDGApproximation=
function(){return e.seriesTypes.arearange&&this instanceof e.seriesTypes.arearange?"range":e.seriesTypes.ohlc&&this instanceof e.seriesTypes.ohlc?"ohlc":e.seriesTypes.column&&this instanceof e.seriesTypes.column?"sum":"average"};n.groupData=F;n.processData=function(){var a=this.chart,c=this.options.dataGrouping,b=!1!==this.allowDG&&c&&y(c.enabled,a.options.isStock),d=this.visible||!a.options.chart.ignoreHiddenSeries,g,e=this.currentDataGrouping,w=!1;this.forceCrop=b;this.groupPixelWidth=null;this.hasProcessed=
!0;b&&!this.requireSorting&&(this.requireSorting=w=!0);b=!1===R.apply(this,arguments)||!b;w&&(this.requireSorting=!1);if(!b){this.destroyGroupedData();b=c.groupAll?this.xData:this.processedXData;var l=c.groupAll?this.yData:this.processedYData,m=a.plotSizeX;a=this.xAxis;var p=a.options.ordinal,q=this.groupPixelWidth=a.getGroupPixelWidth&&a.getGroupPixelWidth();if(q){this.isDirty=g=!0;this.points=null;w=a.getExtremes();var f=w.min;w=w.max;p=p&&a.getGroupIntervalFactor(f,w,this)||1;q=q*(w-f)/m*p;m=a.getTimeTicks(a.normalizeTimeTickInterval(q,
c.units||T),Math.min(f,b[0]),Math.max(w,b[b.length-1]),a.options.startOfWeek,b,this.closestPointRange);l=n.groupData.apply(this,[b,l,m,c.approximation]);b=l.groupedXData;p=l.groupedYData;var r=0;if(c.smoothed&&b.length){var h=b.length-1;for(b[h]=Math.min(b[h],w);h--&&0<h;)b[h]+=q/2;b[0]=Math.max(b[0],f)}for(h=1;h<m.length;h++)m.info.segmentStarts&&-1!==m.info.segmentStarts.indexOf(h)||(r=Math.max(m[h]-m[h-1],r));f=m.info;f.gapSize=r;this.closestPointRange=m.info.totalRange;this.groupMap=l.groupMap;
if(u(b[0])&&b[0]<a.min&&d){if(!u(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,p,a.min,a.max,1),b=c.xData,p=c.yData);this.processedXData=b;this.processedYData=p}else this.groupMap=null;this.hasGroupedData=g;this.currentDataGrouping=f;this.preventGraphAnimation=(e&&e.totalRange)!==(f&&f.totalRange)}};n.destroyGroupedData=function(){var a=this.groupedData;(a||[]).forEach(function(c,b){c&&(a[b]=c.destroy?c.destroy():null)});this.groupedData=
null};n.generatePoints=function(){S.apply(this);this.destroyGroupedData();this.groupedData=this.hasGroupedData?this.points:null};d(O,"update",function(){if(this.dataGroup)return e.error(24,!1,this.series.chart),!1});d(P,"headerFormatter",function(a){var c=this.chart.time,b=a.labelConfig,d=b.series,g=d.tooltipOptions,e=d.options.dataGrouping,f=g.xDateFormat,n=d.xAxis,m=g[(a.isFooter?"footer":"header")+"Format"];if(n&&"datetime"===n.options.type&&e&&l(b.key)){var p=d.currentDataGrouping;e=e.dateTimeLabelFormats||
x.dateTimeLabelFormats;if(p)if(g=e[p.unitName],1===p.count)f=g[0];else{f=g[1];var q=g[2]}else!f&&e&&(f=this.getXDateFormat(b,g,n));f=c.dateFormat(f,b.key);q&&(f+=c.dateFormat(q,b.key+p.totalRange-1));d.chart.styledMode&&(m=this.styledModeFormat(m));a.text=N(m,{point:M(b.point,{key:f}),series:d},c);a.preventDefault()}});d(A,"destroy",n.destroyGroupedData);d(A,"afterSetOptions",function(a){a=a.options;var c=this.type,b=this.chart.options.plotOptions,d=L[c].dataGrouping,e=this.useCommonDataGrouping&&
x;if(H[c]||e)d||(d=C(x,H[c])),a.dataGrouping=C(e,d,b.series&&b.series.dataGrouping,b[c].dataGrouping,this.userOptions.dataGrouping)});d(z,"afterSetScale",function(){this.series.forEach(function(a){a.hasProcessed=!1})});z.prototype.getGroupPixelWidth=function(){var a=this.series,c=a.length,b,d=0,e=!1,f;for(b=c;b--;)(f=a[b].options.dataGrouping)&&(d=Math.max(d,y(f.groupPixelWidth,x.groupPixelWidth)));for(b=c;b--;)(f=a[b].options.dataGrouping)&&a[b].hasProcessed&&(c=(a[b].processedXData||a[b].data).length,
a[b].groupPixelWidth||c>this.chart.plotSizeX/d||c&&f.forced)&&(e=!0);return e?d:0};z.prototype.setDataGrouping=function(a,c){var b;c=y(c,!0);a||(a={forced:!1,units:null});if(this instanceof z)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()};e.dataGrouping=G;"";return G});u(d,"masters/modules/datagrouping.src.js",[d["parts/DataGrouping.js"]],function(d){return d})});
//# sourceMappingURL=datagrouping.js.map