echarts 4.4.0 → 4.6.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.
- package/.github/ISSUE_TEMPLATE.md +1 -1
- package/.github/workflows/nodejs.yml +31 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +6 -12
- package/dist/echarts-en.common.js +2354 -1029
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +2727 -1138
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +2028 -759
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +2354 -1029
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +2727 -1138
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +2028 -759
- package/dist/echarts.simple.min.js +1 -1
- package/dist/extension/dataTool.js +9 -0
- package/dist/extension/dataTool.js.map +1 -1
- package/echarts.all.js +1 -1
- package/lib/chart/bar/BarSeries.js +4 -1
- package/lib/chart/bar/BarView.js +20 -6
- package/lib/chart/bar/BaseBarSeries.js +5 -1
- package/lib/chart/candlestick/CandlestickSeries.js +1 -0
- package/lib/chart/candlestick/CandlestickView.js +42 -1
- package/lib/chart/custom.js +1 -0
- package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
- package/lib/chart/funnel/FunnelSeries.js +15 -5
- package/lib/chart/gauge/GaugeSeries.js +0 -9
- package/lib/chart/graph/GraphSeries.js +11 -4
- package/lib/chart/graph/GraphView.js +28 -8
- package/lib/chart/graph/forceHelper.js +8 -2
- package/lib/chart/graph/forceLayout.js +5 -2
- package/lib/chart/heatmap/HeatmapView.js +4 -4
- package/lib/chart/helper/Symbol.js +8 -0
- package/lib/chart/helper/createListFromArray.js +14 -8
- package/lib/chart/helper/whiskerBoxCommon.js +22 -16
- package/lib/chart/line/LineSeries.js +3 -1
- package/lib/chart/line/LineView.js +8 -2
- package/lib/chart/map/MapSeries.js +8 -1
- package/lib/chart/pie/PieSeries.js +27 -6
- package/lib/chart/pie/PieView.js +1 -1
- package/lib/chart/pie/labelLayout.js +102 -19
- package/lib/chart/pie/pieLayout.js +19 -7
- package/lib/chart/radar/RadarSeries.js +3 -3
- package/lib/chart/sankey/SankeyView.js +28 -9
- package/lib/chart/scatter/ScatterSeries.js +3 -1
- package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
- package/lib/chart/tree/TreeSeries.js +15 -1
- package/lib/chart/tree/TreeView.js +4 -2
- package/lib/component/axis/AngleAxisView.js +97 -20
- package/lib/component/axis/AxisBuilder.js +63 -24
- package/lib/component/axis/CartesianAxisView.js +55 -11
- package/lib/component/axis/RadiusAxisView.js +36 -4
- package/lib/component/brush/BrushView.js +6 -0
- package/lib/component/brush/brushAction.js +5 -0
- package/lib/component/dataZoom/DataZoomModel.js +15 -1
- package/lib/component/dataZoom/SliderZoomView.js +4 -10
- package/lib/component/helper/BrushController.js +43 -25
- package/lib/component/legend/LegendModel.js +3 -3
- package/lib/component/legend/LegendView.js +17 -13
- package/lib/component/toolbox/ToolboxView.js +16 -7
- package/lib/component/toolbox/feature/MagicType.js +19 -14
- package/lib/coord/Axis.js +44 -12
- package/lib/coord/axisDefault.js +21 -2
- package/lib/coord/axisTickLabelBuilder.js +9 -1
- package/lib/coord/cartesian/Cartesian2D.js +0 -15
- package/lib/coord/geo/geoJSONLoader.js +1 -1
- package/lib/coord/polar/polarCreator.js +11 -2
- package/lib/coord/radar/Radar.js +3 -1
- package/lib/coord/radar/RadarModel.js +4 -1
- package/lib/data/DataDiffer.js +2 -4
- package/lib/data/DataDimensionInfo.js +157 -0
- package/lib/data/List.js +29 -23
- package/lib/data/Tree.js +2 -1
- package/lib/data/helper/completeDimensions.js +43 -32
- package/lib/data/helper/createDimensions.js +2 -0
- package/lib/data/helper/sourceHelper.js +214 -114
- package/lib/echarts.js +2 -2
- package/lib/layout/barGrid.js +136 -11
- package/lib/layout/barPolar.js +2 -2
- package/lib/model/Global.js +1 -1
- package/lib/model/Series.js +3 -3
- package/lib/model/referHelper.js +40 -12
- package/lib/scale/Interval.js +87 -2
- package/lib/scale/Log.js +9 -2
- package/lib/scale/helper.js +1 -43
- package/lib/theme/dark.js +3 -0
- package/lib/util/graphic.js +1 -2
- package/lib/util/number.js +25 -1
- package/lib/util/shape/sausage.js +93 -0
- package/lib/visual/LegendVisualProvider.js +75 -0
- package/lib/visual/dataColor.js +2 -12
- package/lib/visual/seriesColor.js +15 -7
- package/map/js/china.js +2 -2
- package/map/json/china.json +1 -1
- package/map/json/province/tianjin.json +1 -1
- package/package.json +3 -2
- package/src/chart/bar/BarSeries.js +5 -1
- package/src/chart/bar/BarView.js +24 -8
- package/src/chart/bar/BaseBarSeries.js +5 -1
- package/src/chart/candlestick/CandlestickSeries.js +2 -0
- package/src/chart/candlestick/CandlestickView.js +44 -1
- package/src/chart/custom.js +1 -0
- package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
- package/src/chart/funnel/FunnelSeries.js +11 -4
- package/src/chart/gauge/GaugeSeries.js +0 -6
- package/src/chart/graph/GraphSeries.js +10 -3
- package/src/chart/graph/GraphView.js +26 -8
- package/src/chart/graph/forceHelper.js +7 -3
- package/src/chart/graph/forceLayout.js +6 -3
- package/src/chart/heatmap/HeatmapView.js +4 -4
- package/src/chart/helper/Symbol.js +9 -0
- package/src/chart/helper/createClipPathFromCoordSys.js +5 -1
- package/src/chart/helper/createGraphFromNodeEdge.js +1 -1
- package/src/chart/helper/createListFromArray.js +13 -8
- package/src/chart/helper/whiskerBoxCommon.js +21 -16
- package/src/chart/line/LineSeries.js +1 -1
- package/src/chart/line/LineView.js +6 -1
- package/src/chart/map/MapSeries.js +5 -1
- package/src/chart/pie/PieSeries.js +26 -5
- package/src/chart/pie/PieView.js +1 -1
- package/src/chart/pie/labelLayout.js +114 -22
- package/src/chart/pie/pieLayout.js +20 -7
- package/src/chart/radar/RadarSeries.js +5 -3
- package/src/chart/sankey/SankeyView.js +26 -9
- package/src/chart/scatter/ScatterSeries.js +1 -1
- package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
- package/src/chart/tree/TreeSeries.js +12 -1
- package/src/chart/tree/TreeView.js +5 -2
- package/src/component/axis/AngleAxisView.js +106 -19
- package/src/component/axis/AxisBuilder.js +78 -33
- package/src/component/axis/CartesianAxisView.js +58 -11
- package/src/component/axis/RadiusAxisView.js +37 -4
- package/src/component/brush/BrushView.js +6 -0
- package/src/component/brush/brushAction.js +6 -1
- package/src/component/dataZoom/DataZoomModel.js +15 -1
- package/src/component/dataZoom/SliderZoomView.js +4 -9
- package/src/component/helper/BrushController.js +50 -28
- package/src/component/legend/LegendModel.js +3 -3
- package/src/component/legend/LegendView.js +18 -12
- package/src/component/toolbox/ToolboxView.js +18 -5
- package/src/component/toolbox/feature/MagicType.js +18 -13
- package/src/coord/Axis.js +48 -13
- package/src/coord/axisDefault.js +25 -1
- package/src/coord/axisTickLabelBuilder.js +10 -0
- package/src/coord/cartesian/Cartesian2D.js +0 -13
- package/src/coord/geo/geoJSONLoader.js +2 -2
- package/src/coord/polar/polarCreator.js +16 -3
- package/src/coord/radar/Radar.js +3 -1
- package/src/coord/radar/RadarModel.js +5 -2
- package/src/data/DataDiffer.js +1 -4
- package/src/data/DataDimensionInfo.js +135 -0
- package/src/data/Graph.js +1 -1
- package/src/data/List.js +33 -20
- package/src/data/Tree.js +3 -1
- package/src/data/helper/completeDimensions.js +49 -30
- package/src/data/helper/createDimensions.js +2 -0
- package/src/data/helper/sourceHelper.js +216 -124
- package/src/echarts.js +2 -2
- package/src/layout/barGrid.js +136 -13
- package/src/layout/barPolar.js +3 -2
- package/src/model/Global.js +1 -1
- package/src/model/Series.js +3 -3
- package/src/model/referHelper.js +34 -11
- package/src/scale/Interval.js +84 -4
- package/src/scale/Log.js +9 -2
- package/src/scale/helper.js +1 -39
- package/src/theme/dark.js +3 -0
- package/src/util/graphic.js +1 -2
- package/src/util/number.js +22 -2
- package/src/util/shape/sausage.js +93 -0
- package/src/visual/LegendVisualProvider.js +55 -0
- package/src/visual/dataColor.js +0 -13
- package/src/visual/seriesColor.js +13 -7
- package/theme/azul.js +163 -0
- package/theme/bee-inspired.js +178 -0
- package/theme/blue.js +178 -0
- package/theme/caravan.js +178 -0
- package/theme/carp.js +163 -0
- package/theme/cool.js +180 -0
- package/theme/dark-blue.js +168 -0
- package/theme/dark-bold.js +168 -0
- package/theme/dark-digerati.js +168 -0
- package/theme/dark-fresh-cut.js +168 -0
- package/theme/dark-mushroom.js +168 -0
- package/theme/dark.js +69 -62
- package/theme/eduardo.js +178 -0
- package/theme/forest.js +163 -0
- package/theme/fresh-cut.js +163 -0
- package/theme/fruit.js +178 -0
- package/theme/gray.js +220 -0
- package/theme/green.js +222 -0
- package/theme/helianthus.js +263 -0
- package/theme/infographic.js +72 -57
- package/theme/inspired.js +163 -0
- package/theme/jazz.js +163 -0
- package/theme/london.js +163 -0
- package/theme/macarons.js +80 -57
- package/theme/macarons2.js +251 -0
- package/theme/mint.js +155 -0
- package/theme/red-velvet.js +163 -0
- package/theme/red.js +225 -0
- package/theme/roma.js +55 -22
- package/theme/royal.js +163 -0
- package/theme/sakura.js +140 -0
- package/theme/shine.js +52 -45
- package/theme/tech-blue.js +180 -0
- package/theme/vintage.js +37 -23
- package/.travis.yml +0 -16
package/dist/echarts.simple.js
CHANGED
|
@@ -208,12 +208,17 @@ function detect(ua) {
|
|
|
208
208
|
// default, so we dont check navigator.maxTouchPoints for them here.
|
|
209
209
|
touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
|
|
210
210
|
// <http://caniuse.com/#search=pointer%20event>.
|
|
211
|
-
pointerEventsSupported:
|
|
212
|
-
// Firefox supports pointer but not by default, only MS browsers are reliable on pointer
|
|
211
|
+
pointerEventsSupported:
|
|
212
|
+
// (1) Firefox supports pointer but not by default, only MS browsers are reliable on pointer
|
|
213
213
|
// events currently. So we dont use that on other browsers unless tested sufficiently.
|
|
214
|
-
//
|
|
214
|
+
// For example, in iOS 13 Mobile Chromium 78, if the touching behavior starts page
|
|
215
|
+
// scroll, the `pointermove` event can not be fired any more. That will break some
|
|
216
|
+
// features like "pan horizontally to move something and pan vertically to page scroll".
|
|
217
|
+
// The horizontal pan probably be interrupted by the casually triggered page scroll.
|
|
218
|
+
// (2) Although IE 10 supports pointer event, it use old style and is different from the
|
|
215
219
|
// standard. So we exclude that. (IE 10 is hardly used on touch device)
|
|
216
|
-
|
|
220
|
+
'onpointerdown' in window
|
|
221
|
+
&& (browser.edge || (browser.ie && browser.version >= 11)),
|
|
217
222
|
// passiveSupported: detectPassiveSupport()
|
|
218
223
|
domSupported: typeof document !== 'undefined'
|
|
219
224
|
};
|
|
@@ -1149,7 +1154,11 @@ function Draggable() {
|
|
|
1149
1154
|
this.on('mousedown', this._dragStart, this);
|
|
1150
1155
|
this.on('mousemove', this._drag, this);
|
|
1151
1156
|
this.on('mouseup', this._dragEnd, this);
|
|
1152
|
-
|
|
1157
|
+
// `mosuemove` and `mouseup` can be continue to fire when dragging.
|
|
1158
|
+
// See [Drag outside] in `Handler.js`. So we do not need to trigger
|
|
1159
|
+
// `_dragEnd` when globalout. That would brings better user experience.
|
|
1160
|
+
// this.on('globalout', this._dragEnd, this);
|
|
1161
|
+
|
|
1153
1162
|
// this._dropTarget = null;
|
|
1154
1163
|
// this._draggingTarget = null;
|
|
1155
1164
|
|
|
@@ -1250,7 +1259,7 @@ var arrySlice = Array.prototype.slice;
|
|
|
1250
1259
|
* param: {string} eventType
|
|
1251
1260
|
* param: {string|Object} query
|
|
1252
1261
|
* return: {boolean}
|
|
1253
|
-
* @param {Function} [eventProcessor.afterTrigger]
|
|
1262
|
+
* @param {Function} [eventProcessor.afterTrigger] Called after all handlers called.
|
|
1254
1263
|
* param: {string} eventType
|
|
1255
1264
|
*/
|
|
1256
1265
|
var Eventful = function (eventProcessor) {
|
|
@@ -1300,8 +1309,10 @@ Eventful.prototype = {
|
|
|
1300
1309
|
/**
|
|
1301
1310
|
* Unbind a event.
|
|
1302
1311
|
*
|
|
1303
|
-
* @param {string} event The event name.
|
|
1312
|
+
* @param {string} [event] The event name.
|
|
1313
|
+
* If no `event` input, "off" all listeners.
|
|
1304
1314
|
* @param {Function} [handler] The event handler.
|
|
1315
|
+
* If no `handler` input, "off" all listeners of the `event`.
|
|
1305
1316
|
*/
|
|
1306
1317
|
off: function (event, handler) {
|
|
1307
1318
|
var _h = this._$handlers;
|
|
@@ -1459,6 +1470,7 @@ Eventful.prototype = {
|
|
|
1459
1470
|
}
|
|
1460
1471
|
};
|
|
1461
1472
|
|
|
1473
|
+
|
|
1462
1474
|
function normalizeQuery(host, query) {
|
|
1463
1475
|
var eventProcessor = host._$eventProcessor;
|
|
1464
1476
|
if (query != null && eventProcessor && eventProcessor.normalizeQuery) {
|
|
@@ -1776,6 +1788,18 @@ function preparePointerTransformer(markers, saved) {
|
|
|
1776
1788
|
);
|
|
1777
1789
|
}
|
|
1778
1790
|
|
|
1791
|
+
/**
|
|
1792
|
+
* Find native event compat for legency IE.
|
|
1793
|
+
* Should be called at the begining of a native event listener.
|
|
1794
|
+
*
|
|
1795
|
+
* @param {Event} [e] Mouse event or touch event or pointer event.
|
|
1796
|
+
* For lagency IE, we use `window.event` is used.
|
|
1797
|
+
* @return {Event} The native event.
|
|
1798
|
+
*/
|
|
1799
|
+
function getNativeEvent(e) {
|
|
1800
|
+
return e || window.event;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1779
1803
|
/**
|
|
1780
1804
|
* Normalize the coordinates of the input event.
|
|
1781
1805
|
*
|
|
@@ -1790,14 +1814,14 @@ function preparePointerTransformer(markers, saved) {
|
|
|
1790
1814
|
* between the result coords and the parameters `el` and `calculate`.
|
|
1791
1815
|
*
|
|
1792
1816
|
* @param {HTMLElement} el DOM element.
|
|
1793
|
-
* @param {Event} [e]
|
|
1794
|
-
* do not need to input it and `window.event` is used.
|
|
1817
|
+
* @param {Event} [e] See `getNativeEvent`.
|
|
1795
1818
|
* @param {boolean} [calculate=false] Whether to force calculate
|
|
1796
1819
|
* the coordinates but not use ones provided by browser.
|
|
1820
|
+
* @return {UIEvent} The normalized native UIEvent.
|
|
1797
1821
|
*/
|
|
1798
1822
|
function normalizeEvent(el, e, calculate) {
|
|
1799
1823
|
|
|
1800
|
-
e = e
|
|
1824
|
+
e = getNativeEvent(e);
|
|
1801
1825
|
|
|
1802
1826
|
if (e.zrX != null) {
|
|
1803
1827
|
return e;
|
|
@@ -1837,8 +1861,11 @@ function normalizeEvent(el, e, calculate) {
|
|
|
1837
1861
|
* @param {HTMLElement} el
|
|
1838
1862
|
* @param {string} name
|
|
1839
1863
|
* @param {Function} handler
|
|
1864
|
+
* @param {Object|boolean} opt If boolean, means `opt.capture`
|
|
1865
|
+
* @param {boolean} [opt.capture=false]
|
|
1866
|
+
* @param {boolean} [opt.passive=false]
|
|
1840
1867
|
*/
|
|
1841
|
-
function addEventListener(el, name, handler) {
|
|
1868
|
+
function addEventListener(el, name, handler, opt) {
|
|
1842
1869
|
if (isDomLevel2) {
|
|
1843
1870
|
// Reproduct the console warning:
|
|
1844
1871
|
// [Violation] Added non-passive event listener to a scroll-blocking <some> event.
|
|
@@ -1861,16 +1888,24 @@ function addEventListener(el, name, handler) {
|
|
|
1861
1888
|
// // By default, the third param of el.addEventListener is `capture: false`.
|
|
1862
1889
|
// : void 0;
|
|
1863
1890
|
// el.addEventListener(name, handler /* , opts */);
|
|
1864
|
-
el.addEventListener(name, handler);
|
|
1891
|
+
el.addEventListener(name, handler, opt);
|
|
1865
1892
|
}
|
|
1866
1893
|
else {
|
|
1894
|
+
// For simplicity, do not implement `setCapture` for IE9-.
|
|
1867
1895
|
el.attachEvent('on' + name, handler);
|
|
1868
1896
|
}
|
|
1869
1897
|
}
|
|
1870
1898
|
|
|
1871
|
-
|
|
1899
|
+
/**
|
|
1900
|
+
* Parameter are the same as `addEventListener`.
|
|
1901
|
+
*
|
|
1902
|
+
* Notice that if a listener is registered twice, one with capture and one without,
|
|
1903
|
+
* remove each one separately. Removal of a capturing listener does not affect a
|
|
1904
|
+
* non-capturing version of the same listener, and vice versa.
|
|
1905
|
+
*/
|
|
1906
|
+
function removeEventListener(el, name, handler, opt) {
|
|
1872
1907
|
if (isDomLevel2) {
|
|
1873
|
-
el.removeEventListener(name, handler);
|
|
1908
|
+
el.removeEventListener(name, handler, opt);
|
|
1874
1909
|
}
|
|
1875
1910
|
else {
|
|
1876
1911
|
el.detachEvent('on' + name, handler);
|
|
@@ -2023,6 +2058,65 @@ var recognizers = {
|
|
|
2023
2058
|
// Only pinch currently.
|
|
2024
2059
|
};
|
|
2025
2060
|
|
|
2061
|
+
/**
|
|
2062
|
+
* [The interface between `Handler` and `HandlerProxy`]:
|
|
2063
|
+
*
|
|
2064
|
+
* The default `HandlerProxy` only support the common standard web environment
|
|
2065
|
+
* (e.g., standalone browser, headless browser, embed browser in mobild APP, ...).
|
|
2066
|
+
* But `HandlerProxy` can be replaced to support more non-standard environment
|
|
2067
|
+
* (e.g., mini app), or to support more feature that the default `HandlerProxy`
|
|
2068
|
+
* not provided (like echarts-gl did).
|
|
2069
|
+
* So the interface between `Handler` and `HandlerProxy` should be stable. Do not
|
|
2070
|
+
* make break changes util inevitable. The interface include the public methods
|
|
2071
|
+
* of `Handler` and the events listed in `handlerNames` below, by which `HandlerProxy`
|
|
2072
|
+
* drives `Handler`.
|
|
2073
|
+
*/
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* [Drag outside]:
|
|
2077
|
+
*
|
|
2078
|
+
* That is, triggering `mousemove` and `mouseup` event when the pointer is out of the
|
|
2079
|
+
* zrender area when dragging. That is important for the improvement of the user experience
|
|
2080
|
+
* when dragging something near the boundary without being terminated unexpectedly.
|
|
2081
|
+
*
|
|
2082
|
+
* We originally consider to introduce new events like `pagemovemove` and `pagemouseup`
|
|
2083
|
+
* to resolve this issue. But some drawbacks of it is described in
|
|
2084
|
+
* https://github.com/ecomfe/zrender/pull/536#issuecomment-560286899
|
|
2085
|
+
*
|
|
2086
|
+
* Instead, we referenced the specifications:
|
|
2087
|
+
* https://www.w3.org/TR/touch-events/#the-touchmove-event
|
|
2088
|
+
* https://www.w3.org/TR/2014/WD-DOM-Level-3-Events-20140925/#event-type-mousemove
|
|
2089
|
+
* where the the mousemove/touchmove can be continue to fire if the user began a drag
|
|
2090
|
+
* operation and the pointer has left the boundary. (for the mouse event, browsers
|
|
2091
|
+
* only do it on `document` and when the pointer has left the boundary of the browser.)
|
|
2092
|
+
*
|
|
2093
|
+
* So the default `HandlerProxy` supports this feature similarly: if it is in the dragging
|
|
2094
|
+
* state (see `pointerCapture` in `HandlerProxy`), the `mousemove` and `mouseup` continue
|
|
2095
|
+
* to fire until release the pointer. That is implemented by listen to those event on
|
|
2096
|
+
* `document`.
|
|
2097
|
+
* If we implement some other `HandlerProxy` only for touch device, that would be easier.
|
|
2098
|
+
* The touch event support this feature by default.
|
|
2099
|
+
*
|
|
2100
|
+
* Note:
|
|
2101
|
+
* There might be some cases that the mouse event can not be
|
|
2102
|
+
* received on `document`. For example,
|
|
2103
|
+
* (A) `useCapture` is not supported and some user defined event listeners on the ancestor
|
|
2104
|
+
* of zr dom throw Error .
|
|
2105
|
+
* (B) `useCapture` is not supported Some user defined event listeners on the ancestor of
|
|
2106
|
+
* zr dom call `stopPropagation`.
|
|
2107
|
+
* In these cases, the `mousemove` event might be keep triggered event
|
|
2108
|
+
* if the mouse is released. We try to reduce the side-effect in those cases.
|
|
2109
|
+
* That is, do nothing (especially, `findHover`) in those cases. See `isOutsideBoundary`.
|
|
2110
|
+
*
|
|
2111
|
+
* Note:
|
|
2112
|
+
* If `HandlerProxy` listens to `document` with `useCapture`, `HandlerProxy` needs to
|
|
2113
|
+
* make sure `stopPropagation` and `preventDefault` doing nothing if and only if the event
|
|
2114
|
+
* target is not zrender dom. Becuase it is dangerous to enable users to call them in
|
|
2115
|
+
* `document` capture phase to prevent the propagation to any listener of the webpage.
|
|
2116
|
+
* But they are needed to work when the pointer inside the zrender dom.
|
|
2117
|
+
*/
|
|
2118
|
+
|
|
2119
|
+
|
|
2026
2120
|
var SILENT = 'silent';
|
|
2027
2121
|
|
|
2028
2122
|
function makeEventPacket(eveType, targetInfo, event) {
|
|
@@ -2047,17 +2141,19 @@ function makeEventPacket(eveType, targetInfo, event) {
|
|
|
2047
2141
|
};
|
|
2048
2142
|
}
|
|
2049
2143
|
|
|
2050
|
-
function stopEvent(
|
|
2144
|
+
function stopEvent() {
|
|
2051
2145
|
stop(this.event);
|
|
2052
2146
|
}
|
|
2053
2147
|
|
|
2054
2148
|
function EmptyProxy() {}
|
|
2055
2149
|
EmptyProxy.prototype.dispose = function () {};
|
|
2056
2150
|
|
|
2151
|
+
|
|
2057
2152
|
var handlerNames = [
|
|
2058
2153
|
'click', 'dblclick', 'mousewheel', 'mouseout',
|
|
2059
2154
|
'mouseup', 'mousedown', 'mousemove', 'contextmenu'
|
|
2060
2155
|
];
|
|
2156
|
+
|
|
2061
2157
|
/**
|
|
2062
2158
|
* @alias module:zrender/Handler
|
|
2063
2159
|
* @constructor
|
|
@@ -2114,7 +2210,6 @@ var Handler = function (storage, painter, proxy, painterRoot) {
|
|
|
2114
2210
|
*/
|
|
2115
2211
|
this._gestureMgr;
|
|
2116
2212
|
|
|
2117
|
-
|
|
2118
2213
|
Draggable.call(this);
|
|
2119
2214
|
|
|
2120
2215
|
this.setHandlerProxy(proxy);
|
|
@@ -2143,6 +2238,8 @@ Handler.prototype = {
|
|
|
2143
2238
|
var x = event.zrX;
|
|
2144
2239
|
var y = event.zrY;
|
|
2145
2240
|
|
|
2241
|
+
var isOutside = isOutsideBoundary(this, x, y);
|
|
2242
|
+
|
|
2146
2243
|
var lastHovered = this._hovered;
|
|
2147
2244
|
var lastHoveredTarget = lastHovered.target;
|
|
2148
2245
|
|
|
@@ -2155,7 +2252,7 @@ Handler.prototype = {
|
|
|
2155
2252
|
lastHoveredTarget = lastHovered.target;
|
|
2156
2253
|
}
|
|
2157
2254
|
|
|
2158
|
-
var hovered = this._hovered = this.findHover(x, y);
|
|
2255
|
+
var hovered = this._hovered = isOutside ? {x: x, y: y} : this.findHover(x, y);
|
|
2159
2256
|
var hoveredTarget = hovered.target;
|
|
2160
2257
|
|
|
2161
2258
|
var proxy = this.proxy;
|
|
@@ -2176,23 +2273,18 @@ Handler.prototype = {
|
|
|
2176
2273
|
},
|
|
2177
2274
|
|
|
2178
2275
|
mouseout: function (event) {
|
|
2179
|
-
|
|
2276
|
+
var eventControl = event.zrEventControl;
|
|
2277
|
+
var zrIsToLocalDOM = event.zrIsToLocalDOM;
|
|
2180
2278
|
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
// dom created by echarts), where 'globalout' event should not
|
|
2184
|
-
// be triggered when mouse enters these doms. (But 'mouseout'
|
|
2185
|
-
// should be triggered at the original hovered element as usual).
|
|
2186
|
-
var element = event.toElement || event.relatedTarget;
|
|
2187
|
-
var innerDom;
|
|
2188
|
-
do {
|
|
2189
|
-
element = element && element.parentNode;
|
|
2279
|
+
if (eventControl !== 'only_globalout') {
|
|
2280
|
+
this.dispatchToElement(this._hovered, 'mouseout', event);
|
|
2190
2281
|
}
|
|
2191
|
-
while (element && element.nodeType !== 9 && !(
|
|
2192
|
-
innerDom = element === this.painterRoot
|
|
2193
|
-
));
|
|
2194
2282
|
|
|
2195
|
-
|
|
2283
|
+
if (eventControl !== 'no_globalout') {
|
|
2284
|
+
// FIXME: if the pointer moving from the extra doms to realy "outside",
|
|
2285
|
+
// the `globalout` should have been triggered. But currently not.
|
|
2286
|
+
!zrIsToLocalDOM && this.trigger('globalout', {type: 'globalout', event: event});
|
|
2287
|
+
}
|
|
2196
2288
|
},
|
|
2197
2289
|
|
|
2198
2290
|
/**
|
|
@@ -2338,9 +2430,18 @@ Handler.prototype = {
|
|
|
2338
2430
|
// Common handlers
|
|
2339
2431
|
each$1(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
|
|
2340
2432
|
Handler.prototype[name] = function (event) {
|
|
2341
|
-
|
|
2342
|
-
var
|
|
2343
|
-
var
|
|
2433
|
+
var x = event.zrX;
|
|
2434
|
+
var y = event.zrY;
|
|
2435
|
+
var isOutside = isOutsideBoundary(this, x, y);
|
|
2436
|
+
|
|
2437
|
+
var hovered;
|
|
2438
|
+
var hoveredTarget;
|
|
2439
|
+
|
|
2440
|
+
if (name !== 'mouseup' || !isOutside) {
|
|
2441
|
+
// Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
|
|
2442
|
+
hovered = this.findHover(x, y);
|
|
2443
|
+
hoveredTarget = hovered.target;
|
|
2444
|
+
}
|
|
2344
2445
|
|
|
2345
2446
|
if (name === 'mousedown') {
|
|
2346
2447
|
this._downEl = hoveredTarget;
|
|
@@ -2392,6 +2493,14 @@ function isHover(displayable, x, y) {
|
|
|
2392
2493
|
return false;
|
|
2393
2494
|
}
|
|
2394
2495
|
|
|
2496
|
+
/**
|
|
2497
|
+
* See [Drag outside].
|
|
2498
|
+
*/
|
|
2499
|
+
function isOutsideBoundary(handlerInstance, x, y) {
|
|
2500
|
+
var painter = handlerInstance.painter;
|
|
2501
|
+
return x < 0 || x > painter.getWidth() || y < 0 || y > painter.getHeight();
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2395
2504
|
mixin(Handler, Eventful);
|
|
2396
2505
|
mixin(Handler, Draggable);
|
|
2397
2506
|
|
|
@@ -6839,23 +6948,31 @@ Style.prototype = {
|
|
|
6839
6948
|
|
|
6840
6949
|
/**
|
|
6841
6950
|
* Whether transform text.
|
|
6842
|
-
* Only
|
|
6951
|
+
* Only available in Path and Image element,
|
|
6952
|
+
* where the text is called as `RectText`.
|
|
6843
6953
|
* @type {boolean}
|
|
6844
6954
|
*/
|
|
6845
6955
|
transformText: false,
|
|
6846
6956
|
|
|
6847
6957
|
/**
|
|
6848
|
-
* Text rotate around position of Path or Image
|
|
6849
|
-
*
|
|
6958
|
+
* Text rotate around position of Path or Image.
|
|
6959
|
+
* The origin of the rotation can be specified by `textOrigin`.
|
|
6960
|
+
* Only available in Path and Image element,
|
|
6961
|
+
* where the text is called as `RectText`.
|
|
6850
6962
|
*/
|
|
6851
6963
|
textRotation: 0,
|
|
6852
6964
|
|
|
6853
6965
|
/**
|
|
6854
|
-
* Text origin of text rotation
|
|
6855
|
-
*
|
|
6856
|
-
*
|
|
6857
|
-
*
|
|
6858
|
-
*
|
|
6966
|
+
* Text origin of text rotation.
|
|
6967
|
+
* Useful in the case like label rotation of circular symbol.
|
|
6968
|
+
* Only available in Path and Image element, where the text is called
|
|
6969
|
+
* as `RectText` and the element is called as "host element".
|
|
6970
|
+
* The value can be:
|
|
6971
|
+
* + If specified as a coordinate like `[10, 40]`, it is the `[x, y]`
|
|
6972
|
+
* base on the left-top corner of the rect of its host element.
|
|
6973
|
+
* + If specified as a string `center`, it is the center of the rect of
|
|
6974
|
+
* its host element.
|
|
6975
|
+
* + By default, this origin is the `textPosition`.
|
|
6859
6976
|
* @type {string|Array.<number>}
|
|
6860
6977
|
*/
|
|
6861
6978
|
textOrigin: null,
|
|
@@ -7528,6 +7645,7 @@ function calculateTextPosition(out, style, rect) {
|
|
|
7528
7645
|
|
|
7529
7646
|
var x = rect.x;
|
|
7530
7647
|
var y = rect.y;
|
|
7648
|
+
distance = distance || 0;
|
|
7531
7649
|
|
|
7532
7650
|
var height = rect.height;
|
|
7533
7651
|
var width = rect.width;
|
|
@@ -7780,8 +7898,11 @@ methods$1.measureText = function (text, font) {
|
|
|
7780
7898
|
* @param {string} text
|
|
7781
7899
|
* @param {string} font
|
|
7782
7900
|
* @param {Object} [truncate]
|
|
7783
|
-
* @return {Object} block: {lineHeight, lines, height, outerHeight}
|
|
7901
|
+
* @return {Object} block: {lineHeight, lines, height, outerHeight, canCacheByTextString}
|
|
7784
7902
|
* Notice: for performance, do not calculate outerWidth util needed.
|
|
7903
|
+
* `canCacheByTextString` means the result `lines` is only determined by the input `text`.
|
|
7904
|
+
* Thus we can simply comparing the `input` text to determin whether the result changed,
|
|
7905
|
+
* without travel the result `lines`.
|
|
7785
7906
|
*/
|
|
7786
7907
|
function parsePlainText(text, font, padding, textLineHeight, truncate) {
|
|
7787
7908
|
text != null && (text += '');
|
|
@@ -7790,12 +7911,14 @@ function parsePlainText(text, font, padding, textLineHeight, truncate) {
|
|
|
7790
7911
|
var lines = text ? text.split('\n') : [];
|
|
7791
7912
|
var height = lines.length * lineHeight;
|
|
7792
7913
|
var outerHeight = height;
|
|
7914
|
+
var canCacheByTextString = true;
|
|
7793
7915
|
|
|
7794
7916
|
if (padding) {
|
|
7795
7917
|
outerHeight += padding[0] + padding[2];
|
|
7796
7918
|
}
|
|
7797
7919
|
|
|
7798
7920
|
if (text && truncate) {
|
|
7921
|
+
canCacheByTextString = false;
|
|
7799
7922
|
var truncOuterHeight = truncate.outerHeight;
|
|
7800
7923
|
var truncOuterWidth = truncate.outerWidth;
|
|
7801
7924
|
if (truncOuterHeight != null && outerHeight > truncOuterHeight) {
|
|
@@ -7822,7 +7945,8 @@ function parsePlainText(text, font, padding, textLineHeight, truncate) {
|
|
|
7822
7945
|
lines: lines,
|
|
7823
7946
|
height: height,
|
|
7824
7947
|
outerHeight: outerHeight,
|
|
7825
|
-
lineHeight: lineHeight
|
|
7948
|
+
lineHeight: lineHeight,
|
|
7949
|
+
canCacheByTextString: canCacheByTextString
|
|
7826
7950
|
};
|
|
7827
7951
|
}
|
|
7828
7952
|
|
|
@@ -8802,7 +8926,6 @@ RectText.prototype = {
|
|
|
8802
8926
|
};
|
|
8803
8927
|
|
|
8804
8928
|
/**
|
|
8805
|
-
* 可绘制的图形基类
|
|
8806
8929
|
* Base class of all displayable graphic objects
|
|
8807
8930
|
* @module zrender/graphic/Displayable
|
|
8808
8931
|
*/
|
|
@@ -8851,16 +8974,15 @@ Displayable.prototype = {
|
|
|
8851
8974
|
type: 'displayable',
|
|
8852
8975
|
|
|
8853
8976
|
/**
|
|
8854
|
-
*
|
|
8855
|
-
* Dirty flag. From which painter will determine if this displayable object needs brush
|
|
8977
|
+
* Dirty flag. From which painter will determine if this displayable object needs brush.
|
|
8856
8978
|
* @name module:zrender/graphic/Displayable#__dirty
|
|
8857
8979
|
* @type {boolean}
|
|
8858
8980
|
*/
|
|
8859
8981
|
__dirty: true,
|
|
8860
8982
|
|
|
8861
8983
|
/**
|
|
8862
|
-
*
|
|
8863
|
-
*
|
|
8984
|
+
* Whether the displayable object is visible. when it is true, the displayable object
|
|
8985
|
+
* is not drawn, but the mouse event can still trigger the object.
|
|
8864
8986
|
* @name module:/zrender/graphic/Displayable#invisible
|
|
8865
8987
|
* @type {boolean}
|
|
8866
8988
|
* @default false
|
|
@@ -8882,7 +9004,7 @@ Displayable.prototype = {
|
|
|
8882
9004
|
z2: 0,
|
|
8883
9005
|
|
|
8884
9006
|
/**
|
|
8885
|
-
* z
|
|
9007
|
+
* The z level determines the displayable object can be drawn in which layer canvas.
|
|
8886
9008
|
* @name module:/zrender/graphic/Displayable#zlevel
|
|
8887
9009
|
* @type {number}
|
|
8888
9010
|
* @default 0
|
|
@@ -8890,7 +9012,7 @@ Displayable.prototype = {
|
|
|
8890
9012
|
zlevel: 0,
|
|
8891
9013
|
|
|
8892
9014
|
/**
|
|
8893
|
-
*
|
|
9015
|
+
* Whether it can be dragged.
|
|
8894
9016
|
* @name module:/zrender/graphic/Displayable#draggable
|
|
8895
9017
|
* @type {boolean}
|
|
8896
9018
|
* @default false
|
|
@@ -8898,7 +9020,7 @@ Displayable.prototype = {
|
|
|
8898
9020
|
draggable: false,
|
|
8899
9021
|
|
|
8900
9022
|
/**
|
|
8901
|
-
*
|
|
9023
|
+
* Whether is it dragging.
|
|
8902
9024
|
* @name module:/zrender/graphic/Displayable#draggable
|
|
8903
9025
|
* @type {boolean}
|
|
8904
9026
|
* @default false
|
|
@@ -8906,7 +9028,7 @@ Displayable.prototype = {
|
|
|
8906
9028
|
dragging: false,
|
|
8907
9029
|
|
|
8908
9030
|
/**
|
|
8909
|
-
*
|
|
9031
|
+
* Whether to respond to mouse events.
|
|
8910
9032
|
* @name module:/zrender/graphic/Displayable#silent
|
|
8911
9033
|
* @type {boolean}
|
|
8912
9034
|
* @default false
|
|
@@ -8956,21 +9078,20 @@ Displayable.prototype = {
|
|
|
8956
9078
|
afterBrush: function (ctx) {},
|
|
8957
9079
|
|
|
8958
9080
|
/**
|
|
8959
|
-
*
|
|
9081
|
+
* Graphic drawing method.
|
|
8960
9082
|
* @param {CanvasRenderingContext2D} ctx
|
|
8961
9083
|
*/
|
|
8962
9084
|
// Interface
|
|
8963
9085
|
brush: function (ctx, prevEl) {},
|
|
8964
9086
|
|
|
8965
9087
|
/**
|
|
8966
|
-
*
|
|
9088
|
+
* Get the minimum bounding box.
|
|
8967
9089
|
* @return {module:zrender/core/BoundingRect}
|
|
8968
9090
|
*/
|
|
8969
9091
|
// Interface
|
|
8970
9092
|
getBoundingRect: function () {},
|
|
8971
9093
|
|
|
8972
9094
|
/**
|
|
8973
|
-
* 判断坐标 x, y 是否在图形上
|
|
8974
9095
|
* If displayable element contain coord x, y
|
|
8975
9096
|
* @param {number} x
|
|
8976
9097
|
* @param {number} y
|
|
@@ -8989,7 +9110,6 @@ Displayable.prototype = {
|
|
|
8989
9110
|
},
|
|
8990
9111
|
|
|
8991
9112
|
/**
|
|
8992
|
-
* 判断坐标 x, y 是否在图形的包围盒上
|
|
8993
9113
|
* If bounding rect of element contain coord x, y
|
|
8994
9114
|
* @param {number} x
|
|
8995
9115
|
* @param {number} y
|
|
@@ -9002,7 +9122,6 @@ Displayable.prototype = {
|
|
|
9002
9122
|
},
|
|
9003
9123
|
|
|
9004
9124
|
/**
|
|
9005
|
-
* 标记图形元素为脏,并且在下一帧重绘
|
|
9006
9125
|
* Mark displayable element dirty and refresh next frame
|
|
9007
9126
|
*/
|
|
9008
9127
|
dirty: function () {
|
|
@@ -9014,11 +9133,10 @@ Displayable.prototype = {
|
|
|
9014
9133
|
},
|
|
9015
9134
|
|
|
9016
9135
|
/**
|
|
9017
|
-
* 图形是否会触发事件
|
|
9018
9136
|
* If displayable object binded any event
|
|
9019
9137
|
* @return {boolean}
|
|
9020
9138
|
*/
|
|
9021
|
-
// TODO,
|
|
9139
|
+
// TODO, events bound by bind
|
|
9022
9140
|
// isSilent: function () {
|
|
9023
9141
|
// return !(
|
|
9024
9142
|
// this.hoverable || this.draggable
|
|
@@ -9270,10 +9388,16 @@ function doClip(clipPaths, ctx) {
|
|
|
9270
9388
|
function createRoot(width, height) {
|
|
9271
9389
|
var domRoot = document.createElement('div');
|
|
9272
9390
|
|
|
9273
|
-
// domRoot.onselectstart = returnFalse; //
|
|
9391
|
+
// domRoot.onselectstart = returnFalse; // Avoid page selected
|
|
9274
9392
|
domRoot.style.cssText = [
|
|
9275
9393
|
'position:relative',
|
|
9276
|
-
|
|
9394
|
+
// IOS13 safari probably has a compositing bug (z order of the canvas and the consequent
|
|
9395
|
+
// dom does not act as expected) when some of the parent dom has
|
|
9396
|
+
// `-webkit-overflow-scrolling: touch;` and the webpage is longer than one screen and
|
|
9397
|
+
// the canvas is not at the top part of the page.
|
|
9398
|
+
// Check `https://bugs.webkit.org/show_bug.cgi?id=203681` for more details. We remove
|
|
9399
|
+
// this `overflow:hidden` to avoid the bug.
|
|
9400
|
+
// 'overflow:hidden',
|
|
9277
9401
|
'width:' + width + 'px',
|
|
9278
9402
|
'height:' + height + 'px',
|
|
9279
9403
|
'padding:0',
|
|
@@ -10496,30 +10620,55 @@ Animation.prototype = {
|
|
|
10496
10620
|
|
|
10497
10621
|
mixin(Animation, Eventful);
|
|
10498
10622
|
|
|
10623
|
+
/* global document */
|
|
10624
|
+
|
|
10499
10625
|
var TOUCH_CLICK_DELAY = 300;
|
|
10500
10626
|
|
|
10501
|
-
var
|
|
10502
|
-
'click', 'dblclick', 'mousewheel', 'mouseout',
|
|
10503
|
-
'mouseup', 'mousedown', 'mousemove', 'contextmenu'
|
|
10504
|
-
];
|
|
10627
|
+
var globalEventSupported = env$1.domSupported;
|
|
10505
10628
|
|
|
10506
|
-
var touchHandlerNames = [
|
|
10507
|
-
'touchstart', 'touchend', 'touchmove'
|
|
10508
|
-
];
|
|
10509
10629
|
|
|
10510
|
-
var
|
|
10511
|
-
|
|
10630
|
+
var localNativeListenerNames = (function () {
|
|
10631
|
+
var mouseHandlerNames = [
|
|
10632
|
+
'click', 'dblclick', 'mousewheel', 'mouseout',
|
|
10633
|
+
'mouseup', 'mousedown', 'mousemove', 'contextmenu'
|
|
10634
|
+
];
|
|
10635
|
+
var touchHandlerNames = [
|
|
10636
|
+
'touchstart', 'touchend', 'touchmove'
|
|
10637
|
+
];
|
|
10638
|
+
var pointerEventNameMap = {
|
|
10639
|
+
pointerdown: 1, pointerup: 1, pointermove: 1, pointerout: 1
|
|
10640
|
+
};
|
|
10641
|
+
var pointerHandlerNames = map(mouseHandlerNames, function (name) {
|
|
10642
|
+
var nm = name.replace('mouse', 'pointer');
|
|
10643
|
+
return pointerEventNameMap.hasOwnProperty(nm) ? nm : name;
|
|
10644
|
+
});
|
|
10645
|
+
|
|
10646
|
+
return {
|
|
10647
|
+
mouse: mouseHandlerNames,
|
|
10648
|
+
touch: touchHandlerNames,
|
|
10649
|
+
pointer: pointerHandlerNames
|
|
10650
|
+
};
|
|
10651
|
+
})();
|
|
10652
|
+
|
|
10653
|
+
var globalNativeListenerNames = {
|
|
10654
|
+
mouse: ['mousemove', 'mouseup'],
|
|
10655
|
+
pointer: ['pointermove', 'pointerup']
|
|
10512
10656
|
};
|
|
10513
10657
|
|
|
10514
|
-
var pointerHandlerNames = map(mouseHandlerNames, function (name) {
|
|
10515
|
-
var nm = name.replace('mouse', 'pointer');
|
|
10516
|
-
return pointerEventNames[nm] ? nm : name;
|
|
10517
|
-
});
|
|
10518
10658
|
|
|
10519
10659
|
function eventNameFix(name) {
|
|
10520
10660
|
return (name === 'mousewheel' && env$1.browser.firefox) ? 'DOMMouseScroll' : name;
|
|
10521
10661
|
}
|
|
10522
10662
|
|
|
10663
|
+
function isPointerFromTouch(event) {
|
|
10664
|
+
var pointerType = event.pointerType;
|
|
10665
|
+
return pointerType === 'pen' || pointerType === 'touch';
|
|
10666
|
+
}
|
|
10667
|
+
|
|
10668
|
+
// function useMSGuesture(handlerProxy, event) {
|
|
10669
|
+
// return isPointerFromTouch(event) && !!handlerProxy._msGesture;
|
|
10670
|
+
// }
|
|
10671
|
+
|
|
10523
10672
|
// function onMSGestureChange(proxy, event) {
|
|
10524
10673
|
// if (event.translationX || event.translationY) {
|
|
10525
10674
|
// // mousemove is carried by MSGesture to reduce the sensitivity.
|
|
@@ -10539,117 +10688,174 @@ function eventNameFix(name) {
|
|
|
10539
10688
|
* 1. Mobile browsers dispatch mouse events 300ms after touchend.
|
|
10540
10689
|
* 2. Chrome for Android dispatch mousedown for long-touch about 650ms
|
|
10541
10690
|
* Result: Blocking Mouse Events for 700ms.
|
|
10691
|
+
*
|
|
10692
|
+
* @param {DOMHandlerScope} scope
|
|
10542
10693
|
*/
|
|
10543
|
-
function setTouchTimer(
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10694
|
+
function setTouchTimer(scope) {
|
|
10695
|
+
scope.touching = true;
|
|
10696
|
+
if (scope.touchTimer != null) {
|
|
10697
|
+
clearTimeout(scope.touchTimer);
|
|
10698
|
+
scope.touchTimer = null;
|
|
10699
|
+
}
|
|
10700
|
+
scope.touchTimer = setTimeout(function () {
|
|
10701
|
+
scope.touching = false;
|
|
10702
|
+
scope.touchTimer = null;
|
|
10548
10703
|
}, 700);
|
|
10549
10704
|
}
|
|
10550
10705
|
|
|
10706
|
+
// Mark touch, which is useful in distinguish touch and
|
|
10707
|
+
// mouse event in upper applicatoin.
|
|
10708
|
+
function markTouch(event) {
|
|
10709
|
+
event && (event.zrByTouch = true);
|
|
10710
|
+
}
|
|
10711
|
+
|
|
10712
|
+
|
|
10713
|
+
// function markTriggeredFromLocal(event) {
|
|
10714
|
+
// event && (event.__zrIsFromLocal = true);
|
|
10715
|
+
// }
|
|
10716
|
+
|
|
10717
|
+
// function isTriggeredFromLocal(instance, event) {
|
|
10718
|
+
// return !!(event && event.__zrIsFromLocal);
|
|
10719
|
+
// }
|
|
10720
|
+
|
|
10721
|
+
function normalizeGlobalEvent(instance, event) {
|
|
10722
|
+
// offsetX, offsetY still need to be calculated. They are necessary in the event
|
|
10723
|
+
// handlers of the upper applications. Set `true` to force calculate them.
|
|
10724
|
+
return normalizeEvent(instance.dom, new FakeGlobalEvent(instance, event), true);
|
|
10725
|
+
}
|
|
10726
|
+
|
|
10727
|
+
/**
|
|
10728
|
+
* Detect whether the given el is in `painterRoot`.
|
|
10729
|
+
*/
|
|
10730
|
+
function isLocalEl(instance, el) {
|
|
10731
|
+
var isLocal = false;
|
|
10732
|
+
do {
|
|
10733
|
+
el = el && el.parentNode;
|
|
10734
|
+
}
|
|
10735
|
+
while (el && el.nodeType !== 9 && !(
|
|
10736
|
+
isLocal = el === instance.painterRoot
|
|
10737
|
+
));
|
|
10738
|
+
return isLocal;
|
|
10739
|
+
}
|
|
10740
|
+
|
|
10741
|
+
/**
|
|
10742
|
+
* Make a fake event but not change the original event,
|
|
10743
|
+
* becuase the global event probably be used by other
|
|
10744
|
+
* listeners not belonging to zrender.
|
|
10745
|
+
* @class
|
|
10746
|
+
*/
|
|
10747
|
+
function FakeGlobalEvent(instance, event) {
|
|
10748
|
+
this.type = event.type;
|
|
10749
|
+
this.target = this.currentTarget = instance.dom;
|
|
10750
|
+
this.pointerType = event.pointerType;
|
|
10751
|
+
// Necessray for the force calculation of zrX, zrY
|
|
10752
|
+
this.clientX = event.clientX;
|
|
10753
|
+
this.clientY = event.clientY;
|
|
10754
|
+
// Because we do not mount global listeners to touch events,
|
|
10755
|
+
// we do not copy `targetTouches` and `changedTouches` here.
|
|
10756
|
+
}
|
|
10757
|
+
var fakeGlobalEventProto = FakeGlobalEvent.prototype;
|
|
10758
|
+
// we make the default methods on the event do nothing,
|
|
10759
|
+
// otherwise it is dangerous. See more details in
|
|
10760
|
+
// [Drag outside] in `Handler.js`.
|
|
10761
|
+
fakeGlobalEventProto.stopPropagation =
|
|
10762
|
+
fakeGlobalEventProto.stopImmediatePropagation =
|
|
10763
|
+
fakeGlobalEventProto.preventDefault = noop;
|
|
10764
|
+
|
|
10765
|
+
|
|
10766
|
+
/**
|
|
10767
|
+
* Local DOM Handlers
|
|
10768
|
+
* @this {HandlerProxy}
|
|
10769
|
+
*/
|
|
10770
|
+
var localDOMHandlers = {
|
|
10771
|
+
|
|
10772
|
+
mousedown: function (event) {
|
|
10773
|
+
event = normalizeEvent(this.dom, event);
|
|
10774
|
+
|
|
10775
|
+
this._mayPointerCapture = [event.zrX, event.zrY];
|
|
10776
|
+
|
|
10777
|
+
this.trigger('mousedown', event);
|
|
10778
|
+
},
|
|
10551
10779
|
|
|
10552
|
-
var domHandlers = {
|
|
10553
|
-
/**
|
|
10554
|
-
* Mouse move handler
|
|
10555
|
-
* @inner
|
|
10556
|
-
* @param {Event} event
|
|
10557
|
-
*/
|
|
10558
10780
|
mousemove: function (event) {
|
|
10559
10781
|
event = normalizeEvent(this.dom, event);
|
|
10560
10782
|
|
|
10783
|
+
var downPoint = this._mayPointerCapture;
|
|
10784
|
+
if (downPoint && (event.zrX !== downPoint[0] || event.zrY !== downPoint[1])) {
|
|
10785
|
+
togglePointerCapture(this, true);
|
|
10786
|
+
}
|
|
10787
|
+
|
|
10561
10788
|
this.trigger('mousemove', event);
|
|
10562
10789
|
},
|
|
10563
10790
|
|
|
10564
|
-
|
|
10565
|
-
* Mouse out handler
|
|
10566
|
-
* @inner
|
|
10567
|
-
* @param {Event} event
|
|
10568
|
-
*/
|
|
10569
|
-
mouseout: function (event) {
|
|
10791
|
+
mouseup: function (event) {
|
|
10570
10792
|
event = normalizeEvent(this.dom, event);
|
|
10571
10793
|
|
|
10572
|
-
|
|
10573
|
-
if (element !== this.dom) {
|
|
10574
|
-
while (element && element.nodeType !== 9) {
|
|
10575
|
-
// 忽略包含在root中的dom引起的mouseOut
|
|
10576
|
-
if (element === this.dom) {
|
|
10577
|
-
return;
|
|
10578
|
-
}
|
|
10794
|
+
togglePointerCapture(this, false);
|
|
10579
10795
|
|
|
10580
|
-
|
|
10581
|
-
|
|
10796
|
+
this.trigger('mouseup', event);
|
|
10797
|
+
},
|
|
10798
|
+
|
|
10799
|
+
mouseout: function (event) {
|
|
10800
|
+
event = normalizeEvent(this.dom, event);
|
|
10801
|
+
|
|
10802
|
+
// Similarly to the browser did on `document` and touch event,
|
|
10803
|
+
// `globalout` will be delayed to final pointer cature release.
|
|
10804
|
+
if (this._pointerCapturing) {
|
|
10805
|
+
event.zrEventControl = 'no_globalout';
|
|
10582
10806
|
}
|
|
10583
10807
|
|
|
10808
|
+
// There might be some doms created by upper layer application
|
|
10809
|
+
// at the same level of painter.getViewportRoot() (e.g., tooltip
|
|
10810
|
+
// dom created by echarts), where 'globalout' event should not
|
|
10811
|
+
// be triggered when mouse enters these doms. (But 'mouseout'
|
|
10812
|
+
// should be triggered at the original hovered element as usual).
|
|
10813
|
+
var element = event.toElement || event.relatedTarget;
|
|
10814
|
+
event.zrIsToLocalDOM = isLocalEl(this, element);
|
|
10815
|
+
|
|
10584
10816
|
this.trigger('mouseout', event);
|
|
10585
10817
|
},
|
|
10586
10818
|
|
|
10587
|
-
/**
|
|
10588
|
-
* Touch开始响应函数
|
|
10589
|
-
* @inner
|
|
10590
|
-
* @param {Event} event
|
|
10591
|
-
*/
|
|
10592
10819
|
touchstart: function (event) {
|
|
10593
10820
|
// Default mouse behaviour should not be disabled here.
|
|
10594
10821
|
// For example, page may needs to be slided.
|
|
10595
10822
|
event = normalizeEvent(this.dom, event);
|
|
10596
10823
|
|
|
10597
|
-
|
|
10598
|
-
// mouse event in upper applicatoin.
|
|
10599
|
-
event.zrByTouch = true;
|
|
10824
|
+
markTouch(event);
|
|
10600
10825
|
|
|
10601
10826
|
this._lastTouchMoment = new Date();
|
|
10602
10827
|
|
|
10603
|
-
this.handler.processGesture(
|
|
10828
|
+
this.handler.processGesture(event, 'start');
|
|
10604
10829
|
|
|
10605
|
-
//
|
|
10606
|
-
//
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
setTouchTimer(this);
|
|
10830
|
+
// For consistent event listener for both touch device and mouse device,
|
|
10831
|
+
// we simulate "mouseover-->mousedown" in touch device. So we trigger
|
|
10832
|
+
// `mousemove` here (to trigger `mouseover` inside), and then trigger
|
|
10833
|
+
// `mousedown`.
|
|
10834
|
+
localDOMHandlers.mousemove.call(this, event);
|
|
10835
|
+
localDOMHandlers.mousedown.call(this, event);
|
|
10612
10836
|
},
|
|
10613
10837
|
|
|
10614
|
-
/**
|
|
10615
|
-
* Touch移动响应函数
|
|
10616
|
-
* @inner
|
|
10617
|
-
* @param {Event} event
|
|
10618
|
-
*/
|
|
10619
10838
|
touchmove: function (event) {
|
|
10620
|
-
|
|
10621
10839
|
event = normalizeEvent(this.dom, event);
|
|
10622
10840
|
|
|
10623
|
-
|
|
10624
|
-
// mouse event in upper applicatoin.
|
|
10625
|
-
event.zrByTouch = true;
|
|
10841
|
+
markTouch(event);
|
|
10626
10842
|
|
|
10627
|
-
this.handler.processGesture(
|
|
10843
|
+
this.handler.processGesture(event, 'change');
|
|
10628
10844
|
|
|
10629
10845
|
// Mouse move should always be triggered no matter whether
|
|
10630
10846
|
// there is gestrue event, because mouse move and pinch may
|
|
10631
10847
|
// be used at the same time.
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
setTouchTimer(this);
|
|
10848
|
+
localDOMHandlers.mousemove.call(this, event);
|
|
10635
10849
|
},
|
|
10636
10850
|
|
|
10637
|
-
/**
|
|
10638
|
-
* Touch结束响应函数
|
|
10639
|
-
* @inner
|
|
10640
|
-
* @param {Event} event
|
|
10641
|
-
*/
|
|
10642
10851
|
touchend: function (event) {
|
|
10643
|
-
|
|
10644
10852
|
event = normalizeEvent(this.dom, event);
|
|
10645
10853
|
|
|
10646
|
-
|
|
10647
|
-
// mouse event in upper applicatoin.
|
|
10648
|
-
event.zrByTouch = true;
|
|
10854
|
+
markTouch(event);
|
|
10649
10855
|
|
|
10650
|
-
this.handler.processGesture(
|
|
10856
|
+
this.handler.processGesture(event, 'end');
|
|
10651
10857
|
|
|
10652
|
-
|
|
10858
|
+
localDOMHandlers.mouseup.call(this, event);
|
|
10653
10859
|
|
|
10654
10860
|
// Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
|
|
10655
10861
|
// triggered in `touchstart`. This seems to be illogical, but by this mechanism,
|
|
@@ -10662,14 +10868,12 @@ var domHandlers = {
|
|
|
10662
10868
|
// click event should always be triggered no matter whether
|
|
10663
10869
|
// there is gestrue event. System click can not be prevented.
|
|
10664
10870
|
if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
|
|
10665
|
-
|
|
10871
|
+
localDOMHandlers.click.call(this, event);
|
|
10666
10872
|
}
|
|
10667
|
-
|
|
10668
|
-
setTouchTimer(this);
|
|
10669
10873
|
},
|
|
10670
10874
|
|
|
10671
10875
|
pointerdown: function (event) {
|
|
10672
|
-
|
|
10876
|
+
localDOMHandlers.mousedown.call(this, event);
|
|
10673
10877
|
|
|
10674
10878
|
// if (useMSGuesture(this, event)) {
|
|
10675
10879
|
// this._msGesture.addPointer(event.pointerId);
|
|
@@ -10683,12 +10887,12 @@ var domHandlers = {
|
|
|
10683
10887
|
// upper application. So, we dont support mousemove on MS touch
|
|
10684
10888
|
// device yet.
|
|
10685
10889
|
if (!isPointerFromTouch(event)) {
|
|
10686
|
-
|
|
10890
|
+
localDOMHandlers.mousemove.call(this, event);
|
|
10687
10891
|
}
|
|
10688
10892
|
},
|
|
10689
10893
|
|
|
10690
10894
|
pointerup: function (event) {
|
|
10691
|
-
|
|
10895
|
+
localDOMHandlers.mouseup.call(this, event);
|
|
10692
10896
|
},
|
|
10693
10897
|
|
|
10694
10898
|
pointerout: function (event) {
|
|
@@ -10696,80 +10900,77 @@ var domHandlers = {
|
|
|
10696
10900
|
// (IE11+/Edge on MS Surface) after click event triggered,
|
|
10697
10901
|
// which is inconsistent with the mousout behavior we defined
|
|
10698
10902
|
// in touchend. So we unify them.
|
|
10699
|
-
// (check
|
|
10903
|
+
// (check localDOMHandlers.touchend for detailed explanation)
|
|
10700
10904
|
if (!isPointerFromTouch(event)) {
|
|
10701
|
-
|
|
10905
|
+
localDOMHandlers.mouseout.call(this, event);
|
|
10702
10906
|
}
|
|
10703
10907
|
}
|
|
10704
|
-
};
|
|
10705
10908
|
|
|
10706
|
-
|
|
10707
|
-
var pointerType = event.pointerType;
|
|
10708
|
-
return pointerType === 'pen' || pointerType === 'touch';
|
|
10709
|
-
}
|
|
10710
|
-
|
|
10711
|
-
// function useMSGuesture(handlerProxy, event) {
|
|
10712
|
-
// return isPointerFromTouch(event) && !!handlerProxy._msGesture;
|
|
10713
|
-
// }
|
|
10909
|
+
};
|
|
10714
10910
|
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10911
|
+
/**
|
|
10912
|
+
* Othere DOM UI Event handlers for zr dom.
|
|
10913
|
+
* @this {HandlerProxy}
|
|
10914
|
+
*/
|
|
10915
|
+
each$1(['click', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
|
|
10916
|
+
localDOMHandlers[name] = function (event) {
|
|
10718
10917
|
event = normalizeEvent(this.dom, event);
|
|
10719
10918
|
this.trigger(name, event);
|
|
10720
10919
|
};
|
|
10721
10920
|
});
|
|
10722
10921
|
|
|
10922
|
+
|
|
10723
10923
|
/**
|
|
10724
|
-
*
|
|
10924
|
+
* DOM UI Event handlers for global page.
|
|
10725
10925
|
*
|
|
10726
|
-
*
|
|
10727
|
-
*
|
|
10926
|
+
* [Caution]:
|
|
10927
|
+
* those handlers should both support in capture phase and bubble phase!
|
|
10928
|
+
*
|
|
10929
|
+
* @this {HandlerProxy}
|
|
10728
10930
|
*/
|
|
10729
|
-
|
|
10730
|
-
each$1(touchHandlerNames, function (name) {
|
|
10731
|
-
instance._handlers[name] = bind(domHandlers[name], instance);
|
|
10732
|
-
});
|
|
10931
|
+
var globalDOMHandlers = {
|
|
10733
10932
|
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10933
|
+
pointermove: function (event) {
|
|
10934
|
+
// FIXME
|
|
10935
|
+
// pointermove is so sensitive that it always triggered when
|
|
10936
|
+
// tap(click) on touch screen, which affect some judgement in
|
|
10937
|
+
// upper application. So, we dont support mousemove on MS touch
|
|
10938
|
+
// device yet.
|
|
10939
|
+
if (!isPointerFromTouch(event)) {
|
|
10940
|
+
globalDOMHandlers.mousemove.call(this, event);
|
|
10941
|
+
}
|
|
10942
|
+
},
|
|
10737
10943
|
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
}
|
|
10944
|
+
pointerup: function (event) {
|
|
10945
|
+
globalDOMHandlers.mouseup.call(this, event);
|
|
10946
|
+
},
|
|
10741
10947
|
|
|
10742
|
-
function
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
return;
|
|
10746
|
-
}
|
|
10747
|
-
return fn.apply(instance, arguments);
|
|
10748
|
-
};
|
|
10749
|
-
}
|
|
10750
|
-
}
|
|
10948
|
+
mousemove: function (event) {
|
|
10949
|
+
this.trigger('mousemove', event);
|
|
10950
|
+
},
|
|
10751
10951
|
|
|
10952
|
+
mouseup: function (event) {
|
|
10953
|
+
var pointerCaptureReleasing = this._pointerCapturing;
|
|
10752
10954
|
|
|
10753
|
-
|
|
10754
|
-
Eventful.call(this);
|
|
10955
|
+
togglePointerCapture(this, false);
|
|
10755
10956
|
|
|
10756
|
-
|
|
10957
|
+
this.trigger('mouseup', event);
|
|
10757
10958
|
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10959
|
+
if (pointerCaptureReleasing) {
|
|
10960
|
+
event.zrEventControl = 'only_globalout';
|
|
10961
|
+
this.trigger('mouseout', event);
|
|
10962
|
+
}
|
|
10963
|
+
}
|
|
10763
10964
|
|
|
10764
|
-
|
|
10765
|
-
* @private
|
|
10766
|
-
* @type {number}
|
|
10767
|
-
*/
|
|
10768
|
-
this._touchTimer;
|
|
10965
|
+
};
|
|
10769
10966
|
|
|
10770
|
-
this._handlers = {};
|
|
10771
10967
|
|
|
10772
|
-
|
|
10968
|
+
/**
|
|
10969
|
+
* @param {HandlerProxy} instance
|
|
10970
|
+
* @param {DOMHandlerScope} scope
|
|
10971
|
+
*/
|
|
10972
|
+
function mountLocalDOMEventListeners(instance, scope) {
|
|
10973
|
+
var domHandlers = scope.domHandlers;
|
|
10773
10974
|
|
|
10774
10975
|
if (env$1.pointerEventsSupported) { // Only IE11+/Edge
|
|
10775
10976
|
// 1. On devices that both enable touch and mouse (e.g., MS Surface and lenovo X240),
|
|
@@ -10778,7 +10979,12 @@ function HandlerDomProxy(dom) {
|
|
|
10778
10979
|
// 2. On MS Surface, it probablely only trigger mousedown but no mouseup when tap on
|
|
10779
10980
|
// screen, which do not occurs in pointer event.
|
|
10780
10981
|
// So we use pointer event to both detect touch gesture and mouse behavior.
|
|
10781
|
-
|
|
10982
|
+
each$1(localNativeListenerNames.pointer, function (nativeEventName) {
|
|
10983
|
+
mountSingleDOMEventListener(scope, nativeEventName, function (event) {
|
|
10984
|
+
// markTriggeredFromLocal(event);
|
|
10985
|
+
domHandlers[nativeEventName].call(instance, event);
|
|
10986
|
+
});
|
|
10987
|
+
});
|
|
10782
10988
|
|
|
10783
10989
|
// FIXME
|
|
10784
10990
|
// Note: MS Gesture require CSS touch-action set. But touch-action is not reliable,
|
|
@@ -10797,7 +11003,13 @@ function HandlerDomProxy(dom) {
|
|
|
10797
11003
|
}
|
|
10798
11004
|
else {
|
|
10799
11005
|
if (env$1.touchEventsSupported) {
|
|
10800
|
-
|
|
11006
|
+
each$1(localNativeListenerNames.touch, function (nativeEventName) {
|
|
11007
|
+
mountSingleDOMEventListener(scope, nativeEventName, function (event) {
|
|
11008
|
+
// markTriggeredFromLocal(event);
|
|
11009
|
+
domHandlers[nativeEventName].call(instance, event);
|
|
11010
|
+
setTouchTimer(scope);
|
|
11011
|
+
});
|
|
11012
|
+
});
|
|
10801
11013
|
// Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
|
|
10802
11014
|
// addEventListener(root, 'mouseout', this._mouseoutHandler);
|
|
10803
11015
|
}
|
|
@@ -10807,23 +11019,145 @@ function HandlerDomProxy(dom) {
|
|
|
10807
11019
|
// mouse event can not be handle in those devices.
|
|
10808
11020
|
// 2. On MS Surface, Chrome will trigger both touch event and mouse event. How to prevent
|
|
10809
11021
|
// mouseevent after touch event triggered, see `setTouchTimer`.
|
|
10810
|
-
|
|
11022
|
+
each$1(localNativeListenerNames.mouse, function (nativeEventName) {
|
|
11023
|
+
mountSingleDOMEventListener(scope, nativeEventName, function (event) {
|
|
11024
|
+
event = getNativeEvent(event);
|
|
11025
|
+
if (!scope.touching) {
|
|
11026
|
+
// markTriggeredFromLocal(event);
|
|
11027
|
+
domHandlers[nativeEventName].call(instance, event);
|
|
11028
|
+
}
|
|
11029
|
+
});
|
|
11030
|
+
});
|
|
10811
11031
|
}
|
|
11032
|
+
}
|
|
11033
|
+
|
|
11034
|
+
/**
|
|
11035
|
+
* @param {HandlerProxy} instance
|
|
11036
|
+
* @param {DOMHandlerScope} scope
|
|
11037
|
+
*/
|
|
11038
|
+
function mountGlobalDOMEventListeners(instance, scope) {
|
|
11039
|
+
// Only IE11+/Edge. See the comment in `mountLocalDOMEventListeners`.
|
|
11040
|
+
if (env$1.pointerEventsSupported) {
|
|
11041
|
+
each$1(globalNativeListenerNames.pointer, mount);
|
|
11042
|
+
}
|
|
11043
|
+
// Touch event has implemented "drag outside" so we do not mount global listener for touch event.
|
|
11044
|
+
// (see https://www.w3.org/TR/touch-events/#the-touchmove-event)
|
|
11045
|
+
// We do not consider "both-support-touch-and-mouse device" for this feature (see the comment of
|
|
11046
|
+
// `mountLocalDOMEventListeners`) to avoid bugs util some requirements come.
|
|
11047
|
+
else if (!env$1.touchEventsSupported) {
|
|
11048
|
+
each$1(globalNativeListenerNames.mouse, mount);
|
|
11049
|
+
}
|
|
11050
|
+
|
|
11051
|
+
function mount(nativeEventName) {
|
|
11052
|
+
function nativeEventListener(event) {
|
|
11053
|
+
event = getNativeEvent(event);
|
|
11054
|
+
// See the reason in [Drag outside] in `Handler.js`
|
|
11055
|
+
// This checking supports both `useCapture` or not.
|
|
11056
|
+
// PENDING: if there is performance issue in some devices,
|
|
11057
|
+
// we probably can not use `useCapture` and change a easier
|
|
11058
|
+
// to judes whether local (mark).
|
|
11059
|
+
if (!isLocalEl(instance, event.target)) {
|
|
11060
|
+
event = normalizeGlobalEvent(instance, event);
|
|
11061
|
+
scope.domHandlers[nativeEventName].call(instance, event);
|
|
11062
|
+
}
|
|
11063
|
+
}
|
|
11064
|
+
mountSingleDOMEventListener(
|
|
11065
|
+
scope, nativeEventName, nativeEventListener,
|
|
11066
|
+
{capture: true} // See [Drag Outside] in `Handler.js`
|
|
11067
|
+
);
|
|
11068
|
+
}
|
|
11069
|
+
}
|
|
11070
|
+
|
|
11071
|
+
function mountSingleDOMEventListener(scope, nativeEventName, listener, opt) {
|
|
11072
|
+
scope.mounted[nativeEventName] = listener;
|
|
11073
|
+
scope.listenerOpts[nativeEventName] = opt;
|
|
11074
|
+
addEventListener(scope.domTarget, eventNameFix(nativeEventName), listener, opt);
|
|
11075
|
+
}
|
|
11076
|
+
|
|
11077
|
+
function unmountDOMEventListeners(scope) {
|
|
11078
|
+
var mounted = scope.mounted;
|
|
11079
|
+
for (var nativeEventName in mounted) {
|
|
11080
|
+
if (mounted.hasOwnProperty(nativeEventName)) {
|
|
11081
|
+
removeEventListener(
|
|
11082
|
+
scope.domTarget, eventNameFix(nativeEventName), mounted[nativeEventName],
|
|
11083
|
+
scope.listenerOpts[nativeEventName]
|
|
11084
|
+
);
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11087
|
+
scope.mounted = {};
|
|
11088
|
+
}
|
|
11089
|
+
|
|
11090
|
+
/**
|
|
11091
|
+
* See [Drag Outside] in `Handler.js`.
|
|
11092
|
+
* @implement
|
|
11093
|
+
* @param {boolean} isPointerCapturing Should never be `null`/`undefined`.
|
|
11094
|
+
* `true`: start to capture pointer if it is not capturing.
|
|
11095
|
+
* `false`: end the capture if it is capturing.
|
|
11096
|
+
*/
|
|
11097
|
+
function togglePointerCapture(instance, isPointerCapturing) {
|
|
11098
|
+
instance._mayPointerCapture = null;
|
|
11099
|
+
|
|
11100
|
+
if (globalEventSupported && (instance._pointerCapturing ^ isPointerCapturing)) {
|
|
11101
|
+
instance._pointerCapturing = isPointerCapturing;
|
|
11102
|
+
|
|
11103
|
+
var globalHandlerScope = instance._globalHandlerScope;
|
|
11104
|
+
isPointerCapturing
|
|
11105
|
+
? mountGlobalDOMEventListeners(instance, globalHandlerScope)
|
|
11106
|
+
: unmountDOMEventListeners(globalHandlerScope);
|
|
11107
|
+
}
|
|
11108
|
+
}
|
|
11109
|
+
|
|
11110
|
+
/**
|
|
11111
|
+
* @inner
|
|
11112
|
+
* @class
|
|
11113
|
+
*/
|
|
11114
|
+
function DOMHandlerScope(domTarget, domHandlers) {
|
|
11115
|
+
this.domTarget = domTarget;
|
|
11116
|
+
this.domHandlers = domHandlers;
|
|
10812
11117
|
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
11118
|
+
// Key: eventName, value: mounted handler funcitons.
|
|
11119
|
+
// Used for unmount.
|
|
11120
|
+
this.mounted = {};
|
|
11121
|
+
this.listenerOpts = {};
|
|
11122
|
+
|
|
11123
|
+
this.touchTimer = null;
|
|
11124
|
+
this.touching = false;
|
|
11125
|
+
}
|
|
11126
|
+
|
|
11127
|
+
/**
|
|
11128
|
+
* @public
|
|
11129
|
+
* @class
|
|
11130
|
+
*/
|
|
11131
|
+
function HandlerDomProxy(dom, painterRoot) {
|
|
11132
|
+
Eventful.call(this);
|
|
11133
|
+
|
|
11134
|
+
this.dom = dom;
|
|
11135
|
+
this.painterRoot = painterRoot;
|
|
11136
|
+
|
|
11137
|
+
this._localHandlerScope = new DOMHandlerScope(dom, localDOMHandlers);
|
|
11138
|
+
|
|
11139
|
+
if (globalEventSupported) {
|
|
11140
|
+
this._globalHandlerScope = new DOMHandlerScope(document, globalDOMHandlers);
|
|
10817
11141
|
}
|
|
11142
|
+
|
|
11143
|
+
/**
|
|
11144
|
+
* @type {boolean}
|
|
11145
|
+
*/
|
|
11146
|
+
this._pointerCapturing = false;
|
|
11147
|
+
/**
|
|
11148
|
+
* @type {Array.<number>} [x, y] or null.
|
|
11149
|
+
*/
|
|
11150
|
+
this._mayPointerCapture = null;
|
|
11151
|
+
|
|
11152
|
+
mountLocalDOMEventListeners(this, this._localHandlerScope);
|
|
10818
11153
|
}
|
|
10819
11154
|
|
|
10820
11155
|
var handlerDomProxyProto = HandlerDomProxy.prototype;
|
|
10821
|
-
handlerDomProxyProto.dispose = function () {
|
|
10822
|
-
var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
|
|
10823
11156
|
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
11157
|
+
handlerDomProxyProto.dispose = function () {
|
|
11158
|
+
unmountDOMEventListeners(this._localHandlerScope);
|
|
11159
|
+
if (globalEventSupported) {
|
|
11160
|
+
unmountDOMEventListeners(this._globalHandlerScope);
|
|
10827
11161
|
}
|
|
10828
11162
|
};
|
|
10829
11163
|
|
|
@@ -10831,6 +11165,7 @@ handlerDomProxyProto.setCursor = function (cursorStyle) {
|
|
|
10831
11165
|
this.dom.style && (this.dom.style.cursor = cursorStyle || 'default');
|
|
10832
11166
|
};
|
|
10833
11167
|
|
|
11168
|
+
|
|
10834
11169
|
mixin(HandlerDomProxy, Eventful);
|
|
10835
11170
|
|
|
10836
11171
|
/*!
|
|
@@ -10852,7 +11187,7 @@ var painterCtors = {
|
|
|
10852
11187
|
/**
|
|
10853
11188
|
* @type {string}
|
|
10854
11189
|
*/
|
|
10855
|
-
var version$1 = '4.
|
|
11190
|
+
var version$1 = '4.2.0';
|
|
10856
11191
|
|
|
10857
11192
|
/**
|
|
10858
11193
|
* Initializing a zrender instance
|
|
@@ -10931,7 +11266,7 @@ var ZRender = function (id, dom, opts) {
|
|
|
10931
11266
|
this.storage = storage;
|
|
10932
11267
|
this.painter = painter;
|
|
10933
11268
|
|
|
10934
|
-
var handerProxy = (!env$1.node && !env$1.worker) ? new HandlerDomProxy(painter.getViewportRoot()) : null;
|
|
11269
|
+
var handerProxy = (!env$1.node && !env$1.worker) ? new HandlerDomProxy(painter.getViewportRoot(), painter.root) : null;
|
|
10935
11270
|
this.handler = new Handler(storage, painter, handerProxy, painter.root);
|
|
10936
11271
|
|
|
10937
11272
|
/**
|
|
@@ -17410,8 +17745,7 @@ function rollbackDefaultTextStyle(style) {
|
|
|
17410
17745
|
}
|
|
17411
17746
|
|
|
17412
17747
|
function getFont(opt, ecModel) {
|
|
17413
|
-
|
|
17414
|
-
var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
|
|
17748
|
+
var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
|
|
17415
17749
|
return trim([
|
|
17416
17750
|
// FIXME in node-canvas fontWeight is before fontStyle
|
|
17417
17751
|
opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
|
|
@@ -18708,8 +19042,28 @@ function quantity(val) {
|
|
|
18708
19042
|
return Math.pow(10, quantityExponent(val));
|
|
18709
19043
|
}
|
|
18710
19044
|
|
|
19045
|
+
/**
|
|
19046
|
+
* Exponent of the quantity of a number
|
|
19047
|
+
* e.g., 1234 equals to 1.234*10^3, so quantityExponent(1234) is 3
|
|
19048
|
+
*
|
|
19049
|
+
* @param {number} val non-negative value
|
|
19050
|
+
* @return {number}
|
|
19051
|
+
*/
|
|
18711
19052
|
function quantityExponent(val) {
|
|
18712
|
-
|
|
19053
|
+
if (val === 0) {
|
|
19054
|
+
return 0;
|
|
19055
|
+
}
|
|
19056
|
+
|
|
19057
|
+
var exp = Math.floor(Math.log(val) / Math.LN10);
|
|
19058
|
+
/**
|
|
19059
|
+
* exp is expected to be the rounded-down result of the base-10 log of val.
|
|
19060
|
+
* But due to the precision loss with Math.log(val), we need to restore it
|
|
19061
|
+
* using 10^exp to make sure we can get val back from exp. #11249
|
|
19062
|
+
*/
|
|
19063
|
+
if (val / Math.pow(10, exp) >= 10) {
|
|
19064
|
+
exp++;
|
|
19065
|
+
}
|
|
19066
|
+
return exp;
|
|
18713
19067
|
}
|
|
18714
19068
|
|
|
18715
19069
|
/**
|
|
@@ -19911,178 +20265,6 @@ var colorPaletteMixin = {
|
|
|
19911
20265
|
* under the License.
|
|
19912
20266
|
*/
|
|
19913
20267
|
|
|
19914
|
-
/**
|
|
19915
|
-
* Helper for model references.
|
|
19916
|
-
* There are many manners to refer axis/coordSys.
|
|
19917
|
-
*/
|
|
19918
|
-
|
|
19919
|
-
// TODO
|
|
19920
|
-
// merge relevant logic to this file?
|
|
19921
|
-
// check: "modelHelper" of tooltip and "BrushTargetManager".
|
|
19922
|
-
|
|
19923
|
-
/**
|
|
19924
|
-
* @return {Object} For example:
|
|
19925
|
-
* {
|
|
19926
|
-
* coordSysName: 'cartesian2d',
|
|
19927
|
-
* coordSysDims: ['x', 'y', ...],
|
|
19928
|
-
* axisMap: HashMap({
|
|
19929
|
-
* x: xAxisModel,
|
|
19930
|
-
* y: yAxisModel
|
|
19931
|
-
* }),
|
|
19932
|
-
* categoryAxisMap: HashMap({
|
|
19933
|
-
* x: xAxisModel,
|
|
19934
|
-
* y: undefined
|
|
19935
|
-
* }),
|
|
19936
|
-
* // It also indicate that whether there is category axis.
|
|
19937
|
-
* firstCategoryDimIndex: 1,
|
|
19938
|
-
* // To replace user specified encode.
|
|
19939
|
-
* }
|
|
19940
|
-
*/
|
|
19941
|
-
function getCoordSysDefineBySeries(seriesModel) {
|
|
19942
|
-
var coordSysName = seriesModel.get('coordinateSystem');
|
|
19943
|
-
var result = {
|
|
19944
|
-
coordSysName: coordSysName,
|
|
19945
|
-
coordSysDims: [],
|
|
19946
|
-
axisMap: createHashMap(),
|
|
19947
|
-
categoryAxisMap: createHashMap()
|
|
19948
|
-
};
|
|
19949
|
-
var fetch = fetchers[coordSysName];
|
|
19950
|
-
if (fetch) {
|
|
19951
|
-
fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
|
|
19952
|
-
return result;
|
|
19953
|
-
}
|
|
19954
|
-
}
|
|
19955
|
-
|
|
19956
|
-
var fetchers = {
|
|
19957
|
-
|
|
19958
|
-
cartesian2d: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
19959
|
-
var xAxisModel = seriesModel.getReferringComponents('xAxis')[0];
|
|
19960
|
-
var yAxisModel = seriesModel.getReferringComponents('yAxis')[0];
|
|
19961
|
-
|
|
19962
|
-
if (__DEV__) {
|
|
19963
|
-
if (!xAxisModel) {
|
|
19964
|
-
throw new Error('xAxis "' + retrieve(
|
|
19965
|
-
seriesModel.get('xAxisIndex'),
|
|
19966
|
-
seriesModel.get('xAxisId'),
|
|
19967
|
-
0
|
|
19968
|
-
) + '" not found');
|
|
19969
|
-
}
|
|
19970
|
-
if (!yAxisModel) {
|
|
19971
|
-
throw new Error('yAxis "' + retrieve(
|
|
19972
|
-
seriesModel.get('xAxisIndex'),
|
|
19973
|
-
seriesModel.get('yAxisId'),
|
|
19974
|
-
0
|
|
19975
|
-
) + '" not found');
|
|
19976
|
-
}
|
|
19977
|
-
}
|
|
19978
|
-
|
|
19979
|
-
result.coordSysDims = ['x', 'y'];
|
|
19980
|
-
axisMap.set('x', xAxisModel);
|
|
19981
|
-
axisMap.set('y', yAxisModel);
|
|
19982
|
-
|
|
19983
|
-
if (isCategory(xAxisModel)) {
|
|
19984
|
-
categoryAxisMap.set('x', xAxisModel);
|
|
19985
|
-
result.firstCategoryDimIndex = 0;
|
|
19986
|
-
}
|
|
19987
|
-
if (isCategory(yAxisModel)) {
|
|
19988
|
-
categoryAxisMap.set('y', yAxisModel);
|
|
19989
|
-
result.firstCategoryDimIndex = 1;
|
|
19990
|
-
}
|
|
19991
|
-
},
|
|
19992
|
-
|
|
19993
|
-
singleAxis: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
19994
|
-
var singleAxisModel = seriesModel.getReferringComponents('singleAxis')[0];
|
|
19995
|
-
|
|
19996
|
-
if (__DEV__) {
|
|
19997
|
-
if (!singleAxisModel) {
|
|
19998
|
-
throw new Error('singleAxis should be specified.');
|
|
19999
|
-
}
|
|
20000
|
-
}
|
|
20001
|
-
|
|
20002
|
-
result.coordSysDims = ['single'];
|
|
20003
|
-
axisMap.set('single', singleAxisModel);
|
|
20004
|
-
|
|
20005
|
-
if (isCategory(singleAxisModel)) {
|
|
20006
|
-
categoryAxisMap.set('single', singleAxisModel);
|
|
20007
|
-
result.firstCategoryDimIndex = 0;
|
|
20008
|
-
}
|
|
20009
|
-
},
|
|
20010
|
-
|
|
20011
|
-
polar: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20012
|
-
var polarModel = seriesModel.getReferringComponents('polar')[0];
|
|
20013
|
-
var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
|
|
20014
|
-
var angleAxisModel = polarModel.findAxisModel('angleAxis');
|
|
20015
|
-
|
|
20016
|
-
if (__DEV__) {
|
|
20017
|
-
if (!angleAxisModel) {
|
|
20018
|
-
throw new Error('angleAxis option not found');
|
|
20019
|
-
}
|
|
20020
|
-
if (!radiusAxisModel) {
|
|
20021
|
-
throw new Error('radiusAxis option not found');
|
|
20022
|
-
}
|
|
20023
|
-
}
|
|
20024
|
-
|
|
20025
|
-
result.coordSysDims = ['radius', 'angle'];
|
|
20026
|
-
axisMap.set('radius', radiusAxisModel);
|
|
20027
|
-
axisMap.set('angle', angleAxisModel);
|
|
20028
|
-
|
|
20029
|
-
if (isCategory(radiusAxisModel)) {
|
|
20030
|
-
categoryAxisMap.set('radius', radiusAxisModel);
|
|
20031
|
-
result.firstCategoryDimIndex = 0;
|
|
20032
|
-
}
|
|
20033
|
-
if (isCategory(angleAxisModel)) {
|
|
20034
|
-
categoryAxisMap.set('angle', angleAxisModel);
|
|
20035
|
-
result.firstCategoryDimIndex = 1;
|
|
20036
|
-
}
|
|
20037
|
-
},
|
|
20038
|
-
|
|
20039
|
-
geo: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20040
|
-
result.coordSysDims = ['lng', 'lat'];
|
|
20041
|
-
},
|
|
20042
|
-
|
|
20043
|
-
parallel: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20044
|
-
var ecModel = seriesModel.ecModel;
|
|
20045
|
-
var parallelModel = ecModel.getComponent(
|
|
20046
|
-
'parallel', seriesModel.get('parallelIndex')
|
|
20047
|
-
);
|
|
20048
|
-
var coordSysDims = result.coordSysDims = parallelModel.dimensions.slice();
|
|
20049
|
-
|
|
20050
|
-
each$1(parallelModel.parallelAxisIndex, function (axisIndex, index) {
|
|
20051
|
-
var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
|
|
20052
|
-
var axisDim = coordSysDims[index];
|
|
20053
|
-
axisMap.set(axisDim, axisModel);
|
|
20054
|
-
|
|
20055
|
-
if (isCategory(axisModel) && result.firstCategoryDimIndex == null) {
|
|
20056
|
-
categoryAxisMap.set(axisDim, axisModel);
|
|
20057
|
-
result.firstCategoryDimIndex = index;
|
|
20058
|
-
}
|
|
20059
|
-
});
|
|
20060
|
-
}
|
|
20061
|
-
};
|
|
20062
|
-
|
|
20063
|
-
function isCategory(axisModel) {
|
|
20064
|
-
return axisModel.get('type') === 'category';
|
|
20065
|
-
}
|
|
20066
|
-
|
|
20067
|
-
/*
|
|
20068
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
20069
|
-
* or more contributor license agreements. See the NOTICE file
|
|
20070
|
-
* distributed with this work for additional information
|
|
20071
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
20072
|
-
* to you under the Apache License, Version 2.0 (the
|
|
20073
|
-
* "License"); you may not use this file except in compliance
|
|
20074
|
-
* with the License. You may obtain a copy of the License at
|
|
20075
|
-
*
|
|
20076
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20077
|
-
*
|
|
20078
|
-
* Unless required by applicable law or agreed to in writing,
|
|
20079
|
-
* software distributed under the License is distributed on an
|
|
20080
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20081
|
-
* KIND, either express or implied. See the License for the
|
|
20082
|
-
* specific language governing permissions and limitations
|
|
20083
|
-
* under the License.
|
|
20084
|
-
*/
|
|
20085
|
-
|
|
20086
20268
|
// Avoid typo.
|
|
20087
20269
|
var SOURCE_FORMAT_ORIGINAL = 'original';
|
|
20088
20270
|
var SOURCE_FORMAT_ARRAY_ROWS = 'arrayRows';
|
|
@@ -20252,6 +20434,13 @@ enableClassCheck(Source);
|
|
|
20252
20434
|
* under the License.
|
|
20253
20435
|
*/
|
|
20254
20436
|
|
|
20437
|
+
// The result of `guessOrdinal`.
|
|
20438
|
+
var BE_ORDINAL = {
|
|
20439
|
+
Must: 1, // Encounter string but not '-' and not number-like.
|
|
20440
|
+
Might: 2, // Encounter string but number-like.
|
|
20441
|
+
Not: 3 // Other cases
|
|
20442
|
+
};
|
|
20443
|
+
|
|
20255
20444
|
var inner$3 = makeInner();
|
|
20256
20445
|
|
|
20257
20446
|
/**
|
|
@@ -20385,14 +20574,6 @@ function prepareSource(seriesModel) {
|
|
|
20385
20574
|
data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine
|
|
20386
20575
|
);
|
|
20387
20576
|
|
|
20388
|
-
// Note: dataset option does not have `encode`.
|
|
20389
|
-
var encodeDefine = seriesOption.encode;
|
|
20390
|
-
if (!encodeDefine && datasetModel) {
|
|
20391
|
-
encodeDefine = makeDefaultEncode(
|
|
20392
|
-
seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
|
|
20393
|
-
);
|
|
20394
|
-
}
|
|
20395
|
-
|
|
20396
20577
|
inner$3(seriesModel).source = new Source({
|
|
20397
20578
|
data: data,
|
|
20398
20579
|
fromDataset: fromDataset,
|
|
@@ -20401,7 +20582,8 @@ function prepareSource(seriesModel) {
|
|
|
20401
20582
|
dimensionsDefine: completeResult.dimensionsDefine,
|
|
20402
20583
|
startIndex: completeResult.startIndex,
|
|
20403
20584
|
dimensionsDetectCount: completeResult.dimensionsDetectCount,
|
|
20404
|
-
|
|
20585
|
+
// Note: dataset option does not have `encode`.
|
|
20586
|
+
encodeDefine: seriesOption.encode
|
|
20405
20587
|
});
|
|
20406
20588
|
}
|
|
20407
20589
|
|
|
@@ -20413,7 +20595,6 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
|
|
|
20413
20595
|
|
|
20414
20596
|
var dimensionsDetectCount;
|
|
20415
20597
|
var startIndex;
|
|
20416
|
-
var findPotentialName;
|
|
20417
20598
|
|
|
20418
20599
|
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
|
|
20419
20600
|
// Rule: Most of the first line are string: it is header.
|
|
@@ -20456,13 +20637,11 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
|
|
|
20456
20637
|
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
|
|
20457
20638
|
if (!dimensionsDefine) {
|
|
20458
20639
|
dimensionsDefine = objectRowsCollectDimensions(data);
|
|
20459
|
-
findPotentialName = true;
|
|
20460
20640
|
}
|
|
20461
20641
|
}
|
|
20462
20642
|
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
|
|
20463
20643
|
if (!dimensionsDefine) {
|
|
20464
20644
|
dimensionsDefine = [];
|
|
20465
|
-
findPotentialName = true;
|
|
20466
20645
|
each$1(data, function (colArr, key) {
|
|
20467
20646
|
dimensionsDefine.push(key);
|
|
20468
20647
|
});
|
|
@@ -20478,21 +20657,10 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
|
|
|
20478
20657
|
}
|
|
20479
20658
|
}
|
|
20480
20659
|
|
|
20481
|
-
var potentialNameDimIndex;
|
|
20482
|
-
if (findPotentialName) {
|
|
20483
|
-
each$1(dimensionsDefine, function (dim, idx) {
|
|
20484
|
-
if ((isObject$1(dim) ? dim.name : dim) === 'name') {
|
|
20485
|
-
potentialNameDimIndex = idx;
|
|
20486
|
-
}
|
|
20487
|
-
});
|
|
20488
|
-
}
|
|
20489
|
-
|
|
20490
20660
|
return {
|
|
20491
20661
|
startIndex: startIndex,
|
|
20492
20662
|
dimensionsDefine: normalizeDimensionsDefine(dimensionsDefine),
|
|
20493
|
-
dimensionsDetectCount: dimensionsDetectCount
|
|
20494
|
-
potentialNameDimIndex: potentialNameDimIndex
|
|
20495
|
-
// TODO: potentialIdDimIdx
|
|
20663
|
+
dimensionsDetectCount: dimensionsDetectCount
|
|
20496
20664
|
};
|
|
20497
20665
|
}
|
|
20498
20666
|
|
|
@@ -20566,107 +20734,202 @@ function objectRowsCollectDimensions(data) {
|
|
|
20566
20734
|
}
|
|
20567
20735
|
}
|
|
20568
20736
|
|
|
20569
|
-
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20737
|
+
/**
|
|
20738
|
+
* [The strategy of the arrengment of data dimensions for dataset]:
|
|
20739
|
+
* "value way": all axes are non-category axes. So series one by one take
|
|
20740
|
+
* several (the number is coordSysDims.length) dimensions from dataset.
|
|
20741
|
+
* The result of data arrengment of data dimensions like:
|
|
20742
|
+
* | ser0_x | ser0_y | ser1_x | ser1_y | ser2_x | ser2_y |
|
|
20743
|
+
* "category way": at least one axis is category axis. So the the first data
|
|
20744
|
+
* dimension is always mapped to the first category axis and shared by
|
|
20745
|
+
* all of the series. The other data dimensions are taken by series like
|
|
20746
|
+
* "value way" does.
|
|
20747
|
+
* The result of data arrengment of data dimensions like:
|
|
20748
|
+
* | ser_shared_x | ser0_y | ser1_y | ser2_y |
|
|
20749
|
+
*
|
|
20750
|
+
* @param {Array.<Object|string>} coordDimensions [{name: <string>, type: <string>, dimsDef: <Array>}, ...]
|
|
20751
|
+
* @param {module:model/Series} seriesModel
|
|
20752
|
+
* @param {module:data/Source} source
|
|
20753
|
+
* @return {Object} encode Never be `null/undefined`.
|
|
20754
|
+
*/
|
|
20755
|
+
function makeSeriesEncodeForAxisCoordSys(coordDimensions, seriesModel, source) {
|
|
20576
20756
|
var encode = {};
|
|
20577
|
-
|
|
20578
|
-
|
|
20757
|
+
|
|
20758
|
+
var datasetModel = getDatasetModel(seriesModel);
|
|
20759
|
+
// Currently only make default when using dataset, util more reqirements occur.
|
|
20760
|
+
if (!datasetModel || !coordDimensions) {
|
|
20761
|
+
return encode;
|
|
20762
|
+
}
|
|
20763
|
+
|
|
20579
20764
|
var encodeItemName = [];
|
|
20580
20765
|
var encodeSeriesName = [];
|
|
20581
|
-
var seriesType = seriesModel.subType;
|
|
20582
|
-
|
|
20583
|
-
// ??? TODO refactor: provide by series itself.
|
|
20584
|
-
// Consider the case: 'map' series is based on geo coordSys,
|
|
20585
|
-
// 'graph', 'heatmap' can be based on cartesian. But can not
|
|
20586
|
-
// give default rule simply here.
|
|
20587
|
-
var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
|
|
20588
|
-
var cSeriesMap = createHashMap([
|
|
20589
|
-
'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
|
|
20590
|
-
]);
|
|
20591
|
-
|
|
20592
|
-
// Usually in this case series will use the first data
|
|
20593
|
-
// dimension as the "value" dimension, or other default
|
|
20594
|
-
// processes respectively.
|
|
20595
|
-
if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
|
|
20596
|
-
var ecModel = seriesModel.ecModel;
|
|
20597
|
-
var datasetMap = inner$3(ecModel).datasetMap;
|
|
20598
|
-
var key = datasetModel.uid + '_' + seriesLayoutBy;
|
|
20599
|
-
var datasetRecord = datasetMap.get(key)
|
|
20600
|
-
|| datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});
|
|
20601
20766
|
|
|
20602
|
-
|
|
20603
|
-
|
|
20604
|
-
|
|
20605
|
-
|
|
20606
|
-
|
|
20607
|
-
|
|
20608
|
-
|
|
20609
|
-
|
|
20610
|
-
|
|
20611
|
-
|
|
20612
|
-
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
|
|
20617
|
-
|
|
20618
|
-
|
|
20619
|
-
|
|
20620
|
-
|
|
20621
|
-
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20767
|
+
var ecModel = seriesModel.ecModel;
|
|
20768
|
+
var datasetMap = inner$3(ecModel).datasetMap;
|
|
20769
|
+
var key = datasetModel.uid + '_' + source.seriesLayoutBy;
|
|
20770
|
+
|
|
20771
|
+
var baseCategoryDimIndex;
|
|
20772
|
+
var categoryWayValueDimStart;
|
|
20773
|
+
coordDimensions = coordDimensions.slice();
|
|
20774
|
+
each$1(coordDimensions, function (coordDimInfo, coordDimIdx) {
|
|
20775
|
+
!isObject$1(coordDimInfo) && (coordDimensions[coordDimIdx] = {name: coordDimInfo});
|
|
20776
|
+
if (coordDimInfo.type === 'ordinal' && baseCategoryDimIndex == null) {
|
|
20777
|
+
baseCategoryDimIndex = coordDimIdx;
|
|
20778
|
+
categoryWayValueDimStart = getDataDimCountOnCoordDim(coordDimensions[coordDimIdx]);
|
|
20779
|
+
}
|
|
20780
|
+
encode[coordDimInfo.name] = [];
|
|
20781
|
+
});
|
|
20782
|
+
|
|
20783
|
+
var datasetRecord = datasetMap.get(key)
|
|
20784
|
+
|| datasetMap.set(key, {categoryWayDim: categoryWayValueDimStart, valueWayDim: 0});
|
|
20785
|
+
|
|
20786
|
+
// TODO
|
|
20787
|
+
// Auto detect first time axis and do arrangement.
|
|
20788
|
+
each$1(coordDimensions, function (coordDimInfo, coordDimIdx) {
|
|
20789
|
+
var coordDimName = coordDimInfo.name;
|
|
20790
|
+
var count = getDataDimCountOnCoordDim(coordDimInfo);
|
|
20791
|
+
|
|
20792
|
+
// In value way.
|
|
20793
|
+
if (baseCategoryDimIndex == null) {
|
|
20794
|
+
var start = datasetRecord.valueWayDim;
|
|
20795
|
+
pushDim(encode[coordDimName], start, count);
|
|
20796
|
+
pushDim(encodeSeriesName, start, count);
|
|
20797
|
+
datasetRecord.valueWayDim += count;
|
|
20798
|
+
|
|
20799
|
+
// ??? TODO give a better default series name rule?
|
|
20800
|
+
// especially when encode x y specified.
|
|
20801
|
+
// consider: when mutiple series share one dimension
|
|
20802
|
+
// category axis, series name should better use
|
|
20803
|
+
// the other dimsion name. On the other hand, use
|
|
20804
|
+
// both dimensions name.
|
|
20805
|
+
}
|
|
20806
|
+
// In category way, the first category axis.
|
|
20807
|
+
else if (baseCategoryDimIndex === coordDimIdx) {
|
|
20808
|
+
pushDim(encode[coordDimName], 0, count);
|
|
20809
|
+
pushDim(encodeItemName, 0, count);
|
|
20810
|
+
}
|
|
20811
|
+
// In category way, the other axis.
|
|
20812
|
+
else {
|
|
20813
|
+
var start = datasetRecord.categoryWayDim;
|
|
20814
|
+
pushDim(encode[coordDimName], start, count);
|
|
20815
|
+
pushDim(encodeSeriesName, start, count);
|
|
20816
|
+
datasetRecord.categoryWayDim += count;
|
|
20817
|
+
}
|
|
20818
|
+
});
|
|
20819
|
+
|
|
20820
|
+
function pushDim(dimIdxArr, idxFrom, idxCount) {
|
|
20821
|
+
for (var i = 0; i < idxCount; i++) {
|
|
20822
|
+
dimIdxArr.push(idxFrom + i);
|
|
20823
|
+
}
|
|
20824
|
+
}
|
|
20825
|
+
|
|
20826
|
+
function getDataDimCountOnCoordDim(coordDimInfo) {
|
|
20827
|
+
var dimsDef = coordDimInfo.dimsDef;
|
|
20828
|
+
return dimsDef ? dimsDef.length : 1;
|
|
20635
20829
|
}
|
|
20636
|
-
|
|
20637
|
-
// ??? TODO refactor: provide by series itself.
|
|
20638
|
-
// [{name: ..., value: ...}, ...] like:
|
|
20639
|
-
else if (nSeriesMap.get(seriesType) != null) {
|
|
20640
|
-
// Find the first not ordinal. (5 is an experience value)
|
|
20641
|
-
var firstNotOrdinal;
|
|
20642
|
-
for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
|
|
20643
|
-
if (!doGuessOrdinal(
|
|
20644
|
-
data, sourceFormat, seriesLayoutBy,
|
|
20645
|
-
completeResult.dimensionsDefine, completeResult.startIndex, i
|
|
20646
|
-
)) {
|
|
20647
|
-
firstNotOrdinal = i;
|
|
20648
|
-
}
|
|
20649
|
-
}
|
|
20650
|
-
if (firstNotOrdinal != null) {
|
|
20651
|
-
encode.value = firstNotOrdinal;
|
|
20652
|
-
var nameDimIndex = completeResult.potentialNameDimIndex
|
|
20653
|
-
|| Math.max(firstNotOrdinal - 1, 0);
|
|
20654
|
-
// By default, label use itemName in charts.
|
|
20655
|
-
// So we dont set encodeLabel here.
|
|
20656
|
-
encodeSeriesName.push(nameDimIndex);
|
|
20657
|
-
encodeItemName.push(nameDimIndex);
|
|
20658
|
-
// encodeTooltip.push(firstNotOrdinal);
|
|
20659
|
-
}
|
|
20660
|
-
}
|
|
20661
|
-
|
|
20662
|
-
// encodeTooltip.length && (encode.tooltip = encodeTooltip);
|
|
20663
|
-
// encodeLabel.length && (encode.label = encodeLabel);
|
|
20830
|
+
|
|
20664
20831
|
encodeItemName.length && (encode.itemName = encodeItemName);
|
|
20665
20832
|
encodeSeriesName.length && (encode.seriesName = encodeSeriesName);
|
|
20666
20833
|
|
|
20667
20834
|
return encode;
|
|
20668
20835
|
}
|
|
20669
20836
|
|
|
20837
|
+
/**
|
|
20838
|
+
* Work for data like [{name: ..., value: ...}, ...].
|
|
20839
|
+
*
|
|
20840
|
+
* @param {module:model/Series} seriesModel
|
|
20841
|
+
* @param {module:data/Source} source
|
|
20842
|
+
* @return {Object} encode Never be `null/undefined`.
|
|
20843
|
+
*/
|
|
20844
|
+
function makeSeriesEncodeForNameBased(seriesModel, source, dimCount) {
|
|
20845
|
+
var encode = {};
|
|
20846
|
+
|
|
20847
|
+
var datasetModel = getDatasetModel(seriesModel);
|
|
20848
|
+
// Currently only make default when using dataset, util more reqirements occur.
|
|
20849
|
+
if (!datasetModel) {
|
|
20850
|
+
return encode;
|
|
20851
|
+
}
|
|
20852
|
+
|
|
20853
|
+
var sourceFormat = source.sourceFormat;
|
|
20854
|
+
var dimensionsDefine = source.dimensionsDefine;
|
|
20855
|
+
|
|
20856
|
+
var potentialNameDimIndex;
|
|
20857
|
+
if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS || sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
|
|
20858
|
+
each$1(dimensionsDefine, function (dim, idx) {
|
|
20859
|
+
if ((isObject$1(dim) ? dim.name : dim) === 'name') {
|
|
20860
|
+
potentialNameDimIndex = idx;
|
|
20861
|
+
}
|
|
20862
|
+
});
|
|
20863
|
+
}
|
|
20864
|
+
|
|
20865
|
+
// idxResult: {v, n}.
|
|
20866
|
+
var idxResult = (function () {
|
|
20867
|
+
|
|
20868
|
+
var idxRes0 = {};
|
|
20869
|
+
var idxRes1 = {};
|
|
20870
|
+
var guessRecords = [];
|
|
20871
|
+
|
|
20872
|
+
// 5 is an experience value.
|
|
20873
|
+
for (var i = 0, len = Math.min(5, dimCount); i < len; i++) {
|
|
20874
|
+
var guessResult = doGuessOrdinal(
|
|
20875
|
+
source.data, sourceFormat, source.seriesLayoutBy,
|
|
20876
|
+
dimensionsDefine, source.startIndex, i
|
|
20877
|
+
);
|
|
20878
|
+
guessRecords.push(guessResult);
|
|
20879
|
+
var isPureNumber = guessResult === BE_ORDINAL.Not;
|
|
20880
|
+
|
|
20881
|
+
// [Strategy of idxRes0]: find the first BE_ORDINAL.Not as the value dim,
|
|
20882
|
+
// and then find a name dim with the priority:
|
|
20883
|
+
// "BE_ORDINAL.Might|BE_ORDINAL.Must" > "other dim" > "the value dim itself".
|
|
20884
|
+
if (isPureNumber && idxRes0.v == null && i !== potentialNameDimIndex) {
|
|
20885
|
+
idxRes0.v = i;
|
|
20886
|
+
}
|
|
20887
|
+
if (idxRes0.n == null
|
|
20888
|
+
|| (idxRes0.n === idxRes0.v)
|
|
20889
|
+
|| (!isPureNumber && guessRecords[idxRes0.n] === BE_ORDINAL.Not)
|
|
20890
|
+
) {
|
|
20891
|
+
idxRes0.n = i;
|
|
20892
|
+
}
|
|
20893
|
+
if (fulfilled(idxRes0) && guessRecords[idxRes0.n] !== BE_ORDINAL.Not) {
|
|
20894
|
+
return idxRes0;
|
|
20895
|
+
}
|
|
20896
|
+
|
|
20897
|
+
// [Strategy of idxRes1]: if idxRes0 not satisfied (that is, no BE_ORDINAL.Not),
|
|
20898
|
+
// find the first BE_ORDINAL.Might as the value dim,
|
|
20899
|
+
// and then find a name dim with the priority:
|
|
20900
|
+
// "other dim" > "the value dim itself".
|
|
20901
|
+
// That is for backward compat: number-like (e.g., `'3'`, `'55'`) can be
|
|
20902
|
+
// treated as number.
|
|
20903
|
+
if (!isPureNumber) {
|
|
20904
|
+
if (guessResult === BE_ORDINAL.Might && idxRes1.v == null && i !== potentialNameDimIndex) {
|
|
20905
|
+
idxRes1.v = i;
|
|
20906
|
+
}
|
|
20907
|
+
if (idxRes1.n == null || (idxRes1.n === idxRes1.v)) {
|
|
20908
|
+
idxRes1.n = i;
|
|
20909
|
+
}
|
|
20910
|
+
}
|
|
20911
|
+
}
|
|
20912
|
+
|
|
20913
|
+
function fulfilled(idxResult) {
|
|
20914
|
+
return idxResult.v != null && idxResult.n != null;
|
|
20915
|
+
}
|
|
20916
|
+
|
|
20917
|
+
return fulfilled(idxRes0) ? idxRes0 : fulfilled(idxRes1) ? idxRes1 : null;
|
|
20918
|
+
})();
|
|
20919
|
+
|
|
20920
|
+
if (idxResult) {
|
|
20921
|
+
encode.value = idxResult.v;
|
|
20922
|
+
// `potentialNameDimIndex` has highest priority.
|
|
20923
|
+
var nameDimIndex = potentialNameDimIndex != null ? potentialNameDimIndex : idxResult.n;
|
|
20924
|
+
// By default, label use itemName in charts.
|
|
20925
|
+
// So we dont set encodeLabel here.
|
|
20926
|
+
encode.itemName = [nameDimIndex];
|
|
20927
|
+
encode.seriesName = [nameDimIndex];
|
|
20928
|
+
}
|
|
20929
|
+
|
|
20930
|
+
return encode;
|
|
20931
|
+
}
|
|
20932
|
+
|
|
20670
20933
|
/**
|
|
20671
20934
|
* If return null/undefined, indicate that should not use datasetModel.
|
|
20672
20935
|
*/
|
|
@@ -20690,7 +20953,7 @@ function getDatasetModel(seriesModel) {
|
|
|
20690
20953
|
*
|
|
20691
20954
|
* @param {module:echars/data/Source} source
|
|
20692
20955
|
* @param {number} dimIndex
|
|
20693
|
-
* @return {
|
|
20956
|
+
* @return {BE_ORDINAL} guess result.
|
|
20694
20957
|
*/
|
|
20695
20958
|
function guessOrdinal(source, dimIndex) {
|
|
20696
20959
|
return doGuessOrdinal(
|
|
@@ -20704,6 +20967,7 @@ function guessOrdinal(source, dimIndex) {
|
|
|
20704
20967
|
}
|
|
20705
20968
|
|
|
20706
20969
|
// dimIndex may be overflow source data.
|
|
20970
|
+
// return {BE_ORDINAL}
|
|
20707
20971
|
function doGuessOrdinal(
|
|
20708
20972
|
data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
|
|
20709
20973
|
) {
|
|
@@ -20712,15 +20976,26 @@ function doGuessOrdinal(
|
|
|
20712
20976
|
var maxLoop = 5;
|
|
20713
20977
|
|
|
20714
20978
|
if (isTypedArray(data)) {
|
|
20715
|
-
return
|
|
20979
|
+
return BE_ORDINAL.Not;
|
|
20716
20980
|
}
|
|
20717
20981
|
|
|
20718
20982
|
// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
|
|
20719
20983
|
// always exists in source.
|
|
20720
20984
|
var dimName;
|
|
20985
|
+
var dimType;
|
|
20721
20986
|
if (dimensionsDefine) {
|
|
20722
|
-
|
|
20723
|
-
|
|
20987
|
+
var dimDefItem = dimensionsDefine[dimIndex];
|
|
20988
|
+
if (isObject$1(dimDefItem)) {
|
|
20989
|
+
dimName = dimDefItem.name;
|
|
20990
|
+
dimType = dimDefItem.type;
|
|
20991
|
+
}
|
|
20992
|
+
else if (isString(dimDefItem)) {
|
|
20993
|
+
dimName = dimDefItem;
|
|
20994
|
+
}
|
|
20995
|
+
}
|
|
20996
|
+
|
|
20997
|
+
if (dimType != null) {
|
|
20998
|
+
return dimType === 'ordinal' ? BE_ORDINAL.Must : BE_ORDINAL.Not;
|
|
20724
20999
|
}
|
|
20725
21000
|
|
|
20726
21001
|
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
|
|
@@ -20743,7 +21018,7 @@ function doGuessOrdinal(
|
|
|
20743
21018
|
}
|
|
20744
21019
|
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
|
|
20745
21020
|
if (!dimName) {
|
|
20746
|
-
return;
|
|
21021
|
+
return BE_ORDINAL.Not;
|
|
20747
21022
|
}
|
|
20748
21023
|
for (var i = 0; i < data.length && i < maxLoop; i++) {
|
|
20749
21024
|
var item = data[i];
|
|
@@ -20754,11 +21029,11 @@ function doGuessOrdinal(
|
|
|
20754
21029
|
}
|
|
20755
21030
|
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
|
|
20756
21031
|
if (!dimName) {
|
|
20757
|
-
return;
|
|
21032
|
+
return BE_ORDINAL.Not;
|
|
20758
21033
|
}
|
|
20759
21034
|
var sample = data[dimName];
|
|
20760
21035
|
if (!sample || isTypedArray(sample)) {
|
|
20761
|
-
return
|
|
21036
|
+
return BE_ORDINAL.Not;
|
|
20762
21037
|
}
|
|
20763
21038
|
for (var i = 0; i < sample.length && i < maxLoop; i++) {
|
|
20764
21039
|
if ((result = detectValue(sample[i])) != null) {
|
|
@@ -20771,7 +21046,7 @@ function doGuessOrdinal(
|
|
|
20771
21046
|
var item = data[i];
|
|
20772
21047
|
var val = getDataItemValue(item);
|
|
20773
21048
|
if (!isArray(val)) {
|
|
20774
|
-
return
|
|
21049
|
+
return BE_ORDINAL.Not;
|
|
20775
21050
|
}
|
|
20776
21051
|
if ((result = detectValue(val[dimIndex])) != null) {
|
|
20777
21052
|
return result;
|
|
@@ -20780,17 +21055,18 @@ function doGuessOrdinal(
|
|
|
20780
21055
|
}
|
|
20781
21056
|
|
|
20782
21057
|
function detectValue(val) {
|
|
21058
|
+
var beStr = isString(val);
|
|
20783
21059
|
// Consider usage convenience, '1', '2' will be treated as "number".
|
|
20784
21060
|
// `isFinit('')` get `true`.
|
|
20785
21061
|
if (val != null && isFinite(val) && val !== '') {
|
|
20786
|
-
return
|
|
21062
|
+
return beStr ? BE_ORDINAL.Might : BE_ORDINAL.Not;
|
|
20787
21063
|
}
|
|
20788
|
-
else if (
|
|
20789
|
-
return
|
|
21064
|
+
else if (beStr && val !== '-') {
|
|
21065
|
+
return BE_ORDINAL.Must;
|
|
20790
21066
|
}
|
|
20791
21067
|
}
|
|
20792
21068
|
|
|
20793
|
-
return
|
|
21069
|
+
return BE_ORDINAL.Not;
|
|
20794
21070
|
}
|
|
20795
21071
|
|
|
20796
21072
|
/*
|
|
@@ -20995,7 +21271,7 @@ var GlobalModel = Model.extend({
|
|
|
20995
21271
|
mainType, resultItem.keyInfo.subType, true
|
|
20996
21272
|
);
|
|
20997
21273
|
|
|
20998
|
-
if (componentModel && componentModel
|
|
21274
|
+
if (componentModel && componentModel.constructor === ComponentModelClass) {
|
|
20999
21275
|
componentModel.name = resultItem.keyInfo.name;
|
|
21000
21276
|
// componentModel.settingTask && componentModel.settingTask.dirty();
|
|
21001
21277
|
componentModel.mergeOption(newCptOption, this);
|
|
@@ -23537,11 +23813,11 @@ var SeriesModel = ComponentModel.extend({
|
|
|
23537
23813
|
defaultOption: null,
|
|
23538
23814
|
|
|
23539
23815
|
/**
|
|
23540
|
-
*
|
|
23541
|
-
* @type {
|
|
23816
|
+
* legend visual provider to the legend component
|
|
23817
|
+
* @type {Object}
|
|
23542
23818
|
*/
|
|
23543
23819
|
// PENDING
|
|
23544
|
-
|
|
23820
|
+
legendVisualProvider: null,
|
|
23545
23821
|
|
|
23546
23822
|
/**
|
|
23547
23823
|
* Access path of color for visual
|
|
@@ -24630,25 +24906,30 @@ var seriesColor = {
|
|
|
24630
24906
|
reset: function (seriesModel, ecModel) {
|
|
24631
24907
|
var data = seriesModel.getData();
|
|
24632
24908
|
var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.color').split('.');
|
|
24633
|
-
|
|
24634
|
-
|
|
24909
|
+
// Set in itemStyle
|
|
24910
|
+
var color = seriesModel.get(colorAccessPath);
|
|
24911
|
+
var colorCallback = (isFunction$1(color) && !(color instanceof Gradient))
|
|
24912
|
+
? color : null;
|
|
24913
|
+
// Default color
|
|
24914
|
+
if (!color || colorCallback) {
|
|
24915
|
+
color = seriesModel.getColorFromPalette(
|
|
24635
24916
|
// TODO series count changed.
|
|
24636
24917
|
seriesModel.name, null, ecModel.getSeriesCount()
|
|
24637
|
-
);
|
|
24918
|
+
);
|
|
24919
|
+
}
|
|
24638
24920
|
|
|
24639
|
-
// FIXME Set color function or use the platte color
|
|
24640
24921
|
data.setVisual('color', color);
|
|
24641
|
-
|
|
24922
|
+
|
|
24642
24923
|
var borderColorAccessPath = (seriesModel.visualBorderColorAccessPath || 'itemStyle.borderColor').split('.');
|
|
24643
24924
|
var borderColor = seriesModel.get(borderColorAccessPath);
|
|
24644
24925
|
data.setVisual('borderColor', borderColor);
|
|
24645
24926
|
|
|
24646
24927
|
// Only visible series has each data be visual encoded
|
|
24647
24928
|
if (!ecModel.isSeriesFiltered(seriesModel)) {
|
|
24648
|
-
if (
|
|
24929
|
+
if (colorCallback) {
|
|
24649
24930
|
data.each(function (idx) {
|
|
24650
24931
|
data.setItemVisual(
|
|
24651
|
-
idx, 'color',
|
|
24932
|
+
idx, 'color', colorCallback(seriesModel.getDataParams(idx))
|
|
24652
24933
|
);
|
|
24653
24934
|
});
|
|
24654
24935
|
}
|
|
@@ -25733,6 +26014,9 @@ var theme = {
|
|
|
25733
26014
|
},
|
|
25734
26015
|
crossStyle: {
|
|
25735
26016
|
color: contrastColor
|
|
26017
|
+
},
|
|
26018
|
+
label: {
|
|
26019
|
+
color: '#000'
|
|
25736
26020
|
}
|
|
25737
26021
|
}
|
|
25738
26022
|
},
|
|
@@ -26703,10 +26987,10 @@ var isFunction = isFunction$1;
|
|
|
26703
26987
|
var isObject = isObject$1;
|
|
26704
26988
|
var parseClassType = ComponentModel.parseClassType;
|
|
26705
26989
|
|
|
26706
|
-
var version = '4.
|
|
26990
|
+
var version = '4.6.0';
|
|
26707
26991
|
|
|
26708
26992
|
var dependencies = {
|
|
26709
|
-
zrender: '4.
|
|
26993
|
+
zrender: '4.2.0'
|
|
26710
26994
|
};
|
|
26711
26995
|
|
|
26712
26996
|
var TEST_FRAME_REMAIN_TIME = 1;
|
|
@@ -29182,9 +29466,6 @@ DataDiffer.prototype = {
|
|
|
29182
29466
|
initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, '_oldKeyGetter', this);
|
|
29183
29467
|
initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter', this);
|
|
29184
29468
|
|
|
29185
|
-
// Travel by inverted order to make sure order consistency
|
|
29186
|
-
// when duplicate keys exists (consider newDataIndex.pop() below).
|
|
29187
|
-
// For performance consideration, these code below do not look neat.
|
|
29188
29469
|
for (i = 0; i < oldArr.length; i++) {
|
|
29189
29470
|
var key = oldDataKeyArr[i];
|
|
29190
29471
|
var idx = newDataIndexMap[key];
|
|
@@ -29196,7 +29477,7 @@ DataDiffer.prototype = {
|
|
|
29196
29477
|
var len = idx.length;
|
|
29197
29478
|
if (len) {
|
|
29198
29479
|
len === 1 && (newDataIndexMap[key] = null);
|
|
29199
|
-
idx = idx.
|
|
29480
|
+
idx = idx.shift();
|
|
29200
29481
|
}
|
|
29201
29482
|
else {
|
|
29202
29483
|
newDataIndexMap[key] = null;
|
|
@@ -29416,6 +29697,138 @@ function mayLabelDimType(dimType) {
|
|
|
29416
29697
|
* under the License.
|
|
29417
29698
|
*/
|
|
29418
29699
|
|
|
29700
|
+
/**
|
|
29701
|
+
* @class
|
|
29702
|
+
* @param {Object|DataDimensionInfo} [opt] All of the fields will be shallow copied.
|
|
29703
|
+
*/
|
|
29704
|
+
function DataDimensionInfo(opt) {
|
|
29705
|
+
if (opt != null) {
|
|
29706
|
+
extend(this, opt);
|
|
29707
|
+
}
|
|
29708
|
+
|
|
29709
|
+
/**
|
|
29710
|
+
* Dimension name.
|
|
29711
|
+
* Mandatory.
|
|
29712
|
+
* @type {string}
|
|
29713
|
+
*/
|
|
29714
|
+
// this.name;
|
|
29715
|
+
|
|
29716
|
+
/**
|
|
29717
|
+
* The origin name in dimsDef, see source helper.
|
|
29718
|
+
* If displayName given, the tooltip will displayed vertically.
|
|
29719
|
+
* Optional.
|
|
29720
|
+
* @type {string}
|
|
29721
|
+
*/
|
|
29722
|
+
// this.displayName;
|
|
29723
|
+
|
|
29724
|
+
/**
|
|
29725
|
+
* Which coordSys dimension this dimension mapped to.
|
|
29726
|
+
* A `coordDim` can be a "coordSysDim" that the coordSys required
|
|
29727
|
+
* (for example, an item in `coordSysDims` of `model/referHelper#CoordSysInfo`),
|
|
29728
|
+
* or an generated "extra coord name" if does not mapped to any "coordSysDim"
|
|
29729
|
+
* (That is determined by whether `isExtraCoord` is `true`).
|
|
29730
|
+
* Mandatory.
|
|
29731
|
+
* @type {string}
|
|
29732
|
+
*/
|
|
29733
|
+
// this.coordDim;
|
|
29734
|
+
|
|
29735
|
+
/**
|
|
29736
|
+
* The index of this dimension in `series.encode[coordDim]`.
|
|
29737
|
+
* Mandatory.
|
|
29738
|
+
* @type {number}
|
|
29739
|
+
*/
|
|
29740
|
+
// this.coordDimIndex;
|
|
29741
|
+
|
|
29742
|
+
/**
|
|
29743
|
+
* Dimension type. The enumerable values are the key of
|
|
29744
|
+
* `dataCtors` of `data/List`.
|
|
29745
|
+
* Optional.
|
|
29746
|
+
* @type {string}
|
|
29747
|
+
*/
|
|
29748
|
+
// this.type;
|
|
29749
|
+
|
|
29750
|
+
/**
|
|
29751
|
+
* This index of this dimension info in `data/List#_dimensionInfos`.
|
|
29752
|
+
* Mandatory after added to `data/List`.
|
|
29753
|
+
* @type {number}
|
|
29754
|
+
*/
|
|
29755
|
+
// this.index;
|
|
29756
|
+
|
|
29757
|
+
/**
|
|
29758
|
+
* The format of `otherDims` is:
|
|
29759
|
+
* ```js
|
|
29760
|
+
* {
|
|
29761
|
+
* tooltip: number optional,
|
|
29762
|
+
* label: number optional,
|
|
29763
|
+
* itemName: number optional,
|
|
29764
|
+
* seriesName: number optional,
|
|
29765
|
+
* }
|
|
29766
|
+
* ```
|
|
29767
|
+
*
|
|
29768
|
+
* A `series.encode` can specified these fields:
|
|
29769
|
+
* ```js
|
|
29770
|
+
* encode: {
|
|
29771
|
+
* // "3, 1, 5" is the index of data dimension.
|
|
29772
|
+
* tooltip: [3, 1, 5],
|
|
29773
|
+
* label: [0, 3],
|
|
29774
|
+
* ...
|
|
29775
|
+
* }
|
|
29776
|
+
* ```
|
|
29777
|
+
* `otherDims` is the parse result of the `series.encode` above, like:
|
|
29778
|
+
* ```js
|
|
29779
|
+
* // Suppose the index of this data dimension is `3`.
|
|
29780
|
+
* this.otherDims = {
|
|
29781
|
+
* // `3` is at the index `0` of the `encode.tooltip`
|
|
29782
|
+
* tooltip: 0,
|
|
29783
|
+
* // `3` is at the index `1` of the `encode.tooltip`
|
|
29784
|
+
* label: 1
|
|
29785
|
+
* };
|
|
29786
|
+
* ```
|
|
29787
|
+
*
|
|
29788
|
+
* This prop should never be `null`/`undefined` after initialized.
|
|
29789
|
+
* @type {Object}
|
|
29790
|
+
*/
|
|
29791
|
+
this.otherDims = {};
|
|
29792
|
+
|
|
29793
|
+
/**
|
|
29794
|
+
* Be `true` if this dimension is not mapped to any "coordSysDim" that the
|
|
29795
|
+
* "coordSys" required.
|
|
29796
|
+
* Mandatory.
|
|
29797
|
+
* @type {boolean}
|
|
29798
|
+
*/
|
|
29799
|
+
// this.isExtraCoord;
|
|
29800
|
+
|
|
29801
|
+
/**
|
|
29802
|
+
* @type {module:data/OrdinalMeta}
|
|
29803
|
+
*/
|
|
29804
|
+
// this.ordinalMeta;
|
|
29805
|
+
|
|
29806
|
+
/**
|
|
29807
|
+
* Whether to create inverted indices.
|
|
29808
|
+
* @type {boolean}
|
|
29809
|
+
*/
|
|
29810
|
+
// this.createInvertedIndices;
|
|
29811
|
+
}
|
|
29812
|
+
|
|
29813
|
+
/*
|
|
29814
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
29815
|
+
* or more contributor license agreements. See the NOTICE file
|
|
29816
|
+
* distributed with this work for additional information
|
|
29817
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
29818
|
+
* to you under the Apache License, Version 2.0 (the
|
|
29819
|
+
* "License"); you may not use this file except in compliance
|
|
29820
|
+
* with the License. You may obtain a copy of the License at
|
|
29821
|
+
*
|
|
29822
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
29823
|
+
*
|
|
29824
|
+
* Unless required by applicable law or agreed to in writing,
|
|
29825
|
+
* software distributed under the License is distributed on an
|
|
29826
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
29827
|
+
* KIND, either express or implied. See the License for the
|
|
29828
|
+
* specific language governing permissions and limitations
|
|
29829
|
+
* under the License.
|
|
29830
|
+
*/
|
|
29831
|
+
|
|
29419
29832
|
/* global Float64Array, Int32Array, Uint32Array, Uint16Array */
|
|
29420
29833
|
|
|
29421
29834
|
/**
|
|
@@ -29493,13 +29906,9 @@ function transferProperties(target, source) {
|
|
|
29493
29906
|
* @constructor
|
|
29494
29907
|
* @alias module:echarts/data/List
|
|
29495
29908
|
*
|
|
29496
|
-
* @param {Array.<string|Object>} dimensions
|
|
29909
|
+
* @param {Array.<string|Object|module:data/DataDimensionInfo>} dimensions
|
|
29497
29910
|
* For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
|
|
29498
29911
|
* Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
|
|
29499
|
-
* Spetial fields: {
|
|
29500
|
-
* ordinalMeta: <module:echarts/data/OrdinalMeta>
|
|
29501
|
-
* createInvertedIndices: <boolean>
|
|
29502
|
-
* }
|
|
29503
29912
|
* @param {module:echarts/model/Model} hostModel
|
|
29504
29913
|
*/
|
|
29505
29914
|
var List = function (dimensions, hostModel) {
|
|
@@ -29515,7 +29924,10 @@ var List = function (dimensions, hostModel) {
|
|
|
29515
29924
|
var dimensionInfo = dimensions[i];
|
|
29516
29925
|
|
|
29517
29926
|
if (isString(dimensionInfo)) {
|
|
29518
|
-
dimensionInfo = {name: dimensionInfo};
|
|
29927
|
+
dimensionInfo = new DataDimensionInfo({name: dimensionInfo});
|
|
29928
|
+
}
|
|
29929
|
+
else if (!(dimensionInfo instanceof DataDimensionInfo)) {
|
|
29930
|
+
dimensionInfo = new DataDimensionInfo(dimensionInfo);
|
|
29519
29931
|
}
|
|
29520
29932
|
|
|
29521
29933
|
var dimensionName = dimensionInfo.name;
|
|
@@ -30496,14 +30908,14 @@ listProto.indexOfName = function (name) {
|
|
|
30496
30908
|
* @return {number}
|
|
30497
30909
|
*/
|
|
30498
30910
|
listProto.indexOfRawIndex = function (rawIndex) {
|
|
30499
|
-
if (!this._indices) {
|
|
30500
|
-
return rawIndex;
|
|
30501
|
-
}
|
|
30502
|
-
|
|
30503
30911
|
if (rawIndex >= this._rawCount || rawIndex < 0) {
|
|
30504
30912
|
return -1;
|
|
30505
30913
|
}
|
|
30506
30914
|
|
|
30915
|
+
if (!this._indices) {
|
|
30916
|
+
return rawIndex;
|
|
30917
|
+
}
|
|
30918
|
+
|
|
30507
30919
|
// Indices are ascending
|
|
30508
30920
|
var indices = this._indices;
|
|
30509
30921
|
|
|
@@ -30535,7 +30947,8 @@ listProto.indexOfRawIndex = function (rawIndex) {
|
|
|
30535
30947
|
* @param {string} dim
|
|
30536
30948
|
* @param {number} value
|
|
30537
30949
|
* @param {number} [maxDistance=Infinity]
|
|
30538
|
-
* @return {Array.<number>}
|
|
30950
|
+
* @return {Array.<number>} If and only if multiple indices has
|
|
30951
|
+
* the same value, they are put to the result.
|
|
30539
30952
|
*/
|
|
30540
30953
|
listProto.indicesOfNearest = function (dim, value, maxDistance) {
|
|
30541
30954
|
var storage = this._storage;
|
|
@@ -30550,23 +30963,35 @@ listProto.indicesOfNearest = function (dim, value, maxDistance) {
|
|
|
30550
30963
|
maxDistance = Infinity;
|
|
30551
30964
|
}
|
|
30552
30965
|
|
|
30553
|
-
var minDist =
|
|
30966
|
+
var minDist = Infinity;
|
|
30554
30967
|
var minDiff = -1;
|
|
30968
|
+
var nearestIndicesLen = 0;
|
|
30969
|
+
|
|
30970
|
+
// Check the test case of `test/ut/spec/data/List.js`.
|
|
30555
30971
|
for (var i = 0, len = this.count(); i < len; i++) {
|
|
30556
|
-
var diff = value - this.get(dim, i
|
|
30972
|
+
var diff = value - this.get(dim, i);
|
|
30557
30973
|
var dist = Math.abs(diff);
|
|
30558
|
-
if (
|
|
30559
|
-
//
|
|
30560
|
-
//
|
|
30561
|
-
//
|
|
30562
|
-
|
|
30974
|
+
if (dist <= maxDistance) {
|
|
30975
|
+
// When the `value` is at the middle of `this.get(dim, i)` and `this.get(dim, i+1)`,
|
|
30976
|
+
// we'd better not push both of them to `nearestIndices`, otherwise it is easy to
|
|
30977
|
+
// get more than one item in `nearestIndices` (more specifically, in `tooltip`).
|
|
30978
|
+
// So we chose the one that `diff >= 0` in this csae.
|
|
30979
|
+
// But if `this.get(dim, i)` and `this.get(dim, j)` get the same value, both of them
|
|
30980
|
+
// should be push to `nearestIndices`.
|
|
30981
|
+
if (dist < minDist
|
|
30982
|
+
|| (dist === minDist && diff >= 0 && minDiff < 0)
|
|
30983
|
+
) {
|
|
30563
30984
|
minDist = dist;
|
|
30564
30985
|
minDiff = diff;
|
|
30565
|
-
|
|
30986
|
+
nearestIndicesLen = 0;
|
|
30987
|
+
}
|
|
30988
|
+
if (diff === minDiff) {
|
|
30989
|
+
nearestIndices[nearestIndicesLen++] = i;
|
|
30566
30990
|
}
|
|
30567
|
-
nearestIndices.push(i);
|
|
30568
30991
|
}
|
|
30569
30992
|
}
|
|
30993
|
+
nearestIndices.length = nearestIndicesLen;
|
|
30994
|
+
|
|
30570
30995
|
return nearestIndices;
|
|
30571
30996
|
};
|
|
30572
30997
|
|
|
@@ -31440,8 +31865,12 @@ listProto.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];
|
|
|
31440
31865
|
/**
|
|
31441
31866
|
* @see {module:echarts/test/ut/spec/data/completeDimensions}
|
|
31442
31867
|
*
|
|
31443
|
-
*
|
|
31444
|
-
*
|
|
31868
|
+
* This method builds the relationship between:
|
|
31869
|
+
* + "what the coord sys or series requires (see `sysDims`)",
|
|
31870
|
+
* + "what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)"
|
|
31871
|
+
* + "what the data source provids (see `source`)".
|
|
31872
|
+
*
|
|
31873
|
+
* Some guess strategy will be adapted if user does not define something.
|
|
31445
31874
|
* If no 'value' dimension specified, the first no-named dimension will be
|
|
31446
31875
|
* named as 'value'.
|
|
31447
31876
|
*
|
|
@@ -31457,32 +31886,20 @@ listProto.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];
|
|
|
31457
31886
|
* @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
|
|
31458
31887
|
* For example: ['asdf', {name, type}, ...].
|
|
31459
31888
|
* @param {Object|HashMap} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
|
|
31889
|
+
* @param {Function} [opt.encodeDefaulter] Called if no `opt.encodeDef` exists.
|
|
31890
|
+
* If not specified, auto find the next available data dim.
|
|
31891
|
+
* param source {module:data/Source}
|
|
31892
|
+
* param dimCount {number}
|
|
31893
|
+
* return {Object} encode Never be `null/undefined`.
|
|
31460
31894
|
* @param {string} [opt.generateCoord] Generate coord dim with the given name.
|
|
31461
|
-
*
|
|
31462
|
-
*
|
|
31895
|
+
* If not specified, extra dim names will be:
|
|
31896
|
+
* 'value', 'value0', 'value1', ...
|
|
31463
31897
|
* @param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
|
|
31464
|
-
*
|
|
31465
|
-
*
|
|
31466
|
-
*
|
|
31898
|
+
* If `generateCoordCount` specified, the generated dim names will be:
|
|
31899
|
+
* `generateCoord` + 0, `generateCoord` + 1, ...
|
|
31900
|
+
* can be Infinity, indicate that use all of the remain columns.
|
|
31467
31901
|
* @param {number} [opt.dimCount] If not specified, guess by the first data item.
|
|
31468
|
-
* @
|
|
31469
|
-
* @return {Array.<Object>} [{
|
|
31470
|
-
* name: string mandatory,
|
|
31471
|
-
* displayName: string, the origin name in dimsDef, see source helper.
|
|
31472
|
-
* If displayName given, the tooltip will displayed vertically.
|
|
31473
|
-
* coordDim: string mandatory,
|
|
31474
|
-
* coordDimIndex: number mandatory,
|
|
31475
|
-
* type: string optional,
|
|
31476
|
-
* otherDims: { never null/undefined
|
|
31477
|
-
* tooltip: number optional,
|
|
31478
|
-
* label: number optional,
|
|
31479
|
-
* itemName: number optional,
|
|
31480
|
-
* seriesName: number optional,
|
|
31481
|
-
* },
|
|
31482
|
-
* isExtraCoord: boolean true if coord is generated
|
|
31483
|
-
* (not specified in encode and not series specified)
|
|
31484
|
-
* other props ...
|
|
31485
|
-
* }]
|
|
31902
|
+
* @return {Array.<module:data/DataDimensionInfo>}
|
|
31486
31903
|
*/
|
|
31487
31904
|
function completeDimensions(sysDims, source, opt) {
|
|
31488
31905
|
if (!Source.isInstance(source)) {
|
|
@@ -31492,7 +31909,6 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31492
31909
|
opt = opt || {};
|
|
31493
31910
|
sysDims = (sysDims || []).slice();
|
|
31494
31911
|
var dimsDef = (opt.dimsDef || []).slice();
|
|
31495
|
-
var encodeDef = createHashMap(opt.encodeDef);
|
|
31496
31912
|
var dataDimNameMap = createHashMap();
|
|
31497
31913
|
var coordDimNameMap = createHashMap();
|
|
31498
31914
|
// var valueCandidate;
|
|
@@ -31506,7 +31922,7 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31506
31922
|
{}, isObject$1(dimsDef[i]) ? dimsDef[i] : {name: dimsDef[i]}
|
|
31507
31923
|
);
|
|
31508
31924
|
var userDimName = dimDefItem.name;
|
|
31509
|
-
var resultItem = result[i] =
|
|
31925
|
+
var resultItem = result[i] = new DataDimensionInfo();
|
|
31510
31926
|
// Name will be applied later for avoiding duplication.
|
|
31511
31927
|
if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
|
|
31512
31928
|
// Only if `series.dimensions` is defined in option
|
|
@@ -31519,6 +31935,12 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31519
31935
|
dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
|
|
31520
31936
|
}
|
|
31521
31937
|
|
|
31938
|
+
var encodeDef = opt.encodeDef;
|
|
31939
|
+
if (!encodeDef && opt.encodeDefaulter) {
|
|
31940
|
+
encodeDef = opt.encodeDefaulter(source, dimCount);
|
|
31941
|
+
}
|
|
31942
|
+
encodeDef = createHashMap(encodeDef);
|
|
31943
|
+
|
|
31522
31944
|
// Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
|
|
31523
31945
|
encodeDef.each(function (dataDims, coordDim) {
|
|
31524
31946
|
dataDims = normalizeToArray(dataDims).slice();
|
|
@@ -31620,7 +32042,7 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31620
32042
|
|
|
31621
32043
|
// Set dim `name` and other `coordDim` and other props.
|
|
31622
32044
|
for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
|
|
31623
|
-
var resultItem = result[resultDimIdx] = result[resultDimIdx] ||
|
|
32045
|
+
var resultItem = result[resultDimIdx] = result[resultDimIdx] || new DataDimensionInfo();
|
|
31624
32046
|
var coordDim = resultItem.coordDim;
|
|
31625
32047
|
|
|
31626
32048
|
if (coordDim == null) {
|
|
@@ -31639,7 +32061,28 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31639
32061
|
dataDimNameMap
|
|
31640
32062
|
));
|
|
31641
32063
|
|
|
31642
|
-
if (resultItem.type == null
|
|
32064
|
+
if (resultItem.type == null
|
|
32065
|
+
&& (
|
|
32066
|
+
guessOrdinal(source, resultDimIdx, resultItem.name) === BE_ORDINAL.Must
|
|
32067
|
+
// Consider the case:
|
|
32068
|
+
// {
|
|
32069
|
+
// dataset: {source: [
|
|
32070
|
+
// ['2001', 123],
|
|
32071
|
+
// ['2002', 456],
|
|
32072
|
+
// ...
|
|
32073
|
+
// ['The others', 987],
|
|
32074
|
+
// ]},
|
|
32075
|
+
// series: {type: 'pie'}
|
|
32076
|
+
// }
|
|
32077
|
+
// The first colum should better be treated as a "ordinal" although it
|
|
32078
|
+
// might not able to be detected as an "ordinal" by `guessOrdinal`.
|
|
32079
|
+
|| (resultItem.isExtraCoord
|
|
32080
|
+
&& (resultItem.otherDims.itemName != null
|
|
32081
|
+
|| resultItem.otherDims.seriesName != null
|
|
32082
|
+
)
|
|
32083
|
+
)
|
|
32084
|
+
)
|
|
32085
|
+
) {
|
|
31643
32086
|
resultItem.type = 'ordinal';
|
|
31644
32087
|
}
|
|
31645
32088
|
}
|
|
@@ -31717,6 +32160,7 @@ function genName(name, map$$1, fromZero) {
|
|
|
31717
32160
|
* @param {string} [opt.generateCoordCount]
|
|
31718
32161
|
* @param {Array.<string|Object>} [opt.dimensionsDefine=source.dimensionsDefine] Overwrite source define.
|
|
31719
32162
|
* @param {Object|HashMap} [opt.encodeDefine=source.encodeDefine] Overwrite source define.
|
|
32163
|
+
* @param {Function} [opt.encodeDefaulter] Make default encode if user not specified.
|
|
31720
32164
|
* @return {Array.<Object>} dimensionsInfo
|
|
31721
32165
|
*/
|
|
31722
32166
|
var createDimensions = function (source, opt) {
|
|
@@ -31725,6 +32169,7 @@ var createDimensions = function (source, opt) {
|
|
|
31725
32169
|
dimsDef: opt.dimensionsDefine || source.dimensionsDefine,
|
|
31726
32170
|
encodeDef: opt.encodeDefine || source.encodeDefine,
|
|
31727
32171
|
dimCount: opt.dimensionsCount,
|
|
32172
|
+
encodeDefaulter: opt.encodeDefaulter,
|
|
31728
32173
|
generateCoord: opt.generateCoord,
|
|
31729
32174
|
generateCoordCount: opt.generateCoordCount
|
|
31730
32175
|
});
|
|
@@ -31749,6 +32194,201 @@ var createDimensions = function (source, opt) {
|
|
|
31749
32194
|
* under the License.
|
|
31750
32195
|
*/
|
|
31751
32196
|
|
|
32197
|
+
/**
|
|
32198
|
+
* Helper for model references.
|
|
32199
|
+
* There are many manners to refer axis/coordSys.
|
|
32200
|
+
*/
|
|
32201
|
+
|
|
32202
|
+
// TODO
|
|
32203
|
+
// merge relevant logic to this file?
|
|
32204
|
+
// check: "modelHelper" of tooltip and "BrushTargetManager".
|
|
32205
|
+
|
|
32206
|
+
/**
|
|
32207
|
+
* @class
|
|
32208
|
+
* For example:
|
|
32209
|
+
* {
|
|
32210
|
+
* coordSysName: 'cartesian2d',
|
|
32211
|
+
* coordSysDims: ['x', 'y', ...],
|
|
32212
|
+
* axisMap: HashMap({
|
|
32213
|
+
* x: xAxisModel,
|
|
32214
|
+
* y: yAxisModel
|
|
32215
|
+
* }),
|
|
32216
|
+
* categoryAxisMap: HashMap({
|
|
32217
|
+
* x: xAxisModel,
|
|
32218
|
+
* y: undefined
|
|
32219
|
+
* }),
|
|
32220
|
+
* // The index of the first category axis in `coordSysDims`.
|
|
32221
|
+
* // `null/undefined` means no category axis exists.
|
|
32222
|
+
* firstCategoryDimIndex: 1,
|
|
32223
|
+
* // To replace user specified encode.
|
|
32224
|
+
* }
|
|
32225
|
+
*/
|
|
32226
|
+
function CoordSysInfo(coordSysName) {
|
|
32227
|
+
/**
|
|
32228
|
+
* @type {string}
|
|
32229
|
+
*/
|
|
32230
|
+
this.coordSysName = coordSysName;
|
|
32231
|
+
/**
|
|
32232
|
+
* @type {Array.<string>}
|
|
32233
|
+
*/
|
|
32234
|
+
this.coordSysDims = [];
|
|
32235
|
+
/**
|
|
32236
|
+
* @type {module:zrender/core/util#HashMap}
|
|
32237
|
+
*/
|
|
32238
|
+
this.axisMap = createHashMap();
|
|
32239
|
+
/**
|
|
32240
|
+
* @type {module:zrender/core/util#HashMap}
|
|
32241
|
+
*/
|
|
32242
|
+
this.categoryAxisMap = createHashMap();
|
|
32243
|
+
/**
|
|
32244
|
+
* @type {number}
|
|
32245
|
+
*/
|
|
32246
|
+
this.firstCategoryDimIndex = null;
|
|
32247
|
+
}
|
|
32248
|
+
|
|
32249
|
+
/**
|
|
32250
|
+
* @return {module:model/referHelper#CoordSysInfo}
|
|
32251
|
+
*/
|
|
32252
|
+
function getCoordSysInfoBySeries(seriesModel) {
|
|
32253
|
+
var coordSysName = seriesModel.get('coordinateSystem');
|
|
32254
|
+
var result = new CoordSysInfo(coordSysName);
|
|
32255
|
+
var fetch = fetchers[coordSysName];
|
|
32256
|
+
if (fetch) {
|
|
32257
|
+
fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
|
|
32258
|
+
return result;
|
|
32259
|
+
}
|
|
32260
|
+
}
|
|
32261
|
+
|
|
32262
|
+
var fetchers = {
|
|
32263
|
+
|
|
32264
|
+
cartesian2d: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
32265
|
+
var xAxisModel = seriesModel.getReferringComponents('xAxis')[0];
|
|
32266
|
+
var yAxisModel = seriesModel.getReferringComponents('yAxis')[0];
|
|
32267
|
+
|
|
32268
|
+
if (__DEV__) {
|
|
32269
|
+
if (!xAxisModel) {
|
|
32270
|
+
throw new Error('xAxis "' + retrieve(
|
|
32271
|
+
seriesModel.get('xAxisIndex'),
|
|
32272
|
+
seriesModel.get('xAxisId'),
|
|
32273
|
+
0
|
|
32274
|
+
) + '" not found');
|
|
32275
|
+
}
|
|
32276
|
+
if (!yAxisModel) {
|
|
32277
|
+
throw new Error('yAxis "' + retrieve(
|
|
32278
|
+
seriesModel.get('xAxisIndex'),
|
|
32279
|
+
seriesModel.get('yAxisId'),
|
|
32280
|
+
0
|
|
32281
|
+
) + '" not found');
|
|
32282
|
+
}
|
|
32283
|
+
}
|
|
32284
|
+
|
|
32285
|
+
result.coordSysDims = ['x', 'y'];
|
|
32286
|
+
axisMap.set('x', xAxisModel);
|
|
32287
|
+
axisMap.set('y', yAxisModel);
|
|
32288
|
+
|
|
32289
|
+
if (isCategory(xAxisModel)) {
|
|
32290
|
+
categoryAxisMap.set('x', xAxisModel);
|
|
32291
|
+
result.firstCategoryDimIndex = 0;
|
|
32292
|
+
}
|
|
32293
|
+
if (isCategory(yAxisModel)) {
|
|
32294
|
+
categoryAxisMap.set('y', yAxisModel);
|
|
32295
|
+
result.firstCategoryDimIndex == null & (result.firstCategoryDimIndex = 1);
|
|
32296
|
+
}
|
|
32297
|
+
},
|
|
32298
|
+
|
|
32299
|
+
singleAxis: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
32300
|
+
var singleAxisModel = seriesModel.getReferringComponents('singleAxis')[0];
|
|
32301
|
+
|
|
32302
|
+
if (__DEV__) {
|
|
32303
|
+
if (!singleAxisModel) {
|
|
32304
|
+
throw new Error('singleAxis should be specified.');
|
|
32305
|
+
}
|
|
32306
|
+
}
|
|
32307
|
+
|
|
32308
|
+
result.coordSysDims = ['single'];
|
|
32309
|
+
axisMap.set('single', singleAxisModel);
|
|
32310
|
+
|
|
32311
|
+
if (isCategory(singleAxisModel)) {
|
|
32312
|
+
categoryAxisMap.set('single', singleAxisModel);
|
|
32313
|
+
result.firstCategoryDimIndex = 0;
|
|
32314
|
+
}
|
|
32315
|
+
},
|
|
32316
|
+
|
|
32317
|
+
polar: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
32318
|
+
var polarModel = seriesModel.getReferringComponents('polar')[0];
|
|
32319
|
+
var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
|
|
32320
|
+
var angleAxisModel = polarModel.findAxisModel('angleAxis');
|
|
32321
|
+
|
|
32322
|
+
if (__DEV__) {
|
|
32323
|
+
if (!angleAxisModel) {
|
|
32324
|
+
throw new Error('angleAxis option not found');
|
|
32325
|
+
}
|
|
32326
|
+
if (!radiusAxisModel) {
|
|
32327
|
+
throw new Error('radiusAxis option not found');
|
|
32328
|
+
}
|
|
32329
|
+
}
|
|
32330
|
+
|
|
32331
|
+
result.coordSysDims = ['radius', 'angle'];
|
|
32332
|
+
axisMap.set('radius', radiusAxisModel);
|
|
32333
|
+
axisMap.set('angle', angleAxisModel);
|
|
32334
|
+
|
|
32335
|
+
if (isCategory(radiusAxisModel)) {
|
|
32336
|
+
categoryAxisMap.set('radius', radiusAxisModel);
|
|
32337
|
+
result.firstCategoryDimIndex = 0;
|
|
32338
|
+
}
|
|
32339
|
+
if (isCategory(angleAxisModel)) {
|
|
32340
|
+
categoryAxisMap.set('angle', angleAxisModel);
|
|
32341
|
+
result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
|
|
32342
|
+
}
|
|
32343
|
+
},
|
|
32344
|
+
|
|
32345
|
+
geo: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
32346
|
+
result.coordSysDims = ['lng', 'lat'];
|
|
32347
|
+
},
|
|
32348
|
+
|
|
32349
|
+
parallel: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
32350
|
+
var ecModel = seriesModel.ecModel;
|
|
32351
|
+
var parallelModel = ecModel.getComponent(
|
|
32352
|
+
'parallel', seriesModel.get('parallelIndex')
|
|
32353
|
+
);
|
|
32354
|
+
var coordSysDims = result.coordSysDims = parallelModel.dimensions.slice();
|
|
32355
|
+
|
|
32356
|
+
each$1(parallelModel.parallelAxisIndex, function (axisIndex, index) {
|
|
32357
|
+
var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
|
|
32358
|
+
var axisDim = coordSysDims[index];
|
|
32359
|
+
axisMap.set(axisDim, axisModel);
|
|
32360
|
+
|
|
32361
|
+
if (isCategory(axisModel) && result.firstCategoryDimIndex == null) {
|
|
32362
|
+
categoryAxisMap.set(axisDim, axisModel);
|
|
32363
|
+
result.firstCategoryDimIndex = index;
|
|
32364
|
+
}
|
|
32365
|
+
});
|
|
32366
|
+
}
|
|
32367
|
+
};
|
|
32368
|
+
|
|
32369
|
+
function isCategory(axisModel) {
|
|
32370
|
+
return axisModel.get('type') === 'category';
|
|
32371
|
+
}
|
|
32372
|
+
|
|
32373
|
+
/*
|
|
32374
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
32375
|
+
* or more contributor license agreements. See the NOTICE file
|
|
32376
|
+
* distributed with this work for additional information
|
|
32377
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
32378
|
+
* to you under the Apache License, Version 2.0 (the
|
|
32379
|
+
* "License"); you may not use this file except in compliance
|
|
32380
|
+
* with the License. You may obtain a copy of the License at
|
|
32381
|
+
*
|
|
32382
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
32383
|
+
*
|
|
32384
|
+
* Unless required by applicable law or agreed to in writing,
|
|
32385
|
+
* software distributed under the License is distributed on an
|
|
32386
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
32387
|
+
* KIND, either express or implied. See the License for the
|
|
32388
|
+
* specific language governing permissions and limitations
|
|
32389
|
+
* under the License.
|
|
32390
|
+
*/
|
|
32391
|
+
|
|
31752
32392
|
/**
|
|
31753
32393
|
* Note that it is too complicated to support 3d stack by value
|
|
31754
32394
|
* (have to create two-dimension inverted index), so in 3d case
|
|
@@ -31915,6 +32555,7 @@ function getStackedDimension(data, targetDim) {
|
|
|
31915
32555
|
* @param {module:echarts/model/Series} seriesModel
|
|
31916
32556
|
* @param {Object} [opt]
|
|
31917
32557
|
* @param {string} [opt.generateCoord]
|
|
32558
|
+
* @param {boolean} [opt.useEncodeDefaulter]
|
|
31918
32559
|
*/
|
|
31919
32560
|
function createListFromArray(source, seriesModel, opt) {
|
|
31920
32561
|
opt = opt || {};
|
|
@@ -31926,14 +32567,14 @@ function createListFromArray(source, seriesModel, opt) {
|
|
|
31926
32567
|
var coordSysName = seriesModel.get('coordinateSystem');
|
|
31927
32568
|
var registeredCoordSys = CoordinateSystemManager.get(coordSysName);
|
|
31928
32569
|
|
|
31929
|
-
var
|
|
32570
|
+
var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
|
|
31930
32571
|
|
|
31931
32572
|
var coordSysDimDefs;
|
|
31932
32573
|
|
|
31933
|
-
if (
|
|
31934
|
-
coordSysDimDefs = map(
|
|
32574
|
+
if (coordSysInfo) {
|
|
32575
|
+
coordSysDimDefs = map(coordSysInfo.coordSysDims, function (dim) {
|
|
31935
32576
|
var dimInfo = {name: dim};
|
|
31936
|
-
var axisModel =
|
|
32577
|
+
var axisModel = coordSysInfo.axisMap.get(dim);
|
|
31937
32578
|
if (axisModel) {
|
|
31938
32579
|
var axisType = axisModel.get('type');
|
|
31939
32580
|
dimInfo.type = getDimensionTypeByAxis(axisType);
|
|
@@ -31954,14 +32595,17 @@ function createListFromArray(source, seriesModel, opt) {
|
|
|
31954
32595
|
|
|
31955
32596
|
var dimInfoList = createDimensions(source, {
|
|
31956
32597
|
coordDimensions: coordSysDimDefs,
|
|
31957
|
-
generateCoord: opt.generateCoord
|
|
32598
|
+
generateCoord: opt.generateCoord,
|
|
32599
|
+
encodeDefaulter: opt.useEncodeDefaulter
|
|
32600
|
+
? curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel)
|
|
32601
|
+
: null
|
|
31958
32602
|
});
|
|
31959
32603
|
|
|
31960
32604
|
var firstCategoryDimIndex;
|
|
31961
32605
|
var hasNameEncode;
|
|
31962
|
-
|
|
32606
|
+
coordSysInfo && each$1(dimInfoList, function (dimInfo, dimIndex) {
|
|
31963
32607
|
var coordDim = dimInfo.coordDim;
|
|
31964
|
-
var categoryAxisModel =
|
|
32608
|
+
var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
|
|
31965
32609
|
if (categoryAxisModel) {
|
|
31966
32610
|
if (firstCategoryDimIndex == null) {
|
|
31967
32611
|
firstCategoryDimIndex = dimIndex;
|
|
@@ -32045,7 +32689,7 @@ SeriesModel.extend({
|
|
|
32045
32689
|
throw new Error('Line not support coordinateSystem besides cartesian and polar');
|
|
32046
32690
|
}
|
|
32047
32691
|
}
|
|
32048
|
-
return createListFromArray(this.getSource(), this);
|
|
32692
|
+
return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
|
|
32049
32693
|
},
|
|
32050
32694
|
|
|
32051
32695
|
defaultOption: {
|
|
@@ -32756,6 +33400,15 @@ symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
|
|
|
32756
33400
|
strokeNoScale: true
|
|
32757
33401
|
});
|
|
32758
33402
|
}
|
|
33403
|
+
else {
|
|
33404
|
+
symbolPath.setStyle({
|
|
33405
|
+
opacity: null,
|
|
33406
|
+
shadowBlur: null,
|
|
33407
|
+
shadowOffsetX: null,
|
|
33408
|
+
shadowOffsetY: null,
|
|
33409
|
+
shadowColor: null
|
|
33410
|
+
});
|
|
33411
|
+
}
|
|
32759
33412
|
|
|
32760
33413
|
var itemStyle = seriesScope && seriesScope.itemStyle;
|
|
32761
33414
|
var hoverItemStyle = seriesScope && seriesScope.hoverItemStyle;
|
|
@@ -34250,7 +34903,7 @@ Chart.extend({
|
|
|
34250
34903
|
// FIXME step not support polar
|
|
34251
34904
|
var step = !isCoordSysPolar && seriesModel.get('step');
|
|
34252
34905
|
var clipShapeForSymbol;
|
|
34253
|
-
if (coordSys && coordSys.getArea) {
|
|
34906
|
+
if (coordSys && coordSys.getArea && seriesModel.get('clip', true)) {
|
|
34254
34907
|
clipShapeForSymbol = coordSys.getArea();
|
|
34255
34908
|
// Avoid float number rounding error for symbol on the edge of axis extent.
|
|
34256
34909
|
// See #7913 and `test/dataZoom-clip.html`.
|
|
@@ -34265,6 +34918,7 @@ Chart.extend({
|
|
|
34265
34918
|
clipShapeForSymbol.r1 += 0.5;
|
|
34266
34919
|
}
|
|
34267
34920
|
}
|
|
34921
|
+
this._clipShapeForSymbol = clipShapeForSymbol;
|
|
34268
34922
|
// Initialization animation or coordinate system changed
|
|
34269
34923
|
if (
|
|
34270
34924
|
!(polyline && prevCoordSys.type === coordSys.type && step === this._step)
|
|
@@ -34417,6 +35071,10 @@ Chart.extend({
|
|
|
34417
35071
|
// Null data
|
|
34418
35072
|
return;
|
|
34419
35073
|
}
|
|
35074
|
+
// fix #11360: should't draw symbol outside clipShapeForSymbol
|
|
35075
|
+
if (this._clipShapeForSymbol && !this._clipShapeForSymbol.contain(pt[0], pt[1])) {
|
|
35076
|
+
return;
|
|
35077
|
+
}
|
|
34420
35078
|
symbol = new SymbolClz(data, dataIndex);
|
|
34421
35079
|
symbol.position = pt;
|
|
34422
35080
|
symbol.setZ(
|
|
@@ -35422,44 +36080,6 @@ function fixExtent(niceTickExtent, extent) {
|
|
|
35422
36080
|
}
|
|
35423
36081
|
}
|
|
35424
36082
|
|
|
35425
|
-
function intervalScaleGetTicks(interval, extent, niceTickExtent, intervalPrecision) {
|
|
35426
|
-
var ticks = [];
|
|
35427
|
-
|
|
35428
|
-
// If interval is 0, return [];
|
|
35429
|
-
if (!interval) {
|
|
35430
|
-
return ticks;
|
|
35431
|
-
}
|
|
35432
|
-
|
|
35433
|
-
// Consider this case: using dataZoom toolbox, zoom and zoom.
|
|
35434
|
-
var safeLimit = 10000;
|
|
35435
|
-
|
|
35436
|
-
if (extent[0] < niceTickExtent[0]) {
|
|
35437
|
-
ticks.push(extent[0]);
|
|
35438
|
-
}
|
|
35439
|
-
var tick = niceTickExtent[0];
|
|
35440
|
-
|
|
35441
|
-
while (tick <= niceTickExtent[1]) {
|
|
35442
|
-
ticks.push(tick);
|
|
35443
|
-
// Avoid rounding error
|
|
35444
|
-
tick = roundNumber$1(tick + interval, intervalPrecision);
|
|
35445
|
-
if (tick === ticks[ticks.length - 1]) {
|
|
35446
|
-
// Consider out of safe float point, e.g.,
|
|
35447
|
-
// -3711126.9907707 + 2e-10 === -3711126.9907707
|
|
35448
|
-
break;
|
|
35449
|
-
}
|
|
35450
|
-
if (ticks.length > safeLimit) {
|
|
35451
|
-
return [];
|
|
35452
|
-
}
|
|
35453
|
-
}
|
|
35454
|
-
// Consider this case: the last item of ticks is smaller
|
|
35455
|
-
// than niceTickExtent[1] and niceTickExtent[1] === extent[1].
|
|
35456
|
-
if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1])) {
|
|
35457
|
-
ticks.push(extent[1]);
|
|
35458
|
-
}
|
|
35459
|
-
|
|
35460
|
-
return ticks;
|
|
35461
|
-
}
|
|
35462
|
-
|
|
35463
36083
|
/*
|
|
35464
36084
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
35465
36085
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -35538,12 +36158,92 @@ var IntervalScale = Scale.extend({
|
|
|
35538
36158
|
},
|
|
35539
36159
|
|
|
35540
36160
|
/**
|
|
36161
|
+
* @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
|
|
35541
36162
|
* @return {Array.<number>}
|
|
35542
36163
|
*/
|
|
35543
|
-
getTicks: function () {
|
|
35544
|
-
|
|
35545
|
-
|
|
35546
|
-
|
|
36164
|
+
getTicks: function (expandToNicedExtent) {
|
|
36165
|
+
var interval = this._interval;
|
|
36166
|
+
var extent = this._extent;
|
|
36167
|
+
var niceTickExtent = this._niceExtent;
|
|
36168
|
+
var intervalPrecision = this._intervalPrecision;
|
|
36169
|
+
|
|
36170
|
+
var ticks = [];
|
|
36171
|
+
// If interval is 0, return [];
|
|
36172
|
+
if (!interval) {
|
|
36173
|
+
return ticks;
|
|
36174
|
+
}
|
|
36175
|
+
|
|
36176
|
+
// Consider this case: using dataZoom toolbox, zoom and zoom.
|
|
36177
|
+
var safeLimit = 10000;
|
|
36178
|
+
|
|
36179
|
+
if (extent[0] < niceTickExtent[0]) {
|
|
36180
|
+
if (expandToNicedExtent) {
|
|
36181
|
+
ticks.push(roundNumber(niceTickExtent[0] - interval));
|
|
36182
|
+
}
|
|
36183
|
+
else {
|
|
36184
|
+
ticks.push(extent[0]);
|
|
36185
|
+
}
|
|
36186
|
+
}
|
|
36187
|
+
var tick = niceTickExtent[0];
|
|
36188
|
+
|
|
36189
|
+
while (tick <= niceTickExtent[1]) {
|
|
36190
|
+
ticks.push(tick);
|
|
36191
|
+
// Avoid rounding error
|
|
36192
|
+
tick = roundNumber(tick + interval, intervalPrecision);
|
|
36193
|
+
if (tick === ticks[ticks.length - 1]) {
|
|
36194
|
+
// Consider out of safe float point, e.g.,
|
|
36195
|
+
// -3711126.9907707 + 2e-10 === -3711126.9907707
|
|
36196
|
+
break;
|
|
36197
|
+
}
|
|
36198
|
+
if (ticks.length > safeLimit) {
|
|
36199
|
+
return [];
|
|
36200
|
+
}
|
|
36201
|
+
}
|
|
36202
|
+
// Consider this case: the last item of ticks is smaller
|
|
36203
|
+
// than niceTickExtent[1] and niceTickExtent[1] === extent[1].
|
|
36204
|
+
var lastNiceTick = ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1];
|
|
36205
|
+
if (extent[1] > lastNiceTick) {
|
|
36206
|
+
if (expandToNicedExtent) {
|
|
36207
|
+
ticks.push(lastNiceTick + interval);
|
|
36208
|
+
}
|
|
36209
|
+
else {
|
|
36210
|
+
ticks.push(extent[1]);
|
|
36211
|
+
}
|
|
36212
|
+
}
|
|
36213
|
+
|
|
36214
|
+
return ticks;
|
|
36215
|
+
},
|
|
36216
|
+
|
|
36217
|
+
/**
|
|
36218
|
+
* @param {number} [splitNumber=5]
|
|
36219
|
+
* @return {Array.<Array.<number>>}
|
|
36220
|
+
*/
|
|
36221
|
+
getMinorTicks: function (splitNumber) {
|
|
36222
|
+
var ticks = this.getTicks(true);
|
|
36223
|
+
var minorTicks = [];
|
|
36224
|
+
var extent = this.getExtent();
|
|
36225
|
+
|
|
36226
|
+
for (var i = 1; i < ticks.length; i++) {
|
|
36227
|
+
var nextTick = ticks[i];
|
|
36228
|
+
var prevTick = ticks[i - 1];
|
|
36229
|
+
var count = 0;
|
|
36230
|
+
var minorTicksGroup = [];
|
|
36231
|
+
var interval = nextTick - prevTick;
|
|
36232
|
+
var minorInterval = interval / splitNumber;
|
|
36233
|
+
|
|
36234
|
+
while (count < splitNumber - 1) {
|
|
36235
|
+
var minorTick = round$1(prevTick + (count + 1) * minorInterval);
|
|
36236
|
+
|
|
36237
|
+
// For the first and last interval. The count may be less than splitNumber.
|
|
36238
|
+
if (minorTick > extent[0] && minorTick < extent[1]) {
|
|
36239
|
+
minorTicksGroup.push(minorTick);
|
|
36240
|
+
}
|
|
36241
|
+
count++;
|
|
36242
|
+
}
|
|
36243
|
+
minorTicks.push(minorTicksGroup);
|
|
36244
|
+
}
|
|
36245
|
+
|
|
36246
|
+
return minorTicks;
|
|
35547
36247
|
},
|
|
35548
36248
|
|
|
35549
36249
|
/**
|
|
@@ -35706,6 +36406,7 @@ function getAxisKey(axis) {
|
|
|
35706
36406
|
* @param {number} opt.count Positive interger.
|
|
35707
36407
|
* @param {number} [opt.barWidth]
|
|
35708
36408
|
* @param {number} [opt.barMaxWidth]
|
|
36409
|
+
* @param {number} [opt.barMinWidth]
|
|
35709
36410
|
* @param {number} [opt.barGap]
|
|
35710
36411
|
* @param {number} [opt.barCategoryGap]
|
|
35711
36412
|
* @return {Object} {width, offset, offsetCenter} If axis.type is not 'category', return undefined.
|
|
@@ -35723,16 +36424,101 @@ function prepareLayoutBarSeries(seriesType, ecModel) {
|
|
|
35723
36424
|
return seriesModels;
|
|
35724
36425
|
}
|
|
35725
36426
|
|
|
36427
|
+
|
|
36428
|
+
/**
|
|
36429
|
+
* Map from (baseAxis.dim + '_' + baseAxis.index) to min gap of two adjacent
|
|
36430
|
+
* values.
|
|
36431
|
+
* This works for time axes, value axes, and log axes.
|
|
36432
|
+
* For a single time axis, return value is in the form like
|
|
36433
|
+
* {'x_0': [1000000]}.
|
|
36434
|
+
* The value of 1000000 is in milliseconds.
|
|
36435
|
+
*/
|
|
36436
|
+
function getValueAxesMinGaps(barSeries) {
|
|
36437
|
+
/**
|
|
36438
|
+
* Map from axis.index to values.
|
|
36439
|
+
* For a single time axis, axisValues is in the form like
|
|
36440
|
+
* {'x_0': [1495555200000, 1495641600000, 1495728000000]}.
|
|
36441
|
+
* Items in axisValues[x], e.g. 1495555200000, are time values of all
|
|
36442
|
+
* series.
|
|
36443
|
+
*/
|
|
36444
|
+
var axisValues = {};
|
|
36445
|
+
each$1(barSeries, function (seriesModel) {
|
|
36446
|
+
var cartesian = seriesModel.coordinateSystem;
|
|
36447
|
+
var baseAxis = cartesian.getBaseAxis();
|
|
36448
|
+
if (baseAxis.type !== 'time' && baseAxis.type !== 'value') {
|
|
36449
|
+
return;
|
|
36450
|
+
}
|
|
36451
|
+
|
|
36452
|
+
var data = seriesModel.getData();
|
|
36453
|
+
var key = baseAxis.dim + '_' + baseAxis.index;
|
|
36454
|
+
var dim = data.mapDimension(baseAxis.dim);
|
|
36455
|
+
for (var i = 0, cnt = data.count(); i < cnt; ++i) {
|
|
36456
|
+
var value = data.get(dim, i);
|
|
36457
|
+
if (!axisValues[key]) {
|
|
36458
|
+
// No previous data for the axis
|
|
36459
|
+
axisValues[key] = [value];
|
|
36460
|
+
}
|
|
36461
|
+
else {
|
|
36462
|
+
// No value in previous series
|
|
36463
|
+
axisValues[key].push(value);
|
|
36464
|
+
}
|
|
36465
|
+
// Ignore duplicated time values in the same axis
|
|
36466
|
+
}
|
|
36467
|
+
});
|
|
36468
|
+
|
|
36469
|
+
var axisMinGaps = [];
|
|
36470
|
+
for (var key in axisValues) {
|
|
36471
|
+
if (axisValues.hasOwnProperty(key)) {
|
|
36472
|
+
var valuesInAxis = axisValues[key];
|
|
36473
|
+
if (valuesInAxis) {
|
|
36474
|
+
// Sort axis values into ascending order to calculate gaps
|
|
36475
|
+
valuesInAxis.sort(function (a, b) {
|
|
36476
|
+
return a - b;
|
|
36477
|
+
});
|
|
36478
|
+
|
|
36479
|
+
var min = null;
|
|
36480
|
+
for (var j = 1; j < valuesInAxis.length; ++j) {
|
|
36481
|
+
var delta = valuesInAxis[j] - valuesInAxis[j - 1];
|
|
36482
|
+
if (delta > 0) {
|
|
36483
|
+
// Ignore 0 delta because they are of the same axis value
|
|
36484
|
+
min = min === null ? delta : Math.min(min, delta);
|
|
36485
|
+
}
|
|
36486
|
+
}
|
|
36487
|
+
// Set to null if only have one data
|
|
36488
|
+
axisMinGaps[key] = min;
|
|
36489
|
+
}
|
|
36490
|
+
}
|
|
36491
|
+
}
|
|
36492
|
+
return axisMinGaps;
|
|
36493
|
+
}
|
|
36494
|
+
|
|
35726
36495
|
function makeColumnLayout(barSeries) {
|
|
36496
|
+
var axisMinGaps = getValueAxesMinGaps(barSeries);
|
|
36497
|
+
|
|
35727
36498
|
var seriesInfoList = [];
|
|
35728
36499
|
each$1(barSeries, function (seriesModel) {
|
|
35729
|
-
var data = seriesModel.getData();
|
|
35730
36500
|
var cartesian = seriesModel.coordinateSystem;
|
|
35731
36501
|
var baseAxis = cartesian.getBaseAxis();
|
|
35732
36502
|
var axisExtent = baseAxis.getExtent();
|
|
35733
|
-
|
|
35734
|
-
|
|
35735
|
-
|
|
36503
|
+
|
|
36504
|
+
var bandWidth;
|
|
36505
|
+
if (baseAxis.type === 'category') {
|
|
36506
|
+
bandWidth = baseAxis.getBandWidth();
|
|
36507
|
+
}
|
|
36508
|
+
else if (baseAxis.type === 'value' || baseAxis.type === 'time') {
|
|
36509
|
+
var key = baseAxis.dim + '_' + baseAxis.index;
|
|
36510
|
+
var minGap = axisMinGaps[key];
|
|
36511
|
+
var extentSpan = Math.abs(axisExtent[1] - axisExtent[0]);
|
|
36512
|
+
var scale = baseAxis.scale.getExtent();
|
|
36513
|
+
var scaleSpan = Math.abs(scale[1] - scale[0]);
|
|
36514
|
+
bandWidth = minGap
|
|
36515
|
+
? extentSpan / scaleSpan * minGap
|
|
36516
|
+
: extentSpan; // When there is only one data value
|
|
36517
|
+
}
|
|
36518
|
+
else {
|
|
36519
|
+
var data = seriesModel.getData();
|
|
36520
|
+
bandWidth = Math.abs(axisExtent[1] - axisExtent[0]) / data.count();
|
|
36521
|
+
}
|
|
35736
36522
|
|
|
35737
36523
|
var barWidth = parsePercent$1(
|
|
35738
36524
|
seriesModel.get('barWidth'), bandWidth
|
|
@@ -35740,6 +36526,11 @@ function makeColumnLayout(barSeries) {
|
|
|
35740
36526
|
var barMaxWidth = parsePercent$1(
|
|
35741
36527
|
seriesModel.get('barMaxWidth'), bandWidth
|
|
35742
36528
|
);
|
|
36529
|
+
var barMinWidth = parsePercent$1(
|
|
36530
|
+
// barMinWidth by default is 1 in cartesian. Because in value axis,
|
|
36531
|
+
// the auto-calculated bar width might be less than 1.
|
|
36532
|
+
seriesModel.get('barMinWidth') || 1, bandWidth
|
|
36533
|
+
);
|
|
35743
36534
|
var barGap = seriesModel.get('barGap');
|
|
35744
36535
|
var barCategoryGap = seriesModel.get('barCategoryGap');
|
|
35745
36536
|
|
|
@@ -35747,6 +36538,7 @@ function makeColumnLayout(barSeries) {
|
|
|
35747
36538
|
bandWidth: bandWidth,
|
|
35748
36539
|
barWidth: barWidth,
|
|
35749
36540
|
barMaxWidth: barMaxWidth,
|
|
36541
|
+
barMinWidth: barMinWidth,
|
|
35750
36542
|
barGap: barGap,
|
|
35751
36543
|
barCategoryGap: barCategoryGap,
|
|
35752
36544
|
axisKey: getAxisKey(baseAxis),
|
|
@@ -35790,7 +36582,6 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35790
36582
|
// only the attributes set on the last series will work.
|
|
35791
36583
|
// Do not change this fact unless there will be a break change.
|
|
35792
36584
|
|
|
35793
|
-
// TODO
|
|
35794
36585
|
var barWidth = seriesInfo.barWidth;
|
|
35795
36586
|
if (barWidth && !stacks[stackId].width) {
|
|
35796
36587
|
// See #6312, do not restrict width.
|
|
@@ -35801,6 +36592,8 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35801
36592
|
|
|
35802
36593
|
var barMaxWidth = seriesInfo.barMaxWidth;
|
|
35803
36594
|
barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
|
|
36595
|
+
var barMinWidth = seriesInfo.barMinWidth;
|
|
36596
|
+
barMinWidth && (stacks[stackId].minWidth = barMinWidth);
|
|
35804
36597
|
var barGap = seriesInfo.barGap;
|
|
35805
36598
|
(barGap != null) && (columnsOnAxis.gap = barGap);
|
|
35806
36599
|
var barCategoryGap = seriesInfo.barCategoryGap;
|
|
@@ -35825,15 +36618,43 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35825
36618
|
autoWidth = Math.max(autoWidth, 0);
|
|
35826
36619
|
|
|
35827
36620
|
// Find if any auto calculated bar exceeded maxBarWidth
|
|
35828
|
-
each$1(stacks, function (column
|
|
36621
|
+
each$1(stacks, function (column) {
|
|
35829
36622
|
var maxWidth = column.maxWidth;
|
|
35830
|
-
|
|
35831
|
-
|
|
35832
|
-
|
|
35833
|
-
|
|
36623
|
+
var minWidth = column.minWidth;
|
|
36624
|
+
|
|
36625
|
+
if (!column.width) {
|
|
36626
|
+
var finalWidth = autoWidth;
|
|
36627
|
+
if (maxWidth && maxWidth < finalWidth) {
|
|
36628
|
+
finalWidth = Math.min(maxWidth, remainedWidth);
|
|
36629
|
+
}
|
|
36630
|
+
// `minWidth` has higher priority. `minWidth` decide that wheter the
|
|
36631
|
+
// bar is able to be visible. So `minWidth` should not be restricted
|
|
36632
|
+
// by `maxWidth` or `remainedWidth` (which is from `bandWidth`). In
|
|
36633
|
+
// the extreme cases for `value` axis, bars are allowed to overlap
|
|
36634
|
+
// with each other if `minWidth` specified.
|
|
36635
|
+
if (minWidth && minWidth > finalWidth) {
|
|
36636
|
+
finalWidth = minWidth;
|
|
35834
36637
|
}
|
|
35835
|
-
|
|
35836
|
-
|
|
36638
|
+
if (finalWidth !== autoWidth) {
|
|
36639
|
+
column.width = finalWidth;
|
|
36640
|
+
remainedWidth -= finalWidth + barGapPercent * finalWidth;
|
|
36641
|
+
autoWidthCount--;
|
|
36642
|
+
}
|
|
36643
|
+
}
|
|
36644
|
+
else {
|
|
36645
|
+
// `barMinWidth/barMaxWidth` has higher priority than `barWidth`, as
|
|
36646
|
+
// CSS does. Becuase barWidth can be a percent value, where
|
|
36647
|
+
// `barMaxWidth` can be used to restrict the final width.
|
|
36648
|
+
var finalWidth = column.width;
|
|
36649
|
+
if (maxWidth) {
|
|
36650
|
+
finalWidth = Math.min(finalWidth, maxWidth);
|
|
36651
|
+
}
|
|
36652
|
+
// `minWidth` has higher priority, as described above
|
|
36653
|
+
if (minWidth) {
|
|
36654
|
+
finalWidth = Math.max(finalWidth, minWidth);
|
|
36655
|
+
}
|
|
36656
|
+
column.width = finalWidth;
|
|
36657
|
+
remainedWidth -= finalWidth + barGapPercent * finalWidth;
|
|
35837
36658
|
autoWidthCount--;
|
|
35838
36659
|
}
|
|
35839
36660
|
});
|
|
@@ -35841,8 +36662,10 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35841
36662
|
// Recalculate width again
|
|
35842
36663
|
autoWidth = (remainedWidth - categoryGap)
|
|
35843
36664
|
/ (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
|
|
36665
|
+
|
|
35844
36666
|
autoWidth = Math.max(autoWidth, 0);
|
|
35845
36667
|
|
|
36668
|
+
|
|
35846
36669
|
var widthSum = 0;
|
|
35847
36670
|
var lastColumn;
|
|
35848
36671
|
each$1(stacks, function (column, idx) {
|
|
@@ -36065,7 +36888,7 @@ function isInLargeMode(seriesModel) {
|
|
|
36065
36888
|
|
|
36066
36889
|
// See cases in `test/bar-start.html` and `#7412`, `#8747`.
|
|
36067
36890
|
function getValueAxisStart(baseAxis, valueAxis, stacked) {
|
|
36068
|
-
return valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
|
|
36891
|
+
return valueAxis.toGlobalCoord(valueAxis.dataToCoord(valueAxis.type === 'log' ? 1 : 0));
|
|
36069
36892
|
}
|
|
36070
36893
|
|
|
36071
36894
|
/*
|
|
@@ -36342,14 +37165,15 @@ var LogScale = Scale.extend({
|
|
|
36342
37165
|
},
|
|
36343
37166
|
|
|
36344
37167
|
/**
|
|
37168
|
+
* @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
|
|
36345
37169
|
* @return {Array.<number>}
|
|
36346
37170
|
*/
|
|
36347
|
-
getTicks: function () {
|
|
37171
|
+
getTicks: function (expandToNicedExtent) {
|
|
36348
37172
|
var originalScale = this._originalScale;
|
|
36349
37173
|
var extent = this._extent;
|
|
36350
37174
|
var originalExtent = originalScale.getExtent();
|
|
36351
37175
|
|
|
36352
|
-
return map(intervalScaleProto$1.getTicks.call(this), function (val) {
|
|
37176
|
+
return map(intervalScaleProto$1.getTicks.call(this, expandToNicedExtent), function (val) {
|
|
36353
37177
|
var powVal = round$1(mathPow$1(this.base, val));
|
|
36354
37178
|
|
|
36355
37179
|
// Fix #4158
|
|
@@ -36364,6 +37188,12 @@ var LogScale = Scale.extend({
|
|
|
36364
37188
|
}, this);
|
|
36365
37189
|
},
|
|
36366
37190
|
|
|
37191
|
+
/**
|
|
37192
|
+
* @param {number} splitNumber
|
|
37193
|
+
* @return {Array.<Array.<number>>}
|
|
37194
|
+
*/
|
|
37195
|
+
getMinorTicks: intervalScaleProto$1.getMinorTicks,
|
|
37196
|
+
|
|
36367
37197
|
/**
|
|
36368
37198
|
* @param {number} val
|
|
36369
37199
|
* @return {string}
|
|
@@ -37399,12 +38229,16 @@ function calculateCategoryInterval(axis) {
|
|
|
37399
38229
|
var interval = Math.max(0, Math.floor(Math.min(dw, dh)));
|
|
37400
38230
|
|
|
37401
38231
|
var cache = inner$6(axis.model);
|
|
38232
|
+
var axisExtent = axis.getExtent();
|
|
37402
38233
|
var lastAutoInterval = cache.lastAutoInterval;
|
|
37403
38234
|
var lastTickCount = cache.lastTickCount;
|
|
37404
38235
|
|
|
37405
38236
|
// Use cache to keep interval stable while moving zoom window,
|
|
37406
38237
|
// otherwise the calculated interval might jitter when the zoom
|
|
37407
38238
|
// window size is close to the interval-changing size.
|
|
38239
|
+
// For example, if all of the axis labels are `a, b, c, d, e, f, g`.
|
|
38240
|
+
// The jitter will cause that sometimes the displayed labels are
|
|
38241
|
+
// `a, d, g` (interval: 2) sometimes `a, c, e`(interval: 1).
|
|
37408
38242
|
if (lastAutoInterval != null
|
|
37409
38243
|
&& lastTickCount != null
|
|
37410
38244
|
&& Math.abs(lastAutoInterval - interval) <= 1
|
|
@@ -37412,6 +38246,10 @@ function calculateCategoryInterval(axis) {
|
|
|
37412
38246
|
// Always choose the bigger one, otherwise the critical
|
|
37413
38247
|
// point is not the same when zooming in or zooming out.
|
|
37414
38248
|
&& lastAutoInterval > interval
|
|
38249
|
+
// If the axis change is caused by chart resize, the cache should not
|
|
38250
|
+
// be used. Otherwise some hiden labels might not be shown again.
|
|
38251
|
+
&& cache.axisExtend0 === axisExtent[0]
|
|
38252
|
+
&& cache.axisExtend1 === axisExtent[1]
|
|
37415
38253
|
) {
|
|
37416
38254
|
interval = lastAutoInterval;
|
|
37417
38255
|
}
|
|
@@ -37420,6 +38258,8 @@ function calculateCategoryInterval(axis) {
|
|
|
37420
38258
|
else {
|
|
37421
38259
|
cache.lastTickCount = tickCount;
|
|
37422
38260
|
cache.lastAutoInterval = interval;
|
|
38261
|
+
cache.axisExtend0 = axisExtent[0];
|
|
38262
|
+
cache.axisExtend1 = axisExtent[1];
|
|
37423
38263
|
}
|
|
37424
38264
|
|
|
37425
38265
|
return interval;
|
|
@@ -37599,7 +38439,7 @@ Axis.prototype = {
|
|
|
37599
38439
|
* @return {boolean}
|
|
37600
38440
|
*/
|
|
37601
38441
|
containData: function (data) {
|
|
37602
|
-
return this.contain(
|
|
38442
|
+
return this.scale.contain(data);
|
|
37603
38443
|
},
|
|
37604
38444
|
|
|
37605
38445
|
/**
|
|
@@ -37687,7 +38527,7 @@ Axis.prototype = {
|
|
|
37687
38527
|
* `axis.getTicksCoords` considers `onBand`, which is used by
|
|
37688
38528
|
* `boundaryGap:true` of category axis and splitLine and splitArea.
|
|
37689
38529
|
* @param {Object} [opt]
|
|
37690
|
-
* @param {
|
|
38530
|
+
* @param {Model} [opt.tickModel=axis.model.getModel('axisTick')]
|
|
37691
38531
|
* @param {boolean} [opt.clamp] If `true`, the first and the last
|
|
37692
38532
|
* tick must be at the axis end points. Otherwise, clip ticks
|
|
37693
38533
|
* that outside the axis extent.
|
|
@@ -37700,7 +38540,6 @@ Axis.prototype = {
|
|
|
37700
38540
|
opt = opt || {};
|
|
37701
38541
|
|
|
37702
38542
|
var tickModel = opt.tickModel || this.getTickModel();
|
|
37703
|
-
|
|
37704
38543
|
var result = createAxisTicks(this, tickModel);
|
|
37705
38544
|
var ticks = result.ticks;
|
|
37706
38545
|
|
|
@@ -37712,13 +38551,41 @@ Axis.prototype = {
|
|
|
37712
38551
|
}, this);
|
|
37713
38552
|
|
|
37714
38553
|
var alignWithLabel = tickModel.get('alignWithLabel');
|
|
38554
|
+
|
|
37715
38555
|
fixOnBandTicksCoords(
|
|
37716
|
-
this, ticksCoords,
|
|
38556
|
+
this, ticksCoords, alignWithLabel, opt.clamp
|
|
37717
38557
|
);
|
|
37718
38558
|
|
|
37719
38559
|
return ticksCoords;
|
|
37720
38560
|
},
|
|
37721
38561
|
|
|
38562
|
+
/**
|
|
38563
|
+
* @return {Array.<Array.<Object>>} [{ coord: ..., tickValue: ...}]
|
|
38564
|
+
*/
|
|
38565
|
+
getMinorTicksCoords: function () {
|
|
38566
|
+
if (this.scale.type === 'ordinal') {
|
|
38567
|
+
// Category axis doesn't support minor ticks
|
|
38568
|
+
return [];
|
|
38569
|
+
}
|
|
38570
|
+
|
|
38571
|
+
var minorTickModel = this.model.getModel('minorTick');
|
|
38572
|
+
var splitNumber = minorTickModel.get('splitNumber');
|
|
38573
|
+
// Protection.
|
|
38574
|
+
if (!(splitNumber > 0 && splitNumber < 100)) {
|
|
38575
|
+
splitNumber = 5;
|
|
38576
|
+
}
|
|
38577
|
+
var minorTicks = this.scale.getMinorTicks(splitNumber);
|
|
38578
|
+
var minorTicksCoords = map(minorTicks, function (minorTicksGroup) {
|
|
38579
|
+
return map(minorTicksGroup, function (minorTick) {
|
|
38580
|
+
return {
|
|
38581
|
+
coord: this.dataToCoord(minorTick),
|
|
38582
|
+
tickValue: minorTick
|
|
38583
|
+
};
|
|
38584
|
+
}, this);
|
|
38585
|
+
}, this);
|
|
38586
|
+
return minorTicksCoords;
|
|
38587
|
+
},
|
|
38588
|
+
|
|
37722
38589
|
/**
|
|
37723
38590
|
* @return {Array.<Object>} [{
|
|
37724
38591
|
* formattedLabel: string,
|
|
@@ -37806,7 +38673,7 @@ function fixExtentWithBands(extent, nTick) {
|
|
|
37806
38673
|
// splitLine/spliteArea should layout appropriately corresponding
|
|
37807
38674
|
// to displayed labels. (So we should not use `getBandWidth` in this
|
|
37808
38675
|
// case).
|
|
37809
|
-
function fixOnBandTicksCoords(axis, ticksCoords,
|
|
38676
|
+
function fixOnBandTicksCoords(axis, ticksCoords, alignWithLabel, clamp) {
|
|
37810
38677
|
var ticksLen = ticksCoords.length;
|
|
37811
38678
|
|
|
37812
38679
|
if (!axis.onBand || alignWithLabel || !ticksLen) {
|
|
@@ -37815,26 +38682,30 @@ function fixOnBandTicksCoords(axis, ticksCoords, tickCategoryInterval, alignWith
|
|
|
37815
38682
|
|
|
37816
38683
|
var axisExtent = axis.getExtent();
|
|
37817
38684
|
var last;
|
|
38685
|
+
var diffSize;
|
|
37818
38686
|
if (ticksLen === 1) {
|
|
37819
38687
|
ticksCoords[0].coord = axisExtent[0];
|
|
37820
38688
|
last = ticksCoords[1] = {coord: axisExtent[0]};
|
|
37821
38689
|
}
|
|
37822
38690
|
else {
|
|
37823
|
-
var
|
|
38691
|
+
var crossLen = ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue;
|
|
38692
|
+
var shift = (ticksCoords[ticksLen - 1].coord - ticksCoords[0].coord) / crossLen;
|
|
38693
|
+
|
|
37824
38694
|
each$1(ticksCoords, function (ticksItem) {
|
|
37825
38695
|
ticksItem.coord -= shift / 2;
|
|
37826
|
-
var tickCategoryInterval = tickCategoryInterval || 0;
|
|
37827
|
-
// Avoid split a single data item when odd interval.
|
|
37828
|
-
if (tickCategoryInterval % 2 > 0) {
|
|
37829
|
-
ticksItem.coord -= shift / ((tickCategoryInterval + 1) * 2);
|
|
37830
|
-
}
|
|
37831
38696
|
});
|
|
37832
|
-
|
|
38697
|
+
|
|
38698
|
+
var dataExtent = axis.scale.getExtent();
|
|
38699
|
+
diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue;
|
|
38700
|
+
|
|
38701
|
+
last = {coord: ticksCoords[ticksLen - 1].coord + shift * diffSize};
|
|
38702
|
+
|
|
37833
38703
|
ticksCoords.push(last);
|
|
37834
38704
|
}
|
|
37835
38705
|
|
|
37836
38706
|
var inverse = axisExtent[0] > axisExtent[1];
|
|
37837
38707
|
|
|
38708
|
+
// Handling clamp.
|
|
37838
38709
|
if (littleThan(ticksCoords[0].coord, axisExtent[0])) {
|
|
37839
38710
|
clamp ? (ticksCoords[0].coord = axisExtent[0]) : ticksCoords.shift();
|
|
37840
38711
|
}
|
|
@@ -37849,6 +38720,10 @@ function fixOnBandTicksCoords(axis, ticksCoords, tickCategoryInterval, alignWith
|
|
|
37849
38720
|
}
|
|
37850
38721
|
|
|
37851
38722
|
function littleThan(a, b) {
|
|
38723
|
+
// Avoid rounding error cause calculated tick coord different with extent.
|
|
38724
|
+
// It may cause an extra unecessary tick added.
|
|
38725
|
+
a = round$1(a);
|
|
38726
|
+
b = round$1(b);
|
|
37852
38727
|
return inverse ? a > b : a < b;
|
|
37853
38728
|
}
|
|
37854
38729
|
}
|
|
@@ -38145,7 +39020,7 @@ axisDefault.valueAxis = merge({
|
|
|
38145
39020
|
// scale: false,
|
|
38146
39021
|
|
|
38147
39022
|
// AxisTick and axisLabel and splitLine are caculated based on splitNumber.
|
|
38148
|
-
splitNumber: 5
|
|
39023
|
+
splitNumber: 5,
|
|
38149
39024
|
|
|
38150
39025
|
// Interval specifies the span of the ticks is mandatorily.
|
|
38151
39026
|
// interval: null
|
|
@@ -38156,6 +39031,30 @@ axisDefault.valueAxis = merge({
|
|
|
38156
39031
|
// Specify max interval when auto calculate tick interval.
|
|
38157
39032
|
// maxInterval: null
|
|
38158
39033
|
|
|
39034
|
+
minorTick: {
|
|
39035
|
+
// Minor tick, not available for cateogry axis.
|
|
39036
|
+
show: false,
|
|
39037
|
+
// Split number of minor ticks. The value should be in range of (0, 100)
|
|
39038
|
+
splitNumber: 5,
|
|
39039
|
+
// Lenght of minor tick
|
|
39040
|
+
length: 3,
|
|
39041
|
+
|
|
39042
|
+
// Same inside with axisTick
|
|
39043
|
+
|
|
39044
|
+
// Line style
|
|
39045
|
+
lineStyle: {
|
|
39046
|
+
// Default to be same with axisTick
|
|
39047
|
+
}
|
|
39048
|
+
},
|
|
39049
|
+
|
|
39050
|
+
minorSplitLine: {
|
|
39051
|
+
show: false,
|
|
39052
|
+
|
|
39053
|
+
lineStyle: {
|
|
39054
|
+
color: '#eee',
|
|
39055
|
+
width: 1
|
|
39056
|
+
}
|
|
39057
|
+
}
|
|
38159
39058
|
}, defaultOption);
|
|
38160
39059
|
|
|
38161
39060
|
axisDefault.timeAxis = defaults({
|
|
@@ -39368,10 +40267,12 @@ var builders = {
|
|
|
39368
40267
|
var axisModel = this.axisModel;
|
|
39369
40268
|
var opt = this.opt;
|
|
39370
40269
|
|
|
39371
|
-
var
|
|
40270
|
+
var ticksEls = buildAxisMajorTicks(this, axisModel, opt);
|
|
39372
40271
|
var labelEls = buildAxisLabel(this, axisModel, opt);
|
|
39373
40272
|
|
|
39374
|
-
fixMinMaxLabelShow(axisModel, labelEls,
|
|
40273
|
+
fixMinMaxLabelShow(axisModel, labelEls, ticksEls);
|
|
40274
|
+
|
|
40275
|
+
buildAxisMinorTicks(this, axisModel, opt);
|
|
39375
40276
|
},
|
|
39376
40277
|
|
|
39377
40278
|
/**
|
|
@@ -39690,42 +40591,27 @@ function isNameLocationCenter(nameLocation) {
|
|
|
39690
40591
|
return nameLocation === 'middle' || nameLocation === 'center';
|
|
39691
40592
|
}
|
|
39692
40593
|
|
|
39693
|
-
function buildAxisTick(axisBuilder, axisModel, opt) {
|
|
39694
|
-
var axis = axisModel.axis;
|
|
39695
|
-
|
|
39696
|
-
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
|
|
39697
|
-
return;
|
|
39698
|
-
}
|
|
39699
|
-
|
|
39700
|
-
var tickModel = axisModel.getModel('axisTick');
|
|
39701
|
-
|
|
39702
|
-
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
39703
|
-
var tickLen = tickModel.get('length');
|
|
39704
|
-
|
|
39705
|
-
var ticksCoords = axis.getTicksCoords();
|
|
39706
40594
|
|
|
40595
|
+
function createTicks(ticksCoords, tickTransform, tickEndCoord, tickLineStyle, aniid) {
|
|
40596
|
+
var tickEls = [];
|
|
39707
40597
|
var pt1 = [];
|
|
39708
40598
|
var pt2 = [];
|
|
39709
|
-
var matrix = axisBuilder._transform;
|
|
39710
|
-
|
|
39711
|
-
var tickEls = [];
|
|
39712
|
-
|
|
39713
40599
|
for (var i = 0; i < ticksCoords.length; i++) {
|
|
39714
40600
|
var tickCoord = ticksCoords[i].coord;
|
|
39715
40601
|
|
|
39716
40602
|
pt1[0] = tickCoord;
|
|
39717
40603
|
pt1[1] = 0;
|
|
39718
40604
|
pt2[0] = tickCoord;
|
|
39719
|
-
pt2[1] =
|
|
40605
|
+
pt2[1] = tickEndCoord;
|
|
39720
40606
|
|
|
39721
|
-
if (
|
|
39722
|
-
applyTransform(pt1, pt1,
|
|
39723
|
-
applyTransform(pt2, pt2,
|
|
40607
|
+
if (tickTransform) {
|
|
40608
|
+
applyTransform(pt1, pt1, tickTransform);
|
|
40609
|
+
applyTransform(pt2, pt2, tickTransform);
|
|
39724
40610
|
}
|
|
39725
40611
|
// Tick line, Not use group transform to have better line draw
|
|
39726
40612
|
var tickEl = new Line({
|
|
39727
40613
|
// Id for animation
|
|
39728
|
-
anid: '
|
|
40614
|
+
anid: aniid + '_' + ticksCoords[i].tickValue,
|
|
39729
40615
|
subPixelOptimize: true,
|
|
39730
40616
|
shape: {
|
|
39731
40617
|
x1: pt1[0],
|
|
@@ -39733,22 +40619,80 @@ function buildAxisTick(axisBuilder, axisModel, opt) {
|
|
|
39733
40619
|
x2: pt2[0],
|
|
39734
40620
|
y2: pt2[1]
|
|
39735
40621
|
},
|
|
39736
|
-
style:
|
|
39737
|
-
lineStyleModel.getLineStyle(),
|
|
39738
|
-
{
|
|
39739
|
-
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
39740
|
-
}
|
|
39741
|
-
),
|
|
40622
|
+
style: tickLineStyle,
|
|
39742
40623
|
z2: 2,
|
|
39743
40624
|
silent: true
|
|
39744
40625
|
});
|
|
39745
|
-
axisBuilder.group.add(tickEl);
|
|
39746
40626
|
tickEls.push(tickEl);
|
|
39747
40627
|
}
|
|
39748
|
-
|
|
39749
40628
|
return tickEls;
|
|
39750
40629
|
}
|
|
39751
40630
|
|
|
40631
|
+
function buildAxisMajorTicks(axisBuilder, axisModel, opt) {
|
|
40632
|
+
var axis = axisModel.axis;
|
|
40633
|
+
|
|
40634
|
+
var tickModel = axisModel.getModel('axisTick');
|
|
40635
|
+
|
|
40636
|
+
if (!tickModel.get('show') || axis.scale.isBlank()) {
|
|
40637
|
+
return;
|
|
40638
|
+
}
|
|
40639
|
+
|
|
40640
|
+
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
40641
|
+
var tickEndCoord = opt.tickDirection * tickModel.get('length');
|
|
40642
|
+
|
|
40643
|
+
var ticksCoords = axis.getTicksCoords();
|
|
40644
|
+
|
|
40645
|
+
var ticksEls = createTicks(ticksCoords, axisBuilder._transform, tickEndCoord, defaults(
|
|
40646
|
+
lineStyleModel.getLineStyle(),
|
|
40647
|
+
{
|
|
40648
|
+
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
40649
|
+
}
|
|
40650
|
+
), 'ticks');
|
|
40651
|
+
|
|
40652
|
+
for (var i = 0; i < ticksEls.length; i++) {
|
|
40653
|
+
axisBuilder.group.add(ticksEls[i]);
|
|
40654
|
+
}
|
|
40655
|
+
|
|
40656
|
+
return ticksEls;
|
|
40657
|
+
}
|
|
40658
|
+
|
|
40659
|
+
function buildAxisMinorTicks(axisBuilder, axisModel, opt) {
|
|
40660
|
+
var axis = axisModel.axis;
|
|
40661
|
+
|
|
40662
|
+
var minorTickModel = axisModel.getModel('minorTick');
|
|
40663
|
+
|
|
40664
|
+
if (!minorTickModel.get('show') || axis.scale.isBlank()) {
|
|
40665
|
+
return;
|
|
40666
|
+
}
|
|
40667
|
+
|
|
40668
|
+
var minorTicksCoords = axis.getMinorTicksCoords();
|
|
40669
|
+
if (!minorTicksCoords.length) {
|
|
40670
|
+
return;
|
|
40671
|
+
}
|
|
40672
|
+
|
|
40673
|
+
var lineStyleModel = minorTickModel.getModel('lineStyle');
|
|
40674
|
+
var tickEndCoord = opt.tickDirection * minorTickModel.get('length');
|
|
40675
|
+
|
|
40676
|
+
var minorTickLineStyle = defaults(
|
|
40677
|
+
lineStyleModel.getLineStyle(),
|
|
40678
|
+
defaults(
|
|
40679
|
+
axisModel.getModel('axisTick').getLineStyle(),
|
|
40680
|
+
{
|
|
40681
|
+
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
40682
|
+
}
|
|
40683
|
+
)
|
|
40684
|
+
);
|
|
40685
|
+
|
|
40686
|
+
for (var i = 0; i < minorTicksCoords.length; i++) {
|
|
40687
|
+
var minorTicksEls = createTicks(
|
|
40688
|
+
minorTicksCoords[i], axisBuilder._transform, tickEndCoord, minorTickLineStyle, 'minorticks_' + i
|
|
40689
|
+
);
|
|
40690
|
+
for (var k = 0; k < minorTicksEls.length; k++) {
|
|
40691
|
+
axisBuilder.group.add(minorTicksEls[k]);
|
|
40692
|
+
}
|
|
40693
|
+
}
|
|
40694
|
+
}
|
|
40695
|
+
|
|
39752
40696
|
function buildAxisLabel(axisBuilder, axisModel, opt) {
|
|
39753
40697
|
var axis = axisModel.axis;
|
|
39754
40698
|
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
|
|
@@ -40168,17 +41112,9 @@ var axisBuilderAttrs = [
|
|
|
40168
41112
|
'axisLine', 'axisTickLabel', 'axisName'
|
|
40169
41113
|
];
|
|
40170
41114
|
var selfBuilderAttrs = [
|
|
40171
|
-
'splitArea', 'splitLine'
|
|
41115
|
+
'splitArea', 'splitLine', 'minorSplitLine'
|
|
40172
41116
|
];
|
|
40173
41117
|
|
|
40174
|
-
// function getAlignWithLabel(model, axisModel) {
|
|
40175
|
-
// var alignWithLabel = model.get('alignWithLabel');
|
|
40176
|
-
// if (alignWithLabel === 'auto') {
|
|
40177
|
-
// alignWithLabel = axisModel.get('axisTick.alignWithLabel');
|
|
40178
|
-
// }
|
|
40179
|
-
// return alignWithLabel;
|
|
40180
|
-
// }
|
|
40181
|
-
|
|
40182
41118
|
var CartesianAxisView = AxisView.extend({
|
|
40183
41119
|
|
|
40184
41120
|
type: 'cartesianAxis',
|
|
@@ -40256,8 +41192,6 @@ var CartesianAxisView = AxisView.extend({
|
|
|
40256
41192
|
var p1 = [];
|
|
40257
41193
|
var p2 = [];
|
|
40258
41194
|
|
|
40259
|
-
// Simple optimization
|
|
40260
|
-
// Batching the lines if color are the same
|
|
40261
41195
|
var lineStyle = lineStyleModel.getLineStyle();
|
|
40262
41196
|
for (var i = 0; i < ticksCoords.length; i++) {
|
|
40263
41197
|
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
|
@@ -40294,6 +41228,63 @@ var CartesianAxisView = AxisView.extend({
|
|
|
40294
41228
|
}
|
|
40295
41229
|
},
|
|
40296
41230
|
|
|
41231
|
+
/**
|
|
41232
|
+
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
|
|
41233
|
+
* @param {module:echarts/coord/cartesian/GridModel} gridModel
|
|
41234
|
+
* @private
|
|
41235
|
+
*/
|
|
41236
|
+
_minorSplitLine: function (axisModel, gridModel) {
|
|
41237
|
+
var axis = axisModel.axis;
|
|
41238
|
+
|
|
41239
|
+
var minorSplitLineModel = axisModel.getModel('minorSplitLine');
|
|
41240
|
+
var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
|
|
41241
|
+
|
|
41242
|
+
var gridRect = gridModel.coordinateSystem.getRect();
|
|
41243
|
+
var isHorizontal = axis.isHorizontal();
|
|
41244
|
+
|
|
41245
|
+
var minorTicksCoords = axis.getMinorTicksCoords();
|
|
41246
|
+
if (!minorTicksCoords.length) {
|
|
41247
|
+
return;
|
|
41248
|
+
}
|
|
41249
|
+
var p1 = [];
|
|
41250
|
+
var p2 = [];
|
|
41251
|
+
|
|
41252
|
+
var lineStyle = lineStyleModel.getLineStyle();
|
|
41253
|
+
|
|
41254
|
+
|
|
41255
|
+
for (var i = 0; i < minorTicksCoords.length; i++) {
|
|
41256
|
+
for (var k = 0; k < minorTicksCoords[i].length; k++) {
|
|
41257
|
+
var tickCoord = axis.toGlobalCoord(minorTicksCoords[i][k].coord);
|
|
41258
|
+
|
|
41259
|
+
if (isHorizontal) {
|
|
41260
|
+
p1[0] = tickCoord;
|
|
41261
|
+
p1[1] = gridRect.y;
|
|
41262
|
+
p2[0] = tickCoord;
|
|
41263
|
+
p2[1] = gridRect.y + gridRect.height;
|
|
41264
|
+
}
|
|
41265
|
+
else {
|
|
41266
|
+
p1[0] = gridRect.x;
|
|
41267
|
+
p1[1] = tickCoord;
|
|
41268
|
+
p2[0] = gridRect.x + gridRect.width;
|
|
41269
|
+
p2[1] = tickCoord;
|
|
41270
|
+
}
|
|
41271
|
+
|
|
41272
|
+
this._axisGroup.add(new Line({
|
|
41273
|
+
anid: 'minor_line_' + minorTicksCoords[i][k].tickValue,
|
|
41274
|
+
subPixelOptimize: true,
|
|
41275
|
+
shape: {
|
|
41276
|
+
x1: p1[0],
|
|
41277
|
+
y1: p1[1],
|
|
41278
|
+
x2: p2[0],
|
|
41279
|
+
y2: p2[1]
|
|
41280
|
+
},
|
|
41281
|
+
style: lineStyle,
|
|
41282
|
+
silent: true
|
|
41283
|
+
}));
|
|
41284
|
+
}
|
|
41285
|
+
}
|
|
41286
|
+
},
|
|
41287
|
+
|
|
40297
41288
|
/**
|
|
40298
41289
|
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
|
|
40299
41290
|
* @param {module:echarts/coord/cartesian/GridModel} gridModel
|
|
@@ -40514,7 +41505,7 @@ var BaseBarSeries = SeriesModel.extend({
|
|
|
40514
41505
|
type: 'series.__base_bar__',
|
|
40515
41506
|
|
|
40516
41507
|
getInitialData: function (option, ecModel) {
|
|
40517
|
-
return createListFromArray(this.getSource(), this);
|
|
41508
|
+
return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
|
|
40518
41509
|
},
|
|
40519
41510
|
|
|
40520
41511
|
getMarkerPosition: function (value) {
|
|
@@ -40555,6 +41546,10 @@ var BaseBarSeries = SeriesModel.extend({
|
|
|
40555
41546
|
progressiveChunkMode: 'mod',
|
|
40556
41547
|
|
|
40557
41548
|
// barMaxWidth: null,
|
|
41549
|
+
|
|
41550
|
+
// In cartesian, the default value is 1. Otherwise null.
|
|
41551
|
+
// barMinWidth: null,
|
|
41552
|
+
|
|
40558
41553
|
// 默认自适应
|
|
40559
41554
|
// barWidth: null,
|
|
40560
41555
|
// 柱间距离,默认为柱形宽度的30%,可设固定值
|
|
@@ -40622,7 +41617,11 @@ BaseBarSeries.extend({
|
|
|
40622
41617
|
defaultOption: {
|
|
40623
41618
|
// If clipped
|
|
40624
41619
|
// Only available on cartesian2d
|
|
40625
|
-
clip: true
|
|
41620
|
+
clip: true,
|
|
41621
|
+
|
|
41622
|
+
// If use caps on two sides of bars
|
|
41623
|
+
// Only available on tangential polar bar
|
|
41624
|
+
roundCap: false
|
|
40626
41625
|
}
|
|
40627
41626
|
});
|
|
40628
41627
|
|
|
@@ -40737,6 +41736,98 @@ var barItemStyle = {
|
|
|
40737
41736
|
* under the License.
|
|
40738
41737
|
*/
|
|
40739
41738
|
|
|
41739
|
+
/**
|
|
41740
|
+
* Sausage: similar to sector, but have half circle on both sides
|
|
41741
|
+
* @public
|
|
41742
|
+
*/
|
|
41743
|
+
var Sausage = extendShape({
|
|
41744
|
+
|
|
41745
|
+
type: 'sausage',
|
|
41746
|
+
|
|
41747
|
+
shape: {
|
|
41748
|
+
|
|
41749
|
+
cx: 0,
|
|
41750
|
+
|
|
41751
|
+
cy: 0,
|
|
41752
|
+
|
|
41753
|
+
r0: 0,
|
|
41754
|
+
|
|
41755
|
+
r: 0,
|
|
41756
|
+
|
|
41757
|
+
startAngle: 0,
|
|
41758
|
+
|
|
41759
|
+
endAngle: Math.PI * 2,
|
|
41760
|
+
|
|
41761
|
+
clockwise: true
|
|
41762
|
+
},
|
|
41763
|
+
|
|
41764
|
+
buildPath: function (ctx, shape) {
|
|
41765
|
+
var x = shape.cx;
|
|
41766
|
+
var y = shape.cy;
|
|
41767
|
+
var r0 = Math.max(shape.r0 || 0, 0);
|
|
41768
|
+
var r = Math.max(shape.r, 0);
|
|
41769
|
+
var dr = (r - r0) * 0.5;
|
|
41770
|
+
var rCenter = r0 + dr;
|
|
41771
|
+
var startAngle = shape.startAngle;
|
|
41772
|
+
var endAngle = shape.endAngle;
|
|
41773
|
+
var clockwise = shape.clockwise;
|
|
41774
|
+
|
|
41775
|
+
var unitStartX = Math.cos(startAngle);
|
|
41776
|
+
var unitStartY = Math.sin(startAngle);
|
|
41777
|
+
var unitEndX = Math.cos(endAngle);
|
|
41778
|
+
var unitEndY = Math.sin(endAngle);
|
|
41779
|
+
|
|
41780
|
+
var lessThanCircle = clockwise
|
|
41781
|
+
? endAngle - startAngle < Math.PI * 2
|
|
41782
|
+
: startAngle - endAngle < Math.PI * 2;
|
|
41783
|
+
|
|
41784
|
+
if (lessThanCircle) {
|
|
41785
|
+
ctx.moveTo(unitStartX * r0 + x, unitStartY * r0 + y);
|
|
41786
|
+
|
|
41787
|
+
ctx.arc(
|
|
41788
|
+
unitStartX * rCenter + x, unitStartY * rCenter + y, dr,
|
|
41789
|
+
-Math.PI + startAngle, startAngle, !clockwise
|
|
41790
|
+
);
|
|
41791
|
+
}
|
|
41792
|
+
|
|
41793
|
+
ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
|
|
41794
|
+
|
|
41795
|
+
ctx.moveTo(unitEndX * r + x, unitEndY * r + y);
|
|
41796
|
+
|
|
41797
|
+
ctx.arc(
|
|
41798
|
+
unitEndX * rCenter + x, unitEndY * rCenter + y, dr,
|
|
41799
|
+
endAngle - Math.PI * 2, endAngle - Math.PI, !clockwise
|
|
41800
|
+
);
|
|
41801
|
+
|
|
41802
|
+
if (r0 !== 0) {
|
|
41803
|
+
ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
|
|
41804
|
+
|
|
41805
|
+
ctx.moveTo(unitStartX * r0 + x, unitEndY * r0 + y);
|
|
41806
|
+
}
|
|
41807
|
+
|
|
41808
|
+
ctx.closePath();
|
|
41809
|
+
}
|
|
41810
|
+
});
|
|
41811
|
+
|
|
41812
|
+
/*
|
|
41813
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
41814
|
+
* or more contributor license agreements. See the NOTICE file
|
|
41815
|
+
* distributed with this work for additional information
|
|
41816
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
41817
|
+
* to you under the Apache License, Version 2.0 (the
|
|
41818
|
+
* "License"); you may not use this file except in compliance
|
|
41819
|
+
* with the License. You may obtain a copy of the License at
|
|
41820
|
+
*
|
|
41821
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
41822
|
+
*
|
|
41823
|
+
* Unless required by applicable law or agreed to in writing,
|
|
41824
|
+
* software distributed under the License is distributed on an
|
|
41825
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
41826
|
+
* KIND, either express or implied. See the License for the
|
|
41827
|
+
* specific language governing permissions and limitations
|
|
41828
|
+
* under the License.
|
|
41829
|
+
*/
|
|
41830
|
+
|
|
40740
41831
|
var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'barBorderWidth'];
|
|
40741
41832
|
var _eventPos = [0, 0];
|
|
40742
41833
|
|
|
@@ -40833,6 +41924,8 @@ extendChartView({
|
|
|
40833
41924
|
// We don't use clipPath in normal mode because we needs a perfect animation
|
|
40834
41925
|
// And don't want the label are clipped.
|
|
40835
41926
|
|
|
41927
|
+
var roundCap = seriesModel.get('roundCap', true);
|
|
41928
|
+
|
|
40836
41929
|
data.diff(oldData)
|
|
40837
41930
|
.add(function (dataIndex) {
|
|
40838
41931
|
if (!data.hasValue(dataIndex)) {
|
|
@@ -40853,7 +41946,7 @@ extendChartView({
|
|
|
40853
41946
|
}
|
|
40854
41947
|
|
|
40855
41948
|
var el = elementCreator[coord.type](
|
|
40856
|
-
|
|
41949
|
+
dataIndex, layout, isHorizontalOrRadial, animationModel, false, roundCap
|
|
40857
41950
|
);
|
|
40858
41951
|
data.setItemGraphicEl(dataIndex, el);
|
|
40859
41952
|
group.add(el);
|
|
@@ -40887,7 +41980,7 @@ extendChartView({
|
|
|
40887
41980
|
}
|
|
40888
41981
|
else {
|
|
40889
41982
|
el = elementCreator[coord.type](
|
|
40890
|
-
|
|
41983
|
+
newIndex, layout, isHorizontalOrRadial, animationModel, true, roundCap
|
|
40891
41984
|
);
|
|
40892
41985
|
}
|
|
40893
41986
|
|
|
@@ -41011,7 +42104,7 @@ var clip = {
|
|
|
41011
42104
|
var elementCreator = {
|
|
41012
42105
|
|
|
41013
42106
|
cartesian2d: function (
|
|
41014
|
-
|
|
42107
|
+
dataIndex, layout, isHorizontal,
|
|
41015
42108
|
animationModel, isUpdate
|
|
41016
42109
|
) {
|
|
41017
42110
|
var rect = new Rect({shape: extend({}, layout)});
|
|
@@ -41032,15 +42125,18 @@ var elementCreator = {
|
|
|
41032
42125
|
},
|
|
41033
42126
|
|
|
41034
42127
|
polar: function (
|
|
41035
|
-
|
|
41036
|
-
animationModel, isUpdate
|
|
42128
|
+
dataIndex, layout, isRadial,
|
|
42129
|
+
animationModel, isUpdate, roundCap
|
|
41037
42130
|
) {
|
|
41038
42131
|
// Keep the same logic with bar in catesion: use end value to control
|
|
41039
42132
|
// direction. Notice that if clockwise is true (by default), the sector
|
|
41040
42133
|
// will always draw clockwisely, no matter whether endAngle is greater
|
|
41041
42134
|
// or less than startAngle.
|
|
41042
42135
|
var clockwise = layout.startAngle < layout.endAngle;
|
|
41043
|
-
|
|
42136
|
+
|
|
42137
|
+
var ShapeClass = (!isRadial && roundCap) ? Sausage : Sector;
|
|
42138
|
+
|
|
42139
|
+
var sector = new ShapeClass({
|
|
41044
42140
|
shape: defaults({clockwise: clockwise}, layout)
|
|
41045
42141
|
});
|
|
41046
42142
|
|
|
@@ -41113,11 +42209,18 @@ var getLayout = {
|
|
|
41113
42209
|
}
|
|
41114
42210
|
};
|
|
41115
42211
|
|
|
42212
|
+
function isZeroOnPolar(layout) {
|
|
42213
|
+
return layout.startAngle != null
|
|
42214
|
+
&& layout.endAngle != null
|
|
42215
|
+
&& layout.startAngle === layout.endAngle;
|
|
42216
|
+
}
|
|
42217
|
+
|
|
41116
42218
|
function updateStyle(
|
|
41117
42219
|
el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar
|
|
41118
42220
|
) {
|
|
41119
42221
|
var color = data.getItemVisual(dataIndex, 'color');
|
|
41120
42222
|
var opacity = data.getItemVisual(dataIndex, 'opacity');
|
|
42223
|
+
var stroke = data.getVisual('borderColor');
|
|
41121
42224
|
var itemStyleModel = itemModel.getModel('itemStyle');
|
|
41122
42225
|
var hoverStyle = itemModel.getModel('emphasis.itemStyle').getBarItemStyle();
|
|
41123
42226
|
|
|
@@ -41127,7 +42230,8 @@ function updateStyle(
|
|
|
41127
42230
|
|
|
41128
42231
|
el.useStyle(defaults(
|
|
41129
42232
|
{
|
|
41130
|
-
|
|
42233
|
+
stroke: isZeroOnPolar(layout) ? 'none' : stroke,
|
|
42234
|
+
fill: isZeroOnPolar(layout) ? 'none' : color,
|
|
41131
42235
|
opacity: opacity
|
|
41132
42236
|
},
|
|
41133
42237
|
itemStyleModel.getBarItemStyle()
|
|
@@ -41146,7 +42250,9 @@ function updateStyle(
|
|
|
41146
42250
|
seriesModel, dataIndex, labelPositionOutside
|
|
41147
42251
|
);
|
|
41148
42252
|
}
|
|
41149
|
-
|
|
42253
|
+
if (isZeroOnPolar(layout)) {
|
|
42254
|
+
hoverStyle.fill = hoverStyle.stroke = 'none';
|
|
42255
|
+
}
|
|
41150
42256
|
setHoverStyle(el, hoverStyle);
|
|
41151
42257
|
}
|
|
41152
42258
|
|
|
@@ -41467,6 +42573,60 @@ var dataSelectableMixin = {
|
|
|
41467
42573
|
* under the License.
|
|
41468
42574
|
*/
|
|
41469
42575
|
|
|
42576
|
+
|
|
42577
|
+
/**
|
|
42578
|
+
* LegendVisualProvider is an bridge that pick encoded color from data and
|
|
42579
|
+
* provide to the legend component.
|
|
42580
|
+
* @param {Function} getDataWithEncodedVisual Function to get data after filtered. It stores all the encoding info
|
|
42581
|
+
* @param {Function} getRawData Function to get raw data before filtered.
|
|
42582
|
+
*/
|
|
42583
|
+
function LegendVisualProvider(getDataWithEncodedVisual, getRawData) {
|
|
42584
|
+
this.getAllNames = function () {
|
|
42585
|
+
var rawData = getRawData();
|
|
42586
|
+
// We find the name from the raw data. In case it's filtered by the legend component.
|
|
42587
|
+
// Normally, the name can be found in rawData, but can't be found in filtered data will display as gray.
|
|
42588
|
+
return rawData.mapArray(rawData.getName);
|
|
42589
|
+
};
|
|
42590
|
+
|
|
42591
|
+
this.containName = function (name) {
|
|
42592
|
+
var rawData = getRawData();
|
|
42593
|
+
return rawData.indexOfName(name) >= 0;
|
|
42594
|
+
};
|
|
42595
|
+
|
|
42596
|
+
this.indexOfName = function (name) {
|
|
42597
|
+
// Only get data when necessary.
|
|
42598
|
+
// Because LegendVisualProvider constructor may be new in the stage that data is not prepared yet.
|
|
42599
|
+
// Invoking Series#getData immediately will throw an error.
|
|
42600
|
+
var dataWithEncodedVisual = getDataWithEncodedVisual();
|
|
42601
|
+
return dataWithEncodedVisual.indexOfName(name);
|
|
42602
|
+
};
|
|
42603
|
+
|
|
42604
|
+
this.getItemVisual = function (dataIndex, key) {
|
|
42605
|
+
// Get encoded visual properties from final filtered data.
|
|
42606
|
+
var dataWithEncodedVisual = getDataWithEncodedVisual();
|
|
42607
|
+
return dataWithEncodedVisual.getItemVisual(dataIndex, key);
|
|
42608
|
+
};
|
|
42609
|
+
}
|
|
42610
|
+
|
|
42611
|
+
/*
|
|
42612
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
42613
|
+
* or more contributor license agreements. See the NOTICE file
|
|
42614
|
+
* distributed with this work for additional information
|
|
42615
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
42616
|
+
* to you under the Apache License, Version 2.0 (the
|
|
42617
|
+
* "License"); you may not use this file except in compliance
|
|
42618
|
+
* with the License. You may obtain a copy of the License at
|
|
42619
|
+
*
|
|
42620
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42621
|
+
*
|
|
42622
|
+
* Unless required by applicable law or agreed to in writing,
|
|
42623
|
+
* software distributed under the License is distributed on an
|
|
42624
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
42625
|
+
* KIND, either express or implied. See the License for the
|
|
42626
|
+
* specific language governing permissions and limitations
|
|
42627
|
+
* under the License.
|
|
42628
|
+
*/
|
|
42629
|
+
|
|
41470
42630
|
var PieSeries = extendSeriesModel({
|
|
41471
42631
|
|
|
41472
42632
|
type: 'series.pie',
|
|
@@ -41477,9 +42637,9 @@ var PieSeries = extendSeriesModel({
|
|
|
41477
42637
|
|
|
41478
42638
|
// Enable legend selection for each data item
|
|
41479
42639
|
// Use a function instead of direct access because data reference may changed
|
|
41480
|
-
this.
|
|
41481
|
-
|
|
41482
|
-
|
|
42640
|
+
this.legendVisualProvider = new LegendVisualProvider(
|
|
42641
|
+
bind(this.getData, this), bind(this.getRawData, this)
|
|
42642
|
+
);
|
|
41483
42643
|
|
|
41484
42644
|
this.updateSelectedMap(this._createSelectableList());
|
|
41485
42645
|
|
|
@@ -41494,7 +42654,10 @@ var PieSeries = extendSeriesModel({
|
|
|
41494
42654
|
},
|
|
41495
42655
|
|
|
41496
42656
|
getInitialData: function (option, ecModel) {
|
|
41497
|
-
return createListSimply(this,
|
|
42657
|
+
return createListSimply(this, {
|
|
42658
|
+
coordDimensions: ['value'],
|
|
42659
|
+
encodeDefaulter: curry(makeSeriesEncodeForNameBased, this)
|
|
42660
|
+
});
|
|
41498
42661
|
},
|
|
41499
42662
|
|
|
41500
42663
|
_createSelectableList: function () {
|
|
@@ -41583,12 +42746,28 @@ var PieSeries = extendSeriesModel({
|
|
|
41583
42746
|
|
|
41584
42747
|
// cursor: null,
|
|
41585
42748
|
|
|
42749
|
+
left: 0,
|
|
42750
|
+
top: 0,
|
|
42751
|
+
right: 0,
|
|
42752
|
+
bottom: 0,
|
|
42753
|
+
width: null,
|
|
42754
|
+
height: null,
|
|
42755
|
+
|
|
41586
42756
|
label: {
|
|
41587
42757
|
// If rotate around circle
|
|
41588
42758
|
rotate: false,
|
|
41589
42759
|
show: true,
|
|
41590
42760
|
// 'outer', 'inside', 'center'
|
|
41591
|
-
position: 'outer'
|
|
42761
|
+
position: 'outer',
|
|
42762
|
+
// 'none', 'labelLine', 'edge'. Works only when position is 'outer'
|
|
42763
|
+
alignTo: 'none',
|
|
42764
|
+
// Closest distance between label and chart edge.
|
|
42765
|
+
// Works only position is 'outer' and alignTo is 'edge'.
|
|
42766
|
+
margin: '25%',
|
|
42767
|
+
// Works only position is 'outer' and alignTo is not 'edge'.
|
|
42768
|
+
bleedMargin: 10,
|
|
42769
|
+
// Distance between text and label line.
|
|
42770
|
+
distanceToLabelLine: 5
|
|
41592
42771
|
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
|
|
41593
42772
|
// 默认使用全局文本样式,详见TEXTSTYLE
|
|
41594
42773
|
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
|
|
@@ -41894,7 +43073,7 @@ piePieceProto._updateLabel = function (data, idx, withAnimation) {
|
|
|
41894
43073
|
{
|
|
41895
43074
|
labelFetcher: data.hostModel,
|
|
41896
43075
|
labelDataIndex: idx,
|
|
41897
|
-
defaultText:
|
|
43076
|
+
defaultText: labelLayout.text,
|
|
41898
43077
|
autoColor: visualColor,
|
|
41899
43078
|
useInsideStyle: !!labelLayout.inside
|
|
41900
43079
|
},
|
|
@@ -42190,33 +43369,20 @@ var dataColor = function (seriesType) {
|
|
|
42190
43369
|
dataAll.getName(rawIdx) || (rawIdx + ''), seriesModel.__paletteScope,
|
|
42191
43370
|
dataAll.count()
|
|
42192
43371
|
);
|
|
42193
|
-
// Legend may use the visual info in data before processed
|
|
42194
|
-
dataAll.setItemVisual(rawIdx, 'color', color);
|
|
42195
|
-
|
|
42196
43372
|
// Data is not filtered
|
|
42197
43373
|
if (filteredIdx != null) {
|
|
42198
43374
|
data.setItemVisual(filteredIdx, 'color', color);
|
|
42199
43375
|
}
|
|
42200
43376
|
}
|
|
42201
|
-
else {
|
|
42202
|
-
// Set data all color for legend
|
|
42203
|
-
dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
|
|
42204
|
-
}
|
|
42205
43377
|
|
|
42206
43378
|
if (!singleDataBorderColor) {
|
|
42207
43379
|
var borderColor = itemModel.get('itemStyle.borderColor');
|
|
42208
|
-
// Legend may use the visual info in data before processed
|
|
42209
|
-
dataAll.setItemVisual(rawIdx, 'borderColor', borderColor);
|
|
42210
43380
|
|
|
42211
43381
|
// Data is not filtered
|
|
42212
43382
|
if (filteredIdx != null) {
|
|
42213
43383
|
data.setItemVisual(filteredIdx, 'borderColor', borderColor);
|
|
42214
43384
|
}
|
|
42215
43385
|
}
|
|
42216
|
-
else {
|
|
42217
|
-
// Set data all borderColor for legend
|
|
42218
|
-
dataAll.setItemVisual(rawIdx, 'borderColor', singleDataBorderColor);
|
|
42219
|
-
}
|
|
42220
43386
|
});
|
|
42221
43387
|
}
|
|
42222
43388
|
};
|
|
@@ -42245,13 +43411,17 @@ var dataColor = function (seriesType) {
|
|
|
42245
43411
|
|
|
42246
43412
|
var RADIAN$1 = Math.PI / 180;
|
|
42247
43413
|
|
|
42248
|
-
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
43414
|
+
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
|
|
42249
43415
|
list.sort(function (a, b) {
|
|
42250
43416
|
return a.y - b.y;
|
|
42251
43417
|
});
|
|
42252
43418
|
|
|
42253
43419
|
function shiftDown(start, end, delta, dir) {
|
|
42254
43420
|
for (var j = start; j < end; j++) {
|
|
43421
|
+
if (list[j].y + delta > viewTop + viewHeight) {
|
|
43422
|
+
break;
|
|
43423
|
+
}
|
|
43424
|
+
|
|
42255
43425
|
list[j].y += delta;
|
|
42256
43426
|
if (j > start
|
|
42257
43427
|
&& j + 1 < end
|
|
@@ -42267,6 +43437,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42267
43437
|
|
|
42268
43438
|
function shiftUp(end, delta) {
|
|
42269
43439
|
for (var j = end; j >= 0; j--) {
|
|
43440
|
+
if (list[j].y - delta < viewTop) {
|
|
43441
|
+
break;
|
|
43442
|
+
}
|
|
43443
|
+
|
|
42270
43444
|
list[j].y -= delta;
|
|
42271
43445
|
if (j > 0
|
|
42272
43446
|
&& list[j].y > list[j - 1].y + list[j - 1].height
|
|
@@ -42286,6 +43460,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42286
43460
|
: 0; // up
|
|
42287
43461
|
|
|
42288
43462
|
for (var i = 0, l = list.length; i < l; i++) {
|
|
43463
|
+
if (list[i].labelAlignTo !== 'none') {
|
|
43464
|
+
continue;
|
|
43465
|
+
}
|
|
43466
|
+
|
|
42289
43467
|
var deltaY = Math.abs(list[i].y - cy);
|
|
42290
43468
|
var length = list[i].len;
|
|
42291
43469
|
var length2 = list[i].len2;
|
|
@@ -42315,6 +43493,12 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42315
43493
|
var upList = [];
|
|
42316
43494
|
var downList = [];
|
|
42317
43495
|
for (var i = 0; i < len; i++) {
|
|
43496
|
+
if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
|
|
43497
|
+
var dx = list[i].x - farthestX;
|
|
43498
|
+
list[i].linePoints[1][0] += dx;
|
|
43499
|
+
list[i].x = farthestX;
|
|
43500
|
+
}
|
|
43501
|
+
|
|
42318
43502
|
delta = list[i].y - lastY;
|
|
42319
43503
|
if (delta < 0) {
|
|
42320
43504
|
shiftDown(i, len, -delta, dir);
|
|
@@ -42336,39 +43520,85 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42336
43520
|
changeX(downList, true, cx, cy, r, dir);
|
|
42337
43521
|
}
|
|
42338
43522
|
|
|
42339
|
-
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
43523
|
+
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
42340
43524
|
var leftList = [];
|
|
42341
43525
|
var rightList = [];
|
|
43526
|
+
var leftmostX = Number.MAX_VALUE;
|
|
43527
|
+
var rightmostX = -Number.MAX_VALUE;
|
|
42342
43528
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
42343
43529
|
if (isPositionCenter(labelLayoutList[i])) {
|
|
42344
43530
|
continue;
|
|
42345
43531
|
}
|
|
42346
43532
|
if (labelLayoutList[i].x < cx) {
|
|
43533
|
+
leftmostX = Math.min(leftmostX, labelLayoutList[i].x);
|
|
42347
43534
|
leftList.push(labelLayoutList[i]);
|
|
42348
43535
|
}
|
|
42349
43536
|
else {
|
|
43537
|
+
rightmostX = Math.max(rightmostX, labelLayoutList[i].x);
|
|
42350
43538
|
rightList.push(labelLayoutList[i]);
|
|
42351
43539
|
}
|
|
42352
43540
|
}
|
|
42353
43541
|
|
|
42354
|
-
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
|
|
42355
|
-
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
|
|
43542
|
+
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
|
|
43543
|
+
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
|
|
42356
43544
|
|
|
42357
43545
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
42358
|
-
|
|
43546
|
+
var layout = labelLayoutList[i];
|
|
43547
|
+
if (isPositionCenter(layout)) {
|
|
42359
43548
|
continue;
|
|
42360
43549
|
}
|
|
42361
|
-
|
|
43550
|
+
|
|
43551
|
+
var linePoints = layout.linePoints;
|
|
42362
43552
|
if (linePoints) {
|
|
43553
|
+
var isAlignToEdge = layout.labelAlignTo === 'edge';
|
|
43554
|
+
|
|
43555
|
+
var realTextWidth = layout.textRect.width;
|
|
43556
|
+
var targetTextWidth;
|
|
43557
|
+
if (isAlignToEdge) {
|
|
43558
|
+
if (layout.x < cx) {
|
|
43559
|
+
targetTextWidth = linePoints[2][0] - layout.labelDistance
|
|
43560
|
+
- viewLeft - layout.labelMargin;
|
|
43561
|
+
}
|
|
43562
|
+
else {
|
|
43563
|
+
targetTextWidth = viewLeft + viewWidth - layout.labelMargin
|
|
43564
|
+
- linePoints[2][0] - layout.labelDistance;
|
|
43565
|
+
}
|
|
43566
|
+
}
|
|
43567
|
+
else {
|
|
43568
|
+
if (layout.x < cx) {
|
|
43569
|
+
targetTextWidth = layout.x - viewLeft - layout.bleedMargin;
|
|
43570
|
+
}
|
|
43571
|
+
else {
|
|
43572
|
+
targetTextWidth = viewLeft + viewWidth - layout.x - layout.bleedMargin;
|
|
43573
|
+
}
|
|
43574
|
+
}
|
|
43575
|
+
if (targetTextWidth < layout.textRect.width) {
|
|
43576
|
+
layout.text = truncateText(layout.text, targetTextWidth, layout.font);
|
|
43577
|
+
if (layout.labelAlignTo === 'edge') {
|
|
43578
|
+
realTextWidth = getWidth(layout.text, layout.font);
|
|
43579
|
+
}
|
|
43580
|
+
}
|
|
43581
|
+
|
|
42363
43582
|
var dist = linePoints[1][0] - linePoints[2][0];
|
|
42364
|
-
if (
|
|
42365
|
-
|
|
43583
|
+
if (isAlignToEdge) {
|
|
43584
|
+
if (layout.x < cx) {
|
|
43585
|
+
linePoints[2][0] = viewLeft + layout.labelMargin + realTextWidth + layout.labelDistance;
|
|
43586
|
+
}
|
|
43587
|
+
else {
|
|
43588
|
+
linePoints[2][0] = viewLeft + viewWidth - layout.labelMargin
|
|
43589
|
+
- realTextWidth - layout.labelDistance;
|
|
43590
|
+
}
|
|
42366
43591
|
}
|
|
42367
43592
|
else {
|
|
42368
|
-
|
|
43593
|
+
if (layout.x < cx) {
|
|
43594
|
+
linePoints[2][0] = layout.x + layout.labelDistance;
|
|
43595
|
+
}
|
|
43596
|
+
else {
|
|
43597
|
+
linePoints[2][0] = layout.x - layout.labelDistance;
|
|
43598
|
+
}
|
|
43599
|
+
linePoints[1][0] = linePoints[2][0] + dist;
|
|
42369
43600
|
}
|
|
42370
|
-
linePoints[1][1] = linePoints[2][1] =
|
|
42371
|
-
linePoints[1][0] = linePoints[2][0] + dist;
|
|
43601
|
+
linePoints[1][1] = linePoints[2][1] = layout.y;
|
|
42372
43602
|
}
|
|
42373
43603
|
}
|
|
42374
43604
|
}
|
|
@@ -42378,7 +43608,7 @@ function isPositionCenter(layout) {
|
|
|
42378
43608
|
return layout.position === 'center';
|
|
42379
43609
|
}
|
|
42380
43610
|
|
|
42381
|
-
var labelLayout = function (seriesModel, r, viewWidth, viewHeight,
|
|
43611
|
+
var labelLayout = function (seriesModel, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
42382
43612
|
var data = seriesModel.getData();
|
|
42383
43613
|
var labelLayoutList = [];
|
|
42384
43614
|
var cx;
|
|
@@ -42393,10 +43623,17 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42393
43623
|
var labelModel = itemModel.getModel('label');
|
|
42394
43624
|
// Use position in normal or emphasis
|
|
42395
43625
|
var labelPosition = labelModel.get('position') || itemModel.get('emphasis.label.position');
|
|
43626
|
+
var labelDistance = labelModel.get('distanceToLabelLine');
|
|
43627
|
+
var labelAlignTo = labelModel.get('alignTo');
|
|
43628
|
+
var labelMargin = parsePercent$1(labelModel.get('margin'), viewWidth);
|
|
43629
|
+
var bleedMargin = labelModel.get('bleedMargin');
|
|
43630
|
+
var font = labelModel.getFont();
|
|
42396
43631
|
|
|
42397
43632
|
var labelLineModel = itemModel.getModel('labelLine');
|
|
42398
43633
|
var labelLineLen = labelLineModel.get('length');
|
|
43634
|
+
labelLineLen = parsePercent$1(labelLineLen, viewWidth);
|
|
42399
43635
|
var labelLineLen2 = labelLineModel.get('length2');
|
|
43636
|
+
labelLineLen2 = parsePercent$1(labelLineLen2, viewWidth);
|
|
42400
43637
|
|
|
42401
43638
|
if (layout.angle < minShowLabelRadian) {
|
|
42402
43639
|
return;
|
|
@@ -42414,6 +43651,12 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42414
43651
|
cx = layout.cx;
|
|
42415
43652
|
cy = layout.cy;
|
|
42416
43653
|
|
|
43654
|
+
var text = seriesModel.getFormattedLabel(idx, 'normal')
|
|
43655
|
+
|| data.getName(idx);
|
|
43656
|
+
var textRect = getBoundingRect(
|
|
43657
|
+
text, font, textAlign, 'top'
|
|
43658
|
+
);
|
|
43659
|
+
|
|
42417
43660
|
var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
|
|
42418
43661
|
if (labelPosition === 'center') {
|
|
42419
43662
|
textX = layout.cx;
|
|
@@ -42434,14 +43677,25 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42434
43677
|
var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
|
|
42435
43678
|
var y3 = y2;
|
|
42436
43679
|
|
|
42437
|
-
|
|
43680
|
+
if (labelAlignTo === 'edge') {
|
|
43681
|
+
// Adjust textX because text align of edge is opposite
|
|
43682
|
+
textX = dx < 0
|
|
43683
|
+
? viewLeft + labelMargin
|
|
43684
|
+
: viewLeft + viewWidth - labelMargin;
|
|
43685
|
+
}
|
|
43686
|
+
else {
|
|
43687
|
+
textX = x3 + (dx < 0 ? -labelDistance : labelDistance);
|
|
43688
|
+
}
|
|
42438
43689
|
textY = y3;
|
|
42439
43690
|
linePoints = [[x1, y1], [x2, y2], [x3, y3]];
|
|
42440
43691
|
}
|
|
42441
43692
|
|
|
42442
|
-
textAlign = isLabelInside
|
|
43693
|
+
textAlign = isLabelInside
|
|
43694
|
+
? 'center'
|
|
43695
|
+
: (labelAlignTo === 'edge'
|
|
43696
|
+
? (dx > 0 ? 'right' : 'left')
|
|
43697
|
+
: (dx > 0 ? 'left' : 'right'));
|
|
42443
43698
|
}
|
|
42444
|
-
var font = labelModel.getFont();
|
|
42445
43699
|
|
|
42446
43700
|
var labelRotate;
|
|
42447
43701
|
var rotate = labelModel.get('rotate');
|
|
@@ -42453,11 +43707,7 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42453
43707
|
? (dx < 0 ? -midAngle + Math.PI : -midAngle)
|
|
42454
43708
|
: 0;
|
|
42455
43709
|
}
|
|
42456
|
-
|
|
42457
|
-
|| data.getName(idx);
|
|
42458
|
-
var textRect = getBoundingRect(
|
|
42459
|
-
text, font, textAlign, 'top'
|
|
42460
|
-
);
|
|
43710
|
+
|
|
42461
43711
|
hasLabelRotate = !!labelRotate;
|
|
42462
43712
|
layout.label = {
|
|
42463
43713
|
x: textX,
|
|
@@ -42470,7 +43720,14 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42470
43720
|
textAlign: textAlign,
|
|
42471
43721
|
verticalAlign: 'middle',
|
|
42472
43722
|
rotation: labelRotate,
|
|
42473
|
-
inside: isLabelInside
|
|
43723
|
+
inside: isLabelInside,
|
|
43724
|
+
labelDistance: labelDistance,
|
|
43725
|
+
labelAlignTo: labelAlignTo,
|
|
43726
|
+
labelMargin:labelMargin,
|
|
43727
|
+
bleedMargin: bleedMargin,
|
|
43728
|
+
textRect: textRect,
|
|
43729
|
+
text: text,
|
|
43730
|
+
font: font
|
|
42474
43731
|
};
|
|
42475
43732
|
|
|
42476
43733
|
// Not layout the inside label
|
|
@@ -42479,7 +43736,7 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42479
43736
|
}
|
|
42480
43737
|
});
|
|
42481
43738
|
if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
|
|
42482
|
-
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
|
|
43739
|
+
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
|
|
42483
43740
|
}
|
|
42484
43741
|
};
|
|
42485
43742
|
|
|
@@ -42506,10 +43763,20 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42506
43763
|
var PI2$4 = Math.PI * 2;
|
|
42507
43764
|
var RADIAN = Math.PI / 180;
|
|
42508
43765
|
|
|
43766
|
+
function getViewRect(seriesModel, api) {
|
|
43767
|
+
return getLayoutRect(
|
|
43768
|
+
seriesModel.getBoxLayoutParams(), {
|
|
43769
|
+
width: api.getWidth(),
|
|
43770
|
+
height: api.getHeight()
|
|
43771
|
+
}
|
|
43772
|
+
);
|
|
43773
|
+
}
|
|
43774
|
+
|
|
42509
43775
|
var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
42510
43776
|
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
|
42511
43777
|
var data = seriesModel.getData();
|
|
42512
43778
|
var valueDim = data.mapDimension('value');
|
|
43779
|
+
var viewRect = getViewRect(seriesModel, api);
|
|
42513
43780
|
|
|
42514
43781
|
var center = seriesModel.get('center');
|
|
42515
43782
|
var radius = seriesModel.get('radius');
|
|
@@ -42521,11 +43788,11 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42521
43788
|
center = [center, center];
|
|
42522
43789
|
}
|
|
42523
43790
|
|
|
42524
|
-
var width = api.getWidth();
|
|
42525
|
-
var height = api.getHeight();
|
|
43791
|
+
var width = parsePercent$1(viewRect.width, api.getWidth());
|
|
43792
|
+
var height = parsePercent$1(viewRect.height, api.getHeight());
|
|
42526
43793
|
var size = Math.min(width, height);
|
|
42527
|
-
var cx = parsePercent$1(center[0], width);
|
|
42528
|
-
var cy = parsePercent$1(center[1], height);
|
|
43794
|
+
var cx = parsePercent$1(center[0], width) + viewRect.x;
|
|
43795
|
+
var cy = parsePercent$1(center[1], height) + viewRect.y;
|
|
42529
43796
|
var r0 = parsePercent$1(radius[0], size / 2);
|
|
42530
43797
|
var r = parsePercent$1(radius[1], size / 2);
|
|
42531
43798
|
|
|
@@ -42571,7 +43838,8 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42571
43838
|
r0: r0,
|
|
42572
43839
|
r: roseType
|
|
42573
43840
|
? NaN
|
|
42574
|
-
: r
|
|
43841
|
+
: r,
|
|
43842
|
+
viewRect: viewRect
|
|
42575
43843
|
});
|
|
42576
43844
|
return;
|
|
42577
43845
|
}
|
|
@@ -42604,7 +43872,8 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42604
43872
|
r0: r0,
|
|
42605
43873
|
r: roseType
|
|
42606
43874
|
? linearMap(value, extent, [r0, r])
|
|
42607
|
-
: r
|
|
43875
|
+
: r,
|
|
43876
|
+
viewRect: viewRect
|
|
42608
43877
|
});
|
|
42609
43878
|
|
|
42610
43879
|
currentAngle = endAngle;
|
|
@@ -42642,7 +43911,7 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42642
43911
|
}
|
|
42643
43912
|
}
|
|
42644
43913
|
|
|
42645
|
-
labelLayout(seriesModel, r, width, height);
|
|
43914
|
+
labelLayout(seriesModel, r, viewRect.width, viewRect.height, viewRect.x, viewRect.y);
|
|
42646
43915
|
});
|
|
42647
43916
|
};
|
|
42648
43917
|
|