2016-09-19 31 views
0

我使用Highcharts,我需要用不同顏色填充圖表的內側。高腳椅在不同背景顏色下填充圖表的內側

我已經試過:

chart: { 
    renderTo: ‘container’, 
    background-color: ‘#ff0000’ 
}, 

等等

但這只是改變整個圖表的背景。

下面是顯示我需要更改的屏幕截圖。

enter image description here

我怎樣才能做到這一點?

下面的代碼太:

<script type="text/javascript"> 

    $(function() { 


      window.chart = new Highcharts.StockChart({ 

       chart: { 
        renderTo: 'container' 

       }, 

       rangeSelector: { 
        selected: 1, 
        inputDateFormat: '%d-%m-%Y', 
        inputDateParser: function (value) { 
         value = value.split('-'); 
         return Date.UTC(
          parseInt(value[2]), 
          parseInt(value[1]) - 1, 
          parseInt(value[0]) 
         ); 
        }, 
       }, 

       title: { 
        text: '' 
       }, 

       plotOptions: { 
        series: { 
         cursor: 'pointer', 
         point: { 
          events: { 
           click: function() { 


           } 
          } 
         } 
        } 
       }, 

       series: [{ 
        name: 'label', 
        data: data, 
        tooltip: { 
         valueDecimals: 2 
       }}] 

      }, function(chart) { 

       // apply the date pickers 
       setTimeout(function() { 
        $('input.highcharts-range-selector', $('#' + chart.options.chart.renderTo)).datepicker() 
       }, 0) 
      }); 



     // Set the datepicker's date format 
     $.datepicker.setDefaults({ 
      dateFormat: 'dd-mm-yy', 
      onSelect: function(dateText) { 
       this.onchange(); 
       this.onblur(); 

      } 
     }); 




    }); 

</script> 
+3

你應該用你一系列的區域類型,而不是線型。然後在你的區域系列中,你可以添加fillColor參數:http://jsfiddle.net/Lf6wmr4g/ –

+0

試過了fillColor:'rgba(200,100,100,0.5)',但它只是在圖表的整齊底部着色 – QuepasaTio

+0

SO你能發佈一張圖片展示你如何看待你的圖表? –

回答

2

嘗試將圖表類型 「區」,並指定一個填充顏色:

chart: { 
    type: 'area' 
} 
plotOptions: { 
    area: { 
     fillColor: 'red' 
    } 
} 

演示:http://jsfiddle.net/remisture/dsuLzpqL/

+0

我已經添加了代碼...在哪裏添加此代碼? – QuepasaTio

-1

系列的部分被稱爲「區域',您可以按如下方式對它們着色http://api.highcharts.com/highcharts/plotOptions.line.zones

samp樂代碼:

series: [{ 
     data: [-10, -5, 0, 5, 10, 15, 10, 10, 5, 0, -5], 
     zones: [{ 
      value: 0, 
      color: '#f7a35c' 
     }, { 
      value: 10, 
      color: '#7cb5ec' 
     }, { 
      color: '#90ed7d' 
     }] 
    }] 

jsfiddle

+0

這只是着色線條。我需要的背景像fillColor:'rgba(200,100,100,0.5)', – QuepasaTio

+0

使用plotbands爲背景着色[jsfiddle](http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software /highcharts.com/tree/master/samples/highcharts/members/axis-addplotband/) –

+0

此答案更適合於您希望特定範圍或圖表的某些部分着色與原始海報的整個請求有關的情況在要被着色的線下面的繪圖區域。 –