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!
Asked
Active
Viewed 194 times
1 Answers
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:
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