2017-08-03 77 views
0

我沒有看到範圍選擇器,但是我已經在代碼中寫入了該選擇器。 我一直在使用的變量,像初始化圖表:如何使用Highcharts功能獲得工作範圍選擇器?

var chart = Highcharts.chart('chartContainer', { 
    xAxis: { 
     type: 'datetime', 
     tickPixelInterval: 150 
    }, 
    yAxis: { 
     title: { 
      text: 'Érték' 
     }, 
     plotLines: [{ 
      value: 0, 
      width: 20, 
      color: '#FFFFFF' 
     }] 
    }, 
    //animation: Highcharts.svg, 
    boost: { 
     seGPUTranslations: true 
    }, 
    rangeSelector: { 
     buttonTheme: { // styles for the buttons 
      fill: 'none', 
      stroke: 'none', 
      'stroke-width': 0, 
      r: 8, 
      style: { 
       color: '#039', 
       fontWeight: 'bold' 
      }, 
      allButtonsEnabled: true, 
      states: { 
       hover: {}, 
       select: { 
        fill: '#039', 
        style: { 
         color: 'white' 
        } 
       } 
       // disabled: { ... } 
      } 
     } 
    }, 
    title: { 
     text: 'Prociszenzor' 
    }, 
    series: [] 
}); 

正如你看到它不包含任何系列,我也從另一個代碼添加:

chart.addSeries({ 
    type: 'line', 
    name: dataaa.ertekek[i].neve + " " + dataaa.ertekek[i].mertek, 
    data: [{ 
     y: dataaa.ertekek[i].ertek/100, 
     x: time 
    }] 
}); 

Dataaa是從JSON文件。 我將這個數組推到主圖表數組中,並使用addPoint函數爲其添加了點。我想製作一個範圍選擇器,但我不知道如何做到這一點。

回答

1

正如你沒有發佈你所期待的我假設的例子。

我根據您的代碼製作了以下jsfiddle。 請注意,我對您發佈的內容進行了以下更改。

<script src="https://code.highcharts.com/stock/highstock.js"></script> 
<script src="https://code.highcharts.com/stock/highcharts-more.js"></script> 

我注意到肯定,如果您使用的是highstock庫,但如果你想有一個範圍selctor,你應該。見highcharts.com/docs/chart-concepts/range-selector

var chart = Highcharts.stockChart('container', { 

我改變chart是一個stockChart

+0

嗯。我忘了寫入啓用:真,進入代碼。 – jhsznrbt