开发者

Using JS based visualization libraries with C#/Linq Collections

I've done a number of asp.net webforms projects, and any charting/grid type stuff I have achieved with server side controls such as Telerik which have nicely taken care of the client side. However, there are some amazing viz libraries such as D3 (http://mbostock.github.com/d3/ex/) and javascript infovis toolkit (http://thejit.org/).

I'd love to give them a go; I've had some limited experience with Java in addition to C#, and normally massage my data into a collection using LINQ. I have a general idea of what JSON is but haven't seen how to plumb it all together. The java world tends not to talk much about .NE开发者_JS百科T integration though, for understandable reasons.

Does anyone know of any example projects or getting started guides that would demonstrate how to take a Linq collection (lets say a collection of simple objects each containing name, and salary values), throwing that out via JSON or whatever is needed, and then consuming and displaying it on the client side with one of these javascript libraries?

Thanks!

PS. I've tagged this with JSON but that's a guess, feel free to retag...


from a 10,000 foot view, look at writing a wcf web service. if you're your returning a collection like a List<> or something of that nature wcf will automatically serialize it to json for you, just tag it with [WebGet(ResponseFormat = WebMessageFormat.Json)] to specify that it should allow get requests and respond to them with json.

if you're using asp.net mvc and you don't want the overhead of a separate web service, add an action to your controller that returns a JsonResult. then you just return new Json(myListVariable); and you're done, properly formatted json sent to your web page.

i suppose i'm assuming you know how to make an ajax request... if not, download jquery, and look up $.post.

finally, if you're really looking for a cool graphing library, and you're cool with html5 being a requirement, check out gRaphael. its really neat.


I don't have any experience or resources for the library you are considering to use, but Google has real good examples for their charting libraries.

http://code.google.com/apis/chart/interactive/docs/examples.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜