@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 - Funnel Alligned</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
                        {
                            Width = "900px",
                            Title = new List<Title>
                            {
                                new Title()
                                {
                                    Left = "left",
                                    Top = "bottom",
                                    Text = "Contrast Funnel",
                                    Subtext = "Fictional Data"
                                }
                            },
                            Tooltip = new ToolTip
                            {
                                Trigger = TriggerType.Item,
                                Formatter = "{a} <br/>{b} : {c}%"
                            },
                            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 }
                                }
                            },
                            Legend = new Legend
                            {
                                Orient = OrientType.Vertical,
                                Left = "left",
                                Data = new List<string> { "Product A", "Product B", "Product C", "Product D", "Product E", }
                            },
                            Calculable = true,
                            Series = new List<object>()
                            {
                                new Funnel
                                {
                                    Left = "10%",
                                    Top = 60,
                                    Bottom = 60,
                                    Width= "80%",
                                    Min = 0,
                                    Max = 100,
                                    MinSize = "0%",
                                    MaxSize = "100%",
                                    Sort = SortType.Ascending,
                                    Gap = 2,
                                    FunnelAlign = HorizontalType.Center,
                                    Center = new List<string> { "50%", "50%"},
                                    Data = ViewData["data1"]
                                }
                            }
                        }
            , "Chart")
        )

        <br />
        <div>
            @await Component.InvokeAsync("CodeTabs", new { product = "chart", example = "pyramid/simplepyramid" })
        </div>
    </div>
</body>
</html>
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using Trirand.Web.Core.Chart.Data;

namespace CoreDemo.Controllers.Chart
{
    public partial class ChartController : Controller
    {
        [Route("chart/pyramid/simplepyramid")]
        public ActionResult SimplePyramid()
        {
            List<Data> data1 = new List<Data>
            {
                new Data { Value = 100, Name = "Product A"},
                new Data { Value = 80, Name = "Product B"},
                new Data { Value = 60, Name = "Product C"},
                new Data { Value = 40, Name = "Product D"},
                new Data { Value = 20, Name = "Product E"}
            };

            ViewData["data1"] = data1;

            return View("~/Views/Chart/Pyramid/SimplePyramid.cshtml");
        }
    }
}