簡體   English   中英

刪除圖表時,AMCharts 5 圖例仍然存在

[英]AMCharts 5 legend stays when chart is deleted

我在我的 Angular 項目中使用了 AMCharts 5 圖表,該圖表需要在某個操作中刪除。 當我刪除圖表時,仍然顯示圖例工具提示。

這是我用來創建圖表的代碼:

 this.rootTest = am5.Root.new('test') this.chartTest = this.rootTest.container.children.push( am5xy.XYChart.new(this.rootTest, { panY: false, layout: this.rootTest.verticalLayout }) ); let xRenderer = am5xy.AxisRendererX.new(this.rootTest, { minGridDistance: 30 }); let xAxis = this.chartTest.xAxes.push( am5xy.CategoryAxis.new(this.rootTest, { renderer: xRenderer, categoryField: "category" }) ); let yAxis = this.chartTest.yAxes.push( am5xy.ValueAxis.new(this.rootTest, { min: 0, renderer: am5xy.AxisRendererY.new(this.rootTest, {}) }) ); let series = this.chartTest.series.push( am5xy.LineSeries.new(this.rootTest, { name: 'Serie', xAxis: xAxis, yAxis: yAxis, valueYField: 'yValue', categoryXField: "category", tooltip: am5.Tooltip.new(this.rootTest, { labelText: "{name} {categoryX}: [bold]{valueY}[/]" }) }) ); xAxis.data.setAll([{ category: 'category1' }, { category: 'category2' }]) series.data.setAll([{ category: 'category1', yValue: 10 }, { category: 'category2', yValue: 20 }]) this.chartTest.set("cursor", am5xy.XYCursor.new(this.rootTest, { behavior: "zoomX" })); let legend = this.chartTest.children.push(am5.Legend.new(this.rootTest, {})); legend.data.setAll(this.chartTest.series.values);

這是我刪除它的方法:

this.rootTest.container.children.clear();

我只有在將 cursor 添加到我的圖表時才會得到這個。

有沒有辦法刪除這些工具提示?

刪除前 刪除

我遇到了同樣的問題,我設法解決了。 我建議你參考這個問題並檢查root.dispose() function。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM