admin管理员组文章数量:1190325
I just use the treemap type of EChart to show the data. But I meet a problem. And the label option shows as the following: itemStyle:{ normal:{ label:{ show :true, formtter:"{b}"}
If my data name's length is too long(maybe more than 60 characters), the label doesn't show on the Treemap. The Name will show on the tooltip. Why? How can I solve this problem? Thanks !
I just use the treemap type of EChart to show the data. But I meet a problem. And the label option shows as the following: itemStyle:{ normal:{ label:{ show :true, formtter:"{b}"}
If my data name's length is too long(maybe more than 60 characters), the label doesn't show on the Treemap. The Name will show on the tooltip. Why? How can I solve this problem? Thanks !
Share Improve this question edited Aug 1, 2016 at 8:17 Sathish Prabhakaran 2613 silver badges10 bronze badges asked Aug 1, 2016 at 7:57 CallaCalla 1411 gold badge1 silver badge9 bronze badges6 Answers
Reset to default 17Try to set the grid as below,
grid: { containLabel: true },
This will adjust your chart label.
Use the extraCssText
property to set a width and force wrapping. This only works if your name
has spaces in it.
tooltip: { extraCssText: "width:200px; white-space:pre-wrap;" }
Set desired space in one or both sides of the grid:
grid: {left:"450px", right:"200px"}
Try to use \n
within the text labels.
Example:
series : [
{
name: 'pie-chart',
type: 'pie',
selectedMode: 'single',
radius: ['50%', '60%'],
data:[
{value:5, name:'Institutionelle Investoren\nRest der Welt: 5 %'},
{value:39, name:'Institutionelle Investoren\nEuropa\n(ohne\nDeutsch-\nland): 39 %'},
{value:31, name:'Institutionelle\nInvestoren\nUSA: 31 %'},
{value:17, name:'Institutionelle\nInvestoren\nDeutsch-\nland: 17 %'},
{value:8, name:'Privatanleger & nicht näher\nbekannte Investoren: 8 %'}
],
...
You can find a good example on the official doc https://echarts.apache.org/examples/en/editor.html?c=treemap-disk
I looked at the official documentation. It said 'yAxis.nameTextStyle.overflow'. https://echarts.apache.org/en/option.html#yAxis.nameTextStyle.overflow
It turned out that the nameTextStyle part had to contain a name such as 'axisLabel'.
tooltip: {
trigger: "axis",
},
yAxis: {
type: "category",
inverse: true,
data: ["very long title very long title very long title very long title very long title very long title", "very long title very long title very long title very long title very long title very long title", "very long title very long title very long title very long title very long title very long title"],
axisLabel: {
margin: 20,
width: "90",
overflow: "truncate",
},
},
result:
本文标签: javascriptLabel can39t display when ECharts label39s length is too longStack Overflow
版权声明:本文标题:javascript - Label can't display when ECharts label's length is too long - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738382984a2084042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论