chartOptions.redraw is not a function in highcharts using angular

偶尔善良 提交于 2021-01-29 09:17:21

问题


This is the html code

<highcharts-chart
  *ngIf="!isLoading"
  [Highcharts]="Highcharts"
  [options]="chartOptions"
  [(update)]="updateChart"
  style="width: 100%; height: 100%; display: block;"
></highcharts-chart>

enter code here

This is the typescriptcode


 onTogglevolume() {
    this.chartOptions.series[2].visible = !this.chartOptions.series[2].visible;

    this.chartOptions = {
      ...this.chartOptions
    };
    this.chartOptions.redraw();

  }

These are import statements

import * as Highcharts from 'highcharts';
import { Options } from "highcharts";
import StockModule from 'highcharts/modules/stock';
StockModule(Highcharts);

回答1:


The load event is only fired once at the begging so it's not the perfect place for more dynamic changes. Instead of this, I suggest using some other event. I guess you are going to calculate the colour of each column after changing the time range. In this case, you should use for example the afterSetExtremes events as I did it in the demo. I also have created a separate method called colorVolume. Inside using the chart reference I used the point update method to change the first column colour.

Demo:
https://stackblitz.com/edit/highcharts-angular-basic-line-fvtyrx
API:
https://api.highcharts.com/highcharts/xAxis.events.afterSetExtremes
https://api.highcharts.com/class-reference/Highcharts.Point#update



来源:https://stackoverflow.com/questions/64889389/chartoptions-redraw-is-not-a-function-in-highcharts-using-angular

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