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
@@ -34,7 +34,7 @@ export default SeriesModel.extend({
34
34
  throw new Error('Line not support coordinateSystem besides cartesian and polar');
35
35
  }
36
36
  }
37
- return createListFromArray(this.getSource(), this);
37
+ return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
38
38
  },
39
39
 
40
40
  defaultOption: {
@@ -21,6 +21,7 @@
21
21
 
22
22
  import {__DEV__} from '../../config';
23
23
  import * as zrUtil from 'zrender/src/core/util';
24
+ import {fromPoints} from 'zrender/src/core/bbox';
24
25
  import SymbolDraw from '../helper/SymbolDraw';
25
26
  import SymbolClz from '../helper/Symbol';
26
27
  import lineAnimationDiff from './lineAnimationDiff';
@@ -45,6 +46,26 @@ function isPointsSame(points1, points2) {
45
46
  return true;
46
47
  }
47
48
 
49
+ function getBoundingDiff(points1, points2) {
50
+ var min1 = [];
51
+ var max1 = [];
52
+
53
+ var min2 = [];
54
+ var max2 = [];
55
+
56
+ fromPoints(points1, min1, max1);
57
+ fromPoints(points2, min2, max2);
58
+
59
+ // Get a max value from each corner of two boundings.
60
+ return Math.max(
61
+ Math.abs(min1[0] - min2[0]),
62
+ Math.abs(min1[1] - min2[1]),
63
+
64
+ Math.abs(max1[0] - max2[0]),
65
+ Math.abs(max1[1] - max2[1])
66
+ );
67
+ }
68
+
48
69
  function getSmooth(smooth) {
49
70
  return typeof (smooth) === 'number' ? smooth : (smooth ? 0.5 : 0);
50
71
  }
@@ -354,7 +375,7 @@ export default ChartView.extend({
354
375
  // FIXME step not support polar
355
376
  var step = !isCoordSysPolar && seriesModel.get('step');
356
377
  var clipShapeForSymbol;
357
- if (coordSys && coordSys.getArea) {
378
+ if (coordSys && coordSys.getArea && seriesModel.get('clip', true)) {
358
379
  clipShapeForSymbol = coordSys.getArea();
359
380
  // Avoid float number rounding error for symbol on the edge of axis extent.
360
381
  // See #7913 and `test/dataZoom-clip.html`.
@@ -369,6 +390,7 @@ export default ChartView.extend({
369
390
  clipShapeForSymbol.r1 += 0.5;
370
391
  }
371
392
  }
393
+ this._clipShapeForSymbol = clipShapeForSymbol;
372
394
  // Initialization animation or coordinate system changed
373
395
  if (
374
396
  !(polyline && prevCoordSys.type === coordSys.type && step === this._step)
@@ -521,6 +543,10 @@ export default ChartView.extend({
521
543
  // Null data
522
544
  return;
523
545
  }
546
+ // fix #11360: should't draw symbol outside clipShapeForSymbol
547
+ if (this._clipShapeForSymbol && !this._clipShapeForSymbol.contain(pt[0], pt[1])) {
548
+ return;
549
+ }
524
550
  symbol = new SymbolClz(data, dataIndex);
525
551
  symbol.position = pt;
526
552
  symbol.setZ(
@@ -652,6 +678,24 @@ export default ChartView.extend({
652
678
  next = turnPointsIntoStep(diff.next, coordSys, step);
653
679
  stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
654
680
  }
681
+ // Don't apply animation if diff is large.
682
+ // For better result and avoid memory explosion problems like
683
+ // https://github.com/apache/incubator-echarts/issues/12229
684
+ if (getBoundingDiff(current, next) > 3000
685
+ || (polygon && getBoundingDiff(stackedOnCurrent, stackedOnNext) > 3000)
686
+ ) {
687
+ polyline.setShape({
688
+ points: next
689
+ });
690
+ if (polygon) {
691
+ polygon.setShape({
692
+ points: next,
693
+ stackedOnPoints: stackedOnNext
694
+ });
695
+ }
696
+ return;
697
+ }
698
+
655
699
  // `diff.current` is subset of `current` (which should be ensured by
656
700
  // turnPointsIntoStep), so points in `__points` can be updated when
657
701
  // points in `current` are update during animation.
@@ -80,8 +80,6 @@ var LinesSeries = SeriesModel.extend({
80
80
  },
81
81
 
82
82
  mergeOption: function (option) {
83
- // The input data may be null/undefined.
84
- option.data = option.data || [];
85
83
 
86
84
  compatEc2(option);
87
85
 
@@ -333,4 +331,4 @@ var LinesSeries = SeriesModel.extend({
333
331
  }
334
332
  });
335
333
 
336
- export default LinesSeries;
334
+ export default LinesSeries;
@@ -24,6 +24,7 @@ import {encodeHTML, addCommas} from '../../util/format';
24
24
  import dataSelectableMixin from '../../component/helper/selectableMixin';
25
25
  import {retrieveRawAttr} from '../../data/helper/dataProvider';
26
26
  import geoSourceManager from '../../coord/geo/geoSourceManager';
27
+ import {makeSeriesEncodeForNameBased} from '../../data/helper/sourceHelper';
27
28
 
28
29
  var MapSeries = SeriesModel.extend({
29
30
 
@@ -46,7 +47,10 @@ var MapSeries = SeriesModel.extend({
46
47
  seriesGroup: [],
47
48
 
48
49
  getInitialData: function (option) {
49
- var data = createListSimply(this, ['value']);
50
+ var data = createListSimply(this, {
51
+ coordDimensions: ['value'],
52
+ encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
53
+ });
50
54
  var valueDim = data.mapDimension('value');
51
55
  var dataNameMap = zrUtil.createHashMap();
52
56
  var selectTargetList = [];
@@ -62,7 +66,7 @@ var MapSeries = SeriesModel.extend({
62
66
  });
63
67
  }
64
68
 
65
- var geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap);
69
+ var geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap, this.option.nameProperty);
66
70
  zrUtil.each(geoSource.regions, function (region) {
67
71
  var name = region.name;
68
72
  if (!dataNameMap.get(name)) {
@@ -127,7 +131,7 @@ var MapSeries = SeriesModel.extend({
127
131
  *
128
132
  * @param {number} dataIndex
129
133
  */
130
- formatTooltip: function (dataIndex) {
134
+ formatTooltip: function (dataIndex, multipleSeries, dataType, renderMode) {
131
135
  // FIXME orignalData and data is a bit confusing
132
136
  var data = this.getData();
133
137
  var formattedValue = addCommas(this.getRawValue(dataIndex));
@@ -145,7 +149,8 @@ var MapSeries = SeriesModel.extend({
145
149
  }
146
150
  }
147
151
 
148
- return seriesNames.join(', ') + '<br />'
152
+ var newLine = renderMode === 'html' ? '<br/>' : '\n';
153
+ return seriesNames.join(', ') + newLine
149
154
  + encodeHTML(name + ' : ' + formattedValue);
150
155
  },
151
156
 
@@ -252,7 +257,8 @@ var MapSeries = SeriesModel.extend({
252
257
  itemStyle: {
253
258
  areaColor: 'rgba(255,215,0,0.8)'
254
259
  }
255
- }
260
+ },
261
+ nameProperty: 'name'
256
262
  }
257
263
 
258
264
  });
@@ -24,6 +24,8 @@ import * as modelUtil from '../../util/model';
24
24
  import {getPercentWithPrecision} from '../../util/number';
25
25
  import dataSelectableMixin from '../../component/helper/selectableMixin';
26
26
  import {retrieveRawAttr} from '../../data/helper/dataProvider';
27
+ import {makeSeriesEncodeForNameBased} from '../../data/helper/sourceHelper';
28
+ import LegendVisualProvider from '../../visual/LegendVisualProvider';
27
29
 
28
30
 
29
31
  var PieSeries = echarts.extendSeriesModel({
@@ -36,9 +38,9 @@ var PieSeries = echarts.extendSeriesModel({
36
38
 
37
39
  // Enable legend selection for each data item
38
40
  // Use a function instead of direct access because data reference may changed
39
- this.legendDataProvider = function () {
40
- return this.getRawData();
41
- };
41
+ this.legendVisualProvider = new LegendVisualProvider(
42
+ zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this)
43
+ );
42
44
 
43
45
  this.updateSelectedMap(this._createSelectableList());
44
46
 
@@ -53,7 +55,10 @@ var PieSeries = echarts.extendSeriesModel({
53
55
  },
54
56
 
55
57
  getInitialData: function (option, ecModel) {
56
- return createListSimply(this, ['value']);
58
+ return createListSimply(this, {
59
+ coordDimensions: ['value'],
60
+ encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
61
+ });
57
62
  },
58
63
 
59
64
  _createSelectableList: function () {
@@ -142,12 +147,28 @@ var PieSeries = echarts.extendSeriesModel({
142
147
 
143
148
  // cursor: null,
144
149
 
150
+ left: 0,
151
+ top: 0,
152
+ right: 0,
153
+ bottom: 0,
154
+ width: null,
155
+ height: null,
156
+
145
157
  label: {
146
158
  // If rotate around circle
147
159
  rotate: false,
148
160
  show: true,
149
161
  // 'outer', 'inside', 'center'
150
- position: 'outer'
162
+ position: 'outer',
163
+ // 'none', 'labelLine', 'edge'. Works only when position is 'outer'
164
+ alignTo: 'none',
165
+ // Closest distance between label and chart edge.
166
+ // Works only position is 'outer' and alignTo is 'edge'.
167
+ margin: '25%',
168
+ // Works only position is 'outer' and alignTo is not 'edge'.
169
+ bleedMargin: 10,
170
+ // Distance between text and label line.
171
+ distanceToLabelLine: 5
151
172
  // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
152
173
  // 默认使用全局文本样式,详见TEXTSTYLE
153
174
  // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
@@ -171,7 +171,7 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
171
171
  toggleItemSelected(
172
172
  this,
173
173
  data.getItemLayout(idx),
174
- seriesModel.isSelected(null, idx),
174
+ seriesModel.isSelected(data.getName(idx)),
175
175
  seriesModel.get('selectedOffset'),
176
176
  seriesModel.get('animation')
177
177
  );
@@ -180,31 +180,36 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
180
180
  var withAnimation = !firstCreate && animationTypeUpdate === 'transition';
181
181
  this._updateLabel(data, idx, withAnimation);
182
182
 
183
- this.highDownOnUpdate = (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled())
183
+ this.highDownOnUpdate = !seriesModel.get('silent')
184
184
  ? function (fromState, toState) {
185
+ var hasAnimation = seriesModel.isAnimationEnabled() && itemModel.get('hoverAnimation');
185
186
  if (toState === 'emphasis') {
186
187
  labelLine.ignore = labelLine.hoverIgnore;
187
188
  labelText.ignore = labelText.hoverIgnore;
188
189
 
189
190
  // Sector may has animation of updating data. Force to move to the last frame
190
191
  // Or it may stopped on the wrong shape
191
- sector.stopAnimation(true);
192
- sector.animateTo({
193
- shape: {
194
- r: layout.r + seriesModel.get('hoverOffset')
195
- }
196
- }, 300, 'elasticOut');
192
+ if (hasAnimation) {
193
+ sector.stopAnimation(true);
194
+ sector.animateTo({
195
+ shape: {
196
+ r: layout.r + seriesModel.get('hoverOffset')
197
+ }
198
+ }, 300, 'elasticOut');
199
+ }
197
200
  }
198
201
  else {
199
202
  labelLine.ignore = labelLine.normalIgnore;
200
203
  labelText.ignore = labelText.normalIgnore;
201
204
 
202
- sector.stopAnimation(true);
203
- sector.animateTo({
204
- shape: {
205
- r: layout.r
206
- }
207
- }, 300, 'elasticOut');
205
+ if (hasAnimation) {
206
+ sector.stopAnimation(true);
207
+ sector.animateTo({
208
+ shape: {
209
+ r: layout.r
210
+ }
211
+ }, 300, 'elasticOut');
212
+ }
208
213
  }
209
214
  }
210
215
  : null;
@@ -273,7 +278,7 @@ piePieceProto._updateLabel = function (data, idx, withAnimation) {
273
278
  {
274
279
  labelFetcher: data.hostModel,
275
280
  labelDataIndex: idx,
276
- defaultText: data.getName(idx),
281
+ defaultText: labelLayout.text,
277
282
  autoColor: visualColor,
278
283
  useInsideStyle: !!labelLayout.inside
279
284
  },
@@ -20,16 +20,21 @@
20
20
  // FIXME emphasis label position is not same with normal label position
21
21
 
22
22
  import * as textContain from 'zrender/src/contain/text';
23
+ import {parsePercent} from '../../util/number';
23
24
 
24
25
  var RADIAN = Math.PI / 180;
25
26
 
26
- function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
27
+ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
27
28
  list.sort(function (a, b) {
28
29
  return a.y - b.y;
29
30
  });
30
31
 
31
32
  function shiftDown(start, end, delta, dir) {
32
33
  for (var j = start; j < end; j++) {
34
+ if (list[j].y + delta > viewTop + viewHeight) {
35
+ break;
36
+ }
37
+
33
38
  list[j].y += delta;
34
39
  if (j > start
35
40
  && j + 1 < end
@@ -45,6 +50,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
45
50
 
46
51
  function shiftUp(end, delta) {
47
52
  for (var j = end; j >= 0; j--) {
53
+ if (list[j].y - delta < viewTop) {
54
+ break;
55
+ }
56
+
48
57
  list[j].y -= delta;
49
58
  if (j > 0
50
59
  && list[j].y > list[j - 1].y + list[j - 1].height
@@ -64,6 +73,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
64
73
  : 0; // up
65
74
 
66
75
  for (var i = 0, l = list.length; i < l; i++) {
76
+ if (list[i].labelAlignTo !== 'none') {
77
+ continue;
78
+ }
79
+
67
80
  var deltaY = Math.abs(list[i].y - cy);
68
81
  var length = list[i].len;
69
82
  var length2 = list[i].len2;
@@ -93,6 +106,12 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
93
106
  var upList = [];
94
107
  var downList = [];
95
108
  for (var i = 0; i < len; i++) {
109
+ if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
110
+ var dx = list[i].x - farthestX;
111
+ list[i].linePoints[1][0] += dx;
112
+ list[i].x = farthestX;
113
+ }
114
+
96
115
  delta = list[i].y - lastY;
97
116
  if (delta < 0) {
98
117
  shiftDown(i, len, -delta, dir);
@@ -114,39 +133,85 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
114
133
  changeX(downList, true, cx, cy, r, dir);
115
134
  }
116
135
 
117
- function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
136
+ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
118
137
  var leftList = [];
119
138
  var rightList = [];
139
+ var leftmostX = Number.MAX_VALUE;
140
+ var rightmostX = -Number.MAX_VALUE;
120
141
  for (var i = 0; i < labelLayoutList.length; i++) {
121
142
  if (isPositionCenter(labelLayoutList[i])) {
122
143
  continue;
123
144
  }
124
145
  if (labelLayoutList[i].x < cx) {
146
+ leftmostX = Math.min(leftmostX, labelLayoutList[i].x);
125
147
  leftList.push(labelLayoutList[i]);
126
148
  }
127
149
  else {
150
+ rightmostX = Math.max(rightmostX, labelLayoutList[i].x);
128
151
  rightList.push(labelLayoutList[i]);
129
152
  }
130
153
  }
131
154
 
132
- adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
133
- adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
155
+ adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
156
+ adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
134
157
 
135
158
  for (var i = 0; i < labelLayoutList.length; i++) {
136
- if (isPositionCenter(labelLayoutList[i])) {
159
+ var layout = labelLayoutList[i];
160
+ if (isPositionCenter(layout)) {
137
161
  continue;
138
162
  }
139
- var linePoints = labelLayoutList[i].linePoints;
163
+
164
+ var linePoints = layout.linePoints;
140
165
  if (linePoints) {
166
+ var isAlignToEdge = layout.labelAlignTo === 'edge';
167
+
168
+ var realTextWidth = layout.textRect.width;
169
+ var targetTextWidth;
170
+ if (isAlignToEdge) {
171
+ if (layout.x < cx) {
172
+ targetTextWidth = linePoints[2][0] - layout.labelDistance
173
+ - viewLeft - layout.labelMargin;
174
+ }
175
+ else {
176
+ targetTextWidth = viewLeft + viewWidth - layout.labelMargin
177
+ - linePoints[2][0] - layout.labelDistance;
178
+ }
179
+ }
180
+ else {
181
+ if (layout.x < cx) {
182
+ targetTextWidth = layout.x - viewLeft - layout.bleedMargin;
183
+ }
184
+ else {
185
+ targetTextWidth = viewLeft + viewWidth - layout.x - layout.bleedMargin;
186
+ }
187
+ }
188
+ if (targetTextWidth < layout.textRect.width) {
189
+ layout.text = textContain.truncateText(layout.text, targetTextWidth, layout.font);
190
+ if (layout.labelAlignTo === 'edge') {
191
+ realTextWidth = textContain.getWidth(layout.text, layout.font);
192
+ }
193
+ }
194
+
141
195
  var dist = linePoints[1][0] - linePoints[2][0];
142
- if (labelLayoutList[i].x < cx) {
143
- linePoints[2][0] = labelLayoutList[i].x + 3;
196
+ if (isAlignToEdge) {
197
+ if (layout.x < cx) {
198
+ linePoints[2][0] = viewLeft + layout.labelMargin + realTextWidth + layout.labelDistance;
199
+ }
200
+ else {
201
+ linePoints[2][0] = viewLeft + viewWidth - layout.labelMargin
202
+ - realTextWidth - layout.labelDistance;
203
+ }
144
204
  }
145
205
  else {
146
- linePoints[2][0] = labelLayoutList[i].x - 3;
206
+ if (layout.x < cx) {
207
+ linePoints[2][0] = layout.x + layout.labelDistance;
208
+ }
209
+ else {
210
+ linePoints[2][0] = layout.x - layout.labelDistance;
211
+ }
212
+ linePoints[1][0] = linePoints[2][0] + dist;
147
213
  }
148
- linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
149
- linePoints[1][0] = linePoints[2][0] + dist;
214
+ linePoints[1][1] = linePoints[2][1] = layout.y;
150
215
  }
151
216
  }
152
217
  }
@@ -156,7 +221,7 @@ function isPositionCenter(layout) {
156
221
  return layout.position === 'center';
157
222
  }
158
223
 
159
- export default function (seriesModel, r, viewWidth, viewHeight, sum) {
224
+ export default function (seriesModel, r, viewWidth, viewHeight, viewLeft, viewTop) {
160
225
  var data = seriesModel.getData();
161
226
  var labelLayoutList = [];
162
227
  var cx;
@@ -171,10 +236,17 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
171
236
  var labelModel = itemModel.getModel('label');
172
237
  // Use position in normal or emphasis
173
238
  var labelPosition = labelModel.get('position') || itemModel.get('emphasis.label.position');
239
+ var labelDistance = labelModel.get('distanceToLabelLine');
240
+ var labelAlignTo = labelModel.get('alignTo');
241
+ var labelMargin = parsePercent(labelModel.get('margin'), viewWidth);
242
+ var bleedMargin = labelModel.get('bleedMargin');
243
+ var font = labelModel.getFont();
174
244
 
175
245
  var labelLineModel = itemModel.getModel('labelLine');
176
246
  var labelLineLen = labelLineModel.get('length');
247
+ labelLineLen = parsePercent(labelLineLen, viewWidth);
177
248
  var labelLineLen2 = labelLineModel.get('length2');
249
+ labelLineLen2 = parsePercent(labelLineLen2, viewWidth);
178
250
 
179
251
  if (layout.angle < minShowLabelRadian) {
180
252
  return;
@@ -192,6 +264,12 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
192
264
  cx = layout.cx;
193
265
  cy = layout.cy;
194
266
 
267
+ var text = seriesModel.getFormattedLabel(idx, 'normal')
268
+ || data.getName(idx);
269
+ var textRect = textContain.getBoundingRect(
270
+ text, font, textAlign, 'top'
271
+ );
272
+
195
273
  var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
196
274
  if (labelPosition === 'center') {
197
275
  textX = layout.cx;
@@ -212,14 +290,25 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
212
290
  var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
213
291
  var y3 = y2;
214
292
 
215
- textX = x3 + (dx < 0 ? -5 : 5);
293
+ if (labelAlignTo === 'edge') {
294
+ // Adjust textX because text align of edge is opposite
295
+ textX = dx < 0
296
+ ? viewLeft + labelMargin
297
+ : viewLeft + viewWidth - labelMargin;
298
+ }
299
+ else {
300
+ textX = x3 + (dx < 0 ? -labelDistance : labelDistance);
301
+ }
216
302
  textY = y3;
217
303
  linePoints = [[x1, y1], [x2, y2], [x3, y3]];
218
304
  }
219
305
 
220
- textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
306
+ textAlign = isLabelInside
307
+ ? 'center'
308
+ : (labelAlignTo === 'edge'
309
+ ? (dx > 0 ? 'right' : 'left')
310
+ : (dx > 0 ? 'left' : 'right'));
221
311
  }
222
- var font = labelModel.getFont();
223
312
 
224
313
  var labelRotate;
225
314
  var rotate = labelModel.get('rotate');
@@ -231,11 +320,7 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
231
320
  ? (dx < 0 ? -midAngle + Math.PI : -midAngle)
232
321
  : 0;
233
322
  }
234
- var text = seriesModel.getFormattedLabel(idx, 'normal')
235
- || data.getName(idx);
236
- var textRect = textContain.getBoundingRect(
237
- text, font, textAlign, 'top'
238
- );
323
+
239
324
  hasLabelRotate = !!labelRotate;
240
325
  layout.label = {
241
326
  x: textX,
@@ -248,7 +333,14 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
248
333
  textAlign: textAlign,
249
334
  verticalAlign: 'middle',
250
335
  rotation: labelRotate,
251
- inside: isLabelInside
336
+ inside: isLabelInside,
337
+ labelDistance: labelDistance,
338
+ labelAlignTo: labelAlignTo,
339
+ labelMargin: labelMargin,
340
+ bleedMargin: bleedMargin,
341
+ textRect: textRect,
342
+ text: text,
343
+ font: font
252
344
  };
253
345
 
254
346
  // Not layout the inside label
@@ -257,6 +349,6 @@ export default function (seriesModel, r, viewWidth, viewHeight, sum) {
257
349
  }
258
350
  });
259
351
  if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
260
- avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
352
+ avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
261
353
  }
262
354
  }
@@ -19,16 +19,27 @@
19
19
 
20
20
 
21
21
  import {parsePercent, linearMap} from '../../util/number';
22
+ import * as layout from '../../util/layout';
22
23
  import labelLayout from './labelLayout';
23
24
  import * as zrUtil from 'zrender/src/core/util';
24
25
 
25
26
  var PI2 = Math.PI * 2;
26
27
  var RADIAN = Math.PI / 180;
27
28
 
29
+ function getViewRect(seriesModel, api) {
30
+ return layout.getLayoutRect(
31
+ seriesModel.getBoxLayoutParams(), {
32
+ width: api.getWidth(),
33
+ height: api.getHeight()
34
+ }
35
+ );
36
+ }
37
+
28
38
  export default function (seriesType, ecModel, api, payload) {
29
39
  ecModel.eachSeriesByType(seriesType, function (seriesModel) {
30
40
  var data = seriesModel.getData();
31
41
  var valueDim = data.mapDimension('value');
42
+ var viewRect = getViewRect(seriesModel, api);
32
43
 
33
44
  var center = seriesModel.get('center');
34
45
  var radius = seriesModel.get('radius');
@@ -40,11 +51,11 @@ export default function (seriesType, ecModel, api, payload) {
40
51
  center = [center, center];
41
52
  }
42
53
 
43
- var width = api.getWidth();
44
- var height = api.getHeight();
54
+ var width = parsePercent(viewRect.width, api.getWidth());
55
+ var height = parsePercent(viewRect.height, api.getHeight());
45
56
  var size = Math.min(width, height);
46
- var cx = parsePercent(center[0], width);
47
- var cy = parsePercent(center[1], height);
57
+ var cx = parsePercent(center[0], width) + viewRect.x;
58
+ var cy = parsePercent(center[1], height) + viewRect.y;
48
59
  var r0 = parsePercent(radius[0], size / 2);
49
60
  var r = parsePercent(radius[1], size / 2);
50
61
 
@@ -90,7 +101,8 @@ export default function (seriesType, ecModel, api, payload) {
90
101
  r0: r0,
91
102
  r: roseType
92
103
  ? NaN
93
- : r
104
+ : r,
105
+ viewRect: viewRect
94
106
  });
95
107
  return;
96
108
  }
@@ -123,7 +135,8 @@ export default function (seriesType, ecModel, api, payload) {
123
135
  r0: r0,
124
136
  r: roseType
125
137
  ? linearMap(value, extent, [r0, r])
126
- : r
138
+ : r,
139
+ viewRect: viewRect
127
140
  });
128
141
 
129
142
  currentAngle = endAngle;
@@ -161,6 +174,6 @@ export default function (seriesType, ecModel, api, payload) {
161
174
  }
162
175
  }
163
176
 
164
- labelLayout(seriesModel, r, width, height);
177
+ labelLayout(seriesModel, r, viewRect.width, viewRect.height, viewRect.x, viewRect.y);
165
178
  });
166
179
  }