To begin with here is a code extract in angular 7+ using Highcharts API:
export class TestComponent implements OnInit{
seek: boolean = false;
exampleChart;
public options = {
chart:{
zoomType: 'x',
events: {
selection: function(event){
this.seek = true;
console.log(this.seek); // outputs to true
}
}
},
xAxis:{
type:'datetime'
}
series:{
// given relevant datetime values
}
};
constructor(){}
ngOnInit{
this.exampleChart = this.options;
}
onClick(){
console.log(this.seek); // outputs false
}
}
Scenario : First i am selecting a particular portion in the graph and then clicking the button
Since the zoomtype is on x-axis, i can zoom in/out and the selection event gets fired with the correct event value. However i am also changing the value of seek in that event to be true. This change does not get reflected to the original seek , as on pressing the button and calling the onClick() function the value of seek in the console outputs to false. I do not know why it is happening like that and how to get the correct value.
selection: (event) => { this.seek = true; }