Echarts x/y axis coordinate text too long solution-line _ Chart

Source: Internet
Author: User
/** * Created by HanSon on 2016/1/24. */function newline (option, number, axis) {/* Note whether your JSON is an array or an object * * option[axis][0][' axislabel ']={interval
            : 0, Formatter:function (params) {var newparamsname = "";
            var paramsnamenumber = params.length;
            var providenumber = number;
            var rownumber = Math.ceil (Paramsnamenumber/providenumber); if (Paramsnamenumber > Providenumber) {for (var p = 0; p < RowNumber; p++) {VA
                    R tempstr = "";
                    var start = p * Providenumber;
                    var end = start + Providenumber;
                    if (p = = rowNumber-1) {tempstr = params.substring (start, paramsnamenumber);
                    else {tempstr = params.substring (start, end) + \ n;
                } Newparamsname + = TempStr;
             }} else {   Newparamsname = params;
Return to Newparamsname}} return option;
 }
# newline-echarts # # #Introduce Many people use Baidu's echarts.js time will appear the data name too long coverage of the situation, newline-echarts.js can be very good to solve this line-changing problem # # #Usage newline (option, 6, ' YAxis ') * Parameter A: Is your option * parameter two: is how many words to change the line * parameter three: is the x axis or the Y axis may the option ' yaxis ' or ' Xaxis ' var chart = echarts.init (document.getElementById ("main")
); <script src= "js/echarts.js" ></script> var option = {# your options} option = newline (option, 6, ' YAxis ') chart.setoption (option) # #Example 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.