I would like to perform simple calculation inside the hovertemplate.
Example:
var data = [
{
type: 'scatter',
mode: 'lines+markers',
x: [1,2,3,4,5],
y: [2.02825,1.63728,6.83839,4.8485,4.73463],
hovertemplate: '<i>Price</i>: $%{y:.2f}' +
'<br><b>X</b>: %{x/100}<br>',
showlegend: false
},
{
x: [1,2,3,4,5],
y: [3.02825,2.63728,4.83839,3.8485,1.73463],
hovertemplate: 'Price: %{y*100:$.2f}<extra></extra>',
showlegend: false
}
];
var layout = {
title: "Set hover text with hovertemplate",
};
Plotly.newPlot('myDiv', data, layout);
Modified example from: Hover text and formatting in JavaScript
In the example I tried to divide by 100 in the first dataset and multiply by 100 in the second dataset.
Any idea if I can perform such calculation?