优化 平移状态下 可以tips

This commit is contained in:
lVAL 2020-10-16 14:47:14 +08:00
parent 58c7914e8b
commit ba3104d9e9

View File

@ -78,7 +78,7 @@ export default {
zr.on('click', this.onClick, this) zr.on('click', this.onClick, this)
this.myChart.on('mousedown', this.onMouseDown); this.myChart.on('mousedown', this.onMouseDown);
this.myChart.on('mouseover', this.onMouseOver); this.myChart.on('mouseover', this.onMouseOver);
this.myChart.on('mouseout', this.onMouseOver); this.myChart.on('mouseout', this.onMouseOut);
this.myChart.on('mouseup', this.onMouseUP); this.myChart.on('mouseup', this.onMouseUP);
this.myChart.on('datazoom', this.onUpdatePosition); this.myChart.on('datazoom', this.onUpdatePosition);
window.addEventListener('resize', this.onUpdatePosition); window.addEventListener('resize', this.onUpdatePosition);
@ -91,7 +91,7 @@ export default {
zr.off('click', this.onClick); zr.off('click', this.onClick);
this.myChart.off('mousedown', this.onMouseDown); this.myChart.off('mousedown', this.onMouseDown);
this.myChart.off('mouseover', this.onMouseOver); this.myChart.off('mouseover', this.onMouseOver);
this.myChart.off('mouseout', this.onMouseOver); this.myChart.off('mouseout', this.onMouseOut);
this.myChart.off('mouseup', this.onMouseUP); this.myChart.off('mouseup', this.onMouseUP);
this.myChart.off('datazoom', this.onUpdatePosition); this.myChart.off('datazoom', this.onUpdatePosition);
window.removeEventListener('resize', this.onUpdatePosition); window.removeEventListener('resize', this.onUpdatePosition);
@ -122,6 +122,19 @@ export default {
}, },
onMouseOver(e) { onMouseOver(e) {
this.pixelExecCb(e, this.handleSelectLine); this.pixelExecCb(e, this.handleSelectLine);
if (this.action == 'Translate') {
setTimeout(() => {
this.onShapeMouseOver(e);
}, 200);
}
},
onMouseOut(e) {
this.pixelExecCb(e, this.handleSelectLine);
if (this.action == 'Translate') {
setTimeout(() => {
this.onShapeMouseOver(e);
}, 200);
}
}, },
onMouseUP(e) { onMouseUP(e) {
switch(this.action) { switch(this.action) {
@ -136,14 +149,25 @@ export default {
onShapePointDragging(e) { onShapePointDragging(e) {
if (this.selected) { if (this.selected) {
this.dragging = true; this.dragging = true;
this.pixelExecCb(e, this.handleDragging);
}
},
onShapeMouseOver() {
if (this.selected) {
this.myChart.dispatchAction({
type: 'showTip',
seriesIndex: this.selected.seriesIndex,
dataIndex: this.selected.dataIndex
});
}
},
onShapeMouseOut() {
if (this.selected) {
this.myChart.dispatchAction({ this.myChart.dispatchAction({
type: 'showTip', type: 'showTip',
seriesIndex: this.selected.seriesIndex, seriesIndex: this.selected.seriesIndex,
dataIndex: this.selected.dataIndex dataIndex: this.selected.dataIndex
}); });
this.pixelExecCb(e, this.handleDragging);
} }
}, },
setLineLight() { setLineLight() {
@ -193,11 +217,11 @@ export default {
cy: 0, cy: 0,
r: 10 r: 10
}, },
style: { invisible: true,
fill: 'rgba(0,0,0,0.0)'
},
draggable: 'horizontal', draggable: 'horizontal',
ondrag: echarts.util.curry(this.onShapePointDragging), ondrag: echarts.util.curry(this.onShapePointDragging),
onmouseover: echarts.util.curry(this.onShapeMouseOver),
onmouseout: echarts.util.curry(this.onShapeMouseOut),
z: 100 z: 100
} }
}, },
@ -301,6 +325,12 @@ export default {
option.graphic[0].elements = filters; option.graphic[0].elements = filters;
this.myChart.setOption(option, {notMerge: true}); this.myChart.setOption(option, {notMerge: true});
this.myChart.dispatchAction({
type: 'showTip',
seriesIndex: this.selected.seriesIndex,
dataIndex: this.selected.dataIndex
});
}, },
handleCreateMark({pointInPixel, yObj, xVal}) { handleCreateMark({pointInPixel, yObj, xVal}) {
const myChart = this.myChart; const myChart = this.myChart;