2013-11-25 22 views
0

我使用flotcharts.org在我的網站上顯示一些數據,我希望通過點擊,複選框或打開選項點來打開或關閉(true或false)選項點按鈕。下面是一個例子,當點上(真):http://www.flotcharts.org/flot/examples/basic-options/index.html浮動圖表,打開或關閉'點'選項

+0

,什麼是你的問題,實現該例子嗎? – Raidri

+0

我很新的JavaScript和jQuery。我在硬編碼時設置選項沒有問題,但我不知道如何在「點擊」時更改它們。這是我現在的代碼:https://pastie.se/14b115ca – user1863502

回答

2

這是我可以編寫了最簡單的例子:

var plot = null; 
drawChart = function(showPoints) { 
    plot = $.plot($("#placeholder"), [ d1, d2, d3 ], { 
       series: { 
        lines: { show: true }, 
        points: { show: showPoints } 
       } 
      }); 
} 

drawChart(false); 

$('#button').click(function(){ 
    drawChart(!plot.getOptions().series.points.show);   
}); 

Fiddle here