Stacked Column 100 Chart

ASP.NET MVC Stacked Column 100% Chart Sample using CanvasJS

Here is an example for adding Interactive Stacked Column 100% Charts into your ASP.NET MVC Application using CanvasJS. In case of Stacked Column 100% Charts, data points are stacked similar to “Stacked Column” except that their individual height is calculated as a percentage of the total sum. This allows you to compare individual contribution of Data Series to the total sum in percent.

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: "stackedColumn100",
    dataPoints: [
        { y: 6, label: "Apple" },
	{ y: 4, label: "Mango" },
	{ y: 5, label: "Orange" },
    ]
},
{
    type: "stackedColumn100",
    dataPoints: [
        { y: 2, label: "Apple" },
	{ y: 6, label: "Mango" },
	{ y: 4, 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>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <script type="text/javascript" src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
    <title>Stacked Column 100% Chart</title>
</head>
<body>
    <div id="chartContainer"></div>

    <script type="text/javascript">
        window.onload = function () {
            var chart = new CanvasJS.Chart("chartContainer", {
                animationEnabled: true,
                title: {
                    text: "Number of Students in Each Room"
                },
                axisX: {
                    title: "Rooms"
                },
                axisY: {
                    title: "percentage"
                },
                data: [
                {
                    type: "stackedColumn100",
                    legendText: "Boys",
                    showInLegend: "true",
                    indexLabel: "#percent %",
                    indexLabelPlacement: "inside",
                    indexLabelFontColor: "white",
                    dataPoints: [
                        { y: 40, label: "Cafeteria" },
                        { y: 10, label: "Lounge" },
                        { y: 72, label: "Games Room" },
                        { y: 30, label: "Lecture Hall" },
                        { y: 21, label: "Library" }
                    ],

                    //dataPoints: @Html.Raw(ViewBag.DataPoints),
                },
                {
                    type: "stackedColumn100",
                    legendText: "Girls",
                    showInLegend: "true",
                    indexLabel: "#percent %",
                    indexLabelPlacement: "inside",
                    indexLabelFontColor: "white",
                    dataPoints: [
                        { y: 20, label: "Cafeteria" },
                        { y: 14, label: "Lounge" },
                        { y: 40, label: "Games Room" },
                        { y: 43, label: "Lecture Hall" },
                        { y: 17, label: "Library" }
                    ],

                    //dataPoints: @Html.Raw(ViewBag.DataPoints),
                }
                ]
            });
            chart.render();
        };
    </script>
</body>
</html>			
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 StackedColumn100()
        {
            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.