I'm building a Asp.Net application. I have this file
TimeDomain.cshtml, in this page I want to display a chart, the data of this chart is on database. So this is the code of my controller:
public ActionResult TimeFrequency()
{
ArrayList arrayValue = new ArrayList();
arrayValue.Add(0.5);
arrayValue.Add(0.1);
arrayValue.Add(0.5);
arrayValue.Add(0.5);
arrayValue.Add(0.3);
arrayValue.Add(0.8);
ViewBag.ArrayValue = arrayValue;
return View();
}
In the TimeDomain.cshtml I have this code to display the chart with random value:
var myConfig = {
type: 'bar',
backgroundColor: "#FFF",
plot: {
lineColor: "rgba(151,187,205,1)",
lineWidth: "2px",
backgroundColor2: "rgba(151,187,205,1)",
marker: {
backgroundColor: "rgba(151,187,205,1)",
borderColor: "white",
shadow: false
}
},
plotarea: {
backgroundColor: "white"
},
series: [{
values: getRandomValue(),
lineColor: "rgba(220,220,220,1)",
lineWidth: "2px",
alpha: 0.5,
borderWidth: "2px",
borderColor: "#C7C7C7",
borderTop: "2px solid #C7C7C7",
borderBottom: "0px",
backgroundColor1: "rgba(220,220,220,1)",
backgroundColor2: "rgba(220,220,220,1)",
marker: {
backgroundColor: "rgba(220,220,220,1)",
}
}]
}
In this line code:
values:getRandomValue(),
the method getRandomValue return an array of values. I want to remove this method and read the value from controller
ViewBag.ArrayValue = arrayValue;
How can I do this?
Aucun commentaire:
Enregistrer un commentaire