Can I use it on a MVC/Razor app?

Feb 1, 2012 at 12:24 PM

Hello;

Very nice control. Keep up the good work.
I got my first chart on webforms in no time but now I'm working on a MVC project.
Is there a version for MVC?

Thanks in advance 

Coordinator
Feb 1, 2012 at 12:38 PM

Hi ebrito,

This is not WebForm control but library for creating javascript code for Highcharts. You can use it also in MVC like this:

Create the chart in the action method and return it to the view:

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);
}

Then you can get the chart from the model:

@model DotNet.Highcharts.Highcharts

@(Model)

You can download and use MVC solution with a lot of examples from here: http://dotnethighcharts.codeplex.com/releases/view/80650

Vangi

 

 

Marked as answer by Vangi on 10/24/2013 at 2:56 AM
Mar 31, 2012 at 10:20 AM
Edited Mar 31, 2012 at 10:21 AM

Hi,

I'm new of Highcharts, is it possible to do the following things? :

1. what if I would create the chart from another controller method? 

2. what if I would like to insert the chart inside a partial view?

thanks in advance.

Andrea