I'm working with a CanvasJS spline graph. Working on the x-axis data, I want to have the x-axis label below the graph showing preset numbers while the datapoints mouseover function should show a date. In the picture below, when I hover on a data point I would like it to show a date for the x-axis label. So it should look something like (2022-09-20: 344) instead of (4: 344).
Index label shows data above every data point, I don't want that. The mouseover function canvajs has might do the trick, but their example uses alert().
dataPoints: [
{ x: 10, y: 71, mouseover: function(e){
alert( e.dataSeries.type + ", dataPoint { x:" + e.dataPoint.x + ", y: "+ e.dataPoint.y + " }" ); },
},
]
I'd like to have their original mouseover function just with different data if possible.
Currently my data points are set from a loop and look like this:
data = [
{
type: "spline",
name: Object.keys(tix_data)[0],
color: color_arr[i] // (array of colors),
showInLegend: true,
axisYIndex: axisYIndex // (this is a variable set elsewhere),
dataPoints: {"y" => someDollarAmount, "label" => i, "name" => someDate}, // etc...
}
]
Where "name" is where I want my date value to go, it just doesn't work as I want it to.
My chart function is currently set up like this:
const chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Market price from days to event"
},
axisY: [{
title: "Market Price",
lineColor: "#C24642",
tickColor: "#C24642",
labelFontColor: "#C24642",
titleFontColor: "#C24642",
prefix: "$"
}],
axisX: [{
title: "Days to event",
reversed: true
}],
data: data
});
I was able to figure somewhat of a solution, the details are in my comment below, but here is an image of the outcome:


You can show custom content in tooltip by setting tooltipContent & regular numbers in the axis labels. Below is an example.