Sunday, 25 April 2021

Plotly - Hide data on hover tooltip depending on value?

When I hover over a stacked line chart, it shows zeroes for all lines not in range. Is there a way to hide these values rather than adding noise to the hover tool?

Minimal Example

Plotly.newPlot('test', [{
    line: { shape : 'vh' },
    stackgroup: '1',
    x: [1, 2],
    y: [1, 1],
}, {
    line: { shape : 'vh' },
    stackgroup: '1',
    x: [3, 4],
    y: [2, 2],
}, {
    line: { shape : 'vh' },
    stackgroup: '1',
    x: [3, 4, 5, 6],
    y: [3, 3, 3, 3],
}], {
    hovermode: 'x unified',
    width: '100%',
});

As a jsfiddle and image:

Minimal example - stacked plotly graph showing legend noise

Context

I have a time-series graph stretching ~5yr containing individual lines that each span 6-12mo. Plotly pads each line with zeroes, which makes the hover tool very noisy.

Plotly hover graph

I want to hide the "0 hours" entries at each x-axis date, either by making sure Plotly doesn't 0-pad the lines or by configuring the tooltip to dynamically hide values.



from Plotly - Hide data on hover tooltip depending on value?

No comments:

Post a Comment