highcharts / highcharts-react

The official Highcharts supported wrapper for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong Gantt Behaviour On Having Multiple Ids in Series Data.

rolandvincze opened this issue · comments

Description

In the provided example, we implemented a gantt chart where initially the series data was rendered correctly even though some ids were duplicate.

Steps to reproduce

Observe how all the gantt bars are rendered initially.
Trigger a re-render on the component (by clicking on any of the gantt in our case).
Note that the series that have duplicate ids render only the last set of data example.

Expected Behavior

When triggering a re-render, the component should either re-render the series correctly (consistent behaviour)
or give an error from the start that the user has data with duplicate ids in his/her series.

Actual Behavior

When re-rendering the chart, only the data of the last are re-rendered.

Relevant Screenshots

before
image

after
image

Hello rolandvincze,

Thanks for contacting us and bringing up this problem!

By default, Highcharts creates a reference to the provided data, not a direct copy, so data points seem overridden during the rerenders after the initial one. Nevertheless, I wouldn't classify it as a bug since by definition id should be a unique value that Highcharts handles as expected. I'd also expect a warning message in the console indicating that using the repeated IDs may lead to some unexpected behaviors. Since the change should be made to the Highcharts core code, feel free to report it here.

What you can do is change the Highcharts's initial data mutation by using the chart.allowMutatingData property set to false to create a direct copy of the provided data. Please refer to your updated example and the API reference.

Kind Regards!

Hi @KamilKubik,

Thank you for the answer! I would have another question regarding this, does this change come with any other side effect besides possible performance issues? (I'm interested in side-effects functionality-wise mainly).

Kind Regards!

From the Highcharts perspective, the mentioned copy is created based on your initial data only. Since this functionality refers to the data directly, I assume the only side effects you can potentially face are related to updating the data. Nevertheless, you shouldn't encounter any apart from the possible performance issues. What I'd potentially expect is the rerendering issues related to React. But I'd be concerned about this only when you face it (your case is a bit specific, and I haven't found any related threads) - feel free to share your code in that scenario.

Regards!