Example #1
0
        private static Chart GeneratePieChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Pie
            };

            var data = new Data {
                Labels = new List <string> {
                    "Red", "Blue", "Yellow"
                }
            };

            var dataset = new PieDataset
            {
                Label           = "My dataset",
                BackgroundColor = new List <string> {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                HoverBackgroundColor = new List <string> {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                Data = new List <double> {
                    300, 50, 100
                }
            };

            data.Datasets = new List <Dataset> {
                dataset
            };

            chart.Data = data;

            return(chart);
        }
        protected override void OnInitialized()
        {
            _config = new PieConfig
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = false,
                        Text    = "ChartJs.Blazor Pie Chart"
                    }
                }
            };

            foreach (string color in new[] { "Red", "Yellow", "Green", "Blue" })
            {
                _config.Data.Labels.Add(color);
            }

            PieDataset <int> dataset = new PieDataset <int>(new[] { 6, 5, 3, 7 })
            {
                BackgroundColor = new[]
                {
                    ColorUtil.ColorHexString(255, 99, 132), // Slice 1 aka "Red"
                    ColorUtil.ColorHexString(255, 205, 86), // Slice 2 aka "Yellow"
                    ColorUtil.ColorHexString(75, 192, 192), // Slice 3 aka "Green"
                    ColorUtil.ColorHexString(54, 162, 235), // Slice 4 aka "Blue"
                }
            };

            _config.Data.Datasets.Add(dataset);
        }
Example #3
0
        private Chart GeneratePieChart(Room room, DateTime from, DateTime to)
        {
            List <string> socketsNames = room.Sockets.Select(s => s.Name).ToList();

            List <string> backgroundColors = new List <string>();
            var           random           = new Random();

            for (int j = 0; j < socketsNames.Count(); j++)
            {
                backgroundColors.Add(String.Format("#{0:X6}", random.Next(0x1000000)));
            }

            List <double> data = new List <double>();

            for (int j = 0; j < socketsNames.Count(); j++)
            {
                double sum = room.Sockets
                             .Where(s => s.Name.Equals(socketsNames[j]))
                             .SelectMany(s => s.SocketDatas)
                             .Where(sd => sd.TimeStamp.CompareTo(from) >= 0 && sd.TimeStamp.CompareTo(to) < 0)
                             .Sum(sd => sd.Value);

                data.Add(Math.Round(sum, 2));
            }

            PieDataset dataset = new PieDataset()
            {
                Label                = "PieDataser",
                BackgroundColor      = backgroundColors,
                HoverBackgroundColor = backgroundColors,
                Data = data
            };

            return(_chartGenerator.GeneratePieChart(socketsNames, dataset));
        }
Example #4
0
 protected void InitComponent()
 {
     options = new PieOptions
     {
         Title = new OptionsTitle
         {
             Display = false,
             Text    = ""
         },
         Legend = new Legend
         {
             Position = Position.Right,
             Labels   = new LegendLabelConfiguration
             {
                 UsePointStyle = true
             }
         },
         Responsive = true,
         Animation  = new ArcAnimation
         {
             AnimateRotate = true,
             AnimateScale  = true
         }
     };
     dataset = new PieDataset
     {
         BackgroundColor      = new[] { ColorUtil.RandomColorString(), ColorUtil.RandomColorString(), ColorUtil.RandomColorString(), ColorUtil.RandomColorString(), ColorUtil.RandomColorString() },
         BorderWidth          = 0,
         HoverBackgroundColor = ColorUtil.RandomColorString(),
         HoverBorderColor     = ColorUtil.RandomColorString(),
         HoverBorderWidth     = 1,
         BorderColor          = "#ffffff",
     };
     config = new PieConfig();
 }
        protected override void OnParametersSet()
        {
            _config = new PieConfig
            {
                Options = new PieOptions
                {
                    Title = new OptionsTitle
                    {
                        Display = true,
                        Text    = "Sample chart from Blazor"
                    },
                    Responsive = true,
                    Animation  = new ArcAnimation
                    {
                        AnimateRotate = true,
                        AnimateScale  = true
                    }
                }
            };

            _config.Data.Labels.AddRange(new[] { "A", "B", "C", "D" });

            var pieSet = new PieDataset
            {
                BackgroundColor      = new[] { ColorUtil.RandomColorString(), ColorUtil.RandomColorString(), ColorUtil.RandomColorString(), ColorUtil.RandomColorString() },
                BorderWidth          = 0,
                HoverBackgroundColor = ColorUtil.RandomColorString(),
                HoverBorderColor     = ColorUtil.RandomColorString(),
                HoverBorderWidth     = 1,
                BorderColor          = "#ffffff",
            };

            pieSet.Data.AddRange(new double[] { 4, 5, 6, 7 });
            _config.Data.Datasets.Add(pieSet);
        }
Example #6
0
 public PiePlot3D(PieDataset dataset)
   : base(dataset)
 {
   PiePlot3D piePlot3D = this;
   this.depthFactor = 0.12;
   this.darkerSides = false;
   this.setCircular(false, false);
 }
 public PieSectionEntity(Shape area, PieDataset dataset, int pieIndex, int sectionIndex, IComparable sectionKey, string toolTipText, string urlText)
   : base(area, toolTipText, urlText)
 {
   PieSectionEntity pieSectionEntity = this;
   this.dataset = dataset;
   this.pieIndex = pieIndex;
   this.sectionIndex = sectionIndex;
   this.sectionKey = sectionKey;
 }
Example #8
0
 public RingPlot(PieDataset dataset)
   : base(dataset)
 {
   RingPlot ringPlot = this;
   this.separatorsVisible = true;
   this.separatorStroke = (Stroke) new BasicStroke(0.5f);
   this.separatorPaint = (Paint) Color.gray;
   this.innerSeparatorExtension = 0.2;
   this.outerSeparatorExtension = 0.2;
   this.sectionDepth = 0.2;
 }
Example #9
0
        private Chart GeneratePieChart(List <Track> tracks)
        {
            Chart chart = new Chart
            {
                Type = Enums.ChartType.Pie,
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data
            {
                Labels = Enum.GetNames(typeof(JudgeStatus))
            };

            PieDataset dataset = new PieDataset
            {
                Label = "Summary",

                BackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromHexString("#28A745"),
                    ChartColor.FromHexString("#FFC720"),
                    ChartColor.FromHexString("#DC3545"),
                    ChartColor.FromHexString("#1B6EC2"),
                    ChartColor.FromHexString("#6C757D")
                },

                HoverBackgroundColor = new List <ChartColor>
                {
                    ChartColor.FromHexString("#28A745"),
                    ChartColor.FromHexString("#FFC720"),
                    ChartColor.FromHexString("#DC3545"),
                    ChartColor.FromHexString("#1B6EC2"),
                    ChartColor.FromHexString("#6C757D")
                },

                Data = new List <double?>
                {
                    tracks.LongCount(x => x.Status == JudgeStatus.Accept),
                    tracks.LongCount(x => x.Status == JudgeStatus.WrongAnswer),
                    tracks.LongCount(x => x.Status == JudgeStatus.CompileError),
                    tracks.LongCount(x => x.Status == JudgeStatus.UnknownError),
                    tracks.LongCount(x => x.Status == JudgeStatus.Pending)
                },
            };

            data.Datasets = new List <Dataset>
            {
                dataset
            };

            chart.Data = data;

            return(chart);
        }
        private Chart GenerateAmountVerenigingenBoughtTicketsChart(McEditie editie)
        {
            Chart chart = new Chart()
            {
                Type    = Enums.ChartType.Doughnut,
                Options = new Options()
                {
                    Title = new Title()
                    {
                        Display  = true,
                        Position = "top",
                        Text     = "Aantal verenigingen met tickets",
                        FontSize = 20
                    }
                }
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data
            {
                Labels = new List <string>()
                {
                    "Verenigingen met tickets", "Verenigingen zonder tickets"
                },
                Datasets = new List <Dataset>()
            };

            int        verenigingenWithTicketsCount = _verenigingRepository.GetAllWhoHaveTickets(editie.Id).Count();
            int        verenigingenCount            = _verenigingRepository.GetAll().Count();
            PieDataset dataset = new PieDataset()
            {
                BackgroundColor = new List <ChartColor>()
                {
                    ChartColorSolid[2],
                    ChartColorSolid[3]
                },
                HoverBackgroundColor = new List <ChartColor>()
                {
                    ChartColorSolid[2],
                    ChartColorSolid[3]
                },
                Data = new List <double>()
                {
                    verenigingenWithTicketsCount,
                    verenigingenCount - verenigingenWithTicketsCount
                }
            };

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

            return(chart);
        }
        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);
        }
        private void SetDeviceGraph()
        {
            var request = _service.Data.Ga.Get(
                "ga:" + WebsiteCode,
                DateTime.Today.AddDays(-7).ToString("yyyy-MM-dd"),
                DateTime.Today.ToString("yyyy-MM-dd"),
                "ga:sessions");

            request.Dimensions = "ga:deviceCategory";
            var requestData = request.Execute();

            var labels = new List <string>();
            var values = new List <double>();

            foreach (var row in requestData.Rows)
            {
                labels.Add(row[0]);
                values.Add(double.Parse(row[1]));
            }

            var data = new ChartJSCore.Models.Data {
                Labels = labels
            };

            var dataset = new PieDataset
            {
                Label           = "Devices used",
                BackgroundColor = new List <string> {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                HoverBackgroundColor = new List <string> {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                Data = values
            };

            data.Datasets = new List <Dataset> {
                dataset
            };
            var chart = new Chart
            {
                Type = "pie",
                Data = data
            };

            ViewBag.devices = chart;
        }
        protected override void OnParametersSet()
        {
            _config = new PieConfig
            {
                Options = new PieOptions
                {
                    Title = new OptionsTitle
                    {
                        Text      = Title,
                        Display   = true,
                        FontColor = ColorUtil.FromDrawingColor(Color.White)
                    },
                    Responsive = true,
                    Animation  = new ArcAnimation
                    {
                        AnimateRotate = true,
                        AnimateScale  = true
                    },
                    Legend = new Legend()
                    {
                        Display = false
                    }
                }
            };

            var pieSet = new PieDataset
            {
                BorderWidth          = 0,
                HoverBackgroundColor = ColorUtil.RandomColorString(),
                HoverBorderColor     = ColorUtil.RandomColorString(),
                HoverBorderWidth     = 1,
                BorderColor          = "#ffffff"
            };

            List <string> colors = new List <string>();

            for (int i = 0; i < Labels.Count; i++)
            {
                colors.Add(ColorUtil.RandomColorString());
            }
            pieSet.BackgroundColor = colors.ToArray();

            _config.Data.Labels.AddRange(Labels);
            pieSet.Data.AddRange(Data);

            _config.Data.Datasets.Add(pieSet);
        }
        public async Task <IActionResult> Graph(string address)
        {
            var graphData = await _blockchainService.GetGraphData(address);

            if (graphData.Succeeded)
            {
                Chart chart = new Chart();
                chart.Type = "pie";

                ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
                data.Labels = new List <string>();

                var pieData   = new List <double>();
                var pieColors = new List <string>();
                foreach (var item in graphData.Value)
                {
                    data.Labels.Add(item.Address);
                    pieData.Add(item.Donation);
                    pieColors.Add(item.Color);
                }

                PieDataset dataset = new PieDataset()
                {
                    Label           = "Donatori",
                    Data            = pieData,
                    BackgroundColor = pieColors,
                };

                data.Datasets = new List <Dataset>();
                data.Datasets.Add(dataset);
                chart.Data        = data;
                ViewData["chart"] = chart;

                var response = await _blockchainService.GetCampaigns();

                var model = new GraphInitViewModel
                {
                    Campaigns = response.Value
                };

                return(View(model));
            }
            return(BadRequest());
        }
Example #15
0
        protected async Task UpdatePieChart(string question, string[] answers, double[] votes)
        {
            _q5Config.Data.Datasets.Clear();
            _q5Config.Data.Labels.Clear();
            await _q5Chart.Update();

            _q5Config.Options = new PieOptions
            {
                Title = new OptionsTitle
                {
                    Display = true,
                    Text    = question
                },
                Responsive = true,
                Animation  = new ArcAnimation
                {
                    AnimateRotate = true,
                    AnimateScale  = true
                }
            };

            _q5Config.Data.Labels.AddRange(answers);

            var pieSet = new PieDataset
            {
                BackgroundColor = answers
                                  .Select(i => i.ToString() == "はい" ? ColorUtil.FromDrawingColor(System.Drawing.Color.Blue)
                                                        : ColorUtil.FromDrawingColor(System.Drawing.Color.Red))
                                  .ToArray(),
                BorderWidth          = 0,
                HoverBackgroundColor = answers
                                       .Select(i => i.ToString() == "はい" ? ColorUtil.FromDrawingColor(System.Drawing.Color.DarkBlue)
                                                        : ColorUtil.FromDrawingColor(System.Drawing.Color.DarkRed))
                                       .ToArray(),
                HoverBorderColor = ColorUtil.FromDrawingColor(System.Drawing.Color.Black),
                HoverBorderWidth = 1,
                BorderColor      = "#ffffff",
            };

            pieSet.Data.AddRange(votes);
            _q5Config.Data.Datasets.Add(pieSet);

            await _q5Chart.Update();
        }
Example #16
0
        private static Chart GeneratePieChart(List <Project> listOfProjects)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Pie;

            Data data = new Data();

            data.Labels = new List <string>()
            {
                "Red", "Blue", "Yellow"
            };

            PieDataset dataset = new PieDataset()
            {
                Label           = "My dataset",
                BackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#FF6384"),
                    ChartColor.FromHexString("#36A2EB"),
                    ChartColor.FromHexString("#FFCE56")
                },
                HoverBackgroundColor = new List <ChartColor>()
                {
                    ChartColor.FromHexString("#FF6384"),
                    ChartColor.FromHexString("#36A2EB"),
                    ChartColor.FromHexString("#FFCE56")
                },
                Data = new List <double>()
                {
                    300, 50, 100
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;

            return(chart);
        }
        public IActionResult Pie()
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Pie;

            Data data = new Data();

            data.Labels = new List <string>()
            {
                "Red", "Blue", "Yellow"
            };

            PieDataset dataset = new PieDataset()
            {
                Label           = "My dataset",
                BackgroundColor = new List <string>()
                {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                HoverBackgroundColor = new List <string>()
                {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                Data = new List <double>()
                {
                    300, 50, 100
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;

            string code = chart.CreateChartCode("pieChart");

            ViewData["chart"] = chart;

            return(View());
        }
Example #18
0
        public static string GeneratePieChart()
        {
            Chart chart = new Chart();

            chart.Type = "pie";

            Data data = new Data();

            data.Labels = new List <string>()
            {
                "Red", "Blue", "Yellow"
            };

            PieDataset dataset = new PieDataset()
            {
                Label           = "My dataset",
                BackgroundColor = new List <string>()
                {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                HoverBackgroundColor = new List <string>()
                {
                    "#FF6384", "#36A2EB", "#FFCE56"
                },
                Data = new List <double>()
                {
                    300, 50, 100
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;

            string code = chart.CreateChartCode("pieChart");

            return(code);
        }
Example #19
0
        public WorldCasesChartConnected()
        {
            _chartConfig = new PieConfig
            {
                Options = new PieOptions(true)
                {
                    Legend = new Legend
                    {
                        Display = false
                    },
                    Responsive          = true,
                    MaintainAspectRatio = false,
                    CutoutPercentage    = 80,
                    Tooltips            = new Tooltips
                    {
                        Enabled         = true,
                        Mode            = InteractionMode.Index,
                        Intersect       = false,
                        BorderWidth     = 1,
                        BorderColor     = "rgba(0, 0, 0, 0.12)",
                        BackgroundColor = "#ffffff",
                        TitleFontColor  = "rgba(0, 0, 0, 0.87)",
                        BodyFontColor   = "rgba(0, 0, 0, 0.54)",
                        FooterFontColor = "rgba(0, 0, 0, 0.54)"
                    }
                }
            };

            _chartDataSet = new PieDataset
            {
                BackgroundColor  = new[] { "#3f51b5", "#e53935", "#008C00" },
                BorderWidth      = 8,
                HoverBorderColor = "#ffffff",
                BorderColor      = "#ffffff"
            };

            _chartConfig.Data.Labels.AddRange(new[] { "Active", "Deaths", "Recovered" });
            _chartConfig.Data.Datasets.Add(_chartDataSet);
        }
Example #20
0
        public PieConfig DrawPieChart <T>(string title, SortedDictionary <string, T> data)
        {
            var config = new PieConfig
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = true,
                        Text    = title
                    },
                    CutoutPercentage = 50,
                    Tooltips         = new Tooltips
                    {
                        Enabled = true,
                    },
                    MaintainAspectRatio = false
                }
            };

            var values = new T[data.Count];

            for (int i = 0; i < data.Count; i++)
            {
                var dataElement = data.ElementAt(i);
                config.Data.Labels.Add(dataElement.Key);
                values[i] = dataElement.Value;
            }

            var dataset = new PieDataset <T>(values)
            {
                BackgroundColor = ChartColors.All.Take(data.Count).Select(ColorUtil.FromDrawingColor).ToArray()
            };

            config.Data.Datasets.Add(dataset);

            return(config);
        }
Example #21
0
        private static Chart GetPercentagePerCountryChart(Dictionary <string, double> percentagePerCountry)
        {
            var chart = new Chart {
                Type = Enums.ChartType.Doughnut
            };
            var data = new ChartJSCore.Models.Data
            {
                Labels = percentagePerCountry.Keys.ToList()
            };
            var dataset = new PieDataset
            {
                Label           = "# hours watched",
                Data            = new List <double?>(percentagePerCountry.Values.Select(x => (double?)x)),
                BorderWidth     = 1,
                BackgroundColor = new List <ChartColor>(),
                Type            = Enums.ChartType.Doughnut,
            };

            for (int i = 0; i < percentagePerCountry.Count; i++)
            {
                dataset.BackgroundColor.Add(ChartColor.CreateRandomChartColor(false));
            }

            data.Datasets = new List <Dataset> {
                dataset
            };
            chart.Data    = data;
            chart.Options = new PieOptions
            {
                Responsive          = true,
                MaintainAspectRatio = false,
                Title = new Title {
                    Text = "Watched per country (in percentage)", Display = true
                },
                ResponsiveAnimationDuration = 500
            };

            return(chart);
        }
Example #22
0
        public Chart GeneratePieChart(List <string> labels, PieDataset dataset)
        {
            Chart chart = new Chart
            {
                Type = "pie"
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data
            {
                Labels = labels
            };

            data.Datasets = new List <Dataset>
            {
                dataset
            };

            Options options = new Options()
            {
                Tooltips = new ToolTip()
            };

            ToolTip toolTip = new ToolTip
            {
                Enabled   = true,
                Mode      = "single",
                Callbacks = new Callback
                {
                    Label = "function(tooltipItem, data) { var indice = tooltipItem.index; return  data.labels[indice] +': '+data.datasets[0].data[indice] + ' kWh';}"
                }
            };

            options.Tooltips = toolTip;

            chart.Options = options;
            chart.Data    = data;

            return(chart);
        }
        private Chart GetEventCategoryChart(StatisticsViewModel statisticsViewModel)
        {
            Chart chart = new Chart();
            Data  data  = new Data();

            data.Datasets = new List <Dataset>();
            chart.Data    = data;
            chart.Type    = Enums.ChartType.Pie;

            var categoryTitles = statisticsViewModel.EventCategoryMap.Keys.ToList();
            var categoryValues = statisticsViewModel.EventCategoryMap.Values.ToList();

            data.Labels = categoryTitles;
            PieDataset dataset = new PieDataset()
            {
                Label           = "TestChart",
                Data            = categoryValues,
                BackgroundColor = GetColors(statisticsViewModel.EventCategoryMap.Keys.Count)
            };

            data.Datasets.Add(dataset);
            return(chart);
        }
Example #24
0
        protected PieConfig GetChartConfig()
        {
            var labels  = new List <string>();
            var values  = new List <double>();
            var colours = new List <string>();

            foreach (var category in CategoryTimes)
            {
                labels.Add(category.Key.Description);
                values.Add(category.Value);
                colours.Add(category.Key.Colour);
            }
            var config = new PieConfig
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Animation  = new ArcAnimation
                    {
                        AnimateRotate = true,
                        AnimateScale  = true,
                    },
                    CutoutPercentage = 50,
                    OnClick          = new DotNetInstanceClickHandler(ClickItem)
                },
            };

            config.Data.Labels.AddRange(labels);
            var dataset = new PieDataset
            {
                BackgroundColor = new ChartJs.Blazor.ChartJS.Common.IndexableOption <string>(colours.ToArray()),
            };

            dataset.Data.AddRange(values);
            config.Data.Datasets.Add(dataset);
            return(config);
        }
Example #25
0
        public static PieConfig SetConfigPieChart(string title, Dictionary <string, double> values)
        {
            PieConfig config = new PieConfig()
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = true,
                        Text    = title
                    }
                }
            };
            List <double> items       = new List <double>();
            List <string> colorsChart = new List <string>();

            int i = 0;

            foreach (string key in values.Keys)
            {
                config.Data.Labels.Add(key);
                items.Add(values[key]);
                colorsChart.Add(colors[i]);
                i++;
            }

            PieDataset <double> dataset = new PieDataset <double>(items)
            {
                BackgroundColor = colors.ToArray()
            };

            config.Data.Datasets.Add(dataset);

            return(config);
        }
Example #26
0
        private static Chart GenerateNestedDoughnutChart()
        {
            Chart chart = new Chart();

            chart.Type = "doughnut";

            Data data = new Data();

            data.Labels = new List <string>()
            {
                "resource-group-1",
                "resource-group-2",
                "Data Services - Basic Database Days",
                "Data Services - Basic Database Days",
                "Azure App Service - Basic Small App Service Hours",
                "resource-group-2 - Other"
            };

            PieDataset outerDataset = new PieDataset()
            {
                BackgroundColor = new List <string>()
                {
                    "#3366CC",
                    "#DC3912",
                    "#FF9900",
                    "#109618",
                    "#990099",
                    "#3B3EAC"
                },
                HoverBackgroundColor = new List <string>()
                {
                    "#3366CC",
                    "#DC3912",
                    "#FF9900",
                    "#109618",
                    "#990099",
                    "#3B3EAC"
                },
                Data = new List <double>()
                {
                    0.0,
                    0.0,
                    8.31,
                    10.43,
                    84.69,
                    0.84
                }
            };

            PieDataset innerDataset = new PieDataset()
            {
                BackgroundColor = new List <string>()
                {
                    "#3366CC",
                    "#DC3912",
                    "#FF9900",
                    "#109618",
                    "#990099",
                    "#3B3EAC"
                },
                HoverBackgroundColor = new List <string>()
                {
                    "#3366CC",
                    "#DC3912",
                    "#FF9900",
                    "#109618",
                    "#990099",
                    "#3B3EAC"
                },
                Data = new List <double>()
                {
                    8.31,
                    95.96
                }
            };

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(outerDataset);
            data.Datasets.Add(innerDataset);

            chart.Data = data;

            return(chart);
        }
Example #27
0
        public void createNewChart(List <string> ChartLabels, IList <double> ChartValues, string chartType, string ChartTitle, string ChartID)
        {
            Chart DateChart = new Chart();

            DateChart.Type = chartType;
            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            data.Labels = ChartLabels;

            Options options = new Options()
            {
                Scales = new Scales()
            };

            Scales scales = new Scales()
            {
                YAxes = new List <Object>()
                {
                    new CartesianScale()
                    {
                        Type     = "linear",
                        Position = "bottom",
                        Ticks    = new CartesianLinearTick()
                        {
                            BeginAtZero = true
                        }
                    }
                }
            };



            if (chartType != "pie")
            {
                options.Scales = scales;

                DateChart.Options = options;

                LineDataset dataset = new LineDataset()
                {
                    Label            = ChartTitle,
                    Data             = ChartValues,
                    Fill             = false,
                    LineTension      = 0.1,
                    BackgroundColor  = "rgba(75, 192, 192, 0.4)",
                    BorderColor      = "rgba(75,192,192,1)",
                    BorderCapStyle   = "butt",
                    BorderDash       = new List <int> {
                    },
                    BorderDashOffset = 0.0,
                    BorderJoinStyle  = "miter",
                    PointBorderColor = new List <string>()
                    {
                        "rgba(75,192,192,1)"
                    },
                    PointBackgroundColor = new List <string>()
                    {
                        "#fff"
                    },
                    PointBorderWidth = new List <int> {
                        1
                    },
                    PointHoverRadius = new List <int> {
                        5
                    },
                    PointHoverBackgroundColor = new List <string>()
                    {
                        "rgba(75,192,192,1)"
                    },
                    PointHoverBorderColor = new List <string>()
                    {
                        "rgba(220,220,220,1)"
                    },
                    PointHoverBorderWidth = new List <int> {
                        2
                    },
                    PointRadius = new List <int> {
                        1
                    },
                    PointHitRadius = new List <int> {
                        10
                    },
                    SpanGaps = false
                };

                data.Datasets = new List <Dataset>();
                data.Datasets.Add(dataset);
            }
            else
            {
                PieDataset pie_dataset = new PieDataset()
                {
                    Label           = "My dataset",
                    BackgroundColor = new List <string>()
                    {
                        "#FF6384", "#36A2EB", "#FFCE56"
                    },
                    HoverBackgroundColor = new List <string>()
                    {
                        "#FF6384", "#36A2EB", "#FFCE56"
                    },
                    Data = ChartValues
                };


                data.Datasets = new List <Dataset>();
                data.Datasets.Add(pie_dataset);
            }

            DateChart.Data = data;

            ViewData[ChartID] = DateChart;
        }
Example #28
0
 public static JFreeChart createPieChart3D(string title, PieDataset dataset, bool legend, bool tooltips, bool urls)
 {
   int num1 = tooltips ? 1 : 0;
   int num2 = urls ? 1 : 0;
   int num3 = legend ? 1 : 0;
   PiePlot3D piePlot3D = new PiePlot3D(dataset);
   piePlot3D.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
   if (num1 != 0)
     piePlot3D.setToolTipGenerator((PieToolTipGenerator) new StandardPieToolTipGenerator());
   if (num2 != 0)
     piePlot3D.setURLGenerator((PieURLGenerator) new StandardPieURLGenerator());
   JFreeChart.__\u003Cclinit\u003E();
   JFreeChart jfc = new JFreeChart(title, JFreeChart.__\u003C\u003EDEFAULT_TITLE_FONT, (Plot) piePlot3D, num3 != 0);
   ChartFactory.currentTheme.apply(jfc);
   return jfc;
 }
Example #29
0
        public Chart GetMonthMood(Month selectedMonth)
        {
            Chart chart = new Chart();

            chart.Type = "pie";

            Data data = new Data();

            data.Labels = new List <string>()
            {
            };

            PieDataset dataset = new PieDataset()
            {
                Label                = "Статистика за " + selectedMonth.MonthName,
                BackgroundColor      = new List <string>(),
                HoverBackgroundColor = new List <string>(),
                Data = new List <double>()
            };

            var userId = userManager.GetUserId(User);
            var moods  = db.UserMoods
                         .Where(m => m.UserId == userId && m.Date.Month == selectedMonth.MonthId).Include(m => m.Mood)
                         .GroupBy(m => m.Mood.Name)
                         .Select(g => new { Name = g.Key, Count = g.Count() })
                         .ToList();

            if (!moods.Any())
            {
                data.Labels.Add("Нет записей");
                dataset.Data.Add(1);
                dataset.BackgroundColor.Add("rgb(169,169,169)");
            }
            else
            {
                foreach (var mood in moods)
                {
                    data.Labels.Add(mood.Name);
                    dataset.Data.Add(mood.Count);

                    switch (mood.Name)
                    {
                    case "Плохое":
                    {
                        dataset.BackgroundColor.Add("rgb(205, 92, 92)");
                        break;
                    }

                    case "Сонное":
                    {
                        dataset.BackgroundColor.Add("rgb(219, 112, 147)");
                        break;
                    }

                    case "Нормальное":
                    {
                        dataset.BackgroundColor.Add("rgb(189, 195, 199)");
                        break;
                    }

                    case "Веселое":
                    {
                        dataset.BackgroundColor.Add("rgb(39, 174, 96)");
                        break;
                    }

                    case "Отличное":
                    {
                        dataset.BackgroundColor.Add("rgb(70, 130, 180)");
                        break;
                    }
                    }
                }
            }

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(dataset);

            chart.Data = data;
            return(chart);
        }
Example #30
0
        private void ConfigGraficos()
        {
            gastosPorDia = new PieDataset <double>()
            {
                BackgroundColor = new[]
                {
                    ColorUtil.ColorHexString(255, 99, 132),
                    ColorUtil.ColorHexString(255, 205, 86),
                    ColorUtil.ColorHexString(255, 93, 27),
                    ColorUtil.ColorHexString(150, 27, 196),
                }
            };

            entradasPorDia = new PieDataset <double>()
            {
                BackgroundColor = new[]
                {
                    ColorUtil.ColorHexString(75, 192, 192),
                    ColorUtil.ColorHexString(54, 162, 235)
                }
            };

            total = new PieDataset <double>()
            {
                BackgroundColor = new[]
                {
                    ColorUtil.ColorHexString(192, 0, 0),
                    ColorUtil.ColorHexString(0, 192, 0)
                }
            };

            ConfigEntrada = new PieConfig
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = true,
                        Text    = "Entradas"
                    }
                }
            };

            ConfigGasto = new PieConfig
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = true,
                        Text    = "Saídas"
                    }
                }
            };

            ConfigTotal = new PieConfig
            {
                Options = new PieOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = true,
                        Text    = "Total"
                    }
                }
            };

            ConfigEntrada.Data.Datasets.Add(entradasPorDia);
            ConfigGasto.Data.Datasets.Add(gastosPorDia);
            ConfigTotal.Data.Datasets.Add(total);
        }
Example #31
0
 public PiePlot(PieDataset dataset)
 {
   PiePlot piePlot = this;
   this.shadowPaint = (Paint) Color.gray;
   this.shadowXOffset = 4.0;
   this.shadowYOffset = 4.0;
   this.simpleLabels = true;
   this.maximumLabelWidth = 0.14;
   this.labelGap = 0.025;
   this.labelLinkStyle = PieLabelLinkStyle.__\u003C\u003ESTANDARD;
   this.labelLinkMargin = 0.025;
   this.labelLinkPaint = (Paint) Color.black;
   this.labelLinkStroke = (Stroke) new BasicStroke(0.5f);
   this.dataset = dataset;
   if (dataset != null)
     dataset.addChangeListener((DatasetChangeListener) this);
   this.pieIndex = 0;
   this.interiorGap = 0.08;
   this.circular = true;
   this.startAngle = 90.0;
   this.direction = Rotation.__\u003C\u003ECLOCKWISE;
   this.minimumArcAngleToDraw = 1E-05;
   this.sectionPaint = (Paint) null;
   this.sectionPaintMap = new PaintMap();
   this.baseSectionPaint = (Paint) Color.gray;
   this.autoPopulateSectionPaint = true;
   this.sectionOutlinesVisible = true;
   this.sectionOutlinePaint = (Paint) null;
   this.sectionOutlinePaintMap = new PaintMap();
   this.baseSectionOutlinePaint = Plot.__\u003C\u003EDEFAULT_OUTLINE_PAINT;
   this.autoPopulateSectionOutlinePaint = false;
   this.sectionOutlineStroke = (Stroke) null;
   this.sectionOutlineStrokeMap = new StrokeMap();
   this.baseSectionOutlineStroke = Plot.__\u003C\u003EDEFAULT_OUTLINE_STROKE;
   this.autoPopulateSectionOutlineStroke = false;
   this.explodePercentages = (Map) new TreeMap();
   this.labelGenerator = (PieSectionLabelGenerator) new StandardPieSectionLabelGenerator();
   this.labelFont = PiePlot.__\u003C\u003EDEFAULT_LABEL_FONT;
   this.labelPaint = PiePlot.__\u003C\u003EDEFAULT_LABEL_PAINT;
   this.labelBackgroundPaint = PiePlot.__\u003C\u003EDEFAULT_LABEL_BACKGROUND_PAINT;
   this.labelOutlinePaint = PiePlot.__\u003C\u003EDEFAULT_LABEL_OUTLINE_PAINT;
   this.labelOutlineStroke = PiePlot.__\u003C\u003EDEFAULT_LABEL_OUTLINE_STROKE;
   this.labelShadowPaint = PiePlot.__\u003C\u003EDEFAULT_LABEL_SHADOW_PAINT;
   this.labelLinksVisible = true;
   this.labelDistributor = (AbstractPieLabelDistributor) new PieLabelDistributor(0);
   this.simpleLabels = false;
   RectangleInsets.__\u003Cclinit\u003E();
   this.simpleLabelOffset = new RectangleInsets(UnitType.__\u003C\u003ERELATIVE, 0.18, 0.18, 0.18, 0.18);
   this.labelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
   this.toolTipGenerator = (PieToolTipGenerator) null;
   this.urlGenerator = (PieURLGenerator) null;
   this.legendLabelGenerator = (PieSectionLabelGenerator) new StandardPieSectionLabelGenerator();
   this.legendLabelToolTipGenerator = (PieSectionLabelGenerator) null;
   this.legendLabelURLGenerator = (PieURLGenerator) null;
   this.legendItemShape = Plot.__\u003C\u003EDEFAULT_LEGEND_ITEM_CIRCLE;
   this.ignoreNullValues = false;
   this.ignoreZeroValues = false;
 }
Example #32
0
 public static JFreeChart createRingChart(string title, PieDataset dataset, bool legend, bool tooltips, Locale locale)
 {
   int num1 = tooltips ? 1 : 0;
   int num2 = legend ? 1 : 0;
   RingPlot ringPlot = new RingPlot(dataset);
   ringPlot.setLabelGenerator((PieSectionLabelGenerator) new StandardPieSectionLabelGenerator(locale));
   ringPlot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
   if (num1 != 0)
     ringPlot.setToolTipGenerator((PieToolTipGenerator) new StandardPieToolTipGenerator(locale));
   JFreeChart.__\u003Cclinit\u003E();
   JFreeChart jfc = new JFreeChart(title, JFreeChart.__\u003C\u003EDEFAULT_TITLE_FONT, (Plot) ringPlot, num2 != 0);
   ChartFactory.currentTheme.apply(jfc);
   return jfc;
 }
Example #33
0
        /// <summary>
        /// Returns a Pie Chart configuration displaying the data provided
        /// </summary>
        /// <param name="data">The data to be displayed</param>
        /// <param name="title">The overall chart title</param>
        /// <param name="scaleLabel"></param>
        /// <returns></returns>
        public static Chart GetPieChart(IDictionary <string, double?> data, string title, SortType sortType = SortType.None, bool displayLegend = true)
        {
            var titleFontSize = 12;

            try { titleFontSize = int.Parse(SystemHelper.GetConfigValue("AppSettings:TitleFontSize")); } catch { }
            var legendFontSize = 12;

            try { legendFontSize = int.Parse(SystemHelper.GetConfigValue("AppSettings:LegendFontSize")); } catch { }

            // Sort the data based on user request
            IDictionary <string, double?> sortedData;

            switch (sortType)
            {
            case SortType.None:
                sortedData = data;
                break;

            case SortType.ByLabel:
                sortedData = data.OrderBy(a => a.Key).ToDictionary(x => x.Key, y => y.Value);
                break;

            case SortType.ByLabelDescending:
                sortedData = data.OrderByDescending(a => a.Key).ToDictionary(x => x.Key, y => y.Value);
                break;

            case SortType.ByValue:
                sortedData = data.OrderBy(a => a.Value).ToDictionary(x => x.Key, y => y.Value);
                break;

            case SortType.ByValueDescending:
                sortedData = data.OrderByDescending(a => a.Value).ToDictionary(x => x.Key, y => y.Value);
                break;

            default:
                sortedData = data;
                break;
            }

            var chart = new Chart();

            chart.Type    = Enums.ChartType.Pie;
            chart.Options = new Options()
            {
                Responsive = true,
                Title      = new Title()
                {
                    Display  = !string.IsNullOrEmpty(title),
                    Text     = title,
                    FontSize = titleFontSize
                },
                Legend = new Legend()
                {
                    Display = displayLegend
                }
            };

            chart.Data          = new ChartJSCore.Models.Data();
            chart.Data.Datasets = new List <Dataset>();
            chart.Data.Labels   = new List <string>();

            var colorList    = new List <ChartColor>();
            var borderColors = new List <ChartColor>();
            var labels       = sortedData.Keys;
            var i            = 0;

            foreach (var name in labels)
            {
                chart.Data.Labels.Add(name);
                colorList.Add(ChartColor.FromHexString(_colorList[i++ % _colorList.Count]));
                borderColors.Add(ChartColor.FromHexString("#000000"));
            }

            //ChartJSCore.Models.Data modelData = new ChartJSCore.Models.Data();
            var dataset = new PieDataset()
            {
                Data            = sortedData.Values.ToList(),
                BackgroundColor = colorList,
                BorderColor     = borderColors,
                BorderWidth     = 2
            };

            chart.Data.Datasets.Add(dataset);

            return(chart);
        }
Example #34
0
 public static JFreeChart createPieChart(string title, PieDataset dataset, PieDataset previousDataset, int percentDiffForMaxScale, bool greenForIncrease, bool legend, bool tooltips, bool urls, bool subTitle, bool showDifference)
 {
   int num1 = tooltips ? 1 : 0;
   int num2 = urls ? 1 : 0;
   int num3 = showDifference ? 1 : 0;
   int num4 = greenForIncrease ? 1 : 0;
   int num5 = legend ? 1 : 0;
   int num6 = subTitle ? 1 : 0;
   PiePlot piePlot = new PiePlot(dataset);
   piePlot.setLabelGenerator((PieSectionLabelGenerator) new StandardPieSectionLabelGenerator());
   piePlot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
   if (num1 != 0)
     piePlot.setToolTipGenerator((PieToolTipGenerator) new StandardPieToolTipGenerator());
   if (num2 != 0)
     piePlot.setURLGenerator((PieURLGenerator) new StandardPieURLGenerator());
   List keys = dataset.getKeys();
   DefaultPieDataset defaultPieDataset = (DefaultPieDataset) null;
   if (num3 != 0)
     defaultPieDataset = new DefaultPieDataset();
   double num7 = (double) byte.MaxValue / (double) percentDiffForMaxScale;
   Iterator iterator = keys.iterator();
   while (iterator.hasNext())
   {
     IComparable comparable = (IComparable) iterator.next();
     Number number1 = dataset.getValue(comparable);
     Number number2 = previousDataset.getValue(comparable);
     if (number2 == null)
     {
       if (num4 != 0)
         piePlot.setSectionPaint(comparable, (Paint) Color.green);
       else
         piePlot.setSectionPaint(comparable, (Paint) Color.red);
       if (num3 != 0)
         defaultPieDataset.setValue((IComparable) new StringBuffer().append((object) comparable).append(" (+100%)").toString(), number1);
     }
     else
     {
       double num8 = (number1.doubleValue() / number2.doubleValue() - 1.0) * 100.0;
       double num9 = Math.abs(num8) < (double) percentDiffForMaxScale ? Math.abs(num8) * num7 : (double) byte.MaxValue;
       if (num4 != 0 && number1.doubleValue() > number2.doubleValue() || num4 == 0 && number1.doubleValue() < number2.doubleValue())
         piePlot.setSectionPaint(comparable, (Paint) new Color(0, ByteCodeHelper.d2i(num9), 0));
       else
         piePlot.setSectionPaint(comparable, (Paint) new Color(ByteCodeHelper.d2i(num9), 0, 0));
       if (num3 != 0)
         defaultPieDataset.setValue((IComparable) new StringBuffer().append((object) comparable).append(" (").append(num8 < 0.0 ? "" : "+").append(NumberFormat.getPercentInstance().format(num8 / 100.0)).append(")").toString(), number1);
     }
   }
   if (num3 != 0)
     piePlot.setDataset((PieDataset) defaultPieDataset);
   JFreeChart.__\u003Cclinit\u003E();
   JFreeChart jfc = new JFreeChart(title, JFreeChart.__\u003C\u003EDEFAULT_TITLE_FONT, (Plot) piePlot, num5 != 0);
   if (num6 != 0)
   {
     TextTitle.__\u003Cclinit\u003E();
     TextTitle textTitle = new TextTitle(new StringBuffer().append("Bright ").append(num4 == 0 ? "green" : "red").append("=change >=-").append(percentDiffForMaxScale).append("%, Bright ").append(num4 != 0 ? "green" : "red").append("=change >=+").append(percentDiffForMaxScale).append("%").toString(), new Font("SansSerif", 0, 10));
     jfc.addSubtitle((Title) textTitle);
   }
   ChartFactory.currentTheme.apply(jfc);
   return jfc;
 }