(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
authormaedhros
Mon, 22 Jan 2007 16:26:45 +0000
changeset 5793 01b18d4550e2
parent 5792 c4dad358b30b
child 5794 8b26323509ce
(svn r8350) -Codechange: [Graphs] Use DrawStringCentered instead of a hardcoded offset to make the string appear centred.
src/graph_gui.cpp
--- a/src/graph_gui.cpp	Mon Jan 22 16:16:52 2007 +0000
+++ b/src/graph_gui.cpp	Mon Jan 22 16:26:45 2007 +0000
@@ -182,14 +182,15 @@
 			x += GRAPH_X_POSITION_SEPARATION;
 		}
 	} else {
-		/* Add 8 to make the string appear centred between the lines. */
-		x = gw->left + GRAPH_X_POSITION_BEGINNING + 8;
+		/* Draw the label under the data point rather than on the grid line. */
+		x = gw->left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
 		y = gw->top + gw->height + 1;
 		uint16 label = gw->x_values_start;
 
 		for (int i = 0; i < gw->num_on_x_axis; i++) {
 			SetDParam(0, label);
-			DrawString(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
+			DrawStringCentered(x, y, STR_01CB, GRAPH_AXIS_LABEL_COLOUR);
+
 			label += gw->x_values_increment;
 			x += GRAPH_X_POSITION_SEPARATION;
 		}