palerdot / react-d3-speedometer

React Speedometer component using d3.js ⚛️
https://palerdot.in/react-d3-speedometer/
MIT License
232 stars 58 forks source link

Allow `segmentValueFormatter` to return a DOM node #169

Closed yosi1314 closed 1 year ago

yosi1314 commented 1 year ago

Hi! Would it be possible to allow segmentValueFormatter to return an object instead of only string? For example instead of a regular text I want to return an svg or a react component. Thanks in advance!

palerdot commented 1 year ago

No. It is not possible and unlikely to be available in the future. This would lead to additional security issues if the library is not able to infer what is being injected into the code. Unless otherwise the function signature specifically mentions a DOM markup as a return value (none so far), optional injection of dom nodes will not be possible.

palerdot commented 1 year ago

This will also lead to alignment/display problems with the injected HTML messing up with current speedometer structure. To accommodate that, further changes may have to made to the library which will lead to an uncontrollable circle. For these reasons, this will not be considered.