forked from Hanson/newline-echarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newline-echarts.js
31 lines (31 loc) · 1.05 KB
/
newline-echarts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Created by HanSon on 2016/1/24.
*/
function newline(option, number, axis){
option[axis]['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++) {
var 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 newParamsName
}
}
return option;
}