Ajax data to FLOT chart in correct format?

∥☆過路亽.° 提交于 2019-11-29 12:22:51

1.) Convert the JSON string back to a javascript object in your javascript:

var jsObj = $.parseJSON(d); // using jquery method

2.) In your GetData method, your

dataLine1.data = "[[1356328800000,5],[1356933600000,3]]";

isn't going to work. That will make your data element a string in the JSON instead of a javascript array. It would be best to fix this in your WebMethod:

DataLines dataLine1 = new DataLines();
dataLine1.data = new List<int[]>();
dataLine1.data.Add(new int[] {1356328800000,5});
dataLine1.data.Add(new int[] {1356933600000,3});

That's totally untested (I've never used the JavaScriptSerializer before, but similar code works with the ServiceStack serializer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!