My current timezone setup is done manually using the timezoneOffset
function from the Highcharts API. I am currently in GMT+2 so I set it to -2 * 60. However, I encountered an issue where my setup would not work properly when the hour changes in October. To solve this problem, I have decided to take either my browser or server time instead of the manual setup. I am aware that I can use the getTimezoneOffset: Function from the Highcharts API. The challenge I am facing is that I am working with TypeScript and Angular 4. Can anyone suggest an elegant solution for this? Thanks in advance.
Below is my current working code using timezoneOffset:
constructor(public userService3: UserService3) {
const Highcharts = require('highcharts');
Highcharts.setOptions({
global: {
timezoneOffset: -2 * 60
}
});
this.options = {
title : { text : '' },
chart: { type: 'area'},
legend: { enabled: false },
credits: { enabled: false },
xAxis: { type: 'datetime',
startOnTick: false,
endOnTick: false,
tickInterval: 36e5 * 2, // two hours
},
yAxis: { min: 0,
max: 100 },
plotOptions: {
series: {
color: '#648e59',
fillOpacity: 0.8,
fillColor: '#648e59',
pointInterval: 36e5 * 2 // two hours
}
},
series: [{
name: 'Someone1',
data: [],
}]
};
}
saveInstance(chartInstance) {
this.chart = chartInstance;
console.log(chartInstance);
}
public ngOnInit () {
this.dataSubscription = this.userService3.getData().subscribe((data)
=> {
this.options.series[0].data = data.data.operating_details;
console.log(data);
});
}
ngOnDestroy() {
if (this.dataSubscription){
this.dataSubscription.unsubscribe();
}
}
Here's my HTML:
<chart [options]="options" (load)="saveInstance($event.context)">
</chart>