2013-04-25 84 views
0

我希望能爲造型線Highchart提供一些幫助。Highcharts造型問題

我想在這裏得到圖表看起來像圖像:

Example of my graph

但我掙扎着爬塊彩色標貼?

任何幫助將不勝感激!

感謝

$('#container').highcharts({ 
     chart: { 
      type: 'line', 
      plotBackgroundImage: 'images/fibre.jpg', 
      plotBorderWidth: 0, 


      /*, 
      marginRight: 130, 
      marginBottom: 25*/ 
     }, 
     title: 
     { 
      text : strTitle 
     }, 
     tooltip: 
     { 
      enabled: false 
     }, 
     xAxis: 
     { 
      categories: arrXAxis,    
      title: 
      { 
       text: strXTitle 
      }, 

     },   
     yAxis: 
     { 
      title: 
      { 
       text: '' 
      }, 
      labels: { 
       formatter: function() { 
        // return this.value +'?' 
        return(''); 
       } 
      }, 
      min: 0, 
      max: 10, 
      minorGridLineWidth: 0, 
      alternateGridColor: null, 
      gridLineWidth: 0, 
      plotBands: 
      [{ 
       from: intRedStart, 
       to: intRedEnd, 
       color: 'rgba(229, 28, 36, 0.6)', 
       label: 
       { 
        text: 'High Risk', 
        style: 
        { 
         color: '#606060' 
        } 
       } 
      }, 
      { 
       from: intAmberStart, 
       to: intAmberEnd, 
       color: 'rgba(239, 140, 30, 0.6)', 
       label: 
       { 
        text: 'Improvement', 
        style: 
        { 
         color: '#606060' 
        } 
       } 
      }, 
      { 
       from: intGreenStart, 
       to: intGreenEnd, 
       color: 'rgba(43, 174, 115, 0.6)', 
       label: 
       { 
        text: 'Healthy', 
        style: 
        { 
         color: '#606060' 
        } 
       } 
      } 


      ] 
     }, 
     legend: { 
      /* 
      layout: 'vertical', 
      align: 'right', 
      verticalAlign: 'top', 
      x: -10, 
      y: 100, 
      borderWidth: 0*/ 
     }, 
     series: 
     [{ 
      allowPointSelect: false,  
      showInLegend: false, 
      data: arrData 
     } /*, { 
       name: '1', 
       data: [10] 
      }, { 
       name: '2', 
       data: [0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0] 
      }, { 
       name: '3', 
       data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] 
      }*/] 
    }); 

回答

0

如果你看一下API doc for plotband labels,我想你應該能夠通過玩弄的「風格」,「對齊」和「verticalAlign」的屬性做類似圖像的東西。希望這有助於:)

編輯:這似乎是背景顏色不可能設置與labels.style對象。我想這是因爲標籤是一個SVG元素(更具體的tspan),所以它不支持標準HTML元素所做的所有CSS。然而,您可以通過對齊「頂部」和「左側」標籤並設置字體顏色來更接近您的目標。如果你真的需要的背景顏色,你可以看看這個:Background color of tspan element

0

您可以爲圖表http://api.highcharts.com/highcharts#chart.plotBackgroundImage設置plotBackgroundImage然後用plotBands http://jsfiddle.net/JRhaS/2/

plotBands: [{ // mark the weekend 
      color: 'rgba(155,255,155,0.5)', 
      from: 0, 
      to: 100 
     },{ // mark the weekend 
      color: 'rgba(100,255,200,0.5)', 
      from:100, 
      to: 200 
     }], 
    }, 
+0

嘿感謝您的答覆,但它的塊健康,改善,高風險的單色我試圖重新創建 - 而不是圖像上的不透明陰謀帶! – ojsglobal 2013-04-25 09:46:11

+0

有yuu試圖設置plotbands標籤? http://api.highcharts.com/highcharts#xAxis.plotBands.label? – 2013-04-25 09:48:00

+0

標籤有效,但設置背景色樣式似乎不起作用。圖表標籤也是如此。我無法找到一種方法來完成TheBounder想要的。我已更新他的帖子,在他的鏈接中添加圖表來源。 – SteveP 2013-04-25 12:40:51