I am writing an APS.NET MVC application that reads data from DB and presents it with google charts.
I am reading the data from DB in C# into 2D array and need to pass it to my javascript code that generates the google chart.
My Code:
ViewBag.Data = new object[,]
{
{"10:00:00",10},
{"11:00:00", 20}
};
@{
Object[,] arr = ViewBag.Data;
}
My Javascript code:
var jsArray = @Html.Raw(Json.Encode(arr));// Only working for 1D array
var data = google.visualization.arrayToDataTable(jsArray);
I can't pass 2D array from my C# code to my javascript code to generate the wanted chart. I see only example for converting 1D arrays from C# to javascript (see above).
Any ideas?
Thanks