You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by Bea starlemi <Ri...@outlook.com> on 2021/01/21 09:59:50 UTC

饼状图的label,如何设置formatter使得数据和百分比都居中?

请问饼状图的label,如何设置formatter使得数据和百分比都居中?

Label配置如下:
                label: {
                    formatter: '{b|{b}}\n{hr|}\n  {c|{c}}  {per|{d}%}  ',
                    backgroundColor: '#eee',
                    borderColor: '#aaa',
                    borderWidth: 1,
                    borderRadius: 5,
                    rich: {
                        hr: {
                            borderColor: '#aaa',
                            width: '100%',
                            borderWidth: 0.5,
                            height: 0
                        },
                        b: {
                            fontSize: 14,
                            lineHeight: 30,
                            color:'#666666',
                            padding:[0,5]
                        },
                        c:{
                            fontSize: 14,
                            lineHeight: 33,
                        },
                        per: {
                            color: '#eee',
                            backgroundColor: '#334455',
                            padding: [2, 4],
                            borderRadius: 2
                        }
                    }
                },

结果发现,数据和百分比对应的这一行,有的能居中,有的是左对齐,有的是右对齐,完全不统一,请问怎么样能够将c和per组成的这行设置为居中呢?
(ps:文档的formatter中只说了a、b、c、d以及{@xxx} {@[n] }五种情况,请问per这个模板变量是在哪里说明的呢?有没有模板变量一览表之类的)

[cid:image003.png@01D6F01E.41C56930]
    图一(居中)

[cid:image001.png@01D6F01E.030C9650]
   图二(右对齐)

[cid:image002.png@01D6F01E.21A49E50]
   图三(左对齐)



发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用