Grouping data weekly, monthly

I have an elevator chart showing daily and weekly stock prices for a given stock. The problem is that the data array is large enough and the daily data points are β€œsampled” into the weekly data points, and the weekly data is checked to the monthly data points.

Is there a way to install them by the user weekly or monthly, when necessary.

Thanks in advance

+6
source share
3 answers

Check out dataGrouping .
You can customize it when necessary, for example,.
Or , if you want to disable , you can set it to false, for example, the code below or here :

series: [{ type: 'candlestick', name: 'AAPL', data: arrayOfData, dataGrouping: { enabled: false } }] 
+7
source

You can change dataGrouping.units at any time using the update() method of each series:

 //http://api.highcharts.com/highstock#plotOptions.series.dataGrouping.units var unit = 'week'; //'day' 'month' //http://api.highcharts.com/highstock#Series.update _chart.series.forEach(function(ser) { ser.update({ dataGrouping: { units: [ [unit, [1]] ] } }, false); }); _chart.redraw(); 

Example: http://jsfiddle.net/X5WbN/20/

+2
source

We tried Hack around this, where we used Highstock (Splinechart) RangeSelector , Event and DataGrouping . When we click the weekly rangeselectorButton, we will catch this event through setExtremes . The message catching the event brings it closer to the "sum". If you use two series than iterating over an object.

  events: { setExtremes: function (e) { if (e.rangeSelectorButton != undefined) { var triger = e.rangeSelectorButton; if (triger.type == 'week') { $.each(this.series, function (index, obj) { obj.options.dataGrouping.units[0] = ['week', [1]]; }); } else if (triger.type == 'day') { $.each(this.series, function (index, obj) { obj.options.dataGrouping.units[0] = ['day', [1]]; }); } } } }, 

@ fiddle

-1
source

Source: https://habr.com/ru/post/911554/


All Articles