-
Notifications
You must be signed in to change notification settings - Fork 19.8k
eChart tooltip error (TypeError) when mychart.dispose command is included #19248
Description
Version
5.4.3
Link to Minimal Reproduction
NA
Steps to Reproduce
_parentElement = document.querySelector('.main__table');
createChart(data) {
// Create the echarts instance
let myChart = echarts.getInstanceByDom(this._parentElement); //get any chart instance if it exist
console.log(myChart);
//Any existing chart has to be destroyed before a new one can be initialized
if (myChart != null && myChart != '' && myChart != undefined) {
myChart.dispose();
myChart = null;
}
// Initialize a new chart
myChart = echarts.init(this._parentElement, {
width: 1000,
height: 400,
});
let option = {
title: {
text: 'Monthly Sales',
fontFamily: 'Nunito Sans',
},
tooltip: {},
legend: {},
dataset: {
dimensions: ['Date', 'Sales'],
source: data,
},
xAxis: { type: 'category' },
yAxis: {},
series: [
{
type: 'bar',
},
],
};
// All the above is applied to the chart
myChart.setOption(option);
}
}
Current Behavior
When I perform a mychart.dispose(), I encounter the below error. However when I remove the option = {tooltip: {}), it works without error.
TypeError: Cannot read properties of null (reading 'removeChild')
at TooltipHTMLContent.dispose (TooltipHTMLContent.js:452:35)
at TooltipView.dispose (TooltipView.js:819:18)
at echarts.js:1082:7
at Array.forEach ()
at each (util.js:205:13)
at ECharts.dispose (echarts.js:1081:7)
at ChartView.createChart (chartView.js:25:15)
at controlCharts (mainController.js:258:15)
Expected Behavior
mychart.dispose() should not result in any tooltip error
Environment
- OS: Windows
- Browser: Chrome
- Framework: JavascriptAny additional comments?
No response