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,7 +22,9 @@ import * as echarts from '../../echarts';
|
|
|
22
22
|
import * as zrUtil from 'zrender/src/core/util';
|
|
23
23
|
|
|
24
24
|
var nodeOpacityPath = ['itemStyle', 'opacity'];
|
|
25
|
+
var hoverNodeOpacityPath = ['emphasis', 'itemStyle', 'opacity'];
|
|
25
26
|
var lineOpacityPath = ['lineStyle', 'opacity'];
|
|
27
|
+
var hoverLineOpacityPath = ['emphasis', 'lineStyle', 'opacity'];
|
|
26
28
|
|
|
27
29
|
function getItemOpacity(item, opacityPath) {
|
|
28
30
|
return item.getVisual('opacity') || item.getModel().get(opacityPath);
|
|
@@ -30,8 +32,8 @@ function getItemOpacity(item, opacityPath) {
|
|
|
30
32
|
|
|
31
33
|
function fadeOutItem(item, opacityPath, opacityRatio) {
|
|
32
34
|
var el = item.getGraphicEl();
|
|
33
|
-
|
|
34
35
|
var opacity = getItemOpacity(item, opacityPath);
|
|
36
|
+
|
|
35
37
|
if (opacityRatio != null) {
|
|
36
38
|
opacity == null && (opacity = 1);
|
|
37
39
|
opacity *= opacityRatio;
|
|
@@ -49,12 +51,14 @@ function fadeInItem(item, opacityPath) {
|
|
|
49
51
|
var opacity = getItemOpacity(item, opacityPath);
|
|
50
52
|
var el = item.getGraphicEl();
|
|
51
53
|
|
|
52
|
-
el.highlight && el.highlight();
|
|
53
54
|
el.traverse(function (child) {
|
|
54
55
|
if (child.type !== 'group') {
|
|
55
56
|
child.setStyle('opacity', opacity);
|
|
56
57
|
}
|
|
57
58
|
});
|
|
59
|
+
|
|
60
|
+
// Support emphasis here.
|
|
61
|
+
el.highlight && el.highlight();
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
var SankeyShape = graphic.extendShape({
|
|
@@ -92,6 +96,14 @@ var SankeyShape = graphic.extendShape({
|
|
|
92
96
|
);
|
|
93
97
|
}
|
|
94
98
|
ctx.closePath();
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
highlight: function () {
|
|
102
|
+
this.trigger('emphasis');
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
downplay: function () {
|
|
106
|
+
this.trigger('normal');
|
|
95
107
|
}
|
|
96
108
|
});
|
|
97
109
|
|
|
@@ -274,8 +286,19 @@ export default echarts.extendChartView({
|
|
|
274
286
|
el.cursor = 'move';
|
|
275
287
|
}
|
|
276
288
|
|
|
289
|
+
el.highlight = function () {
|
|
290
|
+
this.trigger('emphasis');
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
el.downplay = function () {
|
|
294
|
+
this.trigger('normal');
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
el.focusNodeAdjHandler && el.off('mouseover', el.focusNodeAdjHandler);
|
|
298
|
+
el.unfocusNodeAdjHandler && el.off('mouseout', el.unfocusNodeAdjHandler);
|
|
299
|
+
|
|
277
300
|
if (itemModel.get('focusNodeAdjacency')) {
|
|
278
|
-
el.
|
|
301
|
+
el.on('mouseover', el.focusNodeAdjHandler = function () {
|
|
279
302
|
if (!sankeyView._focusAdjacencyDisabled) {
|
|
280
303
|
sankeyView._clearTimer();
|
|
281
304
|
api.dispatchAction({
|
|
@@ -285,7 +308,8 @@ export default echarts.extendChartView({
|
|
|
285
308
|
});
|
|
286
309
|
}
|
|
287
310
|
});
|
|
288
|
-
|
|
311
|
+
|
|
312
|
+
el.on('mouseout', el.unfocusNodeAdjHandler = function () {
|
|
289
313
|
if (!sankeyView._focusAdjacencyDisabled) {
|
|
290
314
|
sankeyView._dispatchUnfocus(api);
|
|
291
315
|
}
|
|
@@ -295,8 +319,12 @@ export default echarts.extendChartView({
|
|
|
295
319
|
|
|
296
320
|
edgeData.eachItemGraphicEl(function (el, dataIndex) {
|
|
297
321
|
var edgeModel = edgeData.getItemModel(dataIndex);
|
|
322
|
+
|
|
323
|
+
el.focusNodeAdjHandler && el.off('mouseover', el.focusNodeAdjHandler);
|
|
324
|
+
el.unfocusNodeAdjHandler && el.off('mouseout', el.unfocusNodeAdjHandler);
|
|
325
|
+
|
|
298
326
|
if (edgeModel.get('focusNodeAdjacency')) {
|
|
299
|
-
el.
|
|
327
|
+
el.on('mouseover', el.focusNodeAdjHandler = function () {
|
|
300
328
|
if (!sankeyView._focusAdjacencyDisabled) {
|
|
301
329
|
sankeyView._clearTimer();
|
|
302
330
|
api.dispatchAction({
|
|
@@ -306,7 +334,8 @@ export default echarts.extendChartView({
|
|
|
306
334
|
});
|
|
307
335
|
}
|
|
308
336
|
});
|
|
309
|
-
|
|
337
|
+
|
|
338
|
+
el.on('mouseout', el.unfocusNodeAdjHandler = function () {
|
|
310
339
|
if (!sankeyView._focusAdjacencyDisabled) {
|
|
311
340
|
sankeyView._dispatchUnfocus(api);
|
|
312
341
|
}
|
|
@@ -347,7 +376,7 @@ export default echarts.extendChartView({
|
|
|
347
376
|
},
|
|
348
377
|
|
|
349
378
|
focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
|
|
350
|
-
var data =
|
|
379
|
+
var data = seriesModel.getData();
|
|
351
380
|
var graph = data.graph;
|
|
352
381
|
var dataIndex = payload.dataIndex;
|
|
353
382
|
var itemModel = data.getItemModel(dataIndex);
|
|
@@ -367,15 +396,15 @@ export default echarts.extendChartView({
|
|
|
367
396
|
});
|
|
368
397
|
|
|
369
398
|
if (node) {
|
|
370
|
-
fadeInItem(node,
|
|
399
|
+
fadeInItem(node, hoverNodeOpacityPath);
|
|
371
400
|
var focusNodeAdj = itemModel.get('focusNodeAdjacency');
|
|
372
401
|
if (focusNodeAdj === 'outEdges') {
|
|
373
402
|
zrUtil.each(node.outEdges, function (edge) {
|
|
374
403
|
if (edge.dataIndex < 0) {
|
|
375
404
|
return;
|
|
376
405
|
}
|
|
377
|
-
fadeInItem(edge,
|
|
378
|
-
fadeInItem(edge.node2,
|
|
406
|
+
fadeInItem(edge, hoverLineOpacityPath);
|
|
407
|
+
fadeInItem(edge.node2, hoverNodeOpacityPath);
|
|
379
408
|
});
|
|
380
409
|
}
|
|
381
410
|
else if (focusNodeAdj === 'inEdges') {
|
|
@@ -383,8 +412,8 @@ export default echarts.extendChartView({
|
|
|
383
412
|
if (edge.dataIndex < 0) {
|
|
384
413
|
return;
|
|
385
414
|
}
|
|
386
|
-
fadeInItem(edge,
|
|
387
|
-
fadeInItem(edge.node1,
|
|
415
|
+
fadeInItem(edge, hoverLineOpacityPath);
|
|
416
|
+
fadeInItem(edge.node1, hoverNodeOpacityPath);
|
|
388
417
|
});
|
|
389
418
|
}
|
|
390
419
|
else if (focusNodeAdj === 'allEdges') {
|
|
@@ -392,21 +421,21 @@ export default echarts.extendChartView({
|
|
|
392
421
|
if (edge.dataIndex < 0) {
|
|
393
422
|
return;
|
|
394
423
|
}
|
|
395
|
-
fadeInItem(edge,
|
|
396
|
-
fadeInItem(edge.node1,
|
|
397
|
-
fadeInItem(edge.node2,
|
|
424
|
+
fadeInItem(edge, hoverLineOpacityPath);
|
|
425
|
+
(edge.node1 !== node) && fadeInItem(edge.node1, hoverNodeOpacityPath);
|
|
426
|
+
(edge.node2 !== node) && fadeInItem(edge.node2, hoverNodeOpacityPath);
|
|
398
427
|
});
|
|
399
428
|
}
|
|
400
429
|
}
|
|
401
430
|
if (edge) {
|
|
402
|
-
fadeInItem(edge,
|
|
403
|
-
fadeInItem(edge.node1,
|
|
404
|
-
fadeInItem(edge.node2,
|
|
431
|
+
fadeInItem(edge, hoverLineOpacityPath);
|
|
432
|
+
fadeInItem(edge.node1, hoverNodeOpacityPath);
|
|
433
|
+
fadeInItem(edge.node2, hoverNodeOpacityPath);
|
|
405
434
|
}
|
|
406
435
|
},
|
|
407
436
|
|
|
408
437
|
unfocusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
|
|
409
|
-
var graph =
|
|
438
|
+
var graph = seriesModel.getGraph();
|
|
410
439
|
|
|
411
440
|
graph.eachNode(function (node) {
|
|
412
441
|
fadeOutItem(node, nodeOpacityPath);
|
|
@@ -429,8 +458,7 @@ function createGridClipShape(rect, seriesModel, cb) {
|
|
|
429
458
|
});
|
|
430
459
|
graphic.initProps(rectEl, {
|
|
431
460
|
shape: {
|
|
432
|
-
width: rect.width + 20
|
|
433
|
-
height: rect.height + 20
|
|
461
|
+
width: rect.width + 20
|
|
434
462
|
}
|
|
435
463
|
}, seriesModel, cb);
|
|
436
464
|
|
|
@@ -87,7 +87,8 @@ function computeNodeValues(nodes) {
|
|
|
87
87
|
zrUtil.each(nodes, function (node) {
|
|
88
88
|
var value1 = sum(node.outEdges, getEdgeValue);
|
|
89
89
|
var value2 = sum(node.inEdges, getEdgeValue);
|
|
90
|
-
var
|
|
90
|
+
var nodeRawValue = node.getValue() || 0;
|
|
91
|
+
var value = Math.max(value1, value2, nodeRawValue);
|
|
91
92
|
node.setLayout({value: value}, true);
|
|
92
93
|
});
|
|
93
94
|
}
|
|
@@ -431,12 +432,12 @@ function getEdgeValue(edge) {
|
|
|
431
432
|
return edge.getValue();
|
|
432
433
|
}
|
|
433
434
|
|
|
434
|
-
function sum(array,
|
|
435
|
+
function sum(array, cb, orient) {
|
|
435
436
|
var sum = 0;
|
|
436
437
|
var len = array.length;
|
|
437
438
|
var i = -1;
|
|
438
439
|
while (++i < len) {
|
|
439
|
-
var value = +
|
|
440
|
+
var value = +cb.call(array, array[i], orient);
|
|
440
441
|
if (!isNaN(value)) {
|
|
441
442
|
sum += value;
|
|
442
443
|
}
|
|
@@ -139,6 +139,11 @@ export default SeriesModel.extend({
|
|
|
139
139
|
// the layout of the tree, two value can be selected, 'orthogonal' or 'radial'
|
|
140
140
|
layout: 'orthogonal',
|
|
141
141
|
|
|
142
|
+
// value can be 'polyline'
|
|
143
|
+
edgeShape: 'curve',
|
|
144
|
+
|
|
145
|
+
edgeForkPosition: '50%',
|
|
146
|
+
|
|
142
147
|
// true | false | 'move' | 'scale', see module:component/helper/RoamController.
|
|
143
148
|
roam: false,
|
|
144
149
|
|
|
@@ -27,6 +27,60 @@ import View from '../../coord/View';
|
|
|
27
27
|
import * as roamHelper from '../../component/helper/roamHelper';
|
|
28
28
|
import RoamController from '../../component/helper/RoamController';
|
|
29
29
|
import {onIrrelevantElement} from '../../component/helper/cursorHelper';
|
|
30
|
+
import { __DEV__ } from '../../config';
|
|
31
|
+
import {parsePercent} from '../../util/number';
|
|
32
|
+
|
|
33
|
+
var TreeShape = graphic.extendShape({
|
|
34
|
+
shape: {
|
|
35
|
+
parentPoint: [],
|
|
36
|
+
childPoints: [],
|
|
37
|
+
orient: '',
|
|
38
|
+
forkPosition: ''
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
style: {
|
|
42
|
+
stroke: '#000',
|
|
43
|
+
fill: null
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
buildPath: function (ctx, shape) {
|
|
47
|
+
var childPoints = shape.childPoints;
|
|
48
|
+
var childLen = childPoints.length;
|
|
49
|
+
var parentPoint = shape.parentPoint;
|
|
50
|
+
var firstChildPos = childPoints[0];
|
|
51
|
+
var lastChildPos = childPoints[childLen - 1];
|
|
52
|
+
|
|
53
|
+
if (childLen === 1) {
|
|
54
|
+
ctx.moveTo(parentPoint[0], parentPoint[1]);
|
|
55
|
+
ctx.lineTo(firstChildPos[0], firstChildPos[1]);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var orient = shape.orient;
|
|
60
|
+
var forkDim = (orient === 'TB' || orient === 'BT') ? 0 : 1;
|
|
61
|
+
var otherDim = 1 - forkDim;
|
|
62
|
+
var forkPosition = parsePercent(shape.forkPosition, 1);
|
|
63
|
+
var tmpPoint = [];
|
|
64
|
+
tmpPoint[forkDim] = parentPoint[forkDim];
|
|
65
|
+
tmpPoint[otherDim] = parentPoint[otherDim] + (lastChildPos[otherDim] - parentPoint[otherDim]) * forkPosition;
|
|
66
|
+
|
|
67
|
+
ctx.moveTo(parentPoint[0], parentPoint[1]);
|
|
68
|
+
ctx.lineTo(tmpPoint[0], tmpPoint[1]);
|
|
69
|
+
ctx.moveTo(firstChildPos[0], firstChildPos[1]);
|
|
70
|
+
tmpPoint[forkDim] = firstChildPos[forkDim];
|
|
71
|
+
ctx.lineTo(tmpPoint[0], tmpPoint[1]);
|
|
72
|
+
tmpPoint[forkDim] = lastChildPos[forkDim];
|
|
73
|
+
ctx.lineTo(tmpPoint[0], tmpPoint[1]);
|
|
74
|
+
ctx.lineTo(lastChildPos[0], lastChildPos[1]);
|
|
75
|
+
|
|
76
|
+
for (var i = 1; i < childLen - 1; i++) {
|
|
77
|
+
var point = childPoints[i];
|
|
78
|
+
ctx.moveTo(point[0], point[1]);
|
|
79
|
+
tmpPoint[forkDim] = point[forkDim];
|
|
80
|
+
ctx.lineTo(tmpPoint[0], tmpPoint[1]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
30
84
|
|
|
31
85
|
export default echarts.extendChartView({
|
|
32
86
|
|
|
@@ -87,6 +141,8 @@ export default echarts.extendChartView({
|
|
|
87
141
|
var seriesScope = {
|
|
88
142
|
expandAndCollapse: seriesModel.get('expandAndCollapse'),
|
|
89
143
|
layout: layout,
|
|
144
|
+
edgeShape: seriesModel.get('edgeShape'),
|
|
145
|
+
edgeForkPosition: seriesModel.get('edgeForkPosition'),
|
|
90
146
|
orient: seriesModel.getOrient(),
|
|
91
147
|
curvature: seriesModel.get('lineStyle.curveness'),
|
|
92
148
|
symbolRotate: seriesModel.get('symbolRotate'),
|
|
@@ -388,22 +444,72 @@ function updateNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
|
|
|
388
444
|
});
|
|
389
445
|
}
|
|
390
446
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
|
|
396
|
-
style: zrUtil.defaults({opacity: 0, strokeNoScale: true}, seriesScope.lineStyle)
|
|
397
|
-
});
|
|
398
|
-
}
|
|
447
|
+
drawEdge(
|
|
448
|
+
seriesModel, node, virtualRoot, symbolEl, sourceOldLayout,
|
|
449
|
+
sourceLayout, targetLayout, group, seriesScope
|
|
450
|
+
);
|
|
399
451
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function drawEdge(
|
|
455
|
+
seriesModel, node, virtualRoot, symbolEl, sourceOldLayout,
|
|
456
|
+
sourceLayout, targetLayout, group, seriesScope
|
|
457
|
+
) {
|
|
458
|
+
|
|
459
|
+
var edgeShape = seriesScope.edgeShape;
|
|
460
|
+
var edge = symbolEl.__edge;
|
|
461
|
+
if (edgeShape === 'curve') {
|
|
462
|
+
if (node.parentNode && node.parentNode !== virtualRoot) {
|
|
463
|
+
if (!edge) {
|
|
464
|
+
edge = symbolEl.__edge = new graphic.BezierCurve({
|
|
465
|
+
shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
|
|
466
|
+
style: zrUtil.defaults({opacity: 0, strokeNoScale: true}, seriesScope.lineStyle)
|
|
467
|
+
});
|
|
468
|
+
}
|
|
404
469
|
|
|
405
|
-
|
|
470
|
+
graphic.updateProps(edge, {
|
|
471
|
+
shape: getEdgeShape(seriesScope, sourceLayout, targetLayout),
|
|
472
|
+
style: {opacity: 1}
|
|
473
|
+
}, seriesModel);
|
|
474
|
+
}
|
|
406
475
|
}
|
|
476
|
+
else if (edgeShape === 'polyline') {
|
|
477
|
+
if (seriesScope.layout === 'orthogonal') {
|
|
478
|
+
if (node !== virtualRoot && node.children && (node.children.length !== 0) && (node.isExpand === true)) {
|
|
479
|
+
var children = node.children;
|
|
480
|
+
var childPoints = [];
|
|
481
|
+
for (var i = 0; i < children.length; i++) {
|
|
482
|
+
var childLayout = children[i].getLayout();
|
|
483
|
+
childPoints.push([childLayout.x, childLayout.y]);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (!edge) {
|
|
487
|
+
edge = symbolEl.__edge = new TreeShape({
|
|
488
|
+
shape: {
|
|
489
|
+
parentPoint: [targetLayout.x, targetLayout.y],
|
|
490
|
+
childPoints: [[targetLayout.x, targetLayout.y]],
|
|
491
|
+
orient: seriesScope.orient,
|
|
492
|
+
forkPosition: seriesScope.edgeForkPosition
|
|
493
|
+
},
|
|
494
|
+
style: zrUtil.defaults({opacity: 0, strokeNoScale: true}, seriesScope.lineStyle)
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
graphic.updateProps(edge, {
|
|
498
|
+
shape: {
|
|
499
|
+
parentPoint: [targetLayout.x, targetLayout.y],
|
|
500
|
+
childPoints: childPoints
|
|
501
|
+
},
|
|
502
|
+
style: {opacity: 1}
|
|
503
|
+
}, seriesModel);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
if (__DEV__) {
|
|
508
|
+
throw new Error('The polyline edgeShape can only be used in orthogonal layout');
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
group.add(edge);
|
|
407
513
|
}
|
|
408
514
|
|
|
409
515
|
function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope) {
|
|
@@ -413,6 +519,7 @@ function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
|
|
|
413
519
|
var seriesScope = getTreeNodeStyle(node, itemModel, seriesScope);
|
|
414
520
|
|
|
415
521
|
var source = node.parentNode === virtualRoot ? node : node.parentNode || node;
|
|
522
|
+
var edgeShape = seriesScope.edgeShape;
|
|
416
523
|
var sourceLayout;
|
|
417
524
|
while (sourceLayout = source.getLayout(), sourceLayout == null) {
|
|
418
525
|
source = source.parentNode === virtualRoot ? source : source.parentNode || source;
|
|
@@ -427,16 +534,42 @@ function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope)
|
|
|
427
534
|
|
|
428
535
|
symbolEl.fadeOut(null, {keepLabel: true});
|
|
429
536
|
|
|
430
|
-
var
|
|
537
|
+
var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
|
|
538
|
+
var sourceEdge = sourceSymbolEl.__edge;
|
|
539
|
+
|
|
540
|
+
// 1. when expand the sub tree, delete the children node should delete the edge of
|
|
541
|
+
// the source at the same time. because the polyline edge shape is only owned by the source.
|
|
542
|
+
// 2.when the node is the only children of the source, delete the node should delete the edge of
|
|
543
|
+
// the source at the same time. the same reason as above.
|
|
544
|
+
var edge = symbolEl.__edge
|
|
545
|
+
|| ((source.isExpand === false || source.children.length === 1) ? sourceEdge : undefined);
|
|
546
|
+
|
|
547
|
+
var edgeShape = seriesScope.edgeShape;
|
|
548
|
+
|
|
431
549
|
if (edge) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
550
|
+
if (edgeShape === 'curve') {
|
|
551
|
+
graphic.updateProps(edge, {
|
|
552
|
+
shape: getEdgeShape(seriesScope, sourceLayout, sourceLayout),
|
|
553
|
+
style: {
|
|
554
|
+
opacity: 0
|
|
555
|
+
}
|
|
556
|
+
}, seriesModel, function () {
|
|
557
|
+
group.remove(edge);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
else if (edgeShape === 'polyline' && seriesScope.layout === 'orthogonal') {
|
|
561
|
+
graphic.updateProps(edge, {
|
|
562
|
+
shape: {
|
|
563
|
+
parentPoint: [sourceLayout.x, sourceLayout.y],
|
|
564
|
+
childPoints: [[sourceLayout.x, sourceLayout.y]]
|
|
565
|
+
},
|
|
566
|
+
style: {
|
|
567
|
+
opacity: 0
|
|
568
|
+
}
|
|
569
|
+
}, seriesModel, function () {
|
|
570
|
+
group.remove(edge);
|
|
571
|
+
});
|
|
572
|
+
}
|
|
440
573
|
}
|
|
441
574
|
}
|
|
442
575
|
|
|
@@ -187,6 +187,7 @@ export default echarts.extendChartView({
|
|
|
187
187
|
var thisStorage = createStorage();
|
|
188
188
|
var oldStorage = this._storage;
|
|
189
189
|
var willInvisibleEls = [];
|
|
190
|
+
|
|
190
191
|
var doRenderNode = zrUtil.curry(
|
|
191
192
|
renderNode, seriesModel,
|
|
192
193
|
thisStorage, oldStorage, reRoot,
|
|
@@ -685,6 +686,11 @@ function renderNode(
|
|
|
685
686
|
// Start of closure variables available in "Procedures in renderNode".
|
|
686
687
|
|
|
687
688
|
var thisLayout = thisNode.getLayout();
|
|
689
|
+
var data = seriesModel.getData();
|
|
690
|
+
|
|
691
|
+
// Only for enabling highlight/downplay. Clear firstly.
|
|
692
|
+
// Because some node will not be rendered.
|
|
693
|
+
data.setItemGraphicEl(thisNode.dataIndex, null);
|
|
688
694
|
|
|
689
695
|
if (!thisLayout || !thisLayout.isInView) {
|
|
690
696
|
return;
|
|
@@ -724,14 +730,36 @@ function renderNode(
|
|
|
724
730
|
return group;
|
|
725
731
|
}
|
|
726
732
|
|
|
733
|
+
var nodeModel = thisNode.getModel();
|
|
734
|
+
|
|
727
735
|
// Background
|
|
728
736
|
var bg = giveGraphic('background', Rect, depth, Z_BG);
|
|
729
737
|
bg && renderBackground(group, bg, isParent && thisLayout.upperHeight);
|
|
730
738
|
|
|
731
739
|
// No children, render content.
|
|
732
|
-
if (
|
|
740
|
+
if (isParent) {
|
|
741
|
+
// Because of the implementation about "traverse" in graphic hover style, we
|
|
742
|
+
// can not set hover listener on the "group" of non-leaf node. Otherwise the
|
|
743
|
+
// hover event from the descendents will be listenered.
|
|
744
|
+
if (graphic.isHighDownDispatcher(group)) {
|
|
745
|
+
graphic.setAsHighDownDispatcher(group, false);
|
|
746
|
+
}
|
|
747
|
+
if (bg) {
|
|
748
|
+
graphic.setAsHighDownDispatcher(bg, true);
|
|
749
|
+
// Only for enabling highlight/downplay.
|
|
750
|
+
data.setItemGraphicEl(thisNode.dataIndex, bg);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
733
754
|
var content = giveGraphic('content', Rect, depth, Z_CONTENT);
|
|
734
755
|
content && renderContent(group, content);
|
|
756
|
+
|
|
757
|
+
if (bg && graphic.isHighDownDispatcher(bg)) {
|
|
758
|
+
graphic.setAsHighDownDispatcher(bg, false);
|
|
759
|
+
}
|
|
760
|
+
graphic.setAsHighDownDispatcher(group, true);
|
|
761
|
+
// Only for enabling highlight/downplay.
|
|
762
|
+
data.setItemGraphicEl(thisNode.dataIndex, group);
|
|
735
763
|
}
|
|
736
764
|
|
|
737
765
|
return group;
|
|
@@ -746,10 +774,17 @@ function renderNode(
|
|
|
746
774
|
bg.seriesIndex = seriesModel.seriesIndex;
|
|
747
775
|
|
|
748
776
|
bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
|
|
749
|
-
var visualBorderColor = thisNode.getVisual('borderColor', true);
|
|
750
|
-
var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
|
|
751
777
|
|
|
752
|
-
|
|
778
|
+
if (thisInvisible) {
|
|
779
|
+
// If invisible, do not set visual, otherwise the element will
|
|
780
|
+
// change immediately before animation. We think it is OK to
|
|
781
|
+
// remain its origin color when moving out of the view window.
|
|
782
|
+
processInvisible(bg);
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
bg.invisible = false;
|
|
786
|
+
var visualBorderColor = thisNode.getVisual('borderColor', true);
|
|
787
|
+
var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
|
|
753
788
|
var normalStyle = getItemStyleNormal(itemStyleNormalModel);
|
|
754
789
|
normalStyle.fill = visualBorderColor;
|
|
755
790
|
var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
|
|
@@ -769,8 +804,8 @@ function renderNode(
|
|
|
769
804
|
}
|
|
770
805
|
|
|
771
806
|
bg.setStyle(normalStyle);
|
|
772
|
-
graphic.
|
|
773
|
-
}
|
|
807
|
+
graphic.setElementHoverStyle(bg, emphasisStyle);
|
|
808
|
+
}
|
|
774
809
|
|
|
775
810
|
group.add(bg);
|
|
776
811
|
}
|
|
@@ -791,8 +826,15 @@ function renderNode(
|
|
|
791
826
|
height: contentHeight
|
|
792
827
|
});
|
|
793
828
|
|
|
794
|
-
|
|
795
|
-
|
|
829
|
+
if (thisInvisible) {
|
|
830
|
+
// If invisible, do not set visual, otherwise the element will
|
|
831
|
+
// change immediately before animation. We think it is OK to
|
|
832
|
+
// remain its origin color when moving out of the view window.
|
|
833
|
+
processInvisible(content);
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
content.invisible = false;
|
|
837
|
+
var visualColor = thisNode.getVisual('color', true);
|
|
796
838
|
var normalStyle = getItemStyleNormal(itemStyleNormalModel);
|
|
797
839
|
normalStyle.fill = visualColor;
|
|
798
840
|
var emphasisStyle = getItemStyleEmphasis(itemStyleEmphasisModel);
|
|
@@ -800,32 +842,19 @@ function renderNode(
|
|
|
800
842
|
prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
|
|
801
843
|
|
|
802
844
|
content.setStyle(normalStyle);
|
|
803
|
-
graphic.
|
|
804
|
-
}
|
|
845
|
+
graphic.setElementHoverStyle(content, emphasisStyle);
|
|
846
|
+
}
|
|
805
847
|
|
|
806
848
|
group.add(content);
|
|
807
849
|
}
|
|
808
850
|
|
|
809
|
-
function
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
// remain its origin color when moving out of the view window.
|
|
814
|
-
cb();
|
|
815
|
-
|
|
816
|
-
if (!element.__tmWillVisible) {
|
|
817
|
-
element.invisible = false;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
else {
|
|
821
|
-
// Delay invisible setting utill animation finished,
|
|
822
|
-
// avoid element vanish suddenly before animation.
|
|
823
|
-
!element.invisible && willInvisibleEls.push(element);
|
|
824
|
-
}
|
|
851
|
+
function processInvisible(element) {
|
|
852
|
+
// Delay invisible setting utill animation finished,
|
|
853
|
+
// avoid element vanish suddenly before animation.
|
|
854
|
+
!element.invisible && willInvisibleEls.push(element);
|
|
825
855
|
}
|
|
826
856
|
|
|
827
857
|
function prepareText(normalStyle, emphasisStyle, visualColor, width, height, upperLabelRect) {
|
|
828
|
-
var nodeModel = thisNode.getModel();
|
|
829
858
|
var text = zrUtil.retrieve(
|
|
830
859
|
seriesModel.getFormattedLabel(
|
|
831
860
|
thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'
|
|
@@ -922,6 +951,7 @@ function renderNode(
|
|
|
922
951
|
// Fade in, user can be aware that these nodes are new.
|
|
923
952
|
lastCfg.fadein = storageName !== 'nodeGroup';
|
|
924
953
|
}
|
|
954
|
+
|
|
925
955
|
}
|
|
926
956
|
|
|
927
957
|
// We can not set all backgroud with the same z, Because the behaviour of
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {retrieve, defaults, extend, each
|
|
20
|
+
import {retrieve, defaults, extend, each} from 'zrender/src/core/util';
|
|
21
21
|
import * as formatUtil from '../../util/format';
|
|
22
22
|
import * as graphic from '../../util/graphic';
|
|
23
23
|
import Model from '../../model/Model';
|