【发布时间】:2014-02-10 22:44:17
【问题描述】:
当页面最初加载时,我得到一组数据,并将其显示在浮动图表中。我有一个下拉菜单,允许用户选择“年初至今”或“月初至今”,一切正常,除了图表没有重绘图表,所以当您将选择更改为“月到日期”,它仍然在 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'
}
}
);
}
【问题讨论】:
-
你能告诉我你的问题的解决方案吗?其实我也有同样的问题。