Skip to content

Commit

Permalink
fix sankey frequent flashing with hovering on the node and edge apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
deqingli committed Nov 6, 2019
1 parent 0f90a73 commit aaf6c3a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/chart/graph/GraphView.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default echarts.extendChartView({

type: 'graph',

_focusState: true,

init: function (ecModel, api) {
var symbolDraw = new SymbolDraw();
var lineDraw = new LineDraw();
Expand All @@ -94,6 +96,7 @@ export default echarts.extendChartView({
},

render: function (seriesModel, ecModel, api) {
var graphView = this;
var coordSys = seriesModel.coordinateSystem;

this._model = seriesModel;
Expand Down Expand Up @@ -163,14 +166,16 @@ export default echarts.extendChartView({

if (itemModel.get('focusNodeAdjacency')) {
el.on('mouseover', el[FOCUS_ADJACENCY] = function () {
graphView._focusState = true;
api.dispatchAction({
type: 'focusNodeAdjacency',
seriesId: seriesModel.id,
dataIndex: el.dataIndex
});
});
el.on('mouseout', el[UNFOCUS_ADJACENCY] = function () {
api.dispatchAction({
graphView._focusState = false;
graphView._dispatchUnfocus(api, {
type: 'unfocusNodeAdjacency',
seriesId: seriesModel.id
});
Expand All @@ -187,14 +192,16 @@ export default echarts.extendChartView({

if (edge.getModel().get('focusNodeAdjacency')) {
el.on('mouseover', el[FOCUS_ADJACENCY] = function () {
graphView._focusState = true;
api.dispatchAction({
type: 'focusNodeAdjacency',
seriesId: seriesModel.id,
edgeDataIndex: edge.dataIndex
});
});
el.on('mouseout', el[UNFOCUS_ADJACENCY] = function () {
api.dispatchAction({
graphView._focusState = false;
graphView._dispatchUnfocus(api, {
type: 'unfocusNodeAdjacency',
seriesId: seriesModel.id
});
Expand Down Expand Up @@ -244,13 +251,31 @@ export default echarts.extendChartView({
});

this._firstRender = false;

this._unfocusDelayCache = [];
},

dispose: function () {
this._controller && this._controller.dispose();
this._controllerHost = {};
},

_dispatchUnfocus: function (api, opt) {
var self = this;
this._unfocusDelayCache.push(opt);
if (this._unfocusDelayTimer == null) {
this._unfocusDelayTimer = setTimeout(function () {
self._unfocusDelayTimer = null;
for (var i = 0; i < self._unfocusDelayCache.length; i++) {
if (!self._focusState) {
api.dispatchAction(self._unfocusDelayCache[i]);
}
}
self._unfocusDelayCache.length = 0;
}, 500);
}
},

focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
var data = this._model.getData();
var graph = data.graph;
Expand Down

0 comments on commit aaf6c3a

Please sign in to comment.