← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~nomeata/widelands/976077 into lp:widelands

 

Joachim Breitner has proposed merging lp:~nomeata/widelands/976077 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #976077 in widelands: "x\y axis in ware statistics are wrong"
  https://bugs.launchpad.net/widelands/+bug/976077

For more details, see:
https://code.launchpad.net/~nomeata/widelands/976077/+merge/131729
-- 
https://code.launchpad.net/~nomeata/widelands/976077/+merge/131729
Your team Widelands Developers is requested to review the proposed merge of lp:~nomeata/widelands/976077 into lp:widelands.
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc	2012-09-21 21:36:07 +0000
+++ src/wui/plot_area.cc	2012-10-27 12:01:23 +0000
@@ -57,7 +57,8 @@
 UI::Panel (parent, x, y, w, h),
 spacing(5),
 space_at_bottom(15),
-space_at_right(5),
+space_at_right(10),
+space_left_of_label(15),
 m_time    (TIME_GAME),
 m_sample_rate(0),
 m_plotmode(PLOTMODE_ABSOLUTE),
@@ -212,7 +213,7 @@
 
 	//  plot the pixels
 	float sub =
-		xline_length
+		(xline_length - space_left_of_label)
 		/
 		(static_cast<float>(time_in_ms_)
 		 /
@@ -237,7 +238,7 @@
 				}
 
 				dataset = &m_data;
-				sub = xline_length / static_cast<float>(nr_samples);
+				sub = (xline_length - space_left_of_label) / static_cast<float>(nr_samples);
 			}
 
 			draw_plot_line
@@ -380,7 +381,7 @@
 	UI::TextStyle xtickstyle(UI::TextStyle::ui_small());
 	xtickstyle.fg = RGBColor(255, 0, 0);
 
-	float sub = xline_length / how_many_ticks;
+	float sub = (xline_length - space_left_of_label) / how_many_ticks;
 	float posx = get_inner_w() - space_at_right;
 
 	for (uint32_t i = 0; i <= how_many_ticks; ++i) {
@@ -389,9 +390,11 @@
 			 static_cast<int32_t>(posx), get_inner_h() - space_at_bottom + 3,
 			 LINE_COLOR, 2);
 
+		// The space at the end is intentional to have the tick centered
+		// over the number, not to the left
 		snprintf
 			(buffer, sizeof(buffer),
-			 "%u", max_x / how_many_ticks * i);
+			 "-%u ", max_x / how_many_ticks * i);
 
 		UI::g_fh->draw_text
 			(dst, xtickstyle,

=== modified file 'src/wui/plot_area.h'
--- src/wui/plot_area.h	2012-02-15 21:25:34 +0000
+++ src/wui/plot_area.h	2012-10-27 12:01:23 +0000
@@ -107,6 +107,7 @@
 	int32_t const spacing;
 	int32_t const space_at_bottom;
 	int32_t const space_at_right;
+	int32_t const space_left_of_label;
 
 	static const uint32_t time_in_ms[];
 	static const uint32_t nr_samples = 30;   // How many samples per diagramm when relative plotting


Follow ups