@using System.Collections.Generic;
@using Trirand.Web.Core
@using Trirand.Web.Core.Chart;
@using Trirand.Web.Core.Chart.Series;
@using Trirand.Web.Core.Chart.ChartFeature;

<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <title>Chart for ASP.NET Core - Doughnut Lasagna</title>  
    <script type="text/javascript" src="~/js/trirand/chart/corechart.min.js"></script>
</head>
<body>
    <div>
        <!--
        The Html.Trirand().CoreChart() helper has two parameters
            - the model of the chart -- all chart properties, data and settings
            - the ID of the chart -- can be used for client-side manipulation
        In this example we are using hardcoded model in the View, but you can contruct the model in 
        the controller based on runtime criteria and database data and pass the model 
        to the View using ViewData
        -->
        @(Html.Trirand().CoreChart(
            new CoreChart
            {
                Title = new List<Title>
                {
                    new Title()
                    {
                        Text = "Browser Share",
                        Subtext = "Fictional Data",
                        X = "right",
                        Y = "bottom"
                    }
                },
                Tooltip = new ToolTip
                {
                    Trigger = TriggerType.Item,
                    Formatter = "{a} <br/>{b} : {c} ({d}%)"
                },
                Legend = new Legend
                {
                    Orient = OrientType.Vertical,
                    Left = "left",
                    Data = new List<string> { "Chrome", "Firefox", "Safari", "IE9+", "IE8-" }
                },
                Toolbox = new ToolBox
                {
                    Show = true,
                    Feature = new Feature
                    {
                        Mark = new Mark { Show = true },
                        DataView = new DataView { Show = true, ReadOnly = false },
                        MagicType = new MagicType { Show = true, Type = new List<object> { "line", "bar", "stack", "tiled" } },
                        Restore = new Restore { Show = true },
                        SaveAsImage = new FeatureImage { Show = true }
                    }
                },
                Series = ViewData["series"] as List<Pie>
            }
            , "Chart")
        )
             
        <br />
        <div>
            @await Component.InvokeAsync("CodeTabs", new { product = "chart", example = "doughnut/lasagna" })
        </div>
    </div>
</body>
</html>

using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using Trirand.Web.Core.Chart.Data;
using Trirand.Web.Core.Chart.Series;
using Trirand.Web.Core.Chart.Style;

namespace CoreDemo.Controllers.Chart
{
    public partial class ChartController : Controller
    {
        [Route("chart/doughnut/lasagna")]
        public ActionResult Lasagna()
        {
            List<Pie> series = new List<Pie>();

            for (int i = 0; i < 30; i++)
            {
                Pie pie = new Pie
                {
                    Name = "Browser",
                    ItemStyle = new ItemStyle
                    {
                        Normal = new Normal
                        {
                            Label = new StyleLabel { Show = i > 28 },
                            LabelLine = new LabelLine { Show = i > 28, Length = 20 }
                        }
                    },
                    Radius = new List<int> { i * 4 + 40, i * 4 + 43 },
                    Data = new List<Data>()
                    {
                        new Data { Value = i * 128 + 80,  Name= "Chrome"},
                        new Data { Value = i * 64 + 160,  Name= "Firefox"},
                        new Data { Value = i * 32 + 320,  Name= "Safari"},
                        new Data { Value = i * 16 + 640,  Name= "IE9+"},
                        new Data { Value = i * 8 + 1280, Name= "IE8-"}
                    }
                };


                series.Add(pie);
            }         

            ViewData["series"] = series;

            return View("~/Views/Chart/doughnut/lasagna.cshtml");
        }
    }
}