javascript - When there are too many characters in the legend of echarts, how to change it into an ellipsis?
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:19:29
0
3
667

I am now making an echarts pie chart, in which the legend is dynamically generated. Sometimes more than a dozen texts are sent to the background, and the style is ugly. Now I want to realize: when the text in a single legend exceeds 8 , automatically turns into an ellipsis of "..." (as shown in the picture below), please give me some advice.

过去多啦不再A梦
过去多啦不再A梦

reply all (3)
迷茫

There is a formatter under the legend configuration item

formatter: function (name) { return (name.length > 8 ? (name.slice(0,8)+"...") : name ); }
    伊谢尔伦

    Make a judgment and then use string concatenation.

    if(name.length>8){ name=name.slice(0,8)+"..." }
      phpcn_u1582

      If the annotation is not displayed on the pie chart, it can be intercepted after the data is transmitted from the background.
      Or just format it.

      formatter: function(name){ return name.length>8?name.substr(0,7)+"...":name; }
        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!