Page 1 of 1

Angular Highcharts - Removing y axis dynamically not working

Posted: Mon Nov 26, 2018 9:09 am
by bibek_n
Hi,

I am trying to add and remove series and axes dynamically. I am able to add series/axes dynamically, but while removing the series I am getting an error message in console saying "Requested Axes does not exist".

Adding series and axes:

Code: Select all

this.highchartCustomObj.addAxis({ 
          id: '1-Y',
          lineWidth: 2,
          gridLineDashStyle: 'Solid',
          gridLineWidth:1,
          title: {
            text: '1st y axis',
            style: {
              fontSize: '10px',
            },
            enabled: true	
          },
          labels: {
            format: '{value:.2f}',
            style: {
              fontSize: '10px',
            },
          },
          opposite: false
        },false,false);
        
        this.highchartCustomObj.addSeries({
          name: '1-name',
          id: '1',
          yAxis:'1-Y',
          data:data.data
        },false);
        
Code to remove series/axis:

Code: Select all

this.highchartCustomObj.get('1').remove(false);
this.highchartCustomObj.get('1-Y').remove(false);
this.updateChartFlag=true;
HTML code:

Code: Select all

<highcharts-chart [Highcharts]="Highcharts"
                        [options]="chartOptions"
                        [(update)]="updateChartFlag"
                        [oneToOne]=true  
                        (chartInstance)="logChartInstance($event)"                      
                        style="width: 100%; height: 400px; display: block;"
                    ></highcharts-chart>
logChartInstance:

Code: Select all

highchartCustomObj:any={};
  logChartInstance(chart: any) {
    this.highchartCustomObj=chart;
      console.log('Chart instance: ', chart);
    
  }
Thanks,
Bibek N

Re: Angular Highcharts - Removing y axis dynamically not working

Posted: Mon Nov 26, 2018 10:53 am
by bastss
Hello Bibek N,

Could you prepare an online demo and send to us to work on it?

Best regards!