stone123
asked on
Draw Oscilloscope line chart on a Windows Form
Experts,
I am trying to draw oscilloscope-like line chart on a Windows Form in C#. The data contains thousands of sample points along certain time period. so the line easily gets to exceed the border of the form.
I wonder if there is any way I can add a scroll bar so that the points with X-coordinates beyond the limit of the form can be seen, instead of being clipped out.
Thanks a lot
stone
I am trying to draw oscilloscope-like line chart on a Windows Form in C#. The data contains thousands of sample points along certain time period. so the line easily gets to exceed the border of the form.
I wonder if there is any way I can add a scroll bar so that the points with X-coordinates beyond the limit of the form can be seen, instead of being clipped out.
Thanks a lot
stone
it can be done. i did the exact same thing. i didn't want to resize or distort the graph.
i used a panel within a panel, and drew on the child panel. if the x coordinate was greater than the width, i increased the child panel's width to the x value. and i set the parent panel's autoscroll property to true.
i used a panel within a panel, and drew on the child panel. if the x coordinate was greater than the width, i increased the child panel's width to the x value. and i set the parent panel's autoscroll property to true.
ASKER
It sounds like a good idea, msdixon. However, when I move the scroll bar, the line changes its length. it becomes shorter than the original one.
you will see the same effect if you try the following code.
Graphics g = panel1.CreateGraphics();
Pen myPen = new Pen(Color.Blue);
myPen.Width = 2;
panel1.Width = 2000;
pnlCanvas.Refresh();
g.DrawLine(myPen, 0, 50, 2000, 50);
Thanks a lot
stone
you will see the same effect if you try the following code.
Graphics g = panel1.CreateGraphics();
Pen myPen = new Pen(Color.Blue);
myPen.Width = 2;
panel1.Width = 2000;
pnlCanvas.Refresh();
g.DrawLine(myPen, 0, 50, 2000, 50);
Thanks a lot
stone
ASKER
This is to eternal_21,
How do you draw a line on a System.Drawing.Image object? Can you provide more detail?
Thanks.
How do you draw a line on a System.Drawing.Image object? Can you provide more detail?
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But what I am really wondering is why you don't just size your output to the form's current size?