Getting Started with the ASP.NET MVC 3D Chart Control

23 Jul 20264 minutes to read

This section briefly explains how to add the Syncfusion® ASP.NET MVC 3D Chart control to an ASP.NET MVC 5 (.NET Framework) application using Visual Studio.

Prerequisites

Refer to the System requirements for ASP.NET MVC controls before creating the application.

Create an ASP.NET MVC application with HTML helper

You can create an ASP.NET MVC application using either of the following options:

Install the ASP.NET MVC NuGet package

To add Syncfusion® ASP.NET MVC controls in the application, open the NuGet Package Manager in Visual Studio by selecting Tools → NuGet Package Manager → Manage NuGet Packages for Solution. Search for Syncfusion.EJ2.MVC5 and install it.

Alternatively, you can use the Package Manager Console by navigating to Tools → NuGet Package Manager → Package Manager Console, and then run the following command:

Install-Package Syncfusion.EJ2.MVC5 -Version 34.1.29

NOTE

Syncfusion® ASP.NET MVC controls are available on nuget.org. Refer to the NuGet packages topic to learn more about installing NuGet packages in various operating system environments. The Syncfusion.EJ2.MVC5 NuGet package depends on Newtonsoft.Json (≥ 12.0.2) for JSON serialization and Syncfusion.Licensing for validating the Syncfusion® license key.

Add the namespace

Add the Syncfusion.EJ2 namespace reference in the Web.config file available in the Views folder.

<namespaces>
    <add namespace="Syncfusion.EJ2" />
</namespaces>

Add script resources

Add the script reference inside the <head> element of the ~/Views/Shared/_Layout.cshtml file as follows.

<head>
    ...
    <!-- Syncfusion ASP.NET MVC controls scripts -->
    <script src="https://cdn.syncfusion.com/ej2/34.1.29/dist/ej2.min.js"></script>
</head>

NOTE

Refer to the Adding Script Reference topic to learn different approaches for adding script references in an ASP.NET MVC application, including local/native references.

Register the Syncfusion® Script Manager

Register the script manager EJS().ScriptManager() at the end of the <body> element in the ~/Views/Shared/_Layout.cshtml file as follows.

<body>
    ...
    <!-- Syncfusion ASP.NET MVC Script Manager -->
    @Html.EJS().ScriptManager()
</body>

Add ASP.NET MVC 3D Chart control

Now, add the Syncfusion® ASP.NET MVC 3D Chart control in ~/Home/Index.cshtml page.

@Html.EJS().Chart3D("container").EnableRotation(true).Rotation(7).Tilt(10).Depth(100).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).LabelPlacement(Syncfusion.EJ2.Charts.LabelPlacement.BetweenTicks).LabelRotation(-45)
).Series(series =>
{
    series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).DataSource(ViewBag.dataSource).XName("X").YName("Y").Name("Gold").Add();
}).Render()
public IActionResult Index()
{
    List<Data> data = new List<Data>
    {
        new Data { X= "Tesla", Y= 137429 },
        new Data { X= "Aion",  Y= 80308  }
    };
    ViewBag.dataSource = data;
    return View();
}
public class Data
{
    public string X;
    public double Y;
}

Press Ctrl + F5 on Windows or + F5 on macOS to run the application. The Syncfusion® ASP.NET MVC 3D Chart control will be rendered in the default web browser.

ASP.NET MVC 3D Chart Control with Data

Troubleshooting

If the 3D Chart control does not render as expected, review the following common issues and their resolutions.

  • “Script Manager is not defined” or scripts run twice@Html.EJS().ScriptManager() was not added, or was added more than once. Ensure ScriptManager is registered exactly once at the end of <body> in _Layout.cshtml.

  • Chart renders but no data points appearXName / YName do not match the property names in the data source. Property names are case-sensitive; verify they match the JSON field names exactly (e.g., x, y).

  • Newtonsoft.Json reference error after upgradeSyncfusion.EJ2.MVC5 requires Newtonsoft.Json ≥ 12.0.2. Install a compatible version via NuGet.

See also