I have 2 plotlines in highchart. When I select (for zoom & reset) some range before and after the plotline area some cases having plotlines even it's not in the selected range. So decided to remove the plotlines after validating the selected range and plotline dates . When I tried to set it back after the reset button click . It's not working.
Removing:
selection(event) {
if((fDate < mCurrentDate && tDate < mCurrentDate)||(fDate > mCurrentDate && tDate > mCurrentDate)){
this.xAxis[0].removePlotLine('mCurrentDate');
}
if((pDate < mCurrentDate && pDate < mCurrentDate)||(pDate > mCurrentDate && pDate > mCurrentDate)){
this.xAxis[0].removePlotLine('mSaleDate');
}
}
When the reset Button is clicked I want to set the plotlines again .
render() {
id:'mCurrentDate',
value: currentDate.getTime(),
color: 'pink',
width: 4,
zIndex: 3},
{
id:'mSaleDate',
value: SaleStartedDate,
color: 'Green',
width: 4,
zIndex: 6})
So the thing is when we do a zoom I need to remove the plotlines if the plotline dates are not in the selected range and when user clicks on the reset zoom button I want to set the plotlines back.
can anyone help me to fix it.
Use update option to recreate the plot line
Here i use the
merge
oflodash
to merge current option and add your plotlines:Update : you don't absolutely need to get all your opions when you call
update
. You just need to pass an object with the changed options