echarts 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.github/pull_request_template.md +66 -0
  2. package/.github/workflows/nodejs.yml +12 -2
  3. package/CONTRIBUTING.md +16 -160
  4. package/NOTICE +1 -1
  5. package/README.md +2 -2
  6. package/dist/echarts-en.common.js +684 -300
  7. package/dist/echarts-en.common.min.js +1 -1
  8. package/dist/echarts-en.js +1070 -407
  9. package/dist/echarts-en.js.map +1 -1
  10. package/dist/echarts-en.min.js +1 -1
  11. package/dist/echarts-en.simple.js +499 -222
  12. package/dist/echarts-en.simple.min.js +1 -1
  13. package/dist/echarts.common.js +684 -300
  14. package/dist/echarts.common.min.js +1 -1
  15. package/dist/echarts.js +1070 -407
  16. package/dist/echarts.js.map +1 -1
  17. package/dist/echarts.min.js +1 -1
  18. package/dist/echarts.simple.js +499 -222
  19. package/dist/echarts.simple.min.js +1 -1
  20. package/lib/chart/bar/BarSeries.js +14 -1
  21. package/lib/chart/bar/BarView.js +134 -14
  22. package/lib/chart/candlestick/candlestickVisual.js +1 -1
  23. package/lib/chart/funnel/FunnelSeries.js +1 -3
  24. package/lib/chart/graph/GraphSeries.js +2 -1
  25. package/lib/chart/graph/GraphView.js +2 -4
  26. package/lib/chart/helper/EffectLine.js +23 -1
  27. package/lib/chart/helper/Line.js +94 -33
  28. package/lib/chart/helper/createRenderPlanner.js +6 -3
  29. package/lib/chart/pie/PieView.js +1 -1
  30. package/lib/chart/radar/RadarSeries.js +20 -0
  31. package/lib/chart/sankey/SankeySeries.js +13 -1
  32. package/lib/chart/sankey/SankeyView.js +42 -23
  33. package/lib/chart/sankey/sankeyLayout.js +4 -3
  34. package/lib/chart/tree/TreeSeries.js +3 -0
  35. package/lib/chart/tree/TreeView.js +151 -25
  36. package/lib/chart/treemap/TreemapView.js +57 -27
  37. package/lib/component/axis/AxisBuilder.js +0 -1
  38. package/lib/component/axis/CartesianAxisView.js +7 -84
  39. package/lib/component/axis/SingleAxisView.js +21 -6
  40. package/lib/component/axis/axisSplitHelper.js +132 -0
  41. package/lib/component/brush/BrushView.js +11 -1
  42. package/lib/component/brush/visualEncoding.js +13 -2
  43. package/lib/component/helper/MapDraw.js +6 -8
  44. package/lib/component/legend/ScrollableLegendView.js +18 -18
  45. package/lib/component/marker/MarkLineModel.js +2 -1
  46. package/lib/component/marker/markerHelper.js +7 -4
  47. package/lib/component/tooltip/TooltipContent.js +60 -23
  48. package/lib/component/tooltip/TooltipView.js +6 -7
  49. package/lib/coord/View.js +9 -0
  50. package/lib/coord/radar/Radar.js +4 -4
  51. package/lib/echarts.js +2 -2
  52. package/lib/layout/barGrid.js +17 -10
  53. package/lib/layout/barPolar.js +0 -5
  54. package/lib/scale/Interval.js +2 -2
  55. package/lib/stream/Scheduler.js +9 -1
  56. package/lib/util/graphic.js +2 -2
  57. package/map/js/china.js +1 -1
  58. package/map/js/province/chongqing.js +1 -1
  59. package/map/js/province/tianjin.js +1 -28
  60. package/map/json/china.json +1 -1
  61. package/map/json/province/chongqing.json +1 -1
  62. package/package.json +10 -6
  63. package/src/chart/bar/BarSeries.js +15 -1
  64. package/src/chart/bar/BarView.js +136 -12
  65. package/src/chart/candlestick/candlestickVisual.js +1 -1
  66. package/src/chart/funnel/FunnelSeries.js +1 -2
  67. package/src/chart/graph/GraphSeries.js +2 -1
  68. package/src/chart/graph/GraphView.js +2 -2
  69. package/src/chart/helper/EffectLine.js +23 -1
  70. package/src/chart/helper/Line.js +84 -26
  71. package/src/chart/helper/createRenderPlanner.js +5 -2
  72. package/src/chart/pie/PieView.js +1 -1
  73. package/src/chart/pie/labelLayout.js +1 -1
  74. package/src/chart/radar/RadarSeries.js +22 -0
  75. package/src/chart/sankey/SankeySeries.js +12 -1
  76. package/src/chart/sankey/SankeyView.js +49 -21
  77. package/src/chart/sankey/sankeyLayout.js +4 -3
  78. package/src/chart/tree/TreeSeries.js +5 -0
  79. package/src/chart/tree/TreeView.js +155 -22
  80. package/src/chart/treemap/TreemapView.js +57 -27
  81. package/src/component/axis/AxisBuilder.js +1 -1
  82. package/src/component/axis/CartesianAxisView.js +3 -86
  83. package/src/component/axis/SingleAxisView.js +21 -4
  84. package/src/component/axis/axisSplitHelper.js +114 -0
  85. package/src/component/brush/BrushView.js +8 -1
  86. package/src/component/brush/visualEncoding.js +6 -3
  87. package/src/component/helper/MapDraw.js +6 -6
  88. package/src/component/legend/ScrollableLegendView.js +18 -16
  89. package/src/component/marker/MarkLineModel.js +2 -1
  90. package/src/component/marker/markerHelper.js +8 -5
  91. package/src/component/tooltip/TooltipContent.js +59 -22
  92. package/src/component/tooltip/TooltipView.js +9 -7
  93. package/src/coord/View.js +10 -1
  94. package/src/coord/radar/Radar.js +5 -7
  95. package/src/echarts.js +2 -2
  96. package/src/layout/barGrid.js +14 -7
  97. package/src/layout/barPolar.js +0 -4
  98. package/src/scale/Interval.js +2 -2
  99. package/src/stream/Scheduler.js +8 -0
  100. package/src/util/graphic.js +2 -2
@@ -1285,7 +1285,11 @@ Draggable.prototype = {
1285
1285
 
1286
1286
  _dragStart: function (e) {
1287
1287
  var draggingTarget = e.target;
1288
- if (draggingTarget && draggingTarget.draggable) {
1288
+ // Find if there is draggable in the ancestor
1289
+ while (draggingTarget && !draggingTarget.draggable) {
1290
+ draggingTarget = draggingTarget.parent;
1291
+ }
1292
+ if (draggingTarget) {
1289
1293
  this._draggingTarget = draggingTarget;
1290
1294
  draggingTarget.dragging = true;
1291
1295
  this._x = e.offsetX;
@@ -1714,6 +1718,8 @@ function buildTransformer(src, dest) {
1714
1718
  var detCache = {};
1715
1719
  var det = determinant(mA, 8, 0, 0, 0, detCache);
1716
1720
  if (det === 0) {
1721
+ // can not make transformer when and only when
1722
+ // any three of the markers are collinear.
1717
1723
  return;
1718
1724
  }
1719
1725
 
@@ -1736,6 +1742,153 @@ function buildTransformer(src, dest) {
1736
1742
  };
1737
1743
  }
1738
1744
 
1745
+ var EVENT_SAVED_PROP = '___zrEVENTSAVED';
1746
+ var _calcOut$1 = [];
1747
+
1748
+ /**
1749
+ * Transform "local coord" from `elFrom` to `elTarget`.
1750
+ * "local coord": the coord based on the input `el`. The origin point is at
1751
+ * the position of "left: 0; top: 0;" in the `el`.
1752
+ *
1753
+ * Support when CSS transform is used.
1754
+ *
1755
+ * Having the `out` (that is, `[outX, outY]`), we can create an DOM element
1756
+ * and set the CSS style as "left: outX; top: outY;" and append it to `elTarge`
1757
+ * to locate the element.
1758
+ *
1759
+ * For example, this code below positions a child of `document.body` on the event
1760
+ * point, no matter whether `body` has `margin`/`paddin`/`transfrom`/... :
1761
+ * ```js
1762
+ * transformLocalCoord(out, container, document.body, event.offsetX, event.offsetY);
1763
+ * if (!eqNaN(out[0])) {
1764
+ * // Then locate the tip element on the event point.
1765
+ * var tipEl = document.createElement('div');
1766
+ * tipEl.style.cssText = 'position: absolute; left:' + out[0] + ';top:' + out[1] + ';';
1767
+ * document.body.appendChild(tipEl);
1768
+ * }
1769
+ * ```
1770
+ *
1771
+ * Notice: In some env this method is not supported. If called, `out` will be `[NaN, NaN]`.
1772
+ *
1773
+ * @param {Array.<number>} out [inX: number, inY: number] The output..
1774
+ * If can not transform, `out` will not be modified but return `false`.
1775
+ * @param {HTMLElement} elFrom The `[inX, inY]` is based on elFrom.
1776
+ * @param {HTMLElement} elTarget The `out` is based on elTarget.
1777
+ * @param {number} inX
1778
+ * @param {number} inY
1779
+ * @return {boolean} Whether transform successfully.
1780
+ */
1781
+ function transformLocalCoord(out, elFrom, elTarget, inX, inY) {
1782
+ return transformCoordWithViewport(_calcOut$1, elFrom, inX, inY, true)
1783
+ && transformCoordWithViewport(out, elTarget, _calcOut$1[0], _calcOut$1[1]);
1784
+ }
1785
+
1786
+ /**
1787
+ * Transform between a "viewport coord" and a "local coord".
1788
+ * "viewport coord": the coord based on the left-top corner of the viewport
1789
+ * of the browser.
1790
+ * "local coord": the coord based on the input `el`. The origin point is at
1791
+ * the position of "left: 0; top: 0;" in the `el`.
1792
+ *
1793
+ * Support the case when CSS transform is used on el.
1794
+ *
1795
+ * @param {Array.<number>} out [inX: number, inY: number] The output. If `inverse: false`,
1796
+ * it represents "local coord", otherwise "vireport coord".
1797
+ * If can not transform, `out` will not be modified but return `false`.
1798
+ * @param {HTMLElement} el The "local coord" is based on the `el`, see comment above.
1799
+ * @param {number} inX If `inverse: false`,
1800
+ * it represents "vireport coord", otherwise "local coord".
1801
+ * @param {number} inY If `inverse: false`,
1802
+ * it represents "vireport coord", otherwise "local coord".
1803
+ * @param {boolean} [inverse=false]
1804
+ * `true`: from "viewport coord" to "local coord".
1805
+ * `false`: from "local coord" to "viewport coord".
1806
+ * @return {boolean} Whether transform successfully.
1807
+ */
1808
+ function transformCoordWithViewport(out, el, inX, inY, inverse) {
1809
+ if (el.getBoundingClientRect && env$1.domSupported && !isCanvasEl(el)) {
1810
+ var saved = el[EVENT_SAVED_PROP] || (el[EVENT_SAVED_PROP] = {});
1811
+ var markers = prepareCoordMarkers(el, saved);
1812
+ var transformer = preparePointerTransformer(markers, saved, inverse);
1813
+ if (transformer) {
1814
+ transformer(out, inX, inY);
1815
+ return true;
1816
+ }
1817
+ }
1818
+ return false;
1819
+ }
1820
+
1821
+ function prepareCoordMarkers(el, saved) {
1822
+ var markers = saved.markers;
1823
+ if (markers) {
1824
+ return markers;
1825
+ }
1826
+
1827
+ markers = saved.markers = [];
1828
+ var propLR = ['left', 'right'];
1829
+ var propTB = ['top', 'bottom'];
1830
+
1831
+ for (var i = 0; i < 4; i++) {
1832
+ var marker = document.createElement('div');
1833
+ var stl = marker.style;
1834
+ var idxLR = i % 2;
1835
+ var idxTB = (i >> 1) % 2;
1836
+ stl.cssText = [
1837
+ 'position: absolute',
1838
+ 'visibility: hidden',
1839
+ 'padding: 0',
1840
+ 'margin: 0',
1841
+ 'border-width: 0',
1842
+ 'user-select: none',
1843
+ 'width:0',
1844
+ 'height:0',
1845
+ // 'width: 5px',
1846
+ // 'height: 5px',
1847
+ propLR[idxLR] + ':0',
1848
+ propTB[idxTB] + ':0',
1849
+ propLR[1 - idxLR] + ':auto',
1850
+ propTB[1 - idxTB] + ':auto',
1851
+ ''
1852
+ ].join('!important;');
1853
+ el.appendChild(marker);
1854
+ markers.push(marker);
1855
+ }
1856
+
1857
+ return markers;
1858
+ }
1859
+
1860
+ function preparePointerTransformer(markers, saved, inverse) {
1861
+ var transformerName = inverse ? 'invTrans' : 'trans';
1862
+ var transformer = saved[transformerName];
1863
+ var oldSrcCoords = saved.srcCoords;
1864
+ var oldCoordTheSame = true;
1865
+ var srcCoords = [];
1866
+ var destCoords = [];
1867
+
1868
+ for (var i = 0; i < 4; i++) {
1869
+ var rect = markers[i].getBoundingClientRect();
1870
+ var ii = 2 * i;
1871
+ var x = rect.left;
1872
+ var y = rect.top;
1873
+ srcCoords.push(x, y);
1874
+ oldCoordTheSame = oldCoordTheSame && oldSrcCoords && x === oldSrcCoords[ii] && y === oldSrcCoords[ii + 1];
1875
+ destCoords.push(markers[i].offsetLeft, markers[i].offsetTop);
1876
+ }
1877
+ // Cache to avoid time consuming of `buildTransformer`.
1878
+ return (oldCoordTheSame && transformer)
1879
+ ? transformer
1880
+ : (
1881
+ saved.srcCoords = srcCoords,
1882
+ saved[transformerName] = inverse
1883
+ ? buildTransformer(destCoords, srcCoords)
1884
+ : buildTransformer(srcCoords, destCoords)
1885
+ );
1886
+ }
1887
+
1888
+ function isCanvasEl(el) {
1889
+ return el.nodeName.toUpperCase() === 'CANVAS';
1890
+ }
1891
+
1739
1892
  /**
1740
1893
  * Utilities for mouse or touch events.
1741
1894
  */
@@ -1743,7 +1896,6 @@ function buildTransformer(src, dest) {
1743
1896
  var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
1744
1897
 
1745
1898
  var MOUSE_EVENT_REG = /^(?:mouse|pointer|contextmenu|drag|drop)|click/;
1746
- var EVENT_SAVED_PROP = '___zrEVENTSAVED';
1747
1899
  var _calcOut = [];
1748
1900
 
1749
1901
  /**
@@ -1808,11 +1960,11 @@ function clientToLocal(el, e, out, calculate) {
1808
1960
 
1809
1961
  function calculateZrXY(el, e, out) {
1810
1962
  // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect.
1811
- if (el.getBoundingClientRect && env$1.domSupported) {
1963
+ if (env$1.domSupported && el.getBoundingClientRect) {
1812
1964
  var ex = e.clientX;
1813
1965
  var ey = e.clientY;
1814
1966
 
1815
- if (el.nodeName.toUpperCase() === 'CANVAS') {
1967
+ if (isCanvasEl(el)) {
1816
1968
  // Original approach, which do not support CSS transform.
1817
1969
  // marker can not be locationed in a canvas container
1818
1970
  // (getBoundingClientRect is always 0). We do not support
@@ -1824,10 +1976,7 @@ function calculateZrXY(el, e, out) {
1824
1976
  return;
1825
1977
  }
1826
1978
  else {
1827
- var saved = el[EVENT_SAVED_PROP] || (el[EVENT_SAVED_PROP] = {});
1828
- var transformer = preparePointerTransformer(prepareCoordMarkers(el, saved), saved);
1829
- if (transformer) {
1830
- transformer(_calcOut, ex, ey);
1979
+ if (transformCoordWithViewport(_calcOut, el, ex, ey)) {
1831
1980
  out.zrX = _calcOut[0];
1832
1981
  out.zrY = _calcOut[1];
1833
1982
  return;
@@ -1837,70 +1986,6 @@ function calculateZrXY(el, e, out) {
1837
1986
  out.zrX = out.zrY = 0;
1838
1987
  }
1839
1988
 
1840
- function prepareCoordMarkers(el, saved) {
1841
- var markers = saved.markers;
1842
- if (markers) {
1843
- return markers;
1844
- }
1845
-
1846
- markers = saved.markers = [];
1847
- var propLR = ['left', 'right'];
1848
- var propTB = ['top', 'bottom'];
1849
-
1850
- for (var i = 0; i < 4; i++) {
1851
- var marker = document.createElement('div');
1852
- var stl = marker.style;
1853
- var idxLR = i % 2;
1854
- var idxTB = (i >> 1) % 2;
1855
- stl.cssText = [
1856
- 'position:absolute',
1857
- 'visibility: hidden',
1858
- 'padding: 0',
1859
- 'margin: 0',
1860
- 'border-width: 0',
1861
- 'width:0',
1862
- 'height:0',
1863
- // 'width: 5px',
1864
- // 'height: 5px',
1865
- propLR[idxLR] + ':0',
1866
- propTB[idxTB] + ':0',
1867
- propLR[1 - idxLR] + ':auto',
1868
- propTB[1 - idxTB] + ':auto',
1869
- ''
1870
- ].join('!important;');
1871
- el.appendChild(marker);
1872
- markers.push(marker);
1873
- }
1874
-
1875
- return markers;
1876
- }
1877
-
1878
- function preparePointerTransformer(markers, saved) {
1879
- var transformer = saved.transformer;
1880
- var oldSrcCoords = saved.srcCoords;
1881
- var useOld = true;
1882
- var srcCoords = [];
1883
- var destCoords = [];
1884
-
1885
- for (var i = 0; i < 4; i++) {
1886
- var rect = markers[i].getBoundingClientRect();
1887
- var ii = 2 * i;
1888
- var x = rect.left;
1889
- var y = rect.top;
1890
- srcCoords.push(x, y);
1891
- useOld &= oldSrcCoords && x === oldSrcCoords[ii] && y === oldSrcCoords[ii + 1];
1892
- destCoords.push(markers[i].offsetLeft, markers[i].offsetTop);
1893
- }
1894
-
1895
- // Cache to avoid time consuming of `buildTransformer`.
1896
- return useOld
1897
- ? transformer
1898
- : (
1899
- saved.srcCoords = srcCoords,
1900
- saved.transformer = buildTransformer(srcCoords, destCoords)
1901
- );
1902
- }
1903
-
1904
1989
  /**
1905
1990
  * Find native event compat for legency IE.
1906
1991
  * Should be called at the begining of a native event listener.
@@ -4770,7 +4855,7 @@ var Animator = function (target, loop, getter, setter) {
4770
4855
 
4771
4856
  Animator.prototype = {
4772
4857
  /**
4773
- * 设置动画关键帧
4858
+ * Set Animation keyframe
4774
4859
  * @param {number} time 关键帧时间,单位是ms
4775
4860
  * @param {Object} props 关键帧的属性值,key-value表示
4776
4861
  * @return {module:zrender/animation/Animator}
@@ -4849,7 +4934,7 @@ Animator.prototype = {
4849
4934
  }
4850
4935
  },
4851
4936
  /**
4852
- * 开始执行动画
4937
+ * Start the animation
4853
4938
  * @param {string|Function} [easing]
4854
4939
  * 动画缓动函数,详见{@link module:zrender/animation/easing}
4855
4940
  * @param {boolean} forceAnimate
@@ -4910,7 +4995,7 @@ Animator.prototype = {
4910
4995
  return this;
4911
4996
  },
4912
4997
  /**
4913
- * 停止动画
4998
+ * Stop animation
4914
4999
  * @param {boolean} forwardToLast If move to last frame before stop
4915
5000
  */
4916
5001
  stop: function (forwardToLast) {
@@ -4927,7 +5012,7 @@ Animator.prototype = {
4927
5012
  clipList.length = 0;
4928
5013
  },
4929
5014
  /**
4930
- * 设置动画延迟开始的时间
5015
+ * Set when animation delay starts
4931
5016
  * @param {number} time 单位ms
4932
5017
  * @return {module:zrender/animation/Animator}
4933
5018
  */
@@ -4936,7 +5021,7 @@ Animator.prototype = {
4936
5021
  return this;
4937
5022
  },
4938
5023
  /**
4939
- * 添加动画结束的回调
5024
+ * Add callback for animation end
4940
5025
  * @param {Function} cb
4941
5026
  * @return {module:zrender/animation/Animator}
4942
5027
  */
@@ -4988,7 +5073,7 @@ if (debugMode === 1) {
4988
5073
  var logError$1 = logError;
4989
5074
 
4990
5075
  /**
4991
- * @alias modue:zrender/mixin/Animatable
5076
+ * @alias module:zrender/mixin/Animatable
4992
5077
  * @constructor
4993
5078
  */
4994
5079
  var Animatable = function () {
@@ -10666,7 +10751,7 @@ Painter.prototype = {
10666
10751
  };
10667
10752
 
10668
10753
  /**
10669
- * 动画主类, 调度和管理所有动画控制器
10754
+ * Animation main class, dispatch and manage all animation controllers
10670
10755
  *
10671
10756
  * @module zrender/animation/Animation
10672
10757
  * @author pissang(https://github.com/pissang)
@@ -10731,14 +10816,14 @@ Animation.prototype = {
10731
10816
 
10732
10817
  constructor: Animation,
10733
10818
  /**
10734
- * 添加 clip
10819
+ * Add clip
10735
10820
  * @param {module:zrender/animation/Clip} clip
10736
10821
  */
10737
10822
  addClip: function (clip) {
10738
10823
  this._clips.push(clip);
10739
10824
  },
10740
10825
  /**
10741
- * 添加 animator
10826
+ * Add animator
10742
10827
  * @param {module:zrender/animation/Animator} animator
10743
10828
  */
10744
10829
  addAnimator: function (animator) {
@@ -10749,7 +10834,7 @@ Animation.prototype = {
10749
10834
  }
10750
10835
  },
10751
10836
  /**
10752
- * 删除动画片段
10837
+ * Delete animation clip
10753
10838
  * @param {module:zrender/animation/Clip} clip
10754
10839
  */
10755
10840
  removeClip: function (clip) {
@@ -10760,7 +10845,7 @@ Animation.prototype = {
10760
10845
  },
10761
10846
 
10762
10847
  /**
10763
- * 删除动画片段
10848
+ * Delete animation clip
10764
10849
  * @param {module:zrender/animation/Animator} animator
10765
10850
  */
10766
10851
  removeAnimator: function (animator) {
@@ -11027,13 +11112,16 @@ function normalizeGlobalEvent(instance, event) {
11027
11112
  * Detect whether the given el is in `painterRoot`.
11028
11113
  */
11029
11114
  function isLocalEl(instance, el) {
11115
+ var elTmp = el;
11030
11116
  var isLocal = false;
11031
- do {
11032
- el = el && el.parentNode;
11117
+ while (elTmp && elTmp.nodeType !== 9
11118
+ && !(
11119
+ isLocal = elTmp.domBelongToZr
11120
+ || (elTmp !== el && elTmp === instance.painterRoot)
11121
+ )
11122
+ ) {
11123
+ elTmp = elTmp.parentNode;
11033
11124
  }
11034
- while (el && el.nodeType !== 9 && !(
11035
- isLocal = el === instance.painterRoot
11036
- ));
11037
11125
  return isLocal;
11038
11126
  }
11039
11127
 
@@ -11488,7 +11576,7 @@ var instances$1 = {}; // ZRender实例map索引
11488
11576
  /**
11489
11577
  * @type {string}
11490
11578
  */
11491
- var version$1 = '4.2.0';
11579
+ var version$1 = '4.3.0';
11492
11580
 
11493
11581
  /**
11494
11582
  * Initializing a zrender instance
@@ -16377,12 +16465,10 @@ var round = Math.round;
16377
16465
  * @param {number} [inputShape.x2]
16378
16466
  * @param {number} [inputShape.y2]
16379
16467
  * @param {Object} [style]
16380
- * @param {number} [style.lineWidth]
16468
+ * @param {number} [style.lineWidth] If `null`/`undefined`/`0`, do not optimize.
16381
16469
  */
16382
16470
  function subPixelOptimizeLine$1(outputShape, inputShape, style) {
16383
- var lineWidth = style && style.lineWidth;
16384
-
16385
- if (!inputShape || !lineWidth) {
16471
+ if (!inputShape) {
16386
16472
  return;
16387
16473
  }
16388
16474
 
@@ -16391,20 +16477,22 @@ function subPixelOptimizeLine$1(outputShape, inputShape, style) {
16391
16477
  var y1 = inputShape.y1;
16392
16478
  var y2 = inputShape.y2;
16393
16479
 
16480
+ outputShape.x1 = x1;
16481
+ outputShape.x2 = x2;
16482
+ outputShape.y1 = y1;
16483
+ outputShape.y2 = y2;
16484
+
16485
+ var lineWidth = style && style.lineWidth;
16486
+ if (!lineWidth) {
16487
+ return;
16488
+ }
16489
+
16394
16490
  if (round(x1 * 2) === round(x2 * 2)) {
16395
16491
  outputShape.x1 = outputShape.x2 = subPixelOptimize$1(x1, lineWidth, true);
16396
16492
  }
16397
- else {
16398
- outputShape.x1 = x1;
16399
- outputShape.x2 = x2;
16400
- }
16401
16493
  if (round(y1 * 2) === round(y2 * 2)) {
16402
16494
  outputShape.y1 = outputShape.y2 = subPixelOptimize$1(y1, lineWidth, true);
16403
16495
  }
16404
- else {
16405
- outputShape.y1 = y1;
16406
- outputShape.y2 = y2;
16407
- }
16408
16496
  }
16409
16497
 
16410
16498
  /**
@@ -16420,12 +16508,10 @@ function subPixelOptimizeLine$1(outputShape, inputShape, style) {
16420
16508
  * @param {number} [inputShape.width]
16421
16509
  * @param {number} [inputShape.height]
16422
16510
  * @param {Object} [style]
16423
- * @param {number} [style.lineWidth]
16511
+ * @param {number} [style.lineWidth] If `null`/`undefined`/`0`, do not optimize.
16424
16512
  */
16425
16513
  function subPixelOptimizeRect$1(outputShape, inputShape, style) {
16426
- var lineWidth = style && style.lineWidth;
16427
-
16428
- if (!inputShape || !lineWidth) {
16514
+ if (!inputShape) {
16429
16515
  return;
16430
16516
  }
16431
16517
 
@@ -16434,6 +16520,16 @@ function subPixelOptimizeRect$1(outputShape, inputShape, style) {
16434
16520
  var originWidth = inputShape.width;
16435
16521
  var originHeight = inputShape.height;
16436
16522
 
16523
+ outputShape.x = originX;
16524
+ outputShape.y = originY;
16525
+ outputShape.width = originWidth;
16526
+ outputShape.height = originHeight;
16527
+
16528
+ var lineWidth = style && style.lineWidth;
16529
+ if (!lineWidth) {
16530
+ return;
16531
+ }
16532
+
16437
16533
  outputShape.x = subPixelOptimize$1(originX, lineWidth, true);
16438
16534
  outputShape.y = subPixelOptimize$1(originY, lineWidth, true);
16439
16535
  outputShape.width = Math.max(
@@ -16450,11 +16546,14 @@ function subPixelOptimizeRect$1(outputShape, inputShape, style) {
16450
16546
  * Sub pixel optimize for canvas
16451
16547
  *
16452
16548
  * @param {number} position Coordinate, such as x, y
16453
- * @param {number} lineWidth Should be nonnegative integer.
16549
+ * @param {number} lineWidth If `null`/`undefined`/`0`, do not optimize.
16454
16550
  * @param {boolean=} positiveOrNegative Default false (negative).
16455
16551
  * @return {number} Optimized position.
16456
16552
  */
16457
16553
  function subPixelOptimize$1(position, lineWidth, positiveOrNegative) {
16554
+ if (!lineWidth) {
16555
+ return position;
16556
+ }
16458
16557
  // Assure that (position + lineWidth / 2) is near integer edge,
16459
16558
  // otherwise line will be fuzzy in canvas.
16460
16559
  var doubledPosition = round(position * 2);
@@ -18155,7 +18254,7 @@ function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb)
18155
18254
  * configuration in series.
18156
18255
  *
18157
18256
  * Caution: this method will stop previous animation.
18158
- * So if do not use this method to one element twice before
18257
+ * So do not use this method to one element twice before
18159
18258
  * animation starts, unless you know what you are doing.
18160
18259
  *
18161
18260
  * @param {module:zrender/Element} el
@@ -18181,7 +18280,7 @@ function updateProps(el, props, animatableModel, dataIndex, cb) {
18181
18280
  * configuration in series.
18182
18281
  *
18183
18282
  * Caution: this method will stop previous animation.
18184
- * So if do not use this method to one element twice before
18283
+ * So do not use this method to one element twice before
18185
18284
  * animation starts, unless you know what you are doing.
18186
18285
  *
18187
18286
  * @param {module:zrender/Element} el
@@ -25019,8 +25118,11 @@ var createRenderPlanner = function () {
25019
25118
  var originalLarge = fields.large;
25020
25119
  var originalProgressive = fields.progressiveRender;
25021
25120
 
25022
- var large = fields.large = pipelineContext.large;
25023
- var progressive = fields.progressiveRender = pipelineContext.progressiveRender;
25121
+ // FIXME: if the planner works on a filtered series, `pipelineContext` does not
25122
+ // exists. See #11611 . Probably we need to modify this structure, see the comment
25123
+ // on `performRawSeries` in `Schedular.js`.
25124
+ var large = fields.large = pipelineContext && pipelineContext.large;
25125
+ var progressive = fields.progressiveRender = pipelineContext && pipelineContext.progressiveRender;
25024
25126
 
25025
25127
  return !!((originalLarge ^ large) || (originalProgressive ^ progressive)) && 'reset';
25026
25128
  };
@@ -26195,6 +26297,14 @@ function performStageTasks(scheduler, stageHandlers, ecModel, payload, opt) {
26195
26297
  task.dirty();
26196
26298
  }
26197
26299
  var performArgs = scheduler.getPerformArgs(task, opt.block);
26300
+ // FIXME
26301
+ // if intending to decalare `performRawSeries` in handlers, only
26302
+ // stream-independent (specifically, data item independent) operations can be
26303
+ // performed. Because is a series is filtered, most of the tasks will not
26304
+ // be performed. A stream-dependent operation probably cause wrong biz logic.
26305
+ // Perhaps we should not provide a separate callback for this case instead
26306
+ // of providing the config `performRawSeries`. The stream-dependent operaions
26307
+ // and stream-independent operations should better not be mixed.
26198
26308
  performArgs.skip = !stageHandler.performRawSeries
26199
26309
  && ecModel.isSeriesFiltered(task.context.model);
26200
26310
  updatePayload(task, payload);
@@ -27569,10 +27679,10 @@ var isFunction = isFunction$1;
27569
27679
  var isObject = isObject$1;
27570
27680
  var parseClassType = ComponentModel.parseClassType;
27571
27681
 
27572
- var version = '4.6.0';
27682
+ var version = '4.7.0';
27573
27683
 
27574
27684
  var dependencies = {
27575
- zrender: '4.2.0'
27685
+ zrender: '4.3.0'
27576
27686
  };
27577
27687
 
27578
27688
  var TEST_FRAME_REMAIN_TIME = 1;
@@ -33857,7 +33967,7 @@ var IntervalScale = Scale.extend({
33857
33967
 
33858
33968
  if (extent[0] < niceTickExtent[0]) {
33859
33969
  if (expandToNicedExtent) {
33860
- ticks.push(roundNumber(niceTickExtent[0] - interval));
33970
+ ticks.push(roundNumber(niceTickExtent[0] - interval, intervalPrecision));
33861
33971
  }
33862
33972
  else {
33863
33973
  ticks.push(extent[0]);
@@ -33883,7 +33993,7 @@ var IntervalScale = Scale.extend({
33883
33993
  var lastNiceTick = ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1];
33884
33994
  if (extent[1] > lastNiceTick) {
33885
33995
  if (expandToNicedExtent) {
33886
- ticks.push(lastNiceTick + interval);
33996
+ ticks.push(roundNumber(lastNiceTick + interval, intervalPrecision));
33887
33997
  }
33888
33998
  else {
33889
33999
  ticks.push(extent[1]);
@@ -34431,11 +34541,6 @@ function layout(seriesType, ecModel) {
34431
34541
  var value = data.get(valueDim, idx);
34432
34542
  var baseValue = data.get(baseDim, idx);
34433
34543
 
34434
- // If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
34435
- if (isNaN(value) || isNaN(baseValue)) {
34436
- continue;
34437
- }
34438
-
34439
34544
  var sign = value >= 0 ? 'p' : 'n';
34440
34545
  var baseCoord = valueAxisStart;
34441
34546
 
@@ -34468,7 +34573,10 @@ function layout(seriesType, ecModel) {
34468
34573
  if (Math.abs(width) < barMinHeight) {
34469
34574
  width = (width < 0 ? -1 : 1) * barMinHeight;
34470
34575
  }
34471
- stacked && (lastStackCoords[stackId][baseValue][sign] += width);
34576
+ // Ignore stack from NaN value
34577
+ if (!isNaN(width)) {
34578
+ stacked && (lastStackCoords[stackId][baseValue][sign] += width);
34579
+ }
34472
34580
  }
34473
34581
  else {
34474
34582
  var coord = cartesian.dataToPoint([baseValue, value]);
@@ -34481,7 +34589,10 @@ function layout(seriesType, ecModel) {
34481
34589
  // Include zero to has a positive bar
34482
34590
  height = (height <= 0 ? -1 : 1) * barMinHeight;
34483
34591
  }
34484
- stacked && (lastStackCoords[stackId][baseValue][sign] += height);
34592
+ // Ignore stack from NaN value
34593
+ if (!isNaN(height)) {
34594
+ stacked && (lastStackCoords[stackId][baseValue][sign] += height);
34595
+ }
34485
34596
  }
34486
34597
 
34487
34598
  data.setItemLayout(idx, {
@@ -34509,6 +34620,7 @@ var largeLayout = {
34509
34620
 
34510
34621
  var data = seriesModel.getData();
34511
34622
  var cartesian = seriesModel.coordinateSystem;
34623
+ var coordLayout = cartesian.grid.getRect();
34512
34624
  var baseAxis = cartesian.getBaseAxis();
34513
34625
  var valueAxis = cartesian.getOtherAxis(baseAxis);
34514
34626
  var valueDim = data.mapDimension(valueAxis.dim);
@@ -34528,6 +34640,7 @@ var largeLayout = {
34528
34640
  function progress(params, data) {
34529
34641
  var count = params.count;
34530
34642
  var largePoints = new LargeArr(count * 2);
34643
+ var largeBackgroundPoints = new LargeArr(count * 2);
34531
34644
  var largeDataIndices = new LargeArr(count);
34532
34645
  var dataIndex;
34533
34646
  var coord = [];
@@ -34541,7 +34654,9 @@ var largeLayout = {
34541
34654
 
34542
34655
  coord = cartesian.dataToPoint(valuePair, null, coord);
34543
34656
  // Data index might not be in order, depends on `progressiveChunkMode`.
34657
+ largeBackgroundPoints[pointsOffset] = valueAxisHorizontal ? coordLayout.x + coordLayout.width : coord[0];
34544
34658
  largePoints[pointsOffset++] = coord[0];
34659
+ largeBackgroundPoints[pointsOffset] = valueAxisHorizontal ? coord[1] : coordLayout.y + coordLayout.height;
34545
34660
  largePoints[pointsOffset++] = coord[1];
34546
34661
  largeDataIndices[idxOffset++] = dataIndex;
34547
34662
  }
@@ -34549,8 +34664,10 @@ var largeLayout = {
34549
34664
  data.setLayout({
34550
34665
  largePoints: largePoints,
34551
34666
  largeDataIndices: largeDataIndices,
34667
+ largeBackgroundPoints: largeBackgroundPoints,
34552
34668
  barWidth: barWidth,
34553
34669
  valueAxisStart: getValueAxisStart(baseAxis, valueAxis, false),
34670
+ backgroundStart: valueAxisHorizontal ? coordLayout.x : coordLayout.y,
34554
34671
  valueAxisHorizontal: valueAxisHorizontal
34555
34672
  });
34556
34673
  }
@@ -42437,6 +42554,117 @@ function layout$1(gridModel, axisModel, opt) {
42437
42554
  * under the License.
42438
42555
  */
42439
42556
 
42557
+ function rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel) {
42558
+ var axis = axisModel.axis;
42559
+
42560
+ if (axis.scale.isBlank()) {
42561
+ return;
42562
+ }
42563
+
42564
+ var splitAreaModel = axisModel.getModel('splitArea');
42565
+ var areaStyleModel = splitAreaModel.getModel('areaStyle');
42566
+ var areaColors = areaStyleModel.get('color');
42567
+
42568
+ var gridRect = gridModel.coordinateSystem.getRect();
42569
+
42570
+ var ticksCoords = axis.getTicksCoords({
42571
+ tickModel: splitAreaModel,
42572
+ clamp: true
42573
+ });
42574
+
42575
+ if (!ticksCoords.length) {
42576
+ return;
42577
+ }
42578
+
42579
+ // For Making appropriate splitArea animation, the color and anid
42580
+ // should be corresponding to previous one if possible.
42581
+ var areaColorsLen = areaColors.length;
42582
+ var lastSplitAreaColors = axisView.__splitAreaColors;
42583
+ var newSplitAreaColors = createHashMap();
42584
+ var colorIndex = 0;
42585
+ if (lastSplitAreaColors) {
42586
+ for (var i = 0; i < ticksCoords.length; i++) {
42587
+ var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
42588
+ if (cIndex != null) {
42589
+ colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
42590
+ break;
42591
+ }
42592
+ }
42593
+ }
42594
+
42595
+ var prev = axis.toGlobalCoord(ticksCoords[0].coord);
42596
+
42597
+ var areaStyle = areaStyleModel.getAreaStyle();
42598
+ areaColors = isArray(areaColors) ? areaColors : [areaColors];
42599
+
42600
+ for (var i = 1; i < ticksCoords.length; i++) {
42601
+ var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
42602
+
42603
+ var x;
42604
+ var y;
42605
+ var width;
42606
+ var height;
42607
+ if (axis.isHorizontal()) {
42608
+ x = prev;
42609
+ y = gridRect.y;
42610
+ width = tickCoord - x;
42611
+ height = gridRect.height;
42612
+ prev = x + width;
42613
+ }
42614
+ else {
42615
+ x = gridRect.x;
42616
+ y = prev;
42617
+ width = gridRect.width;
42618
+ height = tickCoord - y;
42619
+ prev = y + height;
42620
+ }
42621
+
42622
+ var tickValue = ticksCoords[i - 1].tickValue;
42623
+ tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
42624
+
42625
+ axisGroup.add(new Rect({
42626
+ anid: tickValue != null ? 'area_' + tickValue : null,
42627
+ shape: {
42628
+ x: x,
42629
+ y: y,
42630
+ width: width,
42631
+ height: height
42632
+ },
42633
+ style: defaults({
42634
+ fill: areaColors[colorIndex]
42635
+ }, areaStyle),
42636
+ silent: true
42637
+ }));
42638
+
42639
+ colorIndex = (colorIndex + 1) % areaColorsLen;
42640
+ }
42641
+
42642
+ axisView.__splitAreaColors = newSplitAreaColors;
42643
+ }
42644
+
42645
+ function rectCoordAxisHandleRemove(axisView) {
42646
+ axisView.__splitAreaColors = null;
42647
+ }
42648
+
42649
+ /*
42650
+ * Licensed to the Apache Software Foundation (ASF) under one
42651
+ * or more contributor license agreements. See the NOTICE file
42652
+ * distributed with this work for additional information
42653
+ * regarding copyright ownership. The ASF licenses this file
42654
+ * to you under the Apache License, Version 2.0 (the
42655
+ * "License"); you may not use this file except in compliance
42656
+ * with the License. You may obtain a copy of the License at
42657
+ *
42658
+ * http://www.apache.org/licenses/LICENSE-2.0
42659
+ *
42660
+ * Unless required by applicable law or agreed to in writing,
42661
+ * software distributed under the License is distributed on an
42662
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
42663
+ * KIND, either express or implied. See the License for the
42664
+ * specific language governing permissions and limitations
42665
+ * under the License.
42666
+ */
42667
+
42440
42668
  var axisBuilderAttrs = [
42441
42669
  'axisLine', 'axisTickLabel', 'axisName'
42442
42670
  ];
@@ -42488,7 +42716,7 @@ var CartesianAxisView = AxisView.extend({
42488
42716
  },
42489
42717
 
42490
42718
  remove: function () {
42491
- this._splitAreaColors = null;
42719
+ rectCoordAxisHandleRemove(this);
42492
42720
  },
42493
42721
 
42494
42722
  /**
@@ -42620,91 +42848,7 @@ var CartesianAxisView = AxisView.extend({
42620
42848
  * @private
42621
42849
  */
42622
42850
  _splitArea: function (axisModel, gridModel) {
42623
- var axis = axisModel.axis;
42624
-
42625
- if (axis.scale.isBlank()) {
42626
- return;
42627
- }
42628
-
42629
- var splitAreaModel = axisModel.getModel('splitArea');
42630
- var areaStyleModel = splitAreaModel.getModel('areaStyle');
42631
- var areaColors = areaStyleModel.get('color');
42632
-
42633
- var gridRect = gridModel.coordinateSystem.getRect();
42634
-
42635
- var ticksCoords = axis.getTicksCoords({
42636
- tickModel: splitAreaModel,
42637
- clamp: true
42638
- });
42639
-
42640
- if (!ticksCoords.length) {
42641
- return;
42642
- }
42643
-
42644
- // For Making appropriate splitArea animation, the color and anid
42645
- // should be corresponding to previous one if possible.
42646
- var areaColorsLen = areaColors.length;
42647
- var lastSplitAreaColors = this._splitAreaColors;
42648
- var newSplitAreaColors = createHashMap();
42649
- var colorIndex = 0;
42650
- if (lastSplitAreaColors) {
42651
- for (var i = 0; i < ticksCoords.length; i++) {
42652
- var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
42653
- if (cIndex != null) {
42654
- colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
42655
- break;
42656
- }
42657
- }
42658
- }
42659
-
42660
- var prev = axis.toGlobalCoord(ticksCoords[0].coord);
42661
-
42662
- var areaStyle = areaStyleModel.getAreaStyle();
42663
- areaColors = isArray(areaColors) ? areaColors : [areaColors];
42664
-
42665
- for (var i = 1; i < ticksCoords.length; i++) {
42666
- var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
42667
-
42668
- var x;
42669
- var y;
42670
- var width;
42671
- var height;
42672
- if (axis.isHorizontal()) {
42673
- x = prev;
42674
- y = gridRect.y;
42675
- width = tickCoord - x;
42676
- height = gridRect.height;
42677
- prev = x + width;
42678
- }
42679
- else {
42680
- x = gridRect.x;
42681
- y = prev;
42682
- width = gridRect.width;
42683
- height = tickCoord - y;
42684
- prev = y + height;
42685
- }
42686
-
42687
- var tickValue = ticksCoords[i - 1].tickValue;
42688
- tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
42689
-
42690
- this._axisGroup.add(new Rect({
42691
- anid: tickValue != null ? 'area_' + tickValue : null,
42692
- shape: {
42693
- x: x,
42694
- y: y,
42695
- width: width,
42696
- height: height
42697
- },
42698
- style: defaults({
42699
- fill: areaColors[colorIndex]
42700
- }, areaStyle),
42701
- silent: true
42702
- }));
42703
-
42704
- colorIndex = (colorIndex + 1) % areaColorsLen;
42705
- }
42706
-
42707
- this._splitAreaColors = newSplitAreaColors;
42851
+ rectCoordAxisBuildSplitArea(this, this._axisGroup, axisModel, gridModel);
42708
42852
  }
42709
42853
  });
42710
42854
 
@@ -42950,7 +43094,21 @@ BaseBarSeries.extend({
42950
43094
 
42951
43095
  // If use caps on two sides of bars
42952
43096
  // Only available on tangential polar bar
42953
- roundCap: false
43097
+ roundCap: false,
43098
+
43099
+ showBackground: false,
43100
+ backgroundStyle: {
43101
+ color: 'rgba(180, 180, 180, 0.2)',
43102
+ borderColor: null,
43103
+ borderWidth: 0,
43104
+ borderType: 'solid',
43105
+ borderRadius: 0,
43106
+ shadowBlur: 0,
43107
+ shadowColor: null,
43108
+ shadowOffsetX: 0,
43109
+ shadowOffsetY: 0,
43110
+ opacity: 1
43111
+ }
42954
43112
  }
42955
43113
  });
42956
43114
 
@@ -43255,15 +43413,28 @@ extendChartView({
43255
43413
 
43256
43414
  var roundCap = seriesModel.get('roundCap', true);
43257
43415
 
43416
+ var drawBackground = seriesModel.get('showBackground', true);
43417
+ var backgroundModel = seriesModel.getModel('backgroundStyle');
43418
+
43419
+ var bgEls = [];
43420
+ var oldBgEls = this._backgroundEls || [];
43421
+
43258
43422
  data.diff(oldData)
43259
43423
  .add(function (dataIndex) {
43424
+ var itemModel = data.getItemModel(dataIndex);
43425
+ var layout = getLayout[coord.type](data, dataIndex, itemModel);
43426
+
43427
+ if (drawBackground) {
43428
+ var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, layout);
43429
+ bgEl.useStyle(backgroundModel.getBarItemStyle());
43430
+ bgEls[dataIndex] = bgEl;
43431
+ }
43432
+
43433
+ // If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
43260
43434
  if (!data.hasValue(dataIndex)) {
43261
43435
  return;
43262
43436
  }
43263
43437
 
43264
- var itemModel = data.getItemModel(dataIndex);
43265
- var layout = getLayout[coord.type](data, dataIndex, itemModel);
43266
-
43267
43438
  if (needsClip) {
43268
43439
  // Clip will modify the layout params.
43269
43440
  // And return a boolean to determine if the shape are fully clipped.
@@ -43286,16 +43457,24 @@ extendChartView({
43286
43457
  );
43287
43458
  })
43288
43459
  .update(function (newIndex, oldIndex) {
43289
- var el = oldData.getItemGraphicEl(oldIndex);
43460
+ var itemModel = data.getItemModel(newIndex);
43461
+ var layout = getLayout[coord.type](data, newIndex, itemModel);
43462
+
43463
+ if (drawBackground) {
43464
+ var bgEl = oldBgEls[oldIndex];
43465
+ bgEl.useStyle(backgroundModel.getBarItemStyle());
43466
+ bgEls[newIndex] = bgEl;
43290
43467
 
43468
+ var shape = createBackgroundShape(isHorizontalOrRadial, layout, coord);
43469
+ updateProps(bgEl, { shape: shape }, animationModel, newIndex);
43470
+ }
43471
+
43472
+ var el = oldData.getItemGraphicEl(oldIndex);
43291
43473
  if (!data.hasValue(newIndex)) {
43292
43474
  group.remove(el);
43293
43475
  return;
43294
43476
  }
43295
43477
 
43296
- var itemModel = data.getItemModel(newIndex);
43297
- var layout = getLayout[coord.type](data, newIndex, itemModel);
43298
-
43299
43478
  if (needsClip) {
43300
43479
  var isClipped = clip[coord.type](coordSysClipArea, layout);
43301
43480
  if (isClipped) {
@@ -43333,6 +43512,15 @@ extendChartView({
43333
43512
  })
43334
43513
  .execute();
43335
43514
 
43515
+ var bgGroup = this._backgroundGroup || (this._backgroundGroup = new Group());
43516
+ bgGroup.removeAll();
43517
+
43518
+ for (var i = 0; i < bgEls.length; ++i) {
43519
+ bgGroup.add(bgEls[i]);
43520
+ }
43521
+ group.add(bgGroup);
43522
+ this._backgroundEls = bgEls;
43523
+
43336
43524
  this._data = data;
43337
43525
  },
43338
43526
 
@@ -43353,6 +43541,7 @@ extendChartView({
43353
43541
  },
43354
43542
 
43355
43543
  _incrementalRenderLarge: function (params, seriesModel) {
43544
+ this._removeBackground();
43356
43545
  createLarge(seriesModel, this.group, true);
43357
43546
  },
43358
43547
 
@@ -43366,6 +43555,9 @@ extendChartView({
43366
43555
  var group = this.group;
43367
43556
  var data = this._data;
43368
43557
  if (ecModel && ecModel.get('animation') && data && !this._isLargeDraw) {
43558
+ this._removeBackground();
43559
+ this._backgroundEls = [];
43560
+
43369
43561
  data.eachItemGraphicEl(function (el) {
43370
43562
  if (el.type === 'sector') {
43371
43563
  removeSector(el.dataIndex, ecModel, el);
@@ -43379,6 +43571,11 @@ extendChartView({
43379
43571
  group.removeAll();
43380
43572
  }
43381
43573
  this._data = null;
43574
+ },
43575
+
43576
+ _removeBackground: function () {
43577
+ this.group.remove(this._backgroundGroup);
43578
+ this._backgroundGroup = null;
43382
43579
  }
43383
43580
 
43384
43581
  });
@@ -43436,7 +43633,12 @@ var elementCreator = {
43436
43633
  dataIndex, layout, isHorizontal,
43437
43634
  animationModel, isUpdate
43438
43635
  ) {
43439
- var rect = new Rect({shape: extend({}, layout)});
43636
+ var rect = new Rect({
43637
+ shape: extend({}, layout),
43638
+ z2: 1
43639
+ });
43640
+
43641
+ rect.name = 'item';
43440
43642
 
43441
43643
  // Animation
43442
43644
  if (animationModel) {
@@ -43466,9 +43668,12 @@ var elementCreator = {
43466
43668
  var ShapeClass = (!isRadial && roundCap) ? Sausage : Sector;
43467
43669
 
43468
43670
  var sector = new ShapeClass({
43469
- shape: defaults({clockwise: clockwise}, layout)
43671
+ shape: defaults({clockwise: clockwise}, layout),
43672
+ z2: 1
43470
43673
  });
43471
43674
 
43675
+ sector.name = 'item';
43676
+
43472
43677
  // Animation
43473
43678
  if (animationModel) {
43474
43679
  var sectorShape = sector.shape;
@@ -43588,7 +43793,10 @@ function updateStyle(
43588
43793
  // In case width or height are too small.
43589
43794
  function getLineWidth(itemModel, rawLayout) {
43590
43795
  var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
43591
- return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
43796
+ // width or height may be NaN for empty data
43797
+ var width = isNaN(rawLayout.width) ? Number.MAX_VALUE : Math.abs(rawLayout.width);
43798
+ var height = isNaN(rawLayout.height) ? Number.MAX_VALUE : Math.abs(rawLayout.height);
43799
+ return Math.min(lineWidth, width, height);
43592
43800
  }
43593
43801
 
43594
43802
 
@@ -43620,13 +43828,38 @@ function createLarge(seriesModel, group, incremental) {
43620
43828
  var baseDimIdx = data.getLayout('valueAxisHorizontal') ? 1 : 0;
43621
43829
  startPoint[1 - baseDimIdx] = data.getLayout('valueAxisStart');
43622
43830
 
43831
+ var largeDataIndices = data.getLayout('largeDataIndices');
43832
+ var barWidth = data.getLayout('barWidth');
43833
+
43834
+ var backgroundModel = seriesModel.getModel('backgroundStyle');
43835
+ var drawBackground = seriesModel.get('showBackground', true);
43836
+
43837
+ if (drawBackground) {
43838
+ var points = data.getLayout('largeBackgroundPoints');
43839
+ var backgroundStartPoint = [];
43840
+ backgroundStartPoint[1 - baseDimIdx] = data.getLayout('backgroundStart');
43841
+
43842
+ var bgEl = new LargePath({
43843
+ shape: {points: points},
43844
+ incremental: !!incremental,
43845
+ __startPoint: backgroundStartPoint,
43846
+ __baseDimIdx: baseDimIdx,
43847
+ __largeDataIndices: largeDataIndices,
43848
+ __barWidth: barWidth,
43849
+ silent: true,
43850
+ z2: 0
43851
+ });
43852
+ setLargeBackgroundStyle(bgEl, backgroundModel, data);
43853
+ group.add(bgEl);
43854
+ }
43855
+
43623
43856
  var el = new LargePath({
43624
43857
  shape: {points: data.getLayout('largePoints')},
43625
43858
  incremental: !!incremental,
43626
43859
  __startPoint: startPoint,
43627
43860
  __baseDimIdx: baseDimIdx,
43628
- __largeDataIndices: data.getLayout('largeDataIndices'),
43629
- __barWidth: data.getLayout('barWidth')
43861
+ __largeDataIndices: largeDataIndices,
43862
+ __barWidth: barWidth
43630
43863
  });
43631
43864
  group.add(el);
43632
43865
  setLargeStyle(el, seriesModel, data);
@@ -43691,6 +43924,55 @@ function setLargeStyle(el, seriesModel, data) {
43691
43924
  el.style.lineWidth = data.getLayout('barWidth');
43692
43925
  }
43693
43926
 
43927
+ function setLargeBackgroundStyle(el, backgroundModel, data) {
43928
+ var borderColor = backgroundModel.get('borderColor') || backgroundModel.get('color');
43929
+ var itemStyle = backgroundModel.getItemStyle(['color', 'borderColor']);
43930
+
43931
+ el.useStyle(itemStyle);
43932
+ el.style.fill = null;
43933
+ el.style.stroke = borderColor;
43934
+ el.style.lineWidth = data.getLayout('barWidth');
43935
+ }
43936
+
43937
+ function createBackgroundShape(isHorizontalOrRadial, layout, coord) {
43938
+ var coordLayout;
43939
+ var isPolar = coord.type === 'polar';
43940
+ if (isPolar) {
43941
+ coordLayout = coord.getArea();
43942
+ }
43943
+ else {
43944
+ coordLayout = coord.grid.getRect();
43945
+ }
43946
+
43947
+ if (isPolar) {
43948
+ return {
43949
+ cx: coordLayout.cx,
43950
+ cy: coordLayout.cy,
43951
+ r0: isHorizontalOrRadial ? coordLayout.r0 : layout.r0,
43952
+ r: isHorizontalOrRadial ? coordLayout.r : layout.r,
43953
+ startAngle: isHorizontalOrRadial ? layout.startAngle : 0,
43954
+ endAngle: isHorizontalOrRadial ? layout.endAngle : Math.PI * 2
43955
+ };
43956
+ }
43957
+ else {
43958
+ return {
43959
+ x: isHorizontalOrRadial ? layout.x : coordLayout.x,
43960
+ y: isHorizontalOrRadial ? coordLayout.y : layout.y,
43961
+ width: isHorizontalOrRadial ? layout.width : coordLayout.width,
43962
+ height: isHorizontalOrRadial ? coordLayout.height : layout.height
43963
+ };
43964
+ }
43965
+ }
43966
+
43967
+ function createBackgroundEl(coord, isHorizontalOrRadial, layout) {
43968
+ var ElementClz = coord.type === 'polar' ? Sector : Rect;
43969
+ return new ElementClz({
43970
+ shape: createBackgroundShape(isHorizontalOrRadial, layout, coord),
43971
+ silent: true,
43972
+ z2: 0
43973
+ });
43974
+ }
43975
+
43694
43976
  /*
43695
43977
  * Licensed to the Apache Software Foundation (ASF) under one
43696
43978
  * or more contributor license agreements. See the NOTICE file
@@ -44300,7 +44582,7 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
44300
44582
  toggleItemSelected(
44301
44583
  this,
44302
44584
  data.getItemLayout(idx),
44303
- seriesModel.isSelected(null, idx),
44585
+ seriesModel.isSelected(data.getName(idx)),
44304
44586
  seriesModel.get('selectedOffset'),
44305
44587
  seriesModel.get('animation')
44306
44588
  );
@@ -45052,7 +45334,7 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, viewLeft, vie
45052
45334
  inside: isLabelInside,
45053
45335
  labelDistance: labelDistance,
45054
45336
  labelAlignTo: labelAlignTo,
45055
- labelMargin:labelMargin,
45337
+ labelMargin: labelMargin,
45056
45338
  bleedMargin: bleedMargin,
45057
45339
  textRect: textRect,
45058
45340
  text: text,
@@ -48417,24 +48699,63 @@ function assembleCssText(tooltipModel) {
48417
48699
  return cssText.join(';') + ';';
48418
48700
  }
48419
48701
 
48702
+ // If not able to make, do not modify the input `out`.
48703
+ function makeStyleCoord(out, zr, appendToBody, zrX, zrY) {
48704
+ var zrPainter = zr && zr.painter;
48705
+
48706
+ if (appendToBody) {
48707
+ var zrViewportRoot = zrPainter && zrPainter.getViewportRoot();
48708
+ if (zrViewportRoot) {
48709
+ // Some APPs might use scale on body, so we support CSS transform here.
48710
+ transformLocalCoord(out, zrViewportRoot, document.body, zrX, zrY);
48711
+ }
48712
+ }
48713
+ else {
48714
+ out[0] = zrX;
48715
+ out[1] = zrY;
48716
+ // xy should be based on canvas root. But tooltipContent is
48717
+ // the sibling of canvas root. So padding of ec container
48718
+ // should be considered here.
48719
+ var viewportRootOffset = zrPainter && zrPainter.getViewportRootOffset();
48720
+ if (viewportRootOffset) {
48721
+ out[0] += viewportRootOffset.offsetLeft;
48722
+ out[1] += viewportRootOffset.offsetTop;
48723
+ }
48724
+ }
48725
+ }
48726
+
48420
48727
  /**
48421
48728
  * @alias module:echarts/component/tooltip/TooltipContent
48729
+ * @param {HTMLElement} container
48730
+ * @param {ExtensionAPI} api
48731
+ * @param {Object} [opt]
48732
+ * @param {boolean} [opt.appendToBody]
48733
+ * `false`: the DOM element will be inside the container. Default value.
48734
+ * `true`: the DOM element will be appended to HTML body, which avoid
48735
+ * some overflow clip but intrude outside of the container.
48422
48736
  * @constructor
48423
48737
  */
48424
- function TooltipContent(container, api) {
48738
+ function TooltipContent(container, api, opt) {
48425
48739
  if (env$1.wxa) {
48426
48740
  return null;
48427
48741
  }
48428
48742
 
48429
48743
  var el = document.createElement('div');
48744
+ el.domBelongToZr = true;
48745
+ this.el = el;
48430
48746
  var zr = this._zr = api.getZr();
48747
+ var appendToBody = this._appendToBody = opt && opt.appendToBody;
48431
48748
 
48432
- this.el = el;
48749
+ this._styleCoord = [0, 0];
48433
48750
 
48434
- this._x = api.getWidth() / 2;
48435
- this._y = api.getHeight() / 2;
48751
+ makeStyleCoord(this._styleCoord, zr, appendToBody, api.getWidth() / 2, api.getHeight() / 2);
48436
48752
 
48437
- container.appendChild(el);
48753
+ if (appendToBody) {
48754
+ document.body.appendChild(el);
48755
+ }
48756
+ else {
48757
+ container.appendChild(el);
48758
+ }
48438
48759
 
48439
48760
  this._container = container;
48440
48761
 
@@ -48468,7 +48789,8 @@ function TooltipContent(container, api) {
48468
48789
  // Try trigger zrender event to avoid mouse
48469
48790
  // in and out shape too frequently
48470
48791
  var handler = zr.handler;
48471
- normalizeEvent(container, e, true);
48792
+ var zrViewportRoot = zr.painter.getViewportRoot();
48793
+ normalizeEvent(zrViewportRoot, e, true);
48472
48794
  handler.dispatch('mousemove', e);
48473
48795
  }
48474
48796
  };
@@ -48513,12 +48835,13 @@ TooltipContent.prototype = {
48513
48835
  show: function (tooltipModel) {
48514
48836
  clearTimeout(this._hideTimeout);
48515
48837
  var el = this.el;
48838
+ var styleCoord = this._styleCoord;
48516
48839
 
48517
48840
  el.style.cssText = gCssText + assembleCssText(tooltipModel)
48518
48841
  // Because of the reason described in:
48519
48842
  // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
48520
48843
  // we should set initial value to `left` and `top`.
48521
- + ';left:' + this._x + 'px;top:' + this._y + 'px;'
48844
+ + ';left:' + styleCoord[0] + 'px;top:' + styleCoord[1] + 'px;'
48522
48845
  + (tooltipModel.get('extraCssText') || '');
48523
48846
 
48524
48847
  el.style.display = el.innerHTML ? 'block' : 'none';
@@ -48546,23 +48869,13 @@ TooltipContent.prototype = {
48546
48869
  return [el.clientWidth, el.clientHeight];
48547
48870
  },
48548
48871
 
48549
- moveTo: function (x, y) {
48550
- // xy should be based on canvas root. But tooltipContent is
48551
- // the sibling of canvas root. So padding of ec container
48552
- // should be considered here.
48553
- var zr = this._zr;
48554
- var viewportRootOffset;
48555
- if (zr && zr.painter && (viewportRootOffset = zr.painter.getViewportRootOffset())) {
48556
- x += viewportRootOffset.offsetLeft;
48557
- y += viewportRootOffset.offsetTop;
48558
- }
48872
+ moveTo: function (zrX, zrY) {
48873
+ var styleCoord = this._styleCoord;
48874
+ makeStyleCoord(styleCoord, this._zr, this._appendToBody, zrX, zrY);
48559
48875
 
48560
48876
  var style = this.el.style;
48561
- style.left = x + 'px';
48562
- style.top = y + 'px';
48563
-
48564
- this._x = x;
48565
- this._y = y;
48877
+ style.left = styleCoord[0] + 'px';
48878
+ style.top = styleCoord[1] + 'px';
48566
48879
  },
48567
48880
 
48568
48881
  hide: function () {
@@ -48588,6 +48901,10 @@ TooltipContent.prototype = {
48588
48901
  return this._show;
48589
48902
  },
48590
48903
 
48904
+ dispose: function () {
48905
+ this.el.parentNode.removeChild(this.el);
48906
+ },
48907
+
48591
48908
  getOuterSize: function () {
48592
48909
  var width = this.el.clientWidth;
48593
48910
  var height = this.el.clientHeight;
@@ -48604,6 +48921,7 @@ TooltipContent.prototype = {
48604
48921
 
48605
48922
  return {width: width, height: height};
48606
48923
  }
48924
+
48607
48925
  };
48608
48926
 
48609
48927
  /*
@@ -48835,7 +49153,9 @@ extendComponentView({
48835
49153
 
48836
49154
  var tooltipContent;
48837
49155
  if (this._renderMode === 'html') {
48838
- tooltipContent = new TooltipContent(api.getDom(), api);
49156
+ tooltipContent = new TooltipContent(api.getDom(), api, {
49157
+ appendToBody: tooltipModel.get('appendToBody', true)
49158
+ });
48839
49159
  this._newLine = '<br/>';
48840
49160
  }
48841
49161
  else {
@@ -48988,7 +49308,6 @@ extendComponentView({
48988
49308
  offsetX: payload.x,
48989
49309
  offsetY: payload.y,
48990
49310
  position: payload.position,
48991
- event: {},
48992
49311
  dataByCoordSys: payload.dataByCoordSys,
48993
49312
  tooltipOption: payload.tooltipOption
48994
49313
  }, dispatchAction);
@@ -49007,8 +49326,7 @@ extendComponentView({
49007
49326
  offsetX: cx,
49008
49327
  offsetY: cy,
49009
49328
  position: payload.position,
49010
- target: pointInfo.el,
49011
- event: {}
49329
+ target: pointInfo.el
49012
49330
  }, dispatchAction);
49013
49331
  }
49014
49332
  }
@@ -49025,8 +49343,7 @@ extendComponentView({
49025
49343
  offsetX: payload.x,
49026
49344
  offsetY: payload.y,
49027
49345
  position: payload.position,
49028
- target: api.getZr().findHover(payload.x, payload.y).target,
49029
- event: {}
49346
+ target: api.getZr().findHover(payload.x, payload.y).target
49030
49347
  }, dispatchAction);
49031
49348
  }
49032
49349
  },
@@ -49132,7 +49449,9 @@ extendComponentView({
49132
49449
  _showAxisTooltip: function (dataByCoordSys, e) {
49133
49450
  var ecModel = this._ecModel;
49134
49451
  var globalTooltipModel = this._tooltipModel;
49452
+
49135
49453
  var point = [e.offsetX, e.offsetY];
49454
+
49136
49455
  var singleDefaultHTML = [];
49137
49456
  var singleParamsList = [];
49138
49457
  var singleTooltipModel = buildTooltipModel([
@@ -49388,6 +49707,7 @@ extendComponentView({
49388
49707
  _updatePosition: function (tooltipModel, positionExpr, x, y, content, params, el) {
49389
49708
  var viewWidth = this._api.getWidth();
49390
49709
  var viewHeight = this._api.getHeight();
49710
+
49391
49711
  positionExpr = positionExpr || tooltipModel.get('position');
49392
49712
 
49393
49713
  var contentSize = content.getSize();
@@ -49506,7 +49826,7 @@ extendComponentView({
49506
49826
  if (env$1.node) {
49507
49827
  return;
49508
49828
  }
49509
- this._tooltipContent.hide();
49829
+ this._tooltipContent.dispose();
49510
49830
  unregister('itemTooltip', api);
49511
49831
  }
49512
49832
  });
@@ -51351,26 +51671,28 @@ var ScrollableLegendView = LegendView.extend({
51351
51671
  },
51352
51672
 
51353
51673
  _findTargetItemIndex: function (targetDataIndex) {
51674
+ if (!this._showController) {
51675
+ return 0;
51676
+ }
51677
+
51354
51678
  var index;
51355
51679
  var contentGroup = this.getContentGroup();
51356
51680
  var defaultIndex;
51357
51681
 
51358
- if (this._showController) {
51359
- contentGroup.eachChild(function (child, idx) {
51360
- var legendDataIdx = child.__legendDataIndex;
51361
- // FIXME
51362
- // If the given targetDataIndex (from model) is illegal,
51363
- // we use defualtIndex. But the index on the legend model and
51364
- // action payload is still illegal. That case will not be
51365
- // changed until some scenario requires.
51366
- if (defaultIndex == null && legendDataIdx != null) {
51367
- defaultIndex = idx;
51368
- }
51369
- if (legendDataIdx === targetDataIndex) {
51370
- index = idx;
51371
- }
51372
- });
51373
- }
51682
+ contentGroup.eachChild(function (child, idx) {
51683
+ var legendDataIdx = child.__legendDataIndex;
51684
+ // FIXME
51685
+ // If the given targetDataIndex (from model) is illegal,
51686
+ // we use defualtIndex. But the index on the legend model and
51687
+ // action payload is still illegal. That case will not be
51688
+ // changed until some scenario requires.
51689
+ if (defaultIndex == null && legendDataIdx != null) {
51690
+ defaultIndex = idx;
51691
+ }
51692
+ if (legendDataIdx === targetDataIndex) {
51693
+ index = idx;
51694
+ }
51695
+ });
51374
51696
 
51375
51697
  return index != null ? index : defaultIndex;
51376
51698
  }
@@ -51952,8 +52274,8 @@ function markerTypeCalculatorWithExtent(
51952
52274
 
51953
52275
  var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
51954
52276
  coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
51955
- coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex);
51956
-
52277
+ coordArr[targetCoordIndex] = data.get(calcDataDim, dataIndex);
52278
+ var coordArrValue = data.get(targetDataDim, dataIndex);
51957
52279
  // Make it simple, do not visit all stacked value to count precision.
51958
52280
  var precision = getPrecision(data.get(targetDataDim, dataIndex));
51959
52281
  precision = Math.min(precision, 20);
@@ -51961,7 +52283,7 @@ function markerTypeCalculatorWithExtent(
51961
52283
  coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
51962
52284
  }
51963
52285
 
51964
- return coordArr;
52286
+ return [coordArr, coordArrValue];
51965
52287
  }
51966
52288
 
51967
52289
  var curry$4 = curry;
@@ -52024,12 +52346,15 @@ function dataTransform(seriesModel, item) {
52024
52346
  var otherCoordIndex = indexOf$1(dims, axisInfo.baseAxis.dim);
52025
52347
  var targetCoordIndex = indexOf$1(dims, axisInfo.valueAxis.dim);
52026
52348
 
52027
- item.coord = markerTypeCalculator[item.type](
52349
+ var coordInfo = markerTypeCalculator[item.type](
52028
52350
  data, axisInfo.baseDataDim, axisInfo.valueDataDim,
52029
52351
  otherCoordIndex, targetCoordIndex
52030
52352
  );
52353
+ item.coord = coordInfo[0];
52031
52354
  // Force to use the value of calculated value.
52032
- item.value = item.coord[targetCoordIndex];
52355
+ // let item use the value without stack.
52356
+ item.value = coordInfo[1];
52357
+
52033
52358
  }
52034
52359
  else {
52035
52360
  // FIXME Only has one of xAxis and yAxis.
@@ -52421,7 +52746,8 @@ MarkerModel.extend({
52421
52746
  },
52422
52747
  label: {
52423
52748
  show: true,
52424
- position: 'end'
52749
+ position: 'end',
52750
+ distance: 5
52425
52751
  },
52426
52752
  lineStyle: {
52427
52753
  type: 'dashed'
@@ -52646,39 +52972,90 @@ function updateSymbolAndLabelBeforeLineUpdate() {
52646
52972
  var textPosition;
52647
52973
  var textAlign;
52648
52974
  var textVerticalAlign;
52649
-
52650
- var distance$$1 = 5 * invScale;
52651
- // End
52652
- if (label.__position === 'end') {
52653
- textPosition = [d[0] * distance$$1 + toPos[0], d[1] * distance$$1 + toPos[1]];
52654
- textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
52655
- textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
52656
- }
52657
- // Middle
52658
- else if (label.__position === 'middle') {
52659
- var halfPercent = percent / 2;
52660
- var tangent = line.tangentAt(halfPercent);
52661
- var n = [tangent[1], -tangent[0]];
52662
- var cp = line.pointAt(halfPercent);
52663
- if (n[1] > 0) {
52664
- n[0] = -n[0];
52665
- n[1] = -n[1];
52666
- }
52667
- textPosition = [cp[0] + n[0] * distance$$1, cp[1] + n[1] * distance$$1];
52668
- textAlign = 'center';
52669
- textVerticalAlign = 'bottom';
52975
+ var textOrigin;
52976
+
52977
+ var distance$$1 = label.__labelDistance;
52978
+ var distanceX = distance$$1[0] * invScale;
52979
+ var distanceY = distance$$1[1] * invScale;
52980
+ var halfPercent = percent / 2;
52981
+ var tangent = line.tangentAt(halfPercent);
52982
+ var n = [tangent[1], -tangent[0]];
52983
+ var cp = line.pointAt(halfPercent);
52984
+ if (n[1] > 0) {
52985
+ n[0] = -n[0];
52986
+ n[1] = -n[1];
52987
+ }
52988
+ var dir = tangent[0] < 0 ? -1 : 1;
52989
+
52990
+ if (label.__position !== 'start' && label.__position !== 'end') {
52670
52991
  var rotation = -Math.atan2(tangent[1], tangent[0]);
52671
52992
  if (toPos[0] < fromPos[0]) {
52672
52993
  rotation = Math.PI + rotation;
52673
52994
  }
52674
52995
  label.attr('rotation', rotation);
52675
52996
  }
52676
- // Start
52677
- else {
52678
- textPosition = [-d[0] * distance$$1 + fromPos[0], -d[1] * distance$$1 + fromPos[1]];
52679
- textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
52680
- textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
52997
+
52998
+ var dy;
52999
+ switch (label.__position) {
53000
+ case 'insideStartTop':
53001
+ case 'insideMiddleTop':
53002
+ case 'insideEndTop':
53003
+ case 'middle':
53004
+ dy = -distanceY;
53005
+ textVerticalAlign = 'bottom';
53006
+ break;
53007
+
53008
+ case 'insideStartBottom':
53009
+ case 'insideMiddleBottom':
53010
+ case 'insideEndBottom':
53011
+ dy = distanceY;
53012
+ textVerticalAlign = 'top';
53013
+ break;
53014
+
53015
+ default:
53016
+ dy = 0;
53017
+ textVerticalAlign = 'middle';
53018
+ }
53019
+
53020
+ switch (label.__position) {
53021
+ case 'end':
53022
+ textPosition = [d[0] * distanceX + toPos[0], d[1] * distanceY + toPos[1]];
53023
+ textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
53024
+ textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
53025
+ break;
53026
+
53027
+ case 'start':
53028
+ textPosition = [-d[0] * distanceX + fromPos[0], -d[1] * distanceY + fromPos[1]];
53029
+ textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
53030
+ textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
53031
+ break;
53032
+
53033
+ case 'insideStartTop':
53034
+ case 'insideStart':
53035
+ case 'insideStartBottom':
53036
+ textPosition = [distanceX * dir + fromPos[0], fromPos[1] + dy];
53037
+ textAlign = tangent[0] < 0 ? 'right' : 'left';
53038
+ textOrigin = [-distanceX * dir, -dy];
53039
+ break;
53040
+
53041
+ case 'insideMiddleTop':
53042
+ case 'insideMiddle':
53043
+ case 'insideMiddleBottom':
53044
+ case 'middle':
53045
+ textPosition = [cp[0], cp[1] + dy];
53046
+ textAlign = 'center';
53047
+ textOrigin = [0, -dy];
53048
+ break;
53049
+
53050
+ case 'insideEndTop':
53051
+ case 'insideEnd':
53052
+ case 'insideEndBottom':
53053
+ textPosition = [-distanceX * dir + toPos[0], toPos[1] + dy];
53054
+ textAlign = tangent[0] >= 0 ? 'right' : 'left';
53055
+ textOrigin = [distanceX * dir, -dy];
53056
+ break;
52681
53057
  }
53058
+
52682
53059
  label.attr({
52683
53060
  style: {
52684
53061
  // Use the user specified text align and baseline first
@@ -52686,7 +53063,8 @@ function updateSymbolAndLabelBeforeLineUpdate() {
52686
53063
  textAlign: label.__textAlign || textAlign
52687
53064
  },
52688
53065
  position: textPosition,
52689
- scale: [invScale, invScale]
53066
+ scale: [invScale, invScale],
53067
+ origin: textOrigin
52690
53068
  });
52691
53069
  }
52692
53070
  }
@@ -52862,6 +53240,12 @@ lineProto._updateCommonStl = function (lineData, idx, seriesScope) {
52862
53240
  label.__verticalAlign = labelStyle.textVerticalAlign;
52863
53241
  // 'start', 'middle', 'end'
52864
53242
  label.__position = labelModel.get('position') || 'middle';
53243
+
53244
+ var distance$$1 = labelModel.get('distance');
53245
+ if (!isArray(distance$$1)) {
53246
+ distance$$1 = [distance$$1, distance$$1];
53247
+ }
53248
+ label.__labelDistance = distance$$1;
52865
53249
  }
52866
53250
 
52867
53251
  if (emphasisText != null) {