I am currently using the React JSX Highcharts module to create a chart which exhibits several spline series dynamically (using .map function)
I have a global var called DataLines, in my render function I Wrote this:
{DataLines.map(Line,index)=>
<SplineSeries key={index} id={Line.id} name={Line.name} data={Line.points}/>}
when Datalines holds two lines, the chart displays it correctly. However, when I remove the first line from DataLines, it removes the second line instead from the chart (shown by the line names at the bottom of the chart), and the chart itself doesn't actually change, even though we re-rendered it using the new DataLines.
Furthermore, if I have a single line in my chart, and I change the DataLines to hold a different single line instead, it doesn't update the chart at all.
Using console log I see that the data sent into the render function is correct.
What can cause this, and how can I fix it? Is it a known issue with the module?
Thanks in advance!
EDIT : My Server is working on signalr in c# so it will be a bit more complecatied to share that but here is the event that triggers the update of the chart:
createDataLines(lines){
lines.foreach(l=>{
lNewLine={
name:l.name,
id:l.id,
points:l.points,
}
l.points.foreach(p=>{
point={
x:p.time,
y:p.height,
}
lNewLine.points.push(point)
})
this.state.DataLines.push(lNewLine);
});
}
- The function is called from componentDidUpdate and the lines are recieved as props using set state from the parent component. So basically when I Recieve new props I create the graph with new data (and then we are back to the problem where the graph doesnt update properly).