HomedocschartsintegrationASP.NET MVCchart typesDoughnut Chart

ASP.NET MVC Doughnut Chart Sample using CanvasJS

Here is an example for adding Interactive Doughnut Charts into your ASP.NET MVC Application using CanvasJS. Doughnut Chart renders itself with a beautiful animation. You customize various properties like color of individual slices, label content and its position, starting angle, etc.

Please refer to this tutorial for step by step instruction of adding charts to your ASP.Net MVC Application. We recommend that you download the Sample Visual Studio Project and try it on your own to understand the API better.

Download ASP.Net MVC Chart Samples

var chart = new CanvasJS.Chart("chartContainer", {
data: [{
    type: "doughnut",
    dataPoints: [
        { y: 6, label: "Apple" },
	{ y: 4, label: "Mango" },
	{ y: 5, label: "Orange" },

You can further customize these charts to enable features like Zooming, Panning, Exporting, etc. To know more about the available features, please refer to our getting started section.

    Layout = null;

<!DOCTYPE html>

    <meta name="viewport" content="width=device-width" />
    <script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
    <title>Doughnut Chart</title>
    <div id="chartContainer"></div>
    <script type="text/javascript">
        window.onload = function () {
            var chart = new CanvasJS.Chart("chartContainer", {
                title: {
                    text: "Desktop Search Engine Market Share, Jul-2016"
                animationEnabled: true,
                legend: {
                    fontSize: 20,
                    fontFamily: "Helvetica"
                theme: "light2",
                data: [
                    type: "doughnut",
                    indexLabelFontFamily: "Garamond",
                    indexLabelFontSize: 20,
                    indexLabel: "{label} {y}%",
                    startAngle: -20,
                    showInLegend: true,
                    toolTipContent: "{legendText} {y}%",
                    dataPoints: [
                        { y: 72.48, legendText: "Google", label: "Google" },
                        { y: 10.39, legendText: "Bing", label: "Bing" },
                        { y: 7.78, legendText: "Yahoo!", label: "Yahoo!" },
                        { y: 7.14, legendText: "Baidu", label: "Baidu" },
                        { y: 0.22, legendText: "Ask", label: "Ask" },
                        { y: 0.15, legendText: "AOL", label: "AOL" },
                        { y: 1.84, legendText: "Others", label: "Others" }

                    //dataPoints: @Html.Raw(ViewBag.DataPoints),
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ASPNET_MVC_Samples.Controllers
    public class HomeController : Controller
        public ActionResult Doughnut()
            return View();

In order to provide better support, we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.