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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





117952 Jan 13,2015 10:58 AM UTC Jan 14,2015 09:06 AM UTC ASP.NET MVC 1
Tags: Chart
kalpa serashiya
Asked On January 13, 2015 10:58 AM UTC


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.


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

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.


        public ActionResult ChartFeatures()


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

            return View();


2.       Trigger load event of chart







3.       Covert the value from viewbag to use it in 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


                     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.


Please let us know if you have any concern.




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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon