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. Image for the cookie policy date

Chart reference error

Hi People,

I have added required references and code from the Sample which you have provided during installation and also used the following link for the reference.

http://help.syncfusion.com/ug_92/User%20Interface/ASP.NET%20MVC/Chart/index.html

I am getting following error.
Error 1 'Syncfusion.Mvc.Shared.ComponentFactory' does not contain a definition for 'Chart' and no extension method 'Chart' accepting a first argument of type 'Syncfusion.Mvc.Shared.ComponentFactory' could be found (are you missing a using directive or an assembly reference?)

Please find my code as an attachment also.

You can find the file at the below location.
"~/Views/BasicChartType.cshtml"




SyncfusionMvcApplication1_e79588e.rar

7 Replies

AD Administrator Syncfusion Team August 1, 2011 09:49 AM UTC

Hello guys,

I have resolved the above error but now I am getting some script error. Please fing my code as an attachment,

Thanks
Alok Shah



SyncfusionMvcApplication1_fd3dd8a5.rar


AD Administrator Syncfusion Team August 1, 2011 12:44 PM UTC

Can somebody tell me what is the difference between 2 below scripts?

@(new HtmlString(Html.Syncfusion().Chart("chart_Model", (Syncfusion.Mvc.Chart.MVCChartModel)ViewBag.chartModel).ToString())) -- It's working fine

and

@{
Html.Syncfusion().Chart("chart_Model", (Syncfusion.Mvc.Chart.MVCChartModel)ViewBag.chartModel);
} -- It's giving javascript error




VK Vijayabharathi K Syncfusion Team August 4, 2011 05:42 AM UTC

Hi Alok,

Thanks for using Syncfusion products.

By default, razor encodes the HTML. So, we need to use “HtmlString” to render the chart using property model in razor application and also prevent the HTML encoding. In builder model, we are using Render()(for Htmlstring) method to render the chart control. If we are not use “HtmlString” in property model, we got script error due to lack of HtmlString to renderer the control in razor application.


Regards,
Vijayabharathi




MM Manuel Monteagudo August 23, 2012 01:37 AM UTC

I'm having the first error exposed here how it was solved???

The issue with the chart reference.

 

Thanks,



VK Vijayabharathi K Syncfusion Team August 23, 2012 07:17 AM UTC

Hi Manuel,

Thanks for using Syncfusion products.

1)Chart Control

We suspect the cause of issue may be because of not adding required namespace in web.config file. Please refer the below

[Web.config]

<namespaces>

        <add namespace="System.Web.Helpers" />

        <add namespace="System.Web.Mvc" />

        <add namespace="System.Web.Mvc.Ajax" />

        <add namespace="System.Web.Mvc.Html" />

        <add namespace="System.Web.Routing" />

        <add namespace="System.Web.WebPages" />

        <add namespace="System.Drawing" />

        <add namespace="Syncfusion.Mvc.Shared" />

        <add namespace="Syncfusion.Mvc.Chart" />

        <add namespace="Syncfusion.Windows.Forms.Chart" />

        <add namespace="Syncfusion.Mvc.Tools" />

  </namespaces>

If you are using razor sample check this in web.config file available in Views folder. However we have created a simple sample. Please refer the attachment.(Sample_ChartControl)

Also, we are providing Syncfusion project template support to create sample in MVC platform. Please refer the following steps to create a simple chart sample by using template,

1)Open VS2010

2)Choose File->New->Project->New Project dialog opened(Refer projectdialog.png)

3)Choose Syncfusion MVC from this dialog and select Razor MVC3 sample (Refer Projectdialog.png)

4) Select Chart from Syncfusion Wizard and click “Next” button from wizard (Refer SynnWizard.png)

5) Select Theme if you set for control and then click “Done” button from wizard

The chart assemblies and namespace information added in web config files.

2)ChartAdv( Html5 control)

We have created a simple sample for ChartAdv control in MVC platform. Please refer the attachments for this sample(Sample_ChartAdv)

The following steps to create a simple application with ChartAdv control.

1)Create new MVC3 Razor application(Sample_ChartAdv) in VS2010

2) Added below reference assembly in Sample_ChartAdv application

· Syncfusion.Core,

· Syncfusion.Chart.Mvc

· Syncfusion.Shared.Mvc

3) Added code in web config for above assembly and namespace(Refer screenshot webconfig)

4) Added Resource registration to an application (Refer screenshot Layout)

5)Added code for ChartAdv control in view and controller page.

Note: We must add “Syncfusion.Mvc.ChartAdv” namespace in webconfig file for ChartAdv control. Also, we have no separate option to choose ChartAdv(HTML5) from Syncfusion project Template.

Please let us know if any concerns.

Regards,

Vijayabahrathi



Sample_f2000649.zip


JA james replied to Vijayabharathi K April 4, 2018 03:48 PM UTC

Hi Alok,

Thanks for using Syncfusion products.

By default, razor encodes the HTML. So, we need to use “HtmlString” to render the chart using property model in razor application and also prevent the HTML encoding. In builder model, we are using Render()(for Htmlstring) method to render the chart control. If we are not use “HtmlString” in property model, we got script error due to lack of HtmlString to renderer the control in razor application.


Regards,
Vijayabharathi



ozone5000@yahoo.com


SK Sanjith Kesavan Syncfusion Team April 5, 2018 09:45 AM UTC

Hi James, 

Since your query is not clear, please provide more details about your requirement. This would be helpful for us to provide the solution as per your requirement.  

Thanks, 
Sanjith. 


Loader.
Live Chat Icon For mobile
Up arrow icon