-2

I have a MSChart, that x-axis is t(ms), and y-axis is voltage data. Now I would like programming the code like oscilloscope function "Offset". When I adjust numericUpDown to shift the wave and Y-axis. How to get this function? Just like below 2 picture. Thanks!

No shift wave and Y-axis

Now shift Y-axis and wave shift too

sarah
  • 5
  • 4

1 Answers1

1

The way I would tackle it is to change the y-axis Minimum and/or Maximum values. You can also play with the IntervalOffset.

See here:

enter image description here

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;
}
TaW
  • 53,122
  • 8
  • 69
  • 111