2016-05-16 103 views
3

我已經創建了一個highcharts氣泡圖如下:Highcharts - 氣泡圖 - 移動網格線

jsFiddle

如果可能的話,我想a軸網格線是在氣泡的中間。

有沒有辦法實現這一目標?

下面的代碼:

$(function() { 

    var data = [{ x: 0, y: 1, z: 1, dataSeries: 'data #1', dataPerc: '1.2' }, 
       { x: 1, y: 2, z: 2, dataSeries: 'data #2', dataPerc: '2.2' }, 
       { x: 2, y: 0, z: 0, dataSeries: 'data #3', dataPerc: '19.2' }, 
       { x: 3, y: 7, z: 7, dataSeries: 'data #4', dataPerc: '12.0' }, 
       { x: 4, y: 5, z: 5, dataSeries: 'data #5', dataPerc: '24' }, 
       { x: 5, y: 4, z: 4, dataSeries: 'data #6', dataPerc: '12' }, 
       { x: 6, y: 3, z: 3, dataSeries: 'data #7', dataPerc: '15.3' }, 
       { x: 7, y: 3, z: 3, dataSeries: 'data #8', dataPerc: '1.2' }];   

    $('#container').highcharts({ 

     chart: { 
      type: 'bubble', 
      plotBorderWidth: 1, 
      zoomType: 'xy' 
     }, 
      credits: false, 

     legend: { 
      enabled: false 
     }, 

     title: { 
      text: '' 
     }, 

     xAxis: { 
      gridLineWidth: 1, 
      title: { 
       text: '' 
      }, 
      categories: ['data #1', 'data #2', 'data #3', 'data #4', 'data #5', 'data #6', 'data#7', 'data #8'] 
     }, 

     yAxis: { 
      startOnTick: true, 
      min: 0, 
      max: 7, 
      title: { 
       text: 'Score' 
      }, 
      labels: { 
       format: '{value}' 
      }, 
      maxPadding: 0.2 
     }, 

     tooltip: { 
      useHTML: true, 
      headerFormat: '<table>', 
      pointFormat: '<tr><th colspan="2"><h3>{point.dataSeries}</h3></th></tr>' + 
       '<tr><th>Score:</th><td>{point.y}</td></tr>' + 
       '<tr><th>Percentage:</th><td>{point.dataPerc}%</td></tr>', 
      footerFormat: '</table>', 
      followPointer: true 
     }, 

     plotOptions: { 
      series: { 
       dataLabels: { 
        enabled: true, 
        format: '{point.name}' 
       } 
      } 
     }, 
     series: [{ data: data }] 
    }); 
}); 

回答

6

可以使用tickmarkPlacement option

xAxis: { 
    tickmarkPlacement: 'on' 
} 

僅適用於分類軸。如果on刻度線標記放置在類別的中心,如果between刻度線標記放置在類別之間。如果tickInterval是1,則默認值是between,否則on。默認爲null

查看this updates JSFiddle舉例。

+0

破解 - 謝謝:) –