How update option without reload chart (ng2-chart)

前提是你 提交于 2020-08-08 05:54:54

问题


I need to update option in the chart and I need to show the chart with new option. I WANT that the chart IS NOT RELOAD this is my ts.

   @ViewChild(BaseChartDirective)  chart: any;

lineChartOptions: any = {
    responsive: true,
    zoom:{
      // Boolean to enable zooming
      enabled: false,
      sensitivity: 0.5,
      // Enable drag-to-zoom behavior
      drag: true,

      // Zooming directions. Remove the appropriate direction to disable 
      // Eg. 'y' would only allow zooming in the y direction
      mode: 'xy',
      rangeMin: {
        // Format of min zoom range depends on scale type
        x: null,
        y: null
      },
      rangeMax: {
        // Format of max zoom range depends on scale type
        x: null,
        y: null
      }
    }

Now when an external event becames and I need to chage option and active zoom:

handleExternalEvent(){
 this.lineChartOptions.zoom.enabled=true;
    this.chart.chart.update();
}

The problem is update doesn't work. If I do "this.chart.refresh()" the new chart with new options it reloaded but, I don't want reload chart. ANyone can help me?

来源:https://stackoverflow.com/questions/53171508/how-update-option-without-reload-chart-ng2-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!