yanci1179
asked on
ASP.NET MVC 5 using Morris.js Charts
I was able to replicate Morris.js Charts in the following article
http://www.jqueryscript.net/chart-graph/Morris-Good-looking-Charts-Plugin.html
The charts have static data. I need to populate the charts with data that is coming from my SQL Sever Database.
Anyone have any idea on what I need to get started with this?
I was using Entity Framework. I created a context model with my control uses to pass the data to my View. The data displays fine in my view. How do I use this data to populate the charts?
Thank you!!
http://www.jqueryscript.net/chart-graph/Morris-Good-looking-Charts-Plugin.html
The charts have static data. I need to populate the charts with data that is coming from my SQL Sever Database.
Anyone have any idea on what I need to get started with this?
I was using Entity Framework. I created a context model with my control uses to pass the data to my View. The data displays fine in my view. How do I use this data to populate the charts?
Thank you!!
ASKER
I'm new to .net do you mind giving me a sample of where I would put this?
Here's what I have on the view section so far:
Morris.Donut({
element: 'morris-donut-chart',
data: [{ label: "Download Sales", value: 12 },
{ label: "In-Store Sales", value: 30 },
{ label: "Mail-Order Sales", value: 20 }],
resize: true,
colors: ['#87d6c6', '#54cdb4', '#1ab394'],
});
Here's what I have on the view section so far:
Morris.Donut({
element: 'morris-donut-chart',
data: [{ label: "Download Sales", value: 12 },
{ label: "In-Store Sales", value: 30 },
{ label: "Mail-Order Sales", value: 20 }],
resize: true,
colors: ['#87d6c6', '#54cdb4', '#1ab394'],
});
The data is an array of label/value pairs, which you could build, and then pass:
http://morrisjs.github.io/morris.js/donuts.html
Example:
You could use a JQuery call to get the data:
jQuery Ajax GET and POST calls to Controller's Method in MVC
http://www.itorian.com/2013/02/jquery-ajax-get-and-post-calls-to.html
http://morrisjs.github.io/morris.js/donuts.html
The data to plot. This is an array of objects, containing label and value attributes corresponding to the labels and sizes of the segments of the donut chart.
Example:
Morris.Donut({
element: 'morris-donut-chart',
data: data,
resize: true,
colors: ['#87d6c6', '#54cdb4', '#1ab394'],
});
You could use a JQuery call to get the data:
jQuery Ajax GET and POST calls to Controller's Method in MVC
http://www.itorian.com/2013/02/jquery-ajax-get-and-post-calls-to.html
<script type="text/jscript">
$('#SubmitName').click(function () {
var url = "/Home/WelcomeMsg";
var name = $('#Name').val();
$.get(url, { input: name }, function (data) {
$("#rData").html(data);
});
})
</script>
ASKER
i'm sorry, I'm not following.....I'm pretty new to this so my apologies ahead of time. I am using this in my controller
public ActionResult AlignmentSheetsDashboard()
{
var model = AlignmentSheetDb.alignment Sheet.ToLi st();
var serializer = new JavaScriptSerializer();
ViewData["JSON"] = serializer.Serialize(model );
return View(model);
}
I believe the above converts the data into JSON. How can I send it to the chart to load it?
public ActionResult AlignmentSheetsDashboard()
{
var model = AlignmentSheetDb.alignment
var serializer = new JavaScriptSerializer();
ViewData["JSON"] = serializer.Serialize(model
return View(model);
}
I believe the above converts the data into JSON. How can I send it to the chart to load it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much!!
as soon as you have the data available, you simply can call the
Open in new window
HTHRainer