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_QueryChartCursor(object sender, QueryChartCursorEventArgs e) { ChartHitInfo hitInfo = ChartControl.CalcHitInfo(e.Position); if (hitInfo != null && hitInfo.SeriesPoint != null) { e.Cursor = Cursors.Hand; } }
void chart_QueryChartCursor(object sender, QueryChartCursorEventArgs e) { ChartControl myChart = sender as ChartControl; ChartHitInfo hitInfo = myChart.CalcHitInfo(e.Position); if (hitInfo != null && hitInfo.SeriesPoint != null && isLeftMouseButtonReleased) { e.Cursor = Cursors.Hand; } }
void chart_MouseDown(object sender, MouseButtonEventArgs e) { mouseDownTime = DateTime.Now; Point position = e.GetPosition(ChartControl); ChartHitInfo hitInfo = ChartControl.CalcHitInfo(position); if (hitInfo != null && hitInfo.SeriesPoint != null) { rotate = true; startPosition = position; } }
private void CountryChart_MouseUp(object sender, MouseEventArgs e) { if (nowmode != "country") { return; } ChartHitInfo hitInfo = countryChart.CalcHitInfo(e.Location); if (hitInfo.SeriesPoint != null) { showChart(countryChart, "timepoint", countryChart.Name, hitInfo.SeriesPoint.Argument); } }
/// <summary> /// 自定义ChartControl的Tooltip /// </summary> /// <param name="chart">ChartControl</param> /// <param name="e">MouseEventArgs</param> /// <param name="tooltip">ToolTipController</param> /// <param name="tooltipTitle">ToolTipController的Title</param> /// <param name="paramter">委托</param> public static void CustomToolTip(this ChartControl chart, MouseEventArgs e, ToolTipController tooltip, string tooltipTitle, System.Func <string, double[], string> paramter) { ChartHitInfo _hitInfo = chart.CalcHitInfo(e.X, e.Y); SeriesPoint _point = _hitInfo.SeriesPoint; if (_point != null) { string _msg = paramter(_point.Argument, _point.Values); tooltip.ShowHint(_msg, tooltipTitle); } else { tooltip.HideHint(); } }
/// <summary> /// chart钻取实现【在MouseClick事件中实现】 /// </summary> /// <param name="chart">ChartControl</param> /// <param name="e">MouseEventArgs</param> /// <param name="backKeyWord">返回主Series的关键字</param> /// <param name="gotoHandler">向下钻取委托</param> /// <param name="backHandler">返回主Series的委托</param> public static void DrillDownHelper(this ChartControl chart, MouseEventArgs e, string backKeyWord, Action <SeriesPoint> gotoHandler, Action <SeriesPoint> backHandler) { //eg: //private void chartLh_MouseClick(object sender, MouseEventArgs e) //{ // ChartControl _curChart = sender as ChartControl; // _curChart.DrillDownHelper( // e, // "返回", // point => // { // string _argument = point.Argument.ToString(); // if (_curChart.Series["pieSeries"].Visible) // { // _curChart.Series["pieSeries"].Visible = false; // _curChart.SeriesTemplate.Visible = true; // if (_curChart.SeriesTemplate.DataFilters.Count == 0) // _curChart.SeriesTemplate.AddDataFilter("categoryName", _argument, DataFilterCondition.Equal); // else // _curChart.SeriesTemplate.DataFilters[0].Value = _argument; // _curChart.Titles[1].Visible = true; // _curChart.Titles[0].Visible = false; // } // }, // point => // { // _curChart.Titles[0].Visible = true; // _curChart.Series["pieSeries"].Visible = true; // _curChart.SeriesTemplate.Visible = false; // }); //} ChartHitInfo _hitInfo = chart.CalcHitInfo(e.X, e.Y); SeriesPoint _point = _hitInfo.SeriesPoint; if (_point != null) { gotoHandler(_point); } ChartTitle link = _hitInfo.ChartTitle; if (link != null && link.Text.StartsWith(backKeyWord)) { link.Visibility = DefaultBoolean.False; backHandler(_point); } }
/// <summary> /// 设置钻取 /// </summary> /// <param name="chart">ChartControl</param> /// <param name="backKeyWord">返回主Series的关键字</param> /// <param name="gotoHandler">向下钻取委托;参数【SeriesPoint】</param> /// <param name="backHandler">返回主Series的委托;参数【SeriesPoint】</param> public static void SetDrillDown(this ChartControl chart, string backKeyWord, Action <SeriesPoint> gotoHandler, Action <SeriesPoint> backHandler) { //eg: // chartLh.SetDrillDown( // "返回", // point => //{ // string _argument = point.Argument.ToString(); // if (chartLh.Series["pieSeries"].Visible) // { // chartLh.Series["pieSeries"].Visible = false; // chartLh.SeriesTemplate.Visible = true; // if (chartLh.SeriesTemplate.DataFilters.Count == 0) // chartLh.SeriesTemplate.AddDataFilter("categoryName", _argument, DataFilterCondition.Equal); // else // chartLh.SeriesTemplate.DataFilters[0].Value = _argument; // chartLh.Titles[1].Visible = true; // chartLh.Titles[0].Visible = false; // } //}, // point => //{ // chartLh.Titles[0].Visible = true; // chartLh.Series["pieSeries"].Visible = true; // chartLh.SeriesTemplate.Visible = false; //}); chart.MouseClick += (sender, e) => { ChartControl _curChart = sender as ChartControl; ChartHitInfo _hitInfo = _curChart.CalcHitInfo(e.X, e.Y); SeriesPoint _point = _hitInfo.SeriesPoint; if (_point != null) { gotoHandler(_point); } ChartTitle link = _hitInfo.ChartTitle; if (link != null && link.Text.StartsWith(backKeyWord)) { link.Visible = false; backHandler(_point); } }; }
/// <summary> /// ChartControl的Tooltip设置 /// <para>举例</para> /// <code> /// <para> chartControl1.SetToolTip(toolTipController1, "交易详情", (agr, values) =></para> /// <para>{</para> /// <para> return string.Format("时间:{0}\r\n金额:{1}", agr, values[0]);</para> /// <para>});</para> /// </code> /// </summary> /// <param name="chart">ChartControl</param> /// <param name="tooltip">ToolTipController</param> /// <param name="tooltipTitle">ToolTip的Title</param> /// <param name="paramter">委托,参数『Argument,Values』</param> public static void SetToolTip(this ChartControl chart, ToolTipController tooltip, string tooltipTitle, System.Func <string, double[], string> paramter) { chart.MouseMove += (sender, e) => { ChartControl _curChart = sender as ChartControl; ChartHitInfo _hitInfo = _curChart.CalcHitInfo(e.X, e.Y); SeriesPoint _point = _hitInfo.SeriesPoint; if (_point != null) { string _msg = paramter(_point.Argument, _point.Values); tooltip.ShowHint(_msg, tooltipTitle); } else { tooltip.HideHint(); } }; }
/// <summary> /// 环形图左键放开事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void chart_MouseUp(object sender, MouseButtonEventArgs e) { ChartControl chartName = sender as ChartControl; ChartHitInfo hitInfo = chartName.CalcHitInfo(e.GetPosition(chartName)); if (hitInfo == null || hitInfo.SeriesPoint == null) { return; } double distance = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint); Storyboard storyBoard = new Storyboard(); DoubleAnimation animation = new DoubleAnimation(); animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 300)); animation.To = distance > 0 ? 0 : 0.3; storyBoard.Children.Add(animation); Storyboard.SetTarget(animation, hitInfo.SeriesPoint); Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty)); storyBoard.Begin(); e.Handled = true; }
//private Popup pop = new Popup(); private void Chart_MouseUp(object sender, MouseButtonEventArgs e) { if (pop != null && pop.Child != null) { pop.Child = null; pop.IsOpen = false; //tmp = null; } ChartControl chart = sender as ChartControl; if (chart.Name != "KGChart") { System.Windows.Point mouseposition = e.GetPosition(mainFrame); ChartHitInfo hitInfo = chart.CalcHitInfo(e.GetPosition(chart)); if (!hitInfo.InSeries || hitInfo.InLegend) { return; } //Popup pop = new Popup(); pop.IsOpen = true; //pop.AllowsTransparency = true; pop.Placement = System.Windows.Controls.Primitives.PlacementMode.RelativePoint; pop.PlacementTarget = mainFrame; pop.HorizontalOffset = mouseposition.X + 1; pop.VerticalOffset = mouseposition.Y; pop.Height = 350; pop.Width = 700; pop.Child = new RFullViewSizeSubPanel(hitInfo); pop.Effect = new System.Windows.Media.Effects.DropShadowEffect(); //tmp = pop; //mainFrame.Children.Add(new RFullViewSizeSubPanel(hitInfo)); } }
private void Chart_MouseDown(object sender, MouseButtonEventArgs e) { ChartControl chartControl = (ChartControl)sender; ChartHitInfo hitInfo = chartControl.CalcHitInfo(e.GetPosition(chartControl)); int pointIndex = series.Points.IndexOf(hitInfo.SeriesPoint); SeriesPoint point = hitInfo.SeriesPoint; double oldPointPercent = 0; CalcPointPercent(pointIndex, ref oldPointPercent); point.Value++; double newPointPercent = 0; CalcPointPercent(pointIndex, ref newPointPercent); series.Rotation += 360 * (oldPointPercent - newPointPercent); if (series.Rotation > 360) { series.Rotation %= 360; } }
void chart_MouseMove(object sender, MouseEventArgs e) { ChartControl orgchart = sender as ChartControl; Point position = e.GetPosition(orgchart); ChartHitInfo hitInfo = orgchart.CalcHitInfo(position); if (hitInfo != null && hitInfo.SeriesPoint != null) { ttContent.Text = string.Format("设备 = {0}\n数量 = {1}", hitInfo.SeriesPoint.Argument, Math.Round(hitInfo.SeriesPoint.NonAnimatedValue, 2)); pointTooltip.Placement = PlacementMode.RelativePoint; pointTooltip.PlacementTarget = orgchart; pointTooltip.HorizontalOffset = position.X + 5; pointTooltip.VerticalOffset = position.Y + 5; pointTooltip.IsOpen = true; Cursor = Cursors.Hand; } else { pointTooltip.IsOpen = false; Cursor = Cursors.Arrow; } }
void chart_MouseUp(object sender, MouseButtonEventArgs e) { ChartControl myChart = sender as ChartControl; isLeftMouseButtonReleased = true; if (!IsClick(e.Timestamp)) { return; } ChartHitInfo hitInfo = myChart.CalcHitInfo(e.GetPosition(myChart)); if (hitInfo == null || hitInfo.SeriesPoint == null) { return; } double distance = PieSeries.GetExplodedDistance(hitInfo.SeriesPoint); AnimationTimeline animation = distance > 0 ? (AnimationTimeline)TryFindResource("CollapseAnimation") : (AnimationTimeline)TryFindResource("ExplodeAnimation"); Storyboard storyBoard = new Storyboard(); storyBoard.Children.Add(animation); Storyboard.SetTarget(animation, hitInfo.SeriesPoint); Storyboard.SetTargetProperty(animation, new PropertyPath(PieSeries.ExplodedDistanceProperty)); storyBoard.Begin(); }
private void _MouseMove(object sender, MouseEventArgs e) { ChartControl chartControl_current = null; ChartHitInfo hitInfo = null; foreach (Control c in xtraTabControl1.TabPages) { if (c is XtraTabPage && ((XtraTabPage)c).Name == "xtraTabPage3") { foreach (Control b in c.Controls) { if (b is ChartControl && ((ChartControl)b).Equals(sender)) { chartControl_current = ((ChartControl)b); hitInfo = chartControl_current.CalcHitInfo(e.Location); } } } } foreach (Control c in xtraTabControl1.TabPages) { if (c is XtraTabPage && ((XtraTabPage)c).Name == "limitAverageXTP") { foreach (Control b in c.Controls) { if (b is ChartControl && ((ChartControl)b).Equals(sender)) { chartControl_current = ((ChartControl)b); hitInfo = chartControl_current.CalcHitInfo(e.Location); } } } } if (hitInfo == null) { return; } StringBuilder builder = new StringBuilder(); if (hitInfo.InDiagram) { builder.AppendLine("In diagram"); } if (hitInfo.InNonDefaultPane) { builder.AppendLine("In non-default pane: " + hitInfo.NonDefaultPane.Name); } if (hitInfo.InAxis) { builder.AppendLine("In axis: " + hitInfo.Axis.Name); if (hitInfo.AxisLabelItem != null) { builder.AppendLine(" Label item: " + hitInfo.AxisLabelItem.Text); } if (hitInfo.AxisTitle != null) { builder.AppendLine(" Axis title: " + hitInfo.AxisTitle.Text); } } if (hitInfo.InChartTitle) { builder.AppendLine("In chart title: " + hitInfo.ChartTitle.Text); } if (hitInfo.InLegend) { builder.AppendLine("In legend"); } if (hitInfo.InSeries) { builder.AppendLine("In series: " + ((Series)hitInfo.Series).Name); } if (hitInfo.InSeriesLabel) { builder.AppendLine("In series label"); builder.AppendLine(" Series: " + ((Series)hitInfo.Series).Name); } if (hitInfo.SeriesPoint != null) { builder.AppendLine(" Argument: " + hitInfo.SeriesPoint.Argument); if (!hitInfo.SeriesPoint.IsEmpty) { builder.AppendLine(" Value: " + hitInfo.SeriesPoint.Values[0]); } } if (builder.Length > 0) { toolTipController.ShowHint("AIO-testing results:\n" + builder.ToString(), chartControl_current.PointToScreen(e.Location)); } else { toolTipController.HideHint(); } }