Chartjs-Chart.Mvc colliding with System.Web.Helpers.Chart

2๐Ÿ‘

โœ…

Ran into the same issue myself, and found the answer when poking through the Github repo. You need to add the namespaces to Chart.Mvc in the /Views/web.config file.

See the authorโ€™s /Views/web.config file for reference.

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
  <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization"/>
    <add namespace="System.Web.Routing" />
    <add namespace="Chart.Mvc.Sample" />
    <add namespace="Chart.Mvc" />
    <add namespace="Chart.Mvc.ComplexChart" />
    <add namespace="Chart.Mvc.SimpleChart" />
    <add namespace="Chart.Mvc.Sample.Models" />
    <add namespace="Chart.Mvc.Extensions"/>
  </namespaces>
</pages>

0๐Ÿ‘

Adding the reference in the Vies/web.config file helped to get rid of the compilation error, I still do not get the chart displayed on the web page

0๐Ÿ‘

Got it working and displaying by including the namespaces and adding the reference to Chart.js.

Also the namespaces can be included in the razor view directly.

@using Chart.Mvc;
@using Chart.Mvc.Extensions;
@using System.Web.Mvc;
@using System.Web.Mvc.Ajax;
@using System.Web.Mvc.Html;
@using System.Web.Optimization;
@using System.Web.Routing;
@using Chart.Mvc;
@using Chart.Mvc.ComplexChart;
@using Chart.Mvc.SimpleChart;


@Scripts.Render("~/scripts/Chart.js")

Leave a comment