I'm using Plotly to display an histogram with an hovertemplate displaying the value from the group. I need to display a precision to 3 digit, even when the data are big, however Plotly seems to round the value before that so with below example, hovertempalte jump from "28200.000 - 28500.000" to "28600.00 - 28800.00" and value 28589.02 is absorb by the second bar whereas it's below the min from the range.
Is there any option to change that precision on the %{x} value ? I tryed to use hoverformat: .3f but it only add 0 to the end so it doesn't fix.
You can find the example here: https://stackblitz.com/edit/typescript-plotly-hfluqw?file=index.ts
const appDiv: HTMLElement = document.getElementById('app');
appDiv.innerHTML = `<div style="width: 100%; height: 100%" id="chart"></div>`;
import { newPlot } from 'plotly.js-dist';
const data = [
{
type: 'histogram',
marker: { color: 'red' },
mode: 'lines+markers',
x: [25000, 28333.952, 28334.08, 28589.02, 28945.89],
xbins: {
start: 25000,
end: 29340.479,
size: 394.589,
},
hovertemplate: 'value: %{x}',
},
];
const layout = {
bargap: 0.1,
hovermode: 'closest',
xaxis: {
hoverformat: ',.3f',
},
};
newPlot('chart', data, layout);
from precision in Plotly histogram value %{x}
No comments:
Post a Comment