Closed bfang711 closed 6 years ago
Hi @bfang711 !
1) The use of the state
is the best practice.
in your case If you change config this.config.xAxis.crosshair = {width:3,color:'#FF9800'};
You can use update
with refs.
https://stackblitz.com/edit/react-lok-fqmzjx?file=Hello.js
If you use an update
then there is no rerendering.
2) Yes.
Awesome. This is very helpful.
is that possible that I use update to unsubscribe an event as well, since there is no removeEvent like member function?
like:
this.highchart.getChart().update({chart :{events: {click:undefined}}});
where click:
was set to another function before.
I tried this, seems not working as expected. or is there another unsubscribe member function that I missed?
Thank you so much.
@bfang711
events: {click:undefined}}
Defaults to undefined.
update
will update the value click to undefined.
To control the event, use
click: function(event){
if(event......any )
.........
}
@ilyjs Thank you. I think this is exactly the way I want to get it done.
This question is kind of general. If needed, I will provide a reproducible case.
I have 9 line plots shown together within one screen. Each plot is a component, with simple
<ReactHighcharts config={this.config}/>
inrender()
, wherethis.config
is per plot. Except for the series.data, I keep the configs the same among different plots.Now I need to add/remove xAxis.crosshair to/from all the plots. The way I am doing is that for "add", write a line of
this.config.xAxis.crosshair = {width:3,color:'#FF9800'};
for remove write a linethis.config.xAxis.crosshair=undefined;
followed by triggeringrender()
. However I need to do therender()
for all 9 plots, which make it slow to show them all out, even if users won't see the crosshair difference until they move mouse over.So my questions are.
this.config
? (I think this question is kind of general, not just for add/remove xAxis.crosshair. I kind of rendering any changes, small/big by doing like this.)thank you.