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
@@ -149,6 +149,7 @@ SunburstPieceProto.updateData = function (firstCreate, node, state, seriesModel,
149
149
 
150
150
  this._seriesModel = seriesModel || this._seriesModel;
151
151
  this._ecModel = ecModel || this._ecModel;
152
+ graphic.setHoverStyle(this);
152
153
  };
153
154
 
154
155
  SunburstPieceProto.onEmphasis = function (highlightPolicy) {
@@ -113,8 +113,7 @@ var _default = SeriesModel.extend({
113
113
  align: 'center',
114
114
  position: 'inside',
115
115
  distance: 5,
116
- silent: true,
117
- emphasis: {}
116
+ silent: true
118
117
  },
119
118
  itemStyle: {
120
119
  borderWidth: 1,
@@ -124,13 +123,19 @@ var _default = SeriesModel.extend({
124
123
  shadowColor: 'rgba(0, 0, 0, 0.2)',
125
124
  shadowOffsetX: 0,
126
125
  shadowOffsetY: 0,
127
- opacity: 1,
128
- emphasis: {},
129
- highlight: {
126
+ opacity: 1
127
+ },
128
+ highlight: {
129
+ itemStyle: {
130
130
  opacity: 1
131
+ }
132
+ },
133
+ downplay: {
134
+ itemStyle: {
135
+ opacity: 0.5
131
136
  },
132
- downplay: {
133
- opacity: 0.9
137
+ label: {
138
+ opacity: 0.6
134
139
  }
135
140
  },
136
141
  // Animation type canbe expansion, scale
@@ -26,6 +26,10 @@ var SunburstPiece = require("./SunburstPiece");
26
26
 
27
27
  var DataDiffer = require("../../data/DataDiffer");
28
28
 
29
+ var _format = require("../../util/format");
30
+
31
+ var windowOpen = _format.windowOpen;
32
+
29
33
  /*
30
34
  * Licensed to the Apache Software Foundation (ASF) under one
31
35
  * or more contributor license agreements. See the NOTICE file
@@ -193,7 +197,7 @@ var SunburstView = ChartView.extend({
193
197
 
194
198
  if (link) {
195
199
  var linkTarget = itemModel.get('target', true) || '_blank';
196
- window.open(link, linkTarget);
200
+ windowOpen(link, linkTarget);
197
201
  }
198
202
  }
199
203
 
@@ -38,6 +38,8 @@ var _format = require("../../util/format");
38
38
 
39
39
  var encodeHTML = _format.encodeHTML;
40
40
 
41
+ var LegendVisualProvider = require("../../visual/LegendVisualProvider");
42
+
41
43
  /*
42
44
  * Licensed to the Apache Software Foundation (ASF) under one
43
45
  * or more contributor license agreements. See the NOTICE file
@@ -76,9 +78,7 @@ var ThemeRiverSeries = SeriesModel.extend({
76
78
  // Enable legend selection for each data item
77
79
  // Use a function instead of direct access because data reference may changed
78
80
 
79
- this.legendDataProvider = function () {
80
- return this.getRawData();
81
- };
81
+ this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
82
82
  },
83
83
 
84
84
  /**
@@ -26,6 +26,8 @@ var _format = require("../../util/format");
26
26
 
27
27
  var encodeHTML = _format.encodeHTML;
28
28
 
29
+ var Model = require("../../model/Model");
30
+
29
31
  /*
30
32
  * Licensed to the Apache Software Foundation (ASF) under one
31
33
  * or more contributor license agreements. See the NOTICE file
@@ -63,9 +65,21 @@ var _default = SeriesModel.extend({
63
65
  children: option.data
64
66
  };
65
67
  var leaves = option.leaves || {};
66
- var treeOption = {};
67
- treeOption.leaves = leaves;
68
- var tree = Tree.createTree(root, this, treeOption);
68
+ var leavesModel = new Model(leaves, this, this.ecModel);
69
+ var tree = Tree.createTree(root, this, {}, beforeLink);
70
+
71
+ function beforeLink(nodeData) {
72
+ nodeData.wrapMethod('getItemModel', function (model, idx) {
73
+ var node = tree.getNodeByDataIndex(idx);
74
+
75
+ if (!node.children.length || !node.isExpand) {
76
+ model.parentModel = leavesModel;
77
+ }
78
+
79
+ return model;
80
+ });
81
+ }
82
+
69
83
  var treeDepth = 0;
70
84
  tree.eachNode('preorder', function (node) {
71
85
  if (node.depth > treeDepth) {
@@ -133,6 +147,9 @@ var _default = SeriesModel.extend({
133
147
  bottom: '12%',
134
148
  // the layout of the tree, two value can be selected, 'orthogonal' or 'radial'
135
149
  layout: 'orthogonal',
150
+ // value can be 'polyline'
151
+ edgeShape: 'curve',
152
+ edgeForkPosition: '50%',
136
153
  // true | false | 'move' | 'scale', see module:component/helper/RoamController.
137
154
  roam: false,
138
155
  // Symbol size scale ratio in roam
@@ -42,6 +42,14 @@ var _cursorHelper = require("../../component/helper/cursorHelper");
42
42
 
43
43
  var onIrrelevantElement = _cursorHelper.onIrrelevantElement;
44
44
 
45
+ var _config = require("../../config");
46
+
47
+ var __DEV__ = _config.__DEV__;
48
+
49
+ var _number = require("../../util/number");
50
+
51
+ var parsePercent = _number.parsePercent;
52
+
45
53
  /*
46
54
  * Licensed to the Apache Software Foundation (ASF) under one
47
55
  * or more contributor license agreements. See the NOTICE file
@@ -60,6 +68,55 @@ var onIrrelevantElement = _cursorHelper.onIrrelevantElement;
60
68
  * specific language governing permissions and limitations
61
69
  * under the License.
62
70
  */
71
+ var TreeShape = graphic.extendShape({
72
+ shape: {
73
+ parentPoint: [],
74
+ childPoints: [],
75
+ orient: '',
76
+ forkPosition: ''
77
+ },
78
+ style: {
79
+ stroke: '#000',
80
+ fill: null
81
+ },
82
+ buildPath: function (ctx, shape) {
83
+ var childPoints = shape.childPoints;
84
+ var childLen = childPoints.length;
85
+ var parentPoint = shape.parentPoint;
86
+ var firstChildPos = childPoints[0];
87
+ var lastChildPos = childPoints[childLen - 1];
88
+
89
+ if (childLen === 1) {
90
+ ctx.moveTo(parentPoint[0], parentPoint[1]);
91
+ ctx.lineTo(firstChildPos[0], firstChildPos[1]);
92
+ return;
93
+ }
94
+
95
+ var orient = shape.orient;
96
+ var forkDim = orient === 'TB' || orient === 'BT' ? 0 : 1;
97
+ var otherDim = 1 - forkDim;
98
+ var forkPosition = parsePercent(shape.forkPosition, 1);
99
+ var tmpPoint = [];
100
+ tmpPoint[forkDim] = parentPoint[forkDim];
101
+ tmpPoint[otherDim] = parentPoint[otherDim] + (lastChildPos[otherDim] - parentPoint[otherDim]) * forkPosition;
102
+ ctx.moveTo(parentPoint[0], parentPoint[1]);
103
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
104
+ ctx.moveTo(firstChildPos[0], firstChildPos[1]);
105
+ tmpPoint[forkDim] = firstChildPos[forkDim];
106
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
107
+ tmpPoint[forkDim] = lastChildPos[forkDim];
108
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
109
+ ctx.lineTo(lastChildPos[0], lastChildPos[1]);
110
+
111
+ for (var i = 1; i < childLen - 1; i++) {
112
+ var point = childPoints[i];
113
+ ctx.moveTo(point[0], point[1]);
114
+ tmpPoint[forkDim] = point[forkDim];
115
+ ctx.lineTo(tmpPoint[0], tmpPoint[1]);
116
+ }
117
+ }
118
+ });
119
+
63
120
  var _default = echarts.extendChartView({
64
121
  type: 'tree',
65
122
 
@@ -112,6 +169,8 @@ var _default = echarts.extendChartView({
112
169
  var seriesScope = {
113
170
  expandAndCollapse: seriesModel.get('expandAndCollapse'),
114
171
  layout: layout,
172
+ edgeShape: seriesModel.get('edgeShape'),
173
+ edgeForkPosition: seriesModel.get('edgeForkPosition'),
115
174
  orient: seriesModel.getOrient(),
116
175
  curvature: seriesModel.get('lineStyle.curveness'),
117
176
  symbolRotate: seriesModel.get('symbolRotate'),
@@ -387,27 +446,72 @@ function updateNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
387
446
  });
388
447
  }
389
448
 
390
- if (node.parentNode && node.parentNode !== virtualRoot) {
391
- var edge = symbolEl.__edge;
449
+ drawEdge(seriesModel, node, virtualRoot, symbolEl, sourceOldLayout, sourceLayout, targetLayout, group, seriesScope);
450
+ }
392
451
 
393
- if (!edge) {
394
- edge = symbolEl.__edge = new graphic.BezierCurve({
395
- shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
396
- style: zrUtil.defaults({
397
- opacity: 0,
398
- strokeNoScale: true
399
- }, seriesScope.lineStyle)
400
- });
452
+ function drawEdge(seriesModel, node, virtualRoot, symbolEl, sourceOldLayout, sourceLayout, targetLayout, group, seriesScope) {
453
+ var edgeShape = seriesScope.edgeShape;
454
+ var edge = symbolEl.__edge;
455
+
456
+ if (edgeShape === 'curve') {
457
+ if (node.parentNode && node.parentNode !== virtualRoot) {
458
+ if (!edge) {
459
+ edge = symbolEl.__edge = new graphic.BezierCurve({
460
+ shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
461
+ style: zrUtil.defaults({
462
+ opacity: 0,
463
+ strokeNoScale: true
464
+ }, seriesScope.lineStyle)
465
+ });
466
+ }
467
+
468
+ graphic.updateProps(edge, {
469
+ shape: getEdgeShape(seriesScope, sourceLayout, targetLayout),
470
+ style: {
471
+ opacity: 1
472
+ }
473
+ }, seriesModel);
401
474
  }
475
+ } else if (edgeShape === 'polyline') {
476
+ if (seriesScope.layout === 'orthogonal') {
477
+ if (node !== virtualRoot && node.children && node.children.length !== 0 && node.isExpand === true) {
478
+ var children = node.children;
479
+ var childPoints = [];
480
+
481
+ for (var i = 0; i < children.length; i++) {
482
+ var childLayout = children[i].getLayout();
483
+ childPoints.push([childLayout.x, childLayout.y]);
484
+ }
402
485
 
403
- graphic.updateProps(edge, {
404
- shape: getEdgeShape(seriesScope, sourceLayout, targetLayout),
405
- style: {
406
- opacity: 1
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({
495
+ opacity: 0,
496
+ strokeNoScale: true
497
+ }, seriesScope.lineStyle)
498
+ });
499
+ }
500
+
501
+ graphic.updateProps(edge, {
502
+ shape: {
503
+ parentPoint: [targetLayout.x, targetLayout.y],
504
+ childPoints: childPoints
505
+ },
506
+ style: {
507
+ opacity: 1
508
+ }
509
+ }, seriesModel);
407
510
  }
408
- }, seriesModel);
409
- group.add(edge);
511
+ } else {}
410
512
  }
513
+
514
+ group.add(edge);
411
515
  }
412
516
 
413
517
  function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope) {
@@ -416,6 +520,7 @@ function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
416
520
  var itemModel = node.getModel();
417
521
  var seriesScope = getTreeNodeStyle(node, itemModel, seriesScope);
418
522
  var source = node.parentNode === virtualRoot ? node : node.parentNode || node;
523
+ var edgeShape = seriesScope.edgeShape;
419
524
  var sourceLayout;
420
525
 
421
526
  while (sourceLayout = source.getLayout(), sourceLayout == null) {
@@ -431,17 +536,38 @@ function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
431
536
  symbolEl.fadeOut(null, {
432
537
  keepLabel: true
433
538
  });
434
- var edge = symbolEl.__edge;
539
+ var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
540
+ var sourceEdge = sourceSymbolEl.__edge; // 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
+
545
+ var edge = symbolEl.__edge || (source.isExpand === false || source.children.length === 1 ? sourceEdge : undefined);
546
+ var edgeShape = seriesScope.edgeShape;
435
547
 
436
548
  if (edge) {
437
- graphic.updateProps(edge, {
438
- shape: getEdgeShape(seriesScope, sourceLayout, sourceLayout),
439
- style: {
440
- opacity: 0
441
- }
442
- }, seriesModel, function () {
443
- group.remove(edge);
444
- });
549
+ if (edgeShape === 'curve') {
550
+ graphic.updateProps(edge, {
551
+ shape: getEdgeShape(seriesScope, sourceLayout, sourceLayout),
552
+ style: {
553
+ opacity: 0
554
+ }
555
+ }, seriesModel, function () {
556
+ group.remove(edge);
557
+ });
558
+ } else if (edgeShape === 'polyline' && seriesScope.layout === 'orthogonal') {
559
+ graphic.updateProps(edge, {
560
+ shape: {
561
+ parentPoint: [sourceLayout.x, sourceLayout.y],
562
+ childPoints: [[sourceLayout.x, sourceLayout.y]]
563
+ },
564
+ style: {
565
+ opacity: 0
566
+ }
567
+ }, seriesModel, function () {
568
+ group.remove(edge);
569
+ });
570
+ }
445
571
  }
446
572
  }
447
573
 
@@ -228,12 +228,24 @@ var _default = SeriesModel.extend({
228
228
  completeTreeValue(root);
229
229
  var levels = option.levels || [];
230
230
  levels = option.levels = setDefault(levels, ecModel);
231
- var treeOption = {};
232
- treeOption.levels = levels; // Make sure always a new tree is created when setOption,
231
+ var levelModels = zrUtil.map(levels || [], function (levelDefine) {
232
+ return new Model(levelDefine, this, ecModel);
233
+ }, this); // Make sure always a new tree is created when setOption,
233
234
  // in TreemapView, we check whether oldTree === newTree
234
235
  // to choose mappings approach among old shapes and new shapes.
235
236
 
236
- return Tree.createTree(root, this, treeOption).data;
237
+ var tree = Tree.createTree(root, this, null, beforeLink);
238
+
239
+ function beforeLink(nodeData) {
240
+ nodeData.wrapMethod('getItemModel', function (model, idx) {
241
+ var node = tree.getNodeByDataIndex(idx);
242
+ var levelModel = levelModels[node.depth];
243
+ levelModel && (model.parentModel = levelModel);
244
+ return model;
245
+ });
246
+ }
247
+
248
+ return tree.data;
237
249
  },
238
250
  optionUpdated: function () {
239
251
  this.resetViewRoot();
@@ -40,6 +40,10 @@ var animationUtil = require("../../util/animation");
40
40
 
41
41
  var makeStyleMapper = require("../../model/mixin/makeStyleMapper");
42
42
 
43
+ var _format = require("../../util/format");
44
+
45
+ var windowOpen = _format.windowOpen;
46
+
43
47
  /*
44
48
  * Licensed to the Apache Software Foundation (ASF) under one
45
49
  * or more contributor license agreements. See the NOTICE file
@@ -529,7 +533,7 @@ var _default = echarts.extendChartView({
529
533
  var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
530
534
  var link = itemModel.get('link', true);
531
535
  var linkTarget = itemModel.get('target', true) || 'blank';
532
- link && window.open(link, linkTarget);
536
+ link && windowOpen(link, linkTarget);
533
537
  }
534
538
  }
535
539
  }, this);
@@ -673,6 +677,10 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
673
677
 
674
678
 
675
679
  var thisLayout = thisNode.getLayout();
680
+ var data = seriesModel.getData(); // Only for enabling highlight/downplay. Clear firstly.
681
+ // Because some node will not be rendered.
682
+
683
+ data.setItemGraphicEl(thisNode.dataIndex, null);
676
684
 
677
685
  if (!thisLayout || !thisLayout.isInView) {
678
686
  return;
@@ -706,15 +714,37 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
706
714
 
707
715
  if (thisLayout.isAboveViewRoot) {
708
716
  return group;
709
- } // Background
717
+ }
710
718
 
719
+ var nodeModel = thisNode.getModel(); // Background
711
720
 
712
721
  var bg = giveGraphic('background', Rect, depth, Z_BG);
713
- bg && renderBackground(group, bg, isParent && thisLayout.upperHeight); // No children, render content.
722
+ bg && renderBackground(group, bg, isParent && thisLayout.upperLabelHeight); // No children, render content.
723
+
724
+ if (isParent) {
725
+ // Because of the implementation about "traverse" in graphic hover style, we
726
+ // can not set hover listener on the "group" of non-leaf node. Otherwise the
727
+ // hover event from the descendents will be listenered.
728
+ if (graphic.isHighDownDispatcher(group)) {
729
+ graphic.setAsHighDownDispatcher(group, false);
730
+ }
731
+
732
+ if (bg) {
733
+ graphic.setAsHighDownDispatcher(bg, true); // Only for enabling highlight/downplay.
714
734
 
715
- if (!isParent) {
735
+ data.setItemGraphicEl(thisNode.dataIndex, bg);
736
+ }
737
+ } else {
716
738
  var content = giveGraphic('content', Rect, depth, Z_CONTENT);
717
739
  content && renderContent(group, content);
740
+
741
+ if (bg && graphic.isHighDownDispatcher(bg)) {
742
+ graphic.setAsHighDownDispatcher(bg, false);
743
+ }
744
+
745
+ graphic.setAsHighDownDispatcher(group, true); // Only for enabling highlight/downplay.
746
+
747
+ data.setItemGraphicEl(thisNode.dataIndex, group);
718
748
  }
719
749
 
720
750
  return group; // ----------------------------
@@ -731,9 +761,16 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
731
761
  width: thisWidth,
732
762
  height: thisHeight
733
763
  });
734
- var visualBorderColor = thisNode.getVisual('borderColor', true);
735
- var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
736
- updateStyle(bg, function () {
764
+
765
+ if (thisInvisible) {
766
+ // If invisible, do not set visual, otherwise the element will
767
+ // change immediately before animation. We think it is OK to
768
+ // remain its origin color when moving out of the view window.
769
+ processInvisible(bg);
770
+ } else {
771
+ bg.invisible = false;
772
+ var visualBorderColor = thisNode.getVisual('borderColor', true);
773
+ var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
737
774
  var normalStyle = getItemStyleNormal(itemStyleNormalModel);
738
775
  normalStyle.fill = visualBorderColor;
739
776
  var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
@@ -753,8 +790,9 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
753
790
  }
754
791
 
755
792
  bg.setStyle(normalStyle);
756
- graphic.setHoverStyle(bg, emphasisStyle);
757
- });
793
+ graphic.setElementHoverStyle(bg, emphasisStyle);
794
+ }
795
+
758
796
  group.add(bg);
759
797
  }
760
798
 
@@ -771,52 +809,47 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
771
809
  width: contentWidth,
772
810
  height: contentHeight
773
811
  });
774
- var visualColor = thisNode.getVisual('color', true);
775
- updateStyle(content, function () {
812
+
813
+ if (thisInvisible) {
814
+ // If invisible, do not set visual, otherwise the element will
815
+ // change immediately before animation. We think it is OK to
816
+ // remain its origin color when moving out of the view window.
817
+ processInvisible(content);
818
+ } else {
819
+ content.invisible = false;
820
+ var visualColor = thisNode.getVisual('color', true);
776
821
  var normalStyle = getItemStyleNormal(itemStyleNormalModel);
777
822
  normalStyle.fill = visualColor;
778
823
  var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
779
824
  prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
780
825
  content.setStyle(normalStyle);
781
- graphic.setHoverStyle(content, emphasisStyle);
782
- });
826
+ graphic.setElementHoverStyle(content, emphasisStyle);
827
+ }
828
+
783
829
  group.add(content);
784
830
  }
785
831
 
786
- function updateStyle(element, cb) {
787
- if (!thisInvisible) {
788
- // If invisible, do not set visual, otherwise the element will
789
- // change immediately before animation. We think it is OK to
790
- // remain its origin color when moving out of the view window.
791
- cb();
792
-
793
- if (!element.__tmWillVisible) {
794
- element.invisible = false;
795
- }
796
- } else {
797
- // Delay invisible setting utill animation finished,
798
- // avoid element vanish suddenly before animation.
799
- !element.invisible && willInvisibleEls.push(element);
800
- }
832
+ function processInvisible(element) {
833
+ // Delay invisible setting utill animation finished,
834
+ // avoid element vanish suddenly before animation.
835
+ !element.invisible && willInvisibleEls.push(element);
801
836
  }
802
837
 
803
838
  function prepareText(normalStyle, emphasisStyle, visualColor, width, height, upperLabelRect) {
804
- var nodeModel = thisNode.getModel();
805
- var text = zrUtil.retrieve(seriesModel.getFormattedLabel(thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'), nodeModel.get('name'));
806
-
807
- if (!upperLabelRect && thisLayout.isLeafRoot) {
808
- var iconChar = seriesModel.get('drillDownIcon', true);
809
- text = iconChar ? iconChar + ' ' + text : text;
810
- }
811
-
839
+ var defaultText = nodeModel.get('name');
812
840
  var normalLabelModel = nodeModel.getModel(upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL);
813
841
  var emphasisLabelModel = nodeModel.getModel(upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS);
814
842
  var isShow = normalLabelModel.getShallow('show');
815
843
  graphic.setLabelStyle(normalStyle, emphasisStyle, normalLabelModel, emphasisLabelModel, {
816
- defaultText: isShow ? text : null,
844
+ defaultText: isShow ? defaultText : null,
817
845
  autoColor: visualColor,
818
- isRectText: true
846
+ isRectText: true,
847
+ labelFetcher: seriesModel,
848
+ labelDataIndex: thisNode.dataIndex,
849
+ labelProp: upperLabelRect ? 'upperLabel' : 'label'
819
850
  });
851
+ addDrillDownIcon(normalStyle, upperLabelRect, thisLayout);
852
+ addDrillDownIcon(emphasisStyle, upperLabelRect, thisLayout);
820
853
  upperLabelRect && (normalStyle.textRect = zrUtil.clone(upperLabelRect));
821
854
  normalStyle.truncate = isShow && normalLabelModel.get('ellipsis') ? {
822
855
  outerWidth: width,
@@ -825,6 +858,15 @@ function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimat
825
858
  } : null;
826
859
  }
827
860
 
861
+ function addDrillDownIcon(style, upperLabelRect, thisLayout) {
862
+ var text = style.text;
863
+
864
+ if (!upperLabelRect && thisLayout.isLeafRoot && text != null) {
865
+ var iconChar = seriesModel.get('drillDownIcon', true);
866
+ style.text = iconChar ? iconChar + ' ' + text : text;
867
+ }
868
+ }
869
+
828
870
  function giveGraphic(storageName, Ctor, depth, z) {
829
871
  var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
830
872
  var lasts = lastsForAnimation[storageName];