【问题标题】:Amcharts 3 Chart not Redrawing correctlyAmcharts 3 图表未正确重绘
【发布时间】:2020-03-16 03:20:39
【问题描述】:

我正在为我们的图表使用 Amcharts 3,并且我正在动态地在图表上添加/删除指南。如果用户选择了一个复选框,那么它会在图表中添加 2 个指南,但如果用户取消选择该复选框或选中另一个复选框,我希望删除这些指南。到目前为止,我已经正确添加了指南,但是当用户选择/取消选择另一个复选框时,由于某种原因,指南没有被删除。

这是我用来添加/删除指南的代码:

         let posReportTypeChart = chartingManager.getChartById("posReportType");
          // If only one Checkbox is Selected, add the Guides to the chart
            if (this.selectedQrCount == 1) {
                let selected = qrGridEvents.grid.dataSource.data().filter(x => x.IsSelected == true);
                let guideEffDate = this.getNewGuide(selected[0].EffectiveDate);
                let guideEndDate = this.getNewGuide(selected[0].EndDate);
                posReportTypeChart.guides.push(guideEffDate);
                posReportTypeChart.guides.push(guideEndDate);
                this.reDrawPOSReportTypeChart(posReportTypeChart);
            }
            else if (posReportTypeChart.guides.length > 1) {
                posReportTypeChart.guides = [];
                this.reDrawPOSReportTypeChart(posReportTypeChart);
            }

            // This is the function that I am using to redraw the chart. For some reason it is
               adding the Guides fine but whenever I go to remove the Guides this isn't working.
            private reDrawPOSReportTypeChart = (chart: any) => {
                  chartingManager.charts[3] = chart;
                  chart.dataProvider = chartingManager.itemChartingData;
                  chart.validateNow(true, false);
                  chart.invalidateSize();
                  chart.legend.validateNow();
              }

【问题讨论】:

    标签: asp.net-mvc typescript kendo-grid amcharts


    【解决方案1】:

    我找到了答案。您需要使用 chart.categoryAxis.addGuide 添加指南,然后只需使用 chart.categoryAxis.guides = [] 清除指南。只需确保在每次调用后使用 chart.validateData() 来添加或删除指南以重绘图表。

    【讨论】:

      猜你喜欢
      • 2013-11-20
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 2011-03-11
      • 1970-01-01
      相关资源
      最近更新 更多