Ejemplo n.º 1
0
        private void ConfigDailyChart()
        {
            ConfigDaily = Helper.GetLineChartConfig("Brazil Covid-19 Daily Evolution", "Days", "Victims");

            casesPerDaySet = new LineDataset <Point>
            {
                BackgroundColor      = ColorUtil.ColorString(0, 255, 0, 1.0),
                BorderColor          = ColorUtil.ColorString(0, 0, 255, 1.0),
                Label                = "New Cases",
                Fill                 = false,
                PointBackgroundColor = ColorUtil.ColorString(0, 0, 255, 1.0),
                BorderWidth          = 1,
                PointRadius          = 3,
                PointBorderWidth     = 1,
                SteppedLine          = SteppedLine.False,
            };

            deathsPerDaySet = new LineDataset <Point>
            {
                BackgroundColor  = ColorUtil.ColorString(255, 0, 0, 1.0),
                BorderColor      = ColorUtil.ColorString(255, 0, 0, 1.0),
                Label            = "New Deaths",
                Fill             = false,
                BorderWidth      = 1,
                PointRadius      = 2,
                PointBorderWidth = 1,
                SteppedLine      = SteppedLine.False
            };
        }
Ejemplo n.º 2
0
        public LineChartComponent()
        {
            InitComponent();
            config.Options = options;

            dataset = new LineDataset <TimeTuple <int> >
            {
                BackgroundColor  = ColorUtil.RandomColorString(),
                BorderColor      = ColorUtil.RandomColorString(),
                Label            = "Temperature",
                Fill             = false,
                BorderWidth      = 2,
                PointRadius      = 3,
                PointBorderWidth = 1,
                SteppedLine      = SteppedLine.False
            };
            //Initial retrieve of Data
            //var forecasts = await _forecastService.GetForecastAsync(DateTime.Now, 2);
            List <TimeTuple <int> > e = new List <TimeTuple <int> >();
            var rand = new Random();

            e.ToList();
            for (int i = 0; i < 50; i++)
            {
                e.Add(new TimeTuple <int>(new Moment(DateTime.Now.AddSeconds(-300 * i)), rand.Next(10, 100)));
            }
            dataset.AddRange(e);

            //_tempDataSet.AddRange(forecasts.Select(p => new TimeTuple<int>(new Moment(p.Date), p.TemperatureC)));
            config.Data.Datasets.Add(dataset);
        }
Ejemplo n.º 3
0
        private async Task TaskLoadEvolutionChart()
        {
            var getStatistics = await httpClient.GetAsync($"api/ads/evolution/{Id}");

            getStatistics.EnsureSuccessStatusCode();

            var jStatistics = await getStatistics.Content.ReadAsStringAsync();

            var statistics = JsonConvert.DeserializeObject <List <StatisticDatePoint> >(jStatistics);

            IDataset <int> dataset1 = new LineDataset <int>(statistics.Select(s => s.Value).ToArray())
            {
                Label           = Loc["NumberOfViews"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.Blue),
                BorderColor     = ColorUtil.FromDrawingColor(Color.Blue),
                Fill            = FillingMode.Disabled
            };

            foreach (var date in statistics.Select(s => s.Date.ToString("dd/MM")))
            {
                _config.Data.Labels.Add(date);
            }

            _config.Data.Datasets.Add(dataset1);
            await _chart.Update();
        }
        private Chart GetSpendingByDateChart(StatisticsViewModel statisticsViewModel)
        {
            Chart chart = new Chart();
            Data  data  = new Data();

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

            var dates  = statisticsViewModel.SpendingByDateMap.Keys.ToList();
            var values = statisticsViewModel.SpendingByDateMap.Values.ToList();

            data.Labels = dates;
            LineDataset dataset = new LineDataset()
            {
                Label            = "Spending",
                Data             = values,
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets.Add(dataset);
            return(chart);
        }
        private void SetForcesDatasActions()
        {
            ForcesDatas.CollectionChanged += (s, e) =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    var newEle = e.NewItems;
                    for (int i = 0; i < newEle.Count; i++)
                    {
                        var color = ColorUtil.RandomColorString();
                        var ele   = new List <Point> {
                            newEle[i] as Point
                        };
                        var lineSet = new LineDataset <Point>(ele)
                        {
                            Label = "Point " + (ForcesDatas.Count()),
                            PointBackgroundColor  = color,
                            PointBorderWidth      = borderWidth,
                            PointHitRadius        = pointRadius,
                            PointHoverBorderWidth = borderWidth,
                            PointRadius           = pointRadius,
                            PointHoverRadius      = pointRadius * 12 / 10,
                        };
                        _config.Data.Datasets.Add(lineSet);
                    }
                }
                else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    var newEle = e.OldItems;
                    for (int i = 0; i < newEle.Count; i++)
                    {
                        var ele = _config.Data.Datasets.ToList().Find((x) =>
                                                                      (x as LineDataset <Point>).Label == "Point " + (e.OldStartingIndex + 1));

                        _config.Data.Datasets.Remove(ele);
                    }
                    resetLabelText();
                }
                else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
                {
                    var oldEle = e.OldItems;
                    var newEle = e.NewItems;
                    for (int i = 0; i < oldEle.Count; i++)
                    {
                        var ele = _config.Data.Datasets.ToList().Find((x) =>
                                                                      (x as LineDataset <Point>).Label == "Point " + (e.OldStartingIndex + 1)) as LineDataset <Point>;

                        ele.RemoveAll(x => true);
                        ele.AddRange(newEle[i] as IEnumerable <Point>);
                    }
                }
                InvokeAsync(this.StateHasChanged);
            };
        }
Ejemplo n.º 6
0
        public void UpdateChart()
        {
            this.Config.Options.Title.Text = $"Zmienna lingwistyczna {this.parent_variable.Name}: {this.parent_variable.Description}";
            LinearCartesianAxis lca = this.Config.Options.Scales.xAxes[0] as LinearCartesianAxis;

            lca.Ticks.Min = this.parent_variable.Minimum.Value;
            lca.Ticks.Max = this.parent_variable.Maximum.Value;

            this.Config.Data.Datasets.Clear();

            string[] colors = new[] { "blue", "red", "green", "black", "magenta", "cyan", "brown", "yellow" };
            int      icolor = 0;

            foreach (FuzzyValue fval in this.parent_variable.Values)
            {
                LineDataset <Point> data_set = new LineDataset <Point>
                {
                    Label          = fval.Name,
                    LineTension    = 0,
                    PointRadius    = 2,
                    BorderColor    = colors[icolor++ % colors.Length],
                    PointHitRadius = 10,
                    BorderWidth    = 3,
                };

                if (fval.MembershipType == MembershipFunctionFamily.Trapezoidal)
                {
                    NamedParameter sl = fval.GetParameter("SuppL");
                    NamedParameter kl = fval.GetParameter("KernL");
                    NamedParameter kr = fval.GetParameter("KernR");
                    NamedParameter sr = fval.GetParameter("SuppR");

                    data_set.Add(new Point(this.parent_variable.Minimum.Value, 0));
                    data_set.Add(new Point(sl.Value, 0));
                    data_set.Add(new Point(kl.Value, 1));
                    data_set.Add(new Point(kr.Value, 1));
                    data_set.Add(new Point(sr.Value, 0));
                    data_set.Add(new Point(this.parent_variable.Maximum.Value, 0));

                    this.Config.Data.Datasets.Add(data_set);
                }
            }
        }
Ejemplo n.º 7
0
        public static ConfigBase GetChartConfig(TimelineResponse response)
        {
            var config = GetLineConfig();

            config.Options.Title.Text = response.Interest + (response.Versus == "ALL" ? "" : " vs " + response.Versus);

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

            foreach (var item in response.Items)
            {
                config.Data.Labels.Add(item.Label);
                pointData.Add(item.Count == 0 ? 0 : Math.Round((double)item.Wins * 100.0 / (double)item.Count, 2));
            }

            var pointDataset = new LineDataset <double>(pointData)
            {
                Label            = "",
                BorderColor      = DSData.CMDRcolor[response.Interest],
                BorderWidth      = 1,
                PointRadius      = 2,
                PointHoverRadius = 10,
                ShowLine         = false,
                Fill             = false
            };

            var timelineDataset = new LineDataset <double>(response.SmaData)
            {
                Label            = response.Interest,
                BorderColor      = DSData.CMDRcolor[response.Interest],
                BorderWidth      = 3,
                PointRadius      = 1,
                PointHoverRadius = 1,
                ShowLine         = true,
                Fill             = false
            };

            config.Data.Datasets.Add(pointDataset);
            config.Data.Datasets.Add(timelineDataset);

            return(config);
        }
Ejemplo n.º 8
0
        public Chart GetChart(ChartDataSet chartDataSets)
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Line;

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

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


            data.Labels = chartDataSets.XValues;

            LineDataset dataset = new LineDataset()
            {
                Label            = chartDataSets.Title,
                Data             = chartDataSets.YValues.Select(x => (double?)Math.Round(x.Value, 2)).ToList(),
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = chartDataSets.Color,
                BorderColor      = chartDataSets.Color,
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    chartDataSets.Color
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    chartDataSets.Color
                },
                PointHoverBorderColor = new List <ChartColor> {
                    chartDataSets.Color
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets.Add(dataset);


            chart.Data = data;
            return(chart);
        }
Ejemplo n.º 9
0
        private async Task TaskLoadEvolutionChart()
        {
            foreach (var date in DashboardInfo.StatisticsDays.Select(s => s.Date.ToString("dd/MM")))
            {
                _configEvolution.Data.Labels.Add(date);
            }

            IDataset <int> dataset1 = new LineDataset <int>(DashboardInfo.StatisticsDays.Select(d => d.NbVisits))
            {
                Label           = Loc["NumberOfVisits"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.Blue),
                BorderColor     = ColorUtil.FromDrawingColor(Color.Blue),
                Fill            = FillingMode.Disabled
            };

            _configEvolution.Data.Datasets.Add(dataset1);

            IDataset <int> dataset2 = new LineDataset <int>(DashboardInfo.StatisticsDays.Select(d => d.NbRegistar))
            {
                Label           = Loc["NbRegistar"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.Red),
                BorderColor     = ColorUtil.FromDrawingColor(Color.Red),
                Fill            = FillingMode.Disabled
            };

            _configEvolution.Data.Datasets.Add(dataset2);

            IDataset <int> dataset3 = new LineDataset <int>(DashboardInfo.StatisticsDays.Select(d => d.NbLogin))
            {
                Label           = Loc["NbLogins"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.Silver),
                BorderColor     = ColorUtil.FromDrawingColor(Color.Silver),
                Fill            = FillingMode.Disabled
            };

            _configEvolution.Data.Datasets.Add(dataset3);

            IDataset <int> dataset4 = new LineDataset <int>(DashboardInfo.StatisticsDays.Select(d => d.NbRequestSubscription))
            {
                Label           = Loc["NbRequestSubscription"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.Silver),
                BorderColor     = ColorUtil.FromDrawingColor(Color.Silver),
                Fill            = FillingMode.Disabled
            };

            _configEvolution.Data.Datasets.Add(dataset4);

            IDataset <int> dataset5 = new LineDataset <int>(DashboardInfo.StatisticsDays.Select(d => d.NbFinishSubscription))
            {
                Label           = Loc["NbFinishSubscription"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.DarkGreen),
                BorderColor     = ColorUtil.FromDrawingColor(Color.DarkGreen),
                Fill            = FillingMode.Disabled
            };

            _configEvolution.Data.Datasets.Add(dataset5);

            IDataset <int> dataset6 = new LineDataset <int>(DashboardInfo.StatisticsDays.Select(d => d.NbAds))
            {
                Label           = Loc["NbAds"],
                BackgroundColor = ColorUtil.FromDrawingColor(Color.GreenYellow),
                BorderColor     = ColorUtil.FromDrawingColor(Color.GreenYellow),
                Fill            = FillingMode.Disabled
            };

            _configEvolution.Data.Datasets.Add(dataset6);
            await _chartEvolution.Update();
        }
Ejemplo n.º 10
0
        public async Task <IList <ChartJSCore.Models.Chart> > CreateCharts(IEnumerable <Entry> measures)
        {
            ChartJSCore.Models.Chart soilM = new ChartJSCore.Models.Chart();
            ChartJSCore.Models.Chart air   = new ChartJSCore.Models.Chart();

            soilM.Type = "line";
            air.Type   = "line";

            ChartJSCore.Models.Data data  = new ChartJSCore.Models.Data();
            ChartJSCore.Models.Data data2 = new ChartJSCore.Models.Data();
            data.Labels  = measures.Select(g => g.LocalDateTime.ToString("G")).ToList();
            data2.Labels = measures.Select(g => g.LocalDateTime.ToString("G")).ToList();

            LineDataset dataset = new LineDataset()
            {//collection.Skip(Math.Max(0, collection.Count() - N));
                Label            = "Soil moisture",
                Data             = measures.Skip(Math.Max(0, measures.Count() - 350)).Select(g => (double)g.SoilMoisture).ToList(),
                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
            };
            LineDataset dataset2 = new LineDataset()
            {
                Label            = "Air humidity",
                Data             = measures.Skip(Math.Max(0, measures.Count() - 350)).Select(g => (double)g.AirHumidity).ToList(),
                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(75,192,192,1)"
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            LineDataset dataset3 = new LineDataset()
            {
                Label            = "Air temperature",
                Data             = measures.Skip(Math.Max(0, measures.Count() - 350)).Select(g => (double)g.AirTemperature).ToList(),
                Fill             = false,
                LineTension      = 0.1,
                BackgroundColor  = "rgba(200, 60, 40, 0.4)",
                BorderColor      = "rgba(200, 60, 40,1)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(200, 60, 40,1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(200, 60, 40,1)"
                },
                PointHoverBorderColor = new List <string>()
                {
                    "rgba(200, 60, 40,1)"
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

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

            soilM.Data = data;
            air.Data   = data2;

            return(new List <ChartJSCore.Models.Chart> {
                soilM, air
            });
        }
Ejemplo n.º 11
0
        public IActionResult OnGet()
        {
            if (HttpContext.Session.GetString("email") == null)
            {
                return(RedirectToPage("Login"));
            }
            Costs    = CostsRepository.GetCostsByEmail(HttpContext.Session.GetString("email"));
            Vehicles = VehiclesRepository.GetVehiclesByEmail(HttpContext.Session.GetString("email"));

            //Calculates all overdue fixedCosts
            foreach (var item in Vehicles)
            {
                CostsRepository.FixedCostsMontly(item.License);
            }

            //Chart settings
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Line;
            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            data.Labels = new List <string>()
            {
                "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"
            };
            data.Datasets = new List <Dataset>();
            Random random = new Random();

            var year = HttpContext.Request.Query["Year"];

            if (!string.IsNullOrWhiteSpace(year))
            {
                Year = Convert.ToInt32(year);
            }
            else
            {
                Year = DateTime.Now.Year;
            }

            //Foreach to loop through every vehicle to get AnnualCosts and set it in the chart
            foreach (var vehicle in Vehicles)
            {
                int[,] randomColor = new int[3, 1] {
                    { random.Next(0, 255) }, { random.Next(0, 255) }, { random.Next(0, 255) }
                };
                IList <double?> annualCosts = CostsRepository.GetAnnualCosts(vehicle.License, Year);
                LineDataset     dataset     = new LineDataset()
                {
                    Label            = vehicle.Brand_Name + ' ' + vehicle.Model_Name,
                    Data             = annualCosts,
                    Fill             = "false",
                    LineTension      = 0.1,
                    BackgroundColor  = ChartColor.FromRgba((byte)randomColor[0, 0], (byte)randomColor[1, 0], (byte)randomColor[2, 0], 0.4),
                    BorderColor      = ChartColor.FromRgb((byte)randomColor[0, 0], (byte)randomColor[1, 0], (byte)randomColor[2, 0]),
                    BorderCapStyle   = "butt",
                    BorderDash       = new List <int> {
                    },
                    BorderDashOffset = 0.0,
                    BorderJoinStyle  = "miter",
                    PointBorderColor = new List <ChartColor> {
                        ChartColor.FromRgb(75, 192, 192)
                    },
                    PointBackgroundColor = new List <ChartColor> {
                        ChartColor.FromHexString("#ffffff")
                    },
                    PointBorderWidth = new List <int> {
                        1
                    },
                    PointHoverRadius = new List <int> {
                        5
                    },
                    PointHoverBackgroundColor = new List <ChartColor> {
                        ChartColor.FromRgb(75, 192, 192)
                    },
                    PointHoverBorderColor = new List <ChartColor> {
                        ChartColor.FromRgb(220, 220, 220)
                    },
                    PointHoverBorderWidth = new List <int> {
                        2
                    },
                    PointRadius = new List <int> {
                        1
                    },
                    PointHitRadius = new List <int> {
                        10
                    },
                    SpanGaps = false
                };
                data.Datasets.Add(dataset);
            }
            chart.Data = data;

            ViewData["chart"] = chart;


            return(Page());
        }
Ejemplo n.º 12
0
        public void OnGet()
        {
            Chart chart = new Chart();

            chart.Type = "line";
            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            data.Labels = new List <string> {
                "January", "February", "March", "April", "May", "June", "July"
            };

            LineDataset firstDataset = new LineDataset
            {
                Label = "First",
                Data  = new List <double>()
                {
                    65, 59, 80, 81, 56, 55, 40
                },
                Fill             = "origin",
                LineTension      = 0.1,
                BackgroundColor  = "rgba(255, 0, 0, 0.4)",
                BorderColor      = "rgba(255, 0, 0, 0.8)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(255, 0, 0, 1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(255, 0, 0, 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
            };

            LineDataset secondDataset = new LineDataset
            {
                Label = "Second",
                Data  = new List <double>()
                {
                    165, 159, 180, 181, 156, 155, 140
                },
                Fill             = "-1",
                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(firstDataset);
            data.Datasets.Add(secondDataset);
            chart.Data = data;

            FirstChart = chart;
        }
Ejemplo n.º 13
0
        public async Task <ChartJSCore.Models.Chart> GetGraphData()
        {
            Random random = new Random();

            ChartJSCore.Models.Chart chart = new ChartJSCore.Models.Chart();

            chart.Type = "line";
            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            data.Labels = (from contextShereRatese in _context.ShereRateses
                           select contextShereRatese.DateTimeRates.ToLongTimeString()).Distinct().ToList();
            data.Datasets = new List <Dataset>();
            foreach (var companyCode in _context.Companies.Select(w => w.Code))
            {
                string coloRround = "rbga(" + random.Next(0, 255) + "," + random.Next(0, 255) + "," + random.Next(0, 255);

                List <decimal> list = new List <decimal>();
                foreach (decimal @decimal in (_context.ShereRateses.Where(w => w.Code == companyCode).Select(
                                                  contextShereRatese => contextShereRatese.Rate)))
                {
                    list.Add(@decimal);
                }
                LineDataset dataset = new LineDataset()
                {
                    Label            = companyCode,
                    Data             = list as IList <double>,
                    Fill             = "false",
                    LineTension      = 0.1,
                    BackgroundColor  = coloRround + ",0.4)",
                    BorderColor      = coloRround + ",1)",
                    BorderCapStyle   = "butt",
                    BorderDash       = new List <int> {
                    },
                    BorderDashOffset = 0.0,
                    BorderJoinStyle  = "miter",
                    PointBorderColor = new List <string>()
                    {
                        coloRround + ",1)"
                    },
                    PointBackgroundColor = new List <string>()
                    {
                        "#fff"
                    },
                    PointBorderWidth = new List <int> {
                        1
                    },
                    PointHoverRadius = new List <int> {
                        5
                    },
                    PointHoverBackgroundColor = new List <string>()
                    {
                        coloRround + ",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.Add(dataset);
            }
            chart.Data = data;
            return(chart);
        }
Ejemplo n.º 14
0
        public IActionResult MyStatement()
        {
            var accountUserId = ViewData["Id"] = UserManager.GetUserId(User);
            var userOwner     = Repository.Single(p => p.Account.Id == (int)accountUserId);

            #region linechart
            Chart chart1 = new Chart {
                Type = "line"
            };

            Data data1 = new Data {
                Labels = new List <string>()
            };
            LineDataset dataset1P = new LineDataset()
            {
                Label            = "Production",
                Data             = new List <double>(),
                Fill             = false,
                LineTension      = 0.1,
                BackgroundColor  = "rgba(52, 201, 36, 0.4)",
                BorderColor      = "rgba(52, 201, 36,1)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int>(),
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(52, 201, 36,1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(52, 201, 36,1)"
                },
                PointHoverBorderColor = new List <string>()
                {
                    "rgba(52, 201, 36,1)"
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            LineDataset dataset1C = new LineDataset()
            {
                Label            = "Consommation",
                Data             = new List <double>(),
                Fill             = false,
                LineTension      = 0.1,
                BackgroundColor  = "rgba(187, 11, 11, 0.4)",
                BorderColor      = "rgba(187, 11, 11,1)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int>(),
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(187, 11, 11,1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(187, 11, 11,1)"
                },
                PointHoverBorderColor = new List <string>()
                {
                    "rgba(187, 11, 11,1)"
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            var statements1 = StatementRepository.Find(p => p.Equipment.Owner.Id == userOwner.Id).OrderBy(p => p.Date).GroupBy(p => p.Date);
            foreach (var statement in statements1)
            {
                var prod  = 0.0;
                var count = 0;
                foreach (var state in statement)
                {
                    if (count == 0)
                    {
                        dataset1C.Data.Add(state.Consommation);
                        data1.Labels.Add(state.Date.ToString(CultureInfo.CurrentCulture));
                    }
                    count++;
                    prod += state.Production;
                }
                dataset1P.Data.Add(prod);
            }

            data1.Datasets = new List <Dataset> {
                dataset1P, dataset1C
            };

            chart1.Data = data1;

            ViewData["chart1"] = chart1;
            #endregion
            #region barchart
            Chart chart2 = new Chart {
                Type = "bar"
            };

            Data data2 = new Data {
                Labels = new List <string>()
            };
            LineDataset dataset2P = new LineDataset()
            {
                Label            = "Production",
                Data             = new List <double>(),
                Fill             = false,
                LineTension      = 0.1,
                BackgroundColor  = "rgba(52, 201, 36, 0.4)",
                BorderColor      = "rgba(52, 201, 36,1)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int>(),
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(52, 201, 36,1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(52, 201, 36,1)"
                },
                PointHoverBorderColor = new List <string>()
                {
                    "rgba(52, 201, 36,1)"
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            LineDataset dataset2C = new LineDataset()
            {
                Label            = "Consommation",
                Data             = new List <double>(),
                Fill             = false,
                LineTension      = 0.1,
                BackgroundColor  = "rgba(187, 11, 11, 0.4)",
                BorderColor      = "rgba(187, 11, 11,1)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int>(),
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(187, 11, 11,1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(187, 11, 11,1)"
                },
                PointHoverBorderColor = new List <string>()
                {
                    "rgba(187, 11, 11,1)"
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            var statements2 = StatementRepository.Find(p => p.Equipment.Owner.Id == userOwner.Id).OrderBy(p => p.Date).GroupBy(p => p.Date);
            foreach (var statement in statements2)
            {
                var prod  = 0.0;
                var count = 0;
                foreach (var state in statement)
                {
                    if (count == 0)
                    {
                        dataset2C.Data.Add(state.Consommation);
                        data2.Labels.Add(state.Date.ToString(CultureInfo.CurrentCulture));
                    }
                    count++;
                    prod += state.Production;
                }
                dataset2P.Data.Add(prod);
            }

            data2.Datasets = new List <Dataset> {
                dataset2P, dataset2C
            };

            chart2.Data = data2;

            ViewData["chart2"] = chart2;
            #endregion
            #region piechart
            Chart chart3 = new Chart {
                Type = "polarArea"
            };

            Data data3 = new Data {
                Labels = new List <string>()
            };
            PolarDataset dataset3 = new PolarDataset()
            {
                Label           = "My Production",
                BackgroundColor = new List <string>(),
                Data            = new List <double>()
            };

            var green       = 0;
            var statements3 = EquipmentRepository.Find(p => p.Owner.Id == userOwner.Id);
            foreach (var statement in statements3)
            {
                data3.Labels.Add(statement.Name);
                var somme = 0.0;
                var tests = StatementRepository.Find(p => p.Equipment.Owner.Id == userOwner.Id &&
                                                     p.Equipment == statement);
                foreach (var test in tests)
                {
                    somme += test.Production;
                }
                dataset3.BackgroundColor.Add("rgba(" + green + ", 137, 35, 0.6)");
                green += 20;
                dataset3.Data.Add(somme);
            }

            data3.Datasets = new List <Dataset> {
                dataset3
            };

            chart3.Data = data3;

            ViewData["chart3"] = chart3;
            #endregion
            return(View(userOwner));
        }
        private static Chart GenerateTempChart()
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Line;

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

            List <DateTime> labels = GetTempForecast().Select(e => e.dt).ToList();

            List <string> shortLabels = labels.ConvertAll(x => x.ToString("ddd HH mm"));

            data.Labels = shortLabels;


            LineDataset dataset = new LineDataset()
            {
                Label            = "Temperature",
                Data             = GetTempForecast().Select(e => e.temperatureC).ToList(),
                LineTension      = 0.5,
                BackgroundColor  = "rgba(75, 192, 192, 0)",
                BorderColor      = "rgba(244, 66, 66, 1)",
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <string>()
                {
                    "rgba(244, 66, 66, 1)"
                },
                PointBackgroundColor = new List <string>()
                {
                    "#fff"
                },
                PointBorderWidth = new List <int> {
                    3
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <string>()
                {
                    "rgba(244, 66, 66, 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);


            Options options = new Options()
            {
                Scales = new Scales(),

                Legend = new Legend()
                {
                    Labels = new LegendLabel()
                    {
                        BoxWidth = 0,
                        FontSize = 18
                    }
                }
            };

            Scales scale = new Scales()
            {
            };

            TimeScale xAxes = new TimeScale()
            {
                Ticks = new Tick()
            };

            Tick tick = new Tick()
            {
                FontColor = "rgba(244, 66, 66, 1)"
            };


            CartesianScale yAxes = new CartesianScale()
            {
                Ticks = new CartesianLinearTick()
                {
                    Max         = 50,
                    BeginAtZero = true,
                    Callback    = "function(value, index, values) {return value + ' °C' }"
                }
            };

            xAxes.Ticks = tick;
            scale.YAxes = new List <Scale>()
            {
                yAxes
            };
            scale.XAxes = new List <Scale>()
            {
                xAxes
            };

            options.Scales = scale;
            chart.Options  = options;

            chart.Data = data;

            return(chart);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     this.groupBox1 = new System.Windows.Forms.GroupBox();
     this.outputLabel = new System.Windows.Forms.Label();
     this.label1 = new System.Windows.Forms.Label();
     this.lineTextbox = new System.Windows.Forms.TextBox();
     this.addLineButton = new System.Windows.Forms.Button();
     this.groupBox2 = new System.Windows.Forms.GroupBox();
     this.outputLabelStation = new System.Windows.Forms.Label();
     this.stationTextbox = new System.Windows.Forms.TextBox();
     this.label2 = new System.Windows.Forms.Label();
     this.addStationButton = new System.Windows.Forms.Button();
     this.groupBox3 = new System.Windows.Forms.GroupBox();
     this.deleteStationButton = new System.Windows.Forms.Button();
     this.updateStationTextBox = new System.Windows.Forms.TextBox();
     this.updateStationbutton = new System.Windows.Forms.Button();
     this.stationGridView = new System.Windows.Forms.DataGridView();
     this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.stationBindingSource = new System.Windows.Forms.BindingSource(this.components);
     this.stationDataSet = new Coursework.DatabaseDataSet();
     this.groupBox4 = new System.Windows.Forms.GroupBox();
     this.deleteLineButton = new System.Windows.Forms.Button();
     this.updateLineTextBox = new System.Windows.Forms.TextBox();
     this.updateLineButton = new System.Windows.Forms.Button();
     this.lineDataGridView = new System.Windows.Forms.DataGridView();
     this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.lineBindingSource = new System.Windows.Forms.BindingSource(this.components);
     this.lineDataset = new Coursework.LineDataset();
     this.groupBox1.SuspendLayout();
     this.groupBox2.SuspendLayout();
     this.groupBox3.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.stationGridView)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.stationBindingSource)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.stationDataSet)).BeginInit();
     this.groupBox4.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.lineDataGridView)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.lineBindingSource)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.lineDataset)).BeginInit();
     this.SuspendLayout();
     //
     // groupBox1
     //
     this.groupBox1.Controls.Add(this.outputLabel);
     this.groupBox1.Controls.Add(this.label1);
     this.groupBox1.Controls.Add(this.lineTextbox);
     this.groupBox1.Controls.Add(this.addLineButton);
     this.groupBox1.Location = new System.Drawing.Point(16, 15);
     this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
     this.groupBox1.Name = "groupBox1";
     this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
     this.groupBox1.Size = new System.Drawing.Size(355, 156);
     this.groupBox1.TabIndex = 0;
     this.groupBox1.TabStop = false;
     this.groupBox1.Text = "Add Train Line";
     //
     // outputLabel
     //
     this.outputLabel.AutoSize = true;
     this.outputLabel.Location = new System.Drawing.Point(8, 111);
     this.outputLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
     this.outputLabel.Name = "outputLabel";
     this.outputLabel.Size = new System.Drawing.Size(0, 17);
     this.outputLabel.TabIndex = 5;
     //
     // label1
     //
     this.label1.AutoSize = true;
     this.label1.Location = new System.Drawing.Point(8, 46);
     this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
     this.label1.Name = "label1";
     this.label1.Size = new System.Drawing.Size(72, 17);
     this.label1.TabIndex = 4;
     this.label1.Text = "Train Line";
     //
     // lineTextbox
     //
     this.lineTextbox.Location = new System.Drawing.Point(12, 65);
     this.lineTextbox.Margin = new System.Windows.Forms.Padding(4);
     this.lineTextbox.Name = "lineTextbox";
     this.lineTextbox.Size = new System.Drawing.Size(211, 22);
     this.lineTextbox.TabIndex = 3;
     //
     // addLineButton
     //
     this.addLineButton.AutoSize = true;
     this.addLineButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     this.addLineButton.Location = new System.Drawing.Point(232, 65);
     this.addLineButton.Margin = new System.Windows.Forms.Padding(4);
     this.addLineButton.Name = "addLineButton";
     this.addLineButton.Size = new System.Drawing.Size(111, 27);
     this.addLineButton.TabIndex = 2;
     this.addLineButton.Text = "Add Train Line";
     this.addLineButton.UseVisualStyleBackColor = true;
     this.addLineButton.Click += new System.EventHandler(this.addLineButton_Click);
     //
     // groupBox2
     //
     this.groupBox2.Controls.Add(this.outputLabelStation);
     this.groupBox2.Controls.Add(this.stationTextbox);
     this.groupBox2.Controls.Add(this.label2);
     this.groupBox2.Controls.Add(this.addStationButton);
     this.groupBox2.Location = new System.Drawing.Point(379, 15);
     this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
     this.groupBox2.Name = "groupBox2";
     this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
     this.groupBox2.Size = new System.Drawing.Size(355, 156);
     this.groupBox2.TabIndex = 1;
     this.groupBox2.TabStop = false;
     this.groupBox2.Text = "Add Train Station";
     //
     // outputLabelStation
     //
     this.outputLabelStation.AutoSize = true;
     this.outputLabelStation.Location = new System.Drawing.Point(8, 111);
     this.outputLabelStation.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
     this.outputLabelStation.Name = "outputLabelStation";
     this.outputLabelStation.Size = new System.Drawing.Size(0, 17);
     this.outputLabelStation.TabIndex = 6;
     //
     // stationTextbox
     //
     this.stationTextbox.Location = new System.Drawing.Point(8, 69);
     this.stationTextbox.Margin = new System.Windows.Forms.Padding(4);
     this.stationTextbox.Name = "stationTextbox";
     this.stationTextbox.Size = new System.Drawing.Size(197, 22);
     this.stationTextbox.TabIndex = 5;
     //
     // label2
     //
     this.label2.AutoSize = true;
     this.label2.Location = new System.Drawing.Point(8, 49);
     this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
     this.label2.Name = "label2";
     this.label2.Size = new System.Drawing.Size(89, 17);
     this.label2.TabIndex = 5;
     this.label2.Text = "Train Station";
     //
     // addStationButton
     //
     this.addStationButton.AutoSize = true;
     this.addStationButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     this.addStationButton.Location = new System.Drawing.Point(215, 69);
     this.addStationButton.Margin = new System.Windows.Forms.Padding(4);
     this.addStationButton.Name = "addStationButton";
     this.addStationButton.Size = new System.Drawing.Size(128, 27);
     this.addStationButton.TabIndex = 3;
     this.addStationButton.Text = "Add Train Station";
     this.addStationButton.UseVisualStyleBackColor = true;
     this.addStationButton.Click += new System.EventHandler(this.addStationButton_Click);
     //
     // groupBox3
     //
     this.groupBox3.Controls.Add(this.deleteStationButton);
     this.groupBox3.Controls.Add(this.updateStationTextBox);
     this.groupBox3.Controls.Add(this.updateStationbutton);
     this.groupBox3.Controls.Add(this.stationGridView);
     this.groupBox3.Location = new System.Drawing.Point(379, 178);
     this.groupBox3.Margin = new System.Windows.Forms.Padding(4);
     this.groupBox3.Name = "groupBox3";
     this.groupBox3.Padding = new System.Windows.Forms.Padding(4);
     this.groupBox3.Size = new System.Drawing.Size(355, 289);
     this.groupBox3.TabIndex = 2;
     this.groupBox3.TabStop = false;
     this.groupBox3.Text = "Edit / Delete Stations";
     //
     // deleteStationButton
     //
     this.deleteStationButton.Location = new System.Drawing.Point(116, 253);
     this.deleteStationButton.Margin = new System.Windows.Forms.Padding(4);
     this.deleteStationButton.Name = "deleteStationButton";
     this.deleteStationButton.Size = new System.Drawing.Size(100, 28);
     this.deleteStationButton.TabIndex = 8;
     this.deleteStationButton.Text = "Delete";
     this.deleteStationButton.UseVisualStyleBackColor = true;
     this.deleteStationButton.Click += new System.EventHandler(this.deleteStationButton_Click);
     //
     // updateStationTextBox
     //
     this.updateStationTextBox.Location = new System.Drawing.Point(8, 223);
     this.updateStationTextBox.Margin = new System.Windows.Forms.Padding(4);
     this.updateStationTextBox.Name = "updateStationTextBox";
     this.updateStationTextBox.Size = new System.Drawing.Size(211, 22);
     this.updateStationTextBox.TabIndex = 7;
     //
     // updateStationbutton
     //
     this.updateStationbutton.Location = new System.Drawing.Point(8, 253);
     this.updateStationbutton.Margin = new System.Windows.Forms.Padding(4);
     this.updateStationbutton.Name = "updateStationbutton";
     this.updateStationbutton.Size = new System.Drawing.Size(100, 28);
     this.updateStationbutton.TabIndex = 2;
     this.updateStationbutton.Text = "Update";
     this.updateStationbutton.UseVisualStyleBackColor = true;
     this.updateStationbutton.Click += new System.EventHandler(this.updateStationbutton_Click);
     //
     // stationGridView
     //
     this.stationGridView.AutoGenerateColumns = false;
     this.stationGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
     this.stationGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
     this.idDataGridViewTextBoxColumn,
     this.nameDataGridViewTextBoxColumn});
     this.stationGridView.DataSource = this.stationBindingSource;
     this.stationGridView.Location = new System.Drawing.Point(9, 25);
     this.stationGridView.Margin = new System.Windows.Forms.Padding(4);
     this.stationGridView.Name = "stationGridView";
     this.stationGridView.ReadOnly = true;
     this.stationGridView.Size = new System.Drawing.Size(323, 185);
     this.stationGridView.TabIndex = 0;
     this.stationGridView.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.stationGridView_RowHeaderMouseClick);
     //
     // idDataGridViewTextBoxColumn
     //
     this.idDataGridViewTextBoxColumn.DataPropertyName = "Id";
     this.idDataGridViewTextBoxColumn.HeaderText = "Id";
     this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn";
     this.idDataGridViewTextBoxColumn.ReadOnly = true;
     //
     // nameDataGridViewTextBoxColumn
     //
     this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name";
     this.nameDataGridViewTextBoxColumn.HeaderText = "Name";
     this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
     this.nameDataGridViewTextBoxColumn.ReadOnly = true;
     //
     // stationBindingSource
     //
     this.stationBindingSource.DataMember = "Station";
     this.stationBindingSource.DataSource = this.stationDataSet;
     //
     // stationDataSet
     //
     this.stationDataSet.DataSetName = "StationDataSet";
     this.stationDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     //
     // groupBox4
     //
     this.groupBox4.Controls.Add(this.deleteLineButton);
     this.groupBox4.Controls.Add(this.updateLineTextBox);
     this.groupBox4.Controls.Add(this.updateLineButton);
     this.groupBox4.Controls.Add(this.lineDataGridView);
     this.groupBox4.Location = new System.Drawing.Point(16, 178);
     this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
     this.groupBox4.Name = "groupBox4";
     this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
     this.groupBox4.Size = new System.Drawing.Size(355, 289);
     this.groupBox4.TabIndex = 3;
     this.groupBox4.TabStop = false;
     this.groupBox4.Text = "Edit / Delete Line";
     //
     // deleteLineButton
     //
     this.deleteLineButton.Location = new System.Drawing.Point(116, 253);
     this.deleteLineButton.Margin = new System.Windows.Forms.Padding(4);
     this.deleteLineButton.Name = "deleteLineButton";
     this.deleteLineButton.Size = new System.Drawing.Size(100, 28);
     this.deleteLineButton.TabIndex = 7;
     this.deleteLineButton.Text = "Delete";
     this.deleteLineButton.UseVisualStyleBackColor = true;
     this.deleteLineButton.Click += new System.EventHandler(this.deleteLineButton_Click);
     //
     // updateLineTextBox
     //
     this.updateLineTextBox.Location = new System.Drawing.Point(8, 223);
     this.updateLineTextBox.Margin = new System.Windows.Forms.Padding(4);
     this.updateLineTextBox.Name = "updateLineTextBox";
     this.updateLineTextBox.Size = new System.Drawing.Size(211, 22);
     this.updateLineTextBox.TabIndex = 6;
     //
     // updateLineButton
     //
     this.updateLineButton.Location = new System.Drawing.Point(8, 253);
     this.updateLineButton.Margin = new System.Windows.Forms.Padding(4);
     this.updateLineButton.Name = "updateLineButton";
     this.updateLineButton.Size = new System.Drawing.Size(100, 28);
     this.updateLineButton.TabIndex = 1;
     this.updateLineButton.Text = "Update";
     this.updateLineButton.UseVisualStyleBackColor = true;
     this.updateLineButton.Click += new System.EventHandler(this.updateLineButton_Click);
     //
     // lineDataGridView
     //
     this.lineDataGridView.AutoGenerateColumns = false;
     this.lineDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
     this.lineDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
     this.dataGridViewTextBoxColumn1,
     this.dataGridViewTextBoxColumn2});
     this.lineDataGridView.DataSource = this.lineBindingSource;
     this.lineDataGridView.Location = new System.Drawing.Point(8, 25);
     this.lineDataGridView.Margin = new System.Windows.Forms.Padding(4);
     this.lineDataGridView.Name = "lineDataGridView";
     this.lineDataGridView.ReadOnly = true;
     this.lineDataGridView.Size = new System.Drawing.Size(323, 185);
     this.lineDataGridView.TabIndex = 0;
     this.lineDataGridView.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.lineDataGridView_RowHeaderMouseClick);
     //
     // dataGridViewTextBoxColumn1
     //
     this.dataGridViewTextBoxColumn1.DataPropertyName = "Id";
     this.dataGridViewTextBoxColumn1.HeaderText = "Id";
     this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
     this.dataGridViewTextBoxColumn1.ReadOnly = true;
     //
     // dataGridViewTextBoxColumn2
     //
     this.dataGridViewTextBoxColumn2.DataPropertyName = "Name";
     this.dataGridViewTextBoxColumn2.HeaderText = "Name";
     this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
     this.dataGridViewTextBoxColumn2.ReadOnly = true;
     //
     // lineBindingSource
     //
     this.lineBindingSource.DataMember = "Line";
     this.lineBindingSource.DataSource = this.lineDataset;
     //
     // lineDataset
     //
     this.lineDataset.DataSetName = "LineDataset";
     this.lineDataset.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
     //
     // AddLineandStation
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize = new System.Drawing.Size(756, 488);
     this.Controls.Add(this.groupBox4);
     this.Controls.Add(this.groupBox3);
     this.Controls.Add(this.groupBox2);
     this.Controls.Add(this.groupBox1);
     this.Margin = new System.Windows.Forms.Padding(4);
     this.Name = "AddLineandStation";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text = "AddLineandStation";
     this.Load += new System.EventHandler(this.AddLineandStation_Load);
     this.groupBox1.ResumeLayout(false);
     this.groupBox1.PerformLayout();
     this.groupBox2.ResumeLayout(false);
     this.groupBox2.PerformLayout();
     this.groupBox3.ResumeLayout(false);
     this.groupBox3.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this.stationGridView)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.stationBindingSource)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.stationDataSet)).EndInit();
     this.groupBox4.ResumeLayout(false);
     this.groupBox4.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this.lineDataGridView)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.lineBindingSource)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.lineDataset)).EndInit();
     this.ResumeLayout(false);
 }
        public Chart TempChart()
        {
            var chart = new Chart();

            chart.Type = Enums.ChartType.Line;

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

            data.Labels = new List <string>(CityTemperatures.Keys);

            var dataset1 = new LineDataset()
            {
                Label            = "Temperatures",
                Data             = CityTemperatures.Values.ToList(),
                Fill             = "true",
                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
            };

            var dataset2 = new LineDataset()
            {
                Label           = "Median",
                Data            = _medianTemps,
                Fill            = "false",
                LineTension     = 0.1,
                BackgroundColor = "rgba(0, 0, 0, 0.4)",
                BorderColor     = "rgba(0,0,0,1)",
                BorderCapStyle  = "butt",
                PointRadius     = new List <int> {
                    0
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };


            data.Datasets = new List <Dataset> {
                dataset1, dataset2
            };
            chart.Data = data;

            var options = new BarOptions()
            {
                Scales        = new Scales(),
                BarPercentage = 0.7
            };

            var scales = new Scales()
            {
                YAxes = new List <Scale>()
                {
                    new CartesianScale()
                    {
                        Ticks = new CartesianLinearTick()
                        {
                            BeginAtZero = true
                        }
                    }
                }
            };

            options.Scales = scales;

            chart.Options = options;

            chart.Options.Layout = new Layout()
            {
                Padding = new Padding()
                {
                    PaddingObject = new PaddingObject()
                    {
                        Left  = 10,
                        Right = 12
                    }
                }
            };

            return(chart);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Retourne le graphique intégré à l'espace administrauter: nombre de nouvelles notes par mois
        /// </summary>
        /// <param name="nbMonths">Nombre de mois avant celui en cours</param>
        /// <param name="Notes">Liste de notes</param>
        public static Chart GenerateChartNotes(int nbMonths, List <Note> Notes)
        {
            List <string>  monthLabels = new List <string>();
            List <double?> noteCounter = new List <double?>();
            DateTime       dateVar     = DateTime.Now;

            for (int i = 0; i < nbMonths; i++) // Création d'une liste de mois, contenant les n mois inférieurs à celui en cours
            {
                monthLabels.Add(dateVar.ToString("MM/yyyy"));
                dateVar = dateVar.AddMonths(-1);
            }
            monthLabels.Reverse();

            foreach (string monthY in monthLabels) // Création du set de données du graphique
            {
                int nbNotes = 0;
                foreach (Note note in Notes)
                {
                    if (note.DateCreation.Month.ToString("00") + "/" + note.DateCreation.Year.ToString("0000") == monthY)
                    {
                        nbNotes++;
                    }
                }
                noteCounter.Add(nbNotes);
            }

            Chart chart = new Chart
            {
                Type = Enums.ChartType.Line
            };

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

            LineDataset dataset = new LineDataset() // Paramètrage du graphique
            {
                Label            = "Créations",
                Data             = noteCounter,
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

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

            chart.Data = data;
            return(chart);
        }
Ejemplo n.º 19
0
        public Charter(string keyword, GraphData data, string xLabel, string yLabel, bool reverse, int min, int max)
        {
            Data = data;

            _lineConfig = new LineConfig
            {
                Options = new LineOptions
                {
                    Responsive = true,
                    Title      = new OptionsTitle
                    {
                        Display = true,
                        Text    = keyword
                    },
                    Legend = new Legend
                    {
                        Display = false
                    },
                    Tooltips = new Tooltips
                    {
                        Mode      = InteractionMode.Nearest,
                        Intersect = false
                    },
                    Scales = new Scales
                    {
                        yAxes = new List <CartesianAxis>
                        {
                            new LinearCartesianAxis
                            {
                                ScaleLabel = new ScaleLabel
                                {
                                    LabelString = yLabel
                                },
                                Ticks = new LinearCartesianTicks
                                {
                                    Reverse = reverse,
                                    Min     = min,
                                    Max     = max
                                },
                            },
                        },
                        xAxes = new List <CartesianAxis>
                        {
                            new TimeAxis
                            {
                                Distribution = TimeDistribution.Linear,
                                Ticks        = new TimeTicks
                                {
                                    Source = TickSource.Data
                                },
                                Time = new TimeOptions
                                {
                                    Unit           = TimeMeasurement.Day,
                                    Round          = TimeMeasurement.Day,
                                    TooltipFormat  = "MM.DD.YYYY",
                                    DisplayFormats = TimeDisplayFormats.DE_CH
                                },
                                ScaleLabel = new ScaleLabel
                                {
                                    LabelString = xLabel
                                }
                            }
                        }
                    },
                    Hover = new LineOptionsHover
                    {
                        Intersect = true,
                        Mode      = InteractionMode.Y
                    }
                }
            };

            _WeightDataSet = new LineDataset <TimeTuple <int> >
            {
                BackgroundColor  = ColorUtil.FromDrawingColor(System.Drawing.Color.White),
                BorderColor      = ColorUtil.FromDrawingColor(System.Drawing.Color.Red),
                Label            = yLabel,
                Fill             = false,
                BorderWidth      = 2,
                PointRadius      = 2,
                PointBorderWidth = 2,
                SteppedLine      = SteppedLine.False,
                Hidden           = false
            };

            _WeightDataSet.RemoveAll(e => true);

            //data.Shuffle();
            for (int i = 0; i < Data.Positions.Count; i++)
            {
                var pos  = Data.Positions[i];
                var date = Data.Dates[i];
                _WeightDataSet.Add(new TimeTuple <int>(new Moment(date), pos));
            }

            _lineConfig.Data.Datasets.Clear();
            _lineConfig.Data.Datasets.Add(_WeightDataSet);
            _lineChartJs.Update();
        }
Ejemplo n.º 20
0
        public IActionResult Index()
        {
            Chart chart = new Chart();

            chart.Type = Enums.ChartType.Line;

            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            data.Labels = new List <string>()
            {
                "January", "February", "March", "April", "May", "June", "July"
            };

            LineDataset dataset = new LineDataset()
            {
                Label = "My First dataset",
                Data  = new List <double>()
                {
                    65, 59, 80, 81, 56, 55, 40
                },
                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);

            chart.Data = data;

            ViewData["chart"] = chart;

            return(View());
        }
Ejemplo n.º 21
0
        public override void OnPageShown()
        {
            _logger.LogInformation("SHOWN");
            _temperatureManager.OnTemperatureChanged += OnTemperatureChangedExecute;

            ChartConfig = new LineConfig
            {
                Options = new LineOptions
                {
                    Legend = new Legend
                    {
                        Labels = new LegendLabels
                        {
                            FontColor = ColorUtil.FromDrawingColor(Color.White)
                        }
                    },
                    Responsive = true,
                    Tooltips   = new Tooltips
                    {
                        Mode      = InteractionMode.Nearest,
                        Intersect = true
                    },
                    Hover = new Hover
                    {
                        Mode      = InteractionMode.Nearest,
                        Intersect = true
                    },
                    Scales = new Scales
                    {
                        XAxes = new List <CartesianAxis>
                        {
                            new CategoryAxis
                            {
                                GridLines = new GridLines
                                {
                                    Color = ColorUtil.FromDrawingColor(Color.White)
                                },
                                Display    = AxisDisplay.False,
                                ScaleLabel = new ScaleLabel
                                {
                                    Display     = false,
                                    FontColor   = ColorUtil.FromDrawingColor(Color.White),
                                    LabelString = "Month"
                                }
                            }
                        },
                        YAxes = new List <CartesianAxis>
                        {
                            new LinearCartesianAxis
                            {
                                GridLines = new GridLines
                                {
                                    DrawTicks       = true,
                                    DrawOnChartArea = true,
                                    ZeroLineColor   = ColorUtil.FromDrawingColor(Color.White),
                                    Color           = ColorUtil.FromDrawingColor(Color.White)
                                },
                                Ticks = new LinearCartesianTicks
                                {
                                    FontColor    = ColorUtil.FromDrawingColor(Color.White),
                                    StepSize     = 20,
                                    SuggestedMin = 40
                                },
                                ScaleLabel = new ScaleLabel
                                {
                                    Display     = false,
                                    FontColor   = ColorUtil.FromDrawingColor(Color.White),
                                    LabelString = "Value"
                                }
                            }
                        }
                    }
                }
            };

            IDataset <decimal> dataset1 = new LineDataset <decimal>()
            {
                Label           = "Bed",
                BackgroundColor = ColorUtil.FromDrawingColor(ChartColors.Blue),
                BorderColor     = ColorUtil.FromDrawingColor(ChartColors.Blue),
                Fill            = FillingMode.Disabled
            };

            IDataset <decimal> dataset2 = new LineDataset <decimal>()
            {
                Label           = "Extruder",
                BackgroundColor = ColorUtil.FromDrawingColor(ChartColors.Red),
                BorderColor     = ColorUtil.FromDrawingColor(ChartColors.Red),
                Fill            = FillingMode.Disabled
            };

            //((List<string>)ChartConfig.Data.Labels).AddRange(Months.Take(InitalCount));
            ChartConfig.Data.Datasets.Add(dataset1);
            ChartConfig.Data.Datasets.Add(dataset2);
        }
Ejemplo n.º 22
0
        public async Task <JsonResult> OnPostAsync(string UserInput)
        {
            if (!string.IsNullOrEmpty(UserInput))
            {
                List <BinResult> binResults = new List <BinResult>();
                string[]         keywords   = UserInput.Split(" ").Take(5).ToArray();
                List <string>    jReturns   = new List <string>();
                foreach (string keyword in keywords)
                {
                    //    data.Labels.Add(keyword);
                    //todo add link to pastbin raw data based on binID
                    try
                    {
                        HttpAsync httpAsync = new HttpAsync();
                        string    response  = await httpAsync.Get(PsDumpUrl.Replace("#keyword#", keyword));

                        if (!string.IsNullOrEmpty(response))
                        {
                            try
                            {
                                binResults.Add(JsonConvert.DeserializeObject <BinResult>(response));
                                jReturns.Add(response);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                //Create chart
                Chart chart = new Chart();
                chart.Type = Enums.ChartType.Line;
                LineDataset lineDataset = new LineDataset();
                Data        data        = new Data();
                data.Labels   = new List <string>();
                data.Datasets = new List <Dataset>();
                foreach (BinResult binResult in binResults)
                {
                    LineDataset    dataset = new LineDataset();
                    List <double?> c       = new List <double?>();
                    foreach (var line in binResult.data.GroupBy(f => DateTime.Parse(f.Time).ToUniversalTime()
                                                                .ToString("Y", System.Globalization.CultureInfo.CreateSpecificCulture("en-US")))
                             .Select(group => new
                    {
                        xAxis = group.Key,
                        yAxis = group.Count()
                    })
                             .OrderBy(x => x.xAxis))
                    {
                        Debug.WriteLine(line.xAxis);
                        if (!data.Labels.Contains(line.xAxis))
                        {
                            data.Labels.Add(line.xAxis);
                        }

                        if (c.Count() < data.Labels.IndexOf(line.xAxis))
                        {
                            for (int i = c.Count(); i < data.Labels.IndexOf(line.xAxis); i++)
                            {
                                c.Add(0);
                            }
                        }
                        c.Insert(data.Labels.IndexOf(line.xAxis), (line.yAxis));
                        Debug.WriteLine("{0} {1} {2}", binResult.Search, line.xAxis, line.yAxis);
                    }
                    lineDataset = CreateChartDataSet(binResult.Search, c);
                    data.Datasets.Add(lineDataset);
                }
                Options options = new Options()
                {
                    Scales              = new Scales(),
                    Responsive          = true,
                    MaintainAspectRatio = true
                };

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

                CartesianScale yAxes = new CartesianScale()
                {
                    Ticks = new Tick()
                };

                Tick tick = new Tick()
                {
                    Callback = "function(value, index, values) {return '#of bins' + value;}"
                };

                yAxes.Ticks  = tick;
                scales.YAxes = new List <Scale>()
                {
                    yAxes
                };
                options.Scales = scales;
                chart.Options  = options;
                chart.Data     = data;
                return(new JsonResult(new { table = jReturns, chart = chart.CreateChartCode("lineChart") }));
            }
            return(null);
        }
Ejemplo n.º 23
0
        public static string GenerateLineChart()
        {
            Chart chart = new Chart();

            chart.Type = "line";

            Data data = new Data();

            data.Labels = new List <string>()
            {
                "January", "February", "March", "April", "May", "June", "July"
            };

            LineDataset dataset = new LineDataset()
            {
                Label = "My First dataset",
                Data  = new List <double>()
                {
                    65, 59, 80, 81, 56, 55, 40
                },
                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);

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

            Scales scales = new Scales()
            {
                YAxes = new List <Scale>()
                {
                    new CartesianScale()
                }
            };

            CartesianScale yAxes = new CartesianScale()
            {
                Ticks = new Tick()
            };

            Tick tick = new Tick()
            {
                Callback = "function(value, index, values) {return '$' + value;}"
            };

            yAxes.Ticks  = tick;
            scales.YAxes = new List <Scale>()
            {
                yAxes
            };
            options.Scales = scales;
            chart.Options  = options;

            chart.Data = data;

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

            return(code);
        }
Ejemplo n.º 24
0
        protected override void OnInitialized()
        {
            if (Day == MyChartType.Hourly)
            {
                _config = new LineConfig
                {
                    Options = new LineOptions
                    {
                        Title = new OptionsTitle
                        {
                            Display = true,
                            Text    = Title + " Last Day"
                        },
                        Responsive = true,
                        Animation  = new ArcAnimation
                        {
                            AnimateRotate = true,
                            AnimateScale  = true
                        },
                        Scales = new Scales
                        {
                            xAxes = new List <CartesianAxis>
                            {
                                new TimeAxis
                                {
                                    Distribution = TimeDistribution.Linear,
                                    Ticks        = new TimeTicks
                                    {
                                        Source  = TickSource.Auto,
                                        Reverse = true
                                    },
                                    Time = new TimeOptions
                                    {
                                        Unit           = TimeMeasurement.Hour,
                                        Round          = TimeMeasurement.Second,
                                        TooltipFormat  = "DD.MM.YYYY HH:mm:ss",
                                        DisplayFormats = TimeDisplayFormats.DE_CH
                                    },

                                    ScaleLabel = new ScaleLabel
                                    {
                                        LabelString = "Time"
                                    }
                                }
                            }
                        }
                    }
                };
            }
            else if (Day == MyChartType.Daily)
            {
                _config = new LineConfig
                {
                    Options = new LineOptions
                    {
                        Title = new OptionsTitle
                        {
                            Display = true,
                            Text    = Title + " Last 2 Weeks"
                        },
                        Responsive = true,
                        Animation  = new ArcAnimation
                        {
                            AnimateRotate = true,
                            AnimateScale  = true
                        },
                        Scales = new Scales
                        {
                            xAxes = new List <CartesianAxis>
                            {
                                new TimeAxis
                                {
                                    Distribution = TimeDistribution.Linear,
                                    Ticks        = new TimeTicks
                                    {
                                        Source  = TickSource.Auto,
                                        Reverse = true
                                    },
                                    Time = new TimeOptions
                                    {
                                        Unit           = TimeMeasurement.Day,
                                        Round          = TimeMeasurement.Hour,
                                        TooltipFormat  = "DD.MM.YYYY",
                                        DisplayFormats = TimeDisplayFormats.DE_CH
                                    },

                                    ScaleLabel = new ScaleLabel
                                    {
                                        LabelString = "Date"
                                    }
                                }
                            }
                        }
                    }
                };
            }
            else
            {
                _config = new LineConfig
                {
                    Options = new LineOptions
                    {
                        Title = new OptionsTitle
                        {
                            Display = true,
                            Text    = Title + " Monthly"
                        },
                        Responsive = true,
                        Animation  = new ArcAnimation
                        {
                            AnimateRotate = true,
                            AnimateScale  = true
                        },
                        Scales = new Scales
                        {
                            xAxes = new List <CartesianAxis>
                            {
                                new TimeAxis
                                {
                                    Distribution = TimeDistribution.Linear,
                                    Ticks        = new TimeTicks
                                    {
                                        Source  = TickSource.Auto,
                                        Reverse = true
                                    },
                                    Time = new TimeOptions
                                    {
                                        Unit           = TimeMeasurement.Month,
                                        Round          = TimeMeasurement.Day,
                                        TooltipFormat  = "DD.MM.YYYY",
                                        DisplayFormats = TimeDisplayFormats.DE_CH
                                    },

                                    ScaleLabel = new ScaleLabel
                                    {
                                        LabelString = "Date"
                                    }
                                }
                            }
                        }
                    }
                };
            }

            var Set = new LineDataset <TimeTuple <decimal> >
            {
                BackgroundColor  = ColorUtil.FromDrawingColor(Color.Blue),
                BorderColor      = ColorUtil.FromDrawingColor(Color.Blue),
                Fill             = false,
                BorderWidth      = 1,
                PointRadius      = 5,
                PointBorderWidth = 1,
                SteppedLine      = SteppedLine.False,
                ShowLine         = true,
                Label            = "Current"
            };

            var PrevSet = new LineDataset <TimeTuple <decimal> >
            {
                BackgroundColor  = ColorUtil.FromDrawingColor(Color.LightBlue),
                BorderDash       = new int[] { 10, 5 },
                BorderColor      = ColorUtil.FromDrawingColor(Color.LightBlue),
                Fill             = false,
                BorderWidth      = 1,
                PointRadius      = 3,
                PointBorderWidth = 1,
                SteppedLine      = SteppedLine.False,
                ShowLine         = true,
                Label            = "Previous"
            };

            for (int i = 0; i < Data.Count; i++)
            {
                var s      = Labels[i];
                var points = new TimeTuple <decimal>(new Moment(s), Convert.ToDecimal(Data[i]));
                Set.Add(points);
            }

            for (int i = 0; i < (Data.Count < PrevData.Count ? Data.Count : PrevData.Count); i++)
            {
                var s      = Labels[i];
                var points = new TimeTuple <decimal>(new Moment(s), Convert.ToDecimal(PrevData[i]));
                PrevSet.Add(points);
            }

            if (Labels.Count > 0)
            {
                DateTime dt = Labels.OrderByDescending(s => s.Date).FirstOrDefault();
                Set.Label = dt.ToString("yyyy-MM-dd");
                if (Day == MyChartType.Hourly)
                {
                    PrevSet.Label = dt.AddDays(-1).ToString("yyyy-MM-dd");
                }
                else if (Day == MyChartType.Daily)
                {
                    PrevSet.Label = dt.AddDays(-14).ToString("yyyy-MM-dd");
                }
                else
                {
                    PrevSet.Label  = "N/A";
                    PrevSet.Hidden = true;
                }
            }

            _config.Data.Datasets.Add(Set);
            _config.Data.Datasets.Add(PrevSet);
        }
Ejemplo n.º 25
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;
        }
        private Chart GetGoalChart(StatisticsViewModel statisticsViewModel)
        {
            Chart chart = new Chart();
            Data  data  = new Data();

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


            data.Labels = new List <string>()
            {
                "asd", "asd", "asd", "asd", "asd", "asd", "asd"
            };
            LineDataset dataset = new LineDataset()
            {
                Label = "TestChart",
                Data  = new List <double?> {
                    65, 59, 80, 81, 56, 55, 40
                },
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

            data.Datasets.Add(dataset);
            return(chart);
        }
Ejemplo n.º 27
0
        private static Chart GenerateLineChart()
        {
            var chart = new Chart {
                Type = Enums.ChartType.Line
            };

            var data = new Data
            {
                Labels = new List <string>
                {
                    "January",
                    "February",
                    "March",
                    "April",
                    "May",
                    "June",
                    "July"
                }
            };

            var dataset = new LineDataset
            {
                Label = "My First dataset",
                Data  = new List <double> {
                    65, 59, 80, 81, 56, 55, 40
                },
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };

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

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

            var scales = new Scales
            {
                YAxes = new List <Scale>
                {
                    new CartesianScale()
                }
            };

            var yAxes = new CartesianScale
            {
                Ticks = new Tick()
            };

            var tick = new Tick
            {
                Callback = "function(value, index, values) {return '$' + value;}"
            };

            yAxes.Ticks  = tick;
            scales.YAxes = new List <Scale> {
                yAxes
            };
            options.Scales = scales;
            chart.Options  = options;

            chart.Data = data;
            return(chart);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Returns a Line Chart configuration tailored for OEE Reporting
        /// </summary>
        /// <param name="machine"></param>
        /// <param name="timeSpan"></param>
        /// <returns></returns>
        public static Chart GetLineChart(List <LineChartValue> data, string title, string scaleLabel, bool displayLegend = true)
        {
            // TODO: How do I put a time series to this?

            var titleFontSize = 12;

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

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

            var chart = new Chart();

            chart.Type = Enums.ChartType.Line;
            if (data?.Count() > 0)
            {
                chart.Options = new Options()
                {
                    Responsive = true,
                    Title      = new Title()
                    {
                        Display  = !string.IsNullOrEmpty(title),
                        Text     = title,
                        FontSize = titleFontSize
                    },
                    Scales = new Scales()
                    {
                        XAxes = new List <Scale>(),
                        YAxes = new List <Scale>()
                        {
                            new CartesianScale()
                            {
                                ScaleLabel = new ScaleLabel()
                                {
                                    Display     = !string.IsNullOrEmpty(scaleLabel),
                                    LabelString = scaleLabel
                                }
                            }
                        }
                    },
                    Legend = new Legend()
                    {
                        Display = displayLegend
                    }
                };

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

                var allSeries = data.Select(x => x.Label).Distinct().ToList();
                chart.Data.Labels = data.OrderBy(a => a.XValue).Select(x => x.XValue).Distinct().ToList();
                var i = 0;
                foreach (var series in allSeries)
                {
                    var samples = new List <double?>();
                    foreach (var label in chart.Data.Labels)
                    {
                        samples.Add(data.Where(x => x.XValue.Equals(label) && x.Label.Equals(series)).Select(y => y.YValue).FirstOrDefault());
                    }

                    var linearDS = new LineDataset()
                    {
                        Label            = series,
                        Data             = samples,
                        SpanGaps         = true,
                        BackgroundColor  = ChartColor.FromHexString(_colorList[i % _colorList.Count]),
                        BorderColor      = ChartColor.FromHexString(_colorList[i % _colorList.Count]),
                        BorderWidth      = (samples.Count() > 50) ? 2 : 3,
                        BorderDashOffset = 0.0,
                        BorderJoinStyle  = "miter",
                        PointHitRadius   = new List <int> {
                            10
                        },
                        Fill        = "false",
                        ShowLine    = true,
                        PointRadius = (samples.Count() > 50) ? new List <int> {
                            0
                        } : new List <int> {
                            2
                        }
                    };
                    chart.Data.Datasets.Add(linearDS);
                    i++;
                }
            }

            return(chart);
        }
Ejemplo n.º 29
0
        public void DoAction(string action, Event eventArgs)
        {
            if (action.Equals("add"))
            {
                if (eventArgs.Contains("Label") && eventArgs.Contains("Value") && eventArgs.Contains("Timestamp"))
                {
                    dataset = new LineDataset <TimeTuple <int> >
                    {
                        BackgroundColor  = ColorUtil.RandomColorString(),
                        BorderColor      = ColorUtil.RandomColorString(),
                        Label            = eventArgs.Get("Label"),
                        Fill             = false,
                        BorderWidth      = 2,
                        PointRadius      = 3,
                        PointBorderWidth = 1,
                        SteppedLine      = SteppedLine.False
                    };
                    List <TimeTuple <int> > e = new List <TimeTuple <int> >();
                    var rand = new Random();
                    e.ToList();
                    for (int i = 0; i < 50; i++)
                    {
                        e.Add(new TimeTuple <int>(new Moment(DateTime.Now.AddSeconds(-300 * i)), rand.Next(50, 100)));
                    }
                    dataset.AddRange(e);
                    dataset.Id = eventArgs.Get("Label");
                    config.Data.Datasets.Add(dataset);
                }
            }
            if (action.Equals("replace"))
            {
                if (eventArgs.Contains("Label") && eventArgs.Contains("Value") && eventArgs.Contains("Timestamp"))
                {
                    HashSet <IMixableDataset <object> > datasets = config.Data.Datasets;
                    for (int i = 0; i < datasets.Count; i++)
                    {
                        if (datasets.ElementAt(i).Id.Equals(eventArgs.Get("Label")))
                        {
                            config.Data.Datasets.Remove(datasets.ElementAt(i));
                        }
                    }

                    dataset = new LineDataset <TimeTuple <int> >
                    {
                        BackgroundColor  = ColorUtil.RandomColorString(),
                        BorderColor      = ColorUtil.RandomColorString(),
                        Label            = eventArgs.Get("Label"),
                        Fill             = false,
                        BorderWidth      = 2,
                        PointRadius      = 3,
                        PointBorderWidth = 1,
                        SteppedLine      = SteppedLine.False
                    };
                    List <TimeTuple <int> > e = new List <TimeTuple <int> >();
                    var rand = new Random();
                    e.ToList();
                    for (int i = 0; i < 10; i++)
                    {
                        e.Add(new TimeTuple <int>(new Moment(DateTime.Now.AddSeconds(-10000 * i)), rand.Next(50, 100)));
                    }
                    dataset.AddRange(e);
                    dataset.Id = eventArgs.Get("Label");
                    config.Data.Datasets.Add(dataset);
                }
            }


            //if (action.Equals("replace"))
            //{
            //    //First remove old label and piece of cake
            //    if (eventArgs.Contains("Label"))
            //    {
            //        int index = -1;
            //        List<string> labels = config.Data.Labels;
            //        for (int i = 0; i < labels.Count; i++)
            //        {
            //            if (eventArgs.Get("Label").Equals(labels.ElementAt(i)))
            //                index = i;
            //        }

            //        if (index > -1)
            //        {
            //            config.Data.Labels.RemoveAt(index);
            //            dataset.Data.RemoveAt(index);
            //        }
            //    }

            //    //then re-add
            //    if (eventArgs.Contains("Label"))
            //        config.Data.Labels.Add(eventArgs.Get("Label"));
            //    if (eventArgs.Contains("Value"))
            //    {
            //        var dataset = config.Data.Datasets.LastOrDefault();
            //        if (dataset != null)
            //            dataset.Data.Add(Convert.ToInt32(eventArgs.Get("Value")));
            //        dataset.BackgroundColor = dataset.BackgroundColor.IndexedValues.Append(ColorUtil.RandomColorString()).ToArray();
            //    }

            //}
        }
Ejemplo n.º 30
0
        //Estadisticas y clasificacion de nivel de gastos
        public async Task <IActionResult> ExpensesAndIncomes()
        {
            //Chart instance
            Chart chart        = new Chart();
            Chart chartIncomes = new Chart();
            Chart chartBalance = new Chart();
            //Getting the user and setting the userId
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var userId = user.Id;
            //User expenses
            List <Expense> listagastos = _db.Expenses.Where(x => x.UserId == userId).ToList();
            //User profile
            List <Profile> listasalario = _db.Profiles.Where(x => x.UserId == userId).ToList();
            //User incomes
            List <Income> listaentradas = _db.Incomes.Include(x => x.IncomeSource).Where(x => x.IncomeSource.UserId == userId).ToList();

            //Setting the chart type
            chart.Type        = Enums.ChartType.Line;
            chartIncomes.Type = Enums.ChartType.Line;
            chartBalance.Type = Enums.ChartType.Line;
            //Extracting the expenses data
            List <double> total        = listagastos.Select(x => Convert.ToDouble(x.Total)).ToList();
            List <double> totalsalario = listasalario.Select(x => Convert.ToDouble(x.Salary)).ToList();
            double        salariototal = totalsalario[0];

            ViewBag.salariototal = salariototal;
            //Extracting the incomes data
            List <double> totalIncomes = listagastos.Select(x => Convert.ToDouble(x.Total)).ToList();

            List <double> totalmes = new List <double>()
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            List <double> totalEntradasMes = new List <double>()
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            List <double> totalBalance = new List <double>()
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            foreach (Expense item in listagastos)
            {
                for (int i = 0; i <= 11; i++)
                {
                    if (item.CreationDate.Month - 1 == i)
                    {
                        var elemento = totalmes.ElementAt(i);
                        elemento += Convert.ToDouble(item.Total);
                        totalmes.RemoveAt(i);
                        totalmes.Insert(i, elemento);
                    }
                }
            }
            foreach (Income item in listaentradas)
            {
                for (int i = 0; i <= 11; i++)
                {
                    if (item.CreationDate.Month - 1 == i)
                    {
                        var elemento = totalEntradasMes.ElementAt(i);
                        elemento += Convert.ToDouble(item.Total);
                        totalEntradasMes.RemoveAt(i);
                        totalEntradasMes.Insert(i, elemento);
                    }
                }
            }
            for (int i = 0; i <= 11; i++)
            {
                double monthBalance = salariototal - totalmes.ElementAt(i) - totalEntradasMes.ElementAt(i);
                totalBalance.RemoveAt(i);
                totalBalance.Insert(i, monthBalance);
            }
            int    indicemes  = DateTime.Now.Month;
            double gastototal = totalmes[indicemes - 1];
            double a          = salariototal - gastototal;
            double porcentaje = (a * 100) / salariototal;

            ViewBag.porcentaje = porcentaje;
            //Data object for expenses
            ChartJSCore.Models.Data data = new ChartJSCore.Models.Data();
            //Data object for incomes
            ChartJSCore.Models.Data dataIncomes = new ChartJSCore.Models.Data();
            //Data object for balance
            ChartJSCore.Models.Data dataBalance = new ChartJSCore.Models.Data();
            List <string>           months      = new List <string>()
            {
                "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
            };

            data.Labels        = months;
            dataIncomes.Labels = months;
            dataBalance.Labels = months;
            //Dataset for expenses chart
            LineDataset dataset = new LineDataset()
            {
                Label            = "Gastos por mes",
                Data             = totalmes,
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            //Dataset for incomes chart
            LineDataset datasetIncomes = new LineDataset()
            {
                Label            = "Entradas por mes",
                Data             = totalEntradasMes,
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                PointHoverBorderWidth = new List <int> {
                    2
                },
                PointRadius = new List <int> {
                    1
                },
                PointHitRadius = new List <int> {
                    10
                },
                SpanGaps = false
            };
            //Dataset for balance chart
            LineDataset datasetBalance = new LineDataset()
            {
                Label            = "Balance por mes",
                Data             = totalBalance,
                Fill             = "false",
                LineTension      = 0.1,
                BackgroundColor  = ChartColor.FromRgba(75, 192, 192, 0.4),
                BorderColor      = ChartColor.FromRgb(75, 192, 192),
                BorderCapStyle   = "butt",
                BorderDash       = new List <int> {
                },
                BorderDashOffset = 0.0,
                BorderJoinStyle  = "miter",
                PointBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointBackgroundColor = new List <ChartColor> {
                    ChartColor.FromHexString("#ffffff")
                },
                PointBorderWidth = new List <int> {
                    1
                },
                PointHoverRadius = new List <int> {
                    5
                },
                PointHoverBackgroundColor = new List <ChartColor> {
                    ChartColor.FromRgb(75, 192, 192)
                },
                PointHoverBorderColor = new List <ChartColor> {
                    ChartColor.FromRgb(220, 220, 220)
                },
                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);
            chart.Data = data;

            dataIncomes.Datasets = new List <Dataset>();
            dataIncomes.Datasets.Add(datasetIncomes);
            chartIncomes.Data = dataIncomes;

            dataBalance.Datasets = new List <Dataset>();
            dataBalance.Datasets.Add(datasetBalance);
            chartBalance.Data = dataBalance;

            //Sending data to the view
            ViewData["expenses"] = chart;
            ViewData["incomes"]  = chartIncomes;
            ViewData["balance"]  = chartBalance;

            return(View());
        }