AJAX data coming thru, but not showing up

2 posts, 1 answers
  1. Answer
    Ed
    Ed avatar
    8 posts
    Member since:
    Jul 2013

    Posted 06 Aug 2013 Link to this post

    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.
  2. Ed
    Ed avatar
    8 posts
    Member since:
    Jul 2013

    Posted 06 Aug 2013 Link to this post

    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.
Back to Top