| | |
| | | private ConstantLine _const_line_x; |
| | | private ConstantLine _const_line_y; |
| | | |
| | | private List<Yw.Geometry.Point2d> _pt_list = null; |
| | | private List<Yw.Geometry.Point2d> _fit_pt_list = null; |
| | | private UniversalCoordinate _coordinate = null; |
| | | |
| | | private bool _line_visible = false; |
| | |
| | | _axis_y = _diagram.AxisY; |
| | | _axis_y.SetAxisYQHDisplay(); |
| | | |
| | | _axis_x.Visibility = DefaultBoolean.False; |
| | | _axis_x.GridLines.Visible = false; |
| | | _axis_y.Visibility = DefaultBoolean.False; |
| | | _axis_y.GridLines.Visible = false; |
| | | |
| | | |
| | | _const_line_x = (ConstantLine)_diagram.AxisX.ConstantLines.GetElementByName("ConstantLineX"); |
| | | _const_line_x.SetWorkPointLineDisplay(); |
| | | |
| | | _const_line_y = (ConstantLine)_diagram.AxisY.ConstantLines.GetElementByName("ConstantLineY"); |
| | | _const_line_y.SetWorkPointLineDisplay(); |
| | | |
| | | _axis_x.Visibility = DefaultBoolean.False; |
| | | _axis_x.GridLines.Visible = false; |
| | | _axis_y.Visibility = DefaultBoolean.False; |
| | | _axis_y.GridLines.Visible = false; |
| | | |
| | | _const_line_x.Visible = false; |
| | | _const_line_y.Visible = false; |
| | |
| | | |
| | | if (_on_move_x_line) |
| | | { |
| | | var diagramCoordinates = _diagram.PointToDiagram(e.Location); |
| | | var axis_value = diagramCoordinates.GetAxisValue(_axis_x); |
| | | var diagram_coordinates = _diagram.PointToDiagram(e.Location); |
| | | var axis_value = diagram_coordinates.GetAxisValue(_axis_x); |
| | | if (axis_value == null) |
| | | return; |
| | | double x = axis_value.NumericalValue; |
| | |
| | | } |
| | | else if (_on_move_y_line) |
| | | { |
| | | var diagramCoordinates = _diagram.PointToDiagram(e.Location); |
| | | var axis_value = diagramCoordinates.GetAxisValue(_axis_y); |
| | | var diagram_coordinates = _diagram.PointToDiagram(e.Location); |
| | | var axis_value = diagram_coordinates.GetAxisValue(_axis_y); |
| | | if (axis_value == null) |
| | | return; |
| | | double y = axis_value.NumericalValue; |
| | |
| | | public void Clear() |
| | | { |
| | | _initial_data = false; |
| | | _pt_list = null; |
| | | _fit_pt_list = null; |
| | | _coordinate = null; |
| | | |
| | | this.chartControl1.BeginInit(); |
| | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(List<Yw.Geometry.Point2d> pt_list, string caption = "", string coordinate = null, Color? color = null) |
| | | public void SetBindingData(List<Yw.Geometry.Point2d> fit_pt_list,List<Yw.Geometry.Point2d> def_pt_list=null, string caption = "", string coordinate = null, Color? color = null) |
| | | { |
| | | _pt_list = pt_list?.Select(t => |
| | | _fit_pt_list = fit_pt_list?.Select(t => |
| | | { |
| | | var x = Math.Round(t.X, 2); |
| | | var y = Math.Round(t.Y, 2); |
| | |
| | | this.chartControl1.Series.Clear(); |
| | | this.chartControl1.AnnotationRepository.Clear(); |
| | | this.chartControl1.Legend.CustomItems.Clear(); |
| | | if (pt_list == null || !pt_list.Any()) |
| | | if (fit_pt_list == null || !fit_pt_list.Any()) |
| | | { |
| | | _initial_data = false; |
| | | this.chartControl1.EndInit(); |
| | |
| | | if (color == null) |
| | | color = PumpChartDisplay.CurveColorQH; |
| | | |
| | | AddLineSeries(color.Value, _axis_x, _axis_y, _default_pane, pt_list); |
| | | AddLineSeries(color.Value, _axis_x, _axis_y, _default_pane, fit_pt_list); |
| | | if (!string.IsNullOrEmpty(caption)) |
| | | { |
| | | AddAnnotation(caption, color.Value, _axis_y, _default_pane, pt_list.Last()); |
| | | AddAnnotation(caption, color.Value, _axis_y, _default_pane, fit_pt_list.Last()); |
| | | } |
| | | |
| | | if (def_pt_list!=null&& def_pt_list.Any()) |
| | | { |
| | | AddPointSeries(color.Value, _axis_x, _axis_y, _default_pane, def_pt_list); |
| | | } |
| | | |
| | | if (_coordinate == null) |
| | |
| | | //是否是无效数据 |
| | | private bool IsInvalidData() |
| | | { |
| | | if (_pt_list == null || !_pt_list.Any()) |
| | | if (_fit_pt_list == null || !_fit_pt_list.Any()) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | _minX = _pt_list.Min(x => x.X); |
| | | _maxX = _pt_list.Max(x => x.X); |
| | | _minX = _fit_pt_list.Min(x => x.X); |
| | | _maxX = _fit_pt_list.Max(x => x.X); |
| | | |
| | | _minY = _pt_list.Min(x => x.Y); |
| | | _maxY = _pt_list.Max(x => x.Y); |
| | | _minY = _fit_pt_list.Min(x => x.Y); |
| | | _maxY = _fit_pt_list.Max(x => x.Y); |
| | | |
| | | _coordinate = UniversalCoordinate.CalcCoordinate(_minX, _maxX, _minY, _maxY); |
| | | if (_coordinate == null) |
| | |
| | | if (this.IsInvalidData()) |
| | | return; |
| | | |
| | | var min_x = _pt_list.Min(x => x.X); |
| | | var max_x = _pt_list.Max(x => x.X); |
| | | var min_x = _fit_pt_list.Min(x => x.X); |
| | | var max_x = _fit_pt_list.Max(x => x.X); |
| | | |
| | | if (x == null) |
| | | { |
| | |
| | | } |
| | | |
| | | var x_value = x.Value; |
| | | var y_value = _pt_list.GetInterPointsY(x_value)?.FirstOrDefault(); |
| | | var y_value = _fit_pt_list.GetInterPointsY(x_value)?.FirstOrDefault(); |
| | | |
| | | _const_line_x.AxisValue = x_value; |
| | | _const_line_x.Title.Text = $"{x_value:N1}"; |
| | |
| | | if (IsInvalidData()) |
| | | return; |
| | | |
| | | var min_y = _pt_list.Min(x => x.Y); |
| | | var max_y = _pt_list.Max(x => x.Y); |
| | | var min_y = _fit_pt_list.Min(x => x.Y); |
| | | var max_y = _fit_pt_list.Max(x => x.Y); |
| | | if (y < min_y || y > max_y) |
| | | return; |
| | | |
| | | var x_value = _pt_list.GetInterPointsX(y)?.LastOrDefault(); |
| | | var x_value = _fit_pt_list.GetInterPointsX(y)?.LastOrDefault(); |
| | | SetAxisXValue(x_value); |
| | | |
| | | } |