/* 绘制X坐标轴 */ protected virtual void _DrawXAxis(Graphics g, int width, int height) { Rectangle rect_grid = _GetGridRect(width, height); Rectangle rect_axis = _GetXAxisRect(width, height); _DrawSingleXAxis(g, rect_axis, rect_grid, _AxesPen); 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); _XAxisMinValueUsed = start_delta_amount; _XAxisMaxValueUsed = stop_delta_amount; string name_unit = XAxisName + (string.IsNullOrEmpty(XAxisUnitName) ? "" : ("(" + XAxisUnitName + ")")); DataFormat df = XAxisKdFormat; _DrawSingleXAxisVal(g, rect_axis, rect_grid, name_unit, _AxesFont, _AxesBrush, start_delta_amount, stop_delta_amount, df); }
/* 绘制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); } } }