echarts 4.5.0-rc.2 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/.github/pull_request_template.md +66 -0
  2. package/.github/workflows/nodejs.yml +12 -2
  3. package/CONTRIBUTING.md +16 -160
  4. package/NOTICE +1 -1
  5. package/README.md +2 -2
  6. package/dist/echarts-en.common.js +2808 -1188
  7. package/dist/echarts-en.common.min.js +1 -1
  8. package/dist/echarts-en.js +3559 -1437
  9. package/dist/echarts-en.js.map +1 -1
  10. package/dist/echarts-en.min.js +1 -1
  11. package/dist/echarts-en.simple.js +2453 -1002
  12. package/dist/echarts-en.simple.min.js +1 -1
  13. package/dist/echarts.common.js +2782 -1188
  14. package/dist/echarts.common.min.js +1 -1
  15. package/dist/echarts.js +3533 -1437
  16. package/dist/echarts.js.map +1 -1
  17. package/dist/echarts.min.js +1 -1
  18. package/dist/echarts.simple.js +2427 -1002
  19. package/dist/echarts.simple.min.js +1 -1
  20. package/dist/extension/bmap.js +336 -2
  21. package/dist/extension/bmap.js.map +1 -1
  22. package/dist/extension/bmap.min.js +1 -1
  23. package/extension/bmap/BMapView.js +6 -2
  24. package/extension-src/bmap/BMapView.js +3 -2
  25. package/lib/chart/bar/BarSeries.js +14 -1
  26. package/lib/chart/bar/BarView.js +161 -16
  27. package/lib/chart/bar/BaseBarSeries.js +3 -1
  28. package/lib/chart/candlestick/candlestickVisual.js +1 -1
  29. package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
  30. package/lib/chart/funnel/FunnelSeries.js +13 -5
  31. package/lib/chart/gauge/GaugeSeries.js +0 -2
  32. package/lib/chart/graph/GraphSeries.js +11 -5
  33. package/lib/chart/graph/GraphView.js +30 -12
  34. package/lib/chart/heatmap/HeatmapView.js +4 -4
  35. package/lib/chart/helper/EffectLine.js +23 -1
  36. package/lib/chart/helper/EffectSymbol.js +2 -1
  37. package/lib/chart/helper/Line.js +94 -33
  38. package/lib/chart/helper/LineDraw.js +5 -1
  39. package/lib/chart/helper/Symbol.js +1 -2
  40. package/lib/chart/helper/createClipPathFromCoordSys.js +4 -1
  41. package/lib/chart/helper/createListFromArray.js +14 -8
  42. package/lib/chart/helper/createRenderPlanner.js +6 -3
  43. package/lib/chart/helper/whiskerBoxCommon.js +22 -16
  44. package/lib/chart/line/LineSeries.js +3 -1
  45. package/lib/chart/line/LineView.js +41 -2
  46. package/lib/chart/map/MapSeries.js +11 -3
  47. package/lib/chart/pie/PieSeries.js +27 -6
  48. package/lib/chart/pie/PieView.js +22 -15
  49. package/lib/chart/pie/labelLayout.js +102 -19
  50. package/lib/chart/pie/pieLayout.js +19 -7
  51. package/lib/chart/radar/RadarSeries.js +23 -3
  52. package/lib/chart/sankey/SankeySeries.js +13 -1
  53. package/lib/chart/sankey/SankeyView.js +70 -32
  54. package/lib/chart/sankey/sankeyLayout.js +22 -3
  55. package/lib/chart/scatter/ScatterSeries.js +3 -1
  56. package/lib/chart/sunburst/SunburstPiece.js +1 -0
  57. package/lib/chart/sunburst/SunburstSeries.js +12 -7
  58. package/lib/chart/sunburst/SunburstView.js +5 -1
  59. package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
  60. package/lib/chart/tree/TreeSeries.js +20 -3
  61. package/lib/chart/tree/TreeView.js +151 -25
  62. package/lib/chart/treemap/TreemapSeries.js +15 -3
  63. package/lib/chart/treemap/TreemapView.js +80 -38
  64. package/lib/component/axis/AngleAxisView.js +64 -7
  65. package/lib/component/axis/AxisBuilder.js +62 -24
  66. package/lib/component/axis/CartesianAxisView.js +52 -85
  67. package/lib/component/axis/RadiusAxisView.js +36 -4
  68. package/lib/component/axis/SingleAxisView.js +21 -6
  69. package/lib/component/axis/axisSplitHelper.js +132 -0
  70. package/lib/component/brush/BrushView.js +11 -1
  71. package/lib/component/brush/visualEncoding.js +13 -2
  72. package/lib/component/dataZoom/SliderZoomView.js +4 -10
  73. package/lib/component/helper/BrushController.js +33 -43
  74. package/lib/component/helper/MapDraw.js +30 -4
  75. package/lib/component/legend/LegendModel.js +3 -3
  76. package/lib/component/legend/LegendView.js +17 -13
  77. package/lib/component/legend/ScrollableLegendView.js +18 -18
  78. package/lib/component/marker/MarkLineModel.js +2 -1
  79. package/lib/component/marker/markerHelper.js +7 -4
  80. package/lib/component/title.js +6 -2
  81. package/lib/component/toolbox/ToolboxView.js +5 -1
  82. package/lib/component/toolbox/feature/MagicType.js +20 -14
  83. package/lib/component/toolbox/feature/SaveAsImage.js +2 -1
  84. package/lib/component/tooltip/TooltipContent.js +60 -23
  85. package/lib/component/tooltip/TooltipView.js +7 -8
  86. package/lib/component/visualMap/PiecewiseModel.js +3 -6
  87. package/lib/coord/Axis.js +30 -2
  88. package/lib/coord/View.js +9 -0
  89. package/lib/coord/axisDefault.js +21 -2
  90. package/lib/coord/axisHelper.js +22 -16
  91. package/lib/coord/calendar/Calendar.js +8 -4
  92. package/lib/coord/geo/geoJSONLoader.js +3 -2
  93. package/lib/coord/geo/geoSourceManager.js +3 -2
  94. package/lib/coord/geo/parseGeoJson.js +3 -2
  95. package/lib/coord/radar/Radar.js +5 -5
  96. package/lib/data/DataDimensionInfo.js +157 -0
  97. package/lib/data/List.js +25 -19
  98. package/lib/data/Tree.js +9 -19
  99. package/lib/data/helper/completeDimensions.js +43 -32
  100. package/lib/data/helper/createDimensions.js +2 -0
  101. package/lib/data/helper/sourceHelper.js +214 -114
  102. package/lib/echarts.js +57 -34
  103. package/lib/langEN.js +26 -0
  104. package/lib/layout/barGrid.js +19 -13
  105. package/lib/layout/barPolar.js +0 -5
  106. package/lib/loading/default.js +43 -27
  107. package/lib/model/Series.js +4 -4
  108. package/lib/model/referHelper.js +40 -12
  109. package/lib/scale/Interval.js +87 -2
  110. package/lib/scale/Log.js +9 -2
  111. package/lib/scale/helper.js +1 -43
  112. package/lib/stream/Scheduler.js +9 -1
  113. package/lib/theme/dark.js +3 -0
  114. package/lib/util/format.js +19 -2
  115. package/lib/util/graphic.js +14 -12
  116. package/lib/visual/LegendVisualProvider.js +75 -0
  117. package/lib/visual/dataColor.js +2 -12
  118. package/lib/visual/seriesColor.js +15 -7
  119. package/lib/visual/symbol.js +12 -2
  120. package/map/js/china.js +1 -1
  121. package/map/js/province/chongqing.js +1 -1
  122. package/map/js/province/gansu.js +2 -2
  123. package/map/js/province/tianjin.js +1 -28
  124. package/map/json/china.json +1 -1
  125. package/map/json/province/chongqing.json +1 -1
  126. package/map/json/province/tianjin.json +1 -1
  127. package/package.json +11 -6
  128. package/src/chart/bar/BarSeries.js +15 -1
  129. package/src/chart/bar/BarView.js +162 -15
  130. package/src/chart/bar/BaseBarSeries.js +1 -1
  131. package/src/chart/candlestick/candlestickVisual.js +1 -1
  132. package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
  133. package/src/chart/funnel/FunnelSeries.js +10 -4
  134. package/src/chart/gauge/GaugeSeries.js +0 -1
  135. package/src/chart/graph/GraphSeries.js +10 -4
  136. package/src/chart/graph/GraphView.js +28 -10
  137. package/src/chart/heatmap/HeatmapView.js +4 -4
  138. package/src/chart/helper/EffectLine.js +23 -1
  139. package/src/chart/helper/EffectSymbol.js +2 -1
  140. package/src/chart/helper/Line.js +84 -26
  141. package/src/chart/helper/LineDraw.js +5 -1
  142. package/src/chart/helper/Symbol.js +2 -2
  143. package/src/chart/helper/createClipPathFromCoordSys.js +4 -0
  144. package/src/chart/helper/createListFromArray.js +13 -8
  145. package/src/chart/helper/createRenderPlanner.js +5 -2
  146. package/src/chart/helper/whiskerBoxCommon.js +21 -16
  147. package/src/chart/line/LineSeries.js +1 -1
  148. package/src/chart/line/LineView.js +45 -1
  149. package/src/chart/map/MapSeries.js +8 -3
  150. package/src/chart/pie/PieSeries.js +26 -5
  151. package/src/chart/pie/PieView.js +20 -15
  152. package/src/chart/pie/labelLayout.js +114 -22
  153. package/src/chart/pie/pieLayout.js +20 -7
  154. package/src/chart/radar/RadarSeries.js +27 -3
  155. package/src/chart/sankey/SankeySeries.js +12 -1
  156. package/src/chart/sankey/SankeyView.js +75 -30
  157. package/src/chart/sankey/sankeyLayout.js +25 -5
  158. package/src/chart/scatter/ScatterSeries.js +1 -1
  159. package/src/chart/sunburst/SunburstPiece.js +2 -0
  160. package/src/chart/sunburst/SunburstSeries.js +12 -7
  161. package/src/chart/sunburst/SunburstView.js +2 -1
  162. package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
  163. package/src/chart/tree/TreeSeries.js +19 -6
  164. package/src/chart/tree/TreeView.js +155 -22
  165. package/src/chart/treemap/TreemapSeries.js +15 -5
  166. package/src/chart/treemap/TreemapView.js +77 -41
  167. package/src/component/axis/AngleAxisView.js +75 -7
  168. package/src/component/axis/AxisBuilder.js +77 -32
  169. package/src/component/axis/CartesianAxisView.js +47 -83
  170. package/src/component/axis/RadiusAxisView.js +37 -4
  171. package/src/component/axis/SingleAxisView.js +21 -4
  172. package/src/component/axis/axisSplitHelper.js +114 -0
  173. package/src/component/brush/BrushView.js +8 -1
  174. package/src/component/brush/visualEncoding.js +6 -3
  175. package/src/component/dataZoom/SliderZoomView.js +4 -9
  176. package/src/component/helper/BrushController.js +40 -47
  177. package/src/component/helper/MapDraw.js +27 -4
  178. package/src/component/legend/LegendModel.js +3 -3
  179. package/src/component/legend/LegendView.js +18 -12
  180. package/src/component/legend/ScrollableLegendView.js +18 -16
  181. package/src/component/marker/MarkLineModel.js +2 -1
  182. package/src/component/marker/markerHelper.js +8 -5
  183. package/src/component/title.js +3 -2
  184. package/src/component/toolbox/ToolboxView.js +5 -0
  185. package/src/component/toolbox/feature/MagicType.js +19 -13
  186. package/src/component/toolbox/feature/SaveAsImage.js +2 -1
  187. package/src/component/tooltip/TooltipContent.js +59 -22
  188. package/src/component/tooltip/TooltipView.js +10 -8
  189. package/src/component/visualMap/PiecewiseModel.js +5 -9
  190. package/src/coord/Axis.js +29 -2
  191. package/src/coord/View.js +10 -1
  192. package/src/coord/axisDefault.js +25 -1
  193. package/src/coord/axisHelper.js +26 -19
  194. package/src/coord/calendar/Calendar.js +12 -5
  195. package/src/coord/geo/geoJSONLoader.js +3 -2
  196. package/src/coord/geo/geoSourceManager.js +3 -2
  197. package/src/coord/geo/parseGeoJson.js +3 -2
  198. package/src/coord/radar/Radar.js +6 -8
  199. package/src/data/DataDimensionInfo.js +135 -0
  200. package/src/data/List.js +29 -16
  201. package/src/data/Tree.js +12 -17
  202. package/src/data/helper/completeDimensions.js +49 -30
  203. package/src/data/helper/createDimensions.js +2 -0
  204. package/src/data/helper/sourceHelper.js +216 -124
  205. package/src/echarts.js +60 -36
  206. package/src/langEN.js +26 -0
  207. package/src/layout/barGrid.js +22 -10
  208. package/src/layout/barPolar.js +0 -4
  209. package/src/loading/default.js +46 -34
  210. package/src/model/Series.js +4 -4
  211. package/src/model/referHelper.js +34 -11
  212. package/src/scale/Interval.js +84 -4
  213. package/src/scale/Log.js +9 -2
  214. package/src/scale/helper.js +1 -39
  215. package/src/stream/Scheduler.js +8 -0
  216. package/src/theme/dark.js +3 -0
  217. package/src/util/format.js +17 -1
  218. package/src/util/graphic.js +13 -11
  219. package/src/visual/LegendVisualProvider.js +55 -0
  220. package/src/visual/dataColor.js +0 -13
  221. package/src/visual/seriesColor.js +13 -7
  222. package/src/visual/symbol.js +11 -2
  223. package/theme/azul.js +163 -0
  224. package/theme/bee-inspired.js +178 -0
  225. package/theme/blue.js +178 -0
  226. package/theme/caravan.js +178 -0
  227. package/theme/carp.js +163 -0
  228. package/theme/cool.js +180 -0
  229. package/theme/dark-blue.js +168 -0
  230. package/theme/dark-bold.js +168 -0
  231. package/theme/dark-digerati.js +168 -0
  232. package/theme/dark-fresh-cut.js +168 -0
  233. package/theme/dark-mushroom.js +168 -0
  234. package/theme/dark.js +69 -62
  235. package/theme/eduardo.js +178 -0
  236. package/theme/forest.js +163 -0
  237. package/theme/fresh-cut.js +163 -0
  238. package/theme/fruit.js +178 -0
  239. package/theme/gray.js +220 -0
  240. package/theme/green.js +222 -0
  241. package/theme/helianthus.js +263 -0
  242. package/theme/infographic.js +72 -57
  243. package/theme/inspired.js +163 -0
  244. package/theme/jazz.js +163 -0
  245. package/theme/london.js +163 -0
  246. package/theme/macarons.js +80 -57
  247. package/theme/macarons2.js +251 -0
  248. package/theme/mint.js +155 -0
  249. package/theme/red-velvet.js +163 -0
  250. package/theme/red.js +225 -0
  251. package/theme/roma.js +55 -22
  252. package/theme/royal.js +163 -0
  253. package/theme/sakura.js +140 -0
  254. package/theme/shine.js +52 -45
  255. package/theme/tech-blue.js +180 -0
  256. package/theme/vintage.js +37 -23
@@ -20,16 +20,21 @@
20
20
  // FIXME emphasis label position is not same with normal label position
21
21
 
22
22
  import * as textContain from 'zrender/src/contain/text';
23
+ import {parsePercent} from '../../util/number';
23
24
 
24
25
  var RADIAN = Math.PI / 180;
25
26
 
26
- function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
27
+ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
27
28
  list.sort(function (a, b) {
28
29
  return a.y - b.y;
29
30
  });
30
31
 
31
32
  function shiftDown(start, end, delta, dir) {
32
33
  for (var j = start; j < end; j++) {
34
+ if (list[j].y + delta > viewTop + viewHeight) {
35
+ break;
36
+ }
37
+
33
38
  list[j].y += delta;
34
39
  if (j > start
35
40
  && j + 1 < end
@@ -45,6 +50,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
45
50
 
46
51
  function shiftUp(end, delta) {
47
52
  for (var j = end; j >= 0; j--) {
53
+ if (list[j].y - delta < viewTop) {
54
+ break;
55
+ }
56
+
48
57
  list[j].y -= delta;
49
58
  if (j > 0
50
59
  && list[j].y > list[j - 1].y + list[j - 1].height
@@ -64,6 +73,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
64
73
  : 0; // up
65
74
 
66
75
  for (var i = 0, l = list.length; i < l; i++) {
76
+ if (list[i].labelAlignTo !== 'none') {
77
+ continue;
78
+ }
79
+
67
80
  var deltaY = Math.abs(list[i].y - cy);
68
81
  var length = list[i].len;
69
82
  var length2 = list[i].len2;
@@ -93,6 +106,12 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
93
106
  var upList = [];
94
107
  var downList = [];
95
108
  for (var i = 0; i < len; i++) {
109
+ if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
110
+ var dx = list[i].x - farthestX;
111
+ list[i].linePoints[1][0] += dx;
112
+ list[i].x = farthestX;
113
+ }
114
+
96
115
  delta = list[i].y - lastY;
97
116
  if (delta < 0) {
98
117
  shiftDown(i, len, -delta, dir);
@@ -114,39 +133,85 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
114
133
  changeX(downList, true, cx, cy, r, dir);
115
134
  }
116
135
 
117
- function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
136
+ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
118
137
  var leftList = [];
119
138
  var rightList = [];
139
+ var leftmostX = Number.MAX_VALUE;
140
+ var rightmostX = -Number.MAX_VALUE;
120
141
  for (var i = 0; i < labelLayoutList.length; i++) {
121
142
  if (isPositionCenter(labelLayoutList[i])) {
122
143
  continue;
123
144
  }
124
145
  if (labelLayoutList[i].x < cx) {
146
+ leftmostX = Math.min(leftmostX, labelLayoutList[i].x);
125
147
  leftList.push(labelLayoutList[i]);
126
148
  }
127
149
  else {
150
+ rightmostX = Math.max(rightmostX, labelLayoutList[i].x);
128
151
  rightList.push(labelLayoutList[i]);
129
152
  }
130
153
  }
131
154
 
132
- adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
133
- adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
155
+ adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
156
+ adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
134
157
 
135
158
  for (var i = 0; i < labelLayoutList.length; i++) {
136
- if (isPositionCenter(labelLayoutList[i])) {
159
+ var layout = labelLayoutList[i];
160
+ if (isPositionCenter(layout)) {
137
161
  continue;
138
162
  }
139
- var linePoints = labelLayoutList[i].linePoints;
163
+
164
+ var linePoints = layout.linePoints;
140
165
  if (linePoints) {
166
+ var isAlignToEdge = layout.labelAlignTo === 'edge';
167
+
168
+ var realTextWidth = layout.textRect.width;
169
+ var targetTextWidth;
170
+ if (isAlignToEdge) {
171
+ if (layout.x < cx) {
172
+ targetTextWidth = linePoints[2][0] - layout.labelDistance
173
+ - viewLeft - layout.labelMargin;
174
+ }
175
+ else {
176
+ targetTextWidth = viewLeft + viewWidth - layout.labelMargin
177
+ - linePoints[2][0] - layout.labelDistance;
178
+ }
179
+ }
180
+ else {
181
+ if (layout.x < cx) {
182
+ targetTextWidth = layout.x - viewLeft - layout.bleedMargin;
183
+ }
184
+ else {
185
+ targetTextWidth = viewLeft + viewWidth - layout.x - layout.bleedMargin;
186
+ }
187
+ }
188
+ if (targetTextWidth < layout.textRect.width) {
189
+ layout.text = textContain.truncateText(layout.text, targetTextWidth, layout.font);
190
+ if (layout.labelAlignTo === 'edge') {
191
+ realTextWidth = textContain.getWidth(layout.text, layout.font);
192
+ }
193
+ }
194
+
141
195
  var dist = linePoints[1][0] - linePoints[2][0];
142
- if (labelLayoutList[i].x < cx) {
143
- linePoints[2][0] = labelLayoutList[i].x + 3;
196
+ if (isAlignToEdge) {
197
+ if (layout.x < cx) {
198
+ linePoints[2][0] = viewLeft + layout.labelMargin + realTextWidth + layout.labelDistance;
199
+ }
200
+ else {
201
+ linePoints[2][0] = viewLeft + viewWidth - layout.labelMargin
202
+ - realTextWidth - layout.labelDistance;
203
+ }
144
204
  }
145
205
  else {
146
- linePoints[2][0] = labelLayoutList[i].x - 3;
206
+ if (layout.x < cx) {
207
+ linePoints[2][0] = layout.x + layout.labelDistance;
208
+ }
209
+ else {
210
+ linePoints[2][0] = layout.x - layout.labelDistance;
211
+ }
212
+ linePoints[1][0] = linePoints[2][0] + dist;
147
213
  }
148
- linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
149
- linePoints[1][0] = linePoints[2][0] + dist;
214
+ linePoints[1][1] = linePoints[2][1] = layout.y;
150
215
  }
151
216
  }
152
217
  }
@@ -156,7 +221,7 @@ function isPositionCenter(layout) {
156
221
  return layout.position === 'center';
157
222
  }
158
223
 
159
- export default function (seriesModel, r, viewWidth, viewHeight, sum) {
224
+ export default function (seriesModel, r, viewWidth, viewHeight, viewLeft, viewTop) {
160
225
  var data = seriesModel.getData();
161
226
  var labelLayoutList = [];
162
227
  var cx;
@@ -171,10 +236,17 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
171
236
  var labelModel = itemModel.getModel('label');
172
237
  // Use position in normal or emphasis
173
238
  var labelPosition = labelModel.get('position') || itemModel.get('emphasis.label.position');
239
+ var labelDistance = labelModel.get('distanceToLabelLine');
240
+ var labelAlignTo = labelModel.get('alignTo');
241
+ var labelMargin = parsePercent(labelModel.get('margin'), viewWidth);
242
+ var bleedMargin = labelModel.get('bleedMargin');
243
+ var font = labelModel.getFont();
174
244
 
175
245
  var labelLineModel = itemModel.getModel('labelLine');
176
246
  var labelLineLen = labelLineModel.get('length');
247
+ labelLineLen = parsePercent(labelLineLen, viewWidth);
177
248
  var labelLineLen2 = labelLineModel.get('length2');
249
+ labelLineLen2 = parsePercent(labelLineLen2, viewWidth);
178
250
 
179
251
  if (layout.angle < minShowLabelRadian) {
180
252
  return;
@@ -192,6 +264,12 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
192
264
  cx = layout.cx;
193
265
  cy = layout.cy;
194
266
 
267
+ var text = seriesModel.getFormattedLabel(idx, 'normal')
268
+ || data.getName(idx);
269
+ var textRect = textContain.getBoundingRect(
270
+ text, font, textAlign, 'top'
271
+ );
272
+
195
273
  var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
196
274
  if (labelPosition === 'center') {
197
275
  textX = layout.cx;
@@ -212,14 +290,25 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
212
290
  var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
213
291
  var y3 = y2;
214
292
 
215
- textX = x3 + (dx < 0 ? -5 : 5);
293
+ if (labelAlignTo === 'edge') {
294
+ // Adjust textX because text align of edge is opposite
295
+ textX = dx < 0
296
+ ? viewLeft + labelMargin
297
+ : viewLeft + viewWidth - labelMargin;
298
+ }
299
+ else {
300
+ textX = x3 + (dx < 0 ? -labelDistance : labelDistance);
301
+ }
216
302
  textY = y3;
217
303
  linePoints = [[x1, y1], [x2, y2], [x3, y3]];
218
304
  }
219
305
 
220
- textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
306
+ textAlign = isLabelInside
307
+ ? 'center'
308
+ : (labelAlignTo === 'edge'
309
+ ? (dx > 0 ? 'right' : 'left')
310
+ : (dx > 0 ? 'left' : 'right'));
221
311
  }
222
- var font = labelModel.getFont();
223
312
 
224
313
  var labelRotate;
225
314
  var rotate = labelModel.get('rotate');
@@ -231,11 +320,7 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
231
320
  ? (dx < 0 ? -midAngle + Math.PI : -midAngle)
232
321
  : 0;
233
322
  }
234
- var text = seriesModel.getFormattedLabel(idx, 'normal')
235
- || data.getName(idx);
236
- var textRect = textContain.getBoundingRect(
237
- text, font, textAlign, 'top'
238
- );
323
+
239
324
  hasLabelRotate = !!labelRotate;
240
325
  layout.label = {
241
326
  x: textX,
@@ -248,7 +333,14 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
248
333
  textAlign: textAlign,
249
334
  verticalAlign: 'middle',
250
335
  rotation: labelRotate,
251
- inside: isLabelInside
336
+ inside: isLabelInside,
337
+ labelDistance: labelDistance,
338
+ labelAlignTo: labelAlignTo,
339
+ labelMargin: labelMargin,
340
+ bleedMargin: bleedMargin,
341
+ textRect: textRect,
342
+ text: text,
343
+ font: font
252
344
  };
253
345
 
254
346
  // Not layout the inside label
@@ -257,6 +349,6 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
257
349
  }
258
350
  });
259
351
  if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
260
- avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
352
+ avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
261
353
  }
262
354
  }
@@ -19,16 +19,27 @@
19
19
 
20
20
 
21
21
  import {parsePercent, linearMap} from '../../util/number';
22
+ import * as layout from '../../util/layout';
22
23
  import labelLayout from './labelLayout';
23
24
  import * as zrUtil from 'zrender/src/core/util';
24
25
 
25
26
  var PI2 = Math.PI * 2;
26
27
  var RADIAN = Math.PI / 180;
27
28
 
29
+ function getViewRect(seriesModel, api) {
30
+ return layout.getLayoutRect(
31
+ seriesModel.getBoxLayoutParams(), {
32
+ width: api.getWidth(),
33
+ height: api.getHeight()
34
+ }
35
+ );
36
+ }
37
+
28
38
  export default function (seriesType, ecModel, api, payload) {
29
39
  ecModel.eachSeriesByType(seriesType, function (seriesModel) {
30
40
  var data = seriesModel.getData();
31
41
  var valueDim = data.mapDimension('value');
42
+ var viewRect = getViewRect(seriesModel, api);
32
43
 
33
44
  var center = seriesModel.get('center');
34
45
  var radius = seriesModel.get('radius');
@@ -40,11 +51,11 @@ export default function (seriesType, ecModel, api, payload) {
40
51
  center = [center, center];
41
52
  }
42
53
 
43
- var width = api.getWidth();
44
- var height = api.getHeight();
54
+ var width = parsePercent(viewRect.width, api.getWidth());
55
+ var height = parsePercent(viewRect.height, api.getHeight());
45
56
  var size = Math.min(width, height);
46
- var cx = parsePercent(center[0], width);
47
- var cy = parsePercent(center[1], height);
57
+ var cx = parsePercent(center[0], width) + viewRect.x;
58
+ var cy = parsePercent(center[1], height) + viewRect.y;
48
59
  var r0 = parsePercent(radius[0], size / 2);
49
60
  var r = parsePercent(radius[1], size / 2);
50
61
 
@@ -90,7 +101,8 @@ export default function (seriesType, ecModel, api, payload) {
90
101
  r0: r0,
91
102
  r: roseType
92
103
  ? NaN
93
- : r
104
+ : r,
105
+ viewRect: viewRect
94
106
  });
95
107
  return;
96
108
  }
@@ -123,7 +135,8 @@ export default function (seriesType, ecModel, api, payload) {
123
135
  r0: r0,
124
136
  r: roseType
125
137
  ? linearMap(value, extent, [r0, r])
126
- : r
138
+ : r,
139
+ viewRect: viewRect
127
140
  });
128
141
 
129
142
  currentAngle = endAngle;
@@ -161,6 +174,6 @@ export default function (seriesType, ecModel, api, payload) {
161
174
  }
162
175
  }
163
176
 
164
- labelLayout(seriesModel, r, width, height);
177
+ labelLayout(seriesModel, r, viewRect.width, viewRect.height, viewRect.x, viewRect.y);
165
178
  });
166
179
  }
@@ -21,6 +21,7 @@ import SeriesModel from '../../model/Series';
21
21
  import createListSimply from '../helper/createListSimply';
22
22
  import * as zrUtil from 'zrender/src/core/util';
23
23
  import {encodeHTML} from '../../util/format';
24
+ import LegendVisualProvider from '../../visual/LegendVisualProvider';
24
25
 
25
26
  var RadarSeries = SeriesModel.extend({
26
27
 
@@ -35,9 +36,10 @@ var RadarSeries = SeriesModel.extend({
35
36
 
36
37
  // Enable legend selection for each data item
37
38
  // Use a function instead of direct access because data reference may changed
38
- this.legendDataProvider = function () {
39
- return this.getRawData();
40
- };
39
+ this.legendVisualProvider = new LegendVisualProvider(
40
+ zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this)
41
+ );
42
+
41
43
  },
42
44
 
43
45
  getInitialData: function (option, ecModel) {
@@ -59,6 +61,28 @@ var RadarSeries = SeriesModel.extend({
59
61
  }).join('<br />');
60
62
  },
61
63
 
64
+ /**
65
+ * @implement
66
+ */
67
+ getTooltipPosition: function (dataIndex) {
68
+ if (dataIndex != null) {
69
+ var data = this.getData();
70
+ var coordSys = this.coordinateSystem;
71
+ var values = data.getValues(
72
+ zrUtil.map(coordSys.dimensions, function (dim) {
73
+ return data.mapDimension(dim);
74
+ }), dataIndex, true
75
+ );
76
+
77
+ for (var i = 0, len = values.length; i < len; i++) {
78
+ if (!isNaN(values[i])) {
79
+ var indicatorAxes = coordSys.getIndicatorAxes();
80
+ return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
81
+ }
82
+ }
83
+ }
84
+ },
85
+
62
86
  defaultOption: {
63
87
  zlevel: 0,
64
88
  z: 2,
@@ -138,6 +138,17 @@ var SankeySeries = SeriesModel.extend({
138
138
  }
139
139
  },
140
140
 
141
+ // Override Series.getDataParams()
142
+ getDataParams: function (dataIndex, dataType) {
143
+ var params = SankeySeries.superCall(this, 'getDataParams', dataIndex, dataType);
144
+ if (params.value == null && dataType === 'node') {
145
+ var node = this.getGraph().getNodeByIndex(dataIndex);
146
+ var nodeValue = node.getLayout().value;
147
+ params.value = nodeValue;
148
+ }
149
+ return params;
150
+ },
151
+
141
152
  defaultOption: {
142
153
  zlevel: 0,
143
154
  z: 2,
@@ -198,7 +209,7 @@ var SankeySeries = SeriesModel.extend({
198
209
  show: true
199
210
  },
200
211
  lineStyle: {
201
- opacity: 0.6
212
+ opacity: 0.5
202
213
  }
203
214
  },
204
215
 
@@ -22,7 +22,9 @@ import * as echarts from '../../echarts';
22
22
  import * as zrUtil from 'zrender/src/core/util';
23
23
 
24
24
  var nodeOpacityPath = ['itemStyle', 'opacity'];
25
+ var hoverNodeOpacityPath = ['emphasis', 'itemStyle', 'opacity'];
25
26
  var lineOpacityPath = ['lineStyle', 'opacity'];
27
+ var hoverLineOpacityPath = ['emphasis', 'lineStyle', 'opacity'];
26
28
 
27
29
  function getItemOpacity(item, opacityPath) {
28
30
  return item.getVisual('opacity') || item.getModel().get(opacityPath);
@@ -30,8 +32,8 @@ function getItemOpacity(item, opacityPath) {
30
32
 
31
33
  function fadeOutItem(item, opacityPath, opacityRatio) {
32
34
  var el = item.getGraphicEl();
33
-
34
35
  var opacity = getItemOpacity(item, opacityPath);
36
+
35
37
  if (opacityRatio != null) {
36
38
  opacity == null && (opacity = 1);
37
39
  opacity *= opacityRatio;
@@ -49,12 +51,14 @@ function fadeInItem(item, opacityPath) {
49
51
  var opacity = getItemOpacity(item, opacityPath);
50
52
  var el = item.getGraphicEl();
51
53
 
52
- el.highlight && el.highlight();
53
54
  el.traverse(function (child) {
54
55
  if (child.type !== 'group') {
55
56
  child.setStyle('opacity', opacity);
56
57
  }
57
58
  });
59
+
60
+ // Support emphasis here.
61
+ el.highlight && el.highlight();
58
62
  }
59
63
 
60
64
  var SankeyShape = graphic.extendShape({
@@ -92,6 +96,14 @@ var SankeyShape = graphic.extendShape({
92
96
  );
93
97
  }
94
98
  ctx.closePath();
99
+ },
100
+
101
+ highlight: function () {
102
+ this.trigger('emphasis');
103
+ },
104
+
105
+ downplay: function () {
106
+ this.trigger('normal');
95
107
  }
96
108
  });
97
109
 
@@ -274,9 +286,21 @@ export default echarts.extendChartView({
274
286
  el.cursor = 'move';
275
287
  }
276
288
 
289
+ el.highlight = function () {
290
+ this.trigger('emphasis');
291
+ };
292
+
293
+ el.downplay = function () {
294
+ this.trigger('normal');
295
+ };
296
+
297
+ el.focusNodeAdjHandler && el.off('mouseover', el.focusNodeAdjHandler);
298
+ el.unfocusNodeAdjHandler && el.off('mouseout', el.unfocusNodeAdjHandler);
299
+
277
300
  if (itemModel.get('focusNodeAdjacency')) {
278
- el.off('mouseover').on('mouseover', function () {
301
+ el.on('mouseover', el.focusNodeAdjHandler = function () {
279
302
  if (!sankeyView._focusAdjacencyDisabled) {
303
+ sankeyView._clearTimer();
280
304
  api.dispatchAction({
281
305
  type: 'focusNodeAdjacency',
282
306
  seriesId: seriesModel.id,
@@ -284,12 +308,10 @@ export default echarts.extendChartView({
284
308
  });
285
309
  }
286
310
  });
287
- el.off('mouseout').on('mouseout', function () {
311
+
312
+ el.on('mouseout', el.unfocusNodeAdjHandler = function () {
288
313
  if (!sankeyView._focusAdjacencyDisabled) {
289
- api.dispatchAction({
290
- type: 'unfocusNodeAdjacency',
291
- seriesId: seriesModel.id
292
- });
314
+ sankeyView._dispatchUnfocus(api);
293
315
  }
294
316
  });
295
317
  }
@@ -297,9 +319,14 @@ export default echarts.extendChartView({
297
319
 
298
320
  edgeData.eachItemGraphicEl(function (el, dataIndex) {
299
321
  var edgeModel = edgeData.getItemModel(dataIndex);
322
+
323
+ el.focusNodeAdjHandler && el.off('mouseover', el.focusNodeAdjHandler);
324
+ el.unfocusNodeAdjHandler && el.off('mouseout', el.unfocusNodeAdjHandler);
325
+
300
326
  if (edgeModel.get('focusNodeAdjacency')) {
301
- el.off('mouseover').on('mouseover', function () {
327
+ el.on('mouseover', el.focusNodeAdjHandler = function () {
302
328
  if (!sankeyView._focusAdjacencyDisabled) {
329
+ sankeyView._clearTimer();
303
330
  api.dispatchAction({
304
331
  type: 'focusNodeAdjacency',
305
332
  seriesId: seriesModel.id,
@@ -307,12 +334,10 @@ export default echarts.extendChartView({
307
334
  });
308
335
  }
309
336
  });
310
- el.off('mouseout').on('mouseout', function () {
337
+
338
+ el.on('mouseout', el.unfocusNodeAdjHandler = function () {
311
339
  if (!sankeyView._focusAdjacencyDisabled) {
312
- api.dispatchAction({
313
- type: 'unfocusNodeAdjacency',
314
- seriesId: seriesModel.id
315
- });
340
+ sankeyView._dispatchUnfocus(api);
316
341
  }
317
342
  });
318
343
  }
@@ -327,10 +352,31 @@ export default echarts.extendChartView({
327
352
  this._data = seriesModel.getData();
328
353
  },
329
354
 
330
- dispose: function () {},
355
+ dispose: function () {
356
+ this._clearTimer();
357
+ },
358
+
359
+ _dispatchUnfocus: function (api) {
360
+ var self = this;
361
+ this._clearTimer();
362
+ this._unfocusDelayTimer = setTimeout(function () {
363
+ self._unfocusDelayTimer = null;
364
+ api.dispatchAction({
365
+ type: 'unfocusNodeAdjacency',
366
+ seriesId: self._model.id
367
+ });
368
+ }, 500);
369
+ },
370
+
371
+ _clearTimer: function () {
372
+ if (this._unfocusDelayTimer) {
373
+ clearTimeout(this._unfocusDelayTimer);
374
+ this._unfocusDelayTimer = null;
375
+ }
376
+ },
331
377
 
332
378
  focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
333
- var data = this._model.getData();
379
+ var data = seriesModel.getData();
334
380
  var graph = data.graph;
335
381
  var dataIndex = payload.dataIndex;
336
382
  var itemModel = data.getItemModel(dataIndex);
@@ -350,15 +396,15 @@ export default echarts.extendChartView({
350
396
  });
351
397
 
352
398
  if (node) {
353
- fadeInItem(node, nodeOpacityPath);
399
+ fadeInItem(node, hoverNodeOpacityPath);
354
400
  var focusNodeAdj = itemModel.get('focusNodeAdjacency');
355
401
  if (focusNodeAdj === 'outEdges') {
356
402
  zrUtil.each(node.outEdges, function (edge) {
357
403
  if (edge.dataIndex < 0) {
358
404
  return;
359
405
  }
360
- fadeInItem(edge, lineOpacityPath);
361
- fadeInItem(edge.node2, nodeOpacityPath);
406
+ fadeInItem(edge, hoverLineOpacityPath);
407
+ fadeInItem(edge.node2, hoverNodeOpacityPath);
362
408
  });
363
409
  }
364
410
  else if (focusNodeAdj === 'inEdges') {
@@ -366,8 +412,8 @@ export default echarts.extendChartView({
366
412
  if (edge.dataIndex < 0) {
367
413
  return;
368
414
  }
369
- fadeInItem(edge, lineOpacityPath);
370
- fadeInItem(edge.node1, nodeOpacityPath);
415
+ fadeInItem(edge, hoverLineOpacityPath);
416
+ fadeInItem(edge.node1, hoverNodeOpacityPath);
371
417
  });
372
418
  }
373
419
  else if (focusNodeAdj === 'allEdges') {
@@ -375,21 +421,21 @@ export default echarts.extendChartView({
375
421
  if (edge.dataIndex < 0) {
376
422
  return;
377
423
  }
378
- fadeInItem(edge, lineOpacityPath);
379
- fadeInItem(edge.node1, nodeOpacityPath);
380
- fadeInItem(edge.node2, nodeOpacityPath);
424
+ fadeInItem(edge, hoverLineOpacityPath);
425
+ (edge.node1 !== node) && fadeInItem(edge.node1, hoverNodeOpacityPath);
426
+ (edge.node2 !== node) && fadeInItem(edge.node2, hoverNodeOpacityPath);
381
427
  });
382
428
  }
383
429
  }
384
430
  if (edge) {
385
- fadeInItem(edge, lineOpacityPath);
386
- fadeInItem(edge.node1, nodeOpacityPath);
387
- fadeInItem(edge.node2, nodeOpacityPath);
431
+ fadeInItem(edge, hoverLineOpacityPath);
432
+ fadeInItem(edge.node1, hoverNodeOpacityPath);
433
+ fadeInItem(edge.node2, hoverNodeOpacityPath);
388
434
  }
389
435
  },
390
436
 
391
437
  unfocusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
392
- var graph = this._model.getGraph();
438
+ var graph = seriesModel.getGraph();
393
439
 
394
440
  graph.eachNode(function (node) {
395
441
  fadeOutItem(node, nodeOpacityPath);
@@ -412,8 +458,7 @@ function createGridClipShape(rect, seriesModel, cb) {
412
458
  });
413
459
  graphic.initProps(rectEl, {
414
460
  shape: {
415
- width: rect.width + 20,
416
- height: rect.height + 20
461
+ width: rect.width + 20
417
462
  }
418
463
  }, seriesModel, cb);
419
464