Dan Dan
Dan Dan

Reputation: 41

MVC 4 Google Charts from SQL Server

I'm playing about with MVC 4 using C#, ASP.NET and Razor. I have set up the basic CRUD functionality using MS SQL Server and it all works fine.

I would now like to display that data in graphical format. I'm loving the Google charts API and have implemented charts using the static array examples with no worries.

The problem I am having now is that I can't seem to find many tutorials/links that explain how to display my MS SQL Data within Google Charts in an MVC-ish way.

Upvotes: 4

Views: 2660

Answers (1)

Thomas Harris
Thomas Harris

Reputation: 434

I'm not sure I fully understand what you are trying to achieve.

You want to return SQL data and then display this in a graph in the view?

If so could take the following approach:

  1. Return data from database in some Data access layer
  2. Load the data into a model. These two task could be done with Entity framework
  3. Return the data from the controller in a JSONResult
  4. In the view call the controller(you could also use a webapi) using Ajax.
  5. Bind result to graph in Ajax callback.

See the question below for more details.

How do I call a controller method from JQuery?

Upvotes: 2

Related Questions