Unexpected change in measure names after re-calling highcharts.getData() method with new measures in options.

Answered
Yegor asked on April 25, 2024

Hello Flexmonster team,

My name is Yegor, and I would like to share with you a potentially incorrect library behavior that I encountered in an application that my team is working on. I'll attach an example below and also describe the steps to reproduce it that I followed myself.
Example: https://jsfiddle.net/sbnq71fx/

To begin with, an instance of the Flexmonster class was created with some set of data. Before making any changes to the example, I log all the measures that are currently available in the instance.

Then I call the highcharts.getData() method to build a highchart, and in the options I pass a new measure without a name, only with a uniqueName. When I re-log the available measures in the instance, we see that the new measure is included in the general list and has a name added that matches the uniqueName.

Then I make a repeated call to highcharts.getData(), where I pass 3 measures in the options, and the first of them matches the previously passed measure by uniqueName, but this time its name has been updated to normal text. In addition to it, 2 new measures are added with normal names different from their uniqueNames.

And if after this I again make a log of available measures in the instance, we will notice that for the first measure, which coincided with the measure from the previous call, the name was updated to the correct one, different from the uniqueName. But for some reason, the names of two new measures were rewritten, and now they began to coincide with the uniqueNames. This can also be seen on the chart itself, which was drawn as a result. New measures have appeared on it, the first one has a normal name, the other two have uniqueNames displayed as names.

If in the options for measures, instead of the “name” property, I use the “caption” property to pass the displayed name, then everything will work correctly, the log will show measures with the correct names, and they will also be correct on the chart. Therefore, I’m not entirely sure whether this is an expected behavior or a bug.

4 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster April 26, 2024

Hello Yegor,

Thank you for reaching out to us and providing us with an example.

Kindly note that the getAllMeasures() API call returns the ResultMeasureObject, which is different from the MeasureObject that you set in the slice. Since there is no name property in the MeasureObject, we recommend setting the caption property instead of name. You are welcome to check the following JSFiddle for reference: https://jsfiddle.net/flexmonster/yx9c46f0/

Please let us know if it works for you. Looking forward to hearing from you.

Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster May 7, 2024

Hello Yegor!

Hope you are doing well.

We were wondering if you had a chance to check the suggested solution. Could you please confirm if it works for you?

Looking forward to hearing your feedback.

Kind regards,
Nadia

Public
Yegor May 8, 2024

Hello Nadia,

Thank you very much for your response. So in the end, using the name property was not the correct way to set the labels using the highcharts.getData() method, and the correct way is to use a caption property instead. Okay, I got it, I'll address this in our code.

Thanks again for your help.

Best regards, Yegor.

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster May 9, 2024

Hello Yegor,

Thank you for the feedback!

As always, do not hesitate to contact us if any questions arise.

Kind regards,
Nadia

Please login or Register to Submit Answer