Inheritance: ElementHost
Exemplo n.º 1
0
        /// <summary>
        /// Método para limpiar gráfico
        /// </summary>
        /// <param name="cht">Gráfico</param>
        ///
        public void limpiarGrafico(LiveCharts.WinForms.CartesianChart cht)
        {
            int cantidad = 0;

            cantidad = cht.AxisX.Count;
            if (cantidad > 0)
            {
                for (int i = 0; i < cantidad; i++)
                {
                    cht.AxisX.RemoveAt(0);
                }
            }

            cantidad = cht.AxisY.Count;
            if (cantidad > 0)
            {
                for (int i = 0; i < cantidad; i++)
                {
                    cht.AxisY.RemoveAt(0);
                }
            }

            cantidad = cht.Series.Count;
            if (cantidad > 0)
            {
                for (int i = 0; i < cantidad; i++)
                {
                    cht.Series.RemoveAt(0);
                }
            }
        }
Exemplo n.º 2
0
        public LineChart()
        {
            preference = new List <productPreference>();
            connection = new Connection_Handler();

            chart = new LiveCharts.WinForms.CartesianChart();
        }
        private static void CreatChartFromDataSets(DateTime start, DateTime end, LiveCharts.WinForms.CartesianChart chart, int resolution, List <DataTable> data, string MetricColumn, string YKey, string legendColumn, string numberFormat)
        {
            chart.Series = new SeriesCollection();
            chart.AxisX.Clear();
            chart.AxisY.Clear();
            foreach (DataTable rig in data)
            {
                if (rig.Rows.Count != 0)
                {
                    Dictionary <int, DataRow> values = new Dictionary <int, DataRow>();
                    foreach (DataRow row in rig.Rows)
                    {
                        if (!string.IsNullOrEmpty(row[MetricColumn].ToString()))
                        {
                            int key = ((int)Math.Round(double.Parse(row["Time"].ToString()) * resolution));
                            values.Add(key, row);
                        }
                    }
                    LineSeries series = new LineSeries();
                    series.Title  = rig.Rows[0][legendColumn].ToString();
                    series.Values = new ChartValues <float>();
                    for (int i = ((int)Math.Round(DateTimeHelper.GetUnixTimeStamp(start) / resolution) * resolution); i <= ((int)Math.Round(DateTimeHelper.GetUnixTimeStamp(end) / resolution) * resolution); i += resolution)
                    {
                        if (values.ContainsKey(i))
                        {
                            if (!string.IsNullOrEmpty(values[i][MetricColumn].ToString()))
                            {
                                series.Values.Add(float.Parse(values[i][MetricColumn].ToString()));
                            }
                            else
                            {
                                series.Values.Add(0f);
                            }
                        }
                        else
                        {
                            series.Values.Add(0f);
                        }
                    }
                    chart.Series.Add(series);
                }
            }
            Axis xAxis = new Axis();

            xAxis.Title  = "Date";
            xAxis.Labels = new List <string>();
            for (int i = ((int)Math.Round(DateTimeHelper.GetUnixTimeStamp(start) / resolution) * resolution); i <= ((int)Math.Round(DateTimeHelper.GetUnixTimeStamp(end) / resolution) * resolution); i += resolution)
            {
                xAxis.Labels.Add(DateTimeHelper.UnixTimeStampToDateTime(i).ToShortDateString() + " " + DateTimeHelper.UnixTimeStampToDateTime(i).ToShortTimeString());
            }
            chart.AxisX.Add(xAxis);

            chart.AxisY.Add(new Axis
            {
                Title          = YKey,
                LabelFormatter = value => value.ToString(numberFormat)
            });

            chart.LegendLocation = LegendLocation.Right;
        }
Exemplo n.º 4
0
        public Plot_LogPH(LiveCharts.WinForms.CartesianChart myChart, SharpFluids.FluidList refType)
        {
            //Settings
            MyChart = myChart;
            RefType = refType;
            Fluid Dome = new Fluid(RefType);


            //Finding the zoom on the X-axis
            Dome.UpdatePX(Dome.LimitPressureMin, 0);
            GraphHMin = Dome.Enthalpy * 0.5;
            Dome.UpdatePX(Dome.LimitPressureMin, 1);
            GraphHMax = Dome.Enthalpy * 1.4;

            //Rounds to nearest 50
            GraphHMin = SpecificEnergy.FromJoulesPerKilogram(Math.Round(GraphHMin.JoulesPerKilogram / 50) * 50);



            //Creating Y Axis
            MyChart.AxisY.Add(new LogarithmicAxis
            {
                LabelFormatter = value => (Math.Pow(10, value)).ToString("N0"),
                Base           = 10,  //Note that Max and min values are based on the 'Base = 10'!
                MaxValue       = 2.5, //2.5,
                MinValue       = 0,   //1
                Title          = "Pressure - [" + string.Format(new CultureInfo("en-US"), "{0:a}", GraphPMax.ToUnit(UnitsNet.Units.PressureUnit.Bar)) + "]",

                Separator = new Separator
                {
                    Stroke          = Brushes.LightGray,
                    Step            = Math.Log10(10) / 2,
                    StrokeThickness = 1,
                },
            });



            //Creating X Axis
            MyChart.AxisX.Add(new Axis
            {
                LabelFormatter = value => value.ToString("N0"),
                MaxValue       = GraphHMax.ToUnit(UnitsNet.Units.SpecificEnergyUnit.KilojoulePerKilogram).Value,
                MinValue       = GraphHMin.ToUnit(UnitsNet.Units.SpecificEnergyUnit.KilojoulePerKilogram).Value,
                Title          = "Enthalpy - [" + string.Format(new CultureInfo("en-US"), "{0:a}", GraphHMax.ToUnit(UnitsNet.Units.SpecificEnergyUnit.KilojoulePerKilogram)) + "]",
                Separator      = new Separator
                {
                    Stroke          = Brushes.LightGray,
                    Step            = 100,
                    StrokeThickness = 0.3,
                },
            });

            //Settings
            MyChart.DataTooltip       = null;
            MyChart.DisableAnimations = true;
            MyChart.Background        = new SolidColorBrush(Color.FromRgb(250, 250, 250));
            MyChart.Hoverable         = false;
        }
Exemplo n.º 5
0
 public LineChartXY(CartesianChart chart)
 {
     this.chart = chart;
     axisY      = new Axis();
     axisX      = new Axis();
     chart.AxisX.Add(axisX);
     chart.AxisY.Add(axisY);
     this.chart.Series = new SeriesCollection();
 }
Exemplo n.º 6
0
        public PlotXY(LiveCharts.WinForms.CartesianChart myChart)
        {
            //Settings
            MyChart = myChart;


            //Creating Y Axis
            MyChart.AxisY.Add(new Axis
            {
                LabelFormatter = value => value.ToString("N1"),
                //MaxValue = 25,
                //MinValue = 0,
                Title = "Capacity [kW]",

                Separator = new Separator
                {
                    Stroke          = Brushes.LightGray,
                    Step            = 0.5,
                    StrokeThickness = 0.3,
                },
            });



            //Creating X Axis
            MyChart.AxisX.Add(new Axis
            {
                LabelFormatter = value => value.ToString("N0"),
                //MaxValue = 2,
                //MinValue = 0,

                Title     = "MassFlow [Kgs]",
                Separator = new Separator
                {
                    Stroke          = Brushes.LightGray,
                    Step            = 5,
                    StrokeThickness = 0.3,
                },
            });

            //Settings
            MyChart.DataTooltip       = null;
            MyChart.DisableAnimations = true;
            MyChart.Background        = new SolidColorBrush(Color.FromRgb(250, 250, 250));
            MyChart.Hoverable         = false;
        }
Exemplo n.º 7
0
        public static void SetData(this LiveCharts.WinForms.CartesianChart chart, List <LineSeries> data)
        {
            data.ForEach(d => chart.Series.Add(d));

            chart.AxisX.Add(new Axis
            {
                Title  = "Jours de la semaine",
                Labels = new[] { "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim" }
            });

            chart.AxisY.Add(new Axis
            {
                Title          = "Nombre de cas",
                LabelFormatter = value => value.ToString(),
                MinValue       = 0
            });
        }
Exemplo n.º 8
0
        public HistogramChart(CartesianChart chart)
        {
            this.chart           = chart;
            this.chart.BackColor = Color.White;

            //create 2 axis
            axisY = new Axis();
            axisX = new Axis();

            axisX.Separator.Step = 1d;
            axisX.LabelsRotation = 45d;

            axisY.LabelFormatter = labelFormatter;
            //add axis to the chart
            chart.AxisX.Add(axisX);
            chart.AxisY.Add(axisY);
            //add empty serires of upcoming data
            chart.Series = new SeriesCollection();
        }
Exemplo n.º 9
0
        public static void double_paint(object obj, double[] x, double[] y, double koef = 1.0)
        {
            LiveCharts.WinForms.CartesianChart    paint_obj = obj as LiveCharts.WinForms.CartesianChart;
            LiveCharts.Defaults.ObservablePoint[] mas       = new LiveCharts.Defaults.ObservablePoint[x.Length];
            for (int i = 0; i < x.Length; i++)
            {
                mas[i] = (new LiveCharts.Defaults.ObservablePoint
                {
                    X = x[i],
                    Y = y[i] / koef
                });
            }
            var ListPoints = new ChartValues <LiveCharts.Defaults.ObservablePoint>();

            ListPoints.AddRange(mas);
            paint_obj.Series.Add(new LineSeries
            {
                Values            = ListPoints,
                PointGeometrySize = 0
            });
        }
Exemplo n.º 10
0
        public static List <double[]> ClasteringShow(LiveCharts.WinForms.CartesianChart cc, DataGridView dgv_out, int numberclass)
        {
            ClasteringM     do_clastering = new ClasteringM();
            List <double[]> output_arr    = new List <double[]>();

            do_clastering.SetValueClaster(numberclass);

            int[] outVector = do_clastering.Cluster(arr_point, numberclass);

            for (int i = 0; i < outVector.Length; i++)
            {
                double[] buffer = new double[4];
                buffer[0] = i;
                buffer[1] = arr_point[i][0];
                buffer[2] = arr_point[i][1];
                buffer[3] = outVector[i];
                output_arr.Add(buffer);
            }
            arr_vector = output_arr;
            return(output_arr);
        }
Exemplo n.º 11
0
        public static void complex_magnitude_paint_with_func(object obj, double[] x, Complex[] y, Func <double, double> f, double koef = 1.0)
        {
            LiveCharts.WinForms.CartesianChart    paint_obj = obj as LiveCharts.WinForms.CartesianChart;
            LiveCharts.Defaults.ObservablePoint[] mas       = new LiveCharts.Defaults.ObservablePoint[x.Length];
            for (int i = 0; i < x.Length; i++)
            {
                mas[i] = (new LiveCharts.Defaults.ObservablePoint
                {
                    X = x[i],
                    Y = f(y[i].Magnitude) / koef
                });
            }
            var ListPoints = new ChartValues <LiveCharts.Defaults.ObservablePoint>();

            ListPoints.AddRange(mas);
            paint_obj.Series.Add(new LineSeries
            {
                Values            = ListPoints,
                PointGeometrySize = 0
            });
        }
Exemplo n.º 12
0
        public static LiveCharts.WinForms.CartesianChart CreateGraph(int stageNumber, Dictionary <DateTime, double> PressureSeriesData, Dictionary <DateTime, double> WaterSeriesData, Dictionary <DateTime, double> SandSeriesData)
        {
            List <string> labels = new List <string>(PressureSeriesData.Keys.Select(date => date.ToString("HH:mm:ss")).ToList <string>());


            LiveCharts.WinForms.CartesianChart chart = new LiveCharts.WinForms.CartesianChart();

            chart.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Title             = "Pressure",
                    Values            = new ChartValues <double>(PressureSeriesData.Values),
                    PointGeometry     = DefaultGeometries.Square,
                    PointGeometrySize = 15,
                    PointForeground   = Brushes.Gray
                },
                new LineSeries
                {
                    Title  = "Water Rate",
                    Values = new ChartValues <double>(WaterSeriesData.Values)
                },
                new LineSeries
                {
                    Title  = "Sand Rate",
                    Values = new ChartValues <double>(SandSeriesData.Values)
                }
            };

            chart.AxisX.Add(new Axis
            {
                Title  = "Time",
                Labels = labels
            });
            chart.LegendLocation = LegendLocation.Right;

            chart.DataClick += CartesianChartOnDataClick;

            return(chart);
        }
Exemplo n.º 13
0
        public QTLPositionView()
        {
            InitializeComponent();
            VIewResultsPresentor = new VIewResultsPresentor();
            this.numericUpDownColAmount.ValueChanged += NumericUpDownColAmount_ValueChanged;
            for (int i = 0; i < amountOfChromosomes; i++)
            {
                CartesianChart cartesianChart = new CartesianChart();
                cartesianChart.Size      = new Size(670, 200);
                cartesianChart.Hoverable = false;
                this.flowLayoutPanel1.Controls.Add(cartesianChart);
                charts.Add(new LineChartXY(cartesianChart));
            }

            foreach (RoundedButtonToolBar btn in this.buttonPanelContainer.Controls.OfType <RoundedButtonToolBar>())
            {
                btn.BackColor = ColorConstants.toolbarButtonsColor;
                btn.FlatAppearance.BorderColor = ColorConstants.toolbarButtonsColor;
            }
            setupComoboxforTraitDist();
            this.labelChartType.Text = Constants.QTLPosition;
        }
Exemplo n.º 14
0
        public static void Show(DataGridView dgv, LiveCharts.WinForms.CartesianChart cc)
        {
            cc.Series.Clear();
            arr_point = new double[dgv.Rows.Count - 1][];

            ScatterSeries ss = new ScatterSeries();

            ss.Title           = "Основные данные";
            ss.PointGeometry   = DefaultGeometries.Triangle;
            ss.StrokeThickness = 2;
            ss.Fill            = Brushes.Transparent;

            ChartValues <ObservablePoint> pointvalue = new ChartValues <ObservablePoint>();

            for (int i = 0; i < dgv.Rows.Count - 1; i++)
            {
                arr_point[i] = new double[] { Convert.ToDouble(dgv.Rows[i].Cells[1].Value), Convert.ToDouble(dgv.Rows[i].Cells[2].Value) };
                pointvalue.Add(new ObservablePoint(Convert.ToDouble(dgv.Rows[i].Cells[1].Value), Convert.ToDouble(dgv.Rows[i].Cells[2].Value)));
            }
            ss.Values = pointvalue;
            cc.Series.Add(ss);
        }
        public static void DrawPoziomOdpaduChart()
        {
            if (DataContainer.guiState == null)
            {
                return;
            }


            LiveCharts.WinForms.CartesianChart poziomOdpaduChart = DataContainer.poziomOdpaduChart;

            poziomOdpaduChart.Series.Clear();
            poziomOdpaduChart.AxisX.Clear();
            poziomOdpaduChart.AxisY.Clear();

            var finishedOrders = DataContainer.sqlDataByOrder.Where(order => order.Value.kitting.endDate >= DataContainer.guiState.viTabs.poziomOdpaduTab.startDate &&
                                                                    order.Value.kitting.endDate <= DataContainer.guiState.viTabs.poziomOdpaduTab.endDate);

            if (!DataContainer.guiState.viTabs.poziomOdpaduTab.lgOrders)
            {
                finishedOrders = finishedOrders.Where(order => order.Value.kitting.odredGroup != "LG");
            }
            if (!DataContainer.guiState.viTabs.poziomOdpaduTab.mstOrders)
            {
                finishedOrders = finishedOrders.Where(order => order.Value.kitting.odredGroup != "MST");
            }
            var    sortedOrders = finishedOrders.OrderBy(o => o.Value.kitting.endDate);
            string lineKey      = DataContainer.guiState.viTabs.poziomOdpaduTab.cumulatedLines ? "Skumulowany" : "Po linii";

            string[] selectedLines = DataContainer.guiState.viTabs.poziomOdpaduTab.selectedLines;

            Dictionary <string, Dictionary <string, WastePerPointStruct> > chartPoints = new Dictionary <string, Dictionary <string, WastePerPointStruct> >();

            foreach (var smtLine in selectedLines)
            {
                chartPoints.Add(smtLine, new Dictionary <string, WastePerPointStruct>());
            }

            foreach (var orderEntry in sortedOrders)
            {
                if (orderEntry.Value.smt.totalManufacturedQty == 0)
                {
                    continue;
                }
                if (lineKey != "Skumulowany")
                {
                    lineKey = orderEntry.Value.smt.smtOrders[0].smtLine;
                    if (!selectedLines.Contains(lineKey))
                    {
                        continue;
                    }
                }
                string dateKey = GetDateKey(DataContainer.guiState.viTabs.poziomOdpaduTab.timeInterval, orderEntry.Value.kitting.endDate);

                foreach (var lineEntry in chartPoints)
                {
                    if (!chartPoints[lineEntry.Key].ContainsKey(dateKey))
                    {
                        chartPoints[lineEntry.Key].Add(dateKey, new WastePerPointStruct());
                    }
                }

                chartPoints[lineKey][dateKey].totalProduction += orderEntry.Value.smt.totalManufacturedQty;
                chartPoints[lineKey][dateKey].totalNg         += orderEntry.Value.visualInspection.ngCount;
                chartPoints[lineKey][dateKey].totalScrap      += orderEntry.Value.visualInspection.scrapCount;
            }

            SeriesCollection seriesCollection = new SeriesCollection();

            ChartValues <float> totalProdValues = new ChartValues <float>();
            List <string>       labels          = new List <string>();

            foreach (var dateEntry in chartPoints[chartPoints.Select(k => k.Key).First()])
            {
                labels.Add(dateEntry.Key);
                totalProdValues.Add(0);
            }


            foreach (var lineEntry in chartPoints)
            {
                int day = 0;
                foreach (var dateKey in labels)
                {
                    totalProdValues[day] += lineEntry.Value[dateKey].totalProduction;
                    day++;
                }
            }

            ColumnSeries totalProductionSeries = new ColumnSeries();

            totalProductionSeries.Fill = new SolidColorBrush
            {
                Color   = System.Windows.Media.Color.FromArgb(255, 50, 50, 50),
                Opacity = .4
            };
            totalProductionSeries.ScalesYAt = 0;
            totalProductionSeries.Values    = totalProdValues;
            totalProductionSeries.Title     = "Produkcja";



            Axis axX = new Axis();

            axX.Labels = labels;


            Axis axY1 = new Axis();

            axY1.Position            = AxisPosition.RightTop;
            axY1.Separator.IsEnabled = false;
            Axis axY2 = new Axis();



            poziomOdpaduChart.AxisX.Add(axX);
            poziomOdpaduChart.AxisY.Add(axY1);
            poziomOdpaduChart.AxisY.Add(axY2);
            seriesCollection.Add(totalProductionSeries);


            foreach (var lineEntry in chartPoints)
            {
                ChartValues <float> ngValues    = new ChartValues <float>();
                ChartValues <float> scrapValues = new ChartValues <float>();

                foreach (var dateEntry in lineEntry.Value)
                {
                    if (dateEntry.Value.totalProduction > 0)
                    {
                        ngValues.Add((float)Math.Round((float)dateEntry.Value.totalNg / (float)dateEntry.Value.totalProduction * 100, 2));
                        scrapValues.Add((float)Math.Round((float)dateEntry.Value.totalScrap / (float)dateEntry.Value.totalProduction * 100, 2));
                    }
                    else
                    {
                        ngValues.Add(0);
                        scrapValues.Add(0);
                    }
                }

                LineSeries ngSeries = new LineSeries();
                ngSeries.Title      = $"ng_{lineEntry.Key}";
                ngSeries.Values     = ngValues;
                ngSeries.DataLabels = true;
                ngSeries.ScalesYAt  = 1;
                Func <ChartPoint, string> ngPt = pt => Math.Round(pt.Y, 2).ToString() + "%";
                ngSeries.LabelPoint = ngPt;
                ngSeries.Stroke     = MediaTools.ColorDrawingToMediaBrush(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()]);
                ngSeries.Fill       = new SolidColorBrush
                {
                    Color   = MediaTools.ColorDrawingToColorMedia(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()]),
                    Opacity = 0.4
                };
                ngSeries.PointGeometry = DefaultGeometries.Square;

                LineSeries scrapSeries = new LineSeries();
                scrapSeries.Values     = scrapValues;
                scrapSeries.Title      = $"scrap_{lineEntry.Key}";
                scrapSeries.LabelPoint = ngPt;
                scrapSeries.DataLabels = true;
                scrapSeries.ScalesYAt  = 1;
                scrapSeries.Fill       = new SolidColorBrush
                {
                    Color   = (MediaTools.ColorDrawingToColorMedia(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()])),
                    Opacity = 0.4
                };
                scrapSeries.Stroke = MediaTools.ColorDrawingToMediaBrush(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()]);
                seriesCollection.Add(ngSeries);
                seriesCollection.Add(scrapSeries);

                //poziomOdpaduChart.Series.Add(ngSeries);
                //poziomOdpaduChart.Series.Add(scrapSeries);
            }

            poziomOdpaduChart.Series.AddRange(seriesCollection);
            poziomOdpaduChart.Zoom = ZoomingOptions.Xy;
            poziomOdpaduChart.Pan  = PanningOptions.Xy;
        }
        public static void RunCardWorkStatAndGenerateChart(string WalletAddress, DateTime start, DateTime end, int resolution, LiveCharts.WinForms.CartesianChart chart, string MetricColumn, string YKey, string LegendColumn, bool sum, string numberFormat)
        {
            List <DataTable> Stats = RunCardWorkReport(MetricColumn, WalletAddress, start, end, resolution, sum);

            CreatChartFromDataSets(start, end, chart, resolution, Stats, MetricColumn, YKey, LegendColumn, numberFormat);
        }
Exemplo n.º 17
0
        public static void Create(string tableName, lwf.CartesianChart chart, List <ProjectDbTable> myTable)
        {
            //List<ProjectDbTable> myTable = Helpers.ConnectDB(tableName);


            ChartValues <double> rvtFileSizeValues = new ChartValues <double>();
            ChartValues <double> idValues          = new ChartValues <double>();
            ChartValues <double> elementsCount     = new ChartValues <double>();

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

            if (myTable != null)
            {
                foreach (var item in myTable)
                {
                    rvtFileSizeValues.Add(item.rvtFileSize / 1000000);
                    idValues.Add(item.id);
                    dateLabels.Add(item.date.ToString("dd/MM/yy"));
                    elementsCount.Add(item.elementsCount);
                }

                chart.Series = new SeriesCollection {
                    new LineSeries
                    {
                        Title     = "File Size",
                        Values    = rvtFileSizeValues,
                        ScalesYAt = 0
                    },
                    new LineSeries
                    {
                        Title     = "Elements",
                        Values    = elementsCount,
                        ScalesYAt = 1
                    },
                };


                chart.AxisX.Add(Helpers.CreateAxe("Date", 89, dateLabels, 5, AxisPosition.LeftBottom)); //step to be adjusted by label count!

                chart.AxisY.Add(Helpers.CreateAxe("MB", 0, AxisPosition.LeftBottom));

                Axis eleCount = Helpers.CreateAxe("Elements Count", 0, AxisPosition.RightTop);

                eleCount.LabelFormatter = value => value / 1000 + "k";
                eleCount.Separator      = new Separator
                {
                    //Step = 1000
                };

                chart.AxisY.Add(eleCount);

                /*
                 * chart.AxisY.Add(new Axis
                 * {
                 *  Title = "Elements Count",
                 *  Position = AxisPosition.RightTop,
                 *  LabelFormatter = value => value / 1000 + "k"
                 *
                 * });
                 */
                chart.LegendLocation = LegendLocation.Bottom;
            }
            else
            {
            }
        }//close method
        public void ProgressChart()
        {
            //**************** 2st 계획 대비 진척 차트 ******************

            cartesianChart1 = new LiveCharts.WinForms.CartesianChart();

            cartesianChart1.Dock     = System.Windows.Forms.DockStyle.Fill;
            cartesianChart1.Location = new System.Drawing.Point(0, 0);
            cartesianChart1.Name     = "cartesianChart1";
            cartesianChart1.Size     = new System.Drawing.Size(991, 366);
            cartesianChart1.TabIndex = 1;
            cartesianChart1.Text     = "cartesianChart1";

            panel11.Controls.Add(cartesianChart1);


            cartesianChart1.Series = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "계획량",
                    Values = new ChartValues <int>()
                }
            };

            //adding series will update and animate the chart automatically
            cartesianChart1.Series.Add(new ColumnSeries
            {
                Title  = "생산량",
                Values = new ChartValues <int>()
            });

            //also adding values updates and animates the chart automatically

            foreach (var item in planList)
            {
                cartesianChart1.Series[0].Values.Add(item.ORDER_M);
                cartesianChart1.Series[1].Values.Add(item.INSU_QTY);
            }

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

            for (int i = 0; i < planList.Count; i++)
            {
                lables.Add(planList[i].PROD_CODE);
            }

            cartesianChart1.AxisX.Add(new Axis
            {
                Title  = "",
                Labels = lables.ToArray()
                         //Labels = new [] { "a", "b", "c", "d", "e" ,"f" }
            });

            cartesianChart1.AxisY.Add(new Axis
            {
                Title          = "갯수",
                MinValue       = 0,
                LabelFormatter = value => value.ToString("N0")
            });

            cartesianChart1.LegendLocation = LegendLocation.Right;
        }
        public void DefectChart()
        {
            //**************** 3rd 모델별 불량 차트 ******************
            cartesianChart2 = new LiveCharts.WinForms.CartesianChart();

            cartesianChart2.Dock     = System.Windows.Forms.DockStyle.Fill;
            cartesianChart2.Location = new System.Drawing.Point(0, 0);
            cartesianChart2.Name     = "cartesianChart2";
            cartesianChart2.Size     = new System.Drawing.Size(991, 366);
            cartesianChart2.TabIndex = 2;
            cartesianChart2.Text     = "cartesianChart2";

            panel12.Controls.Add(cartesianChart2);



            cartesianChart2.Series = new SeriesCollection();

            //adding series updates and animates the chart
            cartesianChart2.Series.Add(new StackedColumnSeries
            {
                Title     = "양품량",
                Values    = new ChartValues <int>(),
                StackMode = StackMode.Values,
                Fill      = System.Windows.Media.Brushes.DarkBlue
            });

            cartesianChart2.Series.Add(new StackedColumnSeries
            {
                Title     = "불량량",
                Values    = new ChartValues <int>(),
                StackMode = StackMode.Values,
                Fill      = System.Windows.Media.Brushes.Chocolate
            });


            foreach (var item in defectList)
            {
                cartesianChart2.Series[0].Values.Add(item.GOOD_QTY);
                cartesianChart2.Series[1].Values.Add(item.BAD_QTY);
            }

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

            for (int i = 0; i < planList.Count; i++)
            {
                lables.Add(planList[i].PROD_CODE);
            }

            cartesianChart2.AxisX.Add(new Axis
            {
                Title     = "",
                Labels    = lables.ToArray(),
                Separator = DefaultAxes.CleanSeparator
            });

            cartesianChart2.AxisY.Add(new Axis
            {
                Title          = "불량량",
                MinValue       = 0,
                LabelFormatter = value => value.ToString("N0")
            });

            cartesianChart2.LegendLocation = LegendLocation.Right;
        }
        public static void DrawingChart(string[] LabelArray, double[] ValueArrayTotal, double[] AbsenceNumber, double[] IndirectNumber, ref CartesianChart chart)
        {
            try
            {
                double YmaxValue = 0;
                double YminValue = 0;
                YminValue = ValueArrayTotal.Min() == 0?1: ValueArrayTotal.Min();
                YmaxValue = ValueArrayTotal.Max();
                chart.Series.Clear();
                chart.AxisX.Clear();
                chart.AxisY.Clear();
                chart.Controls.Clear();
                List <String>        lables           = new List <string>();
                ChartValues <double> valuesTotal      = new ChartValues <double>();
                ChartValues <double> ValueabsenceQty  = new ChartValues <double>();
                ChartValues <double> ValueIndirectQty = new ChartValues <double>();

                for (int i = 0; i < LabelArray.Length; i++)
                {
                    lables.Add(LabelArray[i]);
                    valuesTotal.Add(ValueArrayTotal[i]);
                    ValueabsenceQty.Add(AbsenceNumber[i]);
                    ValueIndirectQty.Add(IndirectNumber[i]);
                }
                chart.Series = new SeriesCollection
                {
                    new ColumnSeries
                    {
                        Title      = "Employees",
                        Values     = valuesTotal,
                        DataLabels = true,
                        Fill       = System.Windows.Media.Brushes.Green,
                        ScalesYAt  = 0,
                        FontSize   = 8
                    }
                };
                chart.Series.Add(
                    new ColumnSeries
                {
                    Title      = "Absence",
                    Values     = ValueabsenceQty,
                    DataLabels = true,
                    Fill       = System.Windows.Media.Brushes.Red,
                    ScalesYAt  = 0,
                    FontSize   = 8
                });
                chart.Series.Add(
                    new ColumnSeries
                {
                    Title      = "Indirect",
                    Values     = ValueIndirectQty,
                    DataLabels = true,
                    Fill       = System.Windows.Media.Brushes.LightBlue,
                    ScalesYAt  = 0,
                    FontSize   = 8
                }
                    );

                chart.DefaultLegend.Margin   = new Thickness(15);
                chart.DefaultLegend.FontSize = 20;
                chart.LegendLocation         = LegendLocation.Top;


                //x axis labels
                chart.AxisX.Add(new Axis
                {
                    Title    = "Dept",
                    Labels   = lables,
                    Unit     = 1,
                    FontSize = 12,

                    FontFamily = new System.Windows.Media.FontFamily("Times New Roman"),
                    Foreground = System.Windows.Media.Brushes.Black,
                    Separator  = new LiveCharts.Wpf.Separator
                    {
                        Step      = 1,
                        IsEnabled = false //disable it to make it invisible.
                    },
                    LabelsRotation = 0,
                });


                //y axis label
                chart.AxisY.Add(new Axis
                {
                    Title          = "People Number",
                    LabelFormatter = value => value.ToString("N0"),
                    FontSize       = 10,

                    FontFamily = new System.Windows.Media.FontFamily("Times New Roman"),

                    Foreground = System.Windows.Media.Brushes.Black,
                    MaxValue   = YmaxValue * 1.2,
                    MinValue   = 0,
                    Width      = 5,
                    Position   = AxisPosition.LeftBottom
                });

                LabelArray       = null;
                lables           = null;
                valuesTotal      = null;
                ValueabsenceQty  = null;
                ValueIndirectQty = null;
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Drawing chart ", ex.Message);
            }

            ClearMemory.CleanMemory();
        }
Exemplo n.º 21
0
 public GraphicSystem(LiveCharts.WinForms.CartesianChart Graphic)
 {
     this.Graphic = Graphic;
 }
Exemplo n.º 22
0
        public static void CreateChartsClaster(List <double[]> arr_point, LiveCharts.WinForms.CartesianChart cc, int clastervalue)
        {
            ChartValues <ObservablePoint> pointvalue  = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue2 = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue3 = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue4 = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue5 = new ChartValues <ObservablePoint>();

            for (int i = 0; i < arr_point.Count; i++)
            {
                switch (Convert.ToInt32(arr_point[i][3]))
                {
                case 0:
                    pointvalue.Add(new ObservablePoint(arr_point[i][1], arr_point[i][2]));
                    break;

                case 1:
                    pointvalue2.Add(new ObservablePoint(arr_point[i][1], arr_point[i][2]));
                    break;

                case 2:
                    pointvalue3.Add(new ObservablePoint(arr_point[i][1], arr_point[i][2]));
                    break;

                case 3:
                    pointvalue4.Add(new ObservablePoint(arr_point[i][1], arr_point[i][2]));
                    break;

                case 4:
                    pointvalue5.Add(new ObservablePoint(arr_point[i][1], arr_point[i][2]));
                    break;
                }
            }

            ScatterSeries pointvalues = new ScatterSeries();

            pointvalues.Title           = "Series 1";
            pointvalues.Values          = pointvalue;
            pointvalues.PointGeometry   = DefaultGeometries.Triangle;
            pointvalues.StrokeThickness = 2;
            pointvalues.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue2s = new ScatterSeries();

            pointvalue2s.Title           = "Series 2";
            pointvalue2s.Values          = pointvalue2;
            pointvalue2s.PointGeometry   = DefaultGeometries.Circle;
            pointvalue2s.StrokeThickness = 2;
            pointvalue2s.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue3s = new ScatterSeries();

            pointvalue3s.Title           = "Series 3";
            pointvalue3s.Values          = pointvalue3;
            pointvalue3s.PointGeometry   = DefaultGeometries.Cross;
            pointvalue3s.StrokeThickness = 2;
            pointvalue3s.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue4s = new ScatterSeries();

            pointvalue4s.Title           = "Series 4";
            pointvalue4s.Values          = pointvalue4;
            pointvalue4s.PointGeometry   = DefaultGeometries.Diamond;
            pointvalue4s.StrokeThickness = 2;
            pointvalue4s.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue5s = new ScatterSeries();

            pointvalue5s.Title           = "Series 5";
            pointvalue5s.Values          = pointvalue5;
            pointvalue5s.PointGeometry   = DefaultGeometries.Square;
            pointvalue5s.StrokeThickness = 2;
            pointvalue5s.Fill            = Brushes.Transparent;

            SeriesCollection sc = new SeriesCollection();

            sc.Add(pointvalues);
            sc.Add(pointvalue2s);
            sc.Add(pointvalue3s);
            sc.Add(pointvalue4s);
            sc.Add(pointvalue5s);
            cc.Series = sc;
        }
Exemplo n.º 23
0
        public void DrawingLiveChart(TargetMQC target, List <chartdatabyDate> chartdatabyDates, List <chartdatabyDate> chartdataDefect, ref CartesianChart chart)
        {
            //xu ly data de chon cac thong so cua chart
            double YmaxValue = 0;
            double YminValue = 0;
            Dictionary <string, double> ValueConvert       = new Dictionary <string, double>();
            Dictionary <string, double> ValueConvertDefect = new Dictionary <string, double>();

            if (chartdatabyDates != null && chartdatabyDates.Count > 0)
            {
                chart.Series.Clear();
                chart.AxisX.Clear();
                chart.AxisY.Clear();
                chart.Controls.Clear();
                //      chart.Base.Foreground = new SolidColorBrush(Color.FromRgb(66, 66, 66));

                //  chart.Background = System.Windows.Media.Brushes.BlanchedAlmond;

                ValueConvert       = DicChangeTime(chartdatabyDates);
                ValueConvertDefect = DicChangeTime(chartdataDefect);
                string[] TimeChanged         = ValueConvert.Keys.ToArray();
                double[] OutputChanged       = ValueConvert.Values.ToArray();
                double[] OutputChangedDefect = ValueConvertDefect.Values.ToArray();
                YmaxValue = OutputChanged.Max();

                YminValue = OutputChanged.Min();
                ChartValues <double> values          = new ChartValues <double>();
                ChartValues <double> valuesTarget    = new ChartValues <double>();
                ChartValues <double> valuesDefect    = new ChartValues <double>();
                ChartValues <double> PercentQuantity = new ChartValues <double>();
                ChartValues <double> Defecttarget    = new ChartValues <double>();
                double per = 0;
                for (int i = 0; i < OutputChanged.Count(); i++)
                {
                    values.Add(OutputChanged[i]);

                    //  valuesTarget.Add(100);
                    if ((OutputChangedDefect[i] + OutputChanged[i]) != 0)
                    {
                        valuesDefect.Add(OutputChangedDefect[i] / (OutputChangedDefect[i] + OutputChanged[i]));
                    }
                    else
                    {
                        valuesDefect.Add(0);
                    }
                    valuesTarget.Add(OutputChangedDefect[i]);
                    if (target.TargetOutput > 0)
                    {
                        per += OutputChanged[i] / target.TargetOutput;
                        PercentQuantity.Add(per);
                        Defecttarget.Add(target.TargetDefect / target.TargetOutput);
                    }
                }
                YmaxValue = values.Max();
                // YmaxValue = (values.Max() > valuesTarget.Max())? values.Max() : valuesTarget.Max();
                List <String> lables = new List <string>();
                for (int i = 0; i < TimeChanged.Count(); i++)
                {
                    lables.Add(TimeChanged[i]);
                }
                chart.Series = new SeriesCollection
                {
                    new ColumnSeries
                    {
                        Title      = "Output Quantity",
                        Values     = values,
                        DataLabels = true,
                        Fill       = System.Windows.Media.Brushes.Green,
                        ScalesYAt  = 0,
                        FontSize   = 15
                    }
                };
                chart.Series.Add(
                    new ColumnSeries
                {
                    Title      = "Defect Quantity",
                    Values     = valuesTarget,
                    DataLabels = true,
                    Fill       = System.Windows.Media.Brushes.Red,
                    ScalesYAt  = 0,
                    FontSize   = 15
                }
                    );
                chart.Series.Add(
                    new LineSeries
                {
                    Title           = "Defect Rate (%)",
                    Values          = valuesDefect,
                    DataLabels      = true,
                    Foreground      = System.Windows.Media.Brushes.Orange,
                    PointForeground = System.Windows.Media.Brushes.Red,
                    ScalesYAt       = 1,
                    FontSize        = 15
                });
                chart.Series.Add(
                    new LineSeries
                {
                    Title           = "Target Quantity(%)",
                    Values          = PercentQuantity,
                    DataLabels      = true,
                    Foreground      = System.Windows.Media.Brushes.BlueViolet,
                    PointForeground = System.Windows.Media.Brushes.BlueViolet,
                    ScalesYAt       = 1,
                    FontSize        = 15
                }
                    );
                chart.Series.Add(
                    new LineSeries
                {
                    Title           = "Defect target(%)",
                    Values          = Defecttarget,
                    DataLabels      = true,
                    Foreground      = System.Windows.Media.Brushes.DarkKhaki,
                    PointForeground = System.Windows.Media.Brushes.DarkKhaki,
                    ScalesYAt       = 1,
                    FontSize        = 15
                }
                    );
                chart.DefaultLegend.Margin   = new Thickness(30);
                chart.DefaultLegend.FontSize = 20;
                chart.LegendLocation         = LegendLocation.Top;


                //x axis labels
                chart.AxisX.Add(new Axis
                {
                    Title    = "Hours",
                    Labels   = lables,
                    Unit     = 1,
                    FontSize = 15,

                    FontFamily = new System.Windows.Media.FontFamily("Times New Roman"),
                    Foreground = System.Windows.Media.Brushes.Black,
                    Separator  = new LiveCharts.Wpf.Separator
                    {
                        Step      = 1,
                        IsEnabled = false //disable it to make it invisible.
                    },
                    LabelsRotation = 0,
                });


                //y axis label
                chart.AxisY.Add(new Axis
                {
                    Title          = "Quantity (pcs)",
                    LabelFormatter = value => value.ToString("N0"),
                    FontSize       = 15,

                    FontFamily = new System.Windows.Media.FontFamily("Times New Roman"),

                    Foreground = System.Windows.Media.Brushes.Black,
                    MaxValue   = YmaxValue * 1.2,
                    MinValue   = 0,
                    Position   = AxisPosition.LeftBottom
                });

                chart.AxisY.Add(new Axis
                {
                    Title          = "percent (%)",
                    LabelFormatter = value => value.ToString("P1"),
                    FontSize       = 15,
                    FontFamily     = new System.Windows.Media.FontFamily("Times New Roman"),
                    Foreground     = System.Windows.Media.Brushes.Black,
                    MaxValue       = 1,
                    MinValue       = 0,
                    Position       = AxisPosition.RightTop
                });
                // chart.Zoom = ZoomingOptions.Xy;
            }
        }
 public ViViewModels(LiveCharts.WinForms.CartesianChart poziomOdpaduChart)
 {
     PoziomOdpaduChart = poziomOdpaduChart;
 }
Exemplo n.º 25
0
        /// <summary>
        /// Update data in specified chart controll
        /// </summary>
        /// <param name="chart">Chart, which need to update</param>
        /// <param name="data">New data</param>
        public static void RefreshForecastChart(LiveCharts.WinForms.CartesianChart chart, FResult data)
        {
            Dictionary <string, List <double> > lines = new Dictionary <string, List <double> >
            {
                { "Forecast points", Enumerable.Repeat(double.NaN, data.TimeSeriesPoints.Count).ToList() },
                { "Lo 80", Enumerable.Repeat(double.NaN, data.TimeSeriesPoints.Count).ToList() },
                { "Hi 80", Enumerable.Repeat(double.NaN, data.TimeSeriesPoints.Count).ToList() },
                { "Lo 95", Enumerable.Repeat(double.NaN, data.TimeSeriesPoints.Count).ToList() },
                { "Hi 95", Enumerable.Repeat(double.NaN, data.TimeSeriesPoints.Count).ToList() },
                { "Time Series", data.TimeSeriesPoints }
            };
            int count = 0;

            for (int i = 0; i < data.ResultDataFrame.Data[0].Count; i++)
            {
                for (int j = 0; j < data.ResultDataFrame.Data.Count; j++)
                {
                    if (count == 0)
                    {
                        lines["Forecast points"].Add(Convert.ToDouble(data.ResultDataFrame.Data[j][i]));
                    }
                    else if (count == 1)
                    {
                        lines["Lo 80"].Add(Convert.ToDouble(data.ResultDataFrame.Data[j][i]));
                    }
                    else if (count == 2)
                    {
                        lines["Hi 80"].Add(Convert.ToDouble(data.ResultDataFrame.Data[j][i]));
                    }
                    else if (count == 3)
                    {
                        lines["Lo 95"].Add(Convert.ToDouble(data.ResultDataFrame.Data[j][i]));
                    }
                    else if (count == 4)
                    {
                        lines["Hi 95"].Add(Convert.ToDouble(data.ResultDataFrame.Data[j][i]));
                    }
                    count++;
                    if (count == 5)
                    {
                        count = 0;
                    }
                }
            }
            List <SeriesOption> lineOptions = lines.Select((line) => new SeriesOption {
                Title = line.Key, Values = line.Value
            }).ToList();

            lineOptions.Where(line => line.Title.Equals("Forecast points"))
            .ToList()
            .ForEach(line => {
                line.IsDashed      = true;
                line.PointGeometry = DefaultGeometries.Diamond;
            });
            lineOptions.Where(line => line.Title.Equals("Time Series"))
            .ToList()
            .ForEach(line =>
            {
                line.LineColor = Brushes.Black;
            });
            chart.Series = CreateSeriesCollection(lineOptions);
        }
Exemplo n.º 26
0
        public static void RebuildClastering(LiveCharts.WinForms.CartesianChart cRebuild, DataGridView dg, int x, int y, int numberclass)
        {
            cRebuild.Series.Clear();
            List <double[]> new_vector = new List <double[]>();

            for (int i = 0; i < arr_vector.Count; i++)
            {
                if (x != arr_vector[i][1] && y != arr_vector[i][2])
                {
                    new_vector.Add(arr_vector[i]);
                }
            }

            double[][] arr_point_new = new double[new_vector.Count][];
            for (int i = 0; i < new_vector.Count; i++)
            {
                arr_point_new[i] = new double[] { new_vector[i][1], new_vector[i][2] };
            }

            ClasteringM do_clastering1 = new ClasteringM();

            do_clastering1.SetValueClaster(numberclass);

            int[]           outVector          = do_clastering1.Cluster(arr_point_new, numberclass);
            List <double[]> new_vector_claster = new List <double[]>();

            for (int i = 0; i < outVector.Length; i++)
            {
                double[] buffer = new double[4];
                buffer[0] = i;
                buffer[1] = arr_point_new[i][0];
                buffer[2] = arr_point_new[i][1];
                buffer[3] = outVector[i];
                new_vector_claster.Add(buffer);
            }


            ChartValues <ObservablePoint> pointvalue  = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue2 = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue3 = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue4 = new ChartValues <ObservablePoint>();
            ChartValues <ObservablePoint> pointvalue5 = new ChartValues <ObservablePoint>();

            for (int i = 0; i < new_vector_claster.Count; i++)
            {
                switch (Convert.ToInt32(new_vector_claster[i][3]))
                {
                case 0:
                    pointvalue.Add(new ObservablePoint(new_vector_claster[i][1], new_vector_claster[i][2]));
                    break;

                case 1:
                    pointvalue2.Add(new ObservablePoint(new_vector_claster[i][1], new_vector_claster[i][2]));
                    break;

                case 2:
                    pointvalue3.Add(new ObservablePoint(new_vector_claster[i][1], new_vector_claster[i][2]));
                    break;

                case 3:
                    pointvalue4.Add(new ObservablePoint(new_vector_claster[i][1], new_vector_claster[i][2]));
                    break;

                case 4:
                    pointvalue5.Add(new ObservablePoint(new_vector_claster[i][1], new_vector_claster[i][2]));
                    break;
                }
            }

            ScatterSeries pointvalues = new ScatterSeries();

            pointvalues.Title           = "Series 1";
            pointvalues.Values          = pointvalue;
            pointvalues.PointGeometry   = DefaultGeometries.Triangle;
            pointvalues.StrokeThickness = 2;
            pointvalues.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue2s = new ScatterSeries();

            pointvalue2s.Title           = "Series 2";
            pointvalue2s.Values          = pointvalue2;
            pointvalue2s.PointGeometry   = DefaultGeometries.Circle;
            pointvalue2s.StrokeThickness = 2;
            pointvalue2s.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue3s = new ScatterSeries();

            pointvalue3s.Title           = "Series 3";
            pointvalue3s.Values          = pointvalue3;
            pointvalue3s.PointGeometry   = DefaultGeometries.Cross;
            pointvalue3s.StrokeThickness = 2;
            pointvalue3s.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue4s = new ScatterSeries();

            pointvalue4s.Title           = "Series 4";
            pointvalue4s.Values          = pointvalue4;
            pointvalue4s.PointGeometry   = DefaultGeometries.Diamond;
            pointvalue4s.StrokeThickness = 2;
            pointvalue4s.Fill            = Brushes.Transparent;

            ScatterSeries pointvalue5s = new ScatterSeries();

            pointvalue5s.Title           = "Series 5";
            pointvalue5s.Values          = pointvalue5;
            pointvalue5s.PointGeometry   = DefaultGeometries.Square;
            pointvalue5s.StrokeThickness = 2;
            pointvalue5s.Fill            = Brushes.Transparent;

            SeriesCollection sc = new SeriesCollection();

            sc.Add(pointvalues);
            sc.Add(pointvalue2s);
            sc.Add(pointvalue3s);
            sc.Add(pointvalue4s);
            sc.Add(pointvalue5s);
            cRebuild.Series = sc;
        }