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