echarts 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/pull_request_template.md +66 -0
- package/.github/workflows/nodejs.yml +12 -2
- package/CONTRIBUTING.md +16 -160
- package/NOTICE +1 -1
- package/README.md +2 -2
- package/dist/echarts-en.common.js +684 -300
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +1070 -407
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +499 -222
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +684 -300
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +1070 -407
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +499 -222
- package/dist/echarts.simple.min.js +1 -1
- package/lib/chart/bar/BarSeries.js +14 -1
- package/lib/chart/bar/BarView.js +134 -14
- package/lib/chart/candlestick/candlestickVisual.js +1 -1
- package/lib/chart/funnel/FunnelSeries.js +1 -3
- package/lib/chart/graph/GraphSeries.js +2 -1
- package/lib/chart/graph/GraphView.js +2 -4
- package/lib/chart/helper/EffectLine.js +23 -1
- package/lib/chart/helper/Line.js +94 -33
- package/lib/chart/helper/createRenderPlanner.js +6 -3
- package/lib/chart/pie/PieView.js +1 -1
- package/lib/chart/radar/RadarSeries.js +20 -0
- package/lib/chart/sankey/SankeySeries.js +13 -1
- package/lib/chart/sankey/SankeyView.js +42 -23
- package/lib/chart/sankey/sankeyLayout.js +4 -3
- package/lib/chart/tree/TreeSeries.js +3 -0
- package/lib/chart/tree/TreeView.js +151 -25
- package/lib/chart/treemap/TreemapView.js +57 -27
- package/lib/component/axis/AxisBuilder.js +0 -1
- package/lib/component/axis/CartesianAxisView.js +7 -84
- package/lib/component/axis/SingleAxisView.js +21 -6
- package/lib/component/axis/axisSplitHelper.js +132 -0
- package/lib/component/brush/BrushView.js +11 -1
- package/lib/component/brush/visualEncoding.js +13 -2
- package/lib/component/helper/MapDraw.js +6 -8
- package/lib/component/legend/ScrollableLegendView.js +18 -18
- package/lib/component/marker/MarkLineModel.js +2 -1
- package/lib/component/marker/markerHelper.js +7 -4
- package/lib/component/tooltip/TooltipContent.js +60 -23
- package/lib/component/tooltip/TooltipView.js +6 -7
- package/lib/coord/View.js +9 -0
- package/lib/coord/radar/Radar.js +4 -4
- package/lib/echarts.js +2 -2
- package/lib/layout/barGrid.js +17 -10
- package/lib/layout/barPolar.js +0 -5
- package/lib/scale/Interval.js +2 -2
- package/lib/stream/Scheduler.js +9 -1
- package/lib/util/graphic.js +2 -2
- package/map/js/china.js +1 -1
- package/map/js/province/chongqing.js +1 -1
- package/map/js/province/tianjin.js +1 -28
- package/map/json/china.json +1 -1
- package/map/json/province/chongqing.json +1 -1
- package/package.json +10 -6
- package/src/chart/bar/BarSeries.js +15 -1
- package/src/chart/bar/BarView.js +136 -12
- package/src/chart/candlestick/candlestickVisual.js +1 -1
- package/src/chart/funnel/FunnelSeries.js +1 -2
- package/src/chart/graph/GraphSeries.js +2 -1
- package/src/chart/graph/GraphView.js +2 -2
- package/src/chart/helper/EffectLine.js +23 -1
- package/src/chart/helper/Line.js +84 -26
- package/src/chart/helper/createRenderPlanner.js +5 -2
- package/src/chart/pie/PieView.js +1 -1
- package/src/chart/pie/labelLayout.js +1 -1
- package/src/chart/radar/RadarSeries.js +22 -0
- package/src/chart/sankey/SankeySeries.js +12 -1
- package/src/chart/sankey/SankeyView.js +49 -21
- package/src/chart/sankey/sankeyLayout.js +4 -3
- package/src/chart/tree/TreeSeries.js +5 -0
- package/src/chart/tree/TreeView.js +155 -22
- package/src/chart/treemap/TreemapView.js +57 -27
- package/src/component/axis/AxisBuilder.js +1 -1
- package/src/component/axis/CartesianAxisView.js +3 -86
- package/src/component/axis/SingleAxisView.js +21 -4
- package/src/component/axis/axisSplitHelper.js +114 -0
- package/src/component/brush/BrushView.js +8 -1
- package/src/component/brush/visualEncoding.js +6 -3
- package/src/component/helper/MapDraw.js +6 -6
- package/src/component/legend/ScrollableLegendView.js +18 -16
- package/src/component/marker/MarkLineModel.js +2 -1
- package/src/component/marker/markerHelper.js +8 -5
- package/src/component/tooltip/TooltipContent.js +59 -22
- package/src/component/tooltip/TooltipView.js +9 -7
- package/src/coord/View.js +10 -1
- package/src/coord/radar/Radar.js +5 -7
- package/src/echarts.js +2 -2
- package/src/layout/barGrid.js +14 -7
- package/src/layout/barPolar.js +0 -4
- package/src/scale/Interval.js +2 -2
- package/src/stream/Scheduler.js +8 -0
- package/src/util/graphic.js +2 -2
|
@@ -22,6 +22,7 @@ import * as graphic from '../../util/graphic';
|
|
|
22
22
|
import AxisBuilder from './AxisBuilder';
|
|
23
23
|
import AxisView from './AxisView';
|
|
24
24
|
import * as cartesianAxisHelper from '../../coord/cartesian/cartesianAxisHelper';
|
|
25
|
+
import {rectCoordAxisBuildSplitArea, rectCoordAxisHandleRemove} from './axisSplitHelper';
|
|
25
26
|
|
|
26
27
|
var axisBuilderAttrs = [
|
|
27
28
|
'axisLine', 'axisTickLabel', 'axisName'
|
|
@@ -74,7 +75,7 @@ var CartesianAxisView = AxisView.extend({
|
|
|
74
75
|
},
|
|
75
76
|
|
|
76
77
|
remove: function () {
|
|
77
|
-
this
|
|
78
|
+
rectCoordAxisHandleRemove(this);
|
|
78
79
|
},
|
|
79
80
|
|
|
80
81
|
/**
|
|
@@ -206,91 +207,7 @@ var CartesianAxisView = AxisView.extend({
|
|
|
206
207
|
* @private
|
|
207
208
|
*/
|
|
208
209
|
_splitArea: function (axisModel, gridModel) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (axis.scale.isBlank()) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var splitAreaModel = axisModel.getModel('splitArea');
|
|
216
|
-
var areaStyleModel = splitAreaModel.getModel('areaStyle');
|
|
217
|
-
var areaColors = areaStyleModel.get('color');
|
|
218
|
-
|
|
219
|
-
var gridRect = gridModel.coordinateSystem.getRect();
|
|
220
|
-
|
|
221
|
-
var ticksCoords = axis.getTicksCoords({
|
|
222
|
-
tickModel: splitAreaModel,
|
|
223
|
-
clamp: true
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
if (!ticksCoords.length) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// For Making appropriate splitArea animation, the color and anid
|
|
231
|
-
// should be corresponding to previous one if possible.
|
|
232
|
-
var areaColorsLen = areaColors.length;
|
|
233
|
-
var lastSplitAreaColors = this._splitAreaColors;
|
|
234
|
-
var newSplitAreaColors = zrUtil.createHashMap();
|
|
235
|
-
var colorIndex = 0;
|
|
236
|
-
if (lastSplitAreaColors) {
|
|
237
|
-
for (var i = 0; i < ticksCoords.length; i++) {
|
|
238
|
-
var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
|
|
239
|
-
if (cIndex != null) {
|
|
240
|
-
colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
var prev = axis.toGlobalCoord(ticksCoords[0].coord);
|
|
247
|
-
|
|
248
|
-
var areaStyle = areaStyleModel.getAreaStyle();
|
|
249
|
-
areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
|
|
250
|
-
|
|
251
|
-
for (var i = 1; i < ticksCoords.length; i++) {
|
|
252
|
-
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
|
253
|
-
|
|
254
|
-
var x;
|
|
255
|
-
var y;
|
|
256
|
-
var width;
|
|
257
|
-
var height;
|
|
258
|
-
if (axis.isHorizontal()) {
|
|
259
|
-
x = prev;
|
|
260
|
-
y = gridRect.y;
|
|
261
|
-
width = tickCoord - x;
|
|
262
|
-
height = gridRect.height;
|
|
263
|
-
prev = x + width;
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
x = gridRect.x;
|
|
267
|
-
y = prev;
|
|
268
|
-
width = gridRect.width;
|
|
269
|
-
height = tickCoord - y;
|
|
270
|
-
prev = y + height;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
var tickValue = ticksCoords[i - 1].tickValue;
|
|
274
|
-
tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
|
|
275
|
-
|
|
276
|
-
this._axisGroup.add(new graphic.Rect({
|
|
277
|
-
anid: tickValue != null ? 'area_' + tickValue : null,
|
|
278
|
-
shape: {
|
|
279
|
-
x: x,
|
|
280
|
-
y: y,
|
|
281
|
-
width: width,
|
|
282
|
-
height: height
|
|
283
|
-
},
|
|
284
|
-
style: zrUtil.defaults({
|
|
285
|
-
fill: areaColors[colorIndex]
|
|
286
|
-
}, areaStyle),
|
|
287
|
-
silent: true
|
|
288
|
-
}));
|
|
289
|
-
|
|
290
|
-
colorIndex = (colorIndex + 1) % areaColorsLen;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
this._splitAreaColors = newSplitAreaColors;
|
|
210
|
+
rectCoordAxisBuildSplitArea(this, this._axisGroup, axisModel, gridModel);
|
|
294
211
|
}
|
|
295
212
|
});
|
|
296
213
|
|
|
@@ -23,12 +23,13 @@ import AxisBuilder from './AxisBuilder';
|
|
|
23
23
|
import * as graphic from '../../util/graphic';
|
|
24
24
|
import * as singleAxisHelper from '../../coord/single/singleAxisHelper';
|
|
25
25
|
import AxisView from './AxisView';
|
|
26
|
+
import {rectCoordAxisBuildSplitArea, rectCoordAxisHandleRemove} from './axisSplitHelper';
|
|
26
27
|
|
|
27
28
|
var axisBuilderAttrs = [
|
|
28
29
|
'axisLine', 'axisTickLabel', 'axisName'
|
|
29
30
|
];
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
+
var selfBuilderAttrs = ['splitArea', 'splitLine'];
|
|
32
33
|
|
|
33
34
|
var SingleAxisView = AxisView.extend({
|
|
34
35
|
|
|
@@ -42,21 +43,33 @@ var SingleAxisView = AxisView.extend({
|
|
|
42
43
|
|
|
43
44
|
group.removeAll();
|
|
44
45
|
|
|
46
|
+
var oldAxisGroup = this._axisGroup;
|
|
47
|
+
this._axisGroup = new graphic.Group();
|
|
48
|
+
|
|
45
49
|
var layout = singleAxisHelper.layout(axisModel);
|
|
46
50
|
|
|
47
51
|
var axisBuilder = new AxisBuilder(axisModel, layout);
|
|
48
52
|
|
|
49
53
|
zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
|
|
50
54
|
|
|
55
|
+
group.add(this._axisGroup);
|
|
51
56
|
group.add(axisBuilder.getGroup());
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
zrUtil.each(selfBuilderAttrs, function (name) {
|
|
59
|
+
if (axisModel.get(name + '.show')) {
|
|
60
|
+
this['_' + name](axisModel);
|
|
61
|
+
}
|
|
62
|
+
}, this);
|
|
63
|
+
|
|
64
|
+
graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
|
|
56
65
|
|
|
57
66
|
SingleAxisView.superCall(this, 'render', axisModel, ecModel, api, payload);
|
|
58
67
|
},
|
|
59
68
|
|
|
69
|
+
remove: function () {
|
|
70
|
+
rectCoordAxisHandleRemove(this);
|
|
71
|
+
},
|
|
72
|
+
|
|
60
73
|
_splitLine: function (axisModel) {
|
|
61
74
|
var axis = axisModel.axis;
|
|
62
75
|
|
|
@@ -125,6 +138,10 @@ var SingleAxisView = AxisView.extend({
|
|
|
125
138
|
silent: true
|
|
126
139
|
}));
|
|
127
140
|
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
_splitArea: function (axisModel) {
|
|
144
|
+
rectCoordAxisBuildSplitArea(this, this._axisGroup, axisModel, axisModel);
|
|
128
145
|
}
|
|
129
146
|
});
|
|
130
147
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import * as zrUtil from 'zrender/src/core/util';
|
|
21
|
+
import * as graphic from '../../util/graphic';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export function rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel) {
|
|
25
|
+
var axis = axisModel.axis;
|
|
26
|
+
|
|
27
|
+
if (axis.scale.isBlank()) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var splitAreaModel = axisModel.getModel('splitArea');
|
|
32
|
+
var areaStyleModel = splitAreaModel.getModel('areaStyle');
|
|
33
|
+
var areaColors = areaStyleModel.get('color');
|
|
34
|
+
|
|
35
|
+
var gridRect = gridModel.coordinateSystem.getRect();
|
|
36
|
+
|
|
37
|
+
var ticksCoords = axis.getTicksCoords({
|
|
38
|
+
tickModel: splitAreaModel,
|
|
39
|
+
clamp: true
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!ticksCoords.length) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// For Making appropriate splitArea animation, the color and anid
|
|
47
|
+
// should be corresponding to previous one if possible.
|
|
48
|
+
var areaColorsLen = areaColors.length;
|
|
49
|
+
var lastSplitAreaColors = axisView.__splitAreaColors;
|
|
50
|
+
var newSplitAreaColors = zrUtil.createHashMap();
|
|
51
|
+
var colorIndex = 0;
|
|
52
|
+
if (lastSplitAreaColors) {
|
|
53
|
+
for (var i = 0; i < ticksCoords.length; i++) {
|
|
54
|
+
var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
|
|
55
|
+
if (cIndex != null) {
|
|
56
|
+
colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var prev = axis.toGlobalCoord(ticksCoords[0].coord);
|
|
63
|
+
|
|
64
|
+
var areaStyle = areaStyleModel.getAreaStyle();
|
|
65
|
+
areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
|
|
66
|
+
|
|
67
|
+
for (var i = 1; i < ticksCoords.length; i++) {
|
|
68
|
+
var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
|
|
69
|
+
|
|
70
|
+
var x;
|
|
71
|
+
var y;
|
|
72
|
+
var width;
|
|
73
|
+
var height;
|
|
74
|
+
if (axis.isHorizontal()) {
|
|
75
|
+
x = prev;
|
|
76
|
+
y = gridRect.y;
|
|
77
|
+
width = tickCoord - x;
|
|
78
|
+
height = gridRect.height;
|
|
79
|
+
prev = x + width;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
x = gridRect.x;
|
|
83
|
+
y = prev;
|
|
84
|
+
width = gridRect.width;
|
|
85
|
+
height = tickCoord - y;
|
|
86
|
+
prev = y + height;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var tickValue = ticksCoords[i - 1].tickValue;
|
|
90
|
+
tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
|
|
91
|
+
|
|
92
|
+
axisGroup.add(new graphic.Rect({
|
|
93
|
+
anid: tickValue != null ? 'area_' + tickValue : null,
|
|
94
|
+
shape: {
|
|
95
|
+
x: x,
|
|
96
|
+
y: y,
|
|
97
|
+
width: width,
|
|
98
|
+
height: height
|
|
99
|
+
},
|
|
100
|
+
style: zrUtil.defaults({
|
|
101
|
+
fill: areaColors[colorIndex]
|
|
102
|
+
}, areaStyle),
|
|
103
|
+
silent: true
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
colorIndex = (colorIndex + 1) % areaColorsLen;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
axisView.__splitAreaColors = newSplitAreaColors;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function rectCoordAxisHandleRemove(axisView) {
|
|
113
|
+
axisView.__splitAreaColors = null;
|
|
114
|
+
}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import * as echarts from '../../echarts';
|
|
21
21
|
import * as zrUtil from 'zrender/src/core/util';
|
|
22
22
|
import BrushController from '../helper/BrushController';
|
|
23
|
+
import {layoutCovers} from './visualEncoding';
|
|
23
24
|
|
|
24
25
|
export default echarts.extendComponentView({
|
|
25
26
|
|
|
@@ -65,7 +66,13 @@ export default echarts.extendComponentView({
|
|
|
65
66
|
/**
|
|
66
67
|
* @override
|
|
67
68
|
*/
|
|
68
|
-
updateTransform:
|
|
69
|
+
updateTransform: function (brushModel, ecModel) {
|
|
70
|
+
// PENDING: `updateTransform` is a little tricky, whose layout need
|
|
71
|
+
// to be calculate mandatorily and other stages will not be performed.
|
|
72
|
+
// Take care the correctness of the logic. See #11754 .
|
|
73
|
+
layoutCovers(ecModel);
|
|
74
|
+
return updateController.apply(this, arguments);
|
|
75
|
+
},
|
|
69
76
|
|
|
70
77
|
/**
|
|
71
78
|
* @override
|
|
@@ -35,16 +35,19 @@ var PRIORITY_BRUSH = echarts.PRIORITY.VISUAL.BRUSH;
|
|
|
35
35
|
*/
|
|
36
36
|
echarts.registerLayout(PRIORITY_BRUSH, function (ecModel, api, payload) {
|
|
37
37
|
ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
|
|
38
|
-
|
|
39
38
|
payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
|
|
40
39
|
payload.key === 'brush' ? payload.brushOption : {brushType: false}
|
|
41
40
|
);
|
|
41
|
+
});
|
|
42
|
+
layoutCovers(ecModel);
|
|
43
|
+
});
|
|
42
44
|
|
|
45
|
+
export function layoutCovers(ecModel) {
|
|
46
|
+
ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
|
|
43
47
|
var brushTargetManager = brushModel.brushTargetManager = new BrushTargetManager(brushModel.option, ecModel);
|
|
44
|
-
|
|
45
48
|
brushTargetManager.setInputRanges(brushModel.areas, ecModel);
|
|
46
49
|
});
|
|
47
|
-
}
|
|
50
|
+
}
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
53
|
* Register the visual encoding if this modules required.
|
|
@@ -181,13 +181,13 @@ MapDraw.prototype = {
|
|
|
181
181
|
var regionsGroup = this._regionsGroup;
|
|
182
182
|
var group = this.group;
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
var transformInfo = geo.getTransformInfo();
|
|
185
|
+
group.transform = transformInfo.roamTransform;
|
|
186
|
+
group.decomposeTransform();
|
|
187
|
+
group.dirty();
|
|
188
188
|
|
|
189
|
-
var scale =
|
|
190
|
-
var position =
|
|
189
|
+
var scale = transformInfo.rawScale;
|
|
190
|
+
var position = transformInfo.rawPosition;
|
|
191
191
|
|
|
192
192
|
regionsGroup.removeAll();
|
|
193
193
|
|
|
@@ -459,26 +459,28 @@ var ScrollableLegendView = LegendView.extend({
|
|
|
459
459
|
},
|
|
460
460
|
|
|
461
461
|
_findTargetItemIndex: function (targetDataIndex) {
|
|
462
|
+
if (!this._showController) {
|
|
463
|
+
return 0;
|
|
464
|
+
}
|
|
465
|
+
|
|
462
466
|
var index;
|
|
463
467
|
var contentGroup = this.getContentGroup();
|
|
464
468
|
var defaultIndex;
|
|
465
469
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
});
|
|
481
|
-
}
|
|
470
|
+
contentGroup.eachChild(function (child, idx) {
|
|
471
|
+
var legendDataIdx = child.__legendDataIndex;
|
|
472
|
+
// FIXME
|
|
473
|
+
// If the given targetDataIndex (from model) is illegal,
|
|
474
|
+
// we use defualtIndex. But the index on the legend model and
|
|
475
|
+
// action payload is still illegal. That case will not be
|
|
476
|
+
// changed until some scenario requires.
|
|
477
|
+
if (defaultIndex == null && legendDataIdx != null) {
|
|
478
|
+
defaultIndex = idx;
|
|
479
|
+
}
|
|
480
|
+
if (legendDataIdx === targetDataIndex) {
|
|
481
|
+
index = idx;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
482
484
|
|
|
483
485
|
return index != null ? index : defaultIndex;
|
|
484
486
|
}
|
|
@@ -69,8 +69,8 @@ function markerTypeCalculatorWithExtent(
|
|
|
69
69
|
|
|
70
70
|
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
|
|
71
71
|
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
|
|
72
|
-
coordArr[targetCoordIndex] = data.get(
|
|
73
|
-
|
|
72
|
+
coordArr[targetCoordIndex] = data.get(calcDataDim, dataIndex);
|
|
73
|
+
var coordArrValue = data.get(targetDataDim, dataIndex);
|
|
74
74
|
// Make it simple, do not visit all stacked value to count precision.
|
|
75
75
|
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
|
|
76
76
|
precision = Math.min(precision, 20);
|
|
@@ -78,7 +78,7 @@ function markerTypeCalculatorWithExtent(
|
|
|
78
78
|
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
return coordArr;
|
|
81
|
+
return [coordArr, coordArrValue];
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
var curry = zrUtil.curry;
|
|
@@ -141,12 +141,15 @@ export function dataTransform(seriesModel, item) {
|
|
|
141
141
|
var otherCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
|
|
142
142
|
var targetCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
var coordInfo = markerTypeCalculator[item.type](
|
|
145
145
|
data, axisInfo.baseDataDim, axisInfo.valueDataDim,
|
|
146
146
|
otherCoordIndex, targetCoordIndex
|
|
147
147
|
);
|
|
148
|
+
item.coord = coordInfo[0];
|
|
148
149
|
// Force to use the value of calculated value.
|
|
149
|
-
item
|
|
150
|
+
// let item use the value without stack.
|
|
151
|
+
item.value = coordInfo[1];
|
|
152
|
+
|
|
150
153
|
}
|
|
151
154
|
else {
|
|
152
155
|
// FIXME Only has one of xAxis and yAxis.
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import * as zrUtil from 'zrender/src/core/util';
|
|
21
21
|
import * as zrColor from 'zrender/src/tool/color';
|
|
22
22
|
import * as eventUtil from 'zrender/src/core/event';
|
|
23
|
+
import * as domUtil from 'zrender/src/core/dom';
|
|
23
24
|
import env from 'zrender/src/core/env';
|
|
24
25
|
import * as formatUtil from '../../util/format';
|
|
25
26
|
|
|
@@ -121,24 +122,63 @@ function assembleCssText(tooltipModel) {
|
|
|
121
122
|
return cssText.join(';') + ';';
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
// If not able to make, do not modify the input `out`.
|
|
126
|
+
function makeStyleCoord(out, zr, appendToBody, zrX, zrY) {
|
|
127
|
+
var zrPainter = zr && zr.painter;
|
|
128
|
+
|
|
129
|
+
if (appendToBody) {
|
|
130
|
+
var zrViewportRoot = zrPainter && zrPainter.getViewportRoot();
|
|
131
|
+
if (zrViewportRoot) {
|
|
132
|
+
// Some APPs might use scale on body, so we support CSS transform here.
|
|
133
|
+
domUtil.transformLocalCoord(out, zrViewportRoot, document.body, zrX, zrY);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
out[0] = zrX;
|
|
138
|
+
out[1] = zrY;
|
|
139
|
+
// xy should be based on canvas root. But tooltipContent is
|
|
140
|
+
// the sibling of canvas root. So padding of ec container
|
|
141
|
+
// should be considered here.
|
|
142
|
+
var viewportRootOffset = zrPainter && zrPainter.getViewportRootOffset();
|
|
143
|
+
if (viewportRootOffset) {
|
|
144
|
+
out[0] += viewportRootOffset.offsetLeft;
|
|
145
|
+
out[1] += viewportRootOffset.offsetTop;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
124
150
|
/**
|
|
125
151
|
* @alias module:echarts/component/tooltip/TooltipContent
|
|
152
|
+
* @param {HTMLElement} container
|
|
153
|
+
* @param {ExtensionAPI} api
|
|
154
|
+
* @param {Object} [opt]
|
|
155
|
+
* @param {boolean} [opt.appendToBody]
|
|
156
|
+
* `false`: the DOM element will be inside the container. Default value.
|
|
157
|
+
* `true`: the DOM element will be appended to HTML body, which avoid
|
|
158
|
+
* some overflow clip but intrude outside of the container.
|
|
126
159
|
* @constructor
|
|
127
160
|
*/
|
|
128
|
-
function TooltipContent(container, api) {
|
|
161
|
+
function TooltipContent(container, api, opt) {
|
|
129
162
|
if (env.wxa) {
|
|
130
163
|
return null;
|
|
131
164
|
}
|
|
132
165
|
|
|
133
166
|
var el = document.createElement('div');
|
|
167
|
+
el.domBelongToZr = true;
|
|
168
|
+
this.el = el;
|
|
134
169
|
var zr = this._zr = api.getZr();
|
|
170
|
+
var appendToBody = this._appendToBody = opt && opt.appendToBody;
|
|
135
171
|
|
|
136
|
-
this.
|
|
172
|
+
this._styleCoord = [0, 0];
|
|
137
173
|
|
|
138
|
-
this.
|
|
139
|
-
this._y = api.getHeight() / 2;
|
|
174
|
+
makeStyleCoord(this._styleCoord, zr, appendToBody, api.getWidth() / 2, api.getHeight() / 2);
|
|
140
175
|
|
|
141
|
-
|
|
176
|
+
if (appendToBody) {
|
|
177
|
+
document.body.appendChild(el);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
container.appendChild(el);
|
|
181
|
+
}
|
|
142
182
|
|
|
143
183
|
this._container = container;
|
|
144
184
|
|
|
@@ -172,7 +212,8 @@ function TooltipContent(container, api) {
|
|
|
172
212
|
// Try trigger zrender event to avoid mouse
|
|
173
213
|
// in and out shape too frequently
|
|
174
214
|
var handler = zr.handler;
|
|
175
|
-
|
|
215
|
+
var zrViewportRoot = zr.painter.getViewportRoot();
|
|
216
|
+
eventUtil.normalizeEvent(zrViewportRoot, e, true);
|
|
176
217
|
handler.dispatch('mousemove', e);
|
|
177
218
|
}
|
|
178
219
|
};
|
|
@@ -217,12 +258,13 @@ TooltipContent.prototype = {
|
|
|
217
258
|
show: function (tooltipModel) {
|
|
218
259
|
clearTimeout(this._hideTimeout);
|
|
219
260
|
var el = this.el;
|
|
261
|
+
var styleCoord = this._styleCoord;
|
|
220
262
|
|
|
221
263
|
el.style.cssText = gCssText + assembleCssText(tooltipModel)
|
|
222
264
|
// Because of the reason described in:
|
|
223
265
|
// http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
|
|
224
266
|
// we should set initial value to `left` and `top`.
|
|
225
|
-
+ ';left:' +
|
|
267
|
+
+ ';left:' + styleCoord[0] + 'px;top:' + styleCoord[1] + 'px;'
|
|
226
268
|
+ (tooltipModel.get('extraCssText') || '');
|
|
227
269
|
|
|
228
270
|
el.style.display = el.innerHTML ? 'block' : 'none';
|
|
@@ -250,23 +292,13 @@ TooltipContent.prototype = {
|
|
|
250
292
|
return [el.clientWidth, el.clientHeight];
|
|
251
293
|
},
|
|
252
294
|
|
|
253
|
-
moveTo: function (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// should be considered here.
|
|
257
|
-
var zr = this._zr;
|
|
258
|
-
var viewportRootOffset;
|
|
259
|
-
if (zr && zr.painter && (viewportRootOffset = zr.painter.getViewportRootOffset())) {
|
|
260
|
-
x += viewportRootOffset.offsetLeft;
|
|
261
|
-
y += viewportRootOffset.offsetTop;
|
|
262
|
-
}
|
|
295
|
+
moveTo: function (zrX, zrY) {
|
|
296
|
+
var styleCoord = this._styleCoord;
|
|
297
|
+
makeStyleCoord(styleCoord, this._zr, this._appendToBody, zrX, zrY);
|
|
263
298
|
|
|
264
299
|
var style = this.el.style;
|
|
265
|
-
style.left =
|
|
266
|
-
style.top =
|
|
267
|
-
|
|
268
|
-
this._x = x;
|
|
269
|
-
this._y = y;
|
|
300
|
+
style.left = styleCoord[0] + 'px';
|
|
301
|
+
style.top = styleCoord[1] + 'px';
|
|
270
302
|
},
|
|
271
303
|
|
|
272
304
|
hide: function () {
|
|
@@ -292,6 +324,10 @@ TooltipContent.prototype = {
|
|
|
292
324
|
return this._show;
|
|
293
325
|
},
|
|
294
326
|
|
|
327
|
+
dispose: function () {
|
|
328
|
+
this.el.parentNode.removeChild(this.el);
|
|
329
|
+
},
|
|
330
|
+
|
|
295
331
|
getOuterSize: function () {
|
|
296
332
|
var width = this.el.clientWidth;
|
|
297
333
|
var height = this.el.clientHeight;
|
|
@@ -308,6 +344,7 @@ TooltipContent.prototype = {
|
|
|
308
344
|
|
|
309
345
|
return {width: width, height: height};
|
|
310
346
|
}
|
|
347
|
+
|
|
311
348
|
};
|
|
312
349
|
|
|
313
350
|
export default TooltipContent;
|
|
@@ -56,7 +56,9 @@ export default echarts.extendComponentView({
|
|
|
56
56
|
|
|
57
57
|
var tooltipContent;
|
|
58
58
|
if (this._renderMode === 'html') {
|
|
59
|
-
tooltipContent = new TooltipContent(api.getDom(), api
|
|
59
|
+
tooltipContent = new TooltipContent(api.getDom(), api, {
|
|
60
|
+
appendToBody: tooltipModel.get('appendToBody', true)
|
|
61
|
+
});
|
|
60
62
|
this._newLine = '<br/>';
|
|
61
63
|
}
|
|
62
64
|
else {
|
|
@@ -209,7 +211,6 @@ export default echarts.extendComponentView({
|
|
|
209
211
|
offsetX: payload.x,
|
|
210
212
|
offsetY: payload.y,
|
|
211
213
|
position: payload.position,
|
|
212
|
-
event: {},
|
|
213
214
|
dataByCoordSys: payload.dataByCoordSys,
|
|
214
215
|
tooltipOption: payload.tooltipOption
|
|
215
216
|
}, dispatchAction);
|
|
@@ -228,8 +229,7 @@ export default echarts.extendComponentView({
|
|
|
228
229
|
offsetX: cx,
|
|
229
230
|
offsetY: cy,
|
|
230
231
|
position: payload.position,
|
|
231
|
-
target: pointInfo.el
|
|
232
|
-
event: {}
|
|
232
|
+
target: pointInfo.el
|
|
233
233
|
}, dispatchAction);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -246,8 +246,7 @@ export default echarts.extendComponentView({
|
|
|
246
246
|
offsetX: payload.x,
|
|
247
247
|
offsetY: payload.y,
|
|
248
248
|
position: payload.position,
|
|
249
|
-
target: api.getZr().findHover(payload.x, payload.y).target
|
|
250
|
-
event: {}
|
|
249
|
+
target: api.getZr().findHover(payload.x, payload.y).target
|
|
251
250
|
}, dispatchAction);
|
|
252
251
|
}
|
|
253
252
|
},
|
|
@@ -353,7 +352,9 @@ export default echarts.extendComponentView({
|
|
|
353
352
|
_showAxisTooltip: function (dataByCoordSys, e) {
|
|
354
353
|
var ecModel = this._ecModel;
|
|
355
354
|
var globalTooltipModel = this._tooltipModel;
|
|
355
|
+
|
|
356
356
|
var point = [e.offsetX, e.offsetY];
|
|
357
|
+
|
|
357
358
|
var singleDefaultHTML = [];
|
|
358
359
|
var singleParamsList = [];
|
|
359
360
|
var singleTooltipModel = buildTooltipModel([
|
|
@@ -609,6 +610,7 @@ export default echarts.extendComponentView({
|
|
|
609
610
|
_updatePosition: function (tooltipModel, positionExpr, x, y, content, params, el) {
|
|
610
611
|
var viewWidth = this._api.getWidth();
|
|
611
612
|
var viewHeight = this._api.getHeight();
|
|
613
|
+
|
|
612
614
|
positionExpr = positionExpr || tooltipModel.get('position');
|
|
613
615
|
|
|
614
616
|
var contentSize = content.getSize();
|
|
@@ -727,7 +729,7 @@ export default echarts.extendComponentView({
|
|
|
727
729
|
if (env.node) {
|
|
728
730
|
return;
|
|
729
731
|
}
|
|
730
|
-
this._tooltipContent.
|
|
732
|
+
this._tooltipContent.dispose();
|
|
731
733
|
globalListener.unregister('itemTooltip', api);
|
|
732
734
|
}
|
|
733
735
|
});
|