當頁面初始加載時,我得到一組數據並將其顯示在浮動圖表中。我有一個允許用戶選擇「年迄今」或「月至日期」的下拉菜單,並且一切正常,除非圖表不重繪圖表,所以當您將選擇更改爲「月日期「,它仍然在x軸上列出所有日曆月份而不是月份的日期。我試過使用$.plot.setupGrid()
和$.plot.draw()
,也chartTaggedSpending.setupGrid()
和chartTaggedSpending.draw()
,它不工作,所以我在這裏做錯了什麼。預先感謝您提供的任何幫助。浮動圖表不會重新繪製
這裏有堪稱ajax.done()
功能塊代碼:
if(selectView = 1 && response.length != 0) {
var chartTaggedSpending = $('#tagged-spending');
var arrMonthLabels = [[1, 'Jan'], [2, 'Feb'], [3, 'Mar'],[4, 'Apr'],
[5, 'May'],[6, 'Jun'], [7, 'Jul'], [8, 'Aug'], [9, 'Sep'], [10, 'Oct'],
[11, 'Nov'], [12, 'Dec']];
$.plot(chartTaggedSpending,
[
{
data: response[1].data,
label: 'Budgeted: ' + response[1].label,
lines: { show: true},
points: { show: true, radius: 7 }
},
{
data: response[0].data,
label: 'Spent: ' + response[0].label,
lines: { show: true},
points: { show: true, radius: 7 }
}
],
{
colors: ['#a6db34', '#33a6db'],
legend: { show: true },
grid: { borderWidth: 0, hoverable: true, clickable: true },
yaxis: {min: 0, max: 2000, ticks: 10, tickColor: '#eeeeee' },
xaxis: {
min: 1,
max: 12,
ticks: arrMonthLabels,
tickColor: '#ffffff'
}
}
);
}
if(selectView = 0 && response.length != 0) {
var chartTaggedSpending = $('#tagged-spending');
$.plot(chartTaggedSpending,
[
{
data: response[1].data,
label: 'Budgeted: ' + response[1].label,
lines: { show: true},
points: { show: true, radius: 7 },
},
{
data: response[0].data,
label: 'Spent: ' + response[0].label,
lines: { show: true},
points: { show: true, radius: 7 }
}
],
{
colors: ['#a6db34', '#33a6db'],
legend: { show: true },
grid: { borderWidth: 0, hoverable: true, clickable: true },
yaxis: {min: 0, max: 1500, ticks: 10, tickColor: '#eeeeee' },
xaxis: {
min: 1,
max: 31,
ticks: 31,
tickColor: '#ffffff'
}
}
);
}
你能告訴我你的問題的解決方案嗎?其實我也有同樣的問題。 –