void chart_MouseMove(object sender, MouseEventArgs e) { Point position = e.GetPosition(ChartControl); ChartHitInfo hitInfo = ChartControl.CalcHitInfo(position); if (!hitInfo.InDiagram || hitInfo == null) { AnimationEnd(sender, position); } if (rotate && !IsClick(DateTime.Now)) { PieSeries2D series = ChartControl.Diagram.Series[0] as PieSeries2D; double angleDelta = CalcAngle(startPosition, position); if (Math.Abs(Rotate.Value + angleDelta) < 360) { Rotate.Value += angleDelta; } else if (Rotate.Value + angleDelta > 360) { Rotate.Value = -360; } else { Rotate.Value = 360; } startPosition = position; } }
void chart_MouseMove(object sender, MouseEventArgs e) { Point position = e.GetPosition(chart); ChartHitInfo hitInfo = chart.CalcHitInfo(position); if (hitInfo == null) { return; } if (rotate && !IsClick(DateTime.Now)) { PieSeries2D series = chart.Diagram.Series[0] as PieSeries2D; double angleDelta = CalcAngle(startPosition, position); if (Math.Abs(slRotation.Value + angleDelta) < 360) { slRotation.Value += angleDelta; } else if (slRotation.Value + angleDelta > 360) { slRotation.Value = -360; } else { slRotation.Value = 360; } startPosition = position; } }
public static ChartControl CreatPieChart(SolidColorBrush forecolor, string ChartTitle, List<ChartDataChartCommonData> dtchart) { mausac = 0; ChartControl abc = new ChartControl(); SimpleDiagram2D dg1 = new SimpleDiagram2D(); //liabc.Titles.Clear(); //Tao Tile cho Chart Title nt = new Title(); nt.Content = ChartTitle; nt.Foreground = forecolor; abc.Titles.Add(nt); //Tinh so Series List<string> countsr = (from p in dtchart group p by p.Series into g select g.Key).ToList(); //Creat Diagram abc.Diagram = dg1; GridControl dtl = new GridControl(); for (int i = 0; i < countsr.Count; i++) { PieSeries2D dgs1 = new PieSeries2D(); dgs1.HoleRadiusPercent = 0;//Thiet lap khoang trong tu tam hinh tron den duong tron dgs1.ArgumentScaleType = ScaleType.Auto; foreach (ChartDataChartCommonData dr in dtchart)//Tao cac point { if (dr.Series == countsr.ElementAt(i)) { //Tao Series SeriesPoint sr1 = new SeriesPoint(); sr1.Argument = dr.Agrument + ":" + dr.Value.ToString(); sr1.Value = dr.Value; sr1.Tag = mausac.ToString(); dgs1.Points.Add(sr1); mausac++; } } dgs1.Label = new SeriesLabel();//Tao Label cho Diagram PieSeries.SetLabelPosition(dgs1.Label, PieLabelPosition.TwoColumns); dgs1.Label.RenderMode = LabelRenderMode.RectangleConnectedToCenter; dgs1.LabelsVisibility = true;//Hien thi Lablel cho tung vung PointOptions pn1 = new PointOptions(); pn1.PointView = PointView.ArgumentAndValues; pn1.Pattern = "{A} ({V})";//Tao mau chu thich NumericOptions nbm1 = new NumericOptions();//Tao Kieu hien thi nbm1.Format = NumericFormat.Percent; pn1.ValueNumericOptions = nbm1; PieSeries2D.SetPercentOptions(pn1, new PercentOptions() { ValueAsPercent = true, PercentageAccuracy = 5 });//Quy dinh ty le phan tram chinh xac dgs1.PointOptions = pn1; dg1.Series.Add(dgs1); //Tao chu thich dgs1.LegendPointOptions = pn1; } abc.Legend = new Legend(); //End tao chu thich //Set mau sac cho seriespont abc.CustomDrawSeriesPoint += abc_CustomDrawSeriesPoint; return abc; }
void timer_Tick(object sender, EventArgs e) { if (chart.Diagram.Series[0].Points.Count > 0) { PieSeries2D.SetExplodedDistance(chart.Diagram.Series[0].Points[0], explodeDistance); UpdateChargeInfo(chart.Diagram.Series[0].Points[0]); } timer.Stop(); }
void UpdateSeries(Series series, int index) { if (series is BubbleSeries2D) { InitializeBubbleSeries(series as BubbleSeries2D); return; } else if (series is FinancialSeries2D) { InitializeFinancialSeries(series as FinancialSeries2D); XYDiagram2D diagram = chart.Diagram as XYDiagram2D; if (diagram != null) { AxisY2D.SetAlwaysShowZeroLevel(diagram.ActualAxisY.ActualWholeRange, false); } return; } if (series is PieSeries2D) { PieSeries2D pieSeries = series as PieSeries2D; if (!(pieSeries is NestedDonutSeries2D)) { pieSeries.HoleRadiusPercent = 0; } InitializePieSeries(pieSeries); return; } if (series is FunnelSeries2D) { InitializeFunnelSeries(series as FunnelSeries2D); return; } if (series is RangeBarSeries2D) { RangeBarSeries2D rangeBar = series as RangeBarSeries2D; InitializeRangeBarSeries(series as RangeBarSeries2D, index + 1); series.LabelsVisibility = false; if (rangeBar is RangeBarOverlappedSeries2D && index == 1) { rangeBar.BarWidth = 0.2; } return; } if (series is RangeAreaSeries2D) { InitializeRangeAreaSeries(series as RangeAreaSeries2D); return; } if (series is CircularSeries2D) { InitializePolarSeries(series as CircularSeries2D); return; } InitializeSeries(series, index + 1); }
static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!(e.NewValue is double)) { return; } PieSeries2D ps = d as PieSeries2D; if (ps == null) { return; } ps.Points.Clear(); ps.Points.Add(new SeriesPoint { Value = (double)e.NewValue, Argument = "Missing" }); ps.Points.Add(new SeriesPoint { Value = 1, Argument = "EnteredAnotherStation" }); ps.Points.Add(new SeriesPoint { Value = 1, Argument = "Entered" }); }
public static ChartControl CreatPieChart(SolidColorBrush forecolor, string ChartTitle, List <ChartDataChartCommonData> dtchart) { mausac = 0; ChartControl abc = new ChartControl(); SimpleDiagram2D dg1 = new SimpleDiagram2D(); //liabc.Titles.Clear(); //Tao Tile cho Chart Title nt = new Title(); nt.Content = ChartTitle; nt.Foreground = forecolor; abc.Titles.Add(nt); //Tinh so Series List <string> countsr = (from p in dtchart group p by p.Series into g select g.Key).ToList(); //Creat Diagram abc.Diagram = dg1; GridControl dtl = new GridControl(); for (int i = 0; i < countsr.Count; i++) { PieSeries2D dgs1 = new PieSeries2D(); dgs1.HoleRadiusPercent = 0; //Thiet lap khoang trong tu tam hinh tron den duong tron dgs1.ArgumentScaleType = ScaleType.Auto; foreach (ChartDataChartCommonData dr in dtchart) //Tao cac point { if (dr.Series == countsr.ElementAt(i)) { //Tao Series SeriesPoint sr1 = new SeriesPoint(); sr1.Argument = dr.Agrument + ":" + dr.Value.ToString(); sr1.Value = dr.Value; sr1.Tag = mausac.ToString(); dgs1.Points.Add(sr1); mausac++; } } dgs1.Label = new SeriesLabel();//Tao Label cho Diagram PieSeries.SetLabelPosition(dgs1.Label, PieLabelPosition.TwoColumns); dgs1.Label.RenderMode = LabelRenderMode.RectangleConnectedToCenter; dgs1.LabelsVisibility = true;//Hien thi Lablel cho tung vung PointOptions pn1 = new PointOptions(); pn1.PointView = PointView.ArgumentAndValues; pn1.Pattern = "{A} ({V})"; //Tao mau chu thich NumericOptions nbm1 = new NumericOptions(); //Tao Kieu hien thi nbm1.Format = NumericFormat.Percent; pn1.ValueNumericOptions = nbm1; PieSeries2D.SetPercentOptions(pn1, new PercentOptions() { ValueAsPercent = true, PercentageAccuracy = 5 }); //Quy dinh ty le phan tram chinh xac dgs1.PointOptions = pn1; dg1.Series.Add(dgs1); //Tao chu thich dgs1.LegendPointOptions = pn1; } abc.Legend = new Legend(); //End tao chu thich //Set mau sac cho seriespont abc.CustomDrawSeriesPoint += abc_CustomDrawSeriesPoint; return(abc); }
void InitializePieSeries(PieSeries2D pieSeries) { pieSeries.DataSource = pieDataSource; pieSeries.ArgumentDataMember = "Argument"; pieSeries.ValueDataMember = "Value"; }