2014-10-10 86 views
0

我需要三個單選按鈕字段來顯示柱狀圖上的年度,月度和週數據,這樣當我選擇任一選項時,顯示器應該是相應的。我在JQchart中發現了很多不同類型的顯示的例子,但是找不到這樣的例子。有沒有其他選擇取代單選按鈕?請幫忙根據在列頂部選擇的選項更改顯示JQchart

+0

向我們展示你的代碼!你已經嘗試了什麼?顯示您現有的代碼將鼓勵人們更多地幫助您。 – talegna 2014-10-10 12:57:30

回答

0

你最好打賭的是有三個系列的數據,每個數據一次。您可以使用單選按鈕上的監聽器輕鬆更換系列。

本質:

 <input type="radio" name="data" id="yearly" class="radioSelector" value="yearly">Yearly<br> 
     <input type="radio" name="data" id="monthly" class="radioSelector" value="monthly">Monthly<br> 
     <input type="radio" name="data" id="daily" class="radioSelector" value="daily">Daily 

     <script> 
     $('.radioSelector').click(function (event) { 

      // Set target ID 
      var id = $(event.target).attr('id'); 

      // get current series 
      var series = $('#jqChart').jqChart('option', 'series'); 

      // check which radio 
      switch (id) { 
       case 'yearly': 
        series = yearlydata; 
        break; 
       case 'monthly': 
        series = monthlydata; 
        break; 
       case 'daily': 
        series = dailydata; 
        break; 
      } 
      // update (redraw) the chart 
      $('#jqChart').jqChart('update'); 
     }); 
     </script> 
相關問題