@using Trirand.Web.Core
@using Trirand.Web.Core.Chart;
@using Trirand.Web.Core.Chart.ChartAxis;
@using Trirand.Web.Core.Chart.Series;
@using Trirand.Web.Core.Chart.ChartFeature;
@using Trirand.Web.Core.Chart.Data;

<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <title>Chart for ASP.NET Core - Gauge Simple</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
                     {
                         Tooltip = new ToolTip
                         {
                             Formatter = "{a} <br/>{b} : {c}%"
                         },
                         Toolbox = new ToolBox
                         {
                             Feature = new Feature
                             {
                                 Restore = new Restore { },
                                 SaveAsImage = new FeatureImage { }
                             }
                         },
                         Series = new List<object>
                         {
                             new Gauge
                             {
                                 Name = "Business Indicators",
                                 Detail = new GaugeDetail
                                 {
                                     Formatter = "{value}%"
                                 },                                
                                 Data = new List<Data>
                                 {
                                     new Data
                                     {
                                         Value = 50,
                                         Name = "Completion Rate"
                                     }
                                 }
                             }
                         }
                     }
            , "Chart")
        )

        <script type="text/javascript">

            setInterval(function () {
                var option = Chart.getOption();
                option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
                Chart.setOption(option, true);
            }, 2000);

        </script>

        <br />
        <div>
            @await Component.InvokeAsync("CodeTabs", new { product = "chart", example = "gauge/simplegauge" })
        </div>
    </div>
</body>
</html>

using Microsoft.AspNetCore.Mvc;

namespace CoreDemo.Controllers.Chart
{
    public partial class ChartController : Controller
    {
        [Route("chart/gauge/simplegauge")]
        public ActionResult SimpleGauge()
        {
            return View("~/Views/Chart/Gauge/SimpleGauge.cshtml");
        }
    }
}