/** * 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