我是javascripting和jquery的新手。我用畫海軍報如何更改使用javascript動態顯示不同的div
我的第一個柱狀圖
<div id="bar1" style="width:600px;height:300px;"></div>
$(function() {
var css_id = "#bar1";
var data = [
{label: 'foo',color:'red', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
{label: 'bar',color:'blue', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
{label: 'baz',color:'green', data: [[1,100], [2,200], [3,300], [4,400], [5,500]]},
];
var options = {
series: {stack: 0,
lines: {show: false, steps: false },
bars: {show: true, barWidth: 0.4, align: 'center',},},
xaxis: {ticks: [[1,'One'], [2,'Two'], [3,'Three'], [4,'Four'], [5,'Five']]},
};
$.plot($(css_id), data, options);
});
我的第二個圖形
<div id="bar2" style="width:600px;height:300px;"></div>
var data = [
{label: 'foo', color:'red', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
{label: 'bar', color:'blue', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
{label: 'baz', color:'yellow', data: [[1,100], [2,200], [3,300], [4,400], [5,500]]},
];
$.plot($("#bar2"), data, {
series: {
stack: 1,
bars: {
show: true,
barWidth: 0.6,
fill:1
}
}
});
現在我有一個圖表中,我有2個條形圖...點擊事件按鈕
$(document).ready(function() {
......
});
現在我應該怎麼寫上的按鈕事件,這樣我動態地改變我的條形圖從<div id="bar1">
到<div id="bar2">
_Now我應該寫什麼按鈕事件的次數,這樣我動態地改變我的條形圖從...到< - - ?? – elclanrs 2012-02-16 20:09:50
用$('#bar1')隱藏一個div,隱藏()並顯示另一個$('#bar2').show(),反之亦然,如果你想顯示另一個。 – kand 2012-02-16 20:10:08
你有什麼嘗試? http://mattgemmell.com/2008/12/08/what-have-you-tried/ – 2012-02-16 20:10:10