lovelace-plotly-graph-card icon indicating copy to clipboard operation
lovelace-plotly-graph-card copied to clipboard

Thousands separator inconsistent

Open JvdMaat opened this issue 3 years ago • 1 comments

I have a graph that has 4 digit numbers that are sometimes whole and sometimes have a decimal. When hovering over the numbers, if it's a fraction, it will have a comma for the thousands separator, when it's a whole number, there is no separator: 5236 6,241.5 Verified the data in Home Assistant History, and it consistently adds the thousands comma separator.

JvdMaat avatar May 02 '22 17:05 JvdMaat

D3 decides how to present numbers but you can override everything. Via a hover template: https://plotly.com/javascript/hover-text-and-formatting/#hovertemplate

Let me know is you succeed :)

One extra caveat is that numbers are represented as strings (in case you are plotting categorical values). This may affect how they are shown. To force them to be numbers, you can add:

entities:
   - entity: sensor.mysensor
     lambda: ys => ys.map(y => +y)

dbuezas avatar May 02 '22 21:05 dbuezas