echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] lengend formatter support value

Open showmethecode9527 opened this issue 3 years ago • 5 comments

What problem does this feature solve?

当前 legendformatter 只支持图例名称 name 参数,不支持 value

legend.formatter params only support name, not support value

legend.formatter

What does the proposed API look like?

// 使用字符串模板,模板变量为图例名称 {name}
formatter: 'Legend {name}: {value}'
// 使用回调函数
formatter: function (name, value) {
    return 'Legend ' + name + ':' + value;
}

showmethecode9527 avatar Feb 23 '22 08:02 showmethecode9527

@showmethecode9527 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

BODY

What problem does this feature solve?

Current 'formatter' of 'legend' only supports the legend name 'name' parameter, not 'value'

legend.formatter params only support name, not support value

legend.formatter

What does the proposed API look like?

Use a string template with the template variable as the legend name {name}
formatter: 'Legend {name}: {value}'
Use callback functions
formatter: function (name, value) {
    return 'Legend ' + name + ':' + value;
}

echarts-bot[bot] avatar Feb 23 '22 08:02 echarts-bot[bot]

同样有这样的需求,希望legend可以拿到对应行的值,类似pie.label的formatter。以实现饼图在显示区域不够宽时,可以借助通过legend代替label进行更复杂的表达。

Ling310 avatar Feb 23 '22 09:02 Ling310

would like to see this as well!

MarvinSt avatar Jun 05 '22 18:06 MarvinSt

lengend 不支持 色块 和 文字 反转位置, 不支持 按 线性样式 等其他元素标示吗?

HolleKitty avatar Jun 28 '22 09:06 HolleKitty

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] avatar Jun 27 '24 21:06 github-actions[bot]

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!

github-actions[bot] avatar Jul 04 '24 21:07 github-actions[bot]