Skip to content

Commit 43016af

Browse files
committed
tweak
1 parent c6ea88a commit 43016af

File tree

4 files changed

+225
-9
lines changed

4 files changed

+225
-9
lines changed

src/chart/map/backwardCompat.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ export default function (option) {
44
// Save geoCoord
55
var mapSeries = [];
66
zrUtil.each(option.series, function (seriesOpt) {
7-
if (seriesOpt.type === 'map') {
7+
if (seriesOpt && seriesOpt.type === 'map') {
88
mapSeries.push(seriesOpt);
9+
seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
10+
// Put x, y, width, height, x2, y2 in the top level
11+
zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
912
}
1013
});
11-
12-
zrUtil.each(mapSeries, function (seriesOpt) {
13-
seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
14-
// Put x, y, width, height, x2, y2 in the top level
15-
zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
16-
});
1714
}

src/chart/radar/backwardCompat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function (option) {
2626
option.polar = polarNotRadar;
2727
}
2828
zrUtil.each(option.series, function (seriesOpt) {
29-
if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
29+
if (seriesOpt && seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
3030
seriesOpt.radarIndex = seriesOpt.polarIndex;
3131
}
3232
});

src/coord/cartesian/Grid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import * as zrUtil from 'zrender/src/core/util';
8-
import * as BoundingRect from 'zrender/src/core/BoundingRect';
8+
import BoundingRect from 'zrender/src/core/BoundingRect';
99
import {getLayoutRect} from '../../util/layout';
1010
import * as axisHelper from '../../coord/axisHelper';
1111
import Cartesian2D from './Cartesian2D';

test/axisLabel.html

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
<!DOCTYPE>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="lib/esl.js"></script>
6+
<script src="lib/config.js"></script>
7+
<script src="lib/jquery.min.js"></script>
8+
<script src="lib/facePrint.js"></script>
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
<link rel="stylesheet" href="reset.css">
11+
</head>
12+
<body>
13+
<style>
14+
body {
15+
background: #333;
16+
}
17+
.chart {
18+
height: 400px;
19+
}
20+
</style>
21+
<div class="chart" id="main1"></div>
22+
<div class="chart" id="main2"></div>
23+
24+
25+
26+
<script>
27+
28+
require([
29+
'echarts'
30+
// 'zrender/tool/color',
31+
// 'echarts/chart/line',
32+
// 'echarts/chart/parallel',
33+
// 'echarts/component/title',
34+
// 'echarts/component/grid',
35+
// 'echarts/component/legend',
36+
// 'echarts/component/tooltip',
37+
// 'echarts/component/toolbox',
38+
// 'echarts/component/visualMap'
39+
], function (echarts) {
40+
var chart = echarts.init(document.getElementById('main1'));
41+
42+
var DECIMALS = [1];
43+
for (var i = 1; i < 15; i++) {
44+
DECIMALS.push(DECIMALS[DECIMALS.length - 1] * 10);
45+
}
46+
47+
window.yAxisLabelFormatter = (function () {
48+
var labelMap = {};
49+
50+
return function (val, index) {
51+
!index && (labelMap = {});
52+
53+
if (val < 0) {
54+
return '';
55+
}
56+
57+
var label = val >= DECIMALS[11]
58+
? fix((val / DECIMALS[12]).toFixed(val >= DECIMALS[13] ? 0 : 1)) + 'T'
59+
: val >= DECIMALS[8]
60+
? fix((val / DECIMALS[9]).toFixed(val >= DECIMALS[10] ? 0 : 1)) + 'B'
61+
: val >= DECIMALS[5]
62+
? fix((val / DECIMALS[6]).toFixed(val >= DECIMALS[7] ? 0 : 1)) + 'M'
63+
: val >= DECIMALS[3]
64+
? fix((val / DECIMALS[3]).toFixed(val >= DECIMALS[4] ? 0 : 1)) + 'K'
65+
: val;
66+
67+
return (
68+
labelMap[label]
69+
? ''
70+
: (labelMap[label] = true, label)
71+
) + '\n';
72+
73+
function fix(valStr) {
74+
return valStr.replace(/[.]0+$/, '');
75+
}
76+
};
77+
})();
78+
79+
window.smallYAxisLabel = {
80+
show: true,
81+
margin: 2,
82+
formatter: window.yAxisLabelFormatter,
83+
inside: true,
84+
textStyle: {
85+
// color: '#f7e1a9',
86+
color: 'rgba(255,255,255,0.3)',
87+
fontSize: 9,
88+
fontFamily: 'STHeiti'
89+
}
90+
};
91+
92+
93+
94+
option = {
95+
backgroundColor: '#eee',
96+
title: {
97+
text: '上两个 label 显示不出来怎么办'
98+
},
99+
grid: {
100+
backgroundColor: '#333',
101+
show: true,
102+
borderWidth: 0,
103+
height: 156,
104+
top: '15%',
105+
left: 100,
106+
right: 100
107+
},
108+
xAxis: {
109+
type: 'time'
110+
},
111+
112+
tooltip: {
113+
trigger: 'axis'
114+
},
115+
116+
yAxis: {
117+
type: 'value',
118+
scale: true,
119+
boundaryGap: ['3%', '3%'],
120+
splitNumber: 3,
121+
axisLine: {
122+
show: false
123+
},
124+
splitLine: {
125+
lineStyle: {
126+
type: 'solid',
127+
color: '#9f520e'
128+
}
129+
},
130+
axisTick: {
131+
show: false
132+
},
133+
axisLabel: window.smallYAxisLabel
134+
},
135+
easing: 'linear',
136+
series: [{
137+
name: '视频制作总数',
138+
type: 'line',
139+
lineStyle: {
140+
normal: {
141+
color: '#f9bb0b'
142+
}
143+
},
144+
showSymbol: false,
145+
data: [{"name":"980061360000","value":[980061360000,1519]},{"name":"980061420000","value":[980061420000,1526]},{"name":"980061480000","value":[980061480000,1530]},{"name":"980061540000","value":[980061540000,1531]},{"name":"980061600000","value":[980061600000,1531]},{"name":"980061660000","value":[980061660000,1532]},{"name":"980061720000","value":[980061720000,1532]},{"name":"980061780000","value":[980061780000,1533]},{"name":"980061840000","value":[980061840000,1533]},{"name":"980061900000","value":[980061900000,1537]},{"name":"980061960000","value":[980061960000,1537]},{"name":"980062020000","value":[980062020000,1539]},{"name":"980062080000","value":[980062080000,1552]},{"name":"980062140000","value":[980062140000,1552]},{"name":"980062200000","value":[980062200000,1559]},{"name":"980062260000","value":[980062260000,1561]},{"name":"980062320000","value":[980062320000,1562]},{"name":"980062380000","value":[980062380000,1562]},{"name":"980062440000","value":[980062440000,1562]},{"name":"980062500000","value":[980062500000,1563]},{"name":"980062560000","value":[980062560000,1563]},{"name":"980062620000","value":[980062620000,1565]},{"name":"980062680000","value":[980062680000,1569]},{"name":"980062740000","value":[980062740000,1575]},{"name":"980062800000","value":[980062800000,1579]},{"name":"980062860000","value":[980062860000,1579]},{"name":"980062920000","value":[980062920000,1581]},{"name":"980062980000","value":[980062980000,1582]},{"name":"980063040000","value":[980063040000,1585]},{"name":"980063100000","value":[980063100000,1589]},{"name":"980063160000","value":[980063160000,1590]},{"name":"980063220000","value":[980063220000,1590]},{"name":"980063280000","value":[980063280000,1591]},{"name":"980063340000","value":[980063340000,1591]},{"name":"980063400000","value":[980063400000,1592]},{"name":"980063460000","value":[980063460000,1592]},{"name":"980063520000","value":[980063520000,1593]},{"name":"980063580000","value":[980063580000,1605]},{"name":"980063640000","value":[980063640000,1609]},{"name":"980063700000","value":[980063700000,1612]},{"name":"980063760000","value":[980063760000,1614]},{"name":"980063820000","value":[980063820000,1614]},{"name":"980063880000","value":[980063880000,1617]},{"name":"980063940000","value":[980063940000,1617]},{"name":"980064000000","value":[980064000000,1619]},{"name":"980064060000","value":[980064060000,1622]},{"name":"980064120000","value":[980064120000,1622]},{"name":"980064180000","value":[980064180000,1624]},{"name":"980064240000","value":[980064240000,1627]},{"name":"980064300000","value":[980064300000,1640]},{"name":"980064360000","value":[980064360000,1642]},{"name":"980064420000","value":[980064420000,1642]},{"name":"980064480000","value":[980064480000,1643]},{"name":"980064540000","value":[980064540000,1644]},{"name":"980064600000","value":[980064600000,1644]},{"name":"980064660000","value":[980064660000,1647]},{"name":"980064720000","value":[980064720000,1647]},{"name":"980064780000","value":[980064780000,1648]},{"name":"980064840000","value":[980064840000,1648]},{"name":"980064900000","value":[980064900000,1648]}]
146+
}]
147+
};
148+
149+
chart.setOption(option);
150+
});
151+
152+
</script>
153+
154+
155+
156+
157+
158+
159+
<script>
160+
161+
require([
162+
'echarts'
163+
], function (echarts) {
164+
var chart = echarts.init(document.getElementById('main2'));
165+
var rotate = 30;
166+
167+
option = {
168+
backgroundColor: '#eee',
169+
title: {
170+
text: 'grid.containLabel'
171+
},
172+
grid: {
173+
containLabel: true,
174+
left: 0
175+
},
176+
tooltip: {
177+
trigger: 'axis'
178+
},
179+
xAxis: {
180+
data: ['a', 'b', 'c', 'd', 'e']
181+
},
182+
yAxis: {
183+
axisLabel: {
184+
rotate: rotate
185+
}
186+
},
187+
series: [{
188+
type: 'line',
189+
data: [
190+
1111111111111,
191+
2222222222222,
192+
3333333333333,
193+
4444444444444,
194+
5555555555555,
195+
6666666666666
196+
]
197+
}]
198+
};
199+
200+
chart.setOption(option);
201+
202+
setInterval(function () {
203+
rotate = (rotate + 1) % 360;
204+
205+
chart.setOption({
206+
yAxis: {
207+
axisLabel: {
208+
rotate: rotate
209+
}
210+
}
211+
});
212+
}, 100);
213+
});
214+
215+
</script>
216+
217+
218+
</body>
219+
</html>

0 commit comments

Comments
 (0)