我正在使用带有 ASP.NET MVC 4的JqPlot 。
这是来自 Jqplot示例之一的示例数据
var line1 = [['2008-06-30 8:00AM', 4], ['2008-7-30 8:00AM', 6.5], ['2008-8-30 8:00AM', 5.7], ['2008-9-30 8:00AM', 9], ['2008-10-30 8:00AM', 8.2]];
该对中的第一个值是 DateTime,另一个是值。
现在我试图从控制器中获得这样的价值,我正在使用Web Api Controller
我的动作如下
public List<Stats> GetGraphData()
{
var stats = new List<Stats>
{
new Stats {Date = DateTime.Now, Value = 4},
new Stats {Date = DateTime.Now.AddMonths(1), Value = 11},
new Stats {Date = DateTime.Now.AddMonths(2), Value = 5},
new Stats {Date = DateTime.Now.AddMonths(3), Value = 7},
};
return stats;
}
但返回的值是
[对象{日期=“2012-11-08T16:52:04.5047592+05:30”,值=4},[对象{日期=“2012-11-08T16:52:04.5047592+05:30”,值=4 }, ...
所以我决定尝试JSON.stringify()它给出了以下内容......
[{"日期":"2012-11-08T16:52:04.5047592+05:30","值":4},{"日期":"2012-12-08T16:52:04.5047592+05:30", "值":11},{"日期":"2013-01-08T16:52:04.5047592+05:30","值":5},{"日期":"2013-02-08T16:52:04.5047592 +05:30","价值":7}]
如何获得如下所示的格式?
[['2008-06-30 8:00AM', 4], ['2008-7-30 8:00AM', 6.5], ['2008-8-30 8:00AM', 5.7], ['2008-9-30 8:00AM', 9], ['2008-10-30 8:00AM', 8.2]];
请帮助我。
注意:请随时编辑我的问题的标题,我想不出其他任何东西:P