Search code examples
asp.net-mvcvisual-studiohighchartsdotnethighcharts

Dotnet highcharts not working (Missing assembly)


Hello im using MVC3 (Visual studio express 2012)

I follow the instructions on this side; http://dotnethighcharts.codeplex.com/

I have made a new controller called TestHSController with a corresponding view.

The problem is that when im trying to run the code;

    public ActionResult Index()
    {
        DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
            .SetXAxis(new XAxis
            {
                Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
            })
            .SetSeries(new Series
            {
                Data = new Data(new object[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 })
            });

        return View(chart);
    }

The Xaxis, Series and Data are marked in blue as if im missing an assembly, i have added the DotNet.Highcharts as a reference and in my _Layout i have added the lines;

    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/highcharts.js"></script>

The files are in the repective places.

Any input would be appriciated.


Solution

  • Add following to your controller class

    using DotNet.Highcharts;
    using DotNet.Highcharts.Options; // for XAxis and Series
    using DotNet.Highcharts.Helpers; // for Data
    

    If still it does not build, there is another problem about your project.