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
@@ -15,6 +15,8 @@
15
15
  var mathMax = Math.max;
16
16
  var mathMin = Math.min;
17
17
 
18
+ var EMPTY_OBJ = {};
19
+
18
20
  var graphic = {};
19
21
 
20
22
  graphic.Group = require('zrender/lib/container/Group');
@@ -134,7 +136,6 @@
134
136
  * @return {Object} Modified param
135
137
  */
136
138
  graphic.subPixelOptimizeLine = function (param) {
137
- var subPixelOptimize = graphic.subPixelOptimize;
138
139
  var shape = param.shape;
139
140
  var lineWidth = param.style.lineWidth;
140
141
 
@@ -161,7 +162,6 @@
161
162
  * @return {Object} Modified param
162
163
  */
163
164
  graphic.subPixelOptimizeRect = function (param) {
164
- var subPixelOptimize = graphic.subPixelOptimize;
165
165
  var shape = param.shape;
166
166
  var lineWidth = param.style.lineWidth;
167
167
  var originX = shape.x;
@@ -189,7 +189,7 @@
189
189
  * @param {boolean=} positiveOrNegative Default false (negative).
190
190
  * @return {number} Optimized position.
191
191
  */
192
- graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
192
+ var subPixelOptimize = graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
193
193
  // Assure that (position + lineWidth / 2) is near integer edge,
194
194
  // otherwise line will be fuzzy in canvas.
195
195
  var doubledPosition = round(position * 2);
@@ -223,7 +223,8 @@
223
223
 
224
224
  var normalStyle = {};
225
225
  for (var name in hoverStyle) {
226
- if (hoverStyle.hasOwnProperty(name)) {
226
+ // See comment in `doSingleEnterHover`.
227
+ if (hoverStyle[name] != null) {
227
228
  normalStyle[name] = el.style[name];
228
229
  }
229
230
  }
@@ -248,7 +249,46 @@
248
249
  el.__zr && el.__zr.addHover(el, el.__hoverStl);
249
250
  }
250
251
  else {
251
- el.setStyle(el.__hoverStl);
252
+ var style = el.style;
253
+ var insideRollbackOpt = style.insideRollbackOpt;
254
+
255
+ // Consider case: only `position: 'top'` is set on emphasis, then text
256
+ // color should be returned to `autoColor`, rather than remain '#fff'.
257
+ // So we should rollback then apply again after style merging.
258
+ insideRollbackOpt && rollbackInsideStyle(style);
259
+
260
+ // styles can be:
261
+ // {
262
+ // label: {
263
+ // normal: {
264
+ // show: false,
265
+ // position: 'outside',
266
+ // fontSize: 18
267
+ // },
268
+ // emphasis: {
269
+ // show: true
270
+ // }
271
+ // }
272
+ // },
273
+ // where properties of `emphasis` may not appear in `normal`. We previously use
274
+ // module:echarts/util/model#defaultEmphasis to merge `normal` to `emphasis`.
275
+ // But consider rich text and setOption in merge mode, it is impossible to cover
276
+ // all properties in merge. So we use merge mode when setting style here, where
277
+ // only properties that is not `null/undefined` can be set. The disadventage:
278
+ // null/undefined can not be used to remove style any more in `emphasis`.
279
+ style.extendFrom(el.__hoverStl);
280
+
281
+ // Do not save `insideRollback`.
282
+ if (insideRollbackOpt) {
283
+ applyInsideStyle(style, style.insideOriginalTextPosition, insideRollbackOpt);
284
+
285
+ // textFill may be rollbacked to null.
286
+ if (style.textFill == null) {
287
+ style.textFill = insideRollbackOpt.autoColor;
288
+ }
289
+ }
290
+
291
+ el.dirty(false);
252
292
  el.z2 += 1;
253
293
  }
254
294
 
@@ -268,6 +308,8 @@
268
308
  el.__zr && el.__zr.removeHover(el);
269
309
  }
270
310
  else {
311
+ // Consider null/undefined value, should use
312
+ // `setStyle` but not `extendFrom(stl, true)`.
271
313
  normalStl && el.setStyle(normalStl);
272
314
  el.z2 -= 1;
273
315
  }
@@ -390,27 +432,346 @@
390
432
  };
391
433
 
392
434
  /**
393
- * Set text option in the style
435
+ * @param {Object|module:zrender/graphic/Style} normalStyle
436
+ * @param {Object} emphasisStyle
437
+ * @param {module:echarts/model/Model} normalModel
438
+ * @param {module:echarts/model/Model} emphasisModel
439
+ * @param {Object} opt Check `opt` of `setTextStyleCommon` to find other props.
440
+ * @param {Object} [opt.defaultText]
441
+ * @param {module:echarts/model/Model} [opt.labelFetcher] Fetch text by
442
+ * `opt.labelFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
443
+ * @param {module:echarts/model/Model} [opt.labelDataIndex] Fetch text by
444
+ * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
445
+ * @param {module:echarts/model/Model} [opt.labelDimIndex] Fetch text by
446
+ * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
447
+ * @param {Object} [normalSpecified]
448
+ * @param {Object} [emphasisSpecified]
449
+ */
450
+ graphic.setLabelStyle = function (
451
+ normalStyle, emphasisStyle,
452
+ normalModel, emphasisModel,
453
+ opt,
454
+ normalSpecified, emphasisSpecified
455
+ ) {
456
+ opt = opt || EMPTY_OBJ;
457
+ var labelFetcher = opt.labelFetcher;
458
+ var labelDataIndex = opt.labelDataIndex;
459
+ var labelDimIndex = opt.labelDimIndex;
460
+
461
+ // This scenario, `label.normal.show = true; label.emphasis.show = false`,
462
+ // is not supported util someone requests.
463
+
464
+ var showNormal = normalModel.getShallow('show');
465
+ var showEmphasis = emphasisModel.getShallow('show');
466
+
467
+ // Consider performance, only fetch label when necessary.
468
+ // If `normal.show` is `false` and `emphasis.show` is `true` and `emphasis.formatter` is not set,
469
+ // label should be displayed, where text is fetched by `normal.formatter` or `opt.defaultText`.
470
+ var baseText = (showNormal || showEmphasis)
471
+ ? zrUtil.retrieve2(
472
+ labelFetcher
473
+ ? labelFetcher.getFormattedLabel(labelDataIndex, 'normal', null, labelDimIndex)
474
+ : null,
475
+ opt.defaultText
476
+ )
477
+ : null;
478
+ var normalStyleText = showNormal ? baseText : null;
479
+ var emphasisStyleText = showEmphasis
480
+ ? zrUtil.retrieve2(
481
+ labelFetcher
482
+ ? labelFetcher.getFormattedLabel(labelDataIndex, 'emphasis', null, labelDimIndex)
483
+ : null,
484
+ baseText
485
+ )
486
+ : null;
487
+
488
+ // Optimize: If style.text is null, text will not be drawn.
489
+ if (normalStyleText != null || emphasisStyleText != null) {
490
+ // Always set `textStyle` even if `normalStyle.text` is null, because default
491
+ // values have to be set on `normalStyle`.
492
+ // If we set default values on `emphasisStyle`, consider case:
493
+ // Firstly, `setOption(... label: {normal: {text: null}, emphasis: {show: true}} ...);`
494
+ // Secondly, `setOption(... label: {noraml: {show: true, text: 'abc', color: 'red'} ...);`
495
+ // Then the 'red' will not work on emphasis.
496
+ setTextStyle(normalStyle, normalModel, normalSpecified, opt);
497
+ setTextStyle(emphasisStyle, emphasisModel, emphasisSpecified, opt, true);
498
+ }
499
+
500
+ normalStyle.text = normalStyleText;
501
+ emphasisStyle.text = emphasisStyleText;
502
+ };
503
+
504
+ /**
505
+ * Set basic textStyle properties.
506
+ * @param {Object|module:zrender/graphic/Style} textStyle
507
+ * @param {module:echarts/model/Model} model
508
+ * @param {Object} [specifiedTextStyle] Can be overrided by settings in model.
509
+ * @param {Object} [opt] See `opt` of `setTextStyleCommon`.
510
+ * @param {boolean} [isEmphasis]
511
+ */
512
+ var setTextStyle = graphic.setTextStyle = function (
513
+ textStyle, textStyleModel, specifiedTextStyle, opt, isEmphasis
514
+ ) {
515
+ setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis);
516
+ specifiedTextStyle && zrUtil.extend(textStyle, specifiedTextStyle);
517
+ textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
518
+
519
+ return textStyle;
520
+ };
521
+
522
+ /**
523
+ * Set text option in the style.
524
+ * @deprecated
394
525
  * @param {Object} textStyle
395
526
  * @param {module:echarts/model/Model} labelModel
396
- * @param {string} color
527
+ * @param {string|boolean} defaultColor Default text color.
528
+ * If set as false, it will be processed as a emphasis style.
397
529
  */
398
- graphic.setText = function (textStyle, labelModel, color) {
399
- var labelPosition = labelModel.getShallow('position') || 'inside';
400
- var labelOffset = labelModel.getShallow('offset');
401
- var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
402
- var textStyleModel = labelModel.getModel('textStyle');
403
- zrUtil.extend(textStyle, {
404
- textDistance: labelModel.getShallow('distance') || 5,
405
- textFont: textStyleModel.getFont(),
406
- textPosition: labelPosition,
407
- textOffset: labelOffset,
408
- textFill: textStyleModel.getTextColor() || labelColor
409
- });
530
+ graphic.setText = function (textStyle, labelModel, defaultColor) {
531
+ var opt = {isRectText: true};
532
+ var isEmphasis;
533
+
534
+ if (defaultColor === false) {
535
+ isEmphasis = true;
536
+ }
537
+ else {
538
+ // Support setting color as 'auto' to get visual color.
539
+ opt.autoColor = defaultColor;
540
+ }
541
+ setTextStyleCommon(textStyle, labelModel, opt, isEmphasis);
542
+ textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
410
543
  };
411
544
 
545
+ /**
546
+ * {
547
+ * disableBox: boolean, Whether diable drawing box of block (outer most).
548
+ * isRectText: boolean,
549
+ * autoColor: string, specify a color when color is 'auto',
550
+ * for textFill, textStroke, textBackgroundColor, and textBorderColor.
551
+ * If autoColor specified, it is used as default textFill.
552
+ * useInsideStyle:
553
+ * `true`: Use inside style (textFill, textStroke, textStrokeWidth)
554
+ * if `textFill` is not specified.
555
+ * `false`: Do not use inside style.
556
+ * `null/undefined`: use inside style if `isRectText` is true and
557
+ * `textFill` is not specified and textPosition contains `'inside'`.
558
+ * forceRich: boolean
559
+ * }
560
+ */
561
+ function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
562
+ // Consider there will be abnormal when merge hover style to normal style if given default value.
563
+ opt = opt || EMPTY_OBJ;
564
+
565
+ if (opt.isRectText) {
566
+ var textPosition = textStyleModel.getShallow('position')
567
+ || (isEmphasis ? null : 'inside');
568
+ // 'outside' is not a valid zr textPostion value, but used
569
+ // in bar series, and magric type should be considered.
570
+ textPosition === 'outside' && (textPosition = 'top');
571
+ textStyle.textPosition = textPosition;
572
+ textStyle.textOffset = textStyleModel.getShallow('offset');
573
+ var labelRotate = textStyleModel.getShallow('rotate');
574
+ labelRotate != null && (labelRotate *= Math.PI / 180);
575
+ textStyle.textRotation = labelRotate;
576
+ textStyle.textDistance = zrUtil.retrieve2(
577
+ textStyleModel.getShallow('distance'), isEmphasis ? null : 5
578
+ );
579
+ }
580
+
581
+ var ecModel = textStyleModel.ecModel;
582
+ var globalTextStyle = ecModel && ecModel.option.textStyle;
583
+
584
+ // Consider case:
585
+ // {
586
+ // data: [{
587
+ // value: 12,
588
+ // label: {
589
+ // normal: {
590
+ // rich: {
591
+ // // no 'a' here but using parent 'a'.
592
+ // }
593
+ // }
594
+ // }
595
+ // }],
596
+ // rich: {
597
+ // a: { ... }
598
+ // }
599
+ // }
600
+ var richItemNames = getRichItemNames(textStyleModel);
601
+ var richResult;
602
+ if (richItemNames) {
603
+ richResult = {};
604
+ for (var name in richItemNames) {
605
+ if (richItemNames.hasOwnProperty(name)) {
606
+ // Cascade is supported in rich.
607
+ var richTextStyle = textStyleModel.getModel(['rich', name]);
608
+ // In rich, never `disableBox`.
609
+ setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
610
+ }
611
+ }
612
+ }
613
+ textStyle.rich = richResult;
614
+
615
+ setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
616
+
617
+ if (opt.forceRich && !opt.textStyle) {
618
+ opt.textStyle = {};
619
+ }
620
+
621
+ return textStyle;
622
+ }
623
+
624
+ // Consider case:
625
+ // {
626
+ // data: [{
627
+ // value: 12,
628
+ // label: {
629
+ // normal: {
630
+ // rich: {
631
+ // // no 'a' here but using parent 'a'.
632
+ // }
633
+ // }
634
+ // }
635
+ // }],
636
+ // rich: {
637
+ // a: { ... }
638
+ // }
639
+ // }
640
+ function getRichItemNames(textStyleModel) {
641
+ // Use object to remove duplicated names.
642
+ var richItemNameMap;
643
+ while (textStyleModel && textStyleModel !== textStyleModel.ecModel) {
644
+ var rich = (textStyleModel.option || EMPTY_OBJ).rich;
645
+ if (rich) {
646
+ richItemNameMap = richItemNameMap || {};
647
+ for (var name in rich) {
648
+ if (rich.hasOwnProperty(name)) {
649
+ richItemNameMap[name] = 1;
650
+ }
651
+ }
652
+ }
653
+ textStyleModel = textStyleModel.parentModel;
654
+ }
655
+ return richItemNameMap;
656
+ }
657
+
658
+ function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, isBlock) {
659
+ // In merge mode, default value should not be given.
660
+ globalTextStyle = !isEmphasis && globalTextStyle || EMPTY_OBJ;
661
+
662
+ textStyle.textFill = getAutoColor(textStyleModel.getShallow('color'), opt)
663
+ || globalTextStyle.color;
664
+ textStyle.textStroke = getAutoColor(textStyleModel.getShallow('textBorderColor'), opt)
665
+ || globalTextStyle.textBorderColor;
666
+ textStyle.textStrokeWidth = zrUtil.retrieve2(
667
+ textStyleModel.getShallow('textBorderWidth'),
668
+ globalTextStyle.textBorderWidth
669
+ );
670
+
671
+ if (!isEmphasis) {
672
+ if (isBlock) {
673
+ // Always set `insideRollback`, for clearing previous.
674
+ var originalTextPosition = textStyle.textPosition;
675
+ textStyle.insideRollback = applyInsideStyle(textStyle, originalTextPosition, opt);
676
+ // Save original textPosition, because style.textPosition will be repalced by
677
+ // real location (like [10, 30]) in zrender.
678
+ textStyle.insideOriginalTextPosition = originalTextPosition;
679
+ textStyle.insideRollbackOpt = opt;
680
+ }
681
+
682
+ // Set default finally.
683
+ if (textStyle.textFill == null) {
684
+ textStyle.textFill = opt.autoColor;
685
+ }
686
+ }
687
+
688
+ // Do not use `getFont` here, because merge should be supported, where
689
+ // part of these properties may be changed in emphasis style, and the
690
+ // others should remain their original value got from normal style.
691
+ textStyle.fontStyle = textStyleModel.getShallow('fontStyle') || globalTextStyle.fontStyle;
692
+ textStyle.fontWeight = textStyleModel.getShallow('fontWeight') || globalTextStyle.fontWeight;
693
+ textStyle.fontSize = textStyleModel.getShallow('fontSize') || globalTextStyle.fontSize;
694
+ textStyle.fontFamily = textStyleModel.getShallow('fontFamily') || globalTextStyle.fontFamily;
695
+
696
+ textStyle.textAlign = textStyleModel.getShallow('align');
697
+ textStyle.textVerticalAlign = textStyleModel.getShallow('verticalAlign')
698
+ || textStyleModel.getShallow('baseline');
699
+
700
+ textStyle.textLineHeight = textStyleModel.getShallow('lineHeight');
701
+ textStyle.textWidth = textStyleModel.getShallow('width');
702
+ textStyle.textHeight = textStyleModel.getShallow('height');
703
+ textStyle.textTag = textStyleModel.getShallow('tag');
704
+
705
+ if (!isBlock || !opt.disableBox) {
706
+ textStyle.textBackgroundColor = getAutoColor(textStyleModel.getShallow('backgroundColor'), opt);
707
+ textStyle.textPadding = textStyleModel.getShallow('padding');
708
+ textStyle.textBorderColor = getAutoColor(textStyleModel.getShallow('borderColor'), opt);
709
+ textStyle.textBorderWidth = textStyleModel.getShallow('borderWidth');
710
+ textStyle.textBorderRadius = textStyleModel.getShallow('borderRadius');
711
+
712
+ textStyle.textBoxShadowColor = textStyleModel.getShallow('shadowColor');
713
+ textStyle.textBoxShadowBlur = textStyleModel.getShallow('shadowBlur');
714
+ textStyle.textBoxShadowOffsetX = textStyleModel.getShallow('shadowOffsetX');
715
+ textStyle.textBoxShadowOffsetY = textStyleModel.getShallow('shadowOffsetY');
716
+ }
717
+
718
+ textStyle.textShadowColor = textStyleModel.getShallow('textShadowColor')
719
+ || globalTextStyle.textShadowColor;
720
+ textStyle.textShadowBlur = textStyleModel.getShallow('textShadowBlur')
721
+ || globalTextStyle.textShadowBlur;
722
+ textStyle.textShadowOffsetX = textStyleModel.getShallow('textShadowOffsetX')
723
+ || globalTextStyle.textShadowOffsetX;
724
+ textStyle.textShadowOffsetY = textStyleModel.getShallow('textShadowOffsetY')
725
+ || globalTextStyle.textShadowOffsetY;
726
+ }
727
+
728
+ function getAutoColor(color, opt) {
729
+ return color !== 'auto' ? color : (opt && opt.autoColor) ? opt.autoColor : null;
730
+ }
731
+
732
+ function applyInsideStyle(textStyle, textPosition, opt) {
733
+ var useInsideStyle = opt.useInsideStyle;
734
+ var insideRollback;
735
+
736
+ if (textStyle.textFill == null
737
+ && useInsideStyle !== false
738
+ && (useInsideStyle === true
739
+ || (opt.isRectText
740
+ && textPosition
741
+ // textPosition can be [10, 30]
742
+ && typeof textPosition === 'string'
743
+ && textPosition.indexOf('inside') >= 0
744
+ )
745
+ )
746
+ ) {
747
+ insideRollback = {
748
+ textFill: null,
749
+ textStroke: textStyle.textStroke,
750
+ textStrokeWidth: textStyle.textStrokeWidth
751
+ };
752
+ textStyle.textFill = '#fff';
753
+ // Consider text with #fff overflow its container.
754
+ if (textStyle.textStroke == null) {
755
+ textStyle.textStroke = opt.autoColor;
756
+ textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
757
+ }
758
+ }
759
+
760
+ return insideRollback;
761
+ }
762
+
763
+ function rollbackInsideStyle(style) {
764
+ var insideRollback = style.insideRollback;
765
+ if (insideRollback) {
766
+ style.textFill = insideRollback.textFill;
767
+ style.textStroke = insideRollback.textStroke;
768
+ style.textStrokeWidth = insideRollback.textStrokeWidth;
769
+ }
770
+ }
771
+
412
772
  graphic.getFont = function (opt, ecModel) {
413
- var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
773
+ // ecModel or default text style model.
774
+ var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
414
775
  return [
415
776
  // FIXME in node-canvas fontWeight is before fontStyle
416
777
  opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
@@ -448,7 +809,7 @@
448
809
  }
449
810
 
450
811
  duration > 0
451
- ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
812
+ ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb, !!cb)
452
813
  : (el.stopAnimation(), el.attr(props), cb && cb());
453
814
  }
454
815
  else {
@@ -639,5 +1000,35 @@
639
1000
  }
640
1001
  };
641
1002
 
1003
+ /**
1004
+ * @param {string} iconStr Support 'image://' or 'path://' or direct svg path.
1005
+ * @param {Object} [opt] Properties of `module:zrender/Element`, except `style`.
1006
+ * @param {Object} [rect] {x, y, width, height}
1007
+ * @return {module:zrender/Element} Icon path or image element.
1008
+ */
1009
+ graphic.createIcon = function (iconStr, opt, rect) {
1010
+ opt = zrUtil.extend({rectHover: true}, opt);
1011
+ var style = opt.style = {strokeNoScale: true};
1012
+ rect = rect || {x: -1, y: -1, width: 2, height: 2};
1013
+
1014
+ if (iconStr) {
1015
+ return iconStr.indexOf('image://') === 0
1016
+ ? (
1017
+ style.image = iconStr.slice(8),
1018
+ zrUtil.defaults(style, rect),
1019
+ new graphic.Image(opt)
1020
+ )
1021
+ : (
1022
+ graphic.makePath(
1023
+ iconStr.replace('path://', ''),
1024
+ opt,
1025
+ rect,
1026
+ 'center'
1027
+ )
1028
+ );
1029
+ }
1030
+
1031
+ };
1032
+
642
1033
  module.exports = graphic;
643
1034
 
@@ -29,6 +29,7 @@
29
29
  function boxLayout(orient, group, gap, maxWidth, maxHeight) {
30
30
  var x = 0;
31
31
  var y = 0;
32
+
32
33
  if (maxWidth == null) {
33
34
  maxWidth = Infinity;
34
35
  }
@@ -36,6 +37,7 @@
36
37
  maxHeight = Infinity;
37
38
  }
38
39
  var currentLineMaxSize = 0;
40
+
39
41
  group.eachChild(function (child, idx) {
40
42
  var position = child.position;
41
43
  var rect = child.getBoundingRect();
@@ -43,10 +45,12 @@
43
45
  var nextChildRect = nextChild && nextChild.getBoundingRect();
44
46
  var nextX;
45
47
  var nextY;
48
+
46
49
  if (orient === 'horizontal') {
47
50
  var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
48
51
  nextX = x + moveX;
49
52
  // Wrap when width exceeds maxWidth or meet a `newline` group
53
+ // FIXME compare before adding gap?
50
54
  if (nextX > maxWidth || child.newline) {
51
55
  x = 0;
52
56
  nextX = moveX;
@@ -54,6 +58,7 @@
54
58
  currentLineMaxSize = rect.height;
55
59
  }
56
60
  else {
61
+ // FIXME: consider rect.y is not `0`?
57
62
  currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
58
63
  }
59
64
  }
@@ -124,7 +129,7 @@
124
129
  * @param {number|string} [positionInfo.y]
125
130
  * @param {number|string} [positionInfo.x2]
126
131
  * @param {number|string} [positionInfo.y2]
127
- * @param {Object} containerRect
132
+ * @param {Object} containerRect {width, height}
128
133
  * @param {string|number} margin
129
134
  * @return {Object} {width, height}
130
135
  */
@@ -193,20 +198,23 @@
193
198
  height = containerHeight - bottom - verticalMargin - top;
194
199
  }
195
200
 
196
- // If width and height are not given
197
- // 1. Graph should not exceeds the container
198
- // 2. Aspect must be keeped
199
- // 3. Graph should take the space as more as possible
200
- if (isNaN(width) && isNaN(height)) {
201
- if (aspect > containerWidth / containerHeight) {
202
- width = containerWidth * 0.8;
203
- }
204
- else {
205
- height = containerHeight * 0.8;
201
+ if (aspect != null) {
202
+ // If width and height are not given
203
+ // 1. Graph should not exceeds the container
204
+ // 2. Aspect must be keeped
205
+ // 3. Graph should take the space as more as possible
206
+ // FIXME
207
+ // Margin is not considered, because there is no case that both
208
+ // using margin and aspect so far.
209
+ if (isNaN(width) && isNaN(height)) {
210
+ if (aspect > containerWidth / containerHeight) {
211
+ width = containerWidth * 0.8;
212
+ }
213
+ else {
214
+ height = containerHeight * 0.8;
215
+ }
206
216
  }
207
- }
208
217
 
209
- if (aspect != null) {
210
218
  // Calculate width or height with given aspect
211
219
  if (isNaN(width)) {
212
220
  width = aspect * height;
@@ -247,11 +255,11 @@
247
255
  top = top || 0;
248
256
  if (isNaN(width)) {
249
257
  // Width may be NaN if only one value is given except width
250
- width = containerWidth - left - (right || 0);
258
+ width = containerWidth - horizontalMargin - left - (right || 0);
251
259
  }
252
260
  if (isNaN(height)) {
253
261
  // Height may be NaN if only one value is given except height
254
- height = containerHeight - top - (bottom || 0);
262
+ height = containerHeight - verticalMargin - top - (bottom || 0);
255
263
  }
256
264
 
257
265
  var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
@@ -281,6 +289,8 @@
281
289
  * @param {number|string} [positionInfo.top]
282
290
  * @param {number|string} [positionInfo.right]
283
291
  * @param {number|string} [positionInfo.bottom]
292
+ * @param {number|string} [positionInfo.width] Only for opt.boundingModel: 'raw'
293
+ * @param {number|string} [positionInfo.height] Only for opt.boundingModel: 'raw'
284
294
  * @param {Object} containerRect
285
295
  * @param {string|number} margin
286
296
  * @param {Object} [opt]
@@ -322,6 +332,7 @@
322
332
  }
323
333
  }
324
334
 
335
+ // The real width and height can not be specified but calculated by the given el.
325
336
  positionInfo = layout.getLayoutRect(
326
337
  zrUtil.defaults(
327
338
  {width: rect.width, height: rect.height},
@@ -372,7 +383,8 @@
372
383
  * @param {Object} targetOption
373
384
  * @param {Object} newOption
374
385
  * @param {Object|string} [opt]
375
- * @param {boolean|Array.<boolean>} [opt.ignoreSize=false] Some component must has width and height.
386
+ * @param {boolean|Array.<boolean>} [opt.ignoreSize=false] Used for the components
387
+ * that width (or height) should not be calculated by left and right (or top and bottom).
376
388
  */
377
389
  layout.mergeLayoutParam = function (targetOption, newOption, opt) {
378
390
  !zrUtil.isObject(opt) && (opt = {});