echarts 3.6.1 → 3.7.2

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 (321) hide show
  1. package/README.md +1 -0
  2. package/dist/echarts-en.js +77756 -0
  3. package/dist/echarts-en.min.js +38 -0
  4. package/dist/echarts.common-en.js +50169 -0
  5. package/dist/echarts.common-en.min.js +30 -0
  6. package/dist/echarts.common.js +5799 -3093
  7. package/dist/echarts.common.min.js +14 -13
  8. package/dist/echarts.js +7628 -4679
  9. package/dist/echarts.min.js +22 -22
  10. package/dist/echarts.simple-en.js +34988 -0
  11. package/dist/echarts.simple-en.min.js +27 -0
  12. package/dist/echarts.simple.js +4472 -2493
  13. package/dist/echarts.simple.min.js +11 -9
  14. package/dist/extension/bmap.js +50 -11
  15. package/dist/extension/bmap.min.js +1 -1
  16. package/dist/extension/dataTool.js +10 -10
  17. package/extension/bmap/BMapCoordSys.js +40 -1
  18. package/index.blank.js +4 -0
  19. package/index.common.js +1 -1
  20. package/index.js +1 -1
  21. package/lib/action/createDataSelectAction.js +6 -2
  22. package/lib/chart/bar/BarView.js +6 -3
  23. package/lib/chart/bar/BaseBarSeries.js +4 -3
  24. package/lib/chart/bar/PictorialBarSeries.js +1 -1
  25. package/lib/chart/bar/PictorialBarView.js +29 -7
  26. package/lib/chart/bar/helper.js +14 -31
  27. package/lib/chart/candlestick/candlestickLayout.js +49 -6
  28. package/lib/chart/chord/chordCircularLayout.js +2 -2
  29. package/lib/chart/custom.js +135 -21
  30. package/lib/chart/funnel/FunnelSeries.js +0 -1
  31. package/lib/chart/funnel/FunnelView.js +15 -22
  32. package/lib/chart/funnel/funnelLayout.js +1 -1
  33. package/lib/chart/gauge/GaugeSeries.js +7 -12
  34. package/lib/chart/gauge/GaugeView.js +32 -53
  35. package/lib/chart/graph/GraphSeries.js +2 -1
  36. package/lib/chart/graph/GraphView.js +39 -45
  37. package/lib/chart/graph/forceHelper.js +5 -0
  38. package/lib/chart/graph/forceLayout.js +1 -1
  39. package/lib/chart/heatmap/HeatmapLayer.js +7 -0
  40. package/lib/chart/heatmap/HeatmapView.js +10 -9
  41. package/lib/chart/helper/EffectSymbol.js +3 -3
  42. package/lib/chart/helper/LargeSymbolDraw.js +6 -1
  43. package/lib/chart/helper/Line.js +40 -22
  44. package/lib/chart/helper/Symbol.js +20 -7
  45. package/lib/chart/helper/SymbolDraw.js +2 -1
  46. package/lib/chart/helper/labelHelper.js +0 -17
  47. package/lib/chart/helper/whiskerBoxCommon.js +11 -3
  48. package/lib/chart/line/LineSeries.js +1 -0
  49. package/lib/chart/line/LineView.js +14 -2
  50. package/lib/chart/line/poly.js +5 -0
  51. package/lib/chart/lines/LinesView.js +22 -7
  52. package/lib/chart/map/MapSeries.js +3 -7
  53. package/lib/chart/map/MapView.js +29 -18
  54. package/lib/chart/pie/PieSeries.js +20 -6
  55. package/lib/chart/pie/PieView.js +20 -23
  56. package/lib/chart/pie/labelLayout.js +3 -3
  57. package/lib/chart/radar/RadarView.js +16 -20
  58. package/lib/chart/sankey/SankeySeries.js +2 -4
  59. package/lib/chart/sankey/SankeyView.js +13 -29
  60. package/lib/chart/sankey/sankeyLayout.js +1 -1
  61. package/lib/chart/scatter/ScatterSeries.js +2 -1
  62. package/lib/chart/themeRiver/ThemeRiverSeries.js +2 -4
  63. package/lib/chart/themeRiver/ThemeRiverView.js +2 -5
  64. package/lib/chart/themeRiver/themeRiverLayout.js +1 -1
  65. package/lib/chart/treemap/Breadcrumb.js +1 -1
  66. package/lib/chart/treemap/TreemapSeries.js +28 -8
  67. package/lib/chart/treemap/TreemapView.js +88 -77
  68. package/lib/chart/treemap/treemapLayout.js +29 -13
  69. package/lib/component/axis/AngleAxisView.js +13 -19
  70. package/lib/component/axis/AxisBuilder.js +260 -186
  71. package/lib/component/axis/CartesianAxisView.js +15 -3
  72. package/lib/component/axis/ParallelAxisView.js +1 -1
  73. package/lib/component/axis/RadiusAxisView.js +1 -1
  74. package/lib/component/axis/SingleAxisView.js +8 -2
  75. package/lib/component/axis/cartesianAxisHelper.js +11 -15
  76. package/lib/component/axisPointer/AxisPointerModel.js +1 -3
  77. package/lib/component/axisPointer/BaseAxisPointer.js +15 -38
  78. package/lib/component/axisPointer/axisTrigger.js +36 -20
  79. package/lib/component/axisPointer/modelHelper.js +3 -4
  80. package/lib/component/axisPointer/viewHelper.js +4 -6
  81. package/lib/component/axisPointer.js +1 -14
  82. package/lib/component/calendar/CalendarView.js +22 -39
  83. package/lib/component/dataZoom/AxisProxy.js +3 -2
  84. package/lib/component/dataZoom/DataZoomModel.js +16 -4
  85. package/lib/component/dataZoom/InsideZoomView.js +5 -3
  86. package/lib/component/dataZoom/SliderZoomView.js +21 -32
  87. package/lib/component/dataZoom/roams.js +33 -9
  88. package/lib/component/dataZoom/typeDefaulter.js +1 -1
  89. package/lib/component/graphic.js +17 -5
  90. package/lib/component/helper/BrushTargetManager.js +1 -1
  91. package/lib/component/helper/MapDraw.js +26 -22
  92. package/lib/component/helper/RoamController.js +12 -11
  93. package/lib/component/helper/listComponent.js +27 -24
  94. package/lib/component/helper/selectableMixin.js +40 -15
  95. package/lib/component/legend/LegendModel.js +11 -3
  96. package/lib/component/legend/LegendView.js +151 -70
  97. package/lib/component/legend/ScrollableLegendModel.js +75 -0
  98. package/lib/component/legend/ScrollableLegendView.js +367 -0
  99. package/lib/component/legend/legendAction.js +1 -0
  100. package/lib/component/legend/scrollableLegendAction.js +24 -0
  101. package/lib/component/legend.js +8 -3
  102. package/lib/component/legendScroll.js +11 -0
  103. package/lib/component/marker/MarkAreaView.js +12 -26
  104. package/lib/component/marker/MarkLineView.js +5 -5
  105. package/lib/component/marker/MarkPointView.js +4 -4
  106. package/lib/component/marker/MarkerModel.js +1 -4
  107. package/lib/component/marker/markerHelper.js +1 -0
  108. package/lib/component/radar/RadarView.js +6 -3
  109. package/lib/component/timeline/SliderTimelineModel.js +4 -6
  110. package/lib/component/timeline/SliderTimelineView.js +14 -16
  111. package/lib/component/timeline/TimelineAxis.js +1 -1
  112. package/lib/component/timeline/TimelineModel.js +1 -3
  113. package/lib/component/title.js +9 -10
  114. package/lib/component/toolbox/ToolboxModel.js +2 -0
  115. package/lib/component/toolbox/ToolboxView.js +15 -27
  116. package/lib/component/toolbox/feature/Brush.js +3 -8
  117. package/lib/component/toolbox/feature/DataView.js +5 -5
  118. package/lib/component/toolbox/feature/DataZoom.js +3 -4
  119. package/lib/component/toolbox/feature/MagicType.js +3 -6
  120. package/lib/component/toolbox/feature/Restore.js +2 -1
  121. package/lib/component/toolbox/feature/SaveAsImage.js +23 -9
  122. package/lib/component/tooltip/TooltipContent.js +4 -4
  123. package/lib/component/tooltip/TooltipView.js +29 -6
  124. package/lib/component/visualMap/ContinuousModel.js +2 -2
  125. package/lib/component/visualMap/ContinuousView.js +12 -8
  126. package/lib/component/visualMap/PiecewiseModel.js +1 -2
  127. package/lib/component/visualMap/PiecewiseView.js +2 -2
  128. package/lib/component/visualMap/VisualMapModel.js +18 -12
  129. package/lib/coord/Axis.js +1 -1
  130. package/lib/coord/axisDefault.js +3 -3
  131. package/lib/coord/axisHelper.js +18 -1
  132. package/lib/coord/axisModelCommonMixin.js +12 -2
  133. package/lib/coord/calendar/Calendar.js +65 -21
  134. package/lib/coord/calendar/CalendarModel.js +6 -12
  135. package/lib/coord/cartesian/Cartesian2D.js +0 -14
  136. package/lib/coord/cartesian/Grid.js +47 -28
  137. package/lib/coord/geo/Geo.js +2 -18
  138. package/lib/coord/geo/GeoModel.js +6 -13
  139. package/lib/coord/geo/fix/diaoyuIsland.js +30 -0
  140. package/lib/coord/geo/geoCreator.js +6 -1
  141. package/lib/coord/polar/Polar.js +0 -13
  142. package/lib/coord/radar/Radar.js +1 -1
  143. package/lib/coord/radar/RadarModel.js +6 -2
  144. package/lib/data/DataDiffer.js +14 -7
  145. package/lib/data/Graph.js +3 -0
  146. package/lib/data/List.js +1 -1
  147. package/lib/data/Tree.js +2 -2
  148. package/lib/data/helper/completeDimensions.js +2 -11
  149. package/lib/echarts.js +33 -10
  150. package/lib/lang/cn.js +4 -0
  151. package/lib/lang/default.js +42 -0
  152. package/lib/lang/en.js +42 -0
  153. package/lib/lang.js +42 -0
  154. package/lib/langEN.js +42 -0
  155. package/lib/layout/barGrid.js +11 -3
  156. package/lib/layout/barPolar.js +9 -2
  157. package/lib/model/Model.js +2 -1
  158. package/lib/model/Series.js +14 -6
  159. package/lib/model/mixin/textStyle.js +11 -9
  160. package/lib/preprocessor/backwardCompat.js +5 -4
  161. package/lib/preprocessor/helper/compatStyle.js +157 -45
  162. package/lib/scale/Interval.js +10 -4
  163. package/lib/scale/Time.js +14 -6
  164. package/lib/scale/helper.js +15 -2
  165. package/lib/util/format.js +4 -24
  166. package/lib/util/graphic.js +412 -21
  167. package/lib/util/layout.js +28 -16
  168. package/lib/util/model.js +26 -11
  169. package/lib/util/number.js +106 -21
  170. package/lib/visual/VisualMapping.js +4 -4
  171. package/package.json +3 -3
  172. package/rollup.config.js +49 -0
  173. package/src/action/createDataSelectAction.js +6 -2
  174. package/src/chart/bar/BarView.js +6 -3
  175. package/src/chart/bar/BaseBarSeries.js +4 -3
  176. package/src/chart/bar/PictorialBarSeries.js +1 -1
  177. package/src/chart/bar/PictorialBarView.js +29 -7
  178. package/src/chart/bar/helper.js +13 -30
  179. package/src/chart/candlestick/candlestickLayout.js +49 -6
  180. package/src/chart/chord/chordCircularLayout.js +2 -2
  181. package/src/chart/custom.js +135 -21
  182. package/src/chart/funnel/FunnelSeries.js +0 -1
  183. package/src/chart/funnel/FunnelView.js +15 -22
  184. package/src/chart/funnel/funnelLayout.js +1 -1
  185. package/src/chart/gauge/GaugeSeries.js +7 -12
  186. package/src/chart/gauge/GaugeView.js +32 -53
  187. package/src/chart/graph/GraphSeries.js +2 -1
  188. package/src/chart/graph/GraphView.js +39 -45
  189. package/src/chart/graph/forceHelper.js +5 -0
  190. package/src/chart/graph/forceLayout.js +1 -1
  191. package/src/chart/heatmap/HeatmapLayer.js +7 -0
  192. package/src/chart/heatmap/HeatmapView.js +10 -9
  193. package/src/chart/helper/EffectSymbol.js +3 -3
  194. package/src/chart/helper/LargeSymbolDraw.js +6 -1
  195. package/src/chart/helper/Line.js +40 -22
  196. package/src/chart/helper/Symbol.js +20 -7
  197. package/src/chart/helper/SymbolDraw.js +2 -1
  198. package/src/chart/helper/labelHelper.js +0 -17
  199. package/src/chart/helper/whiskerBoxCommon.js +11 -4
  200. package/src/chart/line/LineSeries.js +1 -0
  201. package/src/chart/line/LineView.js +14 -2
  202. package/src/chart/line/poly.js +5 -0
  203. package/src/chart/lines/LinesView.js +22 -7
  204. package/src/chart/map/MapSeries.js +3 -7
  205. package/src/chart/map/MapView.js +29 -18
  206. package/src/chart/pie/PieSeries.js +20 -6
  207. package/src/chart/pie/PieView.js +20 -23
  208. package/src/chart/pie/labelLayout.js +3 -3
  209. package/src/chart/radar/RadarView.js +16 -20
  210. package/src/chart/sankey/SankeySeries.js +2 -4
  211. package/src/chart/sankey/SankeyView.js +13 -29
  212. package/src/chart/sankey/sankeyLayout.js +1 -1
  213. package/src/chart/scatter/ScatterSeries.js +2 -1
  214. package/src/chart/themeRiver/ThemeRiverSeries.js +2 -4
  215. package/src/chart/themeRiver/ThemeRiverView.js +2 -5
  216. package/src/chart/themeRiver/themeRiverLayout.js +1 -1
  217. package/src/chart/treemap/Breadcrumb.js +1 -1
  218. package/src/chart/treemap/TreemapSeries.js +28 -8
  219. package/src/chart/treemap/TreemapView.js +88 -77
  220. package/src/chart/treemap/treemapLayout.js +29 -13
  221. package/src/component/axis/AngleAxisView.js +13 -19
  222. package/src/component/axis/AxisBuilder.js +260 -186
  223. package/src/component/axis/CartesianAxisView.js +15 -3
  224. package/src/component/axis/ParallelAxisView.js +1 -1
  225. package/src/component/axis/RadiusAxisView.js +1 -1
  226. package/src/component/axis/SingleAxisView.js +8 -2
  227. package/src/component/axis/cartesianAxisHelper.js +11 -15
  228. package/src/component/axisPointer/AxisPointerModel.js +1 -3
  229. package/src/component/axisPointer/BaseAxisPointer.js +15 -38
  230. package/src/component/axisPointer/axisTrigger.js +36 -20
  231. package/src/component/axisPointer/modelHelper.js +3 -4
  232. package/src/component/axisPointer/viewHelper.js +4 -6
  233. package/src/component/axisPointer.js +1 -14
  234. package/src/component/calendar/CalendarView.js +22 -39
  235. package/src/component/dataZoom/AxisProxy.js +3 -2
  236. package/src/component/dataZoom/DataZoomModel.js +16 -4
  237. package/src/component/dataZoom/InsideZoomView.js +5 -3
  238. package/src/component/dataZoom/SliderZoomView.js +21 -32
  239. package/src/component/dataZoom/roams.js +33 -9
  240. package/src/component/dataZoom/typeDefaulter.js +1 -1
  241. package/src/component/graphic.js +17 -5
  242. package/src/component/helper/BrushTargetManager.js +1 -1
  243. package/src/component/helper/MapDraw.js +26 -22
  244. package/src/component/helper/RoamController.js +12 -11
  245. package/src/component/helper/listComponent.js +27 -24
  246. package/src/component/helper/selectableMixin.js +40 -15
  247. package/src/component/legend/LegendModel.js +11 -3
  248. package/src/component/legend/LegendView.js +151 -70
  249. package/src/component/legend/ScrollableLegendModel.js +76 -0
  250. package/src/component/legend/ScrollableLegendView.js +368 -0
  251. package/src/component/legend/legendAction.js +1 -0
  252. package/src/component/legend/scrollableLegendAction.js +25 -0
  253. package/src/component/legend.js +8 -3
  254. package/src/component/legendScroll.js +12 -0
  255. package/src/component/marker/MarkAreaView.js +12 -26
  256. package/src/component/marker/MarkLineView.js +5 -5
  257. package/src/component/marker/MarkPointView.js +4 -4
  258. package/src/component/marker/MarkerModel.js +1 -4
  259. package/src/component/marker/markerHelper.js +1 -0
  260. package/src/component/radar/RadarView.js +6 -3
  261. package/src/component/timeline/SliderTimelineModel.js +4 -6
  262. package/src/component/timeline/SliderTimelineView.js +14 -16
  263. package/src/component/timeline/TimelineAxis.js +1 -1
  264. package/src/component/timeline/TimelineModel.js +1 -3
  265. package/src/component/title.js +9 -10
  266. package/src/component/toolbox/ToolboxModel.js +2 -0
  267. package/src/component/toolbox/ToolboxView.js +15 -27
  268. package/src/component/toolbox/feature/Brush.js +3 -8
  269. package/src/component/toolbox/feature/DataView.js +5 -5
  270. package/src/component/toolbox/feature/DataZoom.js +3 -4
  271. package/src/component/toolbox/feature/MagicType.js +3 -6
  272. package/src/component/toolbox/feature/Restore.js +2 -1
  273. package/src/component/toolbox/feature/SaveAsImage.js +23 -10
  274. package/src/component/tooltip/TooltipContent.js +4 -4
  275. package/src/component/tooltip/TooltipView.js +29 -7
  276. package/src/component/visualMap/ContinuousModel.js +2 -2
  277. package/src/component/visualMap/ContinuousView.js +12 -8
  278. package/src/component/visualMap/PiecewiseModel.js +1 -2
  279. package/src/component/visualMap/PiecewiseView.js +2 -2
  280. package/src/component/visualMap/VisualMapModel.js +18 -12
  281. package/src/coord/Axis.js +1 -1
  282. package/src/coord/axisDefault.js +3 -3
  283. package/src/coord/axisHelper.js +18 -1
  284. package/src/coord/axisModelCommonMixin.js +12 -2
  285. package/src/coord/calendar/Calendar.js +65 -21
  286. package/src/coord/calendar/CalendarModel.js +6 -12
  287. package/src/coord/cartesian/Cartesian2D.js +0 -14
  288. package/src/coord/cartesian/Grid.js +47 -28
  289. package/src/coord/geo/Geo.js +2 -18
  290. package/src/coord/geo/GeoModel.js +6 -13
  291. package/src/coord/geo/fix/diaoyuIsland.js +30 -0
  292. package/src/coord/geo/geoCreator.js +6 -1
  293. package/src/coord/polar/Polar.js +0 -13
  294. package/src/coord/radar/Radar.js +1 -1
  295. package/src/coord/radar/RadarModel.js +6 -2
  296. package/src/data/DataDiffer.js +14 -7
  297. package/src/data/Graph.js +3 -0
  298. package/src/data/List.js +1 -1
  299. package/src/data/Tree.js +2 -2
  300. package/src/data/helper/completeDimensions.js +2 -11
  301. package/src/echarts.js +33 -10
  302. package/src/lang.js +43 -0
  303. package/src/langEN.js +43 -0
  304. package/src/layout/barGrid.js +11 -3
  305. package/src/layout/barPolar.js +9 -2
  306. package/src/model/Model.js +2 -1
  307. package/src/model/Series.js +14 -6
  308. package/src/model/mixin/textStyle.js +11 -9
  309. package/src/preprocessor/backwardCompat.js +5 -4
  310. package/src/preprocessor/helper/compatStyle.js +157 -45
  311. package/src/scale/Interval.js +10 -4
  312. package/src/scale/Time.js +14 -6
  313. package/src/scale/helper.js +15 -2
  314. package/src/util/format.js +4 -24
  315. package/src/util/graphic.js +412 -21
  316. package/src/util/layout.js +28 -16
  317. package/src/util/model.js +26 -11
  318. package/src/util/number.js +106 -21
  319. package/src/visual/VisualMapping.js +4 -4
  320. package/webpack.config.js +21 -7
  321. package/.npmignore +0 -10
@@ -96,20 +96,6 @@ define(function (require) {
96
96
 
97
97
  var piePieceProto = PiePiece.prototype;
98
98
 
99
- function getLabelStyle(data, idx, state, labelModel, labelPosition) {
100
- var textStyleModel = labelModel.getModel('textStyle');
101
- var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
102
- return {
103
- fill: textStyleModel.getTextColor()
104
- || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
105
- opacity: data.getItemVisual(idx, 'opacity'),
106
- textFont: textStyleModel.getFont(),
107
- text: zrUtil.retrieve(
108
- data.hostModel.getFormattedLabel(idx, state), data.getName(idx)
109
- )
110
- };
111
- }
112
-
113
99
  piePieceProto.updateData = function (data, idx, firstCreate) {
114
100
 
115
101
  var sector = this.childAt(0);
@@ -164,6 +150,9 @@ define(function (require) {
164
150
  );
165
151
  sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
166
152
 
153
+ var cursorStyle = itemModel.getShallow('cursor');
154
+ cursorStyle && sector.attr('cursor', cursorStyle);
155
+
167
156
  // Toggle selected
168
157
  toggleItemSelected(
169
158
  this,
@@ -179,7 +168,7 @@ define(function (require) {
179
168
  sector.stopAnimation(true);
180
169
  sector.animateTo({
181
170
  shape: {
182
- r: layout.r + 10
171
+ r: layout.r + seriesModel.get('hoverOffset')
183
172
  }
184
173
  }, 300, 'elasticOut');
185
174
  }
@@ -231,11 +220,6 @@ define(function (require) {
231
220
  }
232
221
  }, seriesModel, idx);
233
222
  labelText.attr({
234
- style: {
235
- textVerticalAlign: labelLayout.verticalAlign,
236
- textAlign: labelLayout.textAlign,
237
- textFont: labelLayout.font
238
- },
239
223
  rotation: labelLayout.rotation,
240
224
  origin: [labelLayout.x, labelLayout.y],
241
225
  z2: 10
@@ -245,9 +229,23 @@ define(function (require) {
245
229
  var labelHoverModel = itemModel.getModel('label.emphasis');
246
230
  var labelLineModel = itemModel.getModel('labelLine.normal');
247
231
  var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
248
- var labelPosition = labelModel.get('position') || labelHoverModel.get('position');
232
+ var visualColor = data.getItemVisual(idx, 'color');
249
233
 
250
- labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition));
234
+ graphic.setLabelStyle(
235
+ labelText.style, labelText.hoverStyle = {}, labelModel, labelHoverModel,
236
+ {
237
+ labelFetcher: data.hostModel,
238
+ labelDataIndex: idx,
239
+ defaultText: data.getName(idx),
240
+ autoColor: visualColor,
241
+ useInsideStyle: !!labelLayout.inside
242
+ },
243
+ {
244
+ textAlign: labelLayout.textAlign,
245
+ textVerticalAlign: labelLayout.verticalAlign,
246
+ opacity: data.getItemVisual(idx, 'opacity')
247
+ }
248
+ );
251
249
 
252
250
  labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
253
251
  labelText.hoverIgnore = !labelHoverModel.get('show');
@@ -262,7 +260,6 @@ define(function (require) {
262
260
  });
263
261
  labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
264
262
 
265
- labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition);
266
263
  labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
267
264
 
268
265
  var smooth = labelLineModel.get('smooth');
@@ -191,7 +191,7 @@ define(function (require) {
191
191
 
192
192
  textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
193
193
  }
194
- var font = labelModel.getModel('textStyle').getFont();
194
+ var font = labelModel.getFont();
195
195
 
196
196
  var labelRotate = labelModel.get('rotate')
197
197
  ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
@@ -211,8 +211,8 @@ define(function (require) {
211
211
  linePoints: linePoints,
212
212
  textAlign: textAlign,
213
213
  verticalAlign: 'middle',
214
- font: font,
215
- rotation: labelRotate
214
+ rotation: labelRotate,
215
+ inside: isLabelInside
216
216
  };
217
217
 
218
218
  // Not layout the inside label
@@ -26,15 +26,18 @@ define(function (require) {
26
26
  if (symbolType === 'none') {
27
27
  return;
28
28
  }
29
+ var symbolSize = normalizeSymbolSize(
30
+ data.getItemVisual(idx, 'symbolSize')
31
+ );
29
32
  var symbolPath = symbolUtil.createSymbol(
30
- symbolType, -0.5, -0.5, 1, 1, color
33
+ symbolType, -1, -1, 2, 2, color
31
34
  );
32
35
  symbolPath.attr({
33
36
  style: {
34
37
  strokeNoScale: true
35
38
  },
36
39
  z2: 100,
37
- scale: normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'))
40
+ scale: [symbolSize[0] / 2, symbolSize[1] / 2]
38
41
  });
39
42
  return symbolPath;
40
43
  }
@@ -171,24 +174,17 @@ define(function (require) {
171
174
  symbolPath.setStyle(itemStyle);
172
175
  symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
173
176
 
174
- var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
175
- graphic.setText(symbolPath.style, labelModel, color);
176
- symbolPath.setStyle({
177
- text: labelModel.get('show') ? zrUtil.retrieve(
178
- seriesModel.getFormattedLabel(
179
- idx, 'normal', null, symbolPath.__dimIdx
180
- ),
181
- defaultText
182
- ) : ''
183
- });
184
-
185
- graphic.setText(symbolPath.hoverStyle, labelHoverModel, color);
186
- symbolPath.hoverStyle.text = labelHoverModel.get('show') ? zrUtil.retrieve(
187
- seriesModel.getFormattedLabel(
188
- idx, 'emphasis', null, symbolPath.__dimIdx
189
- ),
190
- defaultText
191
- ) : '';
177
+ graphic.setLabelStyle(
178
+ symbolPath.style, symbolPath.hoverStyle, labelModel, labelHoverModel,
179
+ {
180
+ labelFetcher: data.hostModel,
181
+ labelDataIndex: idx,
182
+ labelDimIndex: symbolPath.__dimIdx,
183
+ defaultText: data.get(data.dimensions[symbolPath.__dimIdx], idx),
184
+ autoColor: color,
185
+ isRectText: true
186
+ }
187
+ );
192
188
  });
193
189
 
194
190
  function onEmphasis() {
@@ -92,10 +92,8 @@ define(function (require) {
92
92
  normal: {
93
93
  show: true,
94
94
  position: 'right',
95
- textStyle: {
96
- color: '#000',
97
- fontSize: 12
98
- }
95
+ color: '#000',
96
+ fontSize: 12
99
97
  },
100
98
  emphasis: {
101
99
  show: true
@@ -5,7 +5,6 @@
5
5
  define(function (require) {
6
6
 
7
7
  var graphic = require('../../util/graphic');
8
- var zrUtil = require('zrender/core/util');
9
8
 
10
9
  var SankeyShape = graphic.extendShape({
11
10
  shape: {
@@ -117,9 +116,7 @@ define(function (require) {
117
116
  var layout = node.getLayout();
118
117
  var itemModel = node.getModel();
119
118
  var labelModel = itemModel.getModel('label.normal');
120
- var textStyleModel = labelModel.getModel('textStyle');
121
119
  var labelHoverModel = itemModel.getModel('label.emphasis');
122
- var textStyleHoverModel = labelHoverModel.getModel('textStyle');
123
120
 
124
121
  var rect = new graphic.Rect({
125
122
  shape: {
@@ -128,37 +125,24 @@ define(function (require) {
128
125
  width: node.getLayout().dx,
129
126
  height: node.getLayout().dy
130
127
  },
131
- style: {
132
- // Get formatted label in label.normal option
133
- // Use node id if it is not specified
134
- text: labelModel.get('show')
135
- ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
136
- // Use empty string to hide the label
137
- : '',
138
- textFont: textStyleModel.getFont(),
139
- textFill: textStyleModel.getTextColor(),
140
- textPosition: labelModel.get('position')
141
- }
128
+ style: itemModel.getModel('itemStyle.normal').getItemStyle()
142
129
  });
143
130
 
144
- rect.setStyle(zrUtil.defaults(
145
- {
146
- fill: node.getVisual('color')
147
- },
148
- itemModel.getModel('itemStyle.normal').getItemStyle()
149
- ));
131
+ var hoverStyle = node.getModel('itemStyle.emphasis').getItemStyle();
150
132
 
151
- graphic.setHoverStyle(rect, zrUtil.extend(
152
- node.getModel('itemStyle.emphasis'),
133
+ graphic.setLabelStyle(
134
+ rect.style, hoverStyle, labelModel, labelHoverModel,
153
135
  {
154
- text: labelHoverModel.get('show')
155
- ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
156
- : '',
157
- textFont: textStyleHoverModel.getFont(),
158
- textFill: textStyleHoverModel.getTextColor(),
159
- textPosition: labelHoverModel.get('position')
136
+ labelFetcher: seriesModel,
137
+ labelDataIndex: node.dataIndex,
138
+ defaultText: node.id,
139
+ isRectText: true
160
140
  }
161
- ));
141
+ );
142
+
143
+ rect.setStyle('fill', node.getVisual('color'));
144
+
145
+ graphic.setHoverStyle(rect, hoverStyle);
162
146
 
163
147
  group.add(rect);
164
148
 
@@ -144,7 +144,7 @@ define(function (require) {
144
144
  * @param {module:echarts/data/Graph~Node} nodes node of sankey view
145
145
  * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
146
146
  * @param {number} height the whole height of the area to draw the view
147
- * @param {numbber} nodeGap the vertical distance between two nodes
147
+ * @param {number} nodeGap the vertical distance between two nodes
148
148
  * in the same column.
149
149
  * @param {number} iterations the number of iterations for the algorithm
150
150
  */
@@ -41,6 +41,7 @@ define(function (require) {
41
41
  large: false,
42
42
  // Available when large is true
43
43
  largeThreshold: 2000,
44
+ // cursor: null,
44
45
 
45
46
  // label: {
46
47
  // normal: {
@@ -49,7 +50,7 @@ define(function (require) {
49
50
  // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
50
51
  // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
51
52
  // 'inside'|'left'|'right'|'top'|'bottom'
52
- // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
53
+ // 默认使用全局文本样式,详见TEXTSTYLE
53
54
  // }
54
55
  // },
55
56
  itemStyle: {
@@ -294,10 +294,8 @@ define(function (require) {
294
294
  textAlign: 'right',
295
295
  show: true,
296
296
  position: 'left',
297
- textStyle: {
298
- color: '#000',
299
- fontSize: 11
300
- }
297
+ color: '#000',
298
+ fontSize: 11
301
299
  },
302
300
  emphasis: {
303
301
  show: true
@@ -129,15 +129,12 @@ define(function (require) {
129
129
 
130
130
  var hoverItemStyleModel = itemModel.getModel('itemStyle.emphasis');
131
131
  var itemStyleModel = itemModel.getModel('itemStyle.normal');
132
- var textStyleModel = labelModel.getModel('textStyle');
133
132
 
134
- text.setStyle({
133
+ graphic.setTextStyle(text.style, labelModel, {
135
134
  text: labelModel.get('show')
136
135
  ? seriesModel.getFormattedLabel(indices[j - 1], 'normal')
137
136
  || data.getName(indices[j - 1])
138
- : '',
139
- textFont: textStyleModel.getFont(),
140
- textAlign: labelModel.get('textAlign'),
137
+ : null,
141
138
  textVerticalAlign: 'middle'
142
139
  });
143
140
 
@@ -103,7 +103,7 @@ define(function (require) {
103
103
  * Inspired by Lee Byron's paper Stacked Graphs - Geometry & Aesthetics
104
104
  *
105
105
  * @param {Array.<Array>} data the points in each layer
106
- * @return {Array}
106
+ * @return {Object}
107
107
  */
108
108
  function computeBaseline(data) {
109
109
  var layerNum = data.length;
@@ -100,7 +100,7 @@
100
100
  if (totalWidth > availableSize.width) {
101
101
  totalWidth -= itemWidth - emptyItemWidth;
102
102
  itemWidth = emptyItemWidth;
103
- text = '';
103
+ text = null;
104
104
  }
105
105
 
106
106
  var el = new graphic.Polygon({
@@ -83,11 +83,34 @@ define(function(require) {
83
83
  label: {
84
84
  normal: {
85
85
  show: true,
86
+ // Do not use textDistance, for ellipsis rect just the same as treemap node rect.
87
+ distance: 0,
88
+ padding: 5,
86
89
  position: 'inside', // Can be [5, '5%'] or position stirng like 'insideTopLeft', ...
87
- textStyle: {
88
- color: '#fff',
89
- ellipsis: true
90
- }
90
+ // formatter: null,
91
+ color: '#fff',
92
+ ellipsis: true
93
+ // align
94
+ // verticalAlign
95
+ }
96
+ },
97
+ upperLabel: { // Label when node is parent.
98
+ normal: {
99
+ show: false,
100
+ position: [0, '50%'],
101
+ height: 20,
102
+ // formatter: null,
103
+ color: '#fff',
104
+ ellipsis: true,
105
+ // align: null,
106
+ verticalAlign: 'middle'
107
+ },
108
+ emphasis: {
109
+ show: true,
110
+ position: [0, '50%'],
111
+ color: '#fff',
112
+ ellipsis: true,
113
+ verticalAlign: 'middle'
91
114
  }
92
115
  },
93
116
  itemStyle: {
@@ -146,11 +169,8 @@ define(function(require) {
146
169
  * @override
147
170
  */
148
171
  getInitialData: function (option, ecModel) {
149
- var rootName = option.name;
150
- rootName == null && (rootName = option.name);
151
-
152
172
  // Create a virtual root.
153
- var root = {name: rootName, children: option.data};
173
+ var root = {name: option.name, children: option.data};
154
174
 
155
175
  completeTreeValue(root);
156
176
 
@@ -15,8 +15,10 @@
15
15
  var each = zrUtil.each;
16
16
 
17
17
  var DRAG_THRESHOLD = 3;
18
- var PATH_LABEL_NORMAL = ['label', 'normal'];
18
+ var PATH_LABEL_NOAMAL = ['label', 'normal'];
19
19
  var PATH_LABEL_EMPHASIS = ['label', 'emphasis'];
20
+ var PATH_UPPERLABEL_NORMAL = ['upperLabel', 'normal'];
21
+ var PATH_UPPERLABEL_EMPHASIS = ['upperLabel', 'emphasis'];
20
22
  var Z_BASE = 10; // Should bigger than every z.
21
23
  var Z_BG = 1;
22
24
  var Z_CONTENT = 2;
@@ -65,12 +67,6 @@
65
67
  * @private
66
68
  */
67
69
  this._state = 'ready';
68
-
69
- /**
70
- * @private
71
- * @type {boolean}
72
- */
73
- this._mayClick;
74
70
  },
75
71
 
76
72
  /**
@@ -156,7 +152,7 @@
156
152
  lastsForAnimation, willInvisibleEls
157
153
  );
158
154
 
159
- // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow),
155
+ // Notice: when thisTree and oldTree are the same tree (see list.cloneShallow),
160
156
  // the oldTree is actually losted, so we can not find all of the old graphic
161
157
  // elements from tree. So we use this stragegy: make element storage, move
162
158
  // from old storage to new storage, clear old storage.
@@ -395,8 +391,6 @@
395
391
  * @private
396
392
  */
397
393
  _onPan: function (dx, dy) {
398
- this._mayClick = false;
399
-
400
394
  if (this._state !== 'animating'
401
395
  && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
402
396
  ) {
@@ -429,8 +423,6 @@
429
423
  * @private
430
424
  */
431
425
  _onZoom: function (scale, mouseX, mouseY) {
432
- this._mayClick = false;
433
-
434
426
  if (this._state !== 'animating') {
435
427
  // These param must not be cached.
436
428
  var root = this.seriesModel.getData().tree.root;
@@ -478,25 +470,11 @@
478
470
  * @private
479
471
  */
480
472
  _initEvents: function (containerGroup) {
481
- // FIXME
482
- // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效,
483
- // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标,
484
- // 还是会触发click,期望是不触发。
485
-
486
- // Mousedown occurs when drag start, and mouseup occurs when drag end,
487
- // click event should not be triggered in that case.
488
-
489
- containerGroup.on('mousedown', function (e) {
490
- this._state === 'ready' && (this._mayClick = true);
491
- }, this);
492
- containerGroup.on('mouseup', function (e) {
493
- if (this._mayClick) {
494
- this._mayClick = false;
495
- this._state === 'ready' && onClick.call(this, e);
473
+ containerGroup.on('click', function (e) {
474
+ if (this._state !== 'ready') {
475
+ return;
496
476
  }
497
- }, this);
498
477
 
499
- function onClick(e) {
500
478
  var nodeClick = this.seriesModel.get('nodeClick', true);
501
479
 
502
480
  if (!nodeClick) {
@@ -524,7 +502,8 @@
524
502
  link && window.open(link, linkTarget);
525
503
  }
526
504
  }
527
- }
505
+
506
+ }, this);
528
507
  },
529
508
 
530
509
  /**
@@ -658,6 +637,9 @@
658
637
  return;
659
638
  }
660
639
 
640
+ // -------------------------------------------------------------------
641
+ // Start of closure variables available in "Procedures in renderNode".
642
+
661
643
  var thisLayout = thisNode.getLayout();
662
644
 
663
645
  if (!thisLayout || !thisLayout.isInView) {
@@ -666,11 +648,20 @@
666
648
 
667
649
  var thisWidth = thisLayout.width;
668
650
  var thisHeight = thisLayout.height;
651
+ var borderWidth = thisLayout.borderWidth;
669
652
  var thisInvisible = thisLayout.invisible;
670
653
 
671
654
  var thisRawIndex = thisNode.getRawIndex();
672
655
  var oldRawIndex = oldNode && oldNode.getRawIndex();
673
656
 
657
+ var thisViewChildren = thisNode.viewChildren;
658
+ var upperHeight = thisLayout.upperHeight;
659
+ var isParent = thisViewChildren && thisViewChildren.length;
660
+ var itemStyleEmphasisModel = thisNode.getModel('itemStyle.emphasis');
661
+
662
+ // End of closure ariables available in "Procedures in renderNode".
663
+ // -----------------------------------------------------------------
664
+
674
665
  // Node group
675
666
  var group = giveGraphic('nodeGroup', Group);
676
667
 
@@ -690,20 +681,12 @@
690
681
 
691
682
  // Background
692
683
  var bg = giveGraphic('background', Rect, depth, Z_BG);
693
- if (bg) {
694
- bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
695
- updateStyle(bg, function () {
696
- bg.setStyle('fill', thisNode.getVisual('borderColor', true));
697
- });
698
- group.add(bg);
699
- }
700
-
701
- var thisViewChildren = thisNode.viewChildren;
684
+ bg && renderBackground(group, bg, isParent && thisLayout.upperHeight);
702
685
 
703
686
  // No children, render content.
704
- if (!thisViewChildren || !thisViewChildren.length) {
687
+ if (!isParent) {
705
688
  var content = giveGraphic('content', Rect, depth, Z_CONTENT);
706
- content && renderContent(group);
689
+ content && renderContent(group, content);
707
690
  }
708
691
 
709
692
  return group;
@@ -712,12 +695,44 @@
712
695
  // | Procedures in renderNode |
713
696
  // ----------------------------
714
697
 
715
- function renderContent(group) {
698
+ function renderBackground(group, bg, useUpperLabel) {
699
+ // For tooltip.
700
+ bg.dataIndex = thisNode.dataIndex;
701
+ bg.seriesIndex = seriesModel.seriesIndex;
702
+
703
+ bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
704
+ var visualBorderColor = thisNode.getVisual('borderColor', true);
705
+ var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
706
+
707
+ updateStyle(bg, function () {
708
+ var normalStyle = {fill: visualBorderColor};
709
+ var emphasisStyle = {fill: emphasisBorderColor};
710
+
711
+ if (useUpperLabel) {
712
+ var upperLabelWidth = thisWidth - 2 * borderWidth;
713
+
714
+ prepareText(
715
+ normalStyle, emphasisStyle, visualBorderColor, upperLabelWidth, upperHeight,
716
+ {x: borderWidth, y: 0, width: upperLabelWidth, height: upperHeight}
717
+ );
718
+ }
719
+ // For old bg.
720
+ else {
721
+ normalStyle.text = emphasisStyle.text = null;
722
+ }
723
+
724
+ bg.setStyle(normalStyle);
725
+ graphic.setHoverStyle(bg, emphasisStyle);
726
+ });
727
+
728
+ group.add(bg);
729
+ }
730
+
731
+ function renderContent(group, content) {
716
732
  // For tooltip.
717
733
  content.dataIndex = thisNode.dataIndex;
718
734
  content.seriesIndex = seriesModel.seriesIndex;
719
735
 
720
- var borderWidth = thisLayout.borderWidth;
721
736
  var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
722
737
  var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
723
738
 
@@ -732,7 +747,7 @@
732
747
  var visualColor = thisNode.getVisual('color', true);
733
748
  updateStyle(content, function () {
734
749
  var normalStyle = {fill: visualColor};
735
- var emphasisStyle = thisNode.getModel('itemStyle.emphasis').getItemStyle();
750
+ var emphasisStyle = itemStyleEmphasisModel.getItemStyle();
736
751
 
737
752
  prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
738
753
 
@@ -761,50 +776,46 @@
761
776
  }
762
777
  }
763
778
 
764
- function prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight) {
779
+ function prepareText(normalStyle, emphasisStyle, visualColor, width, height, upperLabelRect) {
765
780
  var nodeModel = thisNode.getModel();
766
- var text = nodeModel.get('name');
767
- if (thisLayout.isLeafRoot) {
781
+ var text = zrUtil.retrieve(
782
+ seriesModel.getFormattedLabel(
783
+ thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'
784
+ ),
785
+ nodeModel.get('name')
786
+ );
787
+ if (!upperLabelRect && thisLayout.isLeafRoot) {
768
788
  var iconChar = seriesModel.get('drillDownIcon', true);
769
789
  text = iconChar ? iconChar + ' ' + text : text;
770
790
  }
771
791
 
772
- setText(
773
- text, normalStyle, nodeModel, PATH_LABEL_NORMAL,
774
- visualColor, contentWidth, contentHeight
792
+ var normalLabelModel = nodeModel.getModel(
793
+ upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
775
794
  );
776
- setText(
777
- text, emphasisStyle, nodeModel, PATH_LABEL_EMPHASIS,
778
- visualColor, contentWidth, contentHeight
795
+ var emphasisLabelModel = nodeModel.getModel(
796
+ upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS
779
797
  );
780
- }
781
798
 
782
- function setText(text, style, nodeModel, labelPath, visualColor, contentWidth, contentHeight) {
783
- var labelModel = nodeModel.getModel(labelPath);
784
- var labelTextStyleModel = labelModel.getModel('textStyle');
799
+ var isShow = normalLabelModel.getShallow('show');
785
800
 
786
- graphic.setText(style, labelModel, visualColor);
801
+ graphic.setLabelStyle(
802
+ normalStyle, emphasisStyle, normalLabelModel, emphasisLabelModel,
803
+ {
804
+ defaultText: isShow ? text : null,
805
+ autoColor: visualColor,
806
+ isRectText: true
807
+ }
808
+ );
787
809
 
788
- // text.align and text.baseline is not included by graphic.setText,
789
- // because in most cases the two attributes are not exposed to user,
790
- // except in treemap.
791
- style.textAlign = labelTextStyleModel.get('align');
792
- style.textVerticalAlign = labelTextStyleModel.get('baseline');
810
+ upperLabelRect && (normalStyle.textRect = zrUtil.clone(upperLabelRect));
793
811
 
794
- var textRect = labelTextStyleModel.getTextRect(text);
795
- if (!labelModel.getShallow('show') || textRect.height > contentHeight) {
796
- style.text = '';
797
- }
798
- else if (textRect.width > contentWidth) {
799
- style.text = labelTextStyleModel.get('ellipsis')
800
- ? labelTextStyleModel.truncateText(
801
- text, contentWidth, null, {minChar: 2}
802
- )
803
- : '';
804
- }
805
- else {
806
- style.text = text;
807
- }
812
+ normalStyle.truncate = (isShow && normalLabelModel.get('ellipsis'))
813
+ ? {
814
+ outerWidth: width,
815
+ outerHeight: height,
816
+ minChar: 2
817
+ }
818
+ : null;
808
819
  }
809
820
 
810
821
  function giveGraphic(storageName, Ctor, depth, z) {