echarts 4.5.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/dist/echarts-en.common.js +1790 -774
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +2029 -849
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +1676 -691
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +1790 -774
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +2029 -849
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +1676 -691
- package/dist/echarts.simple.min.js +1 -1
- package/lib/chart/bar/BarView.js +11 -1
- package/lib/chart/bar/BaseBarSeries.js +3 -1
- package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
- package/lib/chart/funnel/FunnelSeries.js +15 -5
- package/lib/chart/gauge/GaugeSeries.js +0 -2
- package/lib/chart/graph/GraphSeries.js +9 -4
- package/lib/chart/graph/GraphView.js +28 -8
- package/lib/chart/heatmap/HeatmapView.js +4 -4
- 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/component/axis/AngleAxisView.js +64 -7
- 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/dataZoom/SliderZoomView.js +4 -10
- package/lib/component/helper/BrushController.js +33 -43
- package/lib/component/legend/LegendModel.js +3 -3
- package/lib/component/legend/LegendView.js +17 -13
- package/lib/component/toolbox/ToolboxView.js +5 -1
- package/lib/component/toolbox/feature/MagicType.js +19 -14
- package/lib/coord/Axis.js +30 -2
- package/lib/coord/axisDefault.js +21 -2
- package/lib/data/DataDimensionInfo.js +157 -0
- package/lib/data/List.js +25 -19
- 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 +2 -3
- 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/visual/LegendVisualProvider.js +75 -0
- package/lib/visual/dataColor.js +2 -12
- package/lib/visual/seriesColor.js +15 -7
- package/map/json/province/tianjin.json +1 -1
- package/package.json +3 -2
- package/src/chart/bar/BarView.js +12 -2
- package/src/chart/bar/BaseBarSeries.js +1 -1
- package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
- package/src/chart/funnel/FunnelSeries.js +11 -4
- package/src/chart/gauge/GaugeSeries.js +0 -1
- package/src/chart/graph/GraphSeries.js +8 -3
- package/src/chart/graph/GraphView.js +26 -8
- package/src/chart/heatmap/HeatmapView.js +4 -4
- 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/component/axis/AngleAxisView.js +75 -7
- 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/dataZoom/SliderZoomView.js +4 -9
- package/src/component/helper/BrushController.js +40 -47
- package/src/component/legend/LegendModel.js +3 -3
- package/src/component/legend/LegendView.js +18 -12
- package/src/component/toolbox/ToolboxView.js +5 -0
- package/src/component/toolbox/feature/MagicType.js +18 -13
- package/src/coord/Axis.js +29 -2
- package/src/coord/axisDefault.js +25 -1
- package/src/data/DataDimensionInfo.js +135 -0
- package/src/data/List.js +29 -16
- 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 +6 -3
- 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/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/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
|
|
|
@@ -10511,30 +10620,55 @@ Animation.prototype = {
|
|
|
10511
10620
|
|
|
10512
10621
|
mixin(Animation, Eventful);
|
|
10513
10622
|
|
|
10623
|
+
/* global document */
|
|
10624
|
+
|
|
10514
10625
|
var TOUCH_CLICK_DELAY = 300;
|
|
10515
10626
|
|
|
10516
|
-
var
|
|
10517
|
-
'click', 'dblclick', 'mousewheel', 'mouseout',
|
|
10518
|
-
'mouseup', 'mousedown', 'mousemove', 'contextmenu'
|
|
10519
|
-
];
|
|
10627
|
+
var globalEventSupported = env$1.domSupported;
|
|
10520
10628
|
|
|
10521
|
-
var touchHandlerNames = [
|
|
10522
|
-
'touchstart', 'touchend', 'touchmove'
|
|
10523
|
-
];
|
|
10524
10629
|
|
|
10525
|
-
var
|
|
10526
|
-
|
|
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']
|
|
10527
10656
|
};
|
|
10528
10657
|
|
|
10529
|
-
var pointerHandlerNames = map(mouseHandlerNames, function (name) {
|
|
10530
|
-
var nm = name.replace('mouse', 'pointer');
|
|
10531
|
-
return pointerEventNames[nm] ? nm : name;
|
|
10532
|
-
});
|
|
10533
10658
|
|
|
10534
10659
|
function eventNameFix(name) {
|
|
10535
10660
|
return (name === 'mousewheel' && env$1.browser.firefox) ? 'DOMMouseScroll' : name;
|
|
10536
10661
|
}
|
|
10537
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
|
+
|
|
10538
10672
|
// function onMSGestureChange(proxy, event) {
|
|
10539
10673
|
// if (event.translationX || event.translationY) {
|
|
10540
10674
|
// // mousemove is carried by MSGesture to reduce the sensitivity.
|
|
@@ -10554,117 +10688,174 @@ function eventNameFix(name) {
|
|
|
10554
10688
|
* 1. Mobile browsers dispatch mouse events 300ms after touchend.
|
|
10555
10689
|
* 2. Chrome for Android dispatch mousedown for long-touch about 650ms
|
|
10556
10690
|
* Result: Blocking Mouse Events for 700ms.
|
|
10691
|
+
*
|
|
10692
|
+
* @param {DOMHandlerScope} scope
|
|
10557
10693
|
*/
|
|
10558
|
-
function setTouchTimer(
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
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;
|
|
10563
10703
|
}, 700);
|
|
10564
10704
|
}
|
|
10565
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
|
+
},
|
|
10566
10779
|
|
|
10567
|
-
var domHandlers = {
|
|
10568
|
-
/**
|
|
10569
|
-
* Mouse move handler
|
|
10570
|
-
* @inner
|
|
10571
|
-
* @param {Event} event
|
|
10572
|
-
*/
|
|
10573
10780
|
mousemove: function (event) {
|
|
10574
10781
|
event = normalizeEvent(this.dom, event);
|
|
10575
10782
|
|
|
10783
|
+
var downPoint = this._mayPointerCapture;
|
|
10784
|
+
if (downPoint && (event.zrX !== downPoint[0] || event.zrY !== downPoint[1])) {
|
|
10785
|
+
togglePointerCapture(this, true);
|
|
10786
|
+
}
|
|
10787
|
+
|
|
10576
10788
|
this.trigger('mousemove', event);
|
|
10577
10789
|
},
|
|
10578
10790
|
|
|
10579
|
-
|
|
10580
|
-
* Mouse out handler
|
|
10581
|
-
* @inner
|
|
10582
|
-
* @param {Event} event
|
|
10583
|
-
*/
|
|
10584
|
-
mouseout: function (event) {
|
|
10791
|
+
mouseup: function (event) {
|
|
10585
10792
|
event = normalizeEvent(this.dom, event);
|
|
10586
10793
|
|
|
10587
|
-
|
|
10588
|
-
if (element !== this.dom) {
|
|
10589
|
-
while (element && element.nodeType !== 9) {
|
|
10590
|
-
// 忽略包含在root中的dom引起的mouseOut
|
|
10591
|
-
if (element === this.dom) {
|
|
10592
|
-
return;
|
|
10593
|
-
}
|
|
10794
|
+
togglePointerCapture(this, false);
|
|
10594
10795
|
|
|
10595
|
-
|
|
10596
|
-
|
|
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';
|
|
10597
10806
|
}
|
|
10598
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
|
+
|
|
10599
10816
|
this.trigger('mouseout', event);
|
|
10600
10817
|
},
|
|
10601
10818
|
|
|
10602
|
-
/**
|
|
10603
|
-
* Touch开始响应函数
|
|
10604
|
-
* @inner
|
|
10605
|
-
* @param {Event} event
|
|
10606
|
-
*/
|
|
10607
10819
|
touchstart: function (event) {
|
|
10608
10820
|
// Default mouse behaviour should not be disabled here.
|
|
10609
10821
|
// For example, page may needs to be slided.
|
|
10610
10822
|
event = normalizeEvent(this.dom, event);
|
|
10611
10823
|
|
|
10612
|
-
|
|
10613
|
-
// mouse event in upper applicatoin.
|
|
10614
|
-
event.zrByTouch = true;
|
|
10824
|
+
markTouch(event);
|
|
10615
10825
|
|
|
10616
10826
|
this._lastTouchMoment = new Date();
|
|
10617
10827
|
|
|
10618
10828
|
this.handler.processGesture(event, 'start');
|
|
10619
10829
|
|
|
10620
|
-
//
|
|
10621
|
-
//
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
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);
|
|
10627
10836
|
},
|
|
10628
10837
|
|
|
10629
|
-
/**
|
|
10630
|
-
* Touch移动响应函数
|
|
10631
|
-
* @inner
|
|
10632
|
-
* @param {Event} event
|
|
10633
|
-
*/
|
|
10634
10838
|
touchmove: function (event) {
|
|
10635
|
-
|
|
10636
10839
|
event = normalizeEvent(this.dom, event);
|
|
10637
10840
|
|
|
10638
|
-
|
|
10639
|
-
// mouse event in upper applicatoin.
|
|
10640
|
-
event.zrByTouch = true;
|
|
10841
|
+
markTouch(event);
|
|
10641
10842
|
|
|
10642
10843
|
this.handler.processGesture(event, 'change');
|
|
10643
10844
|
|
|
10644
10845
|
// Mouse move should always be triggered no matter whether
|
|
10645
10846
|
// there is gestrue event, because mouse move and pinch may
|
|
10646
10847
|
// be used at the same time.
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
setTouchTimer(this);
|
|
10848
|
+
localDOMHandlers.mousemove.call(this, event);
|
|
10650
10849
|
},
|
|
10651
10850
|
|
|
10652
|
-
/**
|
|
10653
|
-
* Touch结束响应函数
|
|
10654
|
-
* @inner
|
|
10655
|
-
* @param {Event} event
|
|
10656
|
-
*/
|
|
10657
10851
|
touchend: function (event) {
|
|
10658
|
-
|
|
10659
10852
|
event = normalizeEvent(this.dom, event);
|
|
10660
10853
|
|
|
10661
|
-
|
|
10662
|
-
// mouse event in upper applicatoin.
|
|
10663
|
-
event.zrByTouch = true;
|
|
10854
|
+
markTouch(event);
|
|
10664
10855
|
|
|
10665
10856
|
this.handler.processGesture(event, 'end');
|
|
10666
10857
|
|
|
10667
|
-
|
|
10858
|
+
localDOMHandlers.mouseup.call(this, event);
|
|
10668
10859
|
|
|
10669
10860
|
// Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
|
|
10670
10861
|
// triggered in `touchstart`. This seems to be illogical, but by this mechanism,
|
|
@@ -10677,14 +10868,12 @@ var domHandlers = {
|
|
|
10677
10868
|
// click event should always be triggered no matter whether
|
|
10678
10869
|
// there is gestrue event. System click can not be prevented.
|
|
10679
10870
|
if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
|
|
10680
|
-
|
|
10871
|
+
localDOMHandlers.click.call(this, event);
|
|
10681
10872
|
}
|
|
10682
|
-
|
|
10683
|
-
setTouchTimer(this);
|
|
10684
10873
|
},
|
|
10685
10874
|
|
|
10686
10875
|
pointerdown: function (event) {
|
|
10687
|
-
|
|
10876
|
+
localDOMHandlers.mousedown.call(this, event);
|
|
10688
10877
|
|
|
10689
10878
|
// if (useMSGuesture(this, event)) {
|
|
10690
10879
|
// this._msGesture.addPointer(event.pointerId);
|
|
@@ -10698,12 +10887,12 @@ var domHandlers = {
|
|
|
10698
10887
|
// upper application. So, we dont support mousemove on MS touch
|
|
10699
10888
|
// device yet.
|
|
10700
10889
|
if (!isPointerFromTouch(event)) {
|
|
10701
|
-
|
|
10890
|
+
localDOMHandlers.mousemove.call(this, event);
|
|
10702
10891
|
}
|
|
10703
10892
|
},
|
|
10704
10893
|
|
|
10705
10894
|
pointerup: function (event) {
|
|
10706
|
-
|
|
10895
|
+
localDOMHandlers.mouseup.call(this, event);
|
|
10707
10896
|
},
|
|
10708
10897
|
|
|
10709
10898
|
pointerout: function (event) {
|
|
@@ -10711,80 +10900,77 @@ var domHandlers = {
|
|
|
10711
10900
|
// (IE11+/Edge on MS Surface) after click event triggered,
|
|
10712
10901
|
// which is inconsistent with the mousout behavior we defined
|
|
10713
10902
|
// in touchend. So we unify them.
|
|
10714
|
-
// (check
|
|
10903
|
+
// (check localDOMHandlers.touchend for detailed explanation)
|
|
10715
10904
|
if (!isPointerFromTouch(event)) {
|
|
10716
|
-
|
|
10905
|
+
localDOMHandlers.mouseout.call(this, event);
|
|
10717
10906
|
}
|
|
10718
10907
|
}
|
|
10719
|
-
};
|
|
10720
|
-
|
|
10721
|
-
function isPointerFromTouch(event) {
|
|
10722
|
-
var pointerType = event.pointerType;
|
|
10723
|
-
return pointerType === 'pen' || pointerType === 'touch';
|
|
10724
|
-
}
|
|
10725
10908
|
|
|
10726
|
-
|
|
10727
|
-
// return isPointerFromTouch(event) && !!handlerProxy._msGesture;
|
|
10728
|
-
// }
|
|
10909
|
+
};
|
|
10729
10910
|
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
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) {
|
|
10733
10917
|
event = normalizeEvent(this.dom, event);
|
|
10734
10918
|
this.trigger(name, event);
|
|
10735
10919
|
};
|
|
10736
10920
|
});
|
|
10737
10921
|
|
|
10922
|
+
|
|
10738
10923
|
/**
|
|
10739
|
-
*
|
|
10924
|
+
* DOM UI Event handlers for global page.
|
|
10740
10925
|
*
|
|
10741
|
-
*
|
|
10742
|
-
*
|
|
10926
|
+
* [Caution]:
|
|
10927
|
+
* those handlers should both support in capture phase and bubble phase!
|
|
10928
|
+
*
|
|
10929
|
+
* @this {HandlerProxy}
|
|
10743
10930
|
*/
|
|
10744
|
-
|
|
10745
|
-
each$1(touchHandlerNames, function (name) {
|
|
10746
|
-
instance._handlers[name] = bind(domHandlers[name], instance);
|
|
10747
|
-
});
|
|
10931
|
+
var globalDOMHandlers = {
|
|
10748
10932
|
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
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
|
+
},
|
|
10752
10943
|
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
}
|
|
10944
|
+
pointerup: function (event) {
|
|
10945
|
+
globalDOMHandlers.mouseup.call(this, event);
|
|
10946
|
+
},
|
|
10756
10947
|
|
|
10757
|
-
function
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
return;
|
|
10761
|
-
}
|
|
10762
|
-
return fn.apply(instance, arguments);
|
|
10763
|
-
};
|
|
10764
|
-
}
|
|
10765
|
-
}
|
|
10948
|
+
mousemove: function (event) {
|
|
10949
|
+
this.trigger('mousemove', event);
|
|
10950
|
+
},
|
|
10766
10951
|
|
|
10952
|
+
mouseup: function (event) {
|
|
10953
|
+
var pointerCaptureReleasing = this._pointerCapturing;
|
|
10767
10954
|
|
|
10768
|
-
|
|
10769
|
-
Eventful.call(this);
|
|
10955
|
+
togglePointerCapture(this, false);
|
|
10770
10956
|
|
|
10771
|
-
|
|
10957
|
+
this.trigger('mouseup', event);
|
|
10772
10958
|
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10959
|
+
if (pointerCaptureReleasing) {
|
|
10960
|
+
event.zrEventControl = 'only_globalout';
|
|
10961
|
+
this.trigger('mouseout', event);
|
|
10962
|
+
}
|
|
10963
|
+
}
|
|
10778
10964
|
|
|
10779
|
-
|
|
10780
|
-
* @private
|
|
10781
|
-
* @type {number}
|
|
10782
|
-
*/
|
|
10783
|
-
this._touchTimer;
|
|
10965
|
+
};
|
|
10784
10966
|
|
|
10785
|
-
this._handlers = {};
|
|
10786
10967
|
|
|
10787
|
-
|
|
10968
|
+
/**
|
|
10969
|
+
* @param {HandlerProxy} instance
|
|
10970
|
+
* @param {DOMHandlerScope} scope
|
|
10971
|
+
*/
|
|
10972
|
+
function mountLocalDOMEventListeners(instance, scope) {
|
|
10973
|
+
var domHandlers = scope.domHandlers;
|
|
10788
10974
|
|
|
10789
10975
|
if (env$1.pointerEventsSupported) { // Only IE11+/Edge
|
|
10790
10976
|
// 1. On devices that both enable touch and mouse (e.g., MS Surface and lenovo X240),
|
|
@@ -10793,7 +10979,12 @@ function HandlerDomProxy(dom) {
|
|
|
10793
10979
|
// 2. On MS Surface, it probablely only trigger mousedown but no mouseup when tap on
|
|
10794
10980
|
// screen, which do not occurs in pointer event.
|
|
10795
10981
|
// So we use pointer event to both detect touch gesture and mouse behavior.
|
|
10796
|
-
|
|
10982
|
+
each$1(localNativeListenerNames.pointer, function (nativeEventName) {
|
|
10983
|
+
mountSingleDOMEventListener(scope, nativeEventName, function (event) {
|
|
10984
|
+
// markTriggeredFromLocal(event);
|
|
10985
|
+
domHandlers[nativeEventName].call(instance, event);
|
|
10986
|
+
});
|
|
10987
|
+
});
|
|
10797
10988
|
|
|
10798
10989
|
// FIXME
|
|
10799
10990
|
// Note: MS Gesture require CSS touch-action set. But touch-action is not reliable,
|
|
@@ -10812,7 +11003,13 @@ function HandlerDomProxy(dom) {
|
|
|
10812
11003
|
}
|
|
10813
11004
|
else {
|
|
10814
11005
|
if (env$1.touchEventsSupported) {
|
|
10815
|
-
|
|
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
|
+
});
|
|
10816
11013
|
// Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
|
|
10817
11014
|
// addEventListener(root, 'mouseout', this._mouseoutHandler);
|
|
10818
11015
|
}
|
|
@@ -10822,23 +11019,145 @@ function HandlerDomProxy(dom) {
|
|
|
10822
11019
|
// mouse event can not be handle in those devices.
|
|
10823
11020
|
// 2. On MS Surface, Chrome will trigger both touch event and mouse event. How to prevent
|
|
10824
11021
|
// mouseevent after touch event triggered, see `setTouchTimer`.
|
|
10825
|
-
|
|
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
|
+
});
|
|
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);
|
|
10826
11107
|
}
|
|
11108
|
+
}
|
|
11109
|
+
|
|
11110
|
+
/**
|
|
11111
|
+
* @inner
|
|
11112
|
+
* @class
|
|
11113
|
+
*/
|
|
11114
|
+
function DOMHandlerScope(domTarget, domHandlers) {
|
|
11115
|
+
this.domTarget = domTarget;
|
|
11116
|
+
this.domHandlers = domHandlers;
|
|
11117
|
+
|
|
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;
|
|
10827
11136
|
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
11137
|
+
this._localHandlerScope = new DOMHandlerScope(dom, localDOMHandlers);
|
|
11138
|
+
|
|
11139
|
+
if (globalEventSupported) {
|
|
11140
|
+
this._globalHandlerScope = new DOMHandlerScope(document, globalDOMHandlers);
|
|
10832
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);
|
|
10833
11153
|
}
|
|
10834
11154
|
|
|
10835
11155
|
var handlerDomProxyProto = HandlerDomProxy.prototype;
|
|
10836
|
-
handlerDomProxyProto.dispose = function () {
|
|
10837
|
-
var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
|
|
10838
11156
|
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
11157
|
+
handlerDomProxyProto.dispose = function () {
|
|
11158
|
+
unmountDOMEventListeners(this._localHandlerScope);
|
|
11159
|
+
if (globalEventSupported) {
|
|
11160
|
+
unmountDOMEventListeners(this._globalHandlerScope);
|
|
10842
11161
|
}
|
|
10843
11162
|
};
|
|
10844
11163
|
|
|
@@ -10846,6 +11165,7 @@ handlerDomProxyProto.setCursor = function (cursorStyle) {
|
|
|
10846
11165
|
this.dom.style && (this.dom.style.cursor = cursorStyle || 'default');
|
|
10847
11166
|
};
|
|
10848
11167
|
|
|
11168
|
+
|
|
10849
11169
|
mixin(HandlerDomProxy, Eventful);
|
|
10850
11170
|
|
|
10851
11171
|
/*!
|
|
@@ -10867,7 +11187,7 @@ var painterCtors = {
|
|
|
10867
11187
|
/**
|
|
10868
11188
|
* @type {string}
|
|
10869
11189
|
*/
|
|
10870
|
-
var version$1 = '4.
|
|
11190
|
+
var version$1 = '4.2.0';
|
|
10871
11191
|
|
|
10872
11192
|
/**
|
|
10873
11193
|
* Initializing a zrender instance
|
|
@@ -10946,7 +11266,7 @@ var ZRender = function (id, dom, opts) {
|
|
|
10946
11266
|
this.storage = storage;
|
|
10947
11267
|
this.painter = painter;
|
|
10948
11268
|
|
|
10949
|
-
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;
|
|
10950
11270
|
this.handler = new Handler(storage, painter, handerProxy, painter.root);
|
|
10951
11271
|
|
|
10952
11272
|
/**
|
|
@@ -17425,8 +17745,7 @@ function rollbackDefaultTextStyle(style) {
|
|
|
17425
17745
|
}
|
|
17426
17746
|
|
|
17427
17747
|
function getFont(opt, ecModel) {
|
|
17428
|
-
|
|
17429
|
-
var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
|
|
17748
|
+
var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
|
|
17430
17749
|
return trim([
|
|
17431
17750
|
// FIXME in node-canvas fontWeight is before fontStyle
|
|
17432
17751
|
opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
|
|
@@ -19946,178 +20265,6 @@ var colorPaletteMixin = {
|
|
|
19946
20265
|
* under the License.
|
|
19947
20266
|
*/
|
|
19948
20267
|
|
|
19949
|
-
/**
|
|
19950
|
-
* Helper for model references.
|
|
19951
|
-
* There are many manners to refer axis/coordSys.
|
|
19952
|
-
*/
|
|
19953
|
-
|
|
19954
|
-
// TODO
|
|
19955
|
-
// merge relevant logic to this file?
|
|
19956
|
-
// check: "modelHelper" of tooltip and "BrushTargetManager".
|
|
19957
|
-
|
|
19958
|
-
/**
|
|
19959
|
-
* @return {Object} For example:
|
|
19960
|
-
* {
|
|
19961
|
-
* coordSysName: 'cartesian2d',
|
|
19962
|
-
* coordSysDims: ['x', 'y', ...],
|
|
19963
|
-
* axisMap: HashMap({
|
|
19964
|
-
* x: xAxisModel,
|
|
19965
|
-
* y: yAxisModel
|
|
19966
|
-
* }),
|
|
19967
|
-
* categoryAxisMap: HashMap({
|
|
19968
|
-
* x: xAxisModel,
|
|
19969
|
-
* y: undefined
|
|
19970
|
-
* }),
|
|
19971
|
-
* // It also indicate that whether there is category axis.
|
|
19972
|
-
* firstCategoryDimIndex: 1,
|
|
19973
|
-
* // To replace user specified encode.
|
|
19974
|
-
* }
|
|
19975
|
-
*/
|
|
19976
|
-
function getCoordSysDefineBySeries(seriesModel) {
|
|
19977
|
-
var coordSysName = seriesModel.get('coordinateSystem');
|
|
19978
|
-
var result = {
|
|
19979
|
-
coordSysName: coordSysName,
|
|
19980
|
-
coordSysDims: [],
|
|
19981
|
-
axisMap: createHashMap(),
|
|
19982
|
-
categoryAxisMap: createHashMap()
|
|
19983
|
-
};
|
|
19984
|
-
var fetch = fetchers[coordSysName];
|
|
19985
|
-
if (fetch) {
|
|
19986
|
-
fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
|
|
19987
|
-
return result;
|
|
19988
|
-
}
|
|
19989
|
-
}
|
|
19990
|
-
|
|
19991
|
-
var fetchers = {
|
|
19992
|
-
|
|
19993
|
-
cartesian2d: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
19994
|
-
var xAxisModel = seriesModel.getReferringComponents('xAxis')[0];
|
|
19995
|
-
var yAxisModel = seriesModel.getReferringComponents('yAxis')[0];
|
|
19996
|
-
|
|
19997
|
-
if (__DEV__) {
|
|
19998
|
-
if (!xAxisModel) {
|
|
19999
|
-
throw new Error('xAxis "' + retrieve(
|
|
20000
|
-
seriesModel.get('xAxisIndex'),
|
|
20001
|
-
seriesModel.get('xAxisId'),
|
|
20002
|
-
0
|
|
20003
|
-
) + '" not found');
|
|
20004
|
-
}
|
|
20005
|
-
if (!yAxisModel) {
|
|
20006
|
-
throw new Error('yAxis "' + retrieve(
|
|
20007
|
-
seriesModel.get('xAxisIndex'),
|
|
20008
|
-
seriesModel.get('yAxisId'),
|
|
20009
|
-
0
|
|
20010
|
-
) + '" not found');
|
|
20011
|
-
}
|
|
20012
|
-
}
|
|
20013
|
-
|
|
20014
|
-
result.coordSysDims = ['x', 'y'];
|
|
20015
|
-
axisMap.set('x', xAxisModel);
|
|
20016
|
-
axisMap.set('y', yAxisModel);
|
|
20017
|
-
|
|
20018
|
-
if (isCategory(xAxisModel)) {
|
|
20019
|
-
categoryAxisMap.set('x', xAxisModel);
|
|
20020
|
-
result.firstCategoryDimIndex = 0;
|
|
20021
|
-
}
|
|
20022
|
-
if (isCategory(yAxisModel)) {
|
|
20023
|
-
categoryAxisMap.set('y', yAxisModel);
|
|
20024
|
-
result.firstCategoryDimIndex = 1;
|
|
20025
|
-
}
|
|
20026
|
-
},
|
|
20027
|
-
|
|
20028
|
-
singleAxis: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20029
|
-
var singleAxisModel = seriesModel.getReferringComponents('singleAxis')[0];
|
|
20030
|
-
|
|
20031
|
-
if (__DEV__) {
|
|
20032
|
-
if (!singleAxisModel) {
|
|
20033
|
-
throw new Error('singleAxis should be specified.');
|
|
20034
|
-
}
|
|
20035
|
-
}
|
|
20036
|
-
|
|
20037
|
-
result.coordSysDims = ['single'];
|
|
20038
|
-
axisMap.set('single', singleAxisModel);
|
|
20039
|
-
|
|
20040
|
-
if (isCategory(singleAxisModel)) {
|
|
20041
|
-
categoryAxisMap.set('single', singleAxisModel);
|
|
20042
|
-
result.firstCategoryDimIndex = 0;
|
|
20043
|
-
}
|
|
20044
|
-
},
|
|
20045
|
-
|
|
20046
|
-
polar: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20047
|
-
var polarModel = seriesModel.getReferringComponents('polar')[0];
|
|
20048
|
-
var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
|
|
20049
|
-
var angleAxisModel = polarModel.findAxisModel('angleAxis');
|
|
20050
|
-
|
|
20051
|
-
if (__DEV__) {
|
|
20052
|
-
if (!angleAxisModel) {
|
|
20053
|
-
throw new Error('angleAxis option not found');
|
|
20054
|
-
}
|
|
20055
|
-
if (!radiusAxisModel) {
|
|
20056
|
-
throw new Error('radiusAxis option not found');
|
|
20057
|
-
}
|
|
20058
|
-
}
|
|
20059
|
-
|
|
20060
|
-
result.coordSysDims = ['radius', 'angle'];
|
|
20061
|
-
axisMap.set('radius', radiusAxisModel);
|
|
20062
|
-
axisMap.set('angle', angleAxisModel);
|
|
20063
|
-
|
|
20064
|
-
if (isCategory(radiusAxisModel)) {
|
|
20065
|
-
categoryAxisMap.set('radius', radiusAxisModel);
|
|
20066
|
-
result.firstCategoryDimIndex = 0;
|
|
20067
|
-
}
|
|
20068
|
-
if (isCategory(angleAxisModel)) {
|
|
20069
|
-
categoryAxisMap.set('angle', angleAxisModel);
|
|
20070
|
-
result.firstCategoryDimIndex = 1;
|
|
20071
|
-
}
|
|
20072
|
-
},
|
|
20073
|
-
|
|
20074
|
-
geo: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20075
|
-
result.coordSysDims = ['lng', 'lat'];
|
|
20076
|
-
},
|
|
20077
|
-
|
|
20078
|
-
parallel: function (seriesModel, result, axisMap, categoryAxisMap) {
|
|
20079
|
-
var ecModel = seriesModel.ecModel;
|
|
20080
|
-
var parallelModel = ecModel.getComponent(
|
|
20081
|
-
'parallel', seriesModel.get('parallelIndex')
|
|
20082
|
-
);
|
|
20083
|
-
var coordSysDims = result.coordSysDims = parallelModel.dimensions.slice();
|
|
20084
|
-
|
|
20085
|
-
each$1(parallelModel.parallelAxisIndex, function (axisIndex, index) {
|
|
20086
|
-
var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
|
|
20087
|
-
var axisDim = coordSysDims[index];
|
|
20088
|
-
axisMap.set(axisDim, axisModel);
|
|
20089
|
-
|
|
20090
|
-
if (isCategory(axisModel) && result.firstCategoryDimIndex == null) {
|
|
20091
|
-
categoryAxisMap.set(axisDim, axisModel);
|
|
20092
|
-
result.firstCategoryDimIndex = index;
|
|
20093
|
-
}
|
|
20094
|
-
});
|
|
20095
|
-
}
|
|
20096
|
-
};
|
|
20097
|
-
|
|
20098
|
-
function isCategory(axisModel) {
|
|
20099
|
-
return axisModel.get('type') === 'category';
|
|
20100
|
-
}
|
|
20101
|
-
|
|
20102
|
-
/*
|
|
20103
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
20104
|
-
* or more contributor license agreements. See the NOTICE file
|
|
20105
|
-
* distributed with this work for additional information
|
|
20106
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
20107
|
-
* to you under the Apache License, Version 2.0 (the
|
|
20108
|
-
* "License"); you may not use this file except in compliance
|
|
20109
|
-
* with the License. You may obtain a copy of the License at
|
|
20110
|
-
*
|
|
20111
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20112
|
-
*
|
|
20113
|
-
* Unless required by applicable law or agreed to in writing,
|
|
20114
|
-
* software distributed under the License is distributed on an
|
|
20115
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20116
|
-
* KIND, either express or implied. See the License for the
|
|
20117
|
-
* specific language governing permissions and limitations
|
|
20118
|
-
* under the License.
|
|
20119
|
-
*/
|
|
20120
|
-
|
|
20121
20268
|
// Avoid typo.
|
|
20122
20269
|
var SOURCE_FORMAT_ORIGINAL = 'original';
|
|
20123
20270
|
var SOURCE_FORMAT_ARRAY_ROWS = 'arrayRows';
|
|
@@ -20287,6 +20434,13 @@ enableClassCheck(Source);
|
|
|
20287
20434
|
* under the License.
|
|
20288
20435
|
*/
|
|
20289
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
|
+
|
|
20290
20444
|
var inner$3 = makeInner();
|
|
20291
20445
|
|
|
20292
20446
|
/**
|
|
@@ -20420,14 +20574,6 @@ function prepareSource(seriesModel) {
|
|
|
20420
20574
|
data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine
|
|
20421
20575
|
);
|
|
20422
20576
|
|
|
20423
|
-
// Note: dataset option does not have `encode`.
|
|
20424
|
-
var encodeDefine = seriesOption.encode;
|
|
20425
|
-
if (!encodeDefine && datasetModel) {
|
|
20426
|
-
encodeDefine = makeDefaultEncode(
|
|
20427
|
-
seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
|
|
20428
|
-
);
|
|
20429
|
-
}
|
|
20430
|
-
|
|
20431
20577
|
inner$3(seriesModel).source = new Source({
|
|
20432
20578
|
data: data,
|
|
20433
20579
|
fromDataset: fromDataset,
|
|
@@ -20436,7 +20582,8 @@ function prepareSource(seriesModel) {
|
|
|
20436
20582
|
dimensionsDefine: completeResult.dimensionsDefine,
|
|
20437
20583
|
startIndex: completeResult.startIndex,
|
|
20438
20584
|
dimensionsDetectCount: completeResult.dimensionsDetectCount,
|
|
20439
|
-
|
|
20585
|
+
// Note: dataset option does not have `encode`.
|
|
20586
|
+
encodeDefine: seriesOption.encode
|
|
20440
20587
|
});
|
|
20441
20588
|
}
|
|
20442
20589
|
|
|
@@ -20448,7 +20595,6 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
|
|
|
20448
20595
|
|
|
20449
20596
|
var dimensionsDetectCount;
|
|
20450
20597
|
var startIndex;
|
|
20451
|
-
var findPotentialName;
|
|
20452
20598
|
|
|
20453
20599
|
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
|
|
20454
20600
|
// Rule: Most of the first line are string: it is header.
|
|
@@ -20491,13 +20637,11 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
|
|
|
20491
20637
|
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
|
|
20492
20638
|
if (!dimensionsDefine) {
|
|
20493
20639
|
dimensionsDefine = objectRowsCollectDimensions(data);
|
|
20494
|
-
findPotentialName = true;
|
|
20495
20640
|
}
|
|
20496
20641
|
}
|
|
20497
20642
|
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
|
|
20498
20643
|
if (!dimensionsDefine) {
|
|
20499
20644
|
dimensionsDefine = [];
|
|
20500
|
-
findPotentialName = true;
|
|
20501
20645
|
each$1(data, function (colArr, key) {
|
|
20502
20646
|
dimensionsDefine.push(key);
|
|
20503
20647
|
});
|
|
@@ -20513,21 +20657,10 @@ function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader,
|
|
|
20513
20657
|
}
|
|
20514
20658
|
}
|
|
20515
20659
|
|
|
20516
|
-
var potentialNameDimIndex;
|
|
20517
|
-
if (findPotentialName) {
|
|
20518
|
-
each$1(dimensionsDefine, function (dim, idx) {
|
|
20519
|
-
if ((isObject$1(dim) ? dim.name : dim) === 'name') {
|
|
20520
|
-
potentialNameDimIndex = idx;
|
|
20521
|
-
}
|
|
20522
|
-
});
|
|
20523
|
-
}
|
|
20524
|
-
|
|
20525
20660
|
return {
|
|
20526
20661
|
startIndex: startIndex,
|
|
20527
20662
|
dimensionsDefine: normalizeDimensionsDefine(dimensionsDefine),
|
|
20528
|
-
dimensionsDetectCount: dimensionsDetectCount
|
|
20529
|
-
potentialNameDimIndex: potentialNameDimIndex
|
|
20530
|
-
// TODO: potentialIdDimIdx
|
|
20663
|
+
dimensionsDetectCount: dimensionsDetectCount
|
|
20531
20664
|
};
|
|
20532
20665
|
}
|
|
20533
20666
|
|
|
@@ -20601,107 +20734,202 @@ function objectRowsCollectDimensions(data) {
|
|
|
20601
20734
|
}
|
|
20602
20735
|
}
|
|
20603
20736
|
|
|
20604
|
-
|
|
20605
|
-
|
|
20606
|
-
|
|
20607
|
-
|
|
20608
|
-
|
|
20609
|
-
|
|
20610
|
-
|
|
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) {
|
|
20611
20756
|
var encode = {};
|
|
20612
|
-
|
|
20613
|
-
|
|
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
|
+
|
|
20614
20764
|
var encodeItemName = [];
|
|
20615
20765
|
var encodeSeriesName = [];
|
|
20616
|
-
var seriesType = seriesModel.subType;
|
|
20617
|
-
|
|
20618
|
-
// ??? TODO refactor: provide by series itself.
|
|
20619
|
-
// Consider the case: 'map' series is based on geo coordSys,
|
|
20620
|
-
// 'graph', 'heatmap' can be based on cartesian. But can not
|
|
20621
|
-
// give default rule simply here.
|
|
20622
|
-
var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
|
|
20623
|
-
var cSeriesMap = createHashMap([
|
|
20624
|
-
'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
|
|
20625
|
-
]);
|
|
20626
|
-
|
|
20627
|
-
// Usually in this case series will use the first data
|
|
20628
|
-
// dimension as the "value" dimension, or other default
|
|
20629
|
-
// processes respectively.
|
|
20630
|
-
if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
|
|
20631
|
-
var ecModel = seriesModel.ecModel;
|
|
20632
|
-
var datasetMap = inner$3(ecModel).datasetMap;
|
|
20633
|
-
var key = datasetModel.uid + '_' + seriesLayoutBy;
|
|
20634
|
-
var datasetRecord = datasetMap.get(key)
|
|
20635
|
-
|| datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});
|
|
20636
20766
|
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
|
|
20643
|
-
|
|
20644
|
-
|
|
20645
|
-
|
|
20646
|
-
|
|
20647
|
-
|
|
20648
|
-
|
|
20649
|
-
|
|
20650
|
-
|
|
20651
|
-
|
|
20652
|
-
|
|
20653
|
-
|
|
20654
|
-
|
|
20655
|
-
|
|
20656
|
-
|
|
20657
|
-
|
|
20658
|
-
|
|
20659
|
-
|
|
20660
|
-
|
|
20661
|
-
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20665
|
-
|
|
20666
|
-
|
|
20667
|
-
|
|
20668
|
-
|
|
20669
|
-
|
|
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
|
+
}
|
|
20670
20824
|
}
|
|
20671
|
-
|
|
20672
|
-
|
|
20673
|
-
|
|
20674
|
-
|
|
20675
|
-
|
|
20676
|
-
|
|
20677
|
-
for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
|
|
20678
|
-
if (!doGuessOrdinal(
|
|
20679
|
-
data, sourceFormat, seriesLayoutBy,
|
|
20680
|
-
completeResult.dimensionsDefine, completeResult.startIndex, i
|
|
20681
|
-
)) {
|
|
20682
|
-
firstNotOrdinal = i;
|
|
20683
|
-
}
|
|
20684
|
-
}
|
|
20685
|
-
if (firstNotOrdinal != null) {
|
|
20686
|
-
encode.value = firstNotOrdinal;
|
|
20687
|
-
var nameDimIndex = completeResult.potentialNameDimIndex
|
|
20688
|
-
|| Math.max(firstNotOrdinal - 1, 0);
|
|
20689
|
-
// By default, label use itemName in charts.
|
|
20690
|
-
// So we dont set encodeLabel here.
|
|
20691
|
-
encodeSeriesName.push(nameDimIndex);
|
|
20692
|
-
encodeItemName.push(nameDimIndex);
|
|
20693
|
-
// encodeTooltip.push(firstNotOrdinal);
|
|
20694
|
-
}
|
|
20695
|
-
}
|
|
20696
|
-
|
|
20697
|
-
// encodeTooltip.length && (encode.tooltip = encodeTooltip);
|
|
20698
|
-
// encodeLabel.length && (encode.label = encodeLabel);
|
|
20825
|
+
|
|
20826
|
+
function getDataDimCountOnCoordDim(coordDimInfo) {
|
|
20827
|
+
var dimsDef = coordDimInfo.dimsDef;
|
|
20828
|
+
return dimsDef ? dimsDef.length : 1;
|
|
20829
|
+
}
|
|
20830
|
+
|
|
20699
20831
|
encodeItemName.length && (encode.itemName = encodeItemName);
|
|
20700
20832
|
encodeSeriesName.length && (encode.seriesName = encodeSeriesName);
|
|
20701
20833
|
|
|
20702
20834
|
return encode;
|
|
20703
20835
|
}
|
|
20704
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
|
+
|
|
20705
20933
|
/**
|
|
20706
20934
|
* If return null/undefined, indicate that should not use datasetModel.
|
|
20707
20935
|
*/
|
|
@@ -20725,7 +20953,7 @@ function getDatasetModel(seriesModel) {
|
|
|
20725
20953
|
*
|
|
20726
20954
|
* @param {module:echars/data/Source} source
|
|
20727
20955
|
* @param {number} dimIndex
|
|
20728
|
-
* @return {
|
|
20956
|
+
* @return {BE_ORDINAL} guess result.
|
|
20729
20957
|
*/
|
|
20730
20958
|
function guessOrdinal(source, dimIndex) {
|
|
20731
20959
|
return doGuessOrdinal(
|
|
@@ -20739,6 +20967,7 @@ function guessOrdinal(source, dimIndex) {
|
|
|
20739
20967
|
}
|
|
20740
20968
|
|
|
20741
20969
|
// dimIndex may be overflow source data.
|
|
20970
|
+
// return {BE_ORDINAL}
|
|
20742
20971
|
function doGuessOrdinal(
|
|
20743
20972
|
data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
|
|
20744
20973
|
) {
|
|
@@ -20747,15 +20976,26 @@ function doGuessOrdinal(
|
|
|
20747
20976
|
var maxLoop = 5;
|
|
20748
20977
|
|
|
20749
20978
|
if (isTypedArray(data)) {
|
|
20750
|
-
return
|
|
20979
|
+
return BE_ORDINAL.Not;
|
|
20751
20980
|
}
|
|
20752
20981
|
|
|
20753
20982
|
// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
|
|
20754
20983
|
// always exists in source.
|
|
20755
20984
|
var dimName;
|
|
20985
|
+
var dimType;
|
|
20756
20986
|
if (dimensionsDefine) {
|
|
20757
|
-
|
|
20758
|
-
|
|
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;
|
|
20759
20999
|
}
|
|
20760
21000
|
|
|
20761
21001
|
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
|
|
@@ -20778,7 +21018,7 @@ function doGuessOrdinal(
|
|
|
20778
21018
|
}
|
|
20779
21019
|
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
|
|
20780
21020
|
if (!dimName) {
|
|
20781
|
-
return;
|
|
21021
|
+
return BE_ORDINAL.Not;
|
|
20782
21022
|
}
|
|
20783
21023
|
for (var i = 0; i < data.length && i < maxLoop; i++) {
|
|
20784
21024
|
var item = data[i];
|
|
@@ -20789,11 +21029,11 @@ function doGuessOrdinal(
|
|
|
20789
21029
|
}
|
|
20790
21030
|
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
|
|
20791
21031
|
if (!dimName) {
|
|
20792
|
-
return;
|
|
21032
|
+
return BE_ORDINAL.Not;
|
|
20793
21033
|
}
|
|
20794
21034
|
var sample = data[dimName];
|
|
20795
21035
|
if (!sample || isTypedArray(sample)) {
|
|
20796
|
-
return
|
|
21036
|
+
return BE_ORDINAL.Not;
|
|
20797
21037
|
}
|
|
20798
21038
|
for (var i = 0; i < sample.length && i < maxLoop; i++) {
|
|
20799
21039
|
if ((result = detectValue(sample[i])) != null) {
|
|
@@ -20806,7 +21046,7 @@ function doGuessOrdinal(
|
|
|
20806
21046
|
var item = data[i];
|
|
20807
21047
|
var val = getDataItemValue(item);
|
|
20808
21048
|
if (!isArray(val)) {
|
|
20809
|
-
return
|
|
21049
|
+
return BE_ORDINAL.Not;
|
|
20810
21050
|
}
|
|
20811
21051
|
if ((result = detectValue(val[dimIndex])) != null) {
|
|
20812
21052
|
return result;
|
|
@@ -20815,17 +21055,18 @@ function doGuessOrdinal(
|
|
|
20815
21055
|
}
|
|
20816
21056
|
|
|
20817
21057
|
function detectValue(val) {
|
|
21058
|
+
var beStr = isString(val);
|
|
20818
21059
|
// Consider usage convenience, '1', '2' will be treated as "number".
|
|
20819
21060
|
// `isFinit('')` get `true`.
|
|
20820
21061
|
if (val != null && isFinite(val) && val !== '') {
|
|
20821
|
-
return
|
|
21062
|
+
return beStr ? BE_ORDINAL.Might : BE_ORDINAL.Not;
|
|
20822
21063
|
}
|
|
20823
|
-
else if (
|
|
20824
|
-
return
|
|
21064
|
+
else if (beStr && val !== '-') {
|
|
21065
|
+
return BE_ORDINAL.Must;
|
|
20825
21066
|
}
|
|
20826
21067
|
}
|
|
20827
21068
|
|
|
20828
|
-
return
|
|
21069
|
+
return BE_ORDINAL.Not;
|
|
20829
21070
|
}
|
|
20830
21071
|
|
|
20831
21072
|
/*
|
|
@@ -23572,11 +23813,11 @@ var SeriesModel = ComponentModel.extend({
|
|
|
23572
23813
|
defaultOption: null,
|
|
23573
23814
|
|
|
23574
23815
|
/**
|
|
23575
|
-
*
|
|
23576
|
-
* @type {
|
|
23816
|
+
* legend visual provider to the legend component
|
|
23817
|
+
* @type {Object}
|
|
23577
23818
|
*/
|
|
23578
23819
|
// PENDING
|
|
23579
|
-
|
|
23820
|
+
legendVisualProvider: null,
|
|
23580
23821
|
|
|
23581
23822
|
/**
|
|
23582
23823
|
* Access path of color for visual
|
|
@@ -24665,25 +24906,30 @@ var seriesColor = {
|
|
|
24665
24906
|
reset: function (seriesModel, ecModel) {
|
|
24666
24907
|
var data = seriesModel.getData();
|
|
24667
24908
|
var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.color').split('.');
|
|
24668
|
-
|
|
24669
|
-
|
|
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(
|
|
24670
24916
|
// TODO series count changed.
|
|
24671
24917
|
seriesModel.name, null, ecModel.getSeriesCount()
|
|
24672
|
-
);
|
|
24918
|
+
);
|
|
24919
|
+
}
|
|
24673
24920
|
|
|
24674
|
-
// FIXME Set color function or use the platte color
|
|
24675
24921
|
data.setVisual('color', color);
|
|
24676
|
-
|
|
24922
|
+
|
|
24677
24923
|
var borderColorAccessPath = (seriesModel.visualBorderColorAccessPath || 'itemStyle.borderColor').split('.');
|
|
24678
24924
|
var borderColor = seriesModel.get(borderColorAccessPath);
|
|
24679
24925
|
data.setVisual('borderColor', borderColor);
|
|
24680
24926
|
|
|
24681
24927
|
// Only visible series has each data be visual encoded
|
|
24682
24928
|
if (!ecModel.isSeriesFiltered(seriesModel)) {
|
|
24683
|
-
if (
|
|
24929
|
+
if (colorCallback) {
|
|
24684
24930
|
data.each(function (idx) {
|
|
24685
24931
|
data.setItemVisual(
|
|
24686
|
-
idx, 'color',
|
|
24932
|
+
idx, 'color', colorCallback(seriesModel.getDataParams(idx))
|
|
24687
24933
|
);
|
|
24688
24934
|
});
|
|
24689
24935
|
}
|
|
@@ -25768,6 +26014,9 @@ var theme = {
|
|
|
25768
26014
|
},
|
|
25769
26015
|
crossStyle: {
|
|
25770
26016
|
color: contrastColor
|
|
26017
|
+
},
|
|
26018
|
+
label: {
|
|
26019
|
+
color: '#000'
|
|
25771
26020
|
}
|
|
25772
26021
|
}
|
|
25773
26022
|
},
|
|
@@ -26738,10 +26987,10 @@ var isFunction = isFunction$1;
|
|
|
26738
26987
|
var isObject = isObject$1;
|
|
26739
26988
|
var parseClassType = ComponentModel.parseClassType;
|
|
26740
26989
|
|
|
26741
|
-
var version = '4.
|
|
26990
|
+
var version = '4.6.0';
|
|
26742
26991
|
|
|
26743
26992
|
var dependencies = {
|
|
26744
|
-
zrender: '4.
|
|
26993
|
+
zrender: '4.2.0'
|
|
26745
26994
|
};
|
|
26746
26995
|
|
|
26747
26996
|
var TEST_FRAME_REMAIN_TIME = 1;
|
|
@@ -29448,6 +29697,138 @@ function mayLabelDimType(dimType) {
|
|
|
29448
29697
|
* under the License.
|
|
29449
29698
|
*/
|
|
29450
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
|
+
|
|
29451
29832
|
/* global Float64Array, Int32Array, Uint32Array, Uint16Array */
|
|
29452
29833
|
|
|
29453
29834
|
/**
|
|
@@ -29525,13 +29906,9 @@ function transferProperties(target, source) {
|
|
|
29525
29906
|
* @constructor
|
|
29526
29907
|
* @alias module:echarts/data/List
|
|
29527
29908
|
*
|
|
29528
|
-
* @param {Array.<string|Object>} dimensions
|
|
29909
|
+
* @param {Array.<string|Object|module:data/DataDimensionInfo>} dimensions
|
|
29529
29910
|
* For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
|
|
29530
29911
|
* Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
|
|
29531
|
-
* Spetial fields: {
|
|
29532
|
-
* ordinalMeta: <module:echarts/data/OrdinalMeta>
|
|
29533
|
-
* createInvertedIndices: <boolean>
|
|
29534
|
-
* }
|
|
29535
29912
|
* @param {module:echarts/model/Model} hostModel
|
|
29536
29913
|
*/
|
|
29537
29914
|
var List = function (dimensions, hostModel) {
|
|
@@ -29547,7 +29924,10 @@ var List = function (dimensions, hostModel) {
|
|
|
29547
29924
|
var dimensionInfo = dimensions[i];
|
|
29548
29925
|
|
|
29549
29926
|
if (isString(dimensionInfo)) {
|
|
29550
|
-
dimensionInfo = {name: dimensionInfo};
|
|
29927
|
+
dimensionInfo = new DataDimensionInfo({name: dimensionInfo});
|
|
29928
|
+
}
|
|
29929
|
+
else if (!(dimensionInfo instanceof DataDimensionInfo)) {
|
|
29930
|
+
dimensionInfo = new DataDimensionInfo(dimensionInfo);
|
|
29551
29931
|
}
|
|
29552
29932
|
|
|
29553
29933
|
var dimensionName = dimensionInfo.name;
|
|
@@ -30567,7 +30947,8 @@ listProto.indexOfRawIndex = function (rawIndex) {
|
|
|
30567
30947
|
* @param {string} dim
|
|
30568
30948
|
* @param {number} value
|
|
30569
30949
|
* @param {number} [maxDistance=Infinity]
|
|
30570
|
-
* @return {Array.<number>}
|
|
30950
|
+
* @return {Array.<number>} If and only if multiple indices has
|
|
30951
|
+
* the same value, they are put to the result.
|
|
30571
30952
|
*/
|
|
30572
30953
|
listProto.indicesOfNearest = function (dim, value, maxDistance) {
|
|
30573
30954
|
var storage = this._storage;
|
|
@@ -30582,23 +30963,35 @@ listProto.indicesOfNearest = function (dim, value, maxDistance) {
|
|
|
30582
30963
|
maxDistance = Infinity;
|
|
30583
30964
|
}
|
|
30584
30965
|
|
|
30585
|
-
var minDist =
|
|
30966
|
+
var minDist = Infinity;
|
|
30586
30967
|
var minDiff = -1;
|
|
30968
|
+
var nearestIndicesLen = 0;
|
|
30969
|
+
|
|
30970
|
+
// Check the test case of `test/ut/spec/data/List.js`.
|
|
30587
30971
|
for (var i = 0, len = this.count(); i < len; i++) {
|
|
30588
|
-
var diff = value - this.get(dim, i
|
|
30972
|
+
var diff = value - this.get(dim, i);
|
|
30589
30973
|
var dist = Math.abs(diff);
|
|
30590
|
-
if (
|
|
30591
|
-
//
|
|
30592
|
-
//
|
|
30593
|
-
//
|
|
30594
|
-
|
|
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
|
+
) {
|
|
30595
30984
|
minDist = dist;
|
|
30596
30985
|
minDiff = diff;
|
|
30597
|
-
|
|
30986
|
+
nearestIndicesLen = 0;
|
|
30987
|
+
}
|
|
30988
|
+
if (diff === minDiff) {
|
|
30989
|
+
nearestIndices[nearestIndicesLen++] = i;
|
|
30598
30990
|
}
|
|
30599
|
-
nearestIndices.push(i);
|
|
30600
30991
|
}
|
|
30601
30992
|
}
|
|
30993
|
+
nearestIndices.length = nearestIndicesLen;
|
|
30994
|
+
|
|
30602
30995
|
return nearestIndices;
|
|
30603
30996
|
};
|
|
30604
30997
|
|
|
@@ -31472,8 +31865,12 @@ listProto.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];
|
|
|
31472
31865
|
/**
|
|
31473
31866
|
* @see {module:echarts/test/ut/spec/data/completeDimensions}
|
|
31474
31867
|
*
|
|
31475
|
-
*
|
|
31476
|
-
*
|
|
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.
|
|
31477
31874
|
* If no 'value' dimension specified, the first no-named dimension will be
|
|
31478
31875
|
* named as 'value'.
|
|
31479
31876
|
*
|
|
@@ -31489,32 +31886,20 @@ listProto.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];
|
|
|
31489
31886
|
* @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
|
|
31490
31887
|
* For example: ['asdf', {name, type}, ...].
|
|
31491
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`.
|
|
31492
31894
|
* @param {string} [opt.generateCoord] Generate coord dim with the given name.
|
|
31493
|
-
*
|
|
31494
|
-
*
|
|
31895
|
+
* If not specified, extra dim names will be:
|
|
31896
|
+
* 'value', 'value0', 'value1', ...
|
|
31495
31897
|
* @param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
|
|
31496
|
-
*
|
|
31497
|
-
*
|
|
31498
|
-
*
|
|
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.
|
|
31499
31901
|
* @param {number} [opt.dimCount] If not specified, guess by the first data item.
|
|
31500
|
-
* @
|
|
31501
|
-
* @return {Array.<Object>} [{
|
|
31502
|
-
* name: string mandatory,
|
|
31503
|
-
* displayName: string, the origin name in dimsDef, see source helper.
|
|
31504
|
-
* If displayName given, the tooltip will displayed vertically.
|
|
31505
|
-
* coordDim: string mandatory,
|
|
31506
|
-
* coordDimIndex: number mandatory,
|
|
31507
|
-
* type: string optional,
|
|
31508
|
-
* otherDims: { never null/undefined
|
|
31509
|
-
* tooltip: number optional,
|
|
31510
|
-
* label: number optional,
|
|
31511
|
-
* itemName: number optional,
|
|
31512
|
-
* seriesName: number optional,
|
|
31513
|
-
* },
|
|
31514
|
-
* isExtraCoord: boolean true if coord is generated
|
|
31515
|
-
* (not specified in encode and not series specified)
|
|
31516
|
-
* other props ...
|
|
31517
|
-
* }]
|
|
31902
|
+
* @return {Array.<module:data/DataDimensionInfo>}
|
|
31518
31903
|
*/
|
|
31519
31904
|
function completeDimensions(sysDims, source, opt) {
|
|
31520
31905
|
if (!Source.isInstance(source)) {
|
|
@@ -31524,7 +31909,6 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31524
31909
|
opt = opt || {};
|
|
31525
31910
|
sysDims = (sysDims || []).slice();
|
|
31526
31911
|
var dimsDef = (opt.dimsDef || []).slice();
|
|
31527
|
-
var encodeDef = createHashMap(opt.encodeDef);
|
|
31528
31912
|
var dataDimNameMap = createHashMap();
|
|
31529
31913
|
var coordDimNameMap = createHashMap();
|
|
31530
31914
|
// var valueCandidate;
|
|
@@ -31538,7 +31922,7 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31538
31922
|
{}, isObject$1(dimsDef[i]) ? dimsDef[i] : {name: dimsDef[i]}
|
|
31539
31923
|
);
|
|
31540
31924
|
var userDimName = dimDefItem.name;
|
|
31541
|
-
var resultItem = result[i] =
|
|
31925
|
+
var resultItem = result[i] = new DataDimensionInfo();
|
|
31542
31926
|
// Name will be applied later for avoiding duplication.
|
|
31543
31927
|
if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
|
|
31544
31928
|
// Only if `series.dimensions` is defined in option
|
|
@@ -31551,6 +31935,12 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31551
31935
|
dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
|
|
31552
31936
|
}
|
|
31553
31937
|
|
|
31938
|
+
var encodeDef = opt.encodeDef;
|
|
31939
|
+
if (!encodeDef && opt.encodeDefaulter) {
|
|
31940
|
+
encodeDef = opt.encodeDefaulter(source, dimCount);
|
|
31941
|
+
}
|
|
31942
|
+
encodeDef = createHashMap(encodeDef);
|
|
31943
|
+
|
|
31554
31944
|
// Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
|
|
31555
31945
|
encodeDef.each(function (dataDims, coordDim) {
|
|
31556
31946
|
dataDims = normalizeToArray(dataDims).slice();
|
|
@@ -31652,7 +32042,7 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31652
32042
|
|
|
31653
32043
|
// Set dim `name` and other `coordDim` and other props.
|
|
31654
32044
|
for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
|
|
31655
|
-
var resultItem = result[resultDimIdx] = result[resultDimIdx] ||
|
|
32045
|
+
var resultItem = result[resultDimIdx] = result[resultDimIdx] || new DataDimensionInfo();
|
|
31656
32046
|
var coordDim = resultItem.coordDim;
|
|
31657
32047
|
|
|
31658
32048
|
if (coordDim == null) {
|
|
@@ -31671,7 +32061,28 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
31671
32061
|
dataDimNameMap
|
|
31672
32062
|
));
|
|
31673
32063
|
|
|
31674
|
-
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
|
+
) {
|
|
31675
32086
|
resultItem.type = 'ordinal';
|
|
31676
32087
|
}
|
|
31677
32088
|
}
|
|
@@ -31749,6 +32160,7 @@ function genName(name, map$$1, fromZero) {
|
|
|
31749
32160
|
* @param {string} [opt.generateCoordCount]
|
|
31750
32161
|
* @param {Array.<string|Object>} [opt.dimensionsDefine=source.dimensionsDefine] Overwrite source define.
|
|
31751
32162
|
* @param {Object|HashMap} [opt.encodeDefine=source.encodeDefine] Overwrite source define.
|
|
32163
|
+
* @param {Function} [opt.encodeDefaulter] Make default encode if user not specified.
|
|
31752
32164
|
* @return {Array.<Object>} dimensionsInfo
|
|
31753
32165
|
*/
|
|
31754
32166
|
var createDimensions = function (source, opt) {
|
|
@@ -31757,6 +32169,7 @@ var createDimensions = function (source, opt) {
|
|
|
31757
32169
|
dimsDef: opt.dimensionsDefine || source.dimensionsDefine,
|
|
31758
32170
|
encodeDef: opt.encodeDefine || source.encodeDefine,
|
|
31759
32171
|
dimCount: opt.dimensionsCount,
|
|
32172
|
+
encodeDefaulter: opt.encodeDefaulter,
|
|
31760
32173
|
generateCoord: opt.generateCoord,
|
|
31761
32174
|
generateCoordCount: opt.generateCoordCount
|
|
31762
32175
|
});
|
|
@@ -31781,6 +32194,201 @@ var createDimensions = function (source, opt) {
|
|
|
31781
32194
|
* under the License.
|
|
31782
32195
|
*/
|
|
31783
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
|
+
|
|
31784
32392
|
/**
|
|
31785
32393
|
* Note that it is too complicated to support 3d stack by value
|
|
31786
32394
|
* (have to create two-dimension inverted index), so in 3d case
|
|
@@ -31947,6 +32555,7 @@ function getStackedDimension(data, targetDim) {
|
|
|
31947
32555
|
* @param {module:echarts/model/Series} seriesModel
|
|
31948
32556
|
* @param {Object} [opt]
|
|
31949
32557
|
* @param {string} [opt.generateCoord]
|
|
32558
|
+
* @param {boolean} [opt.useEncodeDefaulter]
|
|
31950
32559
|
*/
|
|
31951
32560
|
function createListFromArray(source, seriesModel, opt) {
|
|
31952
32561
|
opt = opt || {};
|
|
@@ -31958,14 +32567,14 @@ function createListFromArray(source, seriesModel, opt) {
|
|
|
31958
32567
|
var coordSysName = seriesModel.get('coordinateSystem');
|
|
31959
32568
|
var registeredCoordSys = CoordinateSystemManager.get(coordSysName);
|
|
31960
32569
|
|
|
31961
|
-
var
|
|
32570
|
+
var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
|
|
31962
32571
|
|
|
31963
32572
|
var coordSysDimDefs;
|
|
31964
32573
|
|
|
31965
|
-
if (
|
|
31966
|
-
coordSysDimDefs = map(
|
|
32574
|
+
if (coordSysInfo) {
|
|
32575
|
+
coordSysDimDefs = map(coordSysInfo.coordSysDims, function (dim) {
|
|
31967
32576
|
var dimInfo = {name: dim};
|
|
31968
|
-
var axisModel =
|
|
32577
|
+
var axisModel = coordSysInfo.axisMap.get(dim);
|
|
31969
32578
|
if (axisModel) {
|
|
31970
32579
|
var axisType = axisModel.get('type');
|
|
31971
32580
|
dimInfo.type = getDimensionTypeByAxis(axisType);
|
|
@@ -31986,14 +32595,17 @@ function createListFromArray(source, seriesModel, opt) {
|
|
|
31986
32595
|
|
|
31987
32596
|
var dimInfoList = createDimensions(source, {
|
|
31988
32597
|
coordDimensions: coordSysDimDefs,
|
|
31989
|
-
generateCoord: opt.generateCoord
|
|
32598
|
+
generateCoord: opt.generateCoord,
|
|
32599
|
+
encodeDefaulter: opt.useEncodeDefaulter
|
|
32600
|
+
? curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel)
|
|
32601
|
+
: null
|
|
31990
32602
|
});
|
|
31991
32603
|
|
|
31992
32604
|
var firstCategoryDimIndex;
|
|
31993
32605
|
var hasNameEncode;
|
|
31994
|
-
|
|
32606
|
+
coordSysInfo && each$1(dimInfoList, function (dimInfo, dimIndex) {
|
|
31995
32607
|
var coordDim = dimInfo.coordDim;
|
|
31996
|
-
var categoryAxisModel =
|
|
32608
|
+
var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
|
|
31997
32609
|
if (categoryAxisModel) {
|
|
31998
32610
|
if (firstCategoryDimIndex == null) {
|
|
31999
32611
|
firstCategoryDimIndex = dimIndex;
|
|
@@ -32077,7 +32689,7 @@ SeriesModel.extend({
|
|
|
32077
32689
|
throw new Error('Line not support coordinateSystem besides cartesian and polar');
|
|
32078
32690
|
}
|
|
32079
32691
|
}
|
|
32080
|
-
return createListFromArray(this.getSource(), this);
|
|
32692
|
+
return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
|
|
32081
32693
|
},
|
|
32082
32694
|
|
|
32083
32695
|
defaultOption: {
|
|
@@ -34291,7 +34903,7 @@ Chart.extend({
|
|
|
34291
34903
|
// FIXME step not support polar
|
|
34292
34904
|
var step = !isCoordSysPolar && seriesModel.get('step');
|
|
34293
34905
|
var clipShapeForSymbol;
|
|
34294
|
-
if (coordSys && coordSys.getArea) {
|
|
34906
|
+
if (coordSys && coordSys.getArea && seriesModel.get('clip', true)) {
|
|
34295
34907
|
clipShapeForSymbol = coordSys.getArea();
|
|
34296
34908
|
// Avoid float number rounding error for symbol on the edge of axis extent.
|
|
34297
34909
|
// See #7913 and `test/dataZoom-clip.html`.
|
|
@@ -34306,6 +34918,7 @@ Chart.extend({
|
|
|
34306
34918
|
clipShapeForSymbol.r1 += 0.5;
|
|
34307
34919
|
}
|
|
34308
34920
|
}
|
|
34921
|
+
this._clipShapeForSymbol = clipShapeForSymbol;
|
|
34309
34922
|
// Initialization animation or coordinate system changed
|
|
34310
34923
|
if (
|
|
34311
34924
|
!(polyline && prevCoordSys.type === coordSys.type && step === this._step)
|
|
@@ -34458,6 +35071,10 @@ Chart.extend({
|
|
|
34458
35071
|
// Null data
|
|
34459
35072
|
return;
|
|
34460
35073
|
}
|
|
35074
|
+
// fix #11360: should't draw symbol outside clipShapeForSymbol
|
|
35075
|
+
if (this._clipShapeForSymbol && !this._clipShapeForSymbol.contain(pt[0], pt[1])) {
|
|
35076
|
+
return;
|
|
35077
|
+
}
|
|
34461
35078
|
symbol = new SymbolClz(data, dataIndex);
|
|
34462
35079
|
symbol.position = pt;
|
|
34463
35080
|
symbol.setZ(
|
|
@@ -35463,44 +36080,6 @@ function fixExtent(niceTickExtent, extent) {
|
|
|
35463
36080
|
}
|
|
35464
36081
|
}
|
|
35465
36082
|
|
|
35466
|
-
function intervalScaleGetTicks(interval, extent, niceTickExtent, intervalPrecision) {
|
|
35467
|
-
var ticks = [];
|
|
35468
|
-
|
|
35469
|
-
// If interval is 0, return [];
|
|
35470
|
-
if (!interval) {
|
|
35471
|
-
return ticks;
|
|
35472
|
-
}
|
|
35473
|
-
|
|
35474
|
-
// Consider this case: using dataZoom toolbox, zoom and zoom.
|
|
35475
|
-
var safeLimit = 10000;
|
|
35476
|
-
|
|
35477
|
-
if (extent[0] < niceTickExtent[0]) {
|
|
35478
|
-
ticks.push(extent[0]);
|
|
35479
|
-
}
|
|
35480
|
-
var tick = niceTickExtent[0];
|
|
35481
|
-
|
|
35482
|
-
while (tick <= niceTickExtent[1]) {
|
|
35483
|
-
ticks.push(tick);
|
|
35484
|
-
// Avoid rounding error
|
|
35485
|
-
tick = roundNumber$1(tick + interval, intervalPrecision);
|
|
35486
|
-
if (tick === ticks[ticks.length - 1]) {
|
|
35487
|
-
// Consider out of safe float point, e.g.,
|
|
35488
|
-
// -3711126.9907707 + 2e-10 === -3711126.9907707
|
|
35489
|
-
break;
|
|
35490
|
-
}
|
|
35491
|
-
if (ticks.length > safeLimit) {
|
|
35492
|
-
return [];
|
|
35493
|
-
}
|
|
35494
|
-
}
|
|
35495
|
-
// Consider this case: the last item of ticks is smaller
|
|
35496
|
-
// than niceTickExtent[1] and niceTickExtent[1] === extent[1].
|
|
35497
|
-
if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1])) {
|
|
35498
|
-
ticks.push(extent[1]);
|
|
35499
|
-
}
|
|
35500
|
-
|
|
35501
|
-
return ticks;
|
|
35502
|
-
}
|
|
35503
|
-
|
|
35504
36083
|
/*
|
|
35505
36084
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
35506
36085
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -35579,12 +36158,92 @@ var IntervalScale = Scale.extend({
|
|
|
35579
36158
|
},
|
|
35580
36159
|
|
|
35581
36160
|
/**
|
|
36161
|
+
* @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
|
|
35582
36162
|
* @return {Array.<number>}
|
|
35583
36163
|
*/
|
|
35584
|
-
getTicks: function () {
|
|
35585
|
-
|
|
35586
|
-
|
|
35587
|
-
|
|
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;
|
|
35588
36247
|
},
|
|
35589
36248
|
|
|
35590
36249
|
/**
|
|
@@ -35923,7 +36582,6 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35923
36582
|
// only the attributes set on the last series will work.
|
|
35924
36583
|
// Do not change this fact unless there will be a break change.
|
|
35925
36584
|
|
|
35926
|
-
// TODO
|
|
35927
36585
|
var barWidth = seriesInfo.barWidth;
|
|
35928
36586
|
if (barWidth && !stacks[stackId].width) {
|
|
35929
36587
|
// See #6312, do not restrict width.
|
|
@@ -35963,6 +36621,7 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35963
36621
|
each$1(stacks, function (column) {
|
|
35964
36622
|
var maxWidth = column.maxWidth;
|
|
35965
36623
|
var minWidth = column.minWidth;
|
|
36624
|
+
|
|
35966
36625
|
if (!column.width) {
|
|
35967
36626
|
var finalWidth = autoWidth;
|
|
35968
36627
|
if (maxWidth && maxWidth < finalWidth) {
|
|
@@ -35978,7 +36637,7 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35978
36637
|
}
|
|
35979
36638
|
if (finalWidth !== autoWidth) {
|
|
35980
36639
|
column.width = finalWidth;
|
|
35981
|
-
remainedWidth -= finalWidth;
|
|
36640
|
+
remainedWidth -= finalWidth + barGapPercent * finalWidth;
|
|
35982
36641
|
autoWidthCount--;
|
|
35983
36642
|
}
|
|
35984
36643
|
}
|
|
@@ -35995,7 +36654,7 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
35995
36654
|
finalWidth = Math.max(finalWidth, minWidth);
|
|
35996
36655
|
}
|
|
35997
36656
|
column.width = finalWidth;
|
|
35998
|
-
remainedWidth -= finalWidth;
|
|
36657
|
+
remainedWidth -= finalWidth + barGapPercent * finalWidth;
|
|
35999
36658
|
autoWidthCount--;
|
|
36000
36659
|
}
|
|
36001
36660
|
});
|
|
@@ -36003,8 +36662,10 @@ function doCalBarWidthAndOffset(seriesInfoList) {
|
|
|
36003
36662
|
// Recalculate width again
|
|
36004
36663
|
autoWidth = (remainedWidth - categoryGap)
|
|
36005
36664
|
/ (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
|
|
36665
|
+
|
|
36006
36666
|
autoWidth = Math.max(autoWidth, 0);
|
|
36007
36667
|
|
|
36668
|
+
|
|
36008
36669
|
var widthSum = 0;
|
|
36009
36670
|
var lastColumn;
|
|
36010
36671
|
each$1(stacks, function (column, idx) {
|
|
@@ -36143,6 +36804,7 @@ function layout(seriesType, ecModel) {
|
|
|
36143
36804
|
}
|
|
36144
36805
|
stacked && (lastStackCoords[stackId][baseValue][sign] += height);
|
|
36145
36806
|
}
|
|
36807
|
+
|
|
36146
36808
|
data.setItemLayout(idx, {
|
|
36147
36809
|
x: x,
|
|
36148
36810
|
y: y,
|
|
@@ -36503,14 +37165,15 @@ var LogScale = Scale.extend({
|
|
|
36503
37165
|
},
|
|
36504
37166
|
|
|
36505
37167
|
/**
|
|
37168
|
+
* @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
|
|
36506
37169
|
* @return {Array.<number>}
|
|
36507
37170
|
*/
|
|
36508
|
-
getTicks: function () {
|
|
37171
|
+
getTicks: function (expandToNicedExtent) {
|
|
36509
37172
|
var originalScale = this._originalScale;
|
|
36510
37173
|
var extent = this._extent;
|
|
36511
37174
|
var originalExtent = originalScale.getExtent();
|
|
36512
37175
|
|
|
36513
|
-
return map(intervalScaleProto$1.getTicks.call(this), function (val) {
|
|
37176
|
+
return map(intervalScaleProto$1.getTicks.call(this, expandToNicedExtent), function (val) {
|
|
36514
37177
|
var powVal = round$1(mathPow$1(this.base, val));
|
|
36515
37178
|
|
|
36516
37179
|
// Fix #4158
|
|
@@ -36525,6 +37188,12 @@ var LogScale = Scale.extend({
|
|
|
36525
37188
|
}, this);
|
|
36526
37189
|
},
|
|
36527
37190
|
|
|
37191
|
+
/**
|
|
37192
|
+
* @param {number} splitNumber
|
|
37193
|
+
* @return {Array.<Array.<number>>}
|
|
37194
|
+
*/
|
|
37195
|
+
getMinorTicks: intervalScaleProto$1.getMinorTicks,
|
|
37196
|
+
|
|
36528
37197
|
/**
|
|
36529
37198
|
* @param {number} val
|
|
36530
37199
|
* @return {string}
|
|
@@ -37770,7 +38439,7 @@ Axis.prototype = {
|
|
|
37770
38439
|
* @return {boolean}
|
|
37771
38440
|
*/
|
|
37772
38441
|
containData: function (data) {
|
|
37773
|
-
return this.contain(
|
|
38442
|
+
return this.scale.contain(data);
|
|
37774
38443
|
},
|
|
37775
38444
|
|
|
37776
38445
|
/**
|
|
@@ -37858,7 +38527,7 @@ Axis.prototype = {
|
|
|
37858
38527
|
* `axis.getTicksCoords` considers `onBand`, which is used by
|
|
37859
38528
|
* `boundaryGap:true` of category axis and splitLine and splitArea.
|
|
37860
38529
|
* @param {Object} [opt]
|
|
37861
|
-
* @param {
|
|
38530
|
+
* @param {Model} [opt.tickModel=axis.model.getModel('axisTick')]
|
|
37862
38531
|
* @param {boolean} [opt.clamp] If `true`, the first and the last
|
|
37863
38532
|
* tick must be at the axis end points. Otherwise, clip ticks
|
|
37864
38533
|
* that outside the axis extent.
|
|
@@ -37890,6 +38559,33 @@ Axis.prototype = {
|
|
|
37890
38559
|
return ticksCoords;
|
|
37891
38560
|
},
|
|
37892
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
|
+
|
|
37893
38589
|
/**
|
|
37894
38590
|
* @return {Array.<Object>} [{
|
|
37895
38591
|
* formattedLabel: string,
|
|
@@ -38324,7 +39020,7 @@ axisDefault.valueAxis = merge({
|
|
|
38324
39020
|
// scale: false,
|
|
38325
39021
|
|
|
38326
39022
|
// AxisTick and axisLabel and splitLine are caculated based on splitNumber.
|
|
38327
|
-
splitNumber: 5
|
|
39023
|
+
splitNumber: 5,
|
|
38328
39024
|
|
|
38329
39025
|
// Interval specifies the span of the ticks is mandatorily.
|
|
38330
39026
|
// interval: null
|
|
@@ -38335,6 +39031,30 @@ axisDefault.valueAxis = merge({
|
|
|
38335
39031
|
// Specify max interval when auto calculate tick interval.
|
|
38336
39032
|
// maxInterval: null
|
|
38337
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
|
+
}
|
|
38338
39058
|
}, defaultOption);
|
|
38339
39059
|
|
|
38340
39060
|
axisDefault.timeAxis = defaults({
|
|
@@ -39547,10 +40267,12 @@ var builders = {
|
|
|
39547
40267
|
var axisModel = this.axisModel;
|
|
39548
40268
|
var opt = this.opt;
|
|
39549
40269
|
|
|
39550
|
-
var
|
|
40270
|
+
var ticksEls = buildAxisMajorTicks(this, axisModel, opt);
|
|
39551
40271
|
var labelEls = buildAxisLabel(this, axisModel, opt);
|
|
39552
40272
|
|
|
39553
|
-
fixMinMaxLabelShow(axisModel, labelEls,
|
|
40273
|
+
fixMinMaxLabelShow(axisModel, labelEls, ticksEls);
|
|
40274
|
+
|
|
40275
|
+
buildAxisMinorTicks(this, axisModel, opt);
|
|
39554
40276
|
},
|
|
39555
40277
|
|
|
39556
40278
|
/**
|
|
@@ -39869,42 +40591,27 @@ function isNameLocationCenter(nameLocation) {
|
|
|
39869
40591
|
return nameLocation === 'middle' || nameLocation === 'center';
|
|
39870
40592
|
}
|
|
39871
40593
|
|
|
39872
|
-
function buildAxisTick(axisBuilder, axisModel, opt) {
|
|
39873
|
-
var axis = axisModel.axis;
|
|
39874
|
-
|
|
39875
|
-
if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
|
|
39876
|
-
return;
|
|
39877
|
-
}
|
|
39878
|
-
|
|
39879
|
-
var tickModel = axisModel.getModel('axisTick');
|
|
39880
|
-
|
|
39881
|
-
var lineStyleModel = tickModel.getModel('lineStyle');
|
|
39882
|
-
var tickLen = tickModel.get('length');
|
|
39883
|
-
|
|
39884
|
-
var ticksCoords = axis.getTicksCoords();
|
|
39885
40594
|
|
|
40595
|
+
function createTicks(ticksCoords, tickTransform, tickEndCoord, tickLineStyle, aniid) {
|
|
40596
|
+
var tickEls = [];
|
|
39886
40597
|
var pt1 = [];
|
|
39887
40598
|
var pt2 = [];
|
|
39888
|
-
var matrix = axisBuilder._transform;
|
|
39889
|
-
|
|
39890
|
-
var tickEls = [];
|
|
39891
|
-
|
|
39892
40599
|
for (var i = 0; i < ticksCoords.length; i++) {
|
|
39893
40600
|
var tickCoord = ticksCoords[i].coord;
|
|
39894
40601
|
|
|
39895
40602
|
pt1[0] = tickCoord;
|
|
39896
40603
|
pt1[1] = 0;
|
|
39897
40604
|
pt2[0] = tickCoord;
|
|
39898
|
-
pt2[1] =
|
|
40605
|
+
pt2[1] = tickEndCoord;
|
|
39899
40606
|
|
|
39900
|
-
if (
|
|
39901
|
-
applyTransform(pt1, pt1,
|
|
39902
|
-
applyTransform(pt2, pt2,
|
|
40607
|
+
if (tickTransform) {
|
|
40608
|
+
applyTransform(pt1, pt1, tickTransform);
|
|
40609
|
+
applyTransform(pt2, pt2, tickTransform);
|
|
39903
40610
|
}
|
|
39904
40611
|
// Tick line, Not use group transform to have better line draw
|
|
39905
40612
|
var tickEl = new Line({
|
|
39906
40613
|
// Id for animation
|
|
39907
|
-
anid: '
|
|
40614
|
+
anid: aniid + '_' + ticksCoords[i].tickValue,
|
|
39908
40615
|
subPixelOptimize: true,
|
|
39909
40616
|
shape: {
|
|
39910
40617
|
x1: pt1[0],
|
|
@@ -39912,22 +40619,80 @@ function buildAxisTick(axisBuilder, axisModel, opt) {
|
|
|
39912
40619
|
x2: pt2[0],
|
|
39913
40620
|
y2: pt2[1]
|
|
39914
40621
|
},
|
|
39915
|
-
style:
|
|
39916
|
-
lineStyleModel.getLineStyle(),
|
|
39917
|
-
{
|
|
39918
|
-
stroke: axisModel.get('axisLine.lineStyle.color')
|
|
39919
|
-
}
|
|
39920
|
-
),
|
|
40622
|
+
style: tickLineStyle,
|
|
39921
40623
|
z2: 2,
|
|
39922
40624
|
silent: true
|
|
39923
40625
|
});
|
|
39924
|
-
axisBuilder.group.add(tickEl);
|
|
39925
40626
|
tickEls.push(tickEl);
|
|
39926
40627
|
}
|
|
39927
|
-
|
|
39928
40628
|
return tickEls;
|
|
39929
40629
|
}
|
|
39930
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
|
+
|
|
39931
40696
|
function buildAxisLabel(axisBuilder, axisModel, opt) {
|
|
39932
40697
|
var axis = axisModel.axis;
|
|
39933
40698
|
var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
|
|
@@ -40347,17 +41112,9 @@ var axisBuilderAttrs = [
|
|
|
40347
41112
|
'axisLine', 'axisTickLabel', 'axisName'
|
|
40348
41113
|
];
|
|
40349
41114
|
var selfBuilderAttrs = [
|
|
40350
|
-
'splitArea', 'splitLine'
|
|
41115
|
+
'splitArea', 'splitLine', 'minorSplitLine'
|
|
40351
41116
|
];
|
|
40352
41117
|
|
|
40353
|
-
// function getAlignWithLabel(model, axisModel) {
|
|
40354
|
-
// var alignWithLabel = model.get('alignWithLabel');
|
|
40355
|
-
// if (alignWithLabel === 'auto') {
|
|
40356
|
-
// alignWithLabel = axisModel.get('axisTick.alignWithLabel');
|
|
40357
|
-
// }
|
|
40358
|
-
// return alignWithLabel;
|
|
40359
|
-
// }
|
|
40360
|
-
|
|
40361
41118
|
var CartesianAxisView = AxisView.extend({
|
|
40362
41119
|
|
|
40363
41120
|
type: 'cartesianAxis',
|
|
@@ -40435,8 +41192,6 @@ var CartesianAxisView = AxisView.extend({
|
|
|
40435
41192
|
var p1 = [];
|
|
40436
41193
|
var p2 = [];
|
|
40437
41194
|
|
|
40438
|
-
// Simple optimization
|
|
40439
|
-
// Batching the lines if color are the same
|
|
40440
41195
|
var lineStyle = lineStyleModel.getLineStyle();
|
|
40441
41196
|
for (var i = 0; i < ticksCoords.length; i++) {
|
|
40442
41197
|
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
|
@@ -40473,6 +41228,63 @@ var CartesianAxisView = AxisView.extend({
|
|
|
40473
41228
|
}
|
|
40474
41229
|
},
|
|
40475
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
|
+
|
|
40476
41288
|
/**
|
|
40477
41289
|
* @param {module:echarts/coord/cartesian/AxisModel} axisModel
|
|
40478
41290
|
* @param {module:echarts/coord/cartesian/GridModel} gridModel
|
|
@@ -40693,7 +41505,7 @@ var BaseBarSeries = SeriesModel.extend({
|
|
|
40693
41505
|
type: 'series.__base_bar__',
|
|
40694
41506
|
|
|
40695
41507
|
getInitialData: function (option, ecModel) {
|
|
40696
|
-
return createListFromArray(this.getSource(), this);
|
|
41508
|
+
return createListFromArray(this.getSource(), this, {useEncodeDefaulter: true});
|
|
40697
41509
|
},
|
|
40698
41510
|
|
|
40699
41511
|
getMarkerPosition: function (value) {
|
|
@@ -41397,11 +42209,18 @@ var getLayout = {
|
|
|
41397
42209
|
}
|
|
41398
42210
|
};
|
|
41399
42211
|
|
|
42212
|
+
function isZeroOnPolar(layout) {
|
|
42213
|
+
return layout.startAngle != null
|
|
42214
|
+
&& layout.endAngle != null
|
|
42215
|
+
&& layout.startAngle === layout.endAngle;
|
|
42216
|
+
}
|
|
42217
|
+
|
|
41400
42218
|
function updateStyle(
|
|
41401
42219
|
el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar
|
|
41402
42220
|
) {
|
|
41403
42221
|
var color = data.getItemVisual(dataIndex, 'color');
|
|
41404
42222
|
var opacity = data.getItemVisual(dataIndex, 'opacity');
|
|
42223
|
+
var stroke = data.getVisual('borderColor');
|
|
41405
42224
|
var itemStyleModel = itemModel.getModel('itemStyle');
|
|
41406
42225
|
var hoverStyle = itemModel.getModel('emphasis.itemStyle').getBarItemStyle();
|
|
41407
42226
|
|
|
@@ -41411,7 +42230,8 @@ function updateStyle(
|
|
|
41411
42230
|
|
|
41412
42231
|
el.useStyle(defaults(
|
|
41413
42232
|
{
|
|
41414
|
-
|
|
42233
|
+
stroke: isZeroOnPolar(layout) ? 'none' : stroke,
|
|
42234
|
+
fill: isZeroOnPolar(layout) ? 'none' : color,
|
|
41415
42235
|
opacity: opacity
|
|
41416
42236
|
},
|
|
41417
42237
|
itemStyleModel.getBarItemStyle()
|
|
@@ -41430,7 +42250,9 @@ function updateStyle(
|
|
|
41430
42250
|
seriesModel, dataIndex, labelPositionOutside
|
|
41431
42251
|
);
|
|
41432
42252
|
}
|
|
41433
|
-
|
|
42253
|
+
if (isZeroOnPolar(layout)) {
|
|
42254
|
+
hoverStyle.fill = hoverStyle.stroke = 'none';
|
|
42255
|
+
}
|
|
41434
42256
|
setHoverStyle(el, hoverStyle);
|
|
41435
42257
|
}
|
|
41436
42258
|
|
|
@@ -41751,6 +42573,60 @@ var dataSelectableMixin = {
|
|
|
41751
42573
|
* under the License.
|
|
41752
42574
|
*/
|
|
41753
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
|
+
|
|
41754
42630
|
var PieSeries = extendSeriesModel({
|
|
41755
42631
|
|
|
41756
42632
|
type: 'series.pie',
|
|
@@ -41761,9 +42637,9 @@ var PieSeries = extendSeriesModel({
|
|
|
41761
42637
|
|
|
41762
42638
|
// Enable legend selection for each data item
|
|
41763
42639
|
// Use a function instead of direct access because data reference may changed
|
|
41764
|
-
this.
|
|
41765
|
-
|
|
41766
|
-
|
|
42640
|
+
this.legendVisualProvider = new LegendVisualProvider(
|
|
42641
|
+
bind(this.getData, this), bind(this.getRawData, this)
|
|
42642
|
+
);
|
|
41767
42643
|
|
|
41768
42644
|
this.updateSelectedMap(this._createSelectableList());
|
|
41769
42645
|
|
|
@@ -41778,7 +42654,10 @@ var PieSeries = extendSeriesModel({
|
|
|
41778
42654
|
},
|
|
41779
42655
|
|
|
41780
42656
|
getInitialData: function (option, ecModel) {
|
|
41781
|
-
return createListSimply(this,
|
|
42657
|
+
return createListSimply(this, {
|
|
42658
|
+
coordDimensions: ['value'],
|
|
42659
|
+
encodeDefaulter: curry(makeSeriesEncodeForNameBased, this)
|
|
42660
|
+
});
|
|
41782
42661
|
},
|
|
41783
42662
|
|
|
41784
42663
|
_createSelectableList: function () {
|
|
@@ -41867,12 +42746,28 @@ var PieSeries = extendSeriesModel({
|
|
|
41867
42746
|
|
|
41868
42747
|
// cursor: null,
|
|
41869
42748
|
|
|
42749
|
+
left: 0,
|
|
42750
|
+
top: 0,
|
|
42751
|
+
right: 0,
|
|
42752
|
+
bottom: 0,
|
|
42753
|
+
width: null,
|
|
42754
|
+
height: null,
|
|
42755
|
+
|
|
41870
42756
|
label: {
|
|
41871
42757
|
// If rotate around circle
|
|
41872
42758
|
rotate: false,
|
|
41873
42759
|
show: true,
|
|
41874
42760
|
// 'outer', 'inside', 'center'
|
|
41875
|
-
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
|
|
41876
42771
|
// formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
|
|
41877
42772
|
// 默认使用全局文本样式,详见TEXTSTYLE
|
|
41878
42773
|
// distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
|
|
@@ -42178,7 +43073,7 @@ piePieceProto._updateLabel = function (data, idx, withAnimation) {
|
|
|
42178
43073
|
{
|
|
42179
43074
|
labelFetcher: data.hostModel,
|
|
42180
43075
|
labelDataIndex: idx,
|
|
42181
|
-
defaultText:
|
|
43076
|
+
defaultText: labelLayout.text,
|
|
42182
43077
|
autoColor: visualColor,
|
|
42183
43078
|
useInsideStyle: !!labelLayout.inside
|
|
42184
43079
|
},
|
|
@@ -42474,33 +43369,20 @@ var dataColor = function (seriesType) {
|
|
|
42474
43369
|
dataAll.getName(rawIdx) || (rawIdx + ''), seriesModel.__paletteScope,
|
|
42475
43370
|
dataAll.count()
|
|
42476
43371
|
);
|
|
42477
|
-
// Legend may use the visual info in data before processed
|
|
42478
|
-
dataAll.setItemVisual(rawIdx, 'color', color);
|
|
42479
|
-
|
|
42480
43372
|
// Data is not filtered
|
|
42481
43373
|
if (filteredIdx != null) {
|
|
42482
43374
|
data.setItemVisual(filteredIdx, 'color', color);
|
|
42483
43375
|
}
|
|
42484
43376
|
}
|
|
42485
|
-
else {
|
|
42486
|
-
// Set data all color for legend
|
|
42487
|
-
dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
|
|
42488
|
-
}
|
|
42489
43377
|
|
|
42490
43378
|
if (!singleDataBorderColor) {
|
|
42491
43379
|
var borderColor = itemModel.get('itemStyle.borderColor');
|
|
42492
|
-
// Legend may use the visual info in data before processed
|
|
42493
|
-
dataAll.setItemVisual(rawIdx, 'borderColor', borderColor);
|
|
42494
43380
|
|
|
42495
43381
|
// Data is not filtered
|
|
42496
43382
|
if (filteredIdx != null) {
|
|
42497
43383
|
data.setItemVisual(filteredIdx, 'borderColor', borderColor);
|
|
42498
43384
|
}
|
|
42499
43385
|
}
|
|
42500
|
-
else {
|
|
42501
|
-
// Set data all borderColor for legend
|
|
42502
|
-
dataAll.setItemVisual(rawIdx, 'borderColor', singleDataBorderColor);
|
|
42503
|
-
}
|
|
42504
43386
|
});
|
|
42505
43387
|
}
|
|
42506
43388
|
};
|
|
@@ -42529,13 +43411,17 @@ var dataColor = function (seriesType) {
|
|
|
42529
43411
|
|
|
42530
43412
|
var RADIAN$1 = Math.PI / 180;
|
|
42531
43413
|
|
|
42532
|
-
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
43414
|
+
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
|
|
42533
43415
|
list.sort(function (a, b) {
|
|
42534
43416
|
return a.y - b.y;
|
|
42535
43417
|
});
|
|
42536
43418
|
|
|
42537
43419
|
function shiftDown(start, end, delta, dir) {
|
|
42538
43420
|
for (var j = start; j < end; j++) {
|
|
43421
|
+
if (list[j].y + delta > viewTop + viewHeight) {
|
|
43422
|
+
break;
|
|
43423
|
+
}
|
|
43424
|
+
|
|
42539
43425
|
list[j].y += delta;
|
|
42540
43426
|
if (j > start
|
|
42541
43427
|
&& j + 1 < end
|
|
@@ -42551,6 +43437,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42551
43437
|
|
|
42552
43438
|
function shiftUp(end, delta) {
|
|
42553
43439
|
for (var j = end; j >= 0; j--) {
|
|
43440
|
+
if (list[j].y - delta < viewTop) {
|
|
43441
|
+
break;
|
|
43442
|
+
}
|
|
43443
|
+
|
|
42554
43444
|
list[j].y -= delta;
|
|
42555
43445
|
if (j > 0
|
|
42556
43446
|
&& list[j].y > list[j - 1].y + list[j - 1].height
|
|
@@ -42570,6 +43460,10 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42570
43460
|
: 0; // up
|
|
42571
43461
|
|
|
42572
43462
|
for (var i = 0, l = list.length; i < l; i++) {
|
|
43463
|
+
if (list[i].labelAlignTo !== 'none') {
|
|
43464
|
+
continue;
|
|
43465
|
+
}
|
|
43466
|
+
|
|
42573
43467
|
var deltaY = Math.abs(list[i].y - cy);
|
|
42574
43468
|
var length = list[i].len;
|
|
42575
43469
|
var length2 = list[i].len2;
|
|
@@ -42599,6 +43493,12 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42599
43493
|
var upList = [];
|
|
42600
43494
|
var downList = [];
|
|
42601
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
|
+
|
|
42602
43502
|
delta = list[i].y - lastY;
|
|
42603
43503
|
if (delta < 0) {
|
|
42604
43504
|
shiftDown(i, len, -delta, dir);
|
|
@@ -42620,39 +43520,85 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42620
43520
|
changeX(downList, true, cx, cy, r, dir);
|
|
42621
43521
|
}
|
|
42622
43522
|
|
|
42623
|
-
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
43523
|
+
function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
42624
43524
|
var leftList = [];
|
|
42625
43525
|
var rightList = [];
|
|
43526
|
+
var leftmostX = Number.MAX_VALUE;
|
|
43527
|
+
var rightmostX = -Number.MAX_VALUE;
|
|
42626
43528
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
42627
43529
|
if (isPositionCenter(labelLayoutList[i])) {
|
|
42628
43530
|
continue;
|
|
42629
43531
|
}
|
|
42630
43532
|
if (labelLayoutList[i].x < cx) {
|
|
43533
|
+
leftmostX = Math.min(leftmostX, labelLayoutList[i].x);
|
|
42631
43534
|
leftList.push(labelLayoutList[i]);
|
|
42632
43535
|
}
|
|
42633
43536
|
else {
|
|
43537
|
+
rightmostX = Math.max(rightmostX, labelLayoutList[i].x);
|
|
42634
43538
|
rightList.push(labelLayoutList[i]);
|
|
42635
43539
|
}
|
|
42636
43540
|
}
|
|
42637
43541
|
|
|
42638
|
-
adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
|
|
42639
|
-
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);
|
|
42640
43544
|
|
|
42641
43545
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
42642
|
-
|
|
43546
|
+
var layout = labelLayoutList[i];
|
|
43547
|
+
if (isPositionCenter(layout)) {
|
|
42643
43548
|
continue;
|
|
42644
43549
|
}
|
|
42645
|
-
|
|
43550
|
+
|
|
43551
|
+
var linePoints = layout.linePoints;
|
|
42646
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
|
+
|
|
42647
43582
|
var dist = linePoints[1][0] - linePoints[2][0];
|
|
42648
|
-
if (
|
|
42649
|
-
|
|
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
|
+
}
|
|
42650
43591
|
}
|
|
42651
43592
|
else {
|
|
42652
|
-
|
|
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;
|
|
42653
43600
|
}
|
|
42654
|
-
linePoints[1][1] = linePoints[2][1] =
|
|
42655
|
-
linePoints[1][0] = linePoints[2][0] + dist;
|
|
43601
|
+
linePoints[1][1] = linePoints[2][1] = layout.y;
|
|
42656
43602
|
}
|
|
42657
43603
|
}
|
|
42658
43604
|
}
|
|
@@ -42662,7 +43608,7 @@ function isPositionCenter(layout) {
|
|
|
42662
43608
|
return layout.position === 'center';
|
|
42663
43609
|
}
|
|
42664
43610
|
|
|
42665
|
-
var labelLayout = function (seriesModel, r, viewWidth, viewHeight,
|
|
43611
|
+
var labelLayout = function (seriesModel, r, viewWidth, viewHeight, viewLeft, viewTop) {
|
|
42666
43612
|
var data = seriesModel.getData();
|
|
42667
43613
|
var labelLayoutList = [];
|
|
42668
43614
|
var cx;
|
|
@@ -42677,10 +43623,17 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42677
43623
|
var labelModel = itemModel.getModel('label');
|
|
42678
43624
|
// Use position in normal or emphasis
|
|
42679
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();
|
|
42680
43631
|
|
|
42681
43632
|
var labelLineModel = itemModel.getModel('labelLine');
|
|
42682
43633
|
var labelLineLen = labelLineModel.get('length');
|
|
43634
|
+
labelLineLen = parsePercent$1(labelLineLen, viewWidth);
|
|
42683
43635
|
var labelLineLen2 = labelLineModel.get('length2');
|
|
43636
|
+
labelLineLen2 = parsePercent$1(labelLineLen2, viewWidth);
|
|
42684
43637
|
|
|
42685
43638
|
if (layout.angle < minShowLabelRadian) {
|
|
42686
43639
|
return;
|
|
@@ -42698,6 +43651,12 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42698
43651
|
cx = layout.cx;
|
|
42699
43652
|
cy = layout.cy;
|
|
42700
43653
|
|
|
43654
|
+
var text = seriesModel.getFormattedLabel(idx, 'normal')
|
|
43655
|
+
|| data.getName(idx);
|
|
43656
|
+
var textRect = getBoundingRect(
|
|
43657
|
+
text, font, textAlign, 'top'
|
|
43658
|
+
);
|
|
43659
|
+
|
|
42701
43660
|
var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
|
|
42702
43661
|
if (labelPosition === 'center') {
|
|
42703
43662
|
textX = layout.cx;
|
|
@@ -42718,14 +43677,25 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42718
43677
|
var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
|
|
42719
43678
|
var y3 = y2;
|
|
42720
43679
|
|
|
42721
|
-
|
|
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
|
+
}
|
|
42722
43689
|
textY = y3;
|
|
42723
43690
|
linePoints = [[x1, y1], [x2, y2], [x3, y3]];
|
|
42724
43691
|
}
|
|
42725
43692
|
|
|
42726
|
-
textAlign = isLabelInside
|
|
43693
|
+
textAlign = isLabelInside
|
|
43694
|
+
? 'center'
|
|
43695
|
+
: (labelAlignTo === 'edge'
|
|
43696
|
+
? (dx > 0 ? 'right' : 'left')
|
|
43697
|
+
: (dx > 0 ? 'left' : 'right'));
|
|
42727
43698
|
}
|
|
42728
|
-
var font = labelModel.getFont();
|
|
42729
43699
|
|
|
42730
43700
|
var labelRotate;
|
|
42731
43701
|
var rotate = labelModel.get('rotate');
|
|
@@ -42737,11 +43707,7 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42737
43707
|
? (dx < 0 ? -midAngle + Math.PI : -midAngle)
|
|
42738
43708
|
: 0;
|
|
42739
43709
|
}
|
|
42740
|
-
|
|
42741
|
-
|| data.getName(idx);
|
|
42742
|
-
var textRect = getBoundingRect(
|
|
42743
|
-
text, font, textAlign, 'top'
|
|
42744
|
-
);
|
|
43710
|
+
|
|
42745
43711
|
hasLabelRotate = !!labelRotate;
|
|
42746
43712
|
layout.label = {
|
|
42747
43713
|
x: textX,
|
|
@@ -42754,7 +43720,14 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42754
43720
|
textAlign: textAlign,
|
|
42755
43721
|
verticalAlign: 'middle',
|
|
42756
43722
|
rotation: labelRotate,
|
|
42757
|
-
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
|
|
42758
43731
|
};
|
|
42759
43732
|
|
|
42760
43733
|
// Not layout the inside label
|
|
@@ -42763,7 +43736,7 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42763
43736
|
}
|
|
42764
43737
|
});
|
|
42765
43738
|
if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
|
|
42766
|
-
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
|
|
43739
|
+
avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
|
|
42767
43740
|
}
|
|
42768
43741
|
};
|
|
42769
43742
|
|
|
@@ -42790,10 +43763,20 @@ var labelLayout = function (seriesModel, r, viewWidth, viewHeight, sum) {
|
|
|
42790
43763
|
var PI2$4 = Math.PI * 2;
|
|
42791
43764
|
var RADIAN = Math.PI / 180;
|
|
42792
43765
|
|
|
43766
|
+
function getViewRect(seriesModel, api) {
|
|
43767
|
+
return getLayoutRect(
|
|
43768
|
+
seriesModel.getBoxLayoutParams(), {
|
|
43769
|
+
width: api.getWidth(),
|
|
43770
|
+
height: api.getHeight()
|
|
43771
|
+
}
|
|
43772
|
+
);
|
|
43773
|
+
}
|
|
43774
|
+
|
|
42793
43775
|
var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
42794
43776
|
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
|
42795
43777
|
var data = seriesModel.getData();
|
|
42796
43778
|
var valueDim = data.mapDimension('value');
|
|
43779
|
+
var viewRect = getViewRect(seriesModel, api);
|
|
42797
43780
|
|
|
42798
43781
|
var center = seriesModel.get('center');
|
|
42799
43782
|
var radius = seriesModel.get('radius');
|
|
@@ -42805,11 +43788,11 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42805
43788
|
center = [center, center];
|
|
42806
43789
|
}
|
|
42807
43790
|
|
|
42808
|
-
var width = api.getWidth();
|
|
42809
|
-
var height = api.getHeight();
|
|
43791
|
+
var width = parsePercent$1(viewRect.width, api.getWidth());
|
|
43792
|
+
var height = parsePercent$1(viewRect.height, api.getHeight());
|
|
42810
43793
|
var size = Math.min(width, height);
|
|
42811
|
-
var cx = parsePercent$1(center[0], width);
|
|
42812
|
-
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;
|
|
42813
43796
|
var r0 = parsePercent$1(radius[0], size / 2);
|
|
42814
43797
|
var r = parsePercent$1(radius[1], size / 2);
|
|
42815
43798
|
|
|
@@ -42855,7 +43838,8 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42855
43838
|
r0: r0,
|
|
42856
43839
|
r: roseType
|
|
42857
43840
|
? NaN
|
|
42858
|
-
: r
|
|
43841
|
+
: r,
|
|
43842
|
+
viewRect: viewRect
|
|
42859
43843
|
});
|
|
42860
43844
|
return;
|
|
42861
43845
|
}
|
|
@@ -42888,7 +43872,8 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42888
43872
|
r0: r0,
|
|
42889
43873
|
r: roseType
|
|
42890
43874
|
? linearMap(value, extent, [r0, r])
|
|
42891
|
-
: r
|
|
43875
|
+
: r,
|
|
43876
|
+
viewRect: viewRect
|
|
42892
43877
|
});
|
|
42893
43878
|
|
|
42894
43879
|
currentAngle = endAngle;
|
|
@@ -42926,7 +43911,7 @@ var pieLayout = function (seriesType, ecModel, api, payload) {
|
|
|
42926
43911
|
}
|
|
42927
43912
|
}
|
|
42928
43913
|
|
|
42929
|
-
labelLayout(seriesModel, r, width, height);
|
|
43914
|
+
labelLayout(seriesModel, r, viewRect.width, viewRect.height, viewRect.x, viewRect.y);
|
|
42930
43915
|
});
|
|
42931
43916
|
};
|
|
42932
43917
|
|