echarts [Feature] Can I have the legend formatter accept react component instead of just string?

s4n0splo  于 5个月前  发布在  Echarts
关注(0)|答案(3)|浏览(50)

What problem does this feature solve?

We would love to customise on legend as a react component, so that we can apply some customer styling on each different section of the name in legend.

What does the proposed API look like?

Something like

{
   legend: {formatter: (value) => <div>value</div>}
}
qf9go6mv

qf9go6mv1#

Unlike the tooltip component, the legend component doesn't support rendering via HTML elements.

cgh8pdjw

cgh8pdjw2#

Hey @plainheart
Yea. I knew that. I am just wondering. Would it be possible to have that in the future just like the tooltip is having?

evrscar2

evrscar23#

@lianfengluo Hi, I don't think this is quite possible. A better way is not to use legend of ECharts but render it using react and call setOption when user clicks the dom.

相关问题