2016-09-19 29 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

此答案更适合于您希望特定范围或图表的某些部分着色与原始海报的整个请求有关的情况在要被着色的线下面的绘图区域。 –