This is a migrated thread and some comments may be shown as answers.

AJAX data coming thru, but not showing up

1 Answer 32 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 06 Aug 2013, 06:10 PM
I'm using MVC Complete and am trying to get my first chart up and running.  The output of the MVC Extension in the browser is

jQuery(function(){jQuery("#programSpend").kendoChart({"title":{"text":"Program Spend"},"legend":{"position":"bottom"},"series":[{"name":"Sum of Spend","type":"line","field":"Series1Data"}],"categoryAxis":[{"labels":{"rotation":-90},"field":"Category"}],"valueAxis":[{"labels":{"format":"{0:N0}"},"line":{"visible":true}}],"dataSource":{"transport":{"prefix":"","read":{"url":"/ChartJson/ProgramSpend","type":"POST"}},"type":"aspnetmvc-ajax","schema":{"model":{"fields":{"Category":{"type":"string"},"Series1Data":{"type":"number"}}}}},"tooltip":{"format":"{0:N0}","visible":true}});});

and the AJAX method is being properly fired and here is the resulting data.

{"Data":[{"Category":"Dec - 13","Series1Data":29994974.40},{"Category":"Jan - 13","Series1Data":40317364.19},{"Category":"Feb - 11","Series1Data":46536492.18}]}

I'm not sure what the problem is here since it all looks right to me.
Thanks in advance for any assistance.

1 Answer, 1 is accepted

Sort by
0
Ed
Top achievements
Rank 1
answered on 06 Aug 2013, 09:10 PM
figured it out.  I needed to use LINQ to create an anonymous type from the concrete model class - notice the "Data" element at the beginning of the JSON.  That shouldn't be there.
Tags
Charts
Asked by
Ed
Top achievements
Rank 1
Answers by
Ed
Top achievements
Rank 1
Share this question
or