Exemplo n.º 1
0
        public static string GenerateLineScatterChart()
        {
            Chart chart = new Chart();

            chart.Type = "line";

            Data data = new Data();

            LineScatterDataset dataset = new LineScatterDataset()
            {
                Label = "Scatter Dataset",
                Data  = new List <LineScatterData>()
            };

            LineScatterData scatterData1 = new LineScatterData();
            LineScatterData scatterData2 = new LineScatterData();
            LineScatterData scatterData3 = new LineScatterData();

            scatterData1.x = "-10";
            scatterData1.y = "0";
            dataset.Data.Add(scatterData1);

            scatterData2.x = "0";
            scatterData2.y = "10";
            dataset.Data.Add(scatterData2);

            scatterData3.x = "10";
            scatterData3.y = "5";
            dataset.Data.Add(scatterData3);

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

            chart.Data = data;

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

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

            options.Scales = scales;

            chart.Options = options;

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

            return(code);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync()
        {
            //todo: fix the goddamn chart
            //Initalize people with defaults
            var Matches = await _context.Match.OrderBy(x => x.Time).ToListAsync();

            var People = _context.Person.ToList();

            People.ForEach(x => x.Rating = GameInfo.DefaultGameInfo.DefaultRating);

            List <LineScatterDataset> datasets = new List <LineScatterDataset>();

            People.ForEach(x => datasets.Add(new LineScatterDataset()
            {
                Label       = x.PersonName,
                Data        = new List <LineScatterData>(),
                Fill        = "false",
                BorderColor = GetColorString(),
            }));

            var baseTime = Matches[0].Time;
            var endTime  = Matches.Last().Time - baseTime;


            Dictionary <Person, double> ratingDict = new Dictionary <Person, double>();

            People.ForEach(x => ratingDict.Add(x, x.ConservativeRating));
            foreach (var Match in Matches)
            {
                //Todo
                var matchPeople = _context.MatchPeople.Where(x => x.MatchId == Match.MatchId).ToList();
                foreach (MatchPerson matchPerson in matchPeople)
                {
                    TimeSpan interval = matchPerson.Match.Time - baseTime;
                    ratingDict[matchPerson.Person] += matchPerson.RatingChange;
                    var lineScatterData = new LineScatterData()
                    {
                        x = Match.Time.ToString(), y = Math.Round(ratingDict[matchPerson.Person], 3).ToString()
                    };

                    datasets.Single(x => x.Label == matchPerson.PersonName).Data.Add(lineScatterData);
                }
            }
            chart      = new Chart();
            chart.Type = "line";
            Data data = new Data();

            data.Datasets = new List <Dataset>();
            data.Datasets.Add(datasets[1]);
            //datasets.ForEach(x => data.Datasets.Add(x));
            chart.Data = data;

            Options options = new Options()
            {
                Responsive          = true,
                MaintainAspectRatio = false,
                Scales = new Scales()
                {
                    XAxes = new List <Scale>()
                    {
                        new CartesianScale()
                        {
                            Display = true,
                            Ticks   = new TimeTick()
                            {
                                Display = true,
                                Source  = "auto"
                                          //Max = 1,
                            },
                            ScaleLabel = new ScaleLabel()
                            {
                                Display     = true,
                                LabelString = "X AXIS",
                                FontSize    = 20
                            }
                        }
                    },
                    YAxes = new List <Scale>()
                    {
                        new CartesianScale()
                        {
                            Display = true,
                            Ticks   = new CartesianLinearTick()
                            {
                                Display = true,
                            },
                            ScaleLabel = new ScaleLabel()
                            {
                                Display     = true,
                                LabelString = "Y AXIS",
                                FontSize    = 20
                            }
                        }
                    }
                }
            };

            chart.Options = options;
            return(Page());
        }
Exemplo n.º 3
0
        public Chart GenerateLineScatterChart()
        {
            Chart chart = new Chart
            {
                Type = "line"
            };

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();

            LineScatterDataset dataset = new LineScatterDataset()
            {
                Label = "Scatter Dataset",
                Data  = new List <LineScatterData>()
            };

            LineScatterData scatterData1 = new LineScatterData();
            LineScatterData scatterData2 = new LineScatterData();
            LineScatterData scatterData3 = new LineScatterData();

            scatterData1.x = -10;
            scatterData1.y = 0;
            dataset.Data.Add(scatterData1);

            scatterData2.x = 0;
            scatterData2.y = 10;
            dataset.Data.Add(scatterData2);

            scatterData3.x = 10;
            scatterData3.y = 5;
            dataset.Data.Add(scatterData3);

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

            chart.Data = data;

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

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

            options.Scales = scales;

            chart.Options = options;

            return(chart);
        }
        private static Chart GenerateLineScatterChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Line
            };

            var data = new Data();

            var dataset = new LineScatterDataset
            {
                Label = "Scatter Dataset",
                Data  = new List <LineScatterData>()
            };

            var scatterData1 = new LineScatterData();
            var scatterData2 = new LineScatterData();
            var scatterData3 = new LineScatterData();

            scatterData1.X = "-10";
            scatterData1.Y = "0";
            dataset.Data.Add(scatterData1);

            scatterData2.X = "0";
            scatterData2.Y = "10";
            dataset.Data.Add(scatterData2);

            scatterData3.X = "10";
            scatterData3.Y = "5";
            dataset.Data.Add(scatterData3);

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

            chart.Data = data;

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

            var scales = new Scales
            {
                XAxes = new List <Scale>
                {
                    new CartesianScale
                    {
                        Type     = "linear",
                        Position = "bottom",
                        Ticks    = new CartesianLinearTick
                        {
                            BeginAtZero = true
                        }
                    }
                }
            };

            options.Scales = scales;

            chart.Options = options;
            return(chart);
        }
Exemplo n.º 5
0
        private static Chart GenerateLineScatterChart(List <Project> listOfProjects)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Line;

            Data data = new Data();

            LineScatterDataset dataset = new LineScatterDataset()
            {
                Label = "Scatter Dataset",
                Data  = new List <LineScatterData>()
            };

            LineScatterData scatterData1 = new LineScatterData();
            LineScatterData scatterData2 = new LineScatterData();
            LineScatterData scatterData3 = new LineScatterData();

            scatterData1.X = "-10";
            scatterData1.Y = "0";
            dataset.Data.Add(scatterData1);

            scatterData2.X = "0";
            scatterData2.Y = "10";
            dataset.Data.Add(scatterData2);

            scatterData3.X = "10";
            scatterData3.Y = "5";
            dataset.Data.Add(scatterData3);

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

            chart.Data = data;

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

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

            options.Scales = scales;

            chart.Options = options;

            return(chart);
        }