Skupaj Skupaj - 3 months ago 56
C# Question

Bar graph is upside down

I'm trying to make a bar graph from an array and it works. The only problem is that it's upside down.

enter image description here

This is the code i have now:

int widthCalc = pbxGraph.Width / days;

for (int i = 0; i < speedPoints.Length; i++)
float height = distanceGraph[i] * 110;
Rectangle barGraph = new Rectangle(i*(widthCalc/3), 150, 10, (int)height);
g.DrawRectangle(pen, barGraph);
pen.Color = Color.Blue;


Rectangles are defined as the top x, top y, width, and height. Subtract the height from your second Rectangle argument.

new Rectangle(i*(widthCalc/3), 150 - (int)height ...);