Scenario:
I would like to retrieve data with ajax,
once getting data from my database,
then pass Json data back to frontend and refresh line chart
Question:
While I got the data and pass it back to frontend,
it showed type error: Cannot read property 'getTime' of undefined.
What could cause this error?
To be mentioned, the json Data is in the same type with line chart, which is IEnumerable<EqEvDTDataViewModel>.
Code:
My Ajax Function
function instDataChartDropDownSelect(e) { var dataItem = this.dataItem(e.item); var instID = dataItem.InstID; $.ajax({ type: "POST", url: '@Url.Action("MyAction","MyController")', data: { 'instID': instID }, dataType: 'json', success: function (response) { $("#dtchart").data("kendoChart").dataSource.data(response); }, error: function (response) { } }); }
My Line Chart
@(Html.Kendo().Chart(instDatas.EqEvDTDataViewModel) .Name("dtchart") .Title("DT Time History Chart") .Legend(legend => legend .Position(ChartLegendPosition.Bottom) ) .ChartArea(chartArea => chartArea .Background("transparent") ) .SeriesDefaults(seriesDefaults => seriesDefaults.Line().Style(ChartSeriesStyle.Smooth) ) .Series(series => { series.Line(model => model.ReadData).Name("Displacement"); }) .ValueAxis(axis => axis .Numeric() ) .CategoryAxis(axis => axis .Categories( m => m.ReadTime) .Type(ChartCategoryAxisType.Date) .BaseUnit(ChartAxisBaseUnit.Fit) .Labels(labels => labels.Rotation(-90)) .Crosshair(c => c.Visible(true)) .AutoBaseUnitSteps(config => config.Milliseconds(1)) ) .Tooltip(tooltip => tooltip .Visible(true) .Shared(true) .Format("{0:N0}") ) )