Add optional Formatter function for x-value
leonard84 opened this issue · 13 comments
When using baseTime
and a time scale, the x-axis gets nicely formatted, but the tooltip still shows the raw value for the x-axis. It would be nice if it was possible to pass a formatter function, so that you could see the actual date and time.
thanks
I don't have a good solution. You may inject some CSS style into the chart with JS. This seems hacky but should work.
for example:
chart.shadowRoot.querySelector('chart-tooltip').shadowRoot.querySelector('style').innerText += `.value { min-width: 200px; max-width: 200px }`
Can't you use the domain values and the max label length to dynamically calculate the needed tooltip max-size?
For labels, it is already dynamically expanding to 100px, maybe you just need a larger max-size
?
For domain value, since the length of the formatted string may change, I don't want the size of tooltip to change constantly.
We could reduce the flatter, by only ever growing the box (up to a configurable maximum) if we see a larger value.
Yes, but that could be difficult to implement.
Could you offer configurable sizes for the tooltip then to get rid of the workaround with shadowRoot?
I think the ::part CSS pseudo-element can be used. I will look at this next weekend.
I think the ::part CSS pseudo-element can be used.
This is more difficult than I thought. ::part cannot select elements in the nested shadow root.
Maybe I should adopt a more Web Component like interface. But I would leave the interface changes to future v2.0.
I was thinking on making parts the of the style content configurable, you already create it via js in the tooltip plugin anyway, so it should be possible to use parameters for the css.