/// <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; }
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"); }