c# chart控件的坐标设置Minimum和Maximum固定值之后,切换成自动模式的程序

c# chart控件的坐标设置Minimum和Maximum固定值之后,切换成自动模式的程序

c# chart控件的坐标通过chart1.ChartAreas[“ChartArea1”].AxisY.Minimum = 1;设定成固定值

/// 
        /// 设置X轴、Y1、Y2显示的范围大小
        /// 
        /// 
        private void SetScaleSizeMethod(object obj)
        {
            try
            {
                AxisScale axisScale = (AxisScale)obj;
                chart1.ChartAreas[0].AxisX.Minimum = axisScale.X_Axis_min;
                chart1.ChartAreas[0].AxisX.Maximum = axisScale.X_Axis_max;
                chart1.ChartAreas[0].AxisY.Minimum = axisScale.Y1_Axis_min;
                chart1.ChartAreas[0].AxisY.Maximum = axisScale.Y1_Axis_max;
                chart1.ChartAreas[0].AxisY2.Minimum = axisScale.Y2_Axis_min;
                chart1.ChartAreas[0].AxisY2.Maximum = axisScale.Y2_Axis_max;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "修改波形图范围错误");
            }
        }

/// 
        /// 设置X轴、Y1、Y2显示的自动缩放
        /// 
        /// 
        private void SetAutoAxisScaleMethod(object obj)
        {
            try
            {
                if (obj.ToString() == "X")
                {
                    chart1.ChartAreas[0].AxisX.Minimum = double.NaN;
                    chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
                    chart1.ChartAreas[0].AxisX.Interval = 0;
                }
                else if (obj.ToString() == "Y1")
                {
                    chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
                    chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
                    chart1.ChartAreas[0].AxisY.Interval = 0;
                }
                else if (obj.ToString() == "Y2")
                {
                    chart1.ChartAreas[0].AxisY2.Minimum = double.NaN;
                    chart1.ChartAreas[0].AxisY2.Maximum = double.NaN;
                    chart1.ChartAreas[0].AxisY2.Interval = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(),"设置"+ obj.ToString()+"自动缩放发生异常");
            }

你可能感兴趣的:(c#)