akastenraj
Posts: 1
Joined: Mon Jan 10, 2022 5:52 am

tooltip x Axis this.x value not matching my series data x value on x Axis

hi.. any one help me

my data series x value not matching tooltip formatter x axis value. i have using x type on datetime one day date got it correct UTC but 1000 length long date data series not got correct x axis UTC value.

xAxis: {
gridLineWidth: 1,
type: 'datetime',
dateTimeLabelFormats: {
day: "%e. %b",
month: "%b '%y",
year: "%Y"
},
},


tooltip: {
//shared: true,
useHTML: true,
formatter: function () {
var res = fuelRes.find(ele => parseInt(ele.dt) === parseInt(this.x));
var date = `${moment(this.x).format('DD-MM-YYYY HH:MM')}`
if (res !== undefined) {
var deviceVolt = (res.deviceVolt == "-1.00") ? '0' : res.deviceVolt;
//var date = Highcharts.dateFormat('%H:%M:%S %e-%b-%y', this.x);
return '<b>' + date + '</b><br> ------------------- <br> Fuel : <b>' + res.fuelLitr + '</b> Ltrs <br>' + 'Engine : <b>' + res.primaryEngine + '</b><br>' + 'Odo : <b>' + res.odoMeterDevice + '</b> Kms<br>' + 'Speed : <b>' + res.sp + '</b> Kms/h<br>' + 'Volt : <b>' + deviceVolt + '</b> V <br>' + 'Battery : <b>' + res.mainBatteryVolt + '</b> V';
} else {
return 'sadsad';
}
},
split: true,
crosshairs: true,
},
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: tooltip x Axis this.x value not matching my series data x value on x Axis

Hello,

Welcome to our forum and thanks for contacting us with your question!

I was trying to reproduce your problem, but in my case everything is working correctly (https://jsfiddle.net/BlackLabel/re7c9yuf/).

Could you reproduce the issue in an online editor that I could work on? Because in the tooltip you are using a fuelRes variable that I don't know what it is.

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Stock”