public CartesianChart ClearAllChart(CartesianChart cartesianChart)
 {
     cartesianChart.Series.Clear();
     cartesianChart.AxisX.Clear();
     cartesianChart.AxisY.Clear();
     return(cartesianChart);
 }
        private void frmPrincipal_Load(object sender, EventArgs e)
        {
            lblBienvenida.Text =
                "Bienvenido " + usuario.usuario + " [" + (usuario.admin ? "Administrador" : "Usuario") + "]";

            graficoCommon = new CartesianChart();
            this.Controls.Add(graficoCommon);
            graficoCommon.Parent = tabContenedor.TabPages[5];

            numericUpDown3.Minimum = 1;

            configurarGraficoCommon();

            actualizarControlesCommon();
            actualizarTablaCommon();

            if (usuario.admin)
            {
                graficoAdmin = new CartesianChart();
                this.Controls.Add(graficoAdmin);
                graficoAdmin.Parent = tabContenedor.TabPages[3];

                configurarGraficoAdmin();
                actualizarControles();
                actualizarTablas();
            }
            else
            {
                tabContenedor.TabPages[0].Parent = null;
                tabContenedor.TabPages[0].Parent = null;
                tabContenedor.TabPages[0].Parent = null;
                tabContenedor.TabPages[0].Parent = null;
            }
        }
Ejemplo n.º 3
0
        private void configuarGrafico()
        {
            graficoFilas        = new CartesianChart();
            graficoFilas.Parent = tabControl1.TabPages[4];

            graficoFilas.Top    = 10;
            graficoFilas.Left   = 10;
            graficoFilas.Width  = graficoFilas.Parent.Width - 10;
            graficoFilas.Height = graficoFilas.Parent.Height - 10;

            graficoFilas.Series = new SeriesCollection
            {
                new RowSeries {
                    Title = "Cantidad de veces que se le ha pedido a un negocio", Values = new ChartValues <int>(), DataLabels = true
                }
            };
            graficoFilas.AxisY.Add(new Axis {
                Labels = new List <string>()
            });
            graficoFilas.AxisX.Add(new Axis {
                MaxValue = 100
            });
            graficoFilas.LegendLocation = LegendLocation.Bottom;


            foreach (Negocio negocio in NegociosConsulta.getLista())
            {
                graficoFilas.Series[0].Values.Add(negocio.idBusiness);
                graficoFilas.AxisY[0].Labels.Add(negocio.name);
            }
        }
        public CartesianChart AddSeriesToChart(CartesianChart cartesianChart, string seriesName1, string seriesName2, string seriesName3, string seriesName4, List <double> seriesArguments, List <double> seriesValues1, List <double> seriesValues2, List <double> seriesValues3, List <double> seriesValues4)
        {
            var collectionConverter = new CollectionTypeConverter();
            var values1             = collectionConverter.ConvertListToChartValuesCollection(seriesValues1);
            var values2             = collectionConverter.ConvertListToChartValuesCollection(seriesValues2);
            var values3             = collectionConverter.ConvertListToChartValuesCollection(seriesValues3);
            var values4             = collectionConverter.ConvertListToChartValuesCollection(seriesValues4);

            cartesianChart.Series = new SeriesCollection
            {
                new LineSeries(values1)
                {
                    Title  = seriesName1,
                    Values = values1
                },
                new LineSeries(values2)
                {
                    Title  = seriesName2,
                    Values = values2
                },
                new LineSeries(values3)
                {
                    Title  = seriesName3,
                    Values = values3
                },
                new LineSeries(values4)
                {
                    Title  = seriesName4,
                    Values = values4
                }
            };

            return(cartesianChart);
        }
Ejemplo n.º 5
0
        private static void ZoomChart(LiveCharts.WinForms.CartesianChart input)
        {
            input.Zoom = ZoomingOptions.X;

            //add the blank series -at least one series shown in the chart
            input.Series.Add(new LineSeries());
        }
Ejemplo n.º 6
0
        public void TotalDrivingTimePerAlgorithm()
        {
            LiveCharts.WinForms.CartesianChart cartesianChart1 = new LiveCharts.WinForms.CartesianChart();

            cartesianChart1.Series = new SeriesCollection
            {
                new RowSeries
                {
                    Title  = "Time",
                    Values = new ChartValues <double> {
                        data.GetAlgorithmsTiming()[0].TotalSeconds, data.GetAlgorithmsTiming()[1].TotalSeconds
                    }
                }
            };

            cartesianChart1.AxisY.Add(new Axis
            {
                Labels = new[] { "Dijkstra ", "A* Search" }
            });

            cartesianChart1.AxisX.Add(new Axis
            {
                LabelFormatter = value => value + " Seconds"
            });

            var tooltip = new DefaultTooltip
            {
                SelectionMode = TooltipSelectionMode.SharedYValues
            };

            cartesianChart1.DataTooltip = tooltip;
            GenerateChartLabel("Total Driving Time Per Algorithm", new Point(100, 620));
            AddChartToForm(cartesianChart1, new Point(100, 660));
        }
Ejemplo n.º 7
0
        public SingleMarkerTestView()
        {
            InitializeComponent();
            viewResultsPresentor = new VIewResultsPresentor();
            foreach (RoundedButtonToolBar btn in this.buttonPanelContainer.Controls.OfType <RoundedButtonToolBar>())
            {
                btn.BackColor = ColorConstants.toolbarButtonsColor;
                btn.FlatAppearance.BorderColor = ColorConstants.toolbarButtonsColor;
            }

            this.tabControl1.SelectedIndexChanged    += TabControl1_SelectedIndexChanged;
            this.numericUpDownColAmount.ValueChanged += NumericUpDownColAmount_ValueChanged;

            PValueChart            = this.pvalChart;
            segregationHistogram   = this.segregationChart;
            markerQualityHistogram = this.markerQualityChart;
            chiSquaredChart        = this.chiChart;


            setupComoboxForPVal();
            viewResultsPresentor.MarkerQualityHistogram(this.markerQualityHistogram);
            viewResultsPresentor.SegregationMarkerHistogram(this.segregationHistogram);
            viewResultsPresentor.ChiSquaredHistogramChart(this.chiSquaredChart);
            this.labelChartType.Text = Constants.SingleMarkerTest;
        }
Ejemplo n.º 8
0
        public void PlanedTimeAndActualTime()
        {
            LiveCharts.WinForms.CartesianChart cartesianChart1 = new LiveCharts.WinForms.CartesianChart();

            cartesianChart1.Series = new SeriesCollection
            {
                new RowSeries
                {
                    Title  = "Time",
                    Values = new ChartValues <double> {
                        data.GetPlannedTiming().TotalSeconds, data.GetActualTiming().TotalSeconds
                    }
                }
            };

            cartesianChart1.AxisY.Add(new Axis
            {
                Labels = new[] { "Planned Time ", "Actual Time" }
            });

            cartesianChart1.AxisX.Add(new Axis
            {
                LabelFormatter = value => value + " Seconds"
            });

            var tooltip = new DefaultTooltip
            {
                SelectionMode = TooltipSelectionMode.SharedYValues
            };

            cartesianChart1.DataTooltip = tooltip;
            GenerateChartLabel("Total Planned Time/ Actual Time", new Point(550, 620));
            AddChartToForm(cartesianChart1, new Point(550, 660));
        }
Ejemplo n.º 9
0
        public void PValueLogHistogram(CartesianChart chart)
        {
            int    twentyPercent      = 0;
            int    fortyPercent       = 0;
            int    sixtyPercent       = 0;
            int    eightyPercent      = 0;
            int    oneHundrerdPercent = 0;
            double popSize            = (db.SubData[0].Genotype.Length) * (db.SubData[0].TraitValue.Length) * 1.0;

            if (PValhistChart == null)
            {
                PValhistChart = new HistogramChart(chart);
            }
            PValhistChart.RemvoeColumnSeries();
            PValhistChart.AxisXTitle = "-Log(P-Value)";
            PValhistChart.AxisYTitle = "-Log(Proportion of Markers %)";


            foreach (double d in pLogValues)
            {
                if (d >= 0.0 && d < 0.2)
                {
                    twentyPercent++;
                }
                else if (d >= 0.2 && d < 0.4)
                {
                    fortyPercent++;
                }
                else if (d >= 0.4 && d < 0.6)
                {
                    sixtyPercent++;
                }
                else if (d >= 0.6 && d < 0.8)
                {
                    eightyPercent++;
                }
                else if (d >= 0.8 && d <= 1.0)
                {
                    oneHundrerdPercent++;
                }
            }


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

            pValues.Add((twentyPercent / popSize));
            pValues.Add((fortyPercent / popSize));
            pValues.Add((sixtyPercent / popSize));
            pValues.Add((eightyPercent / popSize));
            pValues.Add((oneHundrerdPercent / popSize));

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

            pTitles.Add("0-20%");
            pTitles.Add("20-40%");
            pTitles.Add("40-60%");
            pTitles.Add("60-80%");
            pTitles.Add("80-100%");
            PValhistChart.AddColumnSeries(pTitles, pValues, ColorConstants.highliteColor);
        }
Ejemplo n.º 10
0
        public void CompareNumberOfRoads(List <Report> reports)
        {
            GenerateChartLabel("Number of Roads Comparison", new Point(80, 10));

            LiveCharts.WinForms.CartesianChart cartesianChart1 = new LiveCharts.WinForms.CartesianChart();
            cartesianChart1.Series = new SeriesCollection();

            //adding series will update and animate the chart automatically
            cartesianChart1.Series.Add(new ColumnSeries
            {
                Values = reports.Select(r => r.NumberOfRoads).AsChartValues()
            });

            cartesianChart1.AxisX.Add(new Axis
            {
                Labels         = reports.Select(r => r.Name).AsChartValues(),
                LabelsRotation = 20,
                Separator      = new Separator
                {
                    Step = 1
                }
            });

            cartesianChart1.AxisY.Add(new Axis
            {
                Title = "Number of Roads",
            });

            AddChartToForm(cartesianChart1, new Point(100, 66));
        }
Ejemplo n.º 11
0
        private void changeGraphParameter(LiveCharts.WinForms.CartesianChart graph,
                                          out String paramVariable, String newParam)
        {
            try
            {
                MutGraph.WaitOne();
                paramVariable = newParam;
                graph.Series  = new SeriesCollection
                {
                    new LineSeries
                    {
                        Title          = newParam,
                        Values         = new ChartValues <Double>(OptiParams[newParam]),
                        LineSmoothness = 0
                    }
                };

                graph.Refresh();
                MutGraph.ReleaseMutex();
            }
            catch (Exception e)
            {
                paramVariable = "";
                MessageBox.Show(Properties.Resources.UnknownError + "\n" + e.Message);
            }
        }
Ejemplo n.º 12
0
        private void AddHeatChartFromFile(Panel heatpanel, IntensityData idata)
        {
            LiveCharts.WinForms.CartesianChart heatchart;
            heatchart                   = new LiveCharts.WinForms.CartesianChart();
            heatchart.Size              = new Size(heatSizeX, heatSizeY);
            heatchart.Anchor            = (AnchorStyles.Left | AnchorStyles.Right);
            heatchart.Left              = 0;
            heatchart.Top               = 50;
            heatchart.DisableAnimations = true;
            heatchart.Hoverable         = false;
            heatchart.DataTooltip       = null;

            ChartValues <HeatPoint> values = new ChartValues <HeatPoint>();
            List <HeatPoint>        buffer = new List <HeatPoint>();

            for (int i = 0; i < idata.intensityData.Count(); i++)
            {
                Backend.Model.AggregatedData agregateddata = idata.intensityData[i];
                for (int j = 0; j < agregateddata.aggregatedData.Count(); j++)
                {
                    buffer.Add(new HeatPoint(j, i, agregateddata.aggregatedData[j]));
                }
            }
            values.AddRange(buffer);
            HeatSeries hs = new HeatSeries {
                Values = values,
                GradientStopCollection = gradient
            };

            allPanelsIntensityData.Add(new Tuple <Panel, IntensityData, HeatSeries>(heatpanel, idata, hs));
            heatchart.Series.Add(hs);
            heatpanel.Controls.Add(heatchart);
        }
Ejemplo n.º 13
0
 public frmAdmin()
 {
     InitializeComponent();
     graficocolumnas = new CartesianChart();
     this.Controls.Add(graficocolumnas);
     graficocolumnas.Parent = tabControl1.TabPages[4];
 }
Ejemplo n.º 14
0
        //FirstSeries Update
        public static void UpdateFirstSeries(LiveCharts.WinForms.CartesianChart input, ComboBox combo1, ComboBox combo2, MetroDateTime startDate, MetroDateTime endDate)
        {
            //First Data Series
            if (combo1.SelectedItem == null)
            {
                return;
            }

            string ticker1 = VisualizeComboBox.GetComboBoxKey(combo1);

            var currentIndex = ProvideIndexHistoricalData.Provide(
                ticker1,
                CreateDatePicker.GetDate(startDate),
                CreateDatePicker.GetDate(endDate),
                "d");

            ChartValues1 = new ChartValues <DataPoint>(currentIndex.HistoricalData);

            //Indexer is not support. Thus, I need to remove the old Series
            input.Series.RemoveAt(0);

            input.Series.Insert(0, new LineSeries
            {
                Title           = VisualizeComboBox.GetComboBoxKey(combo1),
                Values          = ChartValues1,
                PointGeometry   = null,
                Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 174, 219)),
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromArgb(35, 0, 174, 219)),
                StrokeThickness = 2.5
            });
        }
 public ChartThread(SimulationForm SimulationForm)
 {
     this.SimulationForm = SimulationForm;
     CartesianChart      = SimulationForm.DataChart;
     Init();
     Start();
 }
        public CartesianChart FillChartwithSeries(CartesianChart cartesianChart)
        {
            cartesianChart.Series = new SeriesCollection
            {
                new LineSeries(_values)
                {
                    Title  = "E_c",
                    Values = _values
                }
            };

            cartesianChart.AxisX.Add(new Axis
            {
                Title      = "OX",
                Labels     = _arguments,
                ShowLabels = true
            });

            cartesianChart.AxisY.Add(new Axis
            {
                Title          = "OY",
                LabelFormatter = value => value.ToString("C")
            });

            cartesianChart.LegendLocation = LegendLocation.Right;

            return(cartesianChart);
        }
Ejemplo n.º 17
0
        public void HeatMapComparison(List <Report> reports)
        {
            LiveCharts.WinForms.CartesianChart cartesianChart1 = new LiveCharts.WinForms.CartesianChart();
            var labels = new string[] { "Roads", "Accidents", "Cars Entered", "Cars Left", "Pedestrians Entered", "Pedestrians Left",
                                        "Dijkstra", "A* Search" };
            ChartValues <HeatPoint> values = new ChartValues <HeatPoint>();

            for (int i = 0; i < reports.Count; i++)
            {
                int dijkstra = 0;
                int aStar    = 0;
                if (reports[i].SPA.Equals("Dijkstra"))
                {
                    dijkstra++;
                }
                else
                {
                    aStar++;
                }
                values.Add(new HeatPoint(i, 0, reports[i].NumberOfRoads));
                values.Add(new HeatPoint(i, 1, reports[i].Accidents));
                values.Add(new HeatPoint(i, 2, reports[i].CarsEntered));
                values.Add(new HeatPoint(i, 3, reports[i].CarsLeft));
                values.Add(new HeatPoint(i, 4, reports[i].PedestriansEntered));
                values.Add(new HeatPoint(i, 5, reports[i].PedestriansLeft));
                values.Add(new HeatPoint(i, 6, dijkstra));
                values.Add(new HeatPoint(i, 7, aStar));
            }
            cartesianChart1.Series.Add(new HeatSeries
            {
                Values                 = values,
                DataLabels             = true,
                GradientStopCollection = new GradientStopCollection
                {
                    new GradientStop(System.Windows.Media.Color.FromRgb(237, 192, 102), 0),
                    new GradientStop(System.Windows.Media.Color.FromRgb(245, 191, 83), 0.10),
                    new GradientStop(System.Windows.Media.Color.FromRgb(237, 167, 26), .5),
                    new GradientStop(System.Windows.Media.Color.FromRgb(191, 132, 11), .75),
                    new GradientStop(System.Windows.Media.Color.FromRgb(143, 99, 9), 1)
                }
            });
            cartesianChart1.AxisX.Add(new Axis
            {
                LabelsRotation = -15,
                Labels         = reports.Select(r => r.Name).AsChartValues(),
                Separator      = new Separator {
                    Step = 1
                },
            });

            cartesianChart1.AxisY.Add(new Axis
            {
                Labels = labels.AsChartValues()
            });
            GenerateChartLabel("Distrubutions Per Report", new Point(960, 340));
            AddHeatMapToForm(cartesianChart1, new Point(900, 420));
        }
Ejemplo n.º 18
0
        private void UpdateDailyChart(List <IStockPrice> data)
        {
            splitContainer.Panel2.Controls.Clear();

            if (data != null && data.Any())
            {
                var dayConfig = Mappers.Xy <ChartModel>()
                                .X(dayModel => (double)dayModel.DateTime.Ticks / TimeSpan.FromSeconds(1).Ticks)
                                .Y(dayModel => dayModel.Value);

                CartesianChart           chart   = new CartesianChart();
                ChartValues <ChartModel> average = new ChartValues <ChartModel>();
                ChartValues <ChartModel> volume  = new ChartValues <ChartModel>();

                ChartValues <ChartModel> open  = new ChartValues <ChartModel>();
                ChartValues <ChartModel> close = new ChartValues <ChartModel>();

                foreach (var item in data)
                {
                    average.Add(new ChartModel(item.Date, item.Min + (item.Max - item.Min) / 2));
                    open.Add(new ChartModel(item.Date, item.Open));
                    close.Add(new ChartModel(item.Date, item.Close));
                    volume.Add(new ChartModel(item.Date, item.Volume));
                }

                _openSerie.Values    = open;
                _closeSerie.Values   = close;
                _averageSerie.Values = average;
                //_volumeSerie.Values = volume;

                chart.Series = new SeriesCollection(dayConfig)
                {
                    _openSerie, _closeSerie, _averageSerie,
                    //_volumeSerie,
                };

                chart.AxisX.Add(new Axis
                {
                    LabelFormatter = DateLabelFormaterDailyX,
                });

                chart.AxisY.Add(new Axis
                {
                    LabelFormatter = DateLabelFormaterDailyY,
                });

                chart.LegendLocation = LegendLocation.Right;

                splitContainer.Panel2.Controls.Add(chart);
                chart.Dock = DockStyle.Fill;
                chart.Zoom = ZoomingOptions.Xy;
                chart.Pan  = PanningOptions.Xy;

                chart.ContextMenuStrip = chartContextMenu;
            }
        }
Ejemplo n.º 19
0
        public frmPrincipal(Appuser u)
        {
            InitializeComponent();
            user = u;

            //inicializar grafico
            graficoProductos = new CartesianChart();
            this.Controls.Add(graficoProductos);
            graficoProductos.Parent = tabControl1.TabPages[3];
        }
Ejemplo n.º 20
0
        public void CompareAlgorithmsTiming(List <Report> reports)
        {
            GenerateChartLabel("Algorithms Timing Comparison", new Point(100, 620));

            LiveCharts.WinForms.CartesianChart cartesianChart1 = new LiveCharts.WinForms.CartesianChart();
            cartesianChart1.Series = new SeriesCollection();

            cartesianChart1.LegendLocation = LegendLocation.Bottom;

            List <double> dijkstraTimings = new List <double>(reports.Count);
            List <double> aStarTimings    = new List <double>(reports.Count);

            reports.ForEach(r =>
            {
                if (r.SPA.Equals("Dijkstra"))
                {
                    dijkstraTimings.Add(r.EADrivingTime.TotalSeconds);
                    aStarTimings.Add(0);
                }
                else
                {
                    aStarTimings.Add(r.EADrivingTime.TotalSeconds);
                    dijkstraTimings.Add(0);
                }
            });
            cartesianChart1.Series.Add(new ColumnSeries
            {
                Title  = "Dijkstra",
                Values = dijkstraTimings.AsChartValues(),
            });
            cartesianChart1.Series.Add(new ColumnSeries
            {
                Title  = "A* Search",
                Values = aStarTimings.AsChartValues()
            });

            cartesianChart1.AxisX.Add(new Axis
            {
                Title          = "Report Name",
                Labels         = reports.Select(r => r.Name).AsChartValues(),
                LabelsRotation = 20,
                Separator      = new Separator
                {
                    Step = 1
                }
            });

            cartesianChart1.AxisY.Add(new Axis
            {
                Title          = "Emergency Car Driving Time",
                LabelFormatter = val => val + " Seconds"
            });

            AddChartToForm(cartesianChart1, new Point(100, 660));
        }
Ejemplo n.º 21
0
 public frmPrincipal(AppUser pUser)
 {
     InitializeComponent();
     user = pUser;
     if (!user.userType)
     {
         graficoEstadisticas = new CartesianChart();
         this.Controls.Add(graficoEstadisticas);
         graficoEstadisticas.Parent = tabControl1.TabPages[6];
     }
 }
Ejemplo n.º 22
0
        public static void ClearChart(LiveCharts.WinForms.CartesianChart barChart, LiveCharts.WinForms.PieChart pieChart)
        {
            pieChart.Series.Clear();
            pieChart.AxisY.Clear();
            pieChart.AxisX.Clear();
            pieChart.Refresh();

            barChart.Series.Clear();
            barChart.AxisY.Clear();
            barChart.AxisX.Clear();
            barChart.Refresh();
        }
Ejemplo n.º 23
0
        private void btnWeightCharts_Click(object sender, EventArgs e)
        {
            var copy = new List <Layer>();

            copy.AddRange(NetworkController.Network.Layers);
            WeightChart wc = new WeightChart();

            int    row = 0;
            int    col = 0;
            Random rnd = new Random();

            foreach (Layer l in copy)
            {
                row = 0;
                foreach (Perceptron p in l.Layer_Neurons)
                {
                    LiveCharts.WinForms.CartesianChart chart = new LiveCharts.WinForms.CartesianChart();

                    chart.Location  = new Point(50 + 170 * col, 50 + 100 * row);
                    chart.Size      = new Size(150, 75);
                    chart.BackColor = Color.LightGray;

                    for (int i = 0; i < p.Weights.Length; i++)  //Go through different weights by index (weight#1, weight#2...) in the same perceptron, weight is the number of connections
                    {
                        //Create a new series, representing the current weight that is being looked at
                        chart.Series.Add(new LineSeries
                        {
                            Values          = new ChartValues <double> {
                            },
                            StrokeThickness = 1,
                            StrokeDashArray = new System.Windows.Media.DoubleCollection(20),
                            Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)(rnd.Next(0, 255)), (byte)(rnd.Next(0, 255)), (byte)(rnd.Next(0, 255)))),
                            Fill            = System.Windows.Media.Brushes.Transparent,
                            LineSmoothness  = 1,
                            PointGeometry   = null,
                        });

                        foreach (double[] w in p.WeightChangeHistogram.Skip(p.WeightHistogram.Count - 50).Take(50))   //Go through weight changes over time of the current perceptron
                        {
                            //var currentweight = w[i];
                            //add the weight of the current connection from the histogram
                            chart.Series[i].Values.Add((double)(w[i])); //Goes through every registered weight in the histogram, pulls out the given index
                        }
                    }

                    wc.Controls.Add(chart);
                    row++;
                }
                col++;
            }

            wc.Show();
        }
Ejemplo n.º 24
0
 private void AddHeatMapToForm(LiveCharts.WinForms.CartesianChart chart, Point location)
 {
     chart.Location  = location;
     chart.AutoSize  = false;
     chart.Size      = new Size(570, 480);
     chart.BackColor = System.Drawing.Color.Transparent;
     chart.Parent    = graphsPanel;
     graphsPanel.SendToBack();
     chart.BackgroundImageLayout = ImageLayout.None;
     graphsPanel.Controls.Add(chart);
     chart.BringToFront();
 }
Ejemplo n.º 25
0
        public Chart(ref LiveCharts.WinForms.CartesianChart chart)
        {
            chart.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Values = chartValues
                }
            };

            _chart = chart;
        }
Ejemplo n.º 26
0
        public frmPrincipal(Usuario pUsuario)
        {
            InitializeComponent();
            usuario = pUsuario;

            if (usuario.userType)
            {
                graficoEstadisticas = new CartesianChart();
                this.Controls.Add(graficoEstadisticas);
                graficoEstadisticas.Parent = tabControl1.TabPages[8];
            }
        }
Ejemplo n.º 27
0
        public void drawChart(LiveCharts.WinForms.CartesianChart chart, XmlNodeList nodeList)
        {
            ChartValues <DateModel> values = new ChartValues <DateModel>();

            var dayConfig = Mappers.Xy <DateModel>()
                            .X(dayModel => (double)dayModel.DateTime.Ticks / TimeSpan.FromHours(1).Ticks)
                            .Y(dayModel => dayModel.Value);

            foreach (XmlNode node in nodeList)
            {
                Console.WriteLine("Test" + node["TimeStamp"].InnerText);
                DateModel dateModel = new DateModel();
                dateModel.DateTime = UnixTimeStampToDateTime(long.Parse(node["TimeStamp"].InnerText));
                dateModel.Value    = double.Parse(node["Value"].InnerText, System.Globalization.CultureInfo.InvariantCulture);
                values.Add(dateModel);
            }

            chart.Series = new SeriesCollection(dayConfig)
            {
                new LineSeries
                {
                    Values            = values,
                    PointGeometrySize = 18,
                    StrokeThickness   = 4,
                    DataLabels        = false
                }
            };

            chart.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49));


            chart.AxisY = new AxesCollection
            {
                new Axis
                {
                    IsMerged  = false,
                    Separator = new Separator
                    {
                        StrokeThickness = 1,
                        StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 10 }),
                        Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86))
                    }
                }
            };

            chart.AxisX = new AxesCollection
            {
                new Axis
                {
                    LabelFormatter = value => "Day: " + new System.DateTime((long)(value * TimeSpan.FromHours(1).Ticks)).ToString("dd HH:mm:ss")
                }
            };
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            lblWelcome.Text =
                "Welcome " + user.username + " [" + (user.userType ? "Administrator" : "Normal user") + "]";

            graficoDemanda = new CartesianChart();
            this.Controls.Add(graficoDemanda);
            graficoDemanda.Parent = tabControl1.TabPages[4];
            configurarGrafico();

            updateAdminControls();
        }
        public CartesianChart AddSeriesToExistingChart(CartesianChart cartesianChart, string seriesName, List <double> seriesToAdd)
        {
            var collectionConverter = new CollectionTypeConverter();
            var values1             = collectionConverter.ConvertListToChartValuesCollection(seriesToAdd);
            var newSeries           = new LineSeries(values1)
            {
                Title  = seriesName,
                Values = values1
            };

            cartesianChart.Series.Add(newSeries);
            return(cartesianChart);
        }
Ejemplo n.º 30
0
        public void AddBarChart(string header, IEnumerable <string> headers, IEnumerable <double> values)
        {
            IChartValues value = new ChartValues <double>();

            foreach (var i in values)
            {
                value.Add(i);
            }

            var ctrl = new LiveCharts.WinForms.CartesianChart
            {
                Location          = new Point(96, 46),
                Size              = new Size(200, 100),
                DataTooltip       = null,
                DisableAnimations = true,
                Tag    = CurrentPage,
                Series = new SeriesCollection
                {
                    new ColumnSeries()
                    {
                        Values = value
                    }
                },
                AxisX = new AxesCollection()
                {
                    new Axis
                    {
                        Separator = new Separator()
                        {
                            Step = 1,
                        },
                        Title  = header,
                        Labels = headers.ToArray()
                    }
                }
            };

            pnControls.Controls.Add(ctrl);

            ctrl.BackColor   = Color.Transparent;
            ctrl.MouseEnter += control_MouseEnter;
            ctrl.MouseLeave += control_MouseLeave;
            ctrl.MouseDown  += control_MouseDown;
            ctrl.MouseMove  += control_MouseMove;
            ctrl.MouseUp    += control_MouseUp;

            ctrl.BringToFront();
            SelectedControl = ctrl;
            pnControls.Invalidate();
            OnContentChanged(new EventArgs());
        }