コード例 #1
0
        private Chart GenerateAmountTicketSoldChart(McEditie editie)
        {
            Chart chart = new Chart()
            {
                Type    = Enums.ChartType.Doughnut,
                Options = new Options()
                {
                    Title = new Title()
                    {
                        Display  = true,
                        Position = "top",
                        Text     = "Aantal verkochte tickets",
                        FontSize = 20
                    }
                }
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data
            {
                Labels = new List <string>()
                {
                    "Aantal verkochte tickets", "Aantal beschikbare tickets"
                },
                Datasets = new List <Dataset>()
            };

            int        ticketsRemaining = editie.GetAmountTicketsRemaining();
            PieDataset dataset          = new PieDataset()
            {
                BackgroundColor = new List <ChartColor>()
                {
                    ChartColorSolid[2],
                    ChartColorSolid[3]
                },
                HoverBackgroundColor = new List <ChartColor>()
                {
                    ChartColorSolid[2],
                    ChartColorSolid[3]
                },
                Data = new List <double>()
                {
                    editie.MaxTickets - ticketsRemaining,
                    ticketsRemaining
                }
            };

            data.Datasets.Add(dataset);
            chart.Data = data;

            return(chart);
        }