Berb
Posts: 9
Joined: Mon Oct 02, 2023 12:49 pm

Highcharts.stockChart averaging when not asked

I have an area chart showing datapoints with 5 minute intervals. The data are integers. The value for 13th Feb at 1300 local is 517.

If I zoom out to show a large number of points, hovering over the 13th Feb 1300 will show a different value, in fact it shows a fraction with over 10 decimal points even though all the data is integers.

I guess when I zoom out, every point can't be displayed so points are displayed 15 minutes to half an hour apart with the values averaged. But I don't want to show an average between these points; I'd rather have fewer points but keep the values of each point.

Is there an option to do this? Have I accidentally set this averaging behaviour in the chart somewhere?

As a side note, how do I remove the decimals in the tooltip if I'm using the point formatter? Setting valueDecimals to zero in the series options is overridden by the formatter I think.
jedrzej.r
Posts: 725
Joined: Tue Jan 24, 2023 11:21 am

Re: Highcharts.stockChart averaging when not asked

Hi!

Thanks for reaching out to us!

This is a default behaviour for Highcharts Stock charts, since it uses dataGrouping to increase performance and readability, when there are multiple data points. You can simply disable this feature by setting the dataGrouping.enabled property to false.

When it comes to tooltip format, the valueDecimals is ignored when the pointFormatter is being used, as it's purpose is to completely customize the tooltip output. Instead, I'd recommend utilzing the pointFormat string templating, which doesn't require sanitizing the output and is JSON compatible.

Demo: https://jsfiddle.net/BlackLabel/92sjrmuv/

References:
https://www.highcharts.com/docs/stock/data-grouping
https://api.highcharts.com/highstock/se ... ng.enabled
https://api.highcharts.com/highstock/se ... roximation
https://api.highcharts.com/highcharts/t ... ointFormat
https://www.highcharts.com/docs/chart-c ... templating

Let me know if that was helpful for you.
Best regards!
Jędrzej Ruta
Highcharts Developer

Return to “Highcharts Usage”