angular - AmCharts Legend,如何在图表中的数据更改上重新单击未单击的图例
问题描述
我有一个来自 Am 图表的不同堆积条形图 ,我为其构建了自定义过滤器,过滤器通过用新的预先准备好的 JSON 数据替换整个 amChart.data 来更改数据。我正在使用带有打字稿且没有后端的 Angular 8,JSON 数据保存在资产中并由服务加载,然后传递到图表。
这些是相关的代码片段,不幸的是我不能分享整个代码。
@Input() dataToDisplay: EventEmitter<any>;
private amChart: any;
constructor(private wh: WarehouseService) {}
ngOnInit() {
this.currentYearDisplayed.subscribe(async year => {
await this.wh.loadData(year);
this.loadDataIntoChart();
});
this.dataToDisplay.subscribe(data => {
if (this.amChart) {
this.amChart.data = data;
this.amChart.invalidateData();
}
});
}
loadDataIntoChart() {
if (this.amChart) {
this.amChart.data = this.wh.filteredSet;
}
}
我取消点击 Legend Aufwand,深蓝色线条消失。我单击一个更改数据并重新加载的过滤器(而 Aufwand Legend 仍未被点击)
我的图例代码是
// Legend
this.amChart.legend = new am4charts.Legend();
this.amChart.legend.position = "right";
this.amChart.legend.width = 100;
我一直在尝试做的只是在加载数据之前重新单击所有关于数据更改的非活动图例,我在文档中或在 stackoverflow 中找不到正确的设置。
任何帮助表示赞赏,并提前感谢您。
解决方案
您可以通过 API 调用show()
对象上的方法来取消隐藏隐藏的系列。
以下将取消隐藏所有系列:
this.amChart.series.each(function(series) {
series.show();
});
推荐阅读
- android - AndroidXMapFragment 从片段初始化时返回 null
- javascript - 为什么 load 没有加载我的 data.text 文件?
- angular - 具有角度和弹簧引导的路由权限的用户登录
- java - Java 奇怪的泛型行为
- python - 如何根据条件删除嵌套列表的元素?
- aem - 在 AEM 6.5 和 Java 11 上打开页面属性时在日志中使用 NPE 发出警告
- java - Open Trip Planner 实时测试
- devexpress - DATAGRIDVIEW 和 DEVEXPRESS 的 GRIDVIEW
- python - 如何仅从 libdiff 比较结果中过滤 delta?
- java - 无法从更新(观察者)方法添加/克隆数组列表