private void RadChart1_LineSeriesSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { //Handle selection of the current point if (e.AddedPoints.Count > 0) { var addedPoint = e.AddedPoints[0]; var series = addedPoint.Presenter as LineSeries; //Get the Content Presenter of the series var pointPresenter = series. ChildrenOfType<ContentPresenter>(). Where(cp => cp.Tag == addedPoint).FirstOrDefault(); var ellipseElement = pointPresenter. ChildrenOfType<Ellipse>().FirstOrDefault(); //Do whatever you want with it :) ellipseElement.Fill = new SolidColorBrush(Colors.Red); } //Handle de-selection of the current point if (e.RemovedPoints.Count > 0) { var removedPoint = e.RemovedPoints[0]; var series = removedPoint.Presenter as LineSeries; var pointPresenter = series. ChildrenOfType<ContentPresenter>(). Where(cp => cp.Tag == removedPoint).FirstOrDefault(); var ellipseElement = pointPresenter. ChildrenOfType<Ellipse>().FirstOrDefault(); //Do whatever you want with it :) ellipseElement.Fill = new SolidColorBrush(Colors.Yellow); } }
/// <summary> /// Occurs when chart item selected (clicked). /// </summary> /// <param name="sender">The chart control that raised event.</param> /// <param name="e">The <see cref="ChartSelectionChangedEventArgs"/> instance.</param> private void ChartSelectionBehavior_OnSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { if (e.AddedPoints != null && e.AddedPoints.Count > 0) { ((ProcessMetricsGadgetChartTabViewModel)DataContext).ShowDrilDown(e.AddedPoints[0].Index); } }
private void PieChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { foreach (var dataPoint in ImportTypePieChart.Series[0].DataPoints) { //string countryName = ((CountryData)dataPoint.DataItem).Name; //if (!this.SelectableCountries.Contains(countryName)) //{ // dataPoint.IsSelected = false; //} } UpdateAll(PieChart.Series[0].DataPoints); }
private static void Behavior_SelectionChanged(object sender, ChartSelectionChangedEventArgs args) { if (isSyncingSelection) { return; } var collection = (IList)GetSelectedItems((ChartSelectionBehavior)sender); foreach (DataPoint point in args.RemovedPoints) { var dataItem = point.DataItem; collection.Remove(dataItem); } foreach (DataPoint point in args.AddedPoints) { var dataItem = point.DataItem; collection.Add(dataItem); } }
private void RadChart1_SelectionChanged(object sender, ChartSelectionChangedEventArgs e) { //Handle selection of the current point if (e.AddedPoints.Count > 0) { // Get the data point. var addedPoint = e.AddedPoints[0]; // Get the series. var series = addedPoint.Presenter as ScatterPointSeries; //Your code here... } //Handle de-selection of the current point if (e.RemovedPoints.Count > 0) { // Get the data point. var removedPoint = e.RemovedPoints[0]; // Get the series. var series = removedPoint.Presenter as ScatterPointSeries; //Your code here... } }
/// <summary> /// 趋势图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var chartSelectionBehavior = sender as ChartSelectionBehavior; if (chartSelectionBehavior != null) { var selectedPoint = chartSelectionBehavior.Chart.SelectedPoints.FirstOrDefault(); if (selectedPoint != null) { var maintainCostItem = selectedPoint.DataItem as MaintainCost; if (maintainCostItem != null) { var maintainCost = MaintainCostReports.FirstOrDefault(p => p.Annual.Year == maintainCostItem.Annual.Year); GenerateDetail(maintainCost); } } } }
/// <summary> /// 趋势图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { CurrentAirlines = _service.CurrentAirlines(); var chartSelectionBehavior = sender as ChartSelectionBehavior; if (chartSelectionBehavior != null) { var selectedPoint = chartSelectionBehavior.Chart.SelectedPoints.FirstOrDefault( p => { var categoricalSeries = p.Presenter as CategoricalSeries; return categoricalSeries != null && categoricalSeries.Visibility == Visibility.Visible; }); if (selectedPoint != null) { var fleetAircraftTrend = selectedPoint.DataItem as FleetAircraftTrend; if (fleetAircraftTrend != null && SelectedTime != fleetAircraftTrend.DateTime) { //选中时间点 SelectedTime = fleetAircraftTrend.DateTime; var time = Convert.ToDateTime(fleetAircraftTrend.DateTime).AddMonths(1).AddDays(-1); var aircraftListRoot = Aircrafts.Where( o => o.OperationHistories.Any( a => (a.AirlinesName.Equals(CurrentAirlines.CnName, StringComparison.OrdinalIgnoreCase)) && a.StartDate <= time && !(a.EndDate != null && a.EndDate < time)) && o.AircraftBusinesses.Any( a => a.StartDate <= time && !(a.EndDate != null && a.EndDate < time))).ToList(); AircraftCollection = _commonMethod.GetAircraftByTime(aircraftListRoot, time); #region 飞机运力XML文件的读写 var xmlConfig = XmlConfigs.FirstOrDefault( p => p.ConfigType.Equals("飞机运力", StringComparison.OrdinalIgnoreCase)); XElement airlineColor = null; var colorConfig = XmlConfigs.FirstOrDefault( p => p.ConfigType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase)); if (colorConfig != null && XElement.Parse(colorConfig.XmlContent) .Descendants("Type") .Any(p => p.Attribute("TypeName").Value.Equals("航空公司", StringComparison.OrdinalIgnoreCase))) { var firstOrDefault = XmlConfigs.FirstOrDefault( p => p.ConfigType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase)); if (firstOrDefault != null) airlineColor = XElement.Parse(firstOrDefault.XmlContent) .Descendants("Type") .FirstOrDefault( p => p.Attribute("TypeName") .Value.Equals("航空公司", StringComparison.OrdinalIgnoreCase)); } if (xmlConfig != null) { var aircraftList = new List<FleetAircraft>(); //飞机数饼图集合 var xelement = XElement.Parse(xmlConfig.XmlContent) .Descendants("DateTime") .FirstOrDefault(p => Convert.ToDateTime(p.Attribute("EndOfMonth").Value) == time); if (xelement != null) { foreach (var type in xelement.Descendants("Type")) { if (type.Attribute("TypeName") .Value.Equals("飞机数", StringComparison.OrdinalIgnoreCase)) { foreach (var item in type.Descendants("Item")) { var fleetAircraft = new FleetAircraft { Aircraft = item.Attribute("Name").Value, Amount = Convert.ToDecimal(item.Value), ToolTip = item.Value + " 架,占 " + item.Attribute("Percent").Value }; if (airlineColor != null) { var firstOrDefault = airlineColor.Descendants("Item") .FirstOrDefault(p => p.Attribute("Name") .Value.Equals(fleetAircraft.Aircraft, StringComparison.OrdinalIgnoreCase)); if (firstOrDefault != null) fleetAircraft.Color = firstOrDefault.Attribute("Color").Value; } if (fleetAircraft.Amount > 0) { aircraftList.Add(fleetAircraft); } } } } } FleetAircraftCollection = aircraftList; } #endregion } } } }
/// <summary> /// 发动机饼状图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RadPieChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var chartSelectionBehavior = sender as ChartSelectionBehavior; if (chartSelectionBehavior != null) { var radChartBase = chartSelectionBehavior.Chart; var selectedPoint = radChartBase.SelectedPoints.FirstOrDefault() as PieDataPoint; if (selectedPoint != null) { var items = ((RadLegend) _importTypePieGrid.Children[1]).Items; items.ToList().ForEach(p => p.IsHovered = false); foreach (var item in items) { if (item.Title.Equals(((FleetImportTypeComposition) selectedPoint.DataItem).ImportType, StringComparison.OrdinalIgnoreCase)) { item.IsHovered = true; break; } } if (radChartBase.EmptyContent.ToString().Equals("发动机引进方式分布", StringComparison.OrdinalIgnoreCase)) { GetGridViewDataSource(selectedPoint, _importTypeWindow, "发动机引进方式"); } } else { if (radChartBase.EmptyContent.ToString().Equals("发动机引进方式分布", StringComparison.OrdinalIgnoreCase)) { _importTypeWindow.Close(); } } } }
private void Target_SelectionChanged(object sender, ChartSelectionChangedEventArgs e) { RefreshContributionChart(e.SelectedIndex); }
/// <summary> /// 趋势图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var selectedPoint = ((ChartSelectionBehavior) sender).Chart.SelectedPoints.FirstOrDefault(p => { var categoricalSeries = p.Presenter as CategoricalSeries; return categoricalSeries != null && categoricalSeries.Visibility == Visibility.Visible; }); if (selectedPoint != null) { var fleetAgeTrend = selectedPoint.DataItem as FleetAgeTrend; if (fleetAgeTrend != null && (!SelectedTime.Equals(fleetAgeTrend.DateTime, StringComparison.OrdinalIgnoreCase) || !_selectedType.Equals(fleetAgeTrend.AircraftType, StringComparison.OrdinalIgnoreCase))) { //选中机型 _selectedType = fleetAgeTrend.AircraftType; //选中时间点 SelectedTime = fleetAgeTrend.DateTime; var time = Convert.ToDateTime(fleetAgeTrend.DateTime).AddMonths(1).AddDays(-1); CreateFleetAgeCollection(_selectedType, time); } } }
void ChartSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { _selectedChart = e.Chart; ChangeChartTypeSilent(); }
/// <summary> /// 趋势图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { CurrentAirlines = _service.CurrentAirlines(); var chartSelectionBehavior = sender as ChartSelectionBehavior; if (chartSelectionBehavior != null) { var selectedPoint = chartSelectionBehavior.Chart.SelectedPoints.FirstOrDefault(point => { var categoricalSeries = point.Presenter as CategoricalSeries; return categoricalSeries != null && categoricalSeries.Visibility == Visibility.Visible; }); if (selectedPoint != null) { var fleetAircraftTrend = selectedPoint.DataItem as FleetAircraftTrend; if (fleetAircraftTrend != null && SelectedTime != fleetAircraftTrend.DateTime) { #region 根据选中时间点过滤飞机数据 SelectedTime = fleetAircraftTrend.DateTime; var time = Convert.ToDateTime(fleetAircraftTrend.DateTime).AddMonths(1).AddDays(-1); var aircraftlist = 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.StartDate <= time && !(aircraftBusiness.EndDate != null && aircraftBusiness.EndDate < time))) .Where(aircraft => { var aircraftBusinessDataObject = aircraft.AircraftBusinesses.FirstOrDefault( aircraftBusiness => aircraftBusiness.StartDate <= time && !(aircraftBusiness.EndDate != null && aircraftBusiness.EndDate < time)); return aircraftBusinessDataObject != null && aircraftBusinessDataObject.Category.Equals("客机", StringComparison.OrdinalIgnoreCase); }).ToList(); AircraftCollection = _commonMethod.GetAircraftByTime(aircraftlist, time); #endregion #region 客机运力XML解析 var xmlConfig = XmlConfigs.FirstOrDefault( config => config.ConfigType.Equals("客机运力", StringComparison.OrdinalIgnoreCase)); XElement airlineColor = null; var colorConfig = XmlSettings.FirstOrDefault( config => config.SettingType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase)); if (colorConfig != null && XElement.Parse(colorConfig.SettingContent) .Descendants("Type") .Any( type => type.Attribute("TypeName") .Value.Equals("航空公司", StringComparison.OrdinalIgnoreCase))) { var xmlSettingDataObject = XmlSettings.FirstOrDefault( config => config.SettingType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase)); if (xmlSettingDataObject != null) airlineColor = XElement.Parse(xmlSettingDataObject.SettingContent) .Descendants("Type").FirstOrDefault( type => type.Attribute("TypeName") .Value.Equals("航空公司", StringComparison.OrdinalIgnoreCase)); } if (xmlConfig != null) { var aircraftList = new List<FleetAircraft>(); //飞机数饼图集合 var seatList = new List<FleetAircraft>(); //座位数饼图集合 var loadList = new List<FleetAircraft>(); //商载量饼图集合 var xelement = XElement.Parse(xmlConfig.ConfigContent) .Descendants("DateTime") .FirstOrDefault( dateTime => Convert.ToDateTime(dateTime.Attribute("EndOfMonth").Value) == time); if (xelement != null) { foreach (var type in xelement.Descendants("Type")) { if (type.Attribute("TypeName") .Value.Equals("飞机数", StringComparison.OrdinalIgnoreCase)) { foreach (var item in type.Descendants("Item")) { var fleetAircraft = new FleetAircraft { Aircraft = item.Attribute("Name").Value, Amount = Convert.ToDecimal(item.Value), ToolTip = item.Value + " 架,占 " + item.Attribute("Percent").Value }; if (airlineColor != null) { var firstOrDefault = airlineColor.Descendants("Item") .FirstOrDefault( aircraftItem => aircraftItem.Attribute("Name") .Value.Equals(fleetAircraft.Aircraft, StringComparison.OrdinalIgnoreCase)); if (firstOrDefault != null) fleetAircraft.Color = firstOrDefault.Attribute("Color").Value; } if (fleetAircraft.Amount > 0) { aircraftList.Add(fleetAircraft); } } } else if (type.Attribute("TypeName") .Value.Equals("座位数", StringComparison.OrdinalIgnoreCase)) { foreach (var item in type.Descendants("Item")) { var fleetAircraft = new FleetAircraft { Aircraft = item.Attribute("Name").Value, Amount = Convert.ToDecimal(item.Value), ToolTip = item.Value + " 座,占 " + item.Attribute("Percent").Value }; if (airlineColor != null) { var firstOrDefault = airlineColor.Descendants("Item").FirstOrDefault(aircraftItem => aircraftItem.Attribute("Name") .Value.Equals(fleetAircraft.Aircraft, StringComparison.OrdinalIgnoreCase)); if (firstOrDefault != null) fleetAircraft.Color = firstOrDefault.Attribute("Color").Value; } if (fleetAircraft.Amount > 0) { seatList.Add(fleetAircraft); } } } else if (type.Attribute("TypeName") .Value.Equals("商载量", StringComparison.OrdinalIgnoreCase)) { foreach (var item in type.Descendants("Item")) { var fleetAircraft = new FleetAircraft { Aircraft = item.Attribute("Name").Value, Amount = Convert.ToDecimal(item.Value), ToolTip = item.Value + " 吨,占 " + item.Attribute("Percent").Value }; if (airlineColor != null) { var firstOrDefault = airlineColor.Descendants("Item") .FirstOrDefault(aircraftItem => aircraftItem.Attribute("Name") .Value.Equals(fleetAircraft.Aircraft, StringComparison.OrdinalIgnoreCase)); if (firstOrDefault != null) fleetAircraft.Color = firstOrDefault.Attribute("Color").Value; } if (fleetAircraft.Amount > 0) { loadList.Add(fleetAircraft); } } } } } FleetAircraftCollection = aircraftList; FleetSeatCollection = seatList; FleetLoadCollection = loadList; } #endregion } } } }
/// <summary> /// 飞机饼状图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RadPieChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var chartSelectionBehavior = sender as ChartSelectionBehavior; if (chartSelectionBehavior != null) { var radChartBase = chartSelectionBehavior.Chart; var selectedPoint = radChartBase.SelectedPoints.FirstOrDefault() as PieDataPoint; var items = new LegendItemCollection(); switch (radChartBase.EmptyContent.ToString()) { case "飞机数分布": items = ((RadLegend) _aircraftPieGrid.Children[1]).Items; break; case "座位数分布": items = ((RadLegend) _seatPieGrid.Children[1]).Items; break; case "商载量分布": items = ((RadLegend) _loadPieGrid.Children[1]).Items; break; } if (selectedPoint != null) { items.ToList().ForEach(p => p.IsHovered = false); foreach (var item in items) { if (item.Title.Equals(((FleetAircraft) selectedPoint.DataItem).Aircraft, StringComparison.OrdinalIgnoreCase)) { item.IsHovered = true; break; } } switch (radChartBase.EmptyContent.ToString()) { case "飞机数分布": GetGridViewDataSourse(selectedPoint, _aircraftWindow, "飞机数"); break; case "座位数分布": GetGridViewDataSourse(selectedPoint, _seatWindow, "座位数"); break; case "商载量分布": GetGridViewDataSourse(selectedPoint, _loadWindow, "商载量"); break; } } else { switch (radChartBase.EmptyContent.ToString()) { case "飞机数分布": _aircraftWindow.Close(); break; case "座位数分布": _seatWindow.Close(); break; case "商载量分布": _loadWindow.Close(); break; } } } }
/// <summary> /// 趋势图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var selectedPoint = ((ChartSelectionBehavior) sender).Chart.SelectedPoints.FirstOrDefault( p => ((CategoricalSeries) p.Presenter).Visibility == Visibility.Visible); if (selectedPoint != null) { var fleetAircraftRegionalTrend = selectedPoint.DataItem as FleetAircraftRegionalTrend; if (fleetAircraftRegionalTrend != null && SelectedTime != fleetAircraftRegionalTrend.DateTime) { //选中时间点 SelectedTime = fleetAircraftRegionalTrend.DateTime; var time = Convert.ToDateTime(fleetAircraftRegionalTrend.DateTime).AddMonths(1).AddDays(-1); ChartSelectionBehaviorSelection(time); } } }
private void ChartSelectionBehavior_SelectionChanged(object sender, ChartSelectionChangedEventArgs e) { if (e.AddedPoints.Count > 0) { this.SelectItem(e.AddedPoints[0].DataItem); } }
/// <summary> /// 飞机饼状图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RadPieChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var radChartBase = ((ChartSelectionBehavior) sender).Chart; var selectedPoint = radChartBase.SelectedPoints.FirstOrDefault() as PieDataPoint; var items = new LegendItemCollection(); if (radChartBase.EmptyContent.ToString().Equals("座级分布", StringComparison.OrdinalIgnoreCase)) { items = ((RadLegend) _regionalPieGrid.Children[1]).Items; } else if (radChartBase.EmptyContent.ToString().Equals("机型分布", StringComparison.OrdinalIgnoreCase)) { items = ((RadLegend) _typePieGrid.Children[1]).Items; } if (selectedPoint != null) { items.ToList().ForEach(p => p.IsHovered = false); foreach (var item in items) { if (item.Title.Equals(((FleetAircraftTypeComposition) selectedPoint.DataItem).AircraftRegional, StringComparison.OrdinalIgnoreCase)) { item.IsHovered = true; break; } } if (radChartBase.EmptyContent.ToString().Equals("座级分布", StringComparison.OrdinalIgnoreCase)) { GetGridViewDataSourse(selectedPoint, _regionalWindow, "座级"); } else if (radChartBase.EmptyContent.ToString().Equals("机型分布", StringComparison.OrdinalIgnoreCase)) { GetGridViewDataSourse(selectedPoint, _typeWindow, "机型"); } } else { if (radChartBase.EmptyContent.ToString().Equals("座级分布", StringComparison.OrdinalIgnoreCase)) { _regionalWindow.Close(); } else if (radChartBase.EmptyContent.ToString().Equals("机型分布", StringComparison.OrdinalIgnoreCase)) { _typeWindow.Close(); } } }
/// <summary> /// 趋势图的选择点事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ChartSelectionBehaviorSelectionChanged(object sender, ChartSelectionChangedEventArgs e) { var chartSelectionBehavior = sender as ChartSelectionBehavior; if (chartSelectionBehavior != null) { var selectedPoint = chartSelectionBehavior.Chart.SelectedPoints.FirstOrDefault(p => { var categoricalSeries = p.Presenter as CategoricalSeries; return categoricalSeries != null && categoricalSeries.Visibility == Visibility.Visible; }); if (selectedPoint != null) { var fleetImportTypeTrend = selectedPoint.DataItem as FleetImportTypeTrend; if (fleetImportTypeTrend != null && SelectedTime != fleetImportTypeTrend.DateTime) { //选中时间点 SelectedTime = fleetImportTypeTrend.DateTime; var time = Convert.ToDateTime(fleetImportTypeTrend.DateTime).AddMonths(1).AddDays(-1); ChartSelectionBehaviorSelection(time); } } } }