1. This warning may appear when the Echarts chart is redrawn:There is a chart instance already initialized on the dom.
Reason: When we redraw the chart, the Dom instance still exists and will be initialized repeatedly.
Solution:
// 在初始化实例之前先将实例销毁,实例销毁后就无法再被使用了,然后再重新进行初始化
that.myChart && that.myChart.dispose()
2. Click event on the mobile terminal of the chart in Echarts (line chart, histogram):
When making the h5 chart on the mobile terminal, I found that if I want to click on a certain point or column, I need to click two or more times to trigger it. Reasons to be added. . .
Solution:
this.char.getZr().on('click',params => {
// 监听鼠标点击的图表区域
const pointInPixel= [params.offsetX, params.offsetY]
if (that.char.containPixel('grid',pointInPixel)) {
let xIndex=that.char.convertFromPixel({
seriesIndex:0},[params.offsetX, params.offsetY])[0]
if (data[xIndex]) {
that.newDate = data[xIndex].tradeDate.replace(/\//g,'.')
let realNumber = data[xIndex].rtnTotal
realNumber=realNumber+''
var number = realNumber.split(".");
var reg = /\d{1,3}(?=(\d{3})+$)/g
if(number.length===1){
realNumber = (number[0] + '').replace(reg, '$&,')
}
that.nowProfit = realNumber
}
document.getElementsByClassName('defaultDate')[0].style.background = '#f5effe'
}
})
3. Echarts chart – > move the mouse in and cancel the small hand:
When there is no need to click to jump in the chart, when the mouse moves into the current chart, the state of the small hand changes to an arrow.
// myChart是绘图的对象
myChart.getZr().on('mousemove', param => {
myChart.getZr().setCursorStyle('default')
// 若鼠标滑过区域位置在当前图表范围内 鼠标设置为小手
// if (radarChart.containPixel('grid', pointInPixel)) {
// radarChart.getZr().setCursorStyle('pointer')
// }
})