private void loadChart()
        {
            //SELECT MONTH(fechaRecepcion) Mes, SUM(id) total_mes FROM averia GROUP BY Mes; regulera
            //select MonthName(fechaRecepcion) as Month, count(id) as averias from taller.averia Group By Month   averias totales
            //select MonthName(fechaRecepcion) as Month, count(id) as averias from taller.averia where estado = 3 Group By Month  averias Reparadas
            // SET lc_time_names = 'es_ES' ; select  CONCAT(UPPER(LEFT(MonthName(fechaRecepcion),1)),SUBSTR(MonthName(fechaRecepcion),2)) as Month, count(id) as averias from taller.averia where estado = 3 Group By Month para que salga la primera letra en Mayus.

            //SET lc_time_names = 'es_ES' para cambiar el idioma de los mese del Mysql

            DataTable dt = serChart.getDatos("SET lc_time_names = 'es_ES' ; select CONCAT(UPPER(LEFT(MonthName(fechaRecepcion),1)),SUBSTR(MonthName(fechaRecepcion),2)) as Month, count(id) as averias from taller.averia where estado = 3 Group By Month ");

            Func <ChartPoint, string> labelPoint   = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
            ChartValues <double>      cht_y_values = new ChartValues <double>();
            SeriesCollection          series       = new LiveCharts.SeriesCollection();

            //no puedo contolar si fechaRecepcion esta vacia en alguna tabla ,como resultado no deja que funcione el programa

            foreach (DataRow dr in dt.Rows)
            {
                PieSeries ps = new PieSeries
                {
                    Title  = "" + dr[0],
                    Values = new ChartValues <double> {
                        double.Parse(dr[1].ToString())
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                };
                series.Add(ps);
            }
            lvRepMes.Series = series;
        }
        public StackedPillarDesignModel()
        {
            SeriesCollection = new LiveCharts.SeriesCollection()
            {
                new StackedColumnSeries()
                {
                    Values = new ChartValues <int> {
                        2, 5
                    },
                    StackMode = StackMode.Values,
                },
                new StackedColumnSeries()
                {
                    Values = new ChartValues <int> {
                        5, 10
                    },
                    StackMode = StackMode.Values,
                }
            };

            XLabels = new string[]
            {
                "8:00", "9:00", "10:00"
            };

            YLabels = new string[]
            {
                "0", "20", "40", "60", "80", "100"
            };

            Formatter = i => $"{i}辆";
        }
Exemple #3
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var series = new SeriesCollection()
            {
                new PieSeries()
                {
                    Title  = "Văn học",
                    Values = new ChartValues <int> {
                        vh
                    },
                    DataLabels = true
                },
                new PieSeries()
                {
                    Title  = "Kinh tế",
                    Values = new ChartValues <int> {
                        kt
                    },
                    DataLabels = true
                },
                new PieSeries()
                {
                    Title  = "Tâm lý - kỹ năng sống",
                    Values = new ChartValues <int> {
                        tlkns
                    },
                    DataLabels = true
                },
                new PieSeries()
                {
                    Title  = "Thiếu nhi",
                    Values = new ChartValues <int> {
                        tn
                    },
                    DataLabels = true
                },
                new PieSeries()
                {
                    Title  = "Nuôi dạy con",
                    Values = new ChartValues <int> {
                        ndc
                    },
                    DataLabels = true
                },

                new PieSeries()
                {
                    Title  = "Học ngoại ngữ",
                    Values = new ChartValues <int> {
                        hnn
                    },
                    DataLabels = true
                }
            };

            reportChart.Series = series;
        }
Exemple #4
0
        private TimeChartViewModel()
        {
            var dayConfig = Initialise();

            if (dayConfig != null)
            {
                Formatter = value => (value < 0) ? null : new System.DateTime((long)((value) * TimeSpan.FromHours(1).Ticks)).ToString("t");
            }

            SeriesCollection = new LiveCharts.SeriesCollection(dayConfig);
        }
Exemple #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog opd = new OpenFileDialog();

            if (opd.ShowDialog() == DialogResult.OK)
            {
                String filePath = opd.FileName;


                try
                {
                    cartesianChart1.Series.Clear();

                    SeriesCollection sc = new SeriesCollection
                    {
                        new RowSeries
                        {
                            Title  = "Cantidad",
                            Values = new ChartValues <int> {
                                1102, 1, 18
                            },
                        },
                    };
                    cartesianChart1.Series = sc;


                    StreamReader streamReader = new StreamReader(filePath);
                    string       read;
                    string[]     titles;
                    if ((titles = streamReader.ReadLine().Split(',')) != null)
                    {
                        dT.Columns.Add(titles[0]);
                        dT.Columns.Add(titles[1]);
                        dT.Columns.Add(titles[2]);
                        dT.Columns.Add(titles[3]);
                        dT.Columns.Add(titles[4]);
                    }

                    //bool titles=true;
                    while ((read = streamReader.ReadLine()) != null)
                    {
                        string[] rowRaw = read.Split(',');



                        dT.Rows.Add(rowRaw);
                        database.DataSource = dT;
                    }
                }
                catch (Exception o)
                {
                }
            }
        }
Exemple #6
0
        private void ProductStatistics()
        {
            DataTable dataTable = Producto.ProductStatistics(this.product.Barcode, this.periodTimeCombo.SelectedIndex, this.datePicker.Value);

            this.splitContainer2.Text = string.Format("{0} {1}", (object)this.product.Description, (object)this.product.Brand);
            this.productStatisticsChart.Series.Clear();
            this.productStatisticsChart.AxisX.Clear();
            this.productStatisticsChart.AxisY.Clear();
            this.productStatisticsChart.Zoom = ZoomingOptions.X;
            this.productStatisticsChart.Pan  = PanningOptions.Unset;
            ChartValues <double> chartValues1 = new ChartValues <double>();
            ChartValues <double> chartValues2 = new ChartValues <double>();
            List <string>        stringList   = new List <string>();

            foreach (DataRow row in (InternalDataCollectionBase)dataTable.Rows)
            {
                chartValues1.Add(Convert.ToDouble(row["Venta"]));
                chartValues2.Add(Convert.ToDouble(row["Compra"]));
                stringList.Add(row["Fecha"].ToString());
            }
            LiveCharts.SeriesCollection series1 = this.productStatisticsChart.Series;
            LineSeries lineSeries1 = new LineSeries();

            lineSeries1.Title  = "Venta";
            lineSeries1.Values = (IChartValues)chartValues1;

            LineSeries lineSeries2 = lineSeries1;

            series1.Add((ISeriesView)lineSeries2);
            LiveCharts.SeriesCollection series2 = this.productStatisticsChart.Series;

            LineSeries lineSeries3 = new LineSeries();

            lineSeries3.Title  = "Compra";
            lineSeries3.Values = (IChartValues)chartValues2;

            LineSeries lineSeries4 = lineSeries3;

            series2.Add((ISeriesView)lineSeries4);
            this.productStatisticsChart.AxisX.Add(new LiveCharts.Wpf.Axis()
            {
                Title  = "Fecha",
                Labels = (IList <string>)stringList
            });
            this.productStatisticsChart.AxisY.Add(new LiveCharts.Wpf.Axis()
            {
                Title          = "Piezas",
                LabelFormatter = (Func <double, string>)(value => value.ToString("N")),
                MinValue       = 0.0
            });
        }
Exemple #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
            stopwatch.Restart();
            //cartesianChart1.Series.Clear();
            //LiveCharts.SeriesCollection series = new LiveCharts.SeriesCollection();
            //var aparelhos = revenueBindingSource.DataSource as List<Revenue>;
            //int[] value = { };

            //foreach (var ap in aparelhos)
            //{
            //    List<int> values = new List<int>();

            //    value = new int[] { ap.TotalA, ap.TotalM, ap.TotalC };
            //    values.AddRange(value);

            //    series.Add(new LineSeries() { Title = ap.Cuidados, Values = new ChartValues<int>(values) });
            //}
            //cartesianChart1.Series = series;



            cartesianChart1.Series.Clear();
            LiveCharts.SeriesCollection series = new LiveCharts.SeriesCollection();
            var years = (from o in revenueBindingSource.DataSource as List <Revenue>
                         select new { Year = o.Year }).Distinct();

            foreach (var year in years)
            {
                List <double> values = new List <double>();
                for (int month = 1; month <= 12; month++)
                {
                    double value = 0;
                    var    data  = from o in revenueBindingSource.DataSource as List <Revenue>
                                   where o.Year.Equals(year.Year) && o.Month.Equals(month)
                                   orderby o.Month ascending
                                   select new { o.Value, o.Month };
                    if (data.SingleOrDefault() != null)
                    {
                        value = data.SingleOrDefault().Value;
                    }
                    values.Add(value);
                }
                series.Add(new LineSeries()
                {
                    Title = year.Year.ToString(), Values = new ChartValues <double>(values)
                });
            }
            cartesianChart1.Series = series;
        }
Exemple #8
0
        private void ShowPieChart()
        {
            String           query = "SELECT date,COUNT(id) AS Logins FROM login_attempt GROUP BY date;";
            MySqlDataAdapter adp   = new MySqlDataAdapter(query, con);
            DataTable        dt    = new DataTable();

            con.Open();
            adp.Fill(dt);

            con.Close();

            string[] numbers = new string[dt.Rows.Count];
            string[] dates   = new string[dt.Rows.Count];


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dates[i]   = dt.Rows[i]["date"].ToString();
                numbers[i] = dt.Rows[i]["Logins"].ToString();
            }



            Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            SeriesCollection piechartData = new SeriesCollection {
            };

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                piechartData.Add(
                    new PieSeries
                {
                    Title  = dates[i],
                    Values = new ChartValues <double> {
                        Convert.ToInt32(numbers[i])
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint,
                }
                    );
            }

            pieChart1.Series = piechartData;

            pieChart1.LegendLocation           = LegendLocation.Right;
            pieChart1.DefaultLegend.Background = System.Windows.Media.Brushes.White;
        }
Exemple #9
0
        private void ambiance_Button_22_Click(object sender, EventArgs e)
        {
            ambiance_TabControl2.SelectedIndex = 0;


            if (String.IsNullOrEmpty(txtParca.Text) || String.IsNullOrEmpty(txtKalip.Text))
            {
                btnExcell.Visible = true;

                var a = kalipService.procAylikSatisOrani(Convert.ToDateTime(dateTimePickerBaslangic.Text).ToShortDateString(), Convert.ToDateTime(dateTimePickerBitis.Text).ToShortDateString());

                LiveCharts.SeriesCollection series = new LiveCharts.SeriesCollection();

                foreach (var obj in a)
                {
                    series.Add(new PieSeries()
                    {
                        Title = obj.NumuneAdi + " " + Convert.ToDateTime(obj.Tarih.ToString()).ToShortDateString(), Values = new ChartValues <int> {
                            Convert.ToInt32(obj.Adet)
                        }, DataLabels = true, LabelPoint = labelpoint
                    });
                    pieChart1.Series = series;
                }


                dataGridView2.DataSource = kalipService.procAylikSatisOrani(Convert.ToDateTime(dateTimePickerBaslangic.Text).ToShortDateString(), Convert.ToDateTime(dateTimePickerBitis.Text).ToShortDateString()); //Datagridviewa aktarım
            }

            else
            {
                var a = kalipService.PieChart(Convert.ToDateTime(dateTimePickerBaslangic.Text).ToShortDateString(), Convert.ToDateTime(dateTimePickerBitis.Text).ToShortDateString(), Convert.ToInt32(txtParca.Text), Convert.ToInt32(txtKalip.Text));

                LiveCharts.SeriesCollection series = new LiveCharts.SeriesCollection();

                foreach (var obj in a)
                {
                    series.Add(new PieSeries()
                    {
                        Title = Convert.ToDateTime(obj.Tarih.ToString()).ToShortDateString(), Values = new ChartValues <int> {
                            Convert.ToInt32(obj.Adet)
                        }, DataLabels = true, LabelPoint = labelpoint
                    });
                    pieChart1.Series = series;
                }
            }
        }
Exemple #10
0
        private void Grafica_Load(object sender, EventArgs e)
        {
            DataSet   datos_h        = controls.getRatingHabitat();
            DataTable seriesHabitats = datos_h.Tables[0];

            DataSet   datos_e        = controls.getRatingEspecie();
            DataTable seriesESpecies = datos_e.Tables[0];

            pieCharH.LegendLocation  = LegendLocation.Bottom;
            pieChartE.LegendLocation = LegendLocation.Bottom;

            SeriesCollection series_h = new SeriesCollection();
            SeriesCollection series_e = new SeriesCollection();



            foreach (DataRow fila in seriesHabitats.Rows)
            {
                series_h.Add(new PieSeries()
                {
                    Title  = fila["Habitat"].ToString(),
                    Values = new ChartValues <int> {
                        Convert.ToInt32(fila["Cantidad"].ToString())
                    },
                    DataLabels = true, LabelPoint = label
                });
            }

            foreach (DataRow fila in seriesESpecies.Rows)
            {
                series_e.Add(new PieSeries()
                {
                    Title  = fila["Especie"].ToString(),
                    Values = new ChartValues <int> {
                        Convert.ToInt32(fila["Cantidad"].ToString())
                    },
                    DataLabels = true,
                    LabelPoint = label
                });
            }

            pieCharH.Series  = series_h;
            pieChartE.Series = series_e;
        }
Exemple #11
0
        private static SeriesCollection ToSeriesCollection(this List <PieSeriesConfig> pieSeriesConfig)
        {
            SeriesCollection          seriesCollection = new LiveCharts.SeriesCollection();
            Func <ChartPoint, string> labelPoint       = chartPoint =>
                                                         string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            foreach (var pieSeries in pieSeriesConfig)
            {
                seriesCollection.Add(
                    new PieSeries
                {
                    Title      = pieSeries.Title,
                    Values     = pieSeries.Values.ToChartValues(),
                    DataLabels = pieSeries.DataLabels,
                    LabelPoint = labelPoint,
                    PushOut    = pieSeries.PushOut
                });
            }
            return(seriesCollection);
        }
Exemple #12
0
        private void MakeGraph(IReadOnlyCollection <XY> points)
        {
            var series = sizeChart.Series.FirstOrDefault(s => s.Title == "Data") ?? new ScatterSeries
            {
                Title  = "Data",
                Values = new ChartValues <ObservablePoint>()
            };

            series.Values.AddRange(points.Select(p => new ObservablePoint(p.X, p.Y)));
            sizeChart.Series.Add(series);

            var mapper = Mappers.Xy <ObservablePoint>()
                         .X(p => Math.Log(p.X, 10))
                         .Y(p => Math.Log(p.Y, 10));
            var collection = new SeriesCollection(mapper);

            for (var i = _minSize; i <= _maxSize; i += 8)
            {
                var size    = i;
                var nSeries = new ScatterSeries
                {
                    Title         = "Size: " + size,
                    Values        = new ChartValues <ObservablePoint>(),
                    PointGeometry = DefaultGeometries.Diamond
                };
                nSeries.Values.AddRange(points.Where(p => p.X == size)
                                        .Select(p => new ObservablePoint(p.NDouble, p.TotDouble)));
                collection.Add(nSeries);
            }

            versusChart.DataClick += (sender, point) =>
            {
                var size = int.Parse(point.SeriesView.Title.Split(' ')[1]);
                var singleKeySizeForm = new SingleKeySizeForm(size, _data.Points.Where(p => p.X == size));
                singleKeySizeForm.ShowDialog();
            };

            versusChart.Series = collection;
        }
Exemple #13
0
        private void profitInvestmentCard()
        {
            DataTable investProfitData = Venta.getSalesInvestProfitData(this.periodTimeCombo.SelectedIndex, this.datePicker.Value);

            this.investmentProfitChart.Series.Clear();
            this.investmentProfitChart.AxisX.Clear();
            this.investmentProfitChart.AxisY.Clear();
            this.investmentProfitChart.Zoom = ZoomingOptions.X;
            this.investmentProfitChart.Pan  = PanningOptions.Unset;

            ChartValues <double> chartValues1 = new ChartValues <double>();
            ChartValues <double> chartValues2 = new ChartValues <double>();
            ChartValues <double> chartValues3 = new ChartValues <double>();
            ChartValues <double> chartValues4 = new ChartValues <double>();
            ChartValues <double> chartValues5 = new ChartValues <double>();
            ChartValues <double> chartValues6 = new ChartValues <double>();


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

            foreach (DataRow row in (InternalDataCollectionBase)investProfitData.Rows)
            {
                chartValues1.Add(Convert.ToDouble(row["Ventas"]));
                chartValues2.Add(Convert.ToDouble(row["Adeudo de Clientes"]));
                chartValues3.Add(Convert.ToDouble(row["Perdida por Scrap"]));
                chartValues4.Add(Convert.ToDouble(row["Inversion"]));
                chartValues5.Add(Convert.ToDouble(row["Ganancia"]));
                chartValues6.Add(Convert.ToDouble(row["Pago de Empleados"]));
                stringList.Add(row["Fecha"].ToString());
            }

            LiveCharts.SeriesCollection series1 = this.investmentProfitChart.Series;
            ColumnSeries columnSeries1          = new ColumnSeries();

            columnSeries1.Title  = "Venta";
            columnSeries1.Values = (IChartValues)chartValues1;
            ColumnSeries columnSeries2 = columnSeries1;

            series1.Add((ISeriesView)columnSeries2);
            LiveCharts.SeriesCollection series2 = this.investmentProfitChart.Series;
            ColumnSeries columnSeries3          = new ColumnSeries();

            columnSeries3.Title  = "Adeudo de Clientes";
            columnSeries3.Values = (IChartValues)chartValues2;
            ColumnSeries columnSeries4 = columnSeries3;

            series2.Add((ISeriesView)columnSeries4);
            LiveCharts.SeriesCollection series3 = this.investmentProfitChart.Series;
            ColumnSeries columnSeries5          = new ColumnSeries();

            columnSeries5.Title  = "Perdida por Scrap";
            columnSeries5.Values = (IChartValues)chartValues3;
            ColumnSeries columnSeries6 = columnSeries5;

            series3.Add((ISeriesView)columnSeries6);
            LiveCharts.SeriesCollection series4 = this.investmentProfitChart.Series;
            ColumnSeries columnSeries7          = new ColumnSeries();

            columnSeries7.Title  = "Pago de Empleados";
            columnSeries7.Values = (IChartValues)chartValues6;
            ColumnSeries columnSeries8 = columnSeries7;

            series4.Add((ISeriesView)columnSeries8);
            LiveCharts.SeriesCollection series5 = this.investmentProfitChart.Series;
            ColumnSeries columnSeries9          = new ColumnSeries();

            columnSeries9.Title  = "Inversión";
            columnSeries9.Values = (IChartValues)chartValues4;
            ColumnSeries columnSeries10 = columnSeries9;

            series5.Add((ISeriesView)columnSeries10);
            LiveCharts.SeriesCollection series6 = this.investmentProfitChart.Series;
            ColumnSeries columnSeries11         = new ColumnSeries();

            columnSeries11.Title  = "Ganancia";
            columnSeries11.Values = (IChartValues)chartValues5;
            ColumnSeries columnSeries12 = columnSeries11;

            series6.Add((ISeriesView)columnSeries12);
            this.investmentProfitChart.AxisX.Add(new LiveCharts.Wpf.Axis()
            {
                Title  = "Fecha",
                Labels = (IList <string>)stringList
            });
            this.investmentProfitChart.AxisY.Add(new LiveCharts.Wpf.Axis()
            {
                Title          = "Pesos",
                LabelFormatter = (Func <double, string>)(value => value.ToString("N"))
            });
        }
        private void DrawLivePieChart(string path, string NodeName)
        {
            try
            {
                LivePieChart.Series.Clear();

                var series = new System.Windows.Forms.DataVisualization.Charting.Series {
                    ChartType = SeriesChartType.Pie
                };

                Func <ChartPoint, string> labelPoint = chartPoint =>
                                                       string.Format("{0} ({1:P})", chartPoint.SeriesView.Title, chartPoint.Participation);
                chart1.Series.Add(series);
                LiveCharts.SeriesCollection ss = new LiveCharts.SeriesCollection();
                LivePieChart.Series = ss;
                DirectoryInfo directory = new DirectoryInfo(path);
                int           count     = 0;
                //chart1.Legends[0].Title = NodeName;
                //chart1.Titles[0].Text = NodeName;
                //chart1.Legends[0].TextWrapThreshold = 50;
                LivePieChart.LegendLocation = LegendLocation.Bottom;
                if (File.Exists(path))
                {
                    FileInfo file = new FileInfo(path);
                    ss.Add(new PieSeries
                    {
                        Title  = FixNameLenght(file.Name),
                        Values = new ChartValues <double> {
                            file.Length
                        },
                        PushOut    = 8,
                        DataLabels = true,
                        LabelPoint = labelPoint
                    });
                    series.Points.AddXY(FixNameLenght(file.Name), file.Length);
                    series.Points[count].Label        = FixNameLenght(file.Name);
                    series.Points[count++].LegendText = string.Format("{0} % \r\n{1}", Math.Round((1.00), 2), checkSize(Math.Round(Convert.ToDouble(file.Length), 2)));
                }
                else
                {
                    double DirSize = GetSize(path), TempSize, other = 0;
                    List <DirectoryInfo> direcories = directory.GetDirectories().ToList();
                    List <FileInfo>      files      = directory.GetFiles().ToList();
                    if (direcories.Count + files.Count <= 10)
                    {
                        foreach (var dir in direcories)
                        {
                            TempSize = GetSize(dir.FullName);
                            ss.Add(new PieSeries {
                                Title  = FixNameLenght(dir.Name),
                                Values = new ChartValues <double> {
                                    TempSize
                                },
                                PushOut    = 8,
                                DataLabels = true,
                                LabelPoint = labelPoint
                            });

                            series.Points.AddXY(FixNameLenght(dir.Name), TempSize);
                            series.Points[count].Label        = FixNameLenght(dir.Name);
                            series.Points[count++].LegendText = string.Format("{0} % \r\n{1}", Math.Round(Convert.ToDouble(TempSize / DirSize) * 100, 2), checkSize(TempSize));
                        }
                        foreach (var file in files)
                        {
                            TempSize = GetSize(file.FullName);
                            ss.Add(new PieSeries
                            {
                                Title  = FixNameLenght(file.Name),
                                Values = new ChartValues <double> {
                                    TempSize
                                },
                                PushOut = 8,


                                DataLabels = true,
                                LabelPoint = labelPoint
                            });

                            series.Points.AddXY(FixNameLenght(file.Name), TempSize);
                            series.Points[count].Label        = FixNameLenght(file.Name);
                            series.Points[count++].LegendText = string.Format("{0} % \r\n{1}", Math.Round(Convert.ToDouble(TempSize / DirSize) * 100, 2), checkSize(TempSize));
                        }
                    }
                    else
                    {
                        foreach (var dir in direcories)
                        {
                            TempSize = GetSize(dir.FullName);



                            if (TempSize > .05 * DirSize)
                            {
                                ss.Add(new PieSeries
                                {
                                    Title  = FixNameLenght(dir.Name),
                                    Values = new ChartValues <double> {
                                        TempSize
                                    },
                                    PushOut    = 8,
                                    DataLabels = true,
                                    LabelPoint = labelPoint
                                });
                                series.Points.AddXY(FixNameLenght(dir.Name), TempSize);
                                series.Points[count].Label        = FixNameLenght(dir.Name);
                                series.Points[count++].LegendText = string.Format("{0} % \r\n{1}", Math.Round(Convert.ToDouble(TempSize / DirSize) * 100, 2), checkSize(TempSize));
                            }
                            else
                            {
                                other += TempSize;
                            }
                        }
                        foreach (var file in files)
                        {
                            TempSize = GetSize(file.FullName);
                            if (TempSize > .05 * DirSize)
                            {
                                ss.Add(new PieSeries
                                {
                                    Title  = FixNameLenght(file.Name),
                                    Values = new ChartValues <double> {
                                        TempSize
                                    },
                                    PushOut = 8,


                                    DataLabels = true,
                                    LabelPoint = labelPoint
                                });
                                series.Points.AddXY(FixNameLenght(file.Name), TempSize);
                                series.Points[count].Label        = FixNameLenght(file.Name);
                                series.Points[count++].LegendText = string.Format("{0} % \r\n{1}", Math.Round(Convert.ToDouble(TempSize / DirSize) * 100, 2), checkSize(TempSize));
                            }
                            else
                            {
                                other += TempSize;
                            }
                        }
                        if (other > DirSize * .03)
                        {
                            ss.Add(new PieSeries
                            {
                                Title  = FixNameLenght("Other"),
                                Values = new ChartValues <double> {
                                    DirSize
                                },
                                PushOut = 8,


                                DataLabels = true,
                                LabelPoint = labelPoint
                            });
                            series.Points.AddXY("Other", other);
                            series.Points[count].Label        = FixNameLenght("Other");
                            series.Points[count++].LegendText = string.Format("{0} % \r\n{1}", Math.Round(Convert.ToDouble(other / DirSize) * 100, 2), checkSize(other));
                        }
                    }
                }
            }
            catch { }
        }
        private void addNewTab(ShowingCurrencyClass showingCurrency)
        {
            TabItem        tabItem = new TabItem();
            CartesianChart cart    = new CartesianChart();

            ChartValues <double> vals   = new ChartValues <double>();
            List <string>        labels = new List <string>();

            string title = "";
            string time  = "";
            int    step  = 0;

            switch (showingCurrency.Type)
            {
            case CurrencyIntervalType.TIME_SERIES_INTRADAY:
            case CurrencyIntervalType.TIME_SERIES_DAILY:
            case CurrencyIntervalType.TIME_SERIES_WEEKLY:
            case CurrencyIntervalType.TIME_SERIES_MONTHLY:
                string[] lista = showingCurrency.Metadata["1. Information"].Split(' ');
                if (showingCurrency.Type == CurrencyIntervalType.TIME_SERIES_INTRADAY)
                {
                    time = lista[0] + lista[1];
                }
                else
                {
                    time = lista[0];
                }
                step  = 4;
                title = showingCurrency.Metadata["2. Symbol"] + "(" + time + ")";
                foreach (string key in showingCurrency.Timeseries.Keys)
                {
                    labels.Add(key);
                    labels.Add("");
                    labels.Add("");
                    labels.Add("");
                    vals.Add(showingCurrency.Timeseries[key]["1. open"]);
                    vals.Add(showingCurrency.Timeseries[key]["2. high"]);
                    vals.Add(showingCurrency.Timeseries[key]["3. low"]);
                    vals.Add(showingCurrency.Timeseries[key]["4. close"]);
                }
                break;

            case CurrencyIntervalType.DIGITAL_CURRENCY_DAILY:
            case CurrencyIntervalType.DIGITAL_CURRENCY_MONTHLY:
            case CurrencyIntervalType.DIGITAL_CURRENCY_WEEKLY:
                string[] listing = showingCurrency.Metadata["1. Information"].Split(' ');
                if (showingCurrency.Type == CurrencyIntervalType.DIGITAL_CURRENCY_INTRADAY)
                {
                    time = listing[0] + listing[1];
                }
                else
                {
                    time = listing[0];
                }
                step  = 4;
                title = showingCurrency.Metadata["2. Digital Currency Code"] + "(" + time + ")";
                foreach (string key in showingCurrency.Timeseries.Keys)
                {
                    labels.Add(key);
                    labels.Add("");
                    labels.Add("");
                    labels.Add("");
                    vals.Add(showingCurrency.Timeseries[key]["1a. open (" + referentCurrency.Symbol + ")"]);
                    vals.Add(showingCurrency.Timeseries[key]["2a. high (" + referentCurrency.Symbol + ")"]);
                    vals.Add(showingCurrency.Timeseries[key]["3a. low (" + referentCurrency.Symbol + ")"]);
                    vals.Add(showingCurrency.Timeseries[key]["4a. close (" + referentCurrency.Symbol + ")"]);
                }
                break;

            case CurrencyIntervalType.DIGITAL_CURRENCY_INTRADAY:
                string[] listej = showingCurrency.Metadata["1. Information"].Split(' ');
                if (showingCurrency.Type == CurrencyIntervalType.DIGITAL_CURRENCY_INTRADAY)
                {
                    time = listej[0] + listej[1];
                }
                else
                {
                    time = listej[0];
                }
                step  = 1;
                title = showingCurrency.Metadata["2. Digital Currency Code"] + "(" + time + ")";
                foreach (string key in showingCurrency.Timeseries.Keys)
                {
                    labels.Add(key);
                    vals.Add(showingCurrency.Timeseries[key]["1a. price (" + referentCurrency.Symbol + ")"]);
                }
                break;
            }

            LiveCharts.SeriesCollection sers = new LiveCharts.SeriesCollection
            {
                new LineSeries
                {
                    Title  = title,
                    Values = vals
                }
            };
            //cart.LegendLocation = LiveCharts.LegendLocation.Right;
            cart.AxisX.Add(new LiveCharts.Wpf.Axis
            {
                Labels    = labels,
                Separator = new LiveCharts.Wpf.Separator
                {
                    Step = step
                },
                LabelsRotation = 15
            });

            cart.Series = sers;

            cart.Width = vals.Count * 10;
            if (step == 1)
            {
                cart.Width = vals.Count * 50;
            }


            ScrollViewer skrol = new ScrollViewer();

            skrol.HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Visible;

            ContextMenu cm = new ContextMenu();
            MenuItem    mi = new MenuItem();

            mi.Header = "Close";

            mi.Click += new RoutedEventHandler((sender, e) => menuItemClicked(sender, e, title));
            cm.Items.Add(mi);

            tabItem.ContextMenu = cm;
            tabItem.Header      = title;
            skrol.Content       = cart;
            tabItem.Content     = skrol;
            tabControl.Items.Add(tabItem);
            tabControl.SelectedItem = tabItem;
        }
Exemple #16
0
        /// <summary>
        /// 円グラフ作成(アニメーションありのグラフ)
        /// </summary>
        public void CreateNLivePieChart()
        {
            try
            {
                pChartStatistics.Series = new LiveCharts.SeriesCollection();

                List <StatisticsData> statisticsDataList = GetStatisticsDataList();
                if (statisticsDataList.Count <= 0)
                {
                    return;
                }

                StatisticsSeries = new LiveCharts.SeriesCollection();
                Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0:#,0}円", chartPoint.Y);

                var totalMoney = statisticsDataList.Select(x => x.Money).Sum();
                //リスト設定
                List <StatisticsListData> statisticsListData = new List <StatisticsListData>();

                foreach (var statisticsData in statisticsDataList)
                {
                    PieSeries pieSeries = new PieSeries
                    {
                        // Title⇒収入と支出の分類を表示
                        Title = statisticsData.Classification,
                        // Values⇒金額を表示
                        Values = new ChartValues <double> {
                            statisticsData.Money
                        },
                        DataLabels = true,
                        LabelPoint = labelPoint
                    };

                    StatisticsSeries.Add(pieSeries);

                    //リスト用のデータ作成
                    StatisticsListData data = new StatisticsListData
                    {
                        Percentage     = (statisticsData.Money / totalMoney * 100).ToString() + "%",
                        Classification = statisticsData.Classification,
                        AmountOfMoney  = statisticsData.Money
                    };
                    statisticsListData.Add(data);
                }

                //円グラフ表示設定
                pChartStatistics.Series                = StatisticsSeries;
                pChartStatistics.LegendLocation        = LegendLocation.Bottom;
                pChartStatistics.StartingRotationAngle = INIT_PIE_ANGLE;

                //リスト表示
                if (!CreateListData(statisticsListData))
                {
                    return;
                }
            }
            catch (Exception e)
            {
                string s = e.Message;
                OriginMBox.MBoxErrorOK(AppConst.SERIES_MESSAGE);
                return;
            }
        }
        public BasePillarDesignModel()
        {
            var linearBlueBrush = new LinearGradientBrush()
            {
                StartPoint    = new Point(0.5, 0),
                EndPoint      = new Point(0.5, 1),
                GradientStops = new GradientStopCollection()
                {
                    new GradientStop((Color)ColorConverter.ConvertFromString("#03F0FD"), 0),
                    new GradientStop((Color)ColorConverter.ConvertFromString("#4A8FDE"), 1),
                }
            };
            var linearYellowBrush = new LinearGradientBrush()
            {
                StartPoint    = new Point(0.5, 0),
                EndPoint      = new Point(0.5, 1),
                GradientStops = new GradientStopCollection()
                {
                    new GradientStop((Color)ColorConverter.ConvertFromString("#F5F258"), 0),
                    new GradientStop((Color)ColorConverter.ConvertFromString("#EAC042"), 1),
                }
            };

            var dataTemplate = new DataTemplate();

            FrameworkElementFactory textFactory = new FrameworkElementFactory(typeof(TextBlock));

            textFactory.Name = "factory";
            textFactory.SetValue(TextBlock.TextProperty, "57");
            textFactory.SetValue(TextBlock.FontSizeProperty, 12D);
            textFactory.SetValue(TextBlock.ForegroundProperty, linearBlueBrush);

            dataTemplate.VisualTree = textFactory;

            SeriesCollection = new LiveCharts.SeriesCollection()
            {
                new ColumnSeries()
                {
                    MaxColumnWidth     = 32,
                    Title              = "驶入车辆",
                    Fill               = linearBlueBrush,
                    DataLabels         = true,
                    DataLabelsTemplate = dataTemplate,
                    LabelPoint         = p => p.Y.ToString(),
                    Values             = new ChartValues <int> {
                        39, 11, 20, 52, 49, 61, 12, 41, 69, 26, 26, 26, 26, 26, 34
                    },
                },
                new ColumnSeries()
                {
                    MaxColumnWidth     = 32,
                    Title              = "驶出车辆",
                    DataLabels         = true,
                    DataLabelsTemplate = dataTemplate,
                    Fill   = linearYellowBrush,
                    Values = new ChartValues <int> {
                        86, 38, 31, 65, 53, 35, 53, 25, 78, 31, 31, 31, 31, 31, 64
                    },
                },
            };

            Labels = new string[]
            {
                "8:00", "9:00", "10:00", "11:00",
                "12:00", "13:00", "14:00", "15:00",
                "16:00", "17:00", "18:00", "19:00",
                "20:00", "21:00", "22:00",
            };



            Formatter = i => $"{i}辆";
        }
        //private ObservableCollection<String> timeline;
        //private ObservableCollection<DateTime> listDate;

        public ReportManagementViewModel() : base()
        {
            listBillModel = ListBillModel.GetInstance();
            listBillModel.LoadAllBill();

            listRevenueModel     = ListRevenueModel.GetInstance();
            listExpenditureModel = ListExpenditureModel.GetInstance();

            ReportCollection = new LiveCharts.SeriesCollection();

            MonthRevenueLabels     = new ObservableCollection <String>();
            MonthExpenditureLabels = new ObservableCollection <String>();
            MonthReportLabels      = new ObservableCollection <string>();

            revenue_month     = new ObservableCollection <int>();
            revenue_year      = new ObservableCollection <int>();
            expenditure_month = new ObservableCollection <int>();
            expenditure_year  = new ObservableCollection <int>();
            overview_month    = new ObservableCollection <int>();
            overview_year     = new ObservableCollection <int>();

            // Calculate revenue
            revenue = new ObservableCollection <double>();
            ObservableCollection <String[]> result_revenue = ListBillModel.GetRevenueByDayAndMonth();

            for (int i = 0; i < result_revenue.Count; i++)
            {
                //Debug.LogOutput(result_revenue[i][0]);
                String item_timeline = result_revenue[i][0].ToString();
                double item_revenue  = Double.Parse(result_revenue[i][1].ToString());

                MonthRevenueLabels.Add(item_timeline);
                revenue_month.Add(Int32.Parse(result_revenue[i][2].ToString()));
                revenue_year.Add(Int32.Parse(result_revenue[i][3].ToString()));
                revenue.Add(item_revenue);
            }

            ReportCollection.Add(new ColumnSeries()
            {
                Title  = "Tổng thu",
                Values = new ChartValues <double>(revenue)
            });

            // Calculate expenditure
            expenditure = new ObservableCollection <double>();
            ObservableCollection <String[]> result_expenditure = ListImportationModel.GetExpenditureByDayAndMonth();

            for (int i = 0; i < result_expenditure.Count; i++)
            {
                Debug.LogOutput(result_expenditure[i][0]);
                String item_timeline    = result_expenditure[i][0].ToString();
                double item_expenditure = Double.Parse(result_expenditure[i][1].ToString());

                MonthExpenditureLabels.Add(item_timeline);
                expenditure_month.Add(Int32.Parse(result_expenditure[i][2].ToString()));
                expenditure_year.Add(Int32.Parse(result_expenditure[i][3].ToString()));
                expenditure.Add(item_expenditure);
            }

            ReportCollection.Add(new ColumnSeries()
            {
                Title  = "Tổng chi",
                Values = new ChartValues <double>(expenditure)
            });

            Formatter = value => value.ToString("N");

            // Calculate for MonthReportLabels: find min and max timeline
            ObservableCollection <string[]> overview_temp = new ObservableCollection <string[]>();

            overview_temp = AdvancedQuery.GetAllTimeline();
            for (int i = 0; i < overview_temp.Count; i++)
            {
                MonthReportLabels.Add(overview_temp[i][0]);
                overview_month.Add(Int32.Parse(overview_temp[i][1]));
                overview_year.Add(Int32.Parse(overview_temp[i][2]));
            }

            // Export Excel
            ExportExcelCommand = new DelegateCommand(ExportExcel);

            // Month report combobox
            MonthReportChangeCommand = new DelegateCommand <string>(MonthReportChange);

            // Month product combobox
            NotifyChanged("SelectedMonthProduct");
            MonthProductChangeCommand = new DelegateCommand <string>(MonthProductChange);

            // init product chart
            ProductSeries = new LiveCharts.SeriesCollection();

            // Month product combobox
            NotifyChanged("SelectedMonthIngredient");
            MonthIngredientChangeCommand = new DelegateCommand <string>(MonthIngredientChange);

            // init ingredient chart
            IngredientSeries = new LiveCharts.SeriesCollection();
        }
Exemple #19
0
        public DashboardView()
        {
            InitializeComponent();



            TopEmployee.Series.Clear();
            LiveCharts.SeriesCollection topPerformingCollections = new LiveCharts.SeriesCollection();


            var dtrSelect = db.DailyTimeRecords.Join(db.Employees, id => id.DailyTimeRecordPK, foreign =>
                                                     foreign.EmployeePK, (primaryId, foreignId) => new { PrimaryID = primaryId, ForeignID = foreignId })
                            .GroupBy(a => a.PrimaryID.UserName)

                            .Select(l => new
            {
                DtrID      = l.Key,
                Number     = l.Count(),
                SumEach    = l.Sum(a => a.PrimaryID.Accumulated),
                Name       = l.FirstOrDefault().ForeignID.UserName,
                Department = l.FirstOrDefault().ForeignID.Department
            }).OrderByDescending(a => a.SumEach).ToList();

            // var dtrList = db.DailyTimeRecords.ToList();


            bool c1 = false, c2 = false, c3 = false, c4 = false, c5 = false, c6 = false, c7 = false;
            int  v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v6 = 0, v7 = 0;

            foreach (var dtr in dtrSelect)
            {
                if (dtr.Department == "Sales and Marketing" && c1 == false)
                {
                    v1 = (int)dtr.SumEach;
                    c1 = true;
                }
                if (dtr.Department == "Creative" && c2 == false)
                {
                    v2 = (int)dtr.SumEach;
                    c2 = true;
                }
                if (dtr.Department == "IT" && c3 == false)
                {
                    v3 = (int)dtr.SumEach;
                    c3 = true;
                }
                if (dtr.Department == "Production" && c4 == false)
                {
                    v4 = (int)dtr.SumEach;
                    c4 = true;
                }
                if (dtr.Department == "Inventory" && c5 == false)
                {
                    v5 = (int)dtr.SumEach;
                    c5 = true;
                }
                if (dtr.Department == "Public Relations" && c6 == false)
                {
                    v6 = (int)dtr.SumEach;
                    c6 = true;
                }

                if (dtr.Department == "Human Resources" && c7 == false)
                {
                    v7 = (int)dtr.SumEach;
                    c7 = true;
                }
            }

            topPerformingCollections.Add(new LiveCharts.Wpf.ColumnSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    v1, v2, v3, v4, v5, v6, v7
                }, Title = "Departments"
            });

            TotalPerformingLabel = new[] { "Sales and Marketing", "Creative", "IT", "Production", "Inventory", "Public Relations", "Human Resources" };
            foreach (var topPerforming in topPerformingCollections)
            {
                TopEmployee.Series.Add(topPerforming);
            }



            PointLabel = chartPoint =>
                         string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            DataContext = this;
            DepartmentChart.Series.Clear();
            LiveCharts.SeriesCollection psc = new LiveCharts.SeriesCollection();

            List <Employee> employees       = new List <Employee>();

            employees = db.Employees.ToList();

            var employeesSelect             = db.Employees.GroupBy(a => a.Department)
                                              .Select(l => new
            {
                PayrollViewKey = l.Key,
                Number         = l.Count(),
                Department     = l.FirstOrDefault().Department
            }).ToList();

            foreach (var select in employeesSelect)
            {
                psc.Add(new LiveCharts.Wpf.PieSeries {
                    DataLabels = true, Values = new LiveCharts.ChartValues <decimal> {
                        select.Number
                    }, Title = select.Department
                });
            }

            foreach (var ps in psc)
            {
                DepartmentChart.Series.Add(ps);
            }



            DataContext = this;
            LeaveChart.Series.Clear();
            LiveCharts.SeriesCollection leaveCollection = new LiveCharts.SeriesCollection();

            var   leaveEmployee = db.Employees.ToList();
            float personalLeaveCount = 0, maternityLeaveCount = 0, paternityLeaveCount = 0, medicalLeaveCount = 0, bereavementLeaveCount = 0, sickLeaveCount = 0;

            foreach (var emp in leaveEmployee)
            {
                personalLeaveCount    += emp.PersonalLeave;
                maternityLeaveCount   += emp.MaternityLeave;
                paternityLeaveCount   += emp.PaternityLeave;
                medicalLeaveCount     += emp.MedicalLeave;
                bereavementLeaveCount += emp.BereavementLeave;
                sickLeaveCount        += emp.SickLeave;
            }

            leaveCollection.Add(new LiveCharts.Wpf.PieSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    (int)personalLeaveCount
                }, Title = "Personal Leave"
            });
            leaveCollection.Add(new LiveCharts.Wpf.PieSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    (int)maternityLeaveCount
                }, Title = "Maternity Leave"
            });
            leaveCollection.Add(new LiveCharts.Wpf.PieSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    (int)paternityLeaveCount
                }, Title = "Paternity Leave"
            });
            leaveCollection.Add(new LiveCharts.Wpf.PieSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    (int)medicalLeaveCount
                }, Title = "Medical Leave"
            });
            leaveCollection.Add(new LiveCharts.Wpf.PieSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    (int)bereavementLeaveCount
                }, Title = "Bereavement Leave"
            });
            leaveCollection.Add(new LiveCharts.Wpf.PieSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    (int)sickLeaveCount
                }, Title = "Sick Leave"
            });



            foreach (var l in leaveCollection)
            {
                LeaveChart.Series.Add(l);
            }



            //// CARTESIAN
            ///
            DataContext = this;
            AppraisalChart.Series.Clear();
            LiveCharts.SeriesCollection appraisalCollections = new LiveCharts.SeriesCollection();

            var employeeList  = db.Employees.ToList();
            var appraisalList = db.Evaluations.ToList();

            List <AppraisalClass> appraisalClass = new List <AppraisalClass>();

            foreach (var emp in employeeList)
            {
                double score = 0;
                foreach (var app in appraisalList)
                {
                    if (emp.UserName == app.UserName)
                    {
                        score += app.TotalScore;
                    }
                }

                appraisalClass.Add(new AppraisalClass
                {
                    Name  = emp.UserName,
                    Score = score
                });
            }

            foreach (var eachAppraise in appraisalClass.OrderByDescending(a => a.Score))
            {
                appraisalCollections.Add(new LiveCharts.Wpf.ColumnSeries {
                    DataLabels = true, Values = new LiveCharts.ChartValues <double> {
                        eachAppraise.Score
                    }, Title = eachAppraise.Name
                });
            }

            foreach (var appcol in appraisalCollections)
            {
                AppraisalChart.Series.Add(appcol);
            }

            /// TOP PERFORMING EMPLOYEES PER DEPARTMENT
            ///
            DataContext = this;

            //Total absence

            TotalAbsence.Series.Clear();
            LiveCharts.SeriesCollection totalAbsence = new LiveCharts.SeriesCollection();
            var datetimeDTR = DateTime.Now;
            var listOfAvailableDate = db.DailyTimeRecords.Where(a => a.DateTimeStamps <= datetimeDTR).ToList();
            int d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0, d7 = 0, d8 = 0, d9 = 0, d10 = 0, d11 = 0, d12 = 0;

            foreach (var dtr in listOfAvailableDate)
            {
                if (dtr.TimeIn == null)
                {
                    if (dtr.DateTimeStamps.Value.Month == 1)
                    {
                        d1++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 2)
                    {
                        d2++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 3)
                    {
                        d3++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 4)
                    {
                        d4++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 5)
                    {
                        d5++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 6)
                    {
                        d6++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 7)
                    {
                        d7++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 8)
                    {
                        d8++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 9)
                    {
                        d9++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 10)
                    {
                        d10++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 11)
                    {
                        d11++;
                    }
                    if (dtr.DateTimeStamps.Value.Month == 12)
                    {
                        d12++;
                    }
                }
            }
            totalAbsence.Add(new LiveCharts.Wpf.ColumnSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12
                }, Title = "Months"
            });


            TotalAbsenceLabel = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
            foreach (var absene in totalAbsence)
            {
                TotalAbsence.Series.Add(absene);
            }
            // Total Overtime

            TotalOvertime.Series.Clear();
            LiveCharts.SeriesCollection totalOvertime = new LiveCharts.SeriesCollection();
            int od1 = 0, od2 = 0, od3 = 0, od4 = 0, od5 = 0, od6 = 0, od7 = 0, od8 = 0, od9 = 0, od10 = 0, od11 = 0, od12 = 0;
            var overtime       = DateTime.Now;
            var listOfOvertime = db.Overtimes.Where(a => a.Status == "Accepted").ToList();

            foreach (var ot in listOfOvertime)
            {
                if (ot.DateOfOvertime.Value.Month == 1)
                {
                    od1++;
                }
                if (ot.DateOfOvertime.Value.Month == 2)
                {
                    od2++;
                }
                if (ot.DateOfOvertime.Value.Month == 3)
                {
                    od3++;
                }
                if (ot.DateOfOvertime.Value.Month == 4)
                {
                    od4++;
                }
                if (ot.DateOfOvertime.Value.Month == 5)
                {
                    od5++;
                }
                if (ot.DateOfOvertime.Value.Month == 6)
                {
                    od6++;
                }
                if (ot.DateOfOvertime.Value.Month == 7)
                {
                    od7++;
                }
                if (ot.DateOfOvertime.Value.Month == 8)
                {
                    od8++;
                }
                if (ot.DateOfOvertime.Value.Month == 9)
                {
                    od9++;
                }
                if (ot.DateOfOvertime.Value.Month == 10)
                {
                    od10++;
                }
                if (ot.DateOfOvertime.Value.Month == 11)
                {
                    od11++;
                }
                if (ot.DateOfOvertime.Value.Month == 12)
                {
                    od12++;
                }
            }

            totalOvertime.Add(new LiveCharts.Wpf.ColumnSeries {
                DataLabels = true, Values = new LiveCharts.ChartValues <int> {
                    od1, od2, od3, od4, od5, od6, od7, od8, od9, od10, od11, od12
                }, Title = "Months"
            });

            foreach (var ot in totalOvertime)
            {
                TotalOvertime.Series.Add(ot);
            }
        }
Exemple #20
0
        // LiveCharts

        public ChartViewModel()
        {
            Bar.Add(new ChartModel()
            {
                Name = "Work time", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#019c7c")), WorkTimeSpan = new TimeSpan(6, 30, 0), ImagePath = "M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M19.03,7.39L20.45,5.97C20,5.46 19.55,5 19.04,4.56L17.62,6C16.07,4.74 14.12,4 12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22C17,22 21,17.97 21,13C21,10.88 20.26,8.93 19.03,7.39M11,14H13V8H11M15,1H9V3H15V1Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Break", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#e8ba53")), WorkTimeSpan = new TimeSpan(1, 10, 0), ImagePath = "M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Lunch", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#23c4bf")), WorkTimeSpan = new TimeSpan(0, 45, 0), ImagePath = "M15.5,21L14,8H16.23L15.1,3.46L16.84,3L18.09,8H22L20.5,21H15.5M5,11H10A3,3 0 0,1 13,14H2A3,3 0 0,1 5,11M13,18A3,3 0 0,1 10,21H5A3,3 0 0,1 2,18H13M3,15H8L9.5,16.5L11,15H12A1,1 0 0,1 13,16A1,1 0 0,1 12,17H3A1,1 0 0,1 2,16A1,1 0 0,1 3,15Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Meeting", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#008eb3")), WorkTimeSpan = new TimeSpan(0, 30, 0), ImagePath = "M4,15H6A2,2 0 0,1 8,17V19H9V17A2,2 0 0,1 11,15H13A2,2 0 0,1 15,17V19H16V17A2,2 0 0,1 18,15H20A2,2 0 0,1 22,17V19H23V22H1V19H2V17A2,2 0 0,1 4,15M11,7L15,10L11,13V7M4,2H20A2,2 0 0,1 22,4V13.54C21.41,13.19 20.73,13 20,13V4H4V13C3.27,13 2.59,13.19 2,13.54V4A2,2 0 0,1 4,2Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Study", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f4656d")), WorkTimeSpan = new TimeSpan(0, 20, 0), ImagePath = "M12,3L1,9L12,15L21,10.09V17H23V9M5,13.18V17.18L12,21L19,17.18V13.18L12,17L5,13.18Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Exit note", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#a7bfd0")), WorkTimeSpan = new TimeSpan(0, 10, 0), ImagePath = "M12,15H10V13H12V15M18,15H14V13H18V15M8,11H6V9H8V11M18,11H10V9H18V11M20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20M4,6V18H20V6H4Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "To the doctor", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#bb8f5b")), WorkTimeSpan = new TimeSpan(0, 10, 0), ImagePath = "M18,18.5A1.5,1.5 0 0,0 19.5,17A1.5,1.5 0 0,0 18,15.5A1.5,1.5 0 0,0 16.5,17A1.5,1.5 0 0,0 18,18.5M19.5,9.5H17V12H21.46L19.5,9.5M6,18.5A1.5,1.5 0 0,0 7.5,17A1.5,1.5 0 0,0 6,15.5A1.5,1.5 0 0,0 4.5,17A1.5,1.5 0 0,0 6,18.5M20,8L23,12V17H21A3,3 0 0,1 18,20A3,3 0 0,1 15,17H9A3,3 0 0,1 6,20A3,3 0 0,1 3,17H1V6C1,4.89 1.89,4 3,4H17V8H20M8,6V9H5V11H8V14H10V11H13V9H10V6H8Z"
            });

            //Users.Add(new ChartModel() { Employee = "Мусійовський Андрій", Department = "ДПК", WorkTimeSpan = new TimeSpan(8, 10, 0) }); // Наразі - для відображення в графіку
            //Users.Add(new ChartModel() { Employee = "Савка Тарас", Department = "ДПК", WorkTimeSpan = new TimeSpan(7, 59, 0) }); // Наразі - для відображення в графіку

            //SelectedItem = Users[0];

            foreach (var item in UserViewModel.UserInfo)
            {
                ChartSelectInfo.Add(new ChartModel()
                {
                    SelectedUser = item as User
                });
            }
            //SelectedChartInfo = ChartSelectInfo.First(o => o.SelectedUser.Login == Environment.UserName);
            SelectedChartInfo = ChartSelectInfo.First();


            //DtUser = ConnectBase.Select("SELECT * FROM " + ConnectBase.userBase);
            //for (int i = 0; i < DtUser.Rows.Count; i++)
            //{
            //    //NewUser = new User() { ID = (int)DtUser.Rows[i]["ID"], Login = DtUser.Rows[i]["Login"].ToString(), LastName = DtUser.Rows[i]["LastName"].ToString(), FirstName = DtUser.Rows[i]["FirstName"].ToString(), SurName = DtUser.Rows[i]["SurName"].ToString(), GroupName = DtUser.Rows[i]["GroupName"].ToString(), Position = DtUser.Rows[i]["Position"].ToString() };
            //    //UserInfo.Add(NewUser);
            //    UserInfo.Add(new User() { ID = (int)DtUser.Rows[i]["ID"], Login = DtUser.Rows[i]["Login"].ToString(), LastName = DtUser.Rows[i]["LastName"].ToString(), FirstName = DtUser.Rows[i]["FirstName"].ToString(), SurName = DtUser.Rows[i]["SurName"].ToString(), GroupName = DtUser.Rows[i]["GroupName"].ToString(), Position = DtUser.Rows[i]["Position"].ToString() });
            //}



            //ConnectBase.Select();
            Dt = ConnectBase.Select("SELECT UserBase.FirstName, Break_Type, Break_Notes, Start_Time, End_Time FROM " + ConnectBase.timeBase + ", UserBase WHERE TimeBase.User_ID = UserBase.ID"); // comboBoxUsers.Items[1].ToString()
            //Dt = ConnectBase.Select("SELECT * FROM " + ConnectBase.timeBase);

            //GetUsers();
            //UsersList.UserInfo


            // ----- LiveCharts
            PointLabel = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            SeriesCollection = new LiveCharts.SeriesCollection();

            foreach (var item in Bar)
            {
                TimeSpan timespan = new TimeSpan();
                int      index    = Bar.IndexOf(item);

                SeriesCollection.Add(new PieSeries {
                    Title  = Bar[index].Name + " - " + Bar[index].WorkTimeSpan,
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(Bar[index].WorkTimeSpan.TotalMinutes)
                    },
                    DataLabels = true, LabelPoint = chartPoint => string.Format(@"{0:hh\:mm\:ss} ({1:P})", timespan = TimeSpan.FromMinutes(chartPoint.Y), chartPoint.Participation),
                });
            }
            // ----- LiveCharts


            //SeriesCollection = new SeriesCollection
            //{
            //    //new PieSeries { Title = Bar[0].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[0].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[1].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[1].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[2].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[2].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[3].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[3].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[4].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[4].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[5].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[5].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[6].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[6].WorkTimeSpan.TotalMinutes) }, DataLabels = true}

            //};
        }
Exemple #21
0
        public UserControlChar()
        {
            InitializeComponent();

            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
            connection.Open();
            SqlCommand     command   = new SqlCommand("SELECT * FROM Transactions WHERE Username = (SELECT Username FROM SelectedUser WHERE Username = Username) AND Type = 'Expense'", connection);
            SqlCommand     comm      = new SqlCommand("SELECT * FROM Transactions WHERE Username = (SELECT Username FROM SelectedUser WHERE Username = Username) AND Type = 'Income'", connection);
            SqlDataAdapter adapter   = new SqlDataAdapter(command);
            SqlDataAdapter data      = new SqlDataAdapter(comm);
            DataTable      dt        = new DataTable();
            DataTable      dataTable = new DataTable();

            data.Fill(dataTable);
            adapter.Fill(dt);
            Func <ChartPoint, string> labelPoint = chartPoint =>
                                                   string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            ChartValues <double> cht_y_values = new ChartValues <double>();

            LiveCharts.SeriesCollection series = new LiveCharts.SeriesCollection();

            foreach (DataRow dr in dt.Rows)
            {
                PieSeries ps = new PieSeries
                {
                    Title  = dr["Category"].ToString(),
                    Values = new ChartValues <double> {
                        double.Parse(dr["Amount"].ToString())
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint,
                };
                series.Add(ps);
            }
            chart.Series                 = series;
            chart.LegendLocation         = LegendLocation.Right;
            chart.ChartLegend.Foreground = Brushes.WhiteSmoke;

            ChartValues <double> values = new ChartValues <double>();

            LiveCharts.SeriesCollection ser = new LiveCharts.SeriesCollection();

            foreach (DataRow dr in dataTable.Rows)
            {
                PieSeries ps = new PieSeries
                {
                    Title  = dr["Category"].ToString(),
                    Values = new ChartValues <double> {
                        double.Parse(dr["Amount"].ToString())
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint,
                };
                ser.Add(ps);
            }
            chartExpense.Series                 = ser;
            chartExpense.LegendLocation         = LegendLocation.Right;
            chartExpense.ChartLegend.Foreground = Brushes.WhiteSmoke;
        }