2016-05-13 40 views
0

我正在動態地將系列添加到我的空圖表中,通過添加一個系列,我還使用addAxis向它添加了一個新的軸,但是當添加我的第一個系列時,我總是得到兩個y軸,一個是我自己的,另一個是highcharts擁有默認的y軸。有沒有辦法禁用這個軸的自動創建?動態添加系列,如何擺脫默認的y軸?

init(): void { 
     this.chartOptions = { 
      chart: { 
       type: this.chart, 
       animation: Highcharts.svg, 
       zoomType: 'x' 
      }, 
      xAxis: { 
       type: this.x 
      }, 
      tooltip: { 
       shared: true, 
       crosshairs: true 
      } 
     } 

     $('#highchartcontainer').highcharts(this.chartOptions); 
    } 

    addSerie(tag: Tag): void { 
     this.addSeries(new Array<Tag>(tag)); 
    } 

    addSeries(tags: Tag[]): void { 

     for (let i = 0; i < tags.length; i++) { 
      let tag = tags[i]; 

      $('#highchartcontainer').highcharts().addAxis({ 
       id: i, 
       title: { 
        text: tag.getTitle(), 
        style: { 
         color: Highcharts.getOptions().colors[i] 
        } 
       }, 
       lineWidth: 2, 
       lineColor: Highcharts.getOptions().colors[i], 
       max: tag.getMaxValue() 
      }); 

      $('#highchartcontainer').highcharts().addSeries({ 
       turboThreshold: 0, 
       name: tag.getId(), 
       yAxis: i, 
       data: (function() { 
        var tag_data = new Array<Point>(); 
        for (var n = 0; n < tag.getData().length; n++) { 
         tag_data.push(new Point(tag.getData()[n].x, tag.getData()[n].y)); 
        } 
        return tag_data; 
       })() 
      }); 
     } 
    } 

https://imgur.com/gnfwKRD

如何擺脫黃標y軸的?

+0

您可以將默認值的可見性設置爲false。 –

+0

如何控制默認的屬性? –

+0

示例[here](http://jsfiddle.net/n10nqdyb/) –

回答

2

使用update設置默認值的可見性應該可以完成這項工作。

chart.yAxis[0].update({visible:false}); 

Here是小提琴。

+0

我想添加我的情況:$('#highchartcontainer')。highcharts()。yAxis [0] .update({visible:false}); –