quade1664
Posts: 1
Joined: Tue Jan 11, 2022 10:18 am

dataLabels or annotations above a certain threshold - for increased performance?

Hi

I have a multiline series graph, I have tried the following code for dataLabels so it shows a sensor when its above the alarm state

Code: Select all

dataLabels: {
	enabled: true,   
        formatter: function() {
        return (this.y>=maxAlarmThreshold)?this.y:"";
}},
This works, however the performance is terrible when plotting lots a months worth of data at 1 min intervals (with 10 series rendered)

I've also seen annotations is available.
My questions are
1) which is more performant, dataLabels or annotations
2) can I only render dataLabels when its in alarm, instead of rendering empty strings
3) how can I achieve the above code using annotations (just a few lines of code that considers the whole data set)

When I turn off dataLabels the performance is great, so its obviously something to do with enabling this
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: dataLabels or annotations above a certain threshold - for increased performance?

Hi quade1664,

Welcome to our forum and thanks for contacting us with your question!

First of all, could you try to create a live demo with your chart? Only that way I can tell for sure what can be done. You can start here: https://jsfiddle.net/BlackLabel/g96kt8jo/24/
In some cases there are simply too many data labels and improvement in the performance is not possible.

Regarding the question which labels have better performance, the answer is that it really depends. There are many factors like chart config and data format and data granuality. Generally I would say that data labels are more efficient in most cases, but if you want to show only few labels then annotations might be the way to go. Additionally, formatter is being triggered for each point, regardless if you want to show data label or not. As I said before, demo is necessary to tell what can be done.

Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”