We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

SeriesType

Thread ID:

Created:

Updated:

Platform:

Replies:

117952 Jan 13,2015 05:58 AM Jan 14,2015 04:06 AM ASP.NET MVC 1
loading
Tags: Chart
kalpa serashiya
Asked On January 13, 2015 05:58 AM

Hi,

I want to soft code the "SeriesType.Bar" of javascript code to paint the bar chart.
I want to assign value to ".Series(sr =>.Type())" from controller using viewbag.

How I can typecast a string value to SeriesType. something to plot either a "Column" or "bar" chart.

Thanks.






Jayavigneshwaran [Syncfusion]
Replied On January 14, 2015 04:06 AM

Hi Kalpa,

Thanks for using Syncfusion product.

We have analyzed this. This can be done by following the below steps.

1.       Pass the type of the chart to be rendered in controller through viewbag.

[CS]

        public ActionResult ChartFeatures()

        {

            ViewBag.type = "spline"; // passed the chart series type

            return View();

  }

2.       Trigger load event of chart

[CSHTML]

     @(Html.EJ().Chart("container")

      

            .Load("onchartload")

       

     )

3.       Covert the value from viewbag to use it in JS

[JS]

   var seriesType = @Html.Raw(Json.Encode(ViewBag.type)); // Converts the value to use it in JS

4.       Code the method, to assign the value passed in viewbag to chart on load

[JS]

                     function  onchartload(sender) {

            sender.model.series[0].type = seriesType; // assign it to chart seriestype

        }

The below screen shot shows the output of the attached sample.

We have also made a sample to illustrate this. Find it from the below location.

 Attachment.zip

Please let us know if you have any concern.

Thanks,

Jayavigneshwaran



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;