This project is read-only.


Sep 5, 2011 at 3:38 PM


Do you have any example or suggestions how to define library in an ASP.Net MVC3 controller returning json values?

Here is my controller

  public ActionResult HighChart()
           // Defining Axis
            Highchart.UI.LineChart hcVendas = new Highchart.UI.LineChart();
            hcVendas.YAxis = new YAxis { title = new Title("Faturamento") };
            hcVendas.XAxis = new XAxis { categories = new[] { "1994""1995""1996""1997""1998""1999""2000""2001""2002" } };
            //New data collection
            var series = new Collection<Serie>();
            series.Add(new Serie { data = new object[] { 400, 435, 446, 479, 554, 634, 687, 750, 831 } });
            hcVendas.DataSource = series;
            return Json(hcVendas, JsonRequestBehavior.AllowGet);
            //return View("HighChart");

here is my view

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <div id="container"> </div>
   <highchart:LineChart id="hcVendas" runat="server" Width="500" Height="350" /> 

Chart is not renedered though data and chart definitions are returned from the contoller?
Nov 20, 2011 at 9:31 AM
Edited Nov 20, 2011 at 10:22 AM

I know this is quite late but most likely, the problem is that the data is being bound to the Highchart control too late in the page lifecycle. Similar to the problem faced by faris_rjoup here [].

I don't have a sample project on which to test this out, but the solution at the bottom of the page could also help with the problem for an MVC project.