/* 绘制Y坐标轴 */ protected virtual void _DrawYAxis(Graphics g, int width, int height) { Rectangle rect_grid = _GetGridRect(width, height); Rectangle rect_axis = _GetYAxisRect(width, height); float delta_amount = _GetMaxDeltaAmount(); float start_delta_amount, stop_delta_amount; ChartCurve1V.GetYAxisStartStopDeltaAmountByBilichi(_DataBilichiStart, _DataBilichiStop, delta_amount, out start_delta_amount, out stop_delta_amount); if (YAxisCombined || _Curves.Count == 0) { _DrawSingleYAxis(g, rect_axis, rect_grid, _AxesPen); string name_unit = YAxisName + (string.IsNullOrEmpty(YAxisUnitName) ? "" : ("(" + YAxisUnitName + ")")); if (YAxisIsAuto) { float y_axis_max = 0.0f, y_axis_min = 0.0f; bool first = true; for (int i = 0; i < _Curves.Count; ++i) { ChartCurve1V cc = _Curves[i]; List <float> data = cc.YAxisData; int start_index, stop_index; cc.GetYAxisStartStopIndex(start_delta_amount, stop_delta_amount, out start_index, out stop_index); float f_max, f_min; cc.GetYAxisDataMaxMinValueInSpan(start_index, stop_index, out f_max, out f_min); if (first) { first = false; y_axis_max = f_max; y_axis_min = f_min; } else { if (y_axis_max < f_max) { y_axis_max = f_max; } if (y_axis_min > f_min) { y_axis_min = f_min; } } } float abs_max = Math.Abs(y_axis_max) > Math.Abs(y_axis_min) ? Math.Abs(y_axis_max) : Math.Abs(y_axis_min); Int64 y_axis_range = ChartCurve1V.GetAxisRange(abs_max); _YAxisMaxValueUsed = (float)y_axis_range / (float)1E6; _YAxisMinValueUsed = -_YAxisMaxValueUsed; } else { _YAxisMaxValueUsed = YAxisMaxValue; _YAxisMinValueUsed = YAxisMinValue; } _DrawSingleYAxisVal(g, rect_axis, rect_grid, name_unit, _AxesFont, _AxesBrush, _YAxisMinValueUsed, _YAxisMaxValueUsed, YAxisKdFormat); } else { int single_axis_width = (int)Math.Round((double)rect_axis.Width / (double)_Curves.Count); for (int i = 0; i < _Curves.Count; ++i) { ChartCurve1V cc = _Curves[i]; Rectangle rect_axis_single; if (i == 0) { rect_axis_single = new Rectangle(rect_axis.Right - single_axis_width, rect_axis.Y, single_axis_width, rect_axis.Height); } else if (i == _Curves.Count - 1) { rect_axis_single = new Rectangle(rect_axis.X, rect_axis.Y, single_axis_width, rect_axis.Height); } else { rect_axis_single = new Rectangle(rect_axis.X + (_Curves.Count - 1 - i) * single_axis_width, rect_axis.Y, single_axis_width, rect_axis.Height); } _DrawSingleYAxis(g, rect_axis_single, rect_grid, cc.Pen); string name_unit = cc.YAxisName + (string.IsNullOrEmpty(cc.YAxisUnitName) ? "" : ("(" + cc.YAxisUnitName + ")")); if (cc.YAxisIsAuto) { int start_index, stop_index; cc.GetYAxisStartStopIndex(start_delta_amount, stop_delta_amount, out start_index, out stop_index); float f_max, f_min; cc.GetYAxisDataMaxMinValueInSpan(start_index, stop_index, out f_max, out f_min); float abs_max = Math.Abs(f_max) > Math.Abs(f_min) ? Math.Abs(f_max) : Math.Abs(f_min); Int64 y_axis_range = ChartCurve1V.GetAxisRange(abs_max); cc.YAxisMaxValueUsed = (float)y_axis_range / (float)1E6; cc.YAxisMinValueUsed = -cc.YAxisMaxValueUsed; } else { cc.YAxisMaxValueUsed = cc.YAxisMaxValue; cc.YAxisMinValueUsed = cc.YAxisMinValue; } _DrawSingleYAxisVal(g, rect_axis_single, rect_grid, name_unit, _AxesFont, cc.Brush, cc.YAxisMinValueUsed, cc.YAxisMaxValueUsed, cc.YAxisKdFormat); } } }
/* 绘制X坐标轴 */ protected override void _DrawXAxis(Graphics g, int width, int height) { Rectangle rect_grid = _GetGridRect(width, height); Rectangle rect_axis = _GetXAxisRect(width, height); if (XAxisCombined || _Curves.Count == 0) { _DrawSingleXAxis(g, rect_axis, rect_grid, _AxesPen); string name_unit = XAxisName + (string.IsNullOrEmpty(XAxisUnitName) ? "" : ("(" + XAxisUnitName + ")")); if (XAxisIsAuto) { float x_axis_max = 0.0f, x_axis_min = 0.0f; bool first = true; for (int i = 0; i < _Curves.Count; ++i) { ChartCurve2V cc = _Curves[i] as ChartCurve2V; if (cc == null) { continue; } List <float> data = cc.XAxisData; float f_max, f_min; cc.GetXAxisDataMaxMinValueInSpan(0, data.Count, out f_max, out f_min); if (first) { first = false; x_axis_max = f_max; x_axis_min = f_min; } else { if (x_axis_max < f_max) { x_axis_max = f_max; } if (x_axis_min > f_min) { x_axis_min = f_min; } } } float abs_max = Math.Abs(x_axis_max) > Math.Abs(x_axis_min) ? Math.Abs(x_axis_max) : Math.Abs(x_axis_min); Int64 y_axis_range = ChartCurve1V.GetAxisRange(abs_max); _XAxisMaxValueUsed = (float)y_axis_range / (float)1E6; _XAxisMinValueUsed = -_XAxisMaxValueUsed; } else { _XAxisMaxValueUsed = XAxisMaxValue; _XAxisMinValueUsed = XAxisMinValue; } _DrawSingleXAxisVal(g, rect_axis, rect_grid, name_unit, _AxesFont, _AxesBrush, _XAxisMinValueUsed, _XAxisMaxValueUsed, XAxisKdFormat); } else { int single_axis_height = (int)Math.Round((double)rect_axis.Height / (double)_Curves.Count); for (int i = 0; i < _Curves.Count; ++i) { ChartCurve2V cc = _Curves[i] as ChartCurve2V; if (cc == null) { continue; } Rectangle rect_axis_single; if (i == 0) { rect_axis_single = new Rectangle(rect_axis.Left, rect_axis.Top, rect_axis.Width, single_axis_height); } else if (i == _Curves.Count - 1) { rect_axis_single = new Rectangle(rect_axis.Left, rect_axis.Bottom - single_axis_height, rect_axis.Width, single_axis_height); } else { rect_axis_single = new Rectangle(rect_axis.Left, rect_axis.Top + i * single_axis_height, rect_axis.Width, single_axis_height); } _DrawSingleXAxis(g, rect_axis_single, rect_grid, cc.Pen); string name_unit = cc.XAxisName + (string.IsNullOrEmpty(cc.XAxisUnitName) ? "" : ("(" + cc.XAxisUnitName + ")")); if (cc.XAxisIsAuto) { float f_max, f_min; cc.GetXAxisDataMaxMinValueInSpan(0, cc.XAxisData.Count, out f_max, out f_min); float abs_max = Math.Abs(f_max) > Math.Abs(f_min) ? Math.Abs(f_max) : Math.Abs(f_min); Int64 x_axis_range = ChartCurve1V.GetAxisRange(abs_max); cc.XAxisMaxValueUsed = (float)x_axis_range / (float)1E6; cc.XAxisMinValueUsed = -cc.XAxisMaxValueUsed; } else { cc.XAxisMaxValueUsed = cc.XAxisMaxValue; cc.XAxisMinValueUsed = cc.XAxisMinValue; } _DrawSingleXAxisVal(g, rect_axis_single, rect_grid, name_unit, _AxesFont, cc.Brush, cc.XAxisMinValueUsed, cc.XAxisMaxValueUsed, cc.XAxisKdFormat); } } }