1
Good morning guys, I’m drawing a line chart on a pictureBox with "drawline"s concatenated.
Basically what I want is to create a horizontal scroll bar to navigate the chart, that is, to be able to scroll through the chart horizontally using the scroll bar. Follows code drawing graph.
void DrawANALISE()
{
Graphics g = pcbANALISE.CreateGraphics();
g.SmoothingMode = SmoothingMode.AntiAlias;
var lastPoint1 = new PointF(0F, (float)(2 * Height / 5) * 0.5F);
PointF newPoint1 = new PointF();
for (int i = 0; i < 6000; i++)
{
//aquisicaodata é uma lista onde há 6000 valores para y
var porcent = aquisicaodata[i] / 5;
newPoint1.X = (i + 1) * 0.2f;
if (porcent > 1) porcent = 1;
var hg = porcent * (2 * pcbANALISE.Height / 5);
if (porcent >= 1) newPoint1.Y = 2 * pcbANALISE.Height / 5 - hg;
else newPoint1.Y = 2 * pcbANALISE.Height / 5 - hg - 1;
using (var p = new Pen(Color.Lime, 0.1f)) g.DrawLine(p, lastPoint1, newPoint1);
lastPoint1 = newPoint1;
}
}
Since in the code I am drawing 1 point every 0.2 pixels horizontally and there are a total of 6000 points, which would result in a total of 1200 pixels horizontally to draw whole graph, a pcb of 500 pixels wide is not enough to display whole graph. That is why I would like to create a horizontal scroll bar so that I can have a view of the entire chart. I will edit if necessary. If anyone can help, I’d really appreciate it!
Thanks again for the attention Weiner, so friend, I did here this way but did not work scrolling. I move the scrollbar but the graph is still stopped.
– Felipe Mateus
If you can continue helping I would be very pleased.
– Felipe Mateus
Just add the method to redesign in the scrollbar, I had forgotten.
– Weiner Lemes
Friend, it even works the scrolling this way, but the graph is really redesigning from the beginning to each tick of the scrolling, which makes the performance fall a lot, if I click to move the graph the program gets a little stuck.
– Felipe Mateus
Now do not want to update haha, show the following error: "System.Invalidoperationexception: 'The object is being used elsewhere.".
– Felipe Mateus
and points to the following line : using (var p = new Pen(Color.Blue, 0.1f)) g.Drawline(p, lastPoint2, newPoint2);
– Felipe Mateus
I will try to make an Aki control to help you, but really you have the need to draw 10 values in a single pixel, because it is not even being shown all these values.
– Weiner Lemes
For my application I need 300 points on a second friend
– Felipe Mateus
is not being shown? Why, if you are not losing performance at all
– Felipe Mateus
if you can do this check I thank you, tried in several ways but unsuccessfully.
– Felipe Mateus
Dude, I don’t know if you know how to answer this, but do you know if for a graphical visualization and analysis application, with user interface it would be better to use c# or java? I don’t have much knowledge in the area yet. I believe the two are similar.
– Felipe Mateus