void BuildLegendCore(Telerik.WinControls.UI.ChartView view) { layout.Children.Clear(); if (view.AreaType == ChartAreaType.Cartesian) { foreach (Telerik.WinControls.UI.ChartSeries series in view.Series) { Color color; if (series is LineSeries) { color = series.BorderColor; } else { color = series.Children[0].BackColor; } layout.Children.Add(new LegendItemElement(series.Name, color)); } } if (view.AreaType == ChartAreaType.Pie && view.Series.Count > 0) { for (int i = 0; i < view.Series[0].DataPoints.Count; i++) { Color color = view.Series[0].Children[i].BackColor; PieDataPoint point = view.Series[0].DataPoints[i] as PieDataPoint; layout.Children.Add(new LegendItemElement(point.Name, color)); } } }
public void PieSeriesWithOneDouble() { KeyValuePair <string, double>[] objects = new KeyValuePair <string, double>[] { new KeyValuePair <string, double>("A", 90000.0) }; Chart chart = new Chart(); DataPointSeries pieSeries = DefaultSeriesToTest; chart.Series.Add(pieSeries); pieSeries.IndependentValueBinding = new Binding("Key"); pieSeries.DependentValueBinding = new Binding("Value"); TestAsync( chart, () => pieSeries.ItemsSource = objects, () => Assert.AreEqual(1, chart.LegendItems.Cast <object>().Count()), () => { IList <PieDataPoint> pieDataPoints = ChartTestUtilities.GetDataPointsForSeries(pieSeries).Cast <PieDataPoint>().ToList(); Assert.AreEqual(1, pieDataPoints.Count); PieDataPoint pieDataPoint = pieDataPoints[0]; Assert.IsNotNull(pieDataPoint.Geometry); Assert.AreSame(typeof(EllipseGeometry), pieDataPoint.Geometry.GetType()); Assert.IsNotNull(pieDataPoint.GeometryHighlight); Assert.AreSame(typeof(EllipseGeometry), pieDataPoint.GeometryHighlight.GetType()); Assert.IsNotNull(pieDataPoint.GeometrySelection); Assert.AreSame(typeof(EllipseGeometry), pieDataPoint.GeometrySelection.GetType()); }); }
private void GetAllExpensesThisMonth() { _expeditures = null; _displayExpeditures.Clear(); _expenseByCategories.Clear(); ExpensePieSeries.DataPoints.Clear(); _totalSpending = 0; _expeditures = _expeditureAccess.GetByMonth(StringManipulation.MonthFilter(StringManipulation.CurrentMonth())); if (_expeditures == null) return; _techCruncher.CrunchExpenses(_expeditures,_expenseByCategories); foreach (var expenseByCategory in _expenseByCategories) { var x = new PieDataPoint { Label = expenseByCategory.Category + "(" + expenseByCategory.Amount + ")", Value = expenseByCategory.Amount }; ExpensePieSeries.DataPoints.Add(x); } foreach (var expediture in _expeditures) { if (expediture.ExTypeId != 1) { expediture.Additional1 = expediture.Account().AccName; expediture.Additional2 =_techCruncher.GetExpeditureLabel(expediture); NightCore.TotalExpediture = _totalSpending += StringManipulation.GetDoubleFromString(expediture.ExAmount.ToString()); _displayExpeditures.Add(expediture); } } ExpenseTransactions.ItemsSource = _displayExpeditures; ExpenseAmount.Text = _totalSpending.ToString("##,###"); CurrencySymbol.Text = NightCore.CurrencySymbol; }
internal override void ArrangeLabel(FrameworkElement visual, ChartSeriesLabelUpdateContext context) { RadSize size = MeasureVisual(visual); PieDataPoint piePoint = context.Point as PieDataPoint; double radius = this.updateContext.Radius; double offsetFromCenter = radius * piePoint.OffsetFromCenter; double offset = context.Definition.Margin.Left; // calculate the position of the label, depending on its size this.updateContext.Radius = radius - offset + offsetFromCenter; this.updateContext.StartAngle = piePoint.startAngle; double angle = piePoint.startAngle; if (this.AngleRange.SweepDirection == ChartSweepDirection.Clockwise) { angle += piePoint.sweepAngle / 2; } else { angle -= piePoint.sweepAngle / 2; } Point middlePoint = this.updateContext.CalculateArcPoint(angle); middlePoint.X += size.Width * Math.Cos(angle * RadMath.DegToRadFactor) / 2; middlePoint.Y += size.Height * Math.Sin(angle * RadMath.DegToRadFactor) / 2; RadRect labelRect = RadRect.Round(new RadRect(middlePoint.X - (size.Width / 2), middlePoint.Y - (size.Height / 2), size.Width, size.Height)); this.ArrangeUIElement(visual, labelRect); this.updateContext.Radius = radius; }
/// <summary> /// 初始化pie /// </summary> private void InitializePie(List <KeyValuePair <double, object> > data) { this.rcv_percent.AreaType = ChartAreaType.Pie; this.rcv_percent.ChartElement.View.ForeColor = Color.White; PieSeries pie = new PieSeries(); pie.ValueMember = "Value"; pie.LabelMode = PieLabelModes.Horizontal; pie.ShowLabels = true; pie.ForeColor = Color.White; if (data.Count == 0) { data.Add(new KeyValuePair <double, object>(0, "")); } foreach (KeyValuePair <double, object> dataItem in data) { PieDataPoint point = new PieDataPoint(dataItem.Key, dataItem.Value.ToString()); point.Label = Transformation(dataItem.Value.ToString()) + "(" + dataItem.Key.ToString() + ")"; pie.DataPoints.Add(point); } this.rcv_percent.Series.Add(pie); this.rcv_percent.ShowLegend = false; }
private void ChartSelectionBehavior_SelectionChanged(object sender, ChartSelectionChangedEventArgs e) { DataPoint tmppp = new PieDataPoint(); foreach (DataPoint info in e.AddedPoints) { tmppp = info; } if (tmppp == null) { return; } var abc = tmppp.DataItem as Data;//.Label.ToString() ; if (abc == null) { return; } //tb3.Text = abc.Category + " " + abc.Value; var lst = new object[3]; lst[0] = abc.Date; lst[1] = abc.IsRtu; lst[2] = abc.Category; //RegionManage.ShowViewByIdAttachRegionWithArgu(Wlst.Ux.About.Services.ViewIdAssign.UxThreeLvViewId, lst); }
private void UpdadateOffsetFromCenter(PieDataPoint point) { if (point != null) { point.OffsetFromCenter = point.IsSelected ? 0.1 : 0; } }
private void UpdateSegmentStyle(PieDataPoint point, PieSegment segment, int index) { segment.isDefaultStyle = false; segment.HighlightPath.Fill = this.HighlightBrush; if (this.segmentStyleSelectorCache != null) { Style style = this.segmentStyleSelectorCache.SelectStyle(point, this); if (style != null) { segment.Path.Style = style; return; } } if (this.segmentStyles.Count > 0) { Style style = this.segmentStyles[index % this.segmentStyles.Count]; if (style != null) { segment.Path.Style = style; return; } } segment.Path.Style = this.defaultSegmentStyleCache; segment.isDefaultStyle = true; }
private void GetAllIncomesThisMonth() { _incomes = null; _displayIncomes.Clear(); _incomeByCategories.Clear(); IncomePieSeries.DataPoints.Clear(); _totalIncome = 0; _incomes = _incomeAccess.GetByMonth(StringManipulation.MonthFilter(StringManipulation.CurrentMonth())); if (_incomes == null) return; _techCruncher.CrunchIncomes(_incomes,_incomeByCategories); foreach (var income in _incomeByCategories) { var x = new PieDataPoint { Label = income.Category +"("+income.Amount+")", Value = income.Amount }; IncomePieSeries.DataPoints.Add(x); } foreach (var income in _incomes) { if (income.InTypeId != 1) { income.Additional1 = income.Account().AccName; income.Additional2 = _techCruncher.GetIncomeLabel(income); NightCore.TotalIncome = _totalIncome += StringManipulation.GetDoubleFromString(income.InAmount.ToString()); _displayIncomes.Add(income); } } IncomeTransactions.ItemsSource = _displayIncomes; IncomeAmount.Text = _totalIncome.ToString("##,###"); CurrencySymbol.Text = NightCore.CurrencySymbol; }
public override void Render(PieDataPoint point) { double percent = double.Parse(point.Percentage.ToString()); txtLabel.SetText(String.Format("{0}: {1:p0}", point.Name, percent), TextView.BufferType.Normal); RequestLayout(); }
public void LegendItemDataPointHasDataContextSet() { Chart chart = new Chart(); PieSeries series = DefaultControlToTest as PieSeries; series.DependentValueBinding = new Binding("Value"); series.IndependentValueBinding = new Binding("Value"); NotifyingDataObject <int> notifyingDataObjectA = new NotifyingDataObject <int> { Value = 5 }; NotifyingDataObject <int> notifyingDataObjectB = new NotifyingDataObject <int> { Value = 7 }; NotifyingDataObject <int>[] notifyingDataObjects = new NotifyingDataObject <int>[] { notifyingDataObjectA, notifyingDataObjectB }; series.ItemsSource = notifyingDataObjects; chart.Series.Add(series); TestAsync( chart, () => { LegendItem[] legendItems = ChartTestUtilities.GetLegend(chart).Items.OfType <LegendItem>().ToArray(); Assert.AreEqual(notifyingDataObjects.Length, legendItems.Length); for (int i = 0; i < notifyingDataObjects.Length; i++) { PieDataPoint legendItemDataPoint = legendItems[i].DataContext as PieDataPoint; Assert.IsNotNull(legendItemDataPoint); Assert.AreEqual(notifyingDataObjects[i], legendItemDataPoint.DataContext); } }); }
private void InitializePie() { this.radChartView1.AreaType = ChartAreaType.Pie; this.radChartView2.AreaType = ChartAreaType.Pie; PieSeries pie = new PieSeries(); pie.LabelMode = PieLabelModes.Horizontal; pie.ShowLabels = true; pie.DrawLinesToLabels = this.radCheckBox1.Checked; pie.SyncLinesToLabelsColor = this.radCheckBox3.Checked; PieSeries smartPie = new PieSeries(); smartPie.LabelMode = PieLabelModes.Horizontal; smartPie.ShowLabels = true; smartPie.DrawLinesToLabels = this.radCheckBox1.Checked; smartPie.SyncLinesToLabelsColor = this.radCheckBox3.Checked; foreach (KeyValuePair <double, object> dataItem in this.data.GetPieData()) { PieDataPoint point = new PieDataPoint(dataItem.Key, dataItem.Value.ToString()); point.Label = dataItem.Value.ToString(); pie.DataPoints.Add(point); point = new PieDataPoint(dataItem.Key, dataItem.Value.ToString()); point.Label = dataItem.Value.ToString(); smartPie.DataPoints.Add(point); } this.radChartView1.Series.Add(pie); this.radChartView2.Series.Add(smartPie); this.radCheckBox1.Checked = true; }
private void UpdatePie(string rootDirectory, int depth, bool showFiles) { if (!Directory.Exists(rootDirectory) && !File.Exists(rootDirectory)) { return; } var dataPoints = new FileSystemEnumerable <PieDataPoint>(rootDirectory, (ref FileSystemEntry entry) => CreateDataPoint(ref entry, depth), new EnumerationOptions() { RecurseSubdirectories = true, AttributesToSkip = 0 }) { ShouldRecursePredicate = (ref FileSystemEntry entry) => GetDepth(ref entry) < depth, ShouldIncludePredicate = (ref FileSystemEntry entry) => showFiles || entry.IsDirectory }; if (!showFiles) { var dataPoint = new PieDataPoint(GetDirectorySize(rootDirectory, recurse: depth == 0), "."); dataPoint.Label = String.Empty; this.pieSeries.DataPoints.Add(dataPoint); } foreach (var dataPoint in dataPoints) { dataPoint.Label = String.Empty; this.pieSeries.DataPoints.Add(dataPoint); } }
public void RatioChangeDouble() { PieDataPoint dataPoint = DefaultControlToTest as PieDataPoint; double ratio = 1.2; dataPoint.Ratio = ratio; Assert.AreEqual(ratio, dataPoint.Ratio); }
public void ActualOffsetRatioChangeDouble() { PieDataPoint dataPoint = DefaultControlToTest as PieDataPoint; double actualOffsetRatio = 1.2; dataPoint.ActualOffsetRatio = actualOffsetRatio; Assert.AreEqual(actualOffsetRatio, dataPoint.ActualOffsetRatio); }
internal static bool HitTestValid(PieDataPoint point, Rect touchRect) { if (point == null) { return(false); } return(point.ContainsRect(touchRect)); }
internal void Update(PieDataPoint dataPoint, PieUpdateContext context) { this.UpdateCore(dataPoint, context); this.point = dataPoint; // tag is used for hit-testing purposes this.Path.Tag = dataPoint; }
public static Geometry Render(PieDataPoint dataPoint, DoughnutSegmentData context) { if (dataPoint.SweepAngle >= ArcSegmentMaxAngle) { return(RenderEllipse(context)); } else { return(RenderArc(context)); } }
public void RatioStringFormatChange() { PieDataPoint dataPoint = DefaultControlToTest as PieDataPoint; double ratio = 0.12345; TestAsync( dataPoint, () => dataPoint.Ratio = ratio, () => Assert.AreEqual(ratio, dataPoint.Ratio), () => Assert.AreEqual(ratio.ToString("p2", CultureInfo.CurrentCulture), dataPoint.FormattedRatio), () => dataPoint.RatioStringFormat = "{0}", () => Assert.AreEqual(ratio.ToString(CultureInfo.CurrentCulture), dataPoint.FormattedRatio)); }
private static DoughnutSegmentData GetSegmentData(PieDataPoint dataPoint, DoughnutUpdateContext context) { var centerPoint = GetCenterPointWithOffset(dataPoint, context); return(new DoughnutSegmentData() { Center = new RadPoint(centerPoint.X, centerPoint.Y), Radius1 = context.Radius, Radius2 = context.InnerRadiusFactor * context.Radius, StartAngle = context.StartAngle, SweepAngle = dataPoint.SweepAngle, SweepDirection = context.SweepDirection }); }
private void InitializePieChart() { PieDataPoint point; PieSeries pieSeries = new PieSeries(); for (int i = 0; i < 6; i++) { point = new PieDataPoint(); point.Value = 60; pieSeries.DataPoints.Add(point); } this.radChartView2.Series.Add(pieSeries); }
private void UpdateHighlightPath(PieDataPoint dataPoint, PieUpdateContext updateContext) { DoughnutSegmentData segment = new DoughnutSegmentData() { Center = new RadPoint(updateContext.Center.X, updateContext.Center.Y), Radius1 = updateContext.Radius, Radius2 = updateContext.Radius * this.ParentSeries.HighlightInnerRadiusFactor, StartAngle = updateContext.StartAngle, SweepAngle = dataPoint.SweepAngle, SweepDirection = updateContext.SweepDirection }; this.highlightPath.Data = DoughnutSegmentRenderer.Render(dataPoint, segment); }
internal void BuildArc(PieDataPoint dataPoint, PieUpdateContext updateContext) { if (this.figure == null) { return; } Point originalCenter = updateContext.Center; updateContext.Center = GetCenterPointWithOffset(dataPoint, updateContext); this.figure.StartPoint = updateContext.Center; this.UpdateHighlightPath(dataPoint, updateContext); // first line LineSegment line1 = new LineSegment(); line1.Point = updateContext.CalculateArcPoint(updateContext.StartAngle); this.figure.Segments.Add(line1); // arc ArcSegment arc = new ArcSegment(); arc.IsLargeArc = dataPoint.SweepAngle > 180 || dataPoint.SweepAngle < -180; arc.Size = updateContext.ArcSize; arc.SweepDirection = dataPoint.SweepAngle > 0 ? updateContext.SweepDirection : updateContext.SweepDirection ^ SweepDirection.Clockwise; // advance the starting angle if (updateContext.SweepDirection == SweepDirection.Clockwise) { updateContext.StartAngle += dataPoint.SweepAngle; } else { updateContext.StartAngle -= dataPoint.SweepAngle; } arc.Point = updateContext.CalculateArcPoint(updateContext.StartAngle); this.figure.Segments.Add(arc); // second line LineSegment line2 = new LineSegment(); line2.Point = updateContext.Center; this.figure.Segments.Add(line2); updateContext.Center = originalCenter; }
private void UpdateDataPoint(PieDataPoint point) { if (point != null) { if (point.IsSelected) { point.OffsetFromCenter = 0.1; point.Label = FormatDataPoint(point); } else { point.OffsetFromCenter = 0; point.Label = String.Empty; } } }
void UpdateSelectedPoint(DataPoint point) { PieDataPoint pieDataPoint = point as PieDataPoint; if (pieDataPoint != null) { if (pieDataPoint.IsSelected) { pieDataPoint.OffsetFromCenter = 0.1; } else { pieDataPoint.OffsetFromCenter = 0; } } }
public override void InitialValues() { base.InitialValues(); double value = 0.0; PieDataPoint dataPoint = DefaultControlToTest as PieDataPoint; Assert.AreEqual(value, dataPoint.Ratio); Assert.AreEqual(value, dataPoint.ActualRatio); Assert.AreEqual(value, dataPoint.OffsetRatio); Assert.AreEqual(value, dataPoint.ActualOffsetRatio); Assert.IsNull(dataPoint.Geometry); Assert.IsNull(dataPoint.GeometryHighlight); Assert.IsNull(dataPoint.GeometrySelection); TestAsync( dataPoint, () => Assert.AreEqual("{0:p2}", dataPoint.RatioStringFormat), () => Assert.AreEqual(value.ToString("p2", CultureInfo.CurrentCulture), dataPoint.FormattedRatio)); }
protected virtual void UpdateCore(PieDataPoint dataPoint, PieUpdateContext context) { if (this.figure != null) { this.figure.Segments.Clear(); if (dataPoint.SweepAngle >= ArcSegmentMaxAngle) { this.AddEllipse(context); } else { this.BuildArc(dataPoint, context); } dataPoint.Radius = context.Radius; dataPoint.CenterPoint = context.Center; } }
/// <summary> /// Adds the labels to each of its PieDataPoints. /// </summary> protected override void OnAfterUpdateDataPoints() { LabeledPieChart chart = this.SeriesHost as LabeledPieChart; if (chart != null) { Panel labelArea = TreeHelper.FindDescendent(chart, "LabelArea_PART") as Panel; if (labelArea != null && this.ItemsSource != null) { foreach (object dataItem in this.ItemsSource) { PieDataPoint pieDataPoint = this.GetDataPoint(dataItem) as PieDataPoint; if (pieDataPoint != null) { this.AddLabelPieDataPoint(pieDataPoint, labelArea); } } } } }
internal static Point GetCenterPointWithOffset(PieDataPoint dataPoint, PieUpdateContext context) { double offset = dataPoint.OffsetFromCenter; if (offset == 0) { return(context.Center); } double pixelOffset = (int)(context.Radius * offset); double originalRadius = context.Radius; context.Radius = pixelOffset; Point centerWithOffset = context.CalculateArcPoint(context.StartAngle + (dataPoint.sweepAngle / 2)); context.Radius = originalRadius; return(centerWithOffset); }
/// <summary> /// Adds the labels to each of its PieDataPoints. /// </summary> protected override void OnAfterUpdateDataPoints() { LabeledPieChart chart = this.SeriesHost as LabeledPieChart; if (chart != null) { Canvas labelArea = chart.Template.FindName("LabelArea_PART", chart) as Canvas; if (labelArea != null && this.ItemsSource != null) { foreach (object dataItem in this.ItemsSource) { PieDataPoint pieDataPoint = this.GetDataPoint(dataItem) as PieDataPoint; if (pieDataPoint != null) { this.AddLabelPieDataPoint(pieDataPoint, labelArea); } } } } }
private static void IsLabeledPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { bool isLabeled = (bool)e.NewValue; if (isLabeled == true) { PieDataPoint pieDataPoint = obj as PieDataPoint; if (pieDataPoint != null) { Chart chart = TreeHelper.FindAncestor <Chart>(pieDataPoint.Parent as DependencyObject); if (chart != null) { Canvas labelArea = chart.Template.FindName("LabelArea_PART", chart) as Canvas; if (labelArea != null) { AddLabel(pieDataPoint, labelArea); } } } } }
protected override void UpdateCore(PieDataPoint dataPoint, PieUpdateContext context) { var doughnutContext = context as DoughnutUpdateContext; if (doughnutContext != null) { var segmentData = DoughnutSegment.GetSegmentData(dataPoint, doughnutContext); var highlightSegmentData = DoughnutSegment.GetSegmentData(dataPoint, doughnutContext); highlightSegmentData.Radius2 = 0.9 * context.Radius; if (context.SweepDirection == SweepDirection.Clockwise) { context.StartAngle += dataPoint.SweepAngle; } else { context.StartAngle -= dataPoint.SweepAngle; } this.Path.Data = DoughnutSegmentRenderer.Render(dataPoint, segmentData); this.HighlightPath.Data = DoughnutSegmentRenderer.Render(dataPoint, highlightSegmentData); var doughnutPoint = dataPoint as DoughnutDataPoint; if (doughnutPoint != null) { doughnutPoint.Radius = doughnutContext.Radius; doughnutPoint.InnerRadius = doughnutContext.Radius * doughnutContext.InnerRadiusFactor; doughnutPoint.CenterPoint = doughnutContext.Center; } } else { base.UpdateCore(dataPoint, context); } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radWindow">弹出窗体</param> /// <param name="header">窗体标示</param> protected void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radWindow, string header) { if (selectedItem != null && radWindow != null) { var fleetAircraftTypeComposition = selectedItem.DataItem as FleetAircraftTypeComposition; if (fleetAircraftTypeComposition != null) { var time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var aircraft = Aircrafts.Where(o => o.OperationHistories.Any( a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)) && o.AircraftBusinesses.Any( a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))); var airlineAircrafts = new List<AircraftDTO>(); if (header.Equals("座级", StringComparison.OrdinalIgnoreCase)) { airlineAircrafts = aircraft.Where(p => { var aircraftBusinessDto = p.AircraftBusinesses.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); return aircraftBusinessDto != null && aircraftBusinessDto.Regional.Equals(fleetAircraftTypeComposition.AircraftRegional, StringComparison.OrdinalIgnoreCase); }).ToList(); } else if (header.Equals("机型", StringComparison.OrdinalIgnoreCase)) { airlineAircrafts = aircraft.Where(p => { var aircraftBusinessDto = p.AircraftBusinesses.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); return aircraftBusinessDto != null && aircraftBusinessDto.AircraftTypeName.Equals( fleetAircraftTypeComposition.AircraftRegional, StringComparison.OrdinalIgnoreCase); }).ToList(); } //找到子窗体的RadGridView,并为其赋值 var rgv = radWindow.Content as RadGridView; if (rgv != null) rgv.ItemsSource = Commonmethod.GetAircraftByTime(airlineAircrafts, time); radWindow.Header = header + " " + fleetAircraftTypeComposition.AircraftRegional + ":" + fleetAircraftTypeComposition.AirTt; if (!radWindow.IsOpen) { Commonmethod.ShowRadWindow(radWindow); } } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="header">窗体标示</param> protected void GetGridViewDataSource(PieDataPoint selectedItem, RadWindow radWindow, string header) { if (selectedItem != null && radWindow != null) { var fleetImportTypeComposition = selectedItem.DataItem as FleetImportTypeComposition; if (fleetImportTypeComposition != null) { var time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var aircraft = Aircrafts.Where(o => o.OperationHistories.Any( a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))) .Where(o => { var operationHistoryDto = o.OperationHistories.FirstOrDefault( a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)); return operationHistoryDto != null && operationHistoryDto.ImportActionType.Equals("引进", StringComparison.OrdinalIgnoreCase); }); var airlineAircrafts = aircraft.Where(p => { var firstOrDefault = p.OperationHistories. FirstOrDefault( a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)); return firstOrDefault != null && SameImportType(firstOrDefault.ImportActionName, fleetImportTypeComposition.ImportType); }).ToList(); //找到子窗体的RadGridView,并为其赋值 var rgv = radWindow.Content as RadGridView; if (rgv != null) rgv.ItemsSource = Commonmethod.GetAircraftByTime(airlineAircrafts, time); radWindow.Header = header + " " + fleetImportTypeComposition.ImportType + ":" + fleetImportTypeComposition.AirTt; if (!radWindow.IsOpen) { Commonmethod.ShowRadWindow(radWindow); } } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="header">窗体标示</param> protected void GetGridViewDataSource(PieDataPoint selectedItem, RadWindow radwindow, string header) { if (selectedItem != null && radwindow != null) { //var fleetImporttTypeComposition = selectedItem.DataItem as FleetImportTypeComposition; //DateTime time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); //var engine = this.Engines.Where(o => o.OperationHistories.Any(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))) // .Where(o => o.OperationHistories.FirstOrDefault(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)).ImportCategory.ActionType .Equals( "引进"); //List<EngineDTO> engines = engine.Where(p => this.SameImportType(p.OperationHistories. // FirstOrDefault(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)).ImportCategory.ActionName, fleetImporttTypeComposition.ImportType)).ToList(); ////找到子窗体的RadGridView,并为其赋值 //RadGridView rgv = radwindow.Content as RadGridView; //rgv.ItemsSource = Commonmethod.GetEngineByTime(engines, time); //radwindow.Header = header + " " + fleetImporttTypeComposition.ImportType + ":" + fleetImporttTypeComposition.AirTt; //if (!radwindow.IsOpen) //{ // Commonmethod.ShowRadWindow(radwindow); //} } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radwindow">弹出窗体</param> /// <param name="header">窗体标示</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radwindow, string header) { if (selectedItem != null && radwindow != null) { FleetManufacturerComposition fleetmanufacturercomposition = selectedItem.DataItem as FleetManufacturerComposition; DateTime time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var aircraft = this.ViewAircraft.Where(o => o.OperationHistories.Any(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))); List<Aircraft> airlineAircrafts = aircraft.Where(p => p.AircraftType.Manufacturer.Name == fleetmanufacturercomposition.Manufacturer).ToList(); //找到子窗体的RadGridView,并为其赋值 RadGridView rgv = radwindow.Content as RadGridView; rgv.ItemsSource = commonmethod.GetAircraftByTime(airlineAircrafts, time); radwindow.Header = header + " " + fleetmanufacturercomposition.Manufacturer + ":" + fleetmanufacturercomposition.AirTt; if (!radwindow.IsOpen) { commonmethod.ShowRadWindow(radwindow); } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radWindow">弹出窗体</param> /// <param name="header">窗体标示</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radWindow, string header) { if (selectedItem != null && radWindow != null) { var fleetAircraft = selectedItem.DataItem as FleetAircraft; if (fleetAircraft != null) { var time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var aircraftData = Aircrafts.Where(aircraft => aircraft.OperationHistories.Any(operation => (operation.AirlinesName.Equals(CurrentAirlines.CnName, StringComparison.OrdinalIgnoreCase)) && operation.StartDate <= time && !(operation.EndDate != null && operation.EndDate < time)) && aircraft.AircraftBusinesses.Any(aircraftBusiness => aircraftBusiness.Category.Equals("客机", StringComparison.OrdinalIgnoreCase) && aircraftBusiness.StartDate <= time && !(aircraftBusiness.EndDate != null && aircraftBusiness.EndDate < time))); var airlineAircrafts = new List<AircraftDTO>(); if (fleetAircraft.Aircraft.Equals(CurrentAirlines.CnName, StringComparison.OrdinalIgnoreCase)) { //部分属性变化------------------ #region 筛选飞机数据 airlineAircrafts = aircraftData.Where(aircraft => { var aircraftbusiness = aircraft.AircraftBusinesses.FirstOrDefault( aircraftBusiness => aircraftBusiness.StartDate <= time && !(aircraftBusiness.EndDate != null && aircraftBusiness.EndDate < time)); if (aircraftbusiness == null) return false; if (!aircraftbusiness.Category.Equals("客机", StringComparison.OrdinalIgnoreCase)) return false; var operationHistory = aircraft.OperationHistories.FirstOrDefault( operation => operation.AirlinesName.Equals(CurrentAirlines.CnName, StringComparison.OrdinalIgnoreCase) && operation.StartDate <= time && !(operation.EndDate != null && operation.EndDate < time)); return operationHistory != null; }).ToList(); #endregion } //找到子窗体的RadGridView,并为其赋值 var radGridView = radWindow.Content as RadGridView; if (radGridView != null) radGridView.ItemsSource = _commonMethod.GetAircraftByTime(airlineAircrafts, time); radWindow.Header = fleetAircraft.Aircraft + header + ":" + fleetAircraft.ToolTip; if (!radWindow.IsOpen) { _commonMethod.ShowRadWindow(radWindow); } } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radwindow">弹出窗体</param> /// <param name="header">窗体标示</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radwindow, string header) { if (selectedItem != null && radwindow != null) { FleetSupplierComposition fleetsuppliercomposition = selectedItem.DataItem as FleetSupplierComposition; DateTime time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); //获取当前时间点的非自有供应商的飞机集合 var aircraft = this.ViewAircraft.Where(p => p.OperationHistories.Any(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)) && p.OwnershipHistorys.Any(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time))) .Where(p => SupplierNameList.Contains(p.OwnershipHistorys.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)).Owner.Name)); List<Aircraft> airlineAircrafts = aircraft.Where(p => p.OwnershipHistorys.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)).Owner.Name == fleetsuppliercomposition.Supplier).ToList(); //找到子窗体的RadGridView,并为其赋值 RadGridView rgv = radwindow.Content as RadGridView; rgv.ItemsSource = commonmethod.GetAircraftByTime(airlineAircrafts, time); radwindow.Header = header + " " + fleetsuppliercomposition.Supplier + ":" + fleetsuppliercomposition.AirTt; if (!radwindow.IsOpen) { commonmethod.ShowRadWindow(radwindow); } } }
/// <summary> /// Just going to test this chart out! /// An also how to use them :) /// </summary> private void MockData() { var mock = new List<MonthlyIncomeVsExpence>(); var incomeMock = new List<IncomeByCategory>(); var expenseMock = new List<ExpenseByCategory>(); var months = new [] {"Jan", "Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; var categories = new[] {"Salary", "Other", "Website Design","Report Form Generator","Updates","Upgrades"}; var categories2 = new[] {"Education", "Fast Food", "Transport", "Entertainment"}; var random = new Random(); foreach (var month in months) { var x = new MonthlyIncomeVsExpence { Month = month, Income = random.Next(1500, 15000), Expense = random.Next(27, 5500) }; mock.Add(x); } foreach (var category in categories) { var x = new IncomeByCategory {Amount = random.Next(1500, 5020), Category = category}; incomeMock.Add(x); } foreach (var s in categories2) { var x = new ExpenseByCategory { Amount = random.Next(1522, 7890), Category = s }; expenseMock.Add(x); } foreach (var incomeByCategory in incomeMock) { var x = new PieDataPoint { Label = incomeByCategory.Category, Value = incomeByCategory.Amount, //OffsetFromCenter=0.2 }; IncomePieSeries.DataPoints.Add(x); } foreach (var expenseByCategory in expenseMock) { var x = new PieDataPoint { Label = expenseByCategory.Category, Value = expenseByCategory.Amount, // OffsetFromCenter = 0.2 }; ExpensePieSeries.DataPoints.Add(x); } }
/// <summary> /// 所有飞机饼状图选择项 /// </summary> /// <param name="selectedItem">选中点</param> private void ShowtotalWindow(PieDataPoint selectedItem) { if (selectedItem != null) { AircraftStatistic selAc = selectedItem.DataItem as AircraftStatistic; //运营的飞机 IEnumerable<Aircraft> operationAircrafts = ViewAircraft.Where(p => p.Airlines.ShortName == selAc.AirlineName); //找到运营子窗体的RadGridView,并为ItemsSource赋值 RadGridView operationDetail = totalOpertationWindow.Content as RadGridView; operationDetail.ItemsSource = operationAircrafts; if (this.ViewPlan != null && allAirlinerPlanHistories != null) { //获取选择航空公司的计划历史 IEnumerable<PlanHistory> airlinePlanHistory = allAirlinerPlanHistories.Where(p => p.Plan.Airlines.ShortName == selAc.AirlineName && p.Annual.Year <= performYear).OrderBy(ob => ob.Annual.Year); //找到计划子窗体的RadGridView,并为ItemsSource赋值 RadGridView rd = totalPlanHistoryWindow.Content as RadGridView; if (airlinePlanHistory != null && airlinePlanHistory.Count() != 0) { rd.ItemsSource = airlinePlanHistory; } else { rd.ItemsSource = null; } } string selYear = string.IsNullOrWhiteSpace(TotalAirlineContent) || TotalAirlineContent.Length < 4 ? "0" : TotalAirlineContent.Substring(2, 4); //子窗体的标题 totalOpertationWindow.Header = selAc.AirlineName + "当前在运营:" + operationAircrafts.Count() + "架"; totalPlanHistoryWindow.Header = selAc.AirlineName + "至" + selYear + "年计划净增:" + selAc.IncreaseAmount + "架;期末份额: " + selAc.TotalAircraftNumberPercent + "%"; if (!totalOpertationWindow.IsOpen) { commonmethod.ShowRadWindow(totalOpertationWindow); } if (!totalPlanHistoryWindow.IsOpen) { commonmethod.ShowRadWindow(totalPlanHistoryWindow); } } }
/// <summary> /// 运营飞机饼状图选择项 /// </summary> /// <param name="selectedItem">选中点</param> private void ShowplanHistoryWindow(PieDataPoint selectedItem) { if (selectedItem != null) { if (this.ViewPlan != null && allAirlinerPlanHistories != null) { AircraftSeattingStatisticByYear selAc = selectedItem.DataItem as AircraftSeattingStatisticByYear; //获取选择航空公司的计划历史 IEnumerable<PlanHistory> airlinePlanHistory = allAirlinerPlanHistories.Where(p => p.Plan.Airlines.ShortName == selAc.AirlineName && p.AircraftType.AircraftCategory.Regional == selAc.SeattingType && p.Annual.Year == selAc.Year); //子窗体的标题 planHistoryWindow.Header = selAc.AirlineName + selAc.Year + "年" + selAc.SeattingType + "净增:" + selAc.AircraftAmount.ToString() + "架;份额: " + selAc.TotalAircraftNumberPercent + "%"; //找到子窗体的RadGridView,并为ItemsSource赋值 RadGridView rd = planHistoryWindow.Content as RadGridView; rd.ItemsSource = airlinePlanHistory; //计划历史子窗体打开 if (!planHistoryWindow.IsOpen) { commonmethod.ShowRadWindow(planHistoryWindow); } } } }
/// <summary> /// 运营飞机饼状图选择项 /// </summary> /// <param name="selectedItem">选中点</param> private void ShowOpertationHistoryWindow(PieDataPoint selectedItem) { if (selectedItem != null) { AircraftStatistic selAc = selectedItem.DataItem as AircraftStatistic; List<Aircraft> airlineAircrafts = ViewAircraft.Where(p => p.Airlines.ShortName == selAc.AirlineName).ToList(); opertationHistoryWindow.Header = selAc.AirlineName + "当前在运营:" + airlineAircrafts.Count.ToString() + "架;份额: " + selAc.TotalAircraftNumberPercent + "%"; //找到子窗体的RadGridView,并为ItemsSource赋值 RadGridView rd = opertationHistoryWindow.Content as RadGridView; rd.ItemsSource = airlineAircrafts; if (!opertationHistoryWindow.IsOpen) { commonmethod.ShowRadWindow(opertationHistoryWindow); } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radwindow">弹出窗体</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radwindow) { if (selectedItem != null && radwindow != null) { var time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var fleetAgeComposition = selectedItem.DataItem as FleetAgeComposition; //找到子窗体的RadGridView,并为其赋值 var rgv = radwindow.Content as RadGridView; if (fleetAgeComposition != null && (aircraftByAgeDic != null && aircraftByAgeDic.ContainsKey(fleetAgeComposition.AgeGroup))) { if (rgv != null) rgv.ItemsSource = CommonMethod.GetAircraftByTime( aircraftByAgeDic[fleetAgeComposition.AgeGroup], time); } if (fleetAgeComposition != null) _ageWindow.Header = "机龄 " + fleetAgeComposition.AgeGroup + "的飞机数:" + fleetAgeComposition.ToolTip; if (!radwindow.IsOpen) { CommonMethod.ShowRadWindow(radwindow); } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radwindow">弹出窗体</param> /// <param name="header">窗体标示</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radwindow, string header) { if (selectedItem != null && radwindow != null) { FleetAircraft fleetaircraft = selectedItem.DataItem as FleetAircraft; DateTime time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var aircraft = this.ViewAircraft.Where(o => o.OperationHistories.Any(a => (a.Airlines.ShortName == this._service.CurrentAirlines.ShortName || a.Airlines.SubType == 2) && a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)) && o.AircraftBusinesses.Any(a => a.AircraftType.AircraftCategory.Category == "货机" && a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))); List<Aircraft> airlineAircrafts = new List<Aircraft>(); if (fleetaircraft.Aircraft == this._service.CurrentAirlines.ShortName) { airlineAircrafts = aircraft.Where(p => { var aircraftbusiness = p.AircraftBusinesses.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); if (aircraftbusiness == null) return false; if (aircraftbusiness.AircraftType.AircraftCategory.Category != "货机") return false; var operationHistory = p.OperationHistories.FirstOrDefault(pp => pp.Airlines.ShortName == this._service.CurrentAirlines.ShortName && pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); if (operationHistory == null) { return false; } else if (operationHistory.SubOperationHistories.Count <= 0) { return true; } else { var suboperationCategory = operationHistory.SubOperationHistories.Where(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)); if (suboperationCategory == null || suboperationCategory.Count() == 0) return true; return suboperationCategory.Any(a => a.Airlines.ShortName == this._service.CurrentAirlines.ShortName); } }).ToList(); } else { //分子公司的筛选 var aircraftSubCompany = aircraft.Where(p => { var aircraftbusiness = p.AircraftBusinesses.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); if (aircraftbusiness == null) return false; if (aircraftbusiness.AircraftType.AircraftCategory.Category != "货机") return false; return p.OperationHistories.Any(pp => pp.Airlines.ShortName == fleetaircraft.Aircraft && pp.Airlines.SubType == 2 && pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); }).ToList(); //分公司的筛选 var aircraftFiliale = aircraft.Where(p => { var aircraftbusiness = p.AircraftBusinesses.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); if (aircraftbusiness == null) return false; if (aircraftbusiness.AircraftType.AircraftCategory.Category != "货机") return false; var operationHistory = p.OperationHistories.FirstOrDefault(pp => pp.Airlines.ShortName == this._service.CurrentAirlines.ShortName && pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)); if (operationHistory == null || operationHistory.SubOperationHistories.Count <= 0) { return false; } else { return operationHistory.SubOperationHistories.Any( a => a.Airlines.ShortName == fleetaircraft.Aircraft && a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)); } }).ToList(); airlineAircrafts = aircraftSubCompany.Union(aircraftFiliale).ToList(); }; //找到子窗体的RadGridView,并为其赋值 RadGridView rgv = radwindow.Content as RadGridView; rgv.ItemsSource = commonmethod.GetAircraftByTime(airlineAircrafts, time); radwindow.Header = fleetaircraft.Aircraft + header + ":" + fleetaircraft.ToolTip; if (!radwindow.IsOpen) { commonmethod.ShowRadWindow(radwindow); } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radwindow">弹出窗体</param> /// <param name="header">窗体标示</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radwindow, string header) { if (selectedItem != null && radwindow != null) { FleetAircraft fleetaircraft = selectedItem.DataItem as FleetAircraft; DateTime time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); var aircraft = this.ViewAircraft.Where(o => o.OperationHistories.Any(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)) && o.AircraftBusinesses.Any(a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))); List<Aircraft> airlineAircrafts = aircraft.Where(p => p.AircraftBusinesses.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)).AircraftType.AircraftCategory.Category == "客机" && p.OperationHistories.FirstOrDefault(pp => pp.StartDate <= time && !(pp.EndDate != null && pp.EndDate < time)).Airlines.ShortName == fleetaircraft.Aircraft).ToList(); //找到子窗体的RadGridView,并为其赋值 RadGridView rgv = radwindow.Content as RadGridView; rgv.ItemsSource = commonmethod.GetAircraftByTime(airlineAircrafts, time); radwindow.Header = fleetaircraft.Aircraft + header + ":" + fleetaircraft.ToolTip; if (!radwindow.IsOpen) { commonmethod.ShowRadWindow(radwindow); } } }
/// <summary> /// 根据选中饼图的航空公司弹出相应的数据列表窗体 /// </summary> /// <param name="selectedItem">选中点</param> /// <param name="radwindow">弹出窗体</param> /// <param name="header">窗体标示</param> private void GetGridViewDataSourse(PieDataPoint selectedItem, RadWindow radwindow, string header) { if (selectedItem != null && radwindow != null) { DateTime time = Convert.ToDateTime(SelectedTime).AddMonths(1).AddDays(-1); FleetAgeComposition fleetagecomposition = selectedItem.DataItem as FleetAgeComposition; //找到子窗体的RadGridView,并为其赋值 RadGridView rgv = radwindow.Content as RadGridView; if (this.AircraftByAgeDic != null && this.AircraftByAgeDic.ContainsKey(fleetagecomposition.AgeGroup)) { rgv.ItemsSource = commonmethod.GetAircraftByTime(AircraftByAgeDic[fleetagecomposition.AgeGroup], time); } AgeWindow.Header = fleetagecomposition.AgeGroup + "的飞机数:" + fleetagecomposition.ToolTip; if (!radwindow.IsOpen) { commonmethod.ShowRadWindow(radwindow); } } }