| | |
| | | private XYDiagram _diagram; |
| | | private XYDiagramDefaultPane _default_pane; |
| | | private AxisX _axis_x; |
| | | private AxisY _axis_y; |
| | | private AxisY _axis_y; |
| | | |
| | | private List<Yw.Geometry.Point2d> _point_pt_list; |
| | | private List<Yw.Geometry.Point2d> _point_pt_list; |
| | | private List<Yw.Geometry.Point2d> _line_pt_list; |
| | | |
| | | private UniversalCoordinate _coordinate; |
| | | private bool _initial_data = false; |
| | | private bool _initial_data = false; |
| | | private bool _mouse_mode = false;//鼠标模式 |
| | | |
| | | #endregion |
| | | #endregion Private Variable |
| | | |
| | | #region Public Variable |
| | | #region Public Variable |
| | | |
| | | /// <summary> |
| | | /// X轴标题 |
| | |
| | | _axis_y.Title.Text = value; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 鼠标模式 |
| | | /// </summary> |
| | |
| | | } |
| | | set |
| | | { |
| | | _mouse_mode = value; |
| | | _mouse_mode = value; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | #endregion Public Variable |
| | | |
| | | #region Public Evnet |
| | | |
| | |
| | | /// </summary> |
| | | public event Action<List<Yw.Geometry.Point2d>> DefinePointChangedEvent; |
| | | |
| | | #endregion |
| | | #endregion Public Evnet |
| | | |
| | | |
| | | |
| | | #region Initial |
| | | |
| | |
| | | this.chartControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.chartControl1_MouseDown); |
| | | this.chartControl1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.chartControl1_KeyUp); |
| | | |
| | | |
| | | _diagram = (XYDiagram)chartControl1.Diagram; |
| | | _default_pane=_diagram.DefaultPane; |
| | | _default_pane = _diagram.DefaultPane; |
| | | _axis_x = _diagram.AxisX; |
| | | //_axis_x.SetAxisXQDisplay(); |
| | | _axis_y = _diagram.AxisY; |
| | | //_axis_y.SetAxisYQLDisplay(); |
| | | |
| | | |
| | | |
| | | _axis_x.Visibility = DefaultBoolean.False; |
| | | _axis_x.GridLines.Visible = false; |
| | | _axis_y.Visibility = DefaultBoolean.False; |
| | | _axis_y.GridLines.Visible = false; |
| | | |
| | | |
| | | this.chartControl1.SetChartMonoColorDisplay(); |
| | | } |
| | |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | /// </summary> |
| | | public void SetBindingData(List<Yw.Geometry.Point2d> point_pt_list, List<Yw.Geometry.Point2d> line_pt_list, string coordinate = null, Color? color = null) |
| | | { |
| | | _initial_data = false; |
| | |
| | | this.chartControl1.EndInit(); |
| | | return; |
| | | } |
| | | |
| | | |
| | | AddPointSeries(color.Value, _axis_x, _axis_y, _default_pane, _point_pt_list); |
| | | AddLineSeries(color.Value, _axis_x, _axis_y, _default_pane, _line_pt_list); |
| | | AddLineSeries(color.Value, _axis_x, _axis_y, _default_pane, _line_pt_list); |
| | | if (_coordinate == null) |
| | | SetCoordinate(); |
| | | |
| | | SetChartAxis(); |
| | | this.chartControl1.EndInit(); |
| | | _initial_data = true; |
| | | |
| | | } |
| | | |
| | | //是否是无效数据 |
| | |
| | | return false; |
| | | } |
| | | |
| | | #region Add Chart Data |
| | | #region Add Chart Data |
| | | |
| | | private void AddPointSeries(Color color, AxisXBase axis_x, AxisYBase axis_y, XYDiagramPaneBase pane, List<Yw.Geometry.Point2d> pt_list) |
| | | { |
| | |
| | | var series_pt = new DevExpress.XtraCharts.SeriesPoint(pt.X, new double[] { pt.Y }); |
| | | series_pt_list.Add(series_pt); |
| | | } |
| | | |
| | | |
| | | var series = new DevExpress.XtraCharts.Series(); |
| | | series.ShowInLegend = false; |
| | | series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Numerical; |
| | |
| | | this.chartControl1.Series.Add(series); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | #endregion Add Chart Data |
| | | |
| | | #endregion |
| | | |
| | | #endregion SetBindingData |
| | | |
| | | #region Set Axis |
| | | |
| | |
| | | _minY = Math.Min(_line_pt_list.Min(x => x.Y), _minY); |
| | | _maxY = Math.Min(_line_pt_list.Max(x => x.Y), _maxY); |
| | | |
| | | |
| | | _coordinate = UniversalCoordinate.CalcCoordinate(_minX, _maxX, _minY, _maxY); |
| | | if (_coordinate == null) |
| | | return; |
| | |
| | | { |
| | | _coordinate.GridNumberX++; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置图表轴 |
| | |
| | | _axis_y.Visibility = DefaultBoolean.False; |
| | | _axis_y.GridLines.Visible = false; |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //计算刻度 X |
| | | var axis_x_labels = new List<CustomAxisLabel>(); |
| | |
| | | _axis_x.CustomLabels.AddRange(axis_x_labels.ToArray()); |
| | | _axis_x.Visibility = DefaultBoolean.True; |
| | | _axis_x.GridLines.Visible = true; |
| | | |
| | | |
| | | //计算刻度 Y |
| | | var axis_y_labels = new List<CustomAxisLabel>(); |
| | |
| | | _axis_y.SetAxisRange(_coordinate.DispMinY(), _coordinate.DispMaxY()); |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion Calc |
| | | #endregion Set Axis |
| | | |
| | | #region ChartEvent |
| | | |
| | | private SeriesPoint _pick_point = null;// 选中点 |
| | | private SeriesPoint _pick_point = null;// 选中点 |
| | | |
| | | private void chartControl1_MouseDown(object sender, MouseEventArgs e) |
| | | { |
| | | if (!_initial_data) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void chartControl1_MouseMove(object sender, MouseEventArgs e) |
| | | { |
| | |
| | | _pick_point.NumericalArgument = diagram_coordinates.NumericalArgument; |
| | | } |
| | | |
| | | |
| | | private void chartControl1_MouseUp(object sender, MouseEventArgs e) |
| | | { |
| | | if (!_mouse_mode) |
| | |
| | | |
| | | _pick_point = null; |
| | | } |
| | | |
| | | |
| | | private void chartControl1_KeyUp(object sender, KeyEventArgs e) |
| | | { |
| | |
| | | } |
| | | _pick_point.Values[0] = y; |
| | | _pick_point.NumericalArgument = x; |
| | | var index = _pick_point.Tag.is |
| | | SetPointPtValue(); |
| | | /* var index = _pick_point.Tag.is |
| | | SetPointPtValue();*/ |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 更新数据 |
| | |
| | | this.DefinePointChangedEvent?.Invoke(_point_pt_list); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #endregion ChartEvent |
| | | } |
| | | } |