Exemple #1
0
        /// <summary>
        /// Статистика для правой таблицы
        /// </summary>
        /// <param name="data">>статистический словарь</param>
        private void ShowStat2(Dictionary <string, int> data)
        {
            data = data.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
            var chartvalues = new ChartValues <int>();

            foreach (var k in data.Keys)
            {
                chartvalues.Add(data[k]);
            }
            if (SeriesCollection2.Count > 0)
            {
                AxisX2.Labels = null;
                Table2        = null;
                Labels2       = null;
                SeriesCollection2.Remove(SeriesCollection2[0]);
            }
            SeriesCollection2.Add(new ColumnSeries
            {
                Values     = chartvalues,
                DataLabels = true
            }
                                  );
            Labels2       = data.Keys.ToArray();
            AxisX2.Labels = Labels2;
            Formatter2    = value => value.ToString();
            DataContext   = this;
            AxisX2.Title  = CripDecripBox.Text;
        }
Exemple #2
0
        private void plotdatabtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SeriesCollection.Clear();
            }
            catch
            {
                SeriesCollection = new SeriesCollection
                {
                };
            }

            try
            {
                SeriesCollection2.Clear();
            }
            catch
            {
                SeriesCollection2 = new SeriesCollection
                {
                };
            }

            var selected = listsrdata.SelectedItem.ToString();

            var chkboxOADs   = TPRplot.Children.OfType <CheckBox>();
            var chkboxdepths = Profileplot.Children.OfType <CheckBox>();

            var plotOADs     = new List <int>();
            var plotOADsdb   = new List <double>();
            var plotdepths   = new List <int>();
            var plotdepthsdb = new List <double>();
            var OADlabels    = new List <string> {
            };

            var rgx = Regex.Split(selected, "  ");

            // get index of data
            int idx = Convert.ToInt32(rgx[0]) - 1;

            JArray exjarr;

            using (StreamReader sr = new StreamReader("srdata.json"))
            {
                string exjson = sr.ReadToEnd();
                exjarr = JArray.Parse(exjson);
            }

            var data = exjarr[idx];

            var rownum = data.Count();
            var colnum = data[0].Count();



            // For the TPR Graph
            foreach (CheckBox chkoad in chkboxOADs)
            {
                if (chkoad.IsChecked.Value)
                {
                    var oadindex = Convert.ToInt32(Regex.Split(chkoad.Name, "_")[1]);

                    plotOADs.Add(oadindex);
                    plotOADsdb.Add(Convert.ToDouble(chkoad.Content));
                }
            }

            // For the Profile Graph
            foreach (CheckBox chkdepth in chkboxdepths)
            {
                if (chkdepth.IsChecked.Value)
                {
                    var dpindex = Convert.ToInt32(Regex.Split(chkdepth.Name, "_")[1]);

                    plotdepths.Add(dpindex);
                    plotdepthsdb.Add(Convert.ToDouble(chkdepth.Content));
                }
            }


            //Plot TPR
            for (int f = 1; f < plotOADs.Count() + 1; f++)
            {
                var tprvals        = new List <double>();
                var pltdepthlabels = new List <string> {
                };

                var pltoadindex = plotOADs[f - 1];

                for (int ff = 1; ff < rownum; ff++)
                {
                    if (Normalizebox.IsChecked.Value == true)
                    {
                        var Normval = Math.Abs(Convert.ToDouble(data[Normdepth.SelectedIndex + 1][Normoad.SelectedIndex + 1]));

                        tprvals.Add(RoundToSignificantDigits(Math.Abs(Convert.ToDouble(data[ff][pltoadindex])) / Normval, 4));
                    }
                    else
                    {
                        tprvals.Add(RoundToSignificantDigits(Math.Abs(Convert.ToDouble(data[ff][pltoadindex])), 4));
                    }
                    pltdepthlabels.Add(data[ff][0].ToString());
                }



                var chvals = tprvals.ToArray <double>();

                //YFormatter = value => value.ToString("C");

                plottpr.AxisX.Clear();

                plottpr.AxisX.Add(
                    new Axis
                {
                    Labels = pltdepthlabels.ToArray()
                }
                    );
                //Labels = pltdepthlabels.ToArray();

                DataContext = this;

                SeriesCollection.Add(new LineSeries
                {
                    Title             = "OAD - " + Convert.ToString(plotOADsdb[f - 1]),
                    Values            = chvals.AsChartValues(), //new ChartValues<double> {  },
                    DataLabels        = true,
                    LineSmoothness    = 0,                      //0: straight lines, 1: really smooth lines
                    PointGeometry     = null,                   //Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"),
                    PointGeometrySize = 50,
                    PointForeground   = Brushes.Gray
                });
            }


            // Plot profile
            for (int g = 1; g < plotdepths.Count() + 1; g++)
            {
                var oadvals      = new List <double>();
                var pltoadlabels = new List <string> {
                };

                var pltdpindex = plotdepths[g - 1];

                for (int gg = 1; gg < colnum / 3 + 1; gg++)
                {
                    if (Normalizebox.IsChecked.Value == true)
                    {
                        var Normval = Math.Abs(Convert.ToDouble(data[Normdepth.SelectedIndex + 1][Normoad.SelectedIndex + 1]));

                        oadvals.Add(RoundToSignificantDigits(Math.Abs(Convert.ToDouble(data[pltdpindex][gg])) / Normval, 4));
                    }
                    else
                    {
                        oadvals.Add(RoundToSignificantDigits(Math.Abs(Convert.ToDouble(data[pltdpindex][gg])), 4));
                    }

                    pltoadlabels.Add(data[0][gg].ToString());
                }

                var chvals = oadvals.ToArray <double>();

                plotprofile.AxisX.Clear();

                plotprofile.AxisX.Add(
                    new Axis
                {
                    Labels = pltoadlabels.ToArray()
                }
                    );


                DataContext = this;


                SeriesCollection2.Add(new LineSeries
                {
                    Title             = "Depth - " + Convert.ToString(plotdepthsdb[g - 1]) + "cm",
                    Values            = chvals.AsChartValues(), //new ChartValues<double> {  },
                    DataLabels        = true,
                    LineSmoothness    = 0,                      //0: straight lines, 1: really smooth lines
                    PointGeometry     = null,                   //Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"),
                    PointGeometrySize = 50,
                    PointForeground   = Brushes.Gray
                });
            }
        }
Exemple #3
0
        public void DiagrammERInit()
        {
            var qry2 = from o in MonthUseERList
                       select new
            {
                o.FactCost,
                o.DifferenceCost,
                o.ResourceName
            };
            double Total     = qry2.Sum(n => n.FactCost);
            double TotalDiff = qry2.Sum(n => Math.Abs(n.DifferenceCost));

            var qry3 = from o in MonthUseERList
                       where o.FactCost >= Total * Proc / 100
                       orderby o.FactCost descending
                       select new
            {
                o.FactCost,
                o.ResourceName
            };
            var qry4 = from o in MonthUseERList
                       where o.FactCost < Total * Proc / 100
                       select new
            {
                o.FactCost,
                o.ResourceName
            };
            double Total1 = qry4.Sum(n => n.FactCost);

            var qry5 = from o in MonthUseERList
                       where Math.Abs(o.DifferenceCost) >= TotalDiff * Proc / 100
                       orderby o.DifferenceCost descending
                       select new
            {
                o.DifferenceCost,
                o.ResourceName
            };
            var qry6 = from o in MonthUseERList
                       where Math.Abs(o.DifferenceCost) < TotalDiff * Proc / 100
                       //orderby o.DifferenceCost descending
                       select new
            {
                o.DifferenceCost,
                o.ResourceName
            };
            double Total2 = qry6.Sum(n => n.DifferenceCost);

            SeriesCollection1.Clear();
            foreach (var newY in qry3.ToList())
            {
                PieSeries ps10 = new PieSeries
                {
                    Title      = newY.ResourceName,
                    DataLabels = true,
                    FontSize   = 10,
                    FontWeight = FontWeights.Bold,
                    LabelPoint = point => string.Format("{0},\r\n {1:N0}", newY.ResourceName, point.Y),
                    Values     = new ChartValues <ObservableValue> {
                        new ObservableValue(newY.FactCost)
                    }
                };
                SeriesCollection1.Add(ps10);
            }
            PieSeries ps2 = new PieSeries
            {
                Title      = "Прочие",
                DataLabels = true,
                FontSize   = 10,
                FontWeight = FontWeights.Bold,
                LabelPoint = point => string.Format("{0},\r\n {1:N0}", "Прочие", point.Y),
                Values     = new ChartValues <ObservableValue> {
                    new ObservableValue(Total1)
                }
            };

            SeriesCollection1.Add(ps2);

            SeriesCollection2.Clear();
            ColumnSeries ps1 = new ColumnSeries()
            {
                //LabelsPosition = BarLabelPosition.Parallel,
                //Fill = System.Windows.Media.Brushes.PowderBlue,
                DataLabels = true,
                FontSize   = 10,
                FontWeight = FontWeights.Bold,
                Values     = new ChartValues <ObservableValue>()
            };

            foreach (var newY in qry5.ToList())
            {
                ps1.Values.Add(new ObservableValue(newY.DifferenceCost));
            }
            ps1.Values.Add(new ObservableValue(Total2));
            SeriesCollection2.Add(ps1);

            LabelsER.Clear();
            foreach (var newX in qry5.ToList())
            {
                LabelsER.Add(newX.ResourceName.ToString());
            }
            ;
            LabelsER.Add("Прочие");

            //Labels = new ObservableCollection<string>(MonthUseList.Select(x => x.ResourceName));
            FormatterER = val => val.ToString("N0");
        }