Мне удалось разобраться в проблеме, как показано ниже:
Контроллер:
public List<object[]> GetProdVal()
{
List<object[]> value = new List<object[]>();
foreach (var item in valuelist)
{
DateTimeConvertor dtc = new DateTimeConvertor();
double.TryParse(dtc.Year(item.Date.ToString()), out double year);
double.TryParse(dtc.Month(item.Date.ToString()), out double month);
double.TryParse(dtc.Day(item.Date.ToString()), out double day);
object[] val = {
year,
month,
day,
item.TotalCost
};
value.Add(val);
}
return value;
}
Просмотр:
prodval_chartData = @Json.Serialize(ViewBag.productionvalue, new Newtonsoft.Json.JsonSerializerSettings {
StringEscapeHandling =Newtonsoft.Json.StringEscapeHandling.EscapeHtml});
var prodval_data = new google.visualization.DataTable();
prodval_data.addColumn('number', 'year');
prodval_data.addColumn('number', 'month');
prodval_data.addColumn('number', 'day');
prodval_data.addColumn('number', 'Total');
prodval_data.addRows(prodval_chartData);
//Insert new column for generated date:
prodval_data.insertColumn(0, 'date', 'Date');
//Count number of iterations:
var count = prodval_data.getNumberOfRows();
for (var i = 0; i < count; i++) {
//Read year, month, day and calculate date
var year = prodval_data.getValue(i, 1);
var month = prodval_data.getValue(i, 2)-1;
var day = prodval_data.getValue(i, 3);
var date = new Date(year, month, day);
prodval_data.setValue(i, 0, date);
}
// remove columns of year, month, day
prodval_data.removeColumn(1);
prodval_data.removeColumn(1);
prodval_data.removeColumn(1);