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
@@ -13,6 +13,11 @@
13
13
  var retrieveValue = zrUtil.retrieve;
14
14
  var each = zrUtil.each;
15
15
 
16
+ var PATH_BORDER_WIDTH = ['itemStyle', 'normal', 'borderWidth'];
17
+ var PATH_GAP_WIDTH = ['itemStyle', 'normal', 'gapWidth'];
18
+ var PATH_UPPER_LABEL_SHOW = ['upperLabel', 'normal', 'show'];
19
+ var PATH_UPPER_LABEL_HEIGHT = ['upperLabel', 'normal', 'height'];
20
+
16
21
  /**
17
22
  * @public
18
23
  */
@@ -92,7 +97,7 @@
92
97
  each(viewAbovePath, function (node, index) {
93
98
  var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
94
99
  node.setLayout(zrUtil.extend(
95
- {dataExtent: [childValue, childValue], borderWidth: 0},
100
+ {dataExtent: [childValue, childValue], borderWidth: 0, upperHeight: 0},
96
101
  viewRootLayout
97
102
  ));
98
103
  });
@@ -146,16 +151,23 @@
146
151
  height = thisLayout.height;
147
152
 
148
153
  // Considering border and gap
149
- var itemStyleModel = node.getModel('itemStyle.normal');
150
- var borderWidth = itemStyleModel.get('borderWidth');
151
- var halfGapWidth = itemStyleModel.get('gapWidth') / 2;
154
+ var nodeModel = node.getModel();
155
+ var borderWidth = nodeModel.get(PATH_BORDER_WIDTH);
156
+ var halfGapWidth = nodeModel.get(PATH_GAP_WIDTH) / 2;
157
+ var upperLabelHeight = getUpperLabelHeight(nodeModel);
158
+ var upperHeight = Math.max(borderWidth, upperLabelHeight);
152
159
  var layoutOffset = borderWidth - halfGapWidth;
160
+ var layoutOffsetUpper = upperHeight - halfGapWidth;
153
161
  var nodeModel = node.getModel();
154
162
 
155
- node.setLayout({borderWidth: borderWidth}, true);
163
+ node.setLayout({
164
+ borderWidth: borderWidth,
165
+ upperHeight: upperHeight,
166
+ upperLabelHeight: upperLabelHeight
167
+ }, true);
156
168
 
157
169
  width = mathMax(width - 2 * layoutOffset, 0);
158
- height = mathMax(height - 2 * layoutOffset, 0);
170
+ height = mathMax(height - layoutOffset - layoutOffsetUpper, 0);
159
171
 
160
172
  var totalArea = width * height;
161
173
  var viewChildren = initChildren(
@@ -166,7 +178,7 @@
166
178
  return;
167
179
  }
168
180
 
169
- var rect = {x: layoutOffset, y: layoutOffset, width: width, height: height};
181
+ var rect = {x: layoutOffset, y: layoutOffsetUpper, width: width, height: height};
170
182
  var rowFixedLength = mathMin(width, height);
171
183
  var best = Infinity; // the best row score so far
172
184
  var row = [];
@@ -459,12 +471,12 @@
459
471
  }
460
472
  area *= sum / currNodeValue;
461
473
 
462
- var borderWidth = parent.getModel('itemStyle.normal').get('borderWidth');
463
-
464
- if (isFinite(borderWidth)) {
465
- // Considering border, suppose aspect ratio is 1.
466
- area += 4 * borderWidth * borderWidth + 4 * borderWidth * Math.pow(area, 0.5);
467
- }
474
+ // Considering border, suppose aspect ratio is 1.
475
+ var parentModel = parent.getModel();
476
+ var borderWidth = parentModel.get(PATH_BORDER_WIDTH);
477
+ var upperHeight = Math.max(borderWidth, getUpperLabelHeight(parentModel, borderWidth));
478
+ area += 4 * borderWidth * borderWidth
479
+ + (3 * borderWidth + upperHeight) * Math.pow(area, 0.5);
468
480
 
469
481
  area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
470
482
 
@@ -551,4 +563,8 @@
551
563
  });
552
564
  }
553
565
 
566
+ function getUpperLabelHeight(model) {
567
+ return model.get(PATH_UPPER_LABEL_SHOW) ? model.get(PATH_UPPER_LABEL_HEIGHT) : 0;
568
+ }
569
+
554
570
  module.exports = update;
@@ -105,8 +105,6 @@
105
105
  var categoryData = angleAxisModel.get('data');
106
106
 
107
107
  var labelModel = angleAxisModel.getModel('axisLabel');
108
- var axisTextStyleModel = labelModel.getModel('textStyle');
109
-
110
108
  var labels = angleAxisModel.getFormattedLabels();
111
109
 
112
110
  var labelMargin = labelModel.get('margin');
@@ -121,27 +119,23 @@
121
119
 
122
120
  var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
123
121
  ? 'center' : (p[0] > cx ? 'left' : 'right');
124
- var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3
122
+ var labelTextVerticalAlign = Math.abs(p[1] - cy) / r < 0.3
125
123
  ? 'middle' : (p[1] > cy ? 'top' : 'bottom');
126
124
 
127
- var textStyleModel = axisTextStyleModel;
128
125
  if (categoryData && categoryData[i] && categoryData[i].textStyle) {
129
- textStyleModel = new Model(
130
- categoryData[i].textStyle, axisTextStyleModel
131
- );
126
+ labelModel = new Model(categoryData[i].textStyle, labelModel, labelModel.ecModel);
132
127
  }
133
- this.group.add(new graphic.Text({
134
- style: {
135
- x: p[0],
136
- y: p[1],
137
- fill: textStyleModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
138
- text: labels[i],
139
- textAlign: labelTextAlign,
140
- textVerticalAlign: labelTextBaseline,
141
- textFont: textStyleModel.getFont()
142
- },
143
- silent: true
144
- }));
128
+
129
+ var textEl = new graphic.Text({silent: true});
130
+ this.group.add(textEl);
131
+ graphic.setTextStyle(textEl.style, labelModel, {
132
+ x: p[0],
133
+ y: p[1],
134
+ textFill: labelModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
135
+ text: labels[i],
136
+ textAlign: labelTextAlign,
137
+ textVerticalAlign: labelTextVerticalAlign
138
+ });
145
139
  }
146
140
  },
147
141
 
@@ -49,7 +49,7 @@
49
49
  * @param {Object} opt Standard axis parameters.
50
50
  * @param {Array.<number>} opt.position [x, y]
51
51
  * @param {number} opt.rotation by radian
52
- * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
52
+ * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'.
53
53
  * @param {number} [opt.tickDirection=1] 1 or -1
54
54
  * @param {number} [opt.labelDirection=1] 1 or -1
55
55
  * @param {number} [opt.labelOffset=0] Usefull when onZero.
@@ -171,172 +171,14 @@
171
171
  /**
172
172
  * @private
173
173
  */
174
- axisTick: function () {
174
+ axisTickLabel: function () {
175
175
  var axisModel = this.axisModel;
176
- var axis = axisModel.axis;
177
-
178
- if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
179
- return;
180
- }
181
-
182
- var tickModel = axisModel.getModel('axisTick');
183
- var opt = this.opt;
184
-
185
- var lineStyleModel = tickModel.getModel('lineStyle');
186
- var tickLen = tickModel.get('length');
187
-
188
- var tickInterval = getInterval(tickModel, opt.labelInterval);
189
- var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
190
- var ticks = axis.scale.getTicks();
191
-
192
- var pt1 = [];
193
- var pt2 = [];
194
- var matrix = this._transform;
195
-
196
- for (var i = 0; i < ticksCoords.length; i++) {
197
- // Only ordinal scale support tick interval
198
- if (ifIgnoreOnTick(axis, i, tickInterval)) {
199
- continue;
200
- }
201
-
202
- var tickCoord = ticksCoords[i];
203
-
204
- pt1[0] = tickCoord;
205
- pt1[1] = 0;
206
- pt2[0] = tickCoord;
207
- pt2[1] = opt.tickDirection * tickLen;
208
-
209
- if (matrix) {
210
- v2ApplyTransform(pt1, pt1, matrix);
211
- v2ApplyTransform(pt2, pt2, matrix);
212
- }
213
- // Tick line, Not use group transform to have better line draw
214
- this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
215
-
216
- // Id for animation
217
- anid: 'tick_' + ticks[i],
218
-
219
- shape: {
220
- x1: pt1[0],
221
- y1: pt1[1],
222
- x2: pt2[0],
223
- y2: pt2[1]
224
- },
225
- style: zrUtil.defaults(
226
- lineStyleModel.getLineStyle(),
227
- {
228
- stroke: axisModel.get('axisLine.lineStyle.color')
229
- }
230
- ),
231
- z2: 2,
232
- silent: true
233
- })));
234
- }
235
- },
236
-
237
- /**
238
- * @param {module:echarts/coord/cartesian/AxisModel} axisModel
239
- * @param {module:echarts/coord/cartesian/GridModel} gridModel
240
- * @private
241
- */
242
- axisLabel: function () {
243
176
  var opt = this.opt;
244
- var axisModel = this.axisModel;
245
- var axis = axisModel.axis;
246
- var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
247
-
248
- if (!show || axis.scale.isBlank()) {
249
- return;
250
- }
251
-
252
- var labelModel = axisModel.getModel('axisLabel');
253
- var textStyleModel = labelModel.getModel('textStyle');
254
- var labelMargin = labelModel.get('margin');
255
- var ticks = axis.scale.getTicks();
256
- var labels = axisModel.getFormattedLabels();
257
-
258
- // Special label rotate.
259
- var labelRotation = (
260
- retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
261
- ) * PI / 180;
262
-
263
- var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
264
- var categoryData = axisModel.get('data');
265
-
266
- var textEls = [];
267
- var silent = isSilent(axisModel);
268
- var triggerEvent = axisModel.get('triggerEvent');
269
-
270
- zrUtil.each(ticks, function (tickVal, index) {
271
- if (ifIgnoreOnTick(axis, index, opt.labelInterval)) {
272
- return;
273
- }
274
-
275
- var itemTextStyleModel = textStyleModel;
276
- if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
277
- itemTextStyleModel = new Model(
278
- categoryData[tickVal].textStyle, textStyleModel, axisModel.ecModel
279
- );
280
- }
281
- var textColor = itemTextStyleModel.getTextColor()
282
- || axisModel.get('axisLine.lineStyle.color');
283
-
284
- var tickCoord = axis.dataToCoord(tickVal);
285
- var pos = [
286
- tickCoord,
287
- opt.labelOffset + opt.labelDirection * labelMargin
288
- ];
289
- var labelStr = axis.scale.getLabel(tickVal);
290
-
291
- var textEl = new graphic.Text({
292
-
293
- // Id for animation
294
- anid: 'label_' + tickVal,
295
-
296
- style: {
297
- text: labels[index],
298
- textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
299
- textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.textVerticalAlign,
300
- textFont: itemTextStyleModel.getFont(),
301
- fill: typeof textColor === 'function'
302
- ? textColor(
303
- // (1) In category axis with data zoom, tick is not the original
304
- // index of axis.data. So tick should not be exposed to user
305
- // in category axis.
306
- // (2) Compatible with previous version, which always returns labelStr.
307
- // But in interval scale labelStr is like '223,445', which maked
308
- // user repalce ','. So we modify it to return original val but remain
309
- // it as 'string' to avoid error in replacing.
310
- axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
311
- index
312
- )
313
- : textColor
314
- },
315
- position: pos,
316
- rotation: labelLayout.rotation,
317
- silent: silent,
318
- z2: 10
319
- });
320
-
321
- // Pack data for mouse event
322
- if (triggerEvent) {
323
- textEl.eventData = makeAxisEventDataBase(axisModel);
324
- textEl.eventData.targetType = 'axisLabel';
325
- textEl.eventData.value = labelStr;
326
- }
327
-
328
- // FIXME
329
- this._dumbGroup.add(textEl);
330
- textEl.updateTransform();
331
-
332
- textEls.push(textEl);
333
- this.group.add(textEl);
334
177
 
335
- textEl.decomposeTransform();
178
+ var tickEls = buildAxisTick(this, axisModel, opt);
179
+ var labelEls = buildAxisLabel(this, axisModel, opt);
336
180
 
337
- }, this);
338
-
339
- fixMinMaxLabelShow(axisModel, textEls);
181
+ fixMinMaxLabelShow(axisModel, labelEls, tickEls);
340
182
  },
341
183
 
342
184
  /**
@@ -365,7 +207,7 @@
365
207
  ? extent[1] + gapSignal * gap
366
208
  : (extent[0] + extent[1]) / 2, // 'middle'
367
209
  // Reuse labelOffset.
368
- nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
210
+ isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0
369
211
  ];
370
212
 
371
213
  var labelLayout;
@@ -377,7 +219,7 @@
377
219
 
378
220
  var axisNameAvailableWidth;
379
221
 
380
- if (nameLocation === 'middle') {
222
+ if (isNameLocationCenter(nameLocation)) {
381
223
  labelLayout = innerTextLayout(
382
224
  opt.rotation,
383
225
  nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
@@ -405,6 +247,8 @@
405
247
  var maxWidth = retrieve(
406
248
  opt.nameTruncateMaxWidth, truncateOpt.maxWidth, axisNameAvailableWidth
407
249
  );
250
+ // FIXME
251
+ // truncate rich text? (consider performance)
408
252
  var truncatedText = (ellipsis != null && maxWidth != null)
409
253
  ? formatUtil.truncateText(
410
254
  name, maxWidth, textFont, ellipsis,
@@ -423,21 +267,12 @@
423
267
  formatterParams[mainType + 'Index'] = axisModel.componentIndex;
424
268
 
425
269
  var textEl = new graphic.Text({
426
-
427
270
  // Id for animation
428
271
  anid: 'name',
429
272
 
430
273
  __fullText: name,
431
274
  __truncatedText: truncatedText,
432
275
 
433
- style: {
434
- text: truncatedText,
435
- textFont: textFont,
436
- fill: textStyleModel.getTextColor()
437
- || axisModel.get('axisLine.lineStyle.color'),
438
- textAlign: labelLayout.textAlign,
439
- textVerticalAlign: labelLayout.textVerticalAlign
440
- },
441
276
  position: pos,
442
277
  rotation: labelLayout.rotation,
443
278
  silent: isSilent(axisModel),
@@ -453,6 +288,15 @@
453
288
  : null
454
289
  });
455
290
 
291
+ graphic.setTextStyle(textEl.style, textStyleModel, {
292
+ text: truncatedText,
293
+ textFont: textFont,
294
+ textFill: textStyleModel.getTextColor()
295
+ || axisModel.get('axisLine.lineStyle.color'),
296
+ textAlign: labelLayout.textAlign,
297
+ textVerticalAlign: labelLayout.textVerticalAlign
298
+ });
299
+
456
300
  if (axisModel.get('triggerEvent')) {
457
301
  textEl.eventData = makeAxisEventDataBase(axisModel);
458
302
  textEl.eventData.targetType = 'axisName';
@@ -556,32 +400,64 @@
556
400
  );
557
401
  }
558
402
 
559
- function fixMinMaxLabelShow(axisModel, textEls) {
403
+ function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
560
404
  // If min or max are user set, we need to check
561
405
  // If the tick on min(max) are overlap on their neighbour tick
562
406
  // If they are overlapped, we need to hide the min(max) tick label
563
407
  var showMinLabel = axisModel.get('axisLabel.showMinLabel');
564
408
  var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
565
- var firstLabel = textEls[0];
566
- var nextLabel = textEls[1];
567
- var lastLabel = textEls[textEls.length - 1];
568
- var prevLabel = textEls[textEls.length - 2];
409
+
410
+ // FIXME
411
+ // Have not consider onBand yet, where tick els is more than label els.
412
+
413
+ labelEls = labelEls || [];
414
+ tickEls = tickEls || [];
415
+
416
+ var firstLabel = labelEls[0];
417
+ var nextLabel = labelEls[1];
418
+ var lastLabel = labelEls[labelEls.length - 1];
419
+ var prevLabel = labelEls[labelEls.length - 2];
420
+
421
+ var firstTick = tickEls[0];
422
+ var nextTick = tickEls[1];
423
+ var lastTick = tickEls[tickEls.length - 1];
424
+ var prevTick = tickEls[tickEls.length - 2];
569
425
 
570
426
  if (showMinLabel === false) {
571
- firstLabel.ignore = true;
427
+ ignoreEl(firstLabel);
428
+ ignoreEl(firstTick);
572
429
  }
573
- else if (axisModel.getMin() != null && isTwoLabelOverlapped(firstLabel, nextLabel)) {
574
- showMinLabel ? (nextLabel.ignore = true) : (firstLabel.ignore = true);
430
+ else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
431
+ if (showMinLabel) {
432
+ ignoreEl(nextLabel);
433
+ ignoreEl(nextTick);
434
+ }
435
+ else {
436
+ ignoreEl(firstLabel);
437
+ ignoreEl(firstTick);
438
+ }
575
439
  }
576
440
 
577
441
  if (showMaxLabel === false) {
578
- lastLabel.ignore = true;
442
+ ignoreEl(lastLabel);
443
+ ignoreEl(lastTick);
579
444
  }
580
- else if (axisModel.getMax() != null && isTwoLabelOverlapped(prevLabel, lastLabel)) {
581
- showMaxLabel ? (prevLabel.ignore = true) : (lastLabel.ignore = true);
445
+ else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
446
+ if (showMaxLabel) {
447
+ ignoreEl(prevLabel);
448
+ ignoreEl(prevTick);
449
+ }
450
+ else {
451
+ ignoreEl(lastLabel);
452
+ ignoreEl(lastTick);
453
+ }
582
454
  }
583
455
  }
584
456
 
457
+ function ignoreEl(el) {
458
+ el && (el.ignore = true);
459
+ }
460
+
585
461
  function isTwoLabelOverlapped(current, next, labelLayout) {
586
462
  // current and next has the same rotation.
587
463
  var firstRect = current && current.getBoundingRect().clone();
@@ -602,11 +478,28 @@
602
478
  return firstRect.intersect(nextRect);
603
479
  }
604
480
 
481
+ function isNameLocationCenter(nameLocation) {
482
+ return nameLocation === 'middle' || nameLocation === 'center';
483
+ }
605
484
 
606
485
  /**
607
486
  * @static
608
487
  */
609
- var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
488
+ var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
489
+ axis,
490
+ i,
491
+ interval,
492
+ ticksCnt,
493
+ showMinLabel,
494
+ showMaxLabel
495
+ ) {
496
+ if (i === 0 && showMinLabel || i === ticksCnt - 1 && showMaxLabel) {
497
+ return false;
498
+ }
499
+
500
+ // FIXME
501
+ // Have not consider label overlap (if label is too long) yet.
502
+
610
503
  var rawTick;
611
504
  var scale = axis.scale;
612
505
  return scale.type === 'ordinal'
@@ -631,5 +524,186 @@
631
524
  return interval;
632
525
  };
633
526
 
527
+ function buildAxisTick(axisBuilder, axisModel, opt) {
528
+ var axis = axisModel.axis;
529
+
530
+ if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
531
+ return;
532
+ }
533
+
534
+ var tickModel = axisModel.getModel('axisTick');
535
+
536
+ var lineStyleModel = tickModel.getModel('lineStyle');
537
+ var tickLen = tickModel.get('length');
538
+
539
+ var tickInterval = getInterval(tickModel, opt.labelInterval);
540
+ var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
541
+ // FIXME
542
+ // Corresponds to ticksCoords ?
543
+ var ticks = axis.scale.getTicks();
544
+
545
+ var showMinLabel = axisModel.get('axisLabel.showMinLabel');
546
+ var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
547
+
548
+ var pt1 = [];
549
+ var pt2 = [];
550
+ var matrix = axisBuilder._transform;
551
+
552
+ var tickEls = [];
553
+
554
+ var ticksCnt = ticksCoords.length;
555
+ for (var i = 0; i < ticksCnt; i++) {
556
+ // Only ordinal scale support tick interval
557
+ if (ifIgnoreOnTick(
558
+ axis, i, tickInterval, ticksCnt,
559
+ showMinLabel, showMaxLabel
560
+ )) {
561
+ continue;
562
+ }
563
+
564
+ var tickCoord = ticksCoords[i];
565
+
566
+ pt1[0] = tickCoord;
567
+ pt1[1] = 0;
568
+ pt2[0] = tickCoord;
569
+ pt2[1] = opt.tickDirection * tickLen;
570
+
571
+ if (matrix) {
572
+ v2ApplyTransform(pt1, pt1, matrix);
573
+ v2ApplyTransform(pt2, pt2, matrix);
574
+ }
575
+ // Tick line, Not use group transform to have better line draw
576
+ var tickEl = new graphic.Line(graphic.subPixelOptimizeLine({
577
+ // Id for animation
578
+ anid: 'tick_' + ticks[i],
579
+
580
+ shape: {
581
+ x1: pt1[0],
582
+ y1: pt1[1],
583
+ x2: pt2[0],
584
+ y2: pt2[1]
585
+ },
586
+ style: zrUtil.defaults(
587
+ lineStyleModel.getLineStyle(),
588
+ {
589
+ stroke: axisModel.get('axisLine.lineStyle.color')
590
+ }
591
+ ),
592
+ z2: 2,
593
+ silent: true
594
+ }));
595
+ axisBuilder.group.add(tickEl);
596
+ tickEls.push(tickEl);
597
+ }
598
+
599
+ return tickEls;
600
+ }
601
+
602
+ function buildAxisLabel(axisBuilder, axisModel, opt) {
603
+ var axis = axisModel.axis;
604
+ var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
605
+
606
+ if (!show || axis.scale.isBlank()) {
607
+ return;
608
+ }
609
+
610
+ var labelModel = axisModel.getModel('axisLabel');
611
+ var labelMargin = labelModel.get('margin');
612
+ var ticks = axis.scale.getTicks();
613
+ var labels = axisModel.getFormattedLabels();
614
+
615
+ // Special label rotate.
616
+ var labelRotation = (
617
+ retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
618
+ ) * PI / 180;
619
+
620
+ var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
621
+ var categoryData = axisModel.get('data');
622
+
623
+ var labelEls = [];
624
+ var silent = isSilent(axisModel);
625
+ var triggerEvent = axisModel.get('triggerEvent');
626
+
627
+ var showMinLabel = axisModel.get('axisLabel.showMinLabel');
628
+ var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
629
+
630
+ zrUtil.each(ticks, function (tickVal, index) {
631
+ if (ifIgnoreOnTick(
632
+ axis, index, opt.labelInterval, ticks.length,
633
+ showMinLabel, showMaxLabel
634
+ )) {
635
+ return;
636
+ }
637
+
638
+ var itemLabelModel = labelModel;
639
+ if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
640
+ itemLabelModel = new Model(
641
+ categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
642
+ );
643
+ }
644
+
645
+ var textColor = itemLabelModel.getTextColor()
646
+ || axisModel.get('axisLine.lineStyle.color');
647
+
648
+ var tickCoord = axis.dataToCoord(tickVal);
649
+ var pos = [
650
+ tickCoord,
651
+ opt.labelOffset + opt.labelDirection * labelMargin
652
+ ];
653
+ var labelStr = axis.scale.getLabel(tickVal);
654
+
655
+ var textEl = new graphic.Text({
656
+ // Id for animation
657
+ anid: 'label_' + tickVal,
658
+ position: pos,
659
+ rotation: labelLayout.rotation,
660
+ silent: silent,
661
+ z2: 10
662
+ });
663
+
664
+ graphic.setTextStyle(textEl.style, itemLabelModel, {
665
+ text: labels[index],
666
+ textAlign: itemLabelModel.getShallow('align', true)
667
+ || labelLayout.textAlign,
668
+ textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
669
+ || itemLabelModel.getShallow('baseline', true)
670
+ || labelLayout.textVerticalAlign,
671
+ textFill: typeof textColor === 'function'
672
+ ? textColor(
673
+ // (1) In category axis with data zoom, tick is not the original
674
+ // index of axis.data. So tick should not be exposed to user
675
+ // in category axis.
676
+ // (2) Compatible with previous version, which always returns labelStr.
677
+ // But in interval scale labelStr is like '223,445', which maked
678
+ // user repalce ','. So we modify it to return original val but remain
679
+ // it as 'string' to avoid error in replacing.
680
+ axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
681
+ index
682
+ )
683
+ : textColor
684
+ });
685
+
686
+ // Pack data for mouse event
687
+ if (triggerEvent) {
688
+ textEl.eventData = makeAxisEventDataBase(axisModel);
689
+ textEl.eventData.targetType = 'axisLabel';
690
+ textEl.eventData.value = labelStr;
691
+ }
692
+
693
+ // FIXME
694
+ axisBuilder._dumbGroup.add(textEl);
695
+ textEl.updateTransform();
696
+
697
+ labelEls.push(textEl);
698
+ axisBuilder.group.add(textEl);
699
+
700
+ textEl.decomposeTransform();
701
+
702
+ });
703
+
704
+ return labelEls;
705
+ }
706
+
707
+
634
708
  module.exports = AxisBuilder;
635
709