Units in chart legend

Hi,
I’m looking to display the unit of a (UoM) item in OH charts legend (“tooltip”).
I mean the box that appears when I mouse-over a chart, it’s only showing the values, not any units.
Can I define them manually ? I did not find an option for that.
I know persistence only stores values, but if so, with recent UoM improvements, the unit to display could be taken from the displayPattern/displayState, too.

2 Likes

Does anyone know how to do this ? @JustinG our master of charts maybe ? Thanks!

Hi, I am sorry to not be of more help but as far as I remember, you can have a look at the echarts documentation and then try to get that into OHs config format.

It is a lot of trial and error though…

Edit: Hmm maybe I misread your question, I guess you want it to be dynamic? Maybe with some kind of variable but thats beyond my knowledge… sorry

That’s the tooltip.

Adding a static unit to the tooltip is very easy. The valueFormatter property will take an arrow function expression:

tooltip:
  - component: oh-chart-tooltip
    config:
      show: true
      valueFormatter: =x=>`${x} UoM`

I’ve never tried to make that dynamic, so I only know that it’s possible within the limits of the expression system (i.e., you could replace UoM with a variable or item state). If you have more than one series in the tooltip and you want different units then I doubt it’s possible, but I don’t know.