echart 上 TooltipContent.dispose 无法读取 null 属性(读取“removeChild”)

问题描述 投票:0回答:1

我正在为 echart(pie) 动态设置选项数据。我用它来动态设置选项

var myChart = echarts.init(document.getElementById('chartId'));
myChart.setOption(this.chartOption , true)

从该页面路由到另一个页面时,我在工具提示处置上收到错误

TypeError:无法读取 null 的属性(读取“removeChild”) 在 TooltipContent.dispose (TooltipContent.js:352:24)

这是我的选择:

 chartOption = {

    tooltip: {
      trigger: 'item'
    },
    series: [
      {
        name: 'Topics',
        type: 'pie',
        data: [],
        color: ["#378AFF", "#FFA32F", "#F54F52", "#3D0C11", "#9552ea", "#93F03B", "#FF2E7E", "#7AC142", "#127C56", "#1B5583"],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  };

我已经使用了合并,但就我而言,它不起作用

[merge]="dynamicData" in html
this.dynamicData = { ... this.chartOption }; in ts file

我希望根据我的要求更改图表数据和选项

angular charts javascript-objects echarts
1个回答
0
投票

您必须在导航之前处理图表实例。

// Before navigating to another page, dispose of the ECharts instance
myChart.dispose();

// Navigate to the new page
// ...
© www.soinside.com 2019 - 2024. All rights reserved.