bibek_n
Posts: 1
Joined: Fri Nov 23, 2018 7:36 am

Angular Highcharts - Removing y axis dynamically not working

Mon Nov 26, 2018 9:09 am

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

bastss
Posts: 134
Joined: Wed Oct 17, 2018 10:59 am

Re: Angular Highcharts - Removing y axis dynamically not working

Mon Nov 26, 2018 10:53 am

Hello Bibek N,

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

Best regards!

Return to “Highcharts Usage”