echarts 4.5.0 → 4.9.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 (329) hide show
  1. package/.DS_Store +0 -0
  2. package/.gitattributes +3 -0
  3. package/.github/pull_request_template.md +66 -0
  4. package/.github/workflows/nodejs.yml +15 -3
  5. package/.huskyrc +5 -0
  6. package/CONTRIBUTING.md +16 -160
  7. package/NOTICE +1 -1
  8. package/README.md +3 -3
  9. package/asset/.DS_Store +0 -0
  10. package/build/.DS_Store +0 -0
  11. package/dist/echarts-en.common.js +3072 -1261
  12. package/dist/echarts-en.common.min.js +1 -1
  13. package/dist/echarts-en.js +4339 -1685
  14. package/dist/echarts-en.js.map +1 -1
  15. package/dist/echarts-en.min.js +1 -1
  16. package/dist/echarts-en.simple.js +2496 -1011
  17. package/dist/echarts-en.simple.min.js +1 -1
  18. package/dist/echarts.common.js +3046 -1261
  19. package/dist/echarts.common.min.js +1 -1
  20. package/dist/echarts.js +4313 -1685
  21. package/dist/echarts.js.map +1 -1
  22. package/dist/echarts.min.js +1 -1
  23. package/dist/echarts.simple.js +2470 -1011
  24. package/dist/echarts.simple.min.js +1 -1
  25. package/dist/extension/bmap.js +33 -11
  26. package/dist/extension/bmap.js.map +1 -1
  27. package/dist/extension/bmap.min.js +1 -1
  28. package/dist/extension/dataTool.js.map +1 -1
  29. package/extension/.DS_Store +0 -0
  30. package/extension/bmap/BMapCoordSys.js +14 -4
  31. package/extension/bmap/BMapModel.js +4 -0
  32. package/extension/bmap/BMapView.js +18 -10
  33. package/extension-src/bmap/BMapCoordSys.js +14 -4
  34. package/extension-src/bmap/BMapModel.js +6 -1
  35. package/extension-src/bmap/BMapView.js +16 -9
  36. package/lib/chart/bar/BarSeries.js +14 -1
  37. package/lib/chart/bar/BarView.js +196 -18
  38. package/lib/chart/bar/BaseBarSeries.js +3 -1
  39. package/lib/chart/bar/PictorialBarSeries.js +1 -1
  40. package/lib/chart/candlestick/candlestickVisual.js +1 -1
  41. package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
  42. package/lib/chart/funnel/FunnelSeries.js +14 -5
  43. package/lib/chart/funnel/funnelLayout.js +162 -46
  44. package/lib/chart/gauge/GaugeSeries.js +0 -2
  45. package/lib/chart/graph/GraphSeries.js +23 -7
  46. package/lib/chart/graph/GraphView.js +30 -12
  47. package/lib/chart/graph/circularLayoutHelper.js +8 -2
  48. package/lib/chart/graph/forceLayout.js +6 -1
  49. package/lib/chart/graph/simpleLayout.js +1 -1
  50. package/lib/chart/graph/simpleLayoutHelper.js +10 -4
  51. package/lib/chart/heatmap/HeatmapView.js +4 -4
  52. package/lib/chart/helper/EffectLine.js +23 -1
  53. package/lib/chart/helper/EffectSymbol.js +2 -1
  54. package/lib/chart/helper/Line.js +129 -42
  55. package/lib/chart/helper/LineDraw.js +5 -1
  56. package/lib/chart/helper/Symbol.js +2 -3
  57. package/lib/chart/helper/createClipPathFromCoordSys.js +4 -1
  58. package/lib/chart/helper/createListFromArray.js +14 -8
  59. package/lib/chart/helper/createRenderPlanner.js +6 -3
  60. package/lib/chart/helper/multipleGraphEdgeHelper.js +258 -0
  61. package/lib/chart/helper/whiskerBoxCommon.js +22 -16
  62. package/lib/chart/line/LineSeries.js +3 -1
  63. package/lib/chart/line/LineView.js +41 -2
  64. package/lib/chart/lines/LinesSeries.js +0 -2
  65. package/lib/chart/map/MapSeries.js +14 -5
  66. package/lib/chart/pie/PieSeries.js +27 -6
  67. package/lib/chart/pie/PieView.js +22 -15
  68. package/lib/chart/pie/labelLayout.js +102 -19
  69. package/lib/chart/pie/pieLayout.js +19 -7
  70. package/lib/chart/radar/RadarSeries.js +27 -6
  71. package/lib/chart/radar/RadarView.js +3 -1
  72. package/lib/chart/sankey/SankeySeries.js +13 -1
  73. package/lib/chart/sankey/SankeyView.js +70 -32
  74. package/lib/chart/sankey/sankeyLayout.js +22 -3
  75. package/lib/chart/scatter/ScatterSeries.js +3 -1
  76. package/lib/chart/sunburst/SunburstPiece.js +5 -1
  77. package/lib/chart/sunburst/SunburstSeries.js +29 -12
  78. package/lib/chart/sunburst/SunburstView.js +5 -1
  79. package/lib/chart/themeRiver/ThemeRiverSeries.js +24 -33
  80. package/lib/chart/tree/TreeSeries.js +20 -3
  81. package/lib/chart/tree/TreeView.js +149 -23
  82. package/lib/chart/treemap/TreemapSeries.js +25 -4
  83. package/lib/chart/treemap/TreemapView.js +80 -38
  84. package/lib/chart/treemap/treemapLayout.js +1 -1
  85. package/lib/chart/treemap/treemapVisual.js +9 -15
  86. package/lib/component/axis/AngleAxisView.js +64 -7
  87. package/lib/component/axis/AxisBuilder.js +62 -24
  88. package/lib/component/axis/CartesianAxisView.js +52 -85
  89. package/lib/component/axis/RadiusAxisView.js +36 -4
  90. package/lib/component/axis/SingleAxisView.js +21 -6
  91. package/lib/component/axis/axisSplitHelper.js +132 -0
  92. package/lib/component/axisPointer/axisTrigger.js +1 -1
  93. package/lib/component/brush/BrushView.js +11 -1
  94. package/lib/component/brush/visualEncoding.js +13 -2
  95. package/lib/component/dataZoom/SliderZoomView.js +4 -10
  96. package/lib/component/helper/BrushController.js +33 -43
  97. package/lib/component/helper/MapDraw.js +30 -4
  98. package/lib/component/legend/LegendModel.js +3 -3
  99. package/lib/component/legend/LegendView.js +17 -13
  100. package/lib/component/legend/ScrollableLegendView.js +18 -18
  101. package/lib/component/marker/MarkAreaView.js +53 -15
  102. package/lib/component/marker/MarkLineModel.js +2 -1
  103. package/lib/component/marker/MarkLineView.js +3 -0
  104. package/lib/component/marker/MarkPointView.js +8 -1
  105. package/lib/component/marker/MarkerModel.js +3 -2
  106. package/lib/component/marker/markerHelper.js +7 -4
  107. package/lib/component/timeline/SliderTimelineView.js +7 -1
  108. package/lib/component/title.js +6 -2
  109. package/lib/component/toolbox/ToolboxView.js +5 -1
  110. package/lib/component/toolbox/feature/DataView.js +23 -8
  111. package/lib/component/toolbox/feature/DataZoom.js +6 -6
  112. package/lib/component/toolbox/feature/MagicType.js +20 -14
  113. package/lib/component/toolbox/feature/SaveAsImage.js +4 -2
  114. package/lib/component/tooltip/TooltipContent.js +101 -30
  115. package/lib/component/tooltip/TooltipRichContent.js +56 -8
  116. package/lib/component/tooltip/TooltipView.js +11 -12
  117. package/lib/component/visualMap/PiecewiseModel.js +3 -6
  118. package/lib/component/visualMap/VisualMapModel.js +1 -1
  119. package/lib/coord/Axis.js +30 -2
  120. package/lib/coord/View.js +9 -0
  121. package/lib/coord/axisDefault.js +22 -3
  122. package/lib/coord/axisHelper.js +24 -18
  123. package/lib/coord/calendar/Calendar.js +8 -4
  124. package/lib/coord/geo/GeoModel.js +2 -1
  125. package/lib/coord/geo/geoJSONLoader.js +3 -2
  126. package/lib/coord/geo/geoSourceManager.js +3 -2
  127. package/lib/coord/geo/parseGeoJson.js +3 -2
  128. package/lib/coord/radar/Radar.js +5 -5
  129. package/lib/data/DataDimensionInfo.js +157 -0
  130. package/lib/data/Graph.js +1 -6
  131. package/lib/data/List.js +26 -20
  132. package/lib/data/Tree.js +5 -42
  133. package/lib/data/helper/completeDimensions.js +43 -32
  134. package/lib/data/helper/createDimensions.js +2 -0
  135. package/lib/data/helper/sourceHelper.js +214 -114
  136. package/lib/echarts.js +57 -34
  137. package/lib/langEN.js +26 -0
  138. package/lib/layout/barGrid.js +19 -13
  139. package/lib/layout/barPolar.js +1 -6
  140. package/lib/loading/default.js +43 -27
  141. package/lib/model/Series.js +4 -4
  142. package/lib/model/referHelper.js +40 -12
  143. package/lib/processor/dataSample.js +1 -1
  144. package/lib/scale/Interval.js +87 -2
  145. package/lib/scale/Log.js +9 -2
  146. package/lib/scale/helper.js +1 -43
  147. package/lib/stream/Scheduler.js +10 -2
  148. package/lib/theme/dark.js +3 -0
  149. package/lib/util/format.js +19 -2
  150. package/lib/util/graphic.js +14 -12
  151. package/lib/visual/LegendVisualProvider.js +75 -0
  152. package/lib/visual/VisualMapping.js +1 -1
  153. package/lib/visual/dataColor.js +2 -12
  154. package/lib/visual/seriesColor.js +15 -7
  155. package/lib/visual/symbol.js +12 -2
  156. package/map/.DS_Store +0 -0
  157. package/map/js/.DS_Store +0 -0
  158. package/map/js/china.js +1 -1
  159. package/map/js/province/.DS_Store +0 -0
  160. package/map/js/province/chongqing.js +1 -1
  161. package/map/js/province/gansu.js +2 -2
  162. package/map/js/province/tianjin.js +1 -28
  163. package/map/json/.DS_Store +0 -0
  164. package/map/json/china.json +1 -1
  165. package/map/json/province/chongqing.json +1 -1
  166. package/map/json/province/tianjin.json +1 -1
  167. package/package.json +12 -6
  168. package/src/.DS_Store +0 -0
  169. package/src/chart/.DS_Store +0 -0
  170. package/src/chart/bar/BarSeries.js +15 -1
  171. package/src/chart/bar/BarView.js +198 -17
  172. package/src/chart/bar/BaseBarSeries.js +1 -1
  173. package/src/chart/bar/PictorialBarSeries.js +2 -2
  174. package/src/chart/candlestick/candlestickVisual.js +1 -1
  175. package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
  176. package/src/chart/funnel/FunnelSeries.js +11 -4
  177. package/src/chart/funnel/funnelLayout.js +179 -53
  178. package/src/chart/gauge/GaugeSeries.js +0 -1
  179. package/src/chart/graph/GraphSeries.js +19 -7
  180. package/src/chart/graph/GraphView.js +28 -10
  181. package/src/chart/graph/circularLayoutHelper.js +8 -2
  182. package/src/chart/graph/forceLayout.js +7 -1
  183. package/src/chart/graph/simpleLayout.js +1 -1
  184. package/src/chart/graph/simpleLayoutHelper.js +12 -5
  185. package/src/chart/heatmap/HeatmapView.js +4 -4
  186. package/src/chart/helper/EffectLine.js +23 -1
  187. package/src/chart/helper/EffectSymbol.js +2 -1
  188. package/src/chart/helper/Line.js +122 -37
  189. package/src/chart/helper/LineDraw.js +5 -1
  190. package/src/chart/helper/Symbol.js +4 -4
  191. package/src/chart/helper/createClipPathFromCoordSys.js +4 -0
  192. package/src/chart/helper/createGraphFromNodeEdge.js +2 -1
  193. package/src/chart/helper/createListFromArray.js +13 -8
  194. package/src/chart/helper/createRenderPlanner.js +5 -2
  195. package/src/chart/helper/multipleGraphEdgeHelper.js +229 -0
  196. package/src/chart/helper/whiskerBoxCommon.js +21 -16
  197. package/src/chart/line/LineSeries.js +1 -1
  198. package/src/chart/line/LineView.js +45 -1
  199. package/src/chart/lines/LinesSeries.js +1 -3
  200. package/src/chart/map/MapSeries.js +11 -5
  201. package/src/chart/pie/PieSeries.js +26 -5
  202. package/src/chart/pie/PieView.js +20 -15
  203. package/src/chart/pie/labelLayout.js +114 -22
  204. package/src/chart/pie/pieLayout.js +20 -7
  205. package/src/chart/radar/RadarSeries.js +31 -6
  206. package/src/chart/radar/RadarView.js +4 -2
  207. package/src/chart/sankey/SankeySeries.js +12 -1
  208. package/src/chart/sankey/SankeyView.js +75 -30
  209. package/src/chart/sankey/sankeyLayout.js +25 -5
  210. package/src/chart/scatter/ScatterSeries.js +1 -1
  211. package/src/chart/sunburst/SunburstPiece.js +7 -1
  212. package/src/chart/sunburst/SunburstSeries.js +28 -15
  213. package/src/chart/sunburst/SunburstView.js +2 -1
  214. package/src/chart/themeRiver/ThemeRiverSeries.js +25 -30
  215. package/src/chart/tree/TreeSeries.js +19 -6
  216. package/src/chart/tree/TreeView.js +156 -23
  217. package/src/chart/treemap/TreemapSeries.js +23 -5
  218. package/src/chart/treemap/TreemapView.js +77 -41
  219. package/src/chart/treemap/treemapLayout.js +2 -2
  220. package/src/chart/treemap/treemapVisual.js +8 -25
  221. package/src/component/axis/AngleAxisView.js +75 -7
  222. package/src/component/axis/AxisBuilder.js +77 -32
  223. package/src/component/axis/CartesianAxisView.js +47 -83
  224. package/src/component/axis/RadiusAxisView.js +37 -4
  225. package/src/component/axis/SingleAxisView.js +21 -4
  226. package/src/component/axis/axisSplitHelper.js +114 -0
  227. package/src/component/axisPointer/axisTrigger.js +1 -1
  228. package/src/component/brush/BrushView.js +8 -1
  229. package/src/component/brush/visualEncoding.js +6 -3
  230. package/src/component/dataZoom/SliderZoomView.js +4 -9
  231. package/src/component/helper/BrushController.js +40 -47
  232. package/src/component/helper/MapDraw.js +27 -4
  233. package/src/component/legend/LegendModel.js +3 -3
  234. package/src/component/legend/LegendView.js +18 -12
  235. package/src/component/legend/ScrollableLegendView.js +18 -16
  236. package/src/component/marker/MarkAreaView.js +53 -15
  237. package/src/component/marker/MarkLineModel.js +2 -1
  238. package/src/component/marker/MarkLineView.js +3 -1
  239. package/src/component/marker/MarkPointView.js +7 -1
  240. package/src/component/marker/MarkerModel.js +3 -2
  241. package/src/component/marker/markerHelper.js +8 -5
  242. package/src/component/timeline/SliderTimelineView.js +9 -6
  243. package/src/component/title.js +4 -3
  244. package/src/component/toolbox/.DS_Store +0 -0
  245. package/src/component/toolbox/ToolboxView.js +5 -0
  246. package/src/component/toolbox/feature/DataView.js +20 -8
  247. package/src/component/toolbox/feature/DataZoom.js +6 -6
  248. package/src/component/toolbox/feature/MagicType.js +19 -13
  249. package/src/component/toolbox/feature/SaveAsImage.js +4 -2
  250. package/src/component/tooltip/TooltipContent.js +94 -28
  251. package/src/component/tooltip/TooltipRichContent.js +52 -9
  252. package/src/component/tooltip/TooltipView.js +14 -12
  253. package/src/component/visualMap/PiecewiseModel.js +5 -9
  254. package/src/component/visualMap/VisualMapModel.js +1 -1
  255. package/src/coord/Axis.js +29 -2
  256. package/src/coord/View.js +10 -1
  257. package/src/coord/axisDefault.js +26 -2
  258. package/src/coord/axisHelper.js +30 -21
  259. package/src/coord/calendar/Calendar.js +12 -5
  260. package/src/coord/geo/GeoModel.js +3 -6
  261. package/src/coord/geo/geoJSONLoader.js +3 -2
  262. package/src/coord/geo/geoSourceManager.js +3 -2
  263. package/src/coord/geo/parseGeoJson.js +3 -2
  264. package/src/coord/radar/Radar.js +6 -8
  265. package/src/data/DataDimensionInfo.js +135 -0
  266. package/src/data/Graph.js +0 -5
  267. package/src/data/List.js +30 -17
  268. package/src/data/Tree.js +6 -39
  269. package/src/data/helper/completeDimensions.js +49 -30
  270. package/src/data/helper/createDimensions.js +2 -0
  271. package/src/data/helper/sourceHelper.js +216 -124
  272. package/src/echarts.js +60 -36
  273. package/src/langEN.js +26 -0
  274. package/src/layout/barGrid.js +22 -10
  275. package/src/layout/barPolar.js +4 -6
  276. package/src/loading/default.js +46 -34
  277. package/src/model/.DS_Store +0 -0
  278. package/src/model/Series.js +4 -4
  279. package/src/model/referHelper.js +34 -11
  280. package/src/preprocessor/.DS_Store +0 -0
  281. package/src/processor/dataSample.js +1 -1
  282. package/src/scale/Interval.js +84 -4
  283. package/src/scale/Log.js +9 -2
  284. package/src/scale/helper.js +1 -39
  285. package/src/stream/Scheduler.js +9 -1
  286. package/src/theme/dark.js +3 -0
  287. package/src/util/.DS_Store +0 -0
  288. package/src/util/format.js +17 -1
  289. package/src/util/graphic.js +13 -11
  290. package/src/visual/LegendVisualProvider.js +55 -0
  291. package/src/visual/VisualMapping.js +1 -1
  292. package/src/visual/dataColor.js +0 -13
  293. package/src/visual/seriesColor.js +13 -7
  294. package/src/visual/symbol.js +11 -2
  295. package/theme/.DS_Store +0 -0
  296. package/theme/azul.js +163 -0
  297. package/theme/bee-inspired.js +178 -0
  298. package/theme/blue.js +178 -0
  299. package/theme/caravan.js +178 -0
  300. package/theme/carp.js +163 -0
  301. package/theme/cool.js +180 -0
  302. package/theme/dark-blue.js +168 -0
  303. package/theme/dark-bold.js +168 -0
  304. package/theme/dark-digerati.js +168 -0
  305. package/theme/dark-fresh-cut.js +168 -0
  306. package/theme/dark-mushroom.js +168 -0
  307. package/theme/dark.js +69 -62
  308. package/theme/eduardo.js +178 -0
  309. package/theme/forest.js +163 -0
  310. package/theme/fresh-cut.js +163 -0
  311. package/theme/fruit.js +178 -0
  312. package/theme/gray.js +220 -0
  313. package/theme/green.js +222 -0
  314. package/theme/helianthus.js +263 -0
  315. package/theme/infographic.js +72 -57
  316. package/theme/inspired.js +163 -0
  317. package/theme/jazz.js +163 -0
  318. package/theme/london.js +163 -0
  319. package/theme/macarons.js +80 -57
  320. package/theme/macarons2.js +251 -0
  321. package/theme/mint.js +155 -0
  322. package/theme/red-velvet.js +163 -0
  323. package/theme/red.js +225 -0
  324. package/theme/roma.js +55 -22
  325. package/theme/royal.js +163 -0
  326. package/theme/sakura.js +140 -0
  327. package/theme/shine.js +52 -45
  328. package/theme/tech-blue.js +180 -0
  329. package/theme/vintage.js +37 -23
@@ -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) {
@@ -47,16 +49,39 @@ var RadarSeries = SeriesModel.extend({
47
49
  });
48
50
  },
49
51
 
50
- formatTooltip: function (dataIndex) {
52
+ formatTooltip: function (dataIndex, multipleSeries, dataType, renderMode) {
51
53
  var data = this.getData();
52
54
  var coordSys = this.coordinateSystem;
53
55
  var indicatorAxes = coordSys.getIndicatorAxes();
54
56
  var name = this.getData().getName(dataIndex);
55
- return encodeHTML(name === '' ? this.name : name) + '<br/>'
57
+ var newLine = renderMode === 'html' ? '<br/>' : '\n';
58
+ return encodeHTML(name === '' ? this.name : name) + newLine
56
59
  + zrUtil.map(indicatorAxes, function (axis, idx) {
57
60
  var val = data.get(data.mapDimension(axis.dim), dataIndex);
58
61
  return encodeHTML(axis.name + ' : ' + val);
59
- }).join('<br />');
62
+ }).join(newLine);
63
+ },
64
+
65
+ /**
66
+ * @implement
67
+ */
68
+ getTooltipPosition: function (dataIndex) {
69
+ if (dataIndex != null) {
70
+ var data = this.getData();
71
+ var coordSys = this.coordinateSystem;
72
+ var values = data.getValues(
73
+ zrUtil.map(coordSys.dimensions, function (dim) {
74
+ return data.mapDimension(dim);
75
+ }), dataIndex, true
76
+ );
77
+
78
+ for (var i = 0, len = values.length; i < len; i++) {
79
+ if (!isNaN(values[i])) {
80
+ var indicatorAxes = coordSys.getIndicatorAxes();
81
+ return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
82
+ }
83
+ }
84
+ }
60
85
  },
61
86
 
62
87
  defaultOption: {
@@ -52,12 +52,14 @@ export default echarts.extendChartView({
52
52
  var symbolPath = symbolUtil.createSymbol(
53
53
  symbolType, -1, -1, 2, 2, color
54
54
  );
55
+ var symbolRotate = data.getItemVisual(idx, 'symbolRotate') || 0;
55
56
  symbolPath.attr({
56
57
  style: {
57
58
  strokeNoScale: true
58
59
  },
59
60
  z2: 100,
60
- scale: [symbolSize[0] / 2, symbolSize[1] / 2]
61
+ scale: [symbolSize[0] / 2, symbolSize[1] / 2],
62
+ rotation: symbolRotate * Math.PI / 180 || 0
61
63
  });
62
64
  return symbolPath;
63
65
  }
@@ -226,4 +228,4 @@ export default echarts.extendChartView({
226
228
  },
227
229
 
228
230
  dispose: function () {}
229
- });
231
+ });
@@ -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
 
@@ -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) {
@@ -201,9 +203,13 @@ SunburstPieceProto._updateLabel = function (seriesModel, visualColor, state) {
201
203
  : itemModel.getModel(state + '.label');
202
204
  var labelHoverModel = itemModel.getModel('emphasis.label');
203
205
 
206
+ var labelFormatter = labelModel.get('formatter');
207
+ // Use normal formatter if no state formatter is defined
208
+ var labelState = labelFormatter ? state : 'normal';
209
+
204
210
  var text = zrUtil.retrieve(
205
211
  seriesModel.getFormattedLabel(
206
- this.node.dataIndex, state, null, null, 'label'
212
+ this.node.dataIndex, labelState, null, null, 'label'
207
213
  ),
208
214
  this.node.name
209
215
  );
@@ -20,6 +20,7 @@
20
20
  import * as zrUtil from 'zrender/src/core/util';
21
21
  import SeriesModel from '../../model/Series';
22
22
  import Tree from '../../data/Tree';
23
+ import Model from '../../model/Model';
23
24
  import {wrapTreePathInfo} from '../helper/treeHelper';
24
25
 
25
26
  export default SeriesModel.extend({
@@ -37,18 +38,25 @@ export default SeriesModel.extend({
37
38
 
38
39
  completeTreeValue(root);
39
40
 
40
- var levels = option.levels || [];
41
-
42
- // levels = option.levels = setDefault(levels, ecModel);
43
-
44
- var treeOption = {};
45
-
46
- treeOption.levels = levels;
41
+ var levelModels = zrUtil.map(option.levels || [], function (levelDefine) {
42
+ return new Model(levelDefine, this, ecModel);
43
+ }, this);
47
44
 
48
45
  // Make sure always a new tree is created when setOption,
49
46
  // in TreemapView, we check whether oldTree === newTree
50
47
  // to choose mappings approach among old shapes and new shapes.
51
- return Tree.createTree(root, this, treeOption).data;
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
+ var levelModel = levelModels[node.depth];
54
+ levelModel && (model.parentModel = levelModel);
55
+ return model;
56
+ });
57
+ }
58
+
59
+ return tree.data;
52
60
  },
53
61
 
54
62
  optionUpdated: function () {
@@ -105,8 +113,7 @@ export default SeriesModel.extend({
105
113
  align: 'center',
106
114
  position: 'inside',
107
115
  distance: 5,
108
- silent: true,
109
- emphasis: {}
116
+ silent: true
110
117
  },
111
118
  itemStyle: {
112
119
  borderWidth: 1,
@@ -116,13 +123,19 @@ export default SeriesModel.extend({
116
123
  shadowColor: 'rgba(0, 0, 0, 0.2)',
117
124
  shadowOffsetX: 0,
118
125
  shadowOffsetY: 0,
119
- opacity: 1,
120
- emphasis: {},
121
- highlight: {
126
+ opacity: 1
127
+ },
128
+ highlight: {
129
+ itemStyle: {
122
130
  opacity: 1
131
+ }
132
+ },
133
+ downplay: {
134
+ itemStyle: {
135
+ opacity: 0.5
123
136
  },
124
- downplay: {
125
- opacity: 0.9
137
+ label: {
138
+ opacity: 0.6
126
139
  }
127
140
  },
128
141
 
@@ -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
  /**
@@ -62,52 +63,46 @@ var ThemeRiverSeries = SeriesModel.extend({
62
63
  */
63
64
  fixData: function (data) {
64
65
  var rawDataLength = data.length;
66
+ /**
67
+ * Make sure every layer data get the same keys.
68
+ * The value index tells which layer has visited.
69
+ * {
70
+ * 2014/01/01: -1
71
+ * }
72
+ */
73
+ var timeValueKeys = {};
65
74
 
66
75
  // grouped data by name
67
76
  var groupResult = groupData(data, function (item) {
77
+ if (!timeValueKeys.hasOwnProperty(item[0])) {
78
+ timeValueKeys[item[0]] = -1;
79
+ }
68
80
  return item[2];
69
81
  });
70
82
  var layData = [];
71
83
  groupResult.buckets.each(function (items, key) {
72
84
  layData.push({name: key, dataList: items});
73
85
  });
74
-
75
86
  var layerNum = layData.length;
76
- var largestLayer = -1;
77
- var index = -1;
78
- for (var i = 0; i < layerNum; ++i) {
79
- var len = layData[i].dataList.length;
80
- if (len > largestLayer) {
81
- largestLayer = len;
82
- index = i;
83
- }
84
- }
85
87
 
86
88
  for (var k = 0; k < layerNum; ++k) {
87
- if (k === index) {
88
- continue;
89
- }
90
89
  var name = layData[k].name;
91
- for (var j = 0; j < largestLayer; ++j) {
92
- var timeValue = layData[index].dataList[j][0];
93
- var length = layData[k].dataList.length;
94
- var keyIndex = -1;
95
- for (var l = 0; l < length; ++l) {
96
- var value = layData[k].dataList[l][0];
97
- if (value === timeValue) {
98
- keyIndex = l;
99
- break;
100
- }
101
- }
102
- if (keyIndex === -1) {
90
+ for (var j = 0; j < layData[k].dataList.length; ++j) {
91
+ var timeValue = layData[k].dataList[j][0];
92
+ timeValueKeys[timeValue] = k;
93
+ }
94
+
95
+ for (var timeValue in timeValueKeys) {
96
+ if (timeValueKeys.hasOwnProperty(timeValue) && timeValueKeys[timeValue] !== k) {
97
+ timeValueKeys[timeValue] = k;
103
98
  data[rawDataLength] = [];
104
99
  data[rawDataLength][0] = timeValue;
105
100
  data[rawDataLength][1] = 0;
106
101
  data[rawDataLength][2] = name;
107
102
  rawDataLength++;
108
-
109
103
  }
110
104
  }
105
+
111
106
  }
112
107
  return data;
113
108
  },
@@ -292,4 +287,4 @@ var ThemeRiverSeries = SeriesModel.extend({
292
287
  }
293
288
  });
294
289
 
295
- export default ThemeRiverSeries;
290
+ export default ThemeRiverSeries;
@@ -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