Skip to content
Advertisement

How to display the Apex Charts datapoint’s datetime value in tooltip?

I’m having trouble getting the datapoint’s corresponding x-axis value which is datetime, to display in the tooltip of the datapoint. Specifically, where within the w.globals object.

var chartOptions = {
...
xaxis: { type: "datetime" },
tooltip: {
    x: { format: "dd MMM yyyy" },
    y: {
        formatter: (value, { series, seriesIndex, dataPointIndex, w })=> {
            return '<div>'+'Value: ' + value + '</div>' +
                   '<div>'+'Timestamp: ' + ?? + '</div>'
    }
 }
...
}

I’m following along the lines of this answer, unsuccessful so far. Seems it works only on the categorical data as demonstrated here.

Advertisement

Answer

The w.globals.seriesX array contains the X values for DateTime series.

const timestamp = w.globals.seriesX[seriesIndex][dataPointIndex]
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement