AxMari
Posts: 6
Joined: Thu Sep 05, 2024 7:01 pm

Highstock Data grouping by number of values

Hello all. trying to use the dataGrouping to allow users to pass a number to group the data points by that number (for ex. if they input 50, every 50 points will be grouped into one data point that is the average of those 50 points). I see groupPixelWidth which goes by pixel size but that doesn't fulfill the acceptance criteria. What is the best way to implement this? Thank you
pawelys
Site Moderator
Posts: 1019
Joined: Wed Sep 02, 2020 10:37 am

Re: Highstock Data grouping by number of values

Hello AxMari,

Regrettably, the feature you're seeking isn't part of our current offerings. A potential workaround you might consider involves our `units` API option. This is primarily designed for stock-related data where constant intervals between points are crucial. You can leverage it when your data points are consistently spaced out. Then, you can calculate the desired group size through a combination of the interval and quantity of points you wish to group. Do bear in mind that if the time periods between your points differ, the number of points within each group will vary. I realize this may not completely address your need, but we wanted to give you a starting point.

Should you need more clarification, do not hesitate to reach out. We enjoy solving challenges together!
Paweł Lysy
Highcharts Developer
AxMari
Posts: 6
Joined: Thu Sep 05, 2024 7:01 pm

Re: Highstock Data grouping by number of values

ahh darn, I'll have to do some sort of work around. Thank you
AxMari
Posts: 6
Joined: Thu Sep 05, 2024 7:01 pm

Re: Highstock Data grouping by number of values

pawelys wrote: Thu Sep 19, 2024 8:23 am Hello AxMari,

Regrettably, the feature you're seeking isn't part of our current offerings. A potential workaround you might consider involves our `units` API option. This is primarily designed for stock-related data where constant intervals between points are crucial. You can leverage it when your data points are consistently spaced out. Then, you can calculate the desired group size through a combination of the interval and quantity of points you wish to group. Do bear in mind that if the time periods between your points differ, the number of points within each group will vary. I realize this may not completely address your need, but we wanted to give you a starting point.

Should you need more clarification, do not hesitate to reach out. We enjoy solving challenges together!
is there a way for me to do a rolling average of every (ex.4) points instead? like every point is the average of the previous 4 points?
pawelys
Site Moderator
Posts: 1019
Joined: Wed Sep 02, 2020 10:37 am

Re: Highstock Data grouping by number of values

Hi AxMari,

I've got two possible solutions to help you achieve your objective.

Firstly, you may consider using the SMA indicator. It's designed to compute the average from a specified number of points outlined in the `series.params.period`. You can check out how it works here: https://jsfiddle.net/BlackLabel/x09zajvL/

Just a friendly heads up - this indicator series won't replace your original series. Instead, it calculates its values based on your main series values. So, for instance, if you're starting with a series like this:
[
[0, 1],
[1, 2],
[2, 2],
[3, 5],
[4, 5]
]
and you select period 4, the output would look something like this:
[
[3, 2.5],
[4, 3.5]
]

Alternatively, another solution is to make use of the dataGrouping option, as I pointed out earlier. We've got an API option, dataGrouping.approximation, that can help you sort out how your values are computed based on the points found in your grouped point. Here's where you can find it: https://api.highcharts.com/highstock/se ... roximation

Much like the first option, this one also has its own set of rules: if the time periods between your points differ, the number of points per group can change.

Feel free to look deeper into the details in our API reference, and of course, if you have any more questions or need further clarification, I'm here to help!
Paweł Lysy
Highcharts Developer

Return to “Highcharts Usage”