make tooltip jump instead of follow

Goes to left or right end of the chart when the crosshairs/mouse passes over it, instead of just following the crosshairs.
This commit is contained in:
Vanessa Dannenberg 2021-06-02 09:38:22 -04:00 committed by GitHub
parent 426daeb145
commit f0030e16ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,6 +168,14 @@ export default class CandleChart extends Vue {
opacity: 1,
},
},
// positioning copied from https://echarts.apache.org/en/option.html#tooltip.position
position: function (pos, params, dom, rect, size) {
// tooltip will be fixed on the right if mouse hovering on the left,
// and on the left if hovering on the right.
var obj = {top: 60};
obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 5;
return obj;
},
},
axisPointer: {
link: [{ xAxisIndex: 'all' }],