dl-gro
Posts: 3
Joined: Mon Jul 17, 2023 8:39 pm

Force Highcharts to not group the last data point in a series

Mon Jul 17, 2023 8:44 pm

Hello,

I am working with Highcharts to plot some time series data.
Some of my charts have a few thousand data points and I know that Highcharts automatically groups data points to optimize for readability and performance.
However, is there a way to force Highcharts to not group the last data point?

I want to allow Highcharts to group data points as it normally does, but disable it for only the last data point in a series so that when a user hovers over the chart, the tooltip that pops over the last point in the chart always corresponds to the last data point in the series.
Is this possible?
I tried setting `dataGrouping: { lastAnchor: 'lastPoint' }` but that did not have the desired effect.

Thanks!

jakub.j
Posts: 857
Joined: Tue Jan 24, 2023 11:14 am

Re: Force Highcharts to not group the last data point in a series

Tue Jul 18, 2023 7:13 am

Thanks for contacting us with your question!

To always show the last point, when grouping the data, you need to set the dataGrouping.approximation to 'close', so that when grouping the data, Highstock will consider the last value in the group.

Demo: https://jsfiddle.net/BlackLabel/ye2goxud/

Feel free to ask any further questions!
Best regards
Jakub
Jakub
Highcharts Developer

dl-gro
Posts: 3
Joined: Mon Jul 17, 2023 8:39 pm

Re: Force Highcharts to not group the last data point in a series

Tue Jul 18, 2023 2:39 pm

Thanks Jakub!

Is there a way to access the dataGroups themselves and set different approximation properties for each?
For example, is there a way to have approximation set to 'average' for all of the data groups except the last group which would have approximation set to 'close'?

dl-gro
Posts: 3
Joined: Mon Jul 17, 2023 8:39 pm

Re: Force Highcharts to not group the last data point in a series

Tue Jul 18, 2023 5:55 pm

Alternatively, is there an approximation setting that will show the data point's actual value?
E.g. if the viewport is small and chart data points are grouped by month, is there way to have Highcharts display the values associated with the actual dates?

Approximation: close - July 1, 2023 - would show the point value for the latest point this month.

Approximation: average - July 1, 2023 - would show the average of the point's in the group.

Desired setting - Approximation: actual? - July 1, 2023 - would show the actual value for the point which occurred on July 1, 2023.

Thanks!

jakub.j
Posts: 857
Joined: Tue Jan 24, 2023 11:14 am

Re: Force Highcharts to not group the last data point in a series

Wed Jul 19, 2023 1:18 pm

Hey!

Unfortunately, there is no way to have approximation set differently for different groups in the same series. You can either set 'average' or 'close' at once. One thing you can do, is to separate your data into 2 series, and than set different approximation for each of them so that it will work as you intended.

I hope you will find it useful
Best regards
Jakub
Jakub
Highcharts Developer

Return to “Highcharts Stock”