【问题标题】:C# MSChart how to shift Y axis like oscilloscope offset button?C# MSChart 如何像示波器偏移按钮一样移动 Y 轴?
【发布时间】:2017-08-04 02:52:29
【问题描述】:

我有一个MSChart,x 轴是 t(ms),y 轴是电压数据。 现在我想编写像示波器功能“偏移”这样的代码。 当我调整numericUpDown 以移动波形和 Y 轴时。 如何获得这个功能?就像下面的2张图片。谢谢!

No shift wave and Y-axis

Now shift Y-axis and wave shift too

【问题讨论】:

    标签: c# mschart


    【解决方案1】:

    我解决它的方法是更改​​ y 轴 Minimum 和/或 Maximum 值。你也可以玩IntervalOffset

    看这里:

    private void numericUpDown5_ValueChanged(object sender, EventArgs e)
    {
        Axis ay = chart2.ChartAreas[0].AxisY;
    
        int oy = (int)numericUpDown5.Value;
    
        if (radioButton1.Checked)  ay.IntervalOffset = oy;
        if (radioButton2.Checked)  ay.Maximum = oy;
        if (radioButton3.Checked)  ay.Minimum = oy;
    }
    
    private void rbAy_CheckedChanged(object sender, EventArgs e)
    {
        Axis ay = chart2.ChartAreas[0].AxisY;
        if (sender == radioButton1) numericUpDown5.Value = (decimal)ay.IntervalOffset;
        if (sender == radioButton2) numericUpDown5.Value = (decimal)ay.Maximum;
        if (sender == radioButton3) numericUpDown5.Value = (decimal)ay.Minimum;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多