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
@@ -87,7 +87,8 @@ function computeNodeValues(nodes) {
87
87
  zrUtil.each(nodes, function (node) {
88
88
  var value1 = sum(node.outEdges, getEdgeValue);
89
89
  var value2 = sum(node.inEdges, getEdgeValue);
90
- var value = Math.max(value1, value2);
90
+ var nodeRawValue = node.getValue() || 0;
91
+ var value = Math.max(value1, value2, nodeRawValue);
91
92
  node.setLayout({value: value}, true);
92
93
  });
93
94
  }
@@ -399,7 +400,13 @@ function relaxRightToLeft(nodesByBreadth, alpha, orient) {
399
400
  zrUtil.each(nodes, function (node) {
400
401
  if (node.outEdges.length) {
401
402
  var y = sum(node.outEdges, weightedTarget, orient)
402
- / sum(node.outEdges, getEdgeValue, orient);
403
+ / sum(node.outEdges, getEdgeValue, orient);
404
+
405
+ if (isNaN(y)) {
406
+ var len = node.outEdges.length;
407
+ y = len ? sum(node.outEdges, centerTarget, orient) / len : 0;
408
+ }
409
+
403
410
  if (orient === 'vertical') {
404
411
  var nodeX = node.getLayout().x + (y - center(node, orient)) * alpha;
405
412
  node.setLayout({x: nodeX}, true);
@@ -416,10 +423,16 @@ function relaxRightToLeft(nodesByBreadth, alpha, orient) {
416
423
  function weightedTarget(edge, orient) {
417
424
  return center(edge.node2, orient) * edge.getValue();
418
425
  }
426
+ function centerTarget(edge, orient) {
427
+ return center(edge.node2, orient);
428
+ }
419
429
 
420
430
  function weightedSource(edge, orient) {
421
431
  return center(edge.node1, orient) * edge.getValue();
422
432
  }
433
+ function centerSource(edge, orient) {
434
+ return center(edge.node1, orient);
435
+ }
423
436
 
424
437
  function center(node, orient) {
425
438
  return orient === 'vertical'
@@ -431,12 +444,12 @@ function getEdgeValue(edge) {
431
444
  return edge.getValue();
432
445
  }
433
446
 
434
- function sum(array, f, orient) {
447
+ function sum(array, cb, orient) {
435
448
  var sum = 0;
436
449
  var len = array.length;
437
450
  var i = -1;
438
451
  while (++i < len) {
439
- var value = +f.call(array, array[i], orient);
452
+ var value = +cb.call(array, array[i], orient);
440
453
  if (!isNaN(value)) {
441
454
  sum += value;
442
455
  }
@@ -455,8 +468,15 @@ function relaxLeftToRight(nodesByBreadth, alpha, orient) {
455
468
  zrUtil.each(nodesByBreadth, function (nodes) {
456
469
  zrUtil.each(nodes, function (node) {
457
470
  if (node.inEdges.length) {
471
+
458
472
  var y = sum(node.inEdges, weightedSource, orient)
459
- / sum(node.inEdges, getEdgeValue, orient);
473
+ / sum(node.inEdges, getEdgeValue, orient);
474
+
475
+ if (isNaN(y)) {
476
+ var len = node.inEdges.length;
477
+ y = len ? sum(node.inEdges, centerSource, orient) / len : 0;
478
+ }
479
+
460
480
  if (orient === 'vertical') {
461
481
  var nodeX = node.getLayout().x + (y - center(node, orient)) * alpha;
462
482
  node.setLayout({x: nodeX}, true);
@@ -27,7 +27,7 @@ export default SeriesModel.extend({
27
27
  dependencies: ['grid', 'polar', 'geo', 'singleAxis', 'calendar'],
28
28
 
29
29
  getInitialData: function (option, ecModel) {
30
- return createListFromArray(this.getSource(), this);
30
+ return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
31
31
  },
32
32
 
33
33
  brushSelector: 'point',
@@ -158,6 +158,8 @@ SunburstPieceProto.updateData = function (
158
158
 
159
159
  this._seriesModel = seriesModel || this._seriesModel;
160
160
  this._ecModel = ecModel || this._ecModel;
161
+
162
+ graphic.setHoverStyle(this);
161
163
  };
162
164
 
163
165
  SunburstPieceProto.onEmphasis = function (highlightPolicy) {
@@ -105,8 +105,7 @@ export default SeriesModel.extend({
105
105
  align: 'center',
106
106
  position: 'inside',
107
107
  distance: 5,
108
- silent: true,
109
- emphasis: {}
108
+ silent: true
110
109
  },
111
110
  itemStyle: {
112
111
  borderWidth: 1,
@@ -116,13 +115,19 @@ export default SeriesModel.extend({
116
115
  shadowColor: 'rgba(0, 0, 0, 0.2)',
117
116
  shadowOffsetX: 0,
118
117
  shadowOffsetY: 0,
119
- opacity: 1,
120
- emphasis: {},
121
- highlight: {
118
+ opacity: 1
119
+ },
120
+ highlight: {
121
+ itemStyle: {
122
122
  opacity: 1
123
+ }
124
+ },
125
+ downplay: {
126
+ itemStyle: {
127
+ opacity: 0.5
123
128
  },
124
- downplay: {
125
- opacity: 0.9
129
+ label: {
130
+ opacity: 0.6
126
131
  }
127
132
  },
128
133
 
@@ -21,6 +21,7 @@ import * as zrUtil from 'zrender/src/core/util';
21
21
  import ChartView from '../../view/Chart';
22
22
  import SunburstPiece from './SunburstPiece';
23
23
  import DataDiffer from '../../data/DataDiffer';
24
+ import {windowOpen} from '../../util/format';
24
25
 
25
26
  var ROOT_TO_NODE_ACTION = 'sunburstRootToNode';
26
27
 
@@ -206,7 +207,7 @@ var SunburstView = ChartView.extend({
206
207
  if (link) {
207
208
  var linkTarget = itemModel.get('target', true)
208
209
  || '_blank';
209
- window.open(link, linkTarget);
210
+ windowOpen(link, linkTarget);
210
211
  }
211
212
  }
212
213
  targetFound = true;
@@ -24,6 +24,7 @@ import List from '../../data/List';
24
24
  import * as zrUtil from 'zrender/src/core/util';
25
25
  import {groupData} from '../../util/model';
26
26
  import {encodeHTML} from '../../util/format';
27
+ import LegendVisualProvider from '../../visual/LegendVisualProvider';
27
28
 
28
29
  var DATA_NAME_INDEX = 2;
29
30
 
@@ -49,9 +50,9 @@ var ThemeRiverSeries = SeriesModel.extend({
49
50
  // Put this function here is for the sake of consistency of code style.
50
51
  // Enable legend selection for each data item
51
52
  // Use a function instead of direct access because data reference may changed
52
- this.legendDataProvider = function () {
53
- return this.getRawData();
54
- };
53
+ this.legendVisualProvider = new LegendVisualProvider(
54
+ zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this)
55
+ );
55
56
  },
56
57
 
57
58
  /**
@@ -20,6 +20,7 @@
20
20
  import SeriesModel from '../../model/Series';
21
21
  import Tree from '../../data/Tree';
22
22
  import {encodeHTML} from '../../util/format';
23
+ import Model from '../../model/Model';
23
24
 
24
25
  export default SeriesModel.extend({
25
26
 
@@ -42,12 +43,19 @@ export default SeriesModel.extend({
42
43
  var root = {name: option.name, children: option.data};
43
44
 
44
45
  var leaves = option.leaves || {};
45
-
46
- var treeOption = {};
47
-
48
- treeOption.leaves = leaves;
49
-
50
- var tree = Tree.createTree(root, this, treeOption);
46
+ var leavesModel = new Model(leaves, this, this.ecModel);
47
+
48
+ var tree = Tree.createTree(root, this, {}, beforeLink);
49
+
50
+ function beforeLink(nodeData) {
51
+ nodeData.wrapMethod('getItemModel', function (model, idx) {
52
+ var node = tree.getNodeByDataIndex(idx);
53
+ if (!node.children.length || !node.isExpand) {
54
+ model.parentModel = leavesModel;
55
+ }
56
+ return model;
57
+ });
58
+ }
51
59
 
52
60
  var treeDepth = 0;
53
61
 
@@ -128,6 +136,11 @@ export default SeriesModel.extend({
128
136
  // the layout of the tree, two value can be selected, 'orthogonal' or 'radial'
129
137
  layout: 'orthogonal',
130
138
 
139
+ // value can be 'polyline'
140
+ edgeShape: 'curve',
141
+
142
+ edgeForkPosition: '50%',
143
+
131
144
  // true | false | 'move' | 'scale', see module:component/helper/RoamController.
132
145
  roam: false,
133
146
 
@@ -27,6 +27,60 @@ import View from '../../coord/View';
27
27
  import * as roamHelper from '../../component/helper/roamHelper';
28
28
  import RoamController from '../../component/helper/RoamController';
29
29
  import {onIrrelevantElement} from '../../component/helper/cursorHelper';
30
+ import { __DEV__ } from '../../config';
31
+ import {parsePercent} from '../../util/number';
32
+
33
+ var TreeShape = graphic.extendShape({
34
+ shape: {
35
+ parentPoint: [],
36
+ childPoints: [],
37
+ orient: '',
38
+ forkPosition: ''
39
+ },
40
+
41
+ style: {
42
+ stroke: '#000',
43
+ fill: null
44
+ },
45
+
46
+ buildPath: function (ctx, shape) {
47
+ var childPoints = shape.childPoints;
48
+ var childLen = childPoints.length;
49
+ var parentPoint = shape.parentPoint;
50
+ var firstChildPos = childPoints[0];
51
+ var lastChildPos = childPoints[childLen - 1];
52
+
53
+ if (childLen === 1) {
54
+ ctx.moveTo(parentPoint[0], parentPoint[1]);
55
+ ctx.lineTo(firstChildPos[0], firstChildPos[1]);
56
+ return;
57
+ }
58
+
59
+ var orient = shape.orient;
60
+ var forkDim = (orient === 'TB' || orient === 'BT') ? 0 : 1;
61
+ var otherDim = 1 - forkDim;
62
+ var forkPosition = parsePercent(shape.forkPosition, 1);
63
+ var tmpPoint = [];
64
+ tmpPoint[forkDim] = parentPoint[forkDim];
65
+ tmpPoint[otherDim] = parentPoint[otherDim] + (lastChildPos[otherDim] - parentPoint[otherDim]) * forkPosition;
66
+
67
+ ctx.moveTo(parentPoint[0], parentPoint[1]);
68
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
69
+ ctx.moveTo(firstChildPos[0], firstChildPos[1]);
70
+ tmpPoint[forkDim] = firstChildPos[forkDim];
71
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
72
+ tmpPoint[forkDim] = lastChildPos[forkDim];
73
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
74
+ ctx.lineTo(lastChildPos[0], lastChildPos[1]);
75
+
76
+ for (var i = 1; i < childLen - 1; i++) {
77
+ var point = childPoints[i];
78
+ ctx.moveTo(point[0], point[1]);
79
+ tmpPoint[forkDim] = point[forkDim];
80
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
81
+ }
82
+ }
83
+ });
30
84
 
31
85
  export default echarts.extendChartView({
32
86
 
@@ -87,6 +141,8 @@ export default echarts.extendChartView({
87
141
  var seriesScope = {
88
142
  expandAndCollapse: seriesModel.get('expandAndCollapse'),
89
143
  layout: layout,
144
+ edgeShape: seriesModel.get('edgeShape'),
145
+ edgeForkPosition: seriesModel.get('edgeForkPosition'),
90
146
  orient: seriesModel.getOrient(),
91
147
  curvature: seriesModel.get('lineStyle.curveness'),
92
148
  symbolRotate: seriesModel.get('symbolRotate'),
@@ -388,22 +444,72 @@ function updateNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
388
444
  });
389
445
  }
390
446
 
391
- if (node.parentNode && node.parentNode !== virtualRoot) {
392
- var edge = symbolEl.__edge;
393
- if (!edge) {
394
- edge = symbolEl.__edge = new graphic.BezierCurve({
395
- shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
396
- style: zrUtil.defaults({opacity: 0, strokeNoScale: true}, seriesScope.lineStyle)
397
- });
398
- }
447
+ drawEdge(
448
+ seriesModel, node, virtualRoot, symbolEl, sourceOldLayout,
449
+ sourceLayout, targetLayout, group, seriesScope
450
+ );
399
451
 
400
- graphic.updateProps(edge, {
401
- shape: getEdgeShape(seriesScope, sourceLayout, targetLayout),
402
- style: {opacity: 1}
403
- }, seriesModel);
452
+ }
453
+
454
+ function drawEdge(
455
+ seriesModel, node, virtualRoot, symbolEl, sourceOldLayout,
456
+ sourceLayout, targetLayout, group, seriesScope
457
+ ) {
458
+
459
+ var edgeShape = seriesScope.edgeShape;
460
+ var edge = symbolEl.__edge;
461
+ if (edgeShape === 'curve') {
462
+ if (node.parentNode && node.parentNode !== virtualRoot) {
463
+ if (!edge) {
464
+ edge = symbolEl.__edge = new graphic.BezierCurve({
465
+ shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
466
+ style: zrUtil.defaults({opacity: 0, strokeNoScale: true}, seriesScope.lineStyle)
467
+ });
468
+ }
404
469
 
405
- group.add(edge);
470
+ graphic.updateProps(edge, {
471
+ shape: getEdgeShape(seriesScope, sourceLayout, targetLayout),
472
+ style: {opacity: 1}
473
+ }, seriesModel);
474
+ }
406
475
  }
476
+ else if (edgeShape === 'polyline') {
477
+ if (seriesScope.layout === 'orthogonal') {
478
+ if (node !== virtualRoot && node.children && (node.children.length !== 0) && (node.isExpand === true)) {
479
+ var children = node.children;
480
+ var childPoints = [];
481
+ for (var i = 0; i < children.length; i++) {
482
+ var childLayout = children[i].getLayout();
483
+ childPoints.push([childLayout.x, childLayout.y]);
484
+ }
485
+
486
+ if (!edge) {
487
+ edge = symbolEl.__edge = new TreeShape({
488
+ shape: {
489
+ parentPoint: [targetLayout.x, targetLayout.y],
490
+ childPoints: [[targetLayout.x, targetLayout.y]],
491
+ orient: seriesScope.orient,
492
+ forkPosition: seriesScope.edgeForkPosition
493
+ },
494
+ style: zrUtil.defaults({opacity: 0, strokeNoScale: true}, seriesScope.lineStyle)
495
+ });
496
+ }
497
+ graphic.updateProps(edge, {
498
+ shape: {
499
+ parentPoint: [targetLayout.x, targetLayout.y],
500
+ childPoints: childPoints
501
+ },
502
+ style: {opacity: 1}
503
+ }, seriesModel);
504
+ }
505
+ }
506
+ else {
507
+ if (__DEV__) {
508
+ throw new Error('The polyline edgeShape can only be used in orthogonal layout');
509
+ }
510
+ }
511
+ }
512
+ group.add(edge);
407
513
  }
408
514
 
409
515
  function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope) {
@@ -413,6 +519,7 @@ function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
413
519
  var seriesScope = getTreeNodeStyle(node, itemModel, seriesScope);
414
520
 
415
521
  var source = node.parentNode === virtualRoot ? node : node.parentNode || node;
522
+ var edgeShape = seriesScope.edgeShape;
416
523
  var sourceLayout;
417
524
  while (sourceLayout = source.getLayout(), sourceLayout == null) {
418
525
  source = source.parentNode === virtualRoot ? source : source.parentNode || source;
@@ -427,16 +534,42 @@ function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
427
534
 
428
535
  symbolEl.fadeOut(null, {keepLabel: true});
429
536
 
430
- var edge = symbolEl.__edge;
537
+ var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
538
+ var sourceEdge = sourceSymbolEl.__edge;
539
+
540
+ // 1. when expand the sub tree, delete the children node should delete the edge of
541
+ // the source at the same time. because the polyline edge shape is only owned by the source.
542
+ // 2.when the node is the only children of the source, delete the node should delete the edge of
543
+ // the source at the same time. the same reason as above.
544
+ var edge = symbolEl.__edge
545
+ || ((source.isExpand === false || source.children.length === 1) ? sourceEdge : undefined);
546
+
547
+ var edgeShape = seriesScope.edgeShape;
548
+
431
549
  if (edge) {
432
- graphic.updateProps(edge, {
433
- shape: getEdgeShape(seriesScope, sourceLayout, sourceLayout),
434
- style: {
435
- opacity: 0
436
- }
437
- }, seriesModel, function () {
438
- group.remove(edge);
439
- });
550
+ if (edgeShape === 'curve') {
551
+ graphic.updateProps(edge, {
552
+ shape: getEdgeShape(seriesScope, sourceLayout, sourceLayout),
553
+ style: {
554
+ opacity: 0
555
+ }
556
+ }, seriesModel, function () {
557
+ group.remove(edge);
558
+ });
559
+ }
560
+ else if (edgeShape === 'polyline' && seriesScope.layout === 'orthogonal') {
561
+ graphic.updateProps(edge, {
562
+ shape: {
563
+ parentPoint: [sourceLayout.x, sourceLayout.y],
564
+ childPoints: [[sourceLayout.x, sourceLayout.y]]
565
+ },
566
+ style: {
567
+ opacity: 0
568
+ }
569
+ }, seriesModel, function () {
570
+ group.remove(edge);
571
+ });
572
+ }
440
573
  }
441
574
  }
442
575
 
@@ -183,15 +183,25 @@ export default SeriesModel.extend({
183
183
  var levels = option.levels || [];
184
184
 
185
185
  levels = option.levels = setDefault(levels, ecModel);
186
-
187
- var treeOption = {};
188
-
189
- treeOption.levels = levels;
186
+ var levelModels = zrUtil.map(levels || [], function (levelDefine) {
187
+ return new Model(levelDefine, this, ecModel);
188
+ }, this);
190
189
 
191
190
  // Make sure always a new tree is created when setOption,
192
191
  // in TreemapView, we check whether oldTree === newTree
193
192
  // to choose mappings approach among old shapes and new shapes.
194
- return Tree.createTree(root, this, treeOption).data;
193
+ var tree = Tree.createTree(root, this, null, beforeLink);
194
+
195
+ function beforeLink(nodeData) {
196
+ nodeData.wrapMethod('getItemModel', function (model, idx) {
197
+ var node = tree.getNodeByDataIndex(idx);
198
+ var levelModel = levelModels[node.depth];
199
+ levelModel && (model.parentModel = levelModel);
200
+ return model;
201
+ });
202
+ }
203
+
204
+ return tree.data;
195
205
  },
196
206
 
197
207
  optionUpdated: function () {
@@ -28,6 +28,7 @@ import BoundingRect from 'zrender/src/core/BoundingRect';
28
28
  import * as matrix from 'zrender/src/core/matrix';
29
29
  import * as animationUtil from '../../util/animation';
30
30
  import makeStyleMapper from '../../model/mixin/makeStyleMapper';
31
+ import {windowOpen} from '../../util/format';
31
32
 
32
33
  var bind = zrUtil.bind;
33
34
  var Group = graphic.Group;
@@ -187,6 +188,7 @@ export default echarts.extendChartView({
187
188
  var thisStorage = createStorage();
188
189
  var oldStorage = this._storage;
189
190
  var willInvisibleEls = [];
191
+
190
192
  var doRenderNode = zrUtil.curry(
191
193
  renderNode, seriesModel,
192
194
  thisStorage, oldStorage, reRoot,
@@ -543,7 +545,7 @@ export default echarts.extendChartView({
543
545
  var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
544
546
  var link = itemModel.get('link', true);
545
547
  var linkTarget = itemModel.get('target', true) || 'blank';
546
- link && window.open(link, linkTarget);
548
+ link && windowOpen(link, linkTarget);
547
549
  }
548
550
  }
549
551
 
@@ -685,6 +687,11 @@ function renderNode(
685
687
  // Start of closure variables available in "Procedures in renderNode".
686
688
 
687
689
  var thisLayout = thisNode.getLayout();
690
+ var data = seriesModel.getData();
691
+
692
+ // Only for enabling highlight/downplay. Clear firstly.
693
+ // Because some node will not be rendered.
694
+ data.setItemGraphicEl(thisNode.dataIndex, null);
688
695
 
689
696
  if (!thisLayout || !thisLayout.isInView) {
690
697
  return;
@@ -724,14 +731,36 @@ function renderNode(
724
731
  return group;
725
732
  }
726
733
 
734
+ var nodeModel = thisNode.getModel();
735
+
727
736
  // Background
728
737
  var bg = giveGraphic('background', Rect, depth, Z_BG);
729
- bg && renderBackground(group, bg, isParent && thisLayout.upperHeight);
738
+ bg && renderBackground(group, bg, isParent && thisLayout.upperLabelHeight);
730
739
 
731
740
  // No children, render content.
732
- if (!isParent) {
741
+ if (isParent) {
742
+ // Because of the implementation about "traverse" in graphic hover style, we
743
+ // can not set hover listener on the "group" of non-leaf node. Otherwise the
744
+ // hover event from the descendents will be listenered.
745
+ if (graphic.isHighDownDispatcher(group)) {
746
+ graphic.setAsHighDownDispatcher(group, false);
747
+ }
748
+ if (bg) {
749
+ graphic.setAsHighDownDispatcher(bg, true);
750
+ // Only for enabling highlight/downplay.
751
+ data.setItemGraphicEl(thisNode.dataIndex, bg);
752
+ }
753
+ }
754
+ else {
733
755
  var content = giveGraphic('content', Rect, depth, Z_CONTENT);
734
756
  content && renderContent(group, content);
757
+
758
+ if (bg && graphic.isHighDownDispatcher(bg)) {
759
+ graphic.setAsHighDownDispatcher(bg, false);
760
+ }
761
+ graphic.setAsHighDownDispatcher(group, true);
762
+ // Only for enabling highlight/downplay.
763
+ data.setItemGraphicEl(thisNode.dataIndex, group);
735
764
  }
736
765
 
737
766
  return group;
@@ -746,10 +775,17 @@ function renderNode(
746
775
  bg.seriesIndex = seriesModel.seriesIndex;
747
776
 
748
777
  bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
749
- var visualBorderColor = thisNode.getVisual('borderColor', true);
750
- var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
751
778
 
752
- updateStyle(bg, function () {
779
+ if (thisInvisible) {
780
+ // If invisible, do not set visual, otherwise the element will
781
+ // change immediately before animation. We think it is OK to
782
+ // remain its origin color when moving out of the view window.
783
+ processInvisible(bg);
784
+ }
785
+ else {
786
+ bg.invisible = false;
787
+ var visualBorderColor = thisNode.getVisual('borderColor', true);
788
+ var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
753
789
  var normalStyle = getItemStyleNormal(itemStyleNormalModel);
754
790
  normalStyle.fill = visualBorderColor;
755
791
  var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
@@ -769,8 +805,8 @@ function renderNode(
769
805
  }
770
806
 
771
807
  bg.setStyle(normalStyle);
772
- graphic.setHoverStyle(bg, emphasisStyle);
773
- });
808
+ graphic.setElementHoverStyle(bg, emphasisStyle);
809
+ }
774
810
 
775
811
  group.add(bg);
776
812
  }
@@ -791,8 +827,15 @@ function renderNode(
791
827
  height: contentHeight
792
828
  });
793
829
 
794
- var visualColor = thisNode.getVisual('color', true);
795
- updateStyle(content, function () {
830
+ if (thisInvisible) {
831
+ // If invisible, do not set visual, otherwise the element will
832
+ // change immediately before animation. We think it is OK to
833
+ // remain its origin color when moving out of the view window.
834
+ processInvisible(content);
835
+ }
836
+ else {
837
+ content.invisible = false;
838
+ var visualColor = thisNode.getVisual('color', true);
796
839
  var normalStyle = getItemStyleNormal(itemStyleNormalModel);
797
840
  normalStyle.fill = visualColor;
798
841
  var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
@@ -800,42 +843,20 @@ function renderNode(
800
843
  prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
801
844
 
802
845
  content.setStyle(normalStyle);
803
- graphic.setHoverStyle(content, emphasisStyle);
804
- });
846
+ graphic.setElementHoverStyle(content, emphasisStyle);
847
+ }
805
848
 
806
849
  group.add(content);
807
850
  }
808
851
 
809
- function updateStyle(element, cb) {
810
- if (!thisInvisible) {
811
- // If invisible, do not set visual, otherwise the element will
812
- // change immediately before animation. We think it is OK to
813
- // remain its origin color when moving out of the view window.
814
- cb();
815
-
816
- if (!element.__tmWillVisible) {
817
- element.invisible = false;
818
- }
819
- }
820
- else {
821
- // Delay invisible setting utill animation finished,
822
- // avoid element vanish suddenly before animation.
823
- !element.invisible && willInvisibleEls.push(element);
824
- }
852
+ function processInvisible(element) {
853
+ // Delay invisible setting utill animation finished,
854
+ // avoid element vanish suddenly before animation.
855
+ !element.invisible && willInvisibleEls.push(element);
825
856
  }
826
857
 
827
858
  function prepareText(normalStyle, emphasisStyle, visualColor, width, height, upperLabelRect) {
828
- var nodeModel = thisNode.getModel();
829
- var text = zrUtil.retrieve(
830
- seriesModel.getFormattedLabel(
831
- thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'
832
- ),
833
- nodeModel.get('name')
834
- );
835
- if (!upperLabelRect && thisLayout.isLeafRoot) {
836
- var iconChar = seriesModel.get('drillDownIcon', true);
837
- text = iconChar ? iconChar + ' ' + text : text;
838
- }
859
+ var defaultText = nodeModel.get('name');
839
860
 
840
861
  var normalLabelModel = nodeModel.getModel(
841
862
  upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
@@ -849,12 +870,18 @@ function renderNode(
849
870
  graphic.setLabelStyle(
850
871
  normalStyle, emphasisStyle, normalLabelModel, emphasisLabelModel,
851
872
  {
852
- defaultText: isShow ? text : null,
873
+ defaultText: isShow ? defaultText : null,
853
874
  autoColor: visualColor,
854
- isRectText: true
875
+ isRectText: true,
876
+ labelFetcher: seriesModel,
877
+ labelDataIndex: thisNode.dataIndex,
878
+ labelProp: upperLabelRect ? 'upperLabel' : 'label'
855
879
  }
856
880
  );
857
881
 
882
+ addDrillDownIcon(normalStyle, upperLabelRect, thisLayout);
883
+ addDrillDownIcon(emphasisStyle, upperLabelRect, thisLayout);
884
+
858
885
  upperLabelRect && (normalStyle.textRect = zrUtil.clone(upperLabelRect));
859
886
 
860
887
  normalStyle.truncate = (isShow && normalLabelModel.get('ellipsis'))
@@ -866,6 +893,14 @@ function renderNode(
866
893
  : null;
867
894
  }
868
895
 
896
+ function addDrillDownIcon(style, upperLabelRect, thisLayout) {
897
+ var text = style.text;
898
+ if (!upperLabelRect && thisLayout.isLeafRoot && text != null) {
899
+ var iconChar = seriesModel.get('drillDownIcon', true);
900
+ style.text = iconChar ? iconChar + ' ' + text : text;
901
+ }
902
+ }
903
+
869
904
  function giveGraphic(storageName, Ctor, depth, z) {
870
905
  var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
871
906
  var lasts = lastsForAnimation[storageName];
@@ -922,6 +957,7 @@ function renderNode(
922
957
  // Fade in, user can be aware that these nodes are new.
923
958
  lastCfg.fadein = storageName !== 'nodeGroup';
924
959
  }
960
+
925
961
  }
926
962
 
927
963
  // We can not set all backgroud with the same z, Because the behaviour of