niveki
Posts: 13
Joined: Tue Mar 15, 2022 8:09 pm

rangeselector sum value

Hello,

I would like to group my data by day, month or year. I find rangeselector function, but the result is given by average.
It's possible to give the sum result ?

Thanks
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: rangeselector sum value

Hi there,

Thank you for contacting us.
I am not sure what you mean by 'result is given by average' and 'sum result'.

Range selector by default shows you the data i.e 3 months, 6 months back from the last data point. So for example, 6 months would be from December 28th to June 28th.
Could you explain it a bit further, and more importantly show me the result in a live code editor such as JSFiddle?

In the meantime, take a look at the given links, maybe you'll get some inspiration!
https://www.highcharts.com/demo/stock/basic-line
https://www.highcharts.com/docs/stock/range-selector
https://api.highcharts.com/highstock/rangeSelector

Waiting for your reply,
Best regards!
Kamil Musiałowski
Highcharts Developer
niveki
Posts: 13
Joined: Tue Mar 15, 2022 8:09 pm

Re: rangeselector sum value

Hi,

ok here you can find an exemple : https://codepen.io/k-vin-maitre/pen/zYWYwbp

if you select month zoom on February the result is 0.67 but it's not the sum of all the data on February because the sum is equal to 14.81 but 0.67 is the average of all the data for the month of February.

it's possible to change the average to the sum ?

thanks
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: rangeselector sum value

The value that you see on the chart is simply a y tick value, not an average of visible range. To get the sum of the visible points, you just have to iterate over them and add their values together. Please take a look at the demo below:
https://jsfiddle.net/BlackLabel/017nhceb/

Let me know if that is what you were looking for,
Best regards!
Kamil Musiałowski
Highcharts Developer
niveki
Posts: 13
Joined: Tue Mar 15, 2022 8:09 pm

Re: rangeselector sum value

hi,

thanks to try to help me.
but I think you don't understand me.
i will try to explain you differently, if you choose month by the "rangeSelector" option for example the value of the point to February need to be egual to 14.81 and not 0.67, same for April 1.82 not 0.06 the point calculate is by the average for all the data for the current month and for me result I need of the sum of data for the current month. And if I choose year I would like the sum of all the data for the year not the average because ([0.67+0.06+0.08+0+0]/5=0.16) the value put for the year option, but normally by sum the result is 19.03.

I hope you understand what I need to do, and sorry I'm French.

thanks
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: rangeselector sum value

Hi there,

Thank you for the explanation. I think now I know what you need to achieve!

You were really close to the solution. The default behavior of the dataGrouping approximation in line type series is 'average'. Just set it to 'sum' to get the desired outcome.
DEMO: https://jsfiddle.net/BlackLabel/b837k1qv/
API Reference: https://api.highcharts.com/highstock/pl ... roximation

I hope that you will find it useful,
Best regards!
Kamil Musiałowski
Highcharts Developer
niveki
Posts: 13
Joined: Tue Mar 15, 2022 8:09 pm

Re: rangeselector sum value

amazing it's just what I need thanks ! :D
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: rangeselector sum value

That's great to hear that, I'm really glad that I could help!

Do not hesitate to contact us in the future,
Best regards!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Usage”