2016-08-05 44 views
-1

我有收集沉澱四種不同類型的數據的自動氣象站:隨着時間的推移期間Highcharts,繪圖沉澱的類型,數量和強度隨時間

  1. 打開/關閉沉澱事件
  2. 總體積在毫米
  3. 強度毫米/小時和
  4. 沉澱型

即:

0    No precipitation 
40    Precipitation present 
51    Light drizzle 
52    Moderate drizzle 
53    Heavy drizzle 

堆積酒吧可以通過降雨類型管理體積隨着時間的推移。

我想按時間分類圖表強度。我認爲根據類型更改標記顏色是對此的答案。請問有更好的解決方案嗎?

+0

戴夫,你找誰繪製兩個沉澱量和降水強度在同一張圖? –

+0

是@MikeZavarello這是我的目標 –

+0

戴夫,你怎麼看待使用兩個yAxs並添加一個系列到一個軸?看看這個例子:http://jsfiddle.net/csts55kf/1/ –

回答

0

基於您的要求的一個建議可能是使用雙軸的組合條形圖和折線圖(GrzegorzBlachliński提到)。

正如您所指出的那樣,堆積條形將有助於顯示每種降水類型的比較體積。然後,您可以疊加線條以顯示每種類型的強度。

我會建議選擇顏色,用戶可以很容易地與每種降水類型相關,特別是在兩種圖表類型之間。

這裏有一個粗略的草稿我編寫基於來自Highcharts網站演示圖表之一:

$(function() { 
 
    $('#container').highcharts({ 
 
     chart: { 
 
      type: 'column' 
 
     }, 
 
     title: { 
 
      text: 'Precipitation' 
 
     }, 
 
     xAxis: { 
 
      categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] 
 
     }, 
 
     yAxis: [{ 
 
      min: 0, 
 
      title: { 
 
       text: 'Preipitation volume (mm)' 
 
      }, 
 
      stackLabels: { 
 
       enabled: true, 
 
       style: { 
 
        fontWeight: 'bold', 
 
        color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' 
 
       } 
 
      } 
 
     },{ 
 
      min: 0, 
 
      title: { 
 
       text: 'Preipitation intensity (mm/hr)' 
 
      }, 
 
      opposite: true 
 
     }], 
 
     legend: { 
 
      //align: 'bottom', 
 
      //x: -30, 
 
      //verticalAlign: 'bottom', 
 
      //y: 25, 
 
      //floating: true, 
 
      backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white', 
 
      borderColor: '#CCC', 
 
      borderWidth: 1, 
 
      shadow: false 
 
     }, 
 
     tooltip: { 
 
      headerFormat: '<b>{point.x}</b><br/>', 
 
      pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}' 
 
     }, 
 
     plotOptions: { 
 
      column: { 
 
       stacking: 'normal', 
 
       dataLabels: { 
 
        enabled: true, 
 
        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', 
 
        style: { 
 
         textShadow: '0 0 3px black' 
 
        } 
 
       } 
 
      } 
 
     }, 
 
     series: [{ 
 
      name: 'rain', 
 
      data: [5, 3, 4, 7, 2], 
 
      color: '#b3b3ff' 
 
     }, { 
 
      name: 'sleet', 
 
      data: [2, 2, 3, 2, 1], 
 
      color: '#d9b3ff' 
 
     }, { 
 
      name: 'snow', 
 
      data: [3, 4, 4, 2, 5], 
 
      color: '#c2c2f0' 
 
     },{ 
 
      name: 'rain intensity', 
 
      data: [5, 3, 4, 7, 2], 
 
      color: 'blue', 
 
      type: 'line', 
 
      yAxis: 1 
 
     }, { 
 
      name: 'sleet intensity', 
 
      data: [2, 2, 3, 2, 1], 
 
      color: 'purple', 
 
      type: 'line', 
 
      yAxis: 1 
 
     }, { 
 
      name: 'snow intensity', 
 
      data: [3, 4, 4, 2, 5], 
 
      color: 'indigo', 
 
      type: 'line', 
 
      yAxis: 1 
 
     }] 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<script src="https://code.highcharts.com/modules/exporting.js"></script> 
 
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

如果你願意的話,我們也歡迎您從這個代碼在工作我在這裏創建的小提琴:http://jsfiddle.net/brightmatrix/kbk53n43/

我希望這對你有幫助。

enter image description here