widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #16403
[Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
Toni Förster has proposed merging lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands.
Commit message:
Clean-up statistics' plotter:
- add ticks at 1/4 and 3/4 on the y-axes
- move y-axes ticks to the right
- draw max_value atop the y-axes
- draw a 0 instead of -0
- draw min value instead of 0
- make min_value green
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/cleanup-statistics-plotter/+merge/365138
The old plot was a little hard to read, so I did some tweaking.
Here are some comparison pictures:
https://fosuta.org/pics/old_stats_1.png
https://fosuta.org/pics/new_stats_1.png
https://fosuta.org/pics/old_stats_2.png
https://fosuta.org/pics/new_stats_2.png
https://fosuta.org/pics/old_stats_2.png
https://fosuta.org/pics/new_stats_3.png
Since it there a no breaking changes, it would be nice if it could
be part of b20. Assumed you agree with the changes.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands.
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc 2019-02-23 11:00:49 +0000
+++ src/wui/general_statistics_menu.cc 2019-03-26 22:42:04 +0000
@@ -42,7 +42,7 @@
using namespace Widelands;
-#define PLOT_HEIGHT 130
+#define PLOT_HEIGHT 145
#define NR_BASE_DATASETS 11
GeneralStatisticsMenu::GeneralStatisticsMenu(InteractiveGameBase& parent,
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2019-02-23 11:00:49 +0000
+++ src/wui/plot_area.cc 2019-03-26 22:42:04 +0000
@@ -245,7 +245,7 @@
kAxisLineColor, kAxisLinesWidth);
// Y Axis
- dst.draw_line_strip({Vector2f(inner_w - kSpaceRight, kSpacing),
+ dst.draw_line_strip({Vector2f(inner_w - kSpaceRight, kSpacing * 3),
Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
kAxisLineColor, kAxisLinesWidth);
// No Arrow here, since this doesn't continue.
@@ -260,7 +260,7 @@
// The space at the end is intentional to have the tick centered
// over the number, not to the left
- if (how_many_ticks != 0) {
+ if (how_many_ticks != 0 && i != 0) {
std::shared_ptr<const UI::RenderedText> xtick = UI::g_fh->render(
xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
Vector2i pos(posx, inner_h - kSpaceBottom + 10);
@@ -271,13 +271,29 @@
posx -= sub;
}
- // draw yticks, one at full, one at half
- dst.draw_line_strip(
- {Vector2f(inner_w - kSpaceRight, kSpacing), Vector2f(inner_w - kSpaceRight - 3, kSpacing)},
- kAxisLineColor, kAxisLinesWidth);
- dst.draw_line_strip(
- {Vector2f(inner_w - kSpaceRight, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2),
- Vector2f(inner_w - kSpaceRight - 3, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2)},
+ // draw yticks, one at full, one at three-quarter, one at half, one at quarter & 0
+ dst.draw_line_strip(
+ {Vector2f(inner_w - kSpaceRight + 3 , kSpacing * 3), Vector2f(inner_w - kSpaceRight - 3, kSpacing * 3)},
+ kAxisLineColor, kAxisLinesWidth);
+
+ dst.draw_line_strip(
+ {Vector2f(inner_w - kSpaceRight + 2, kSpacing * 3 + ((((inner_h - kSpaceBottom) + kSpacing * 3) / 2) - kSpacing * 3) / 2),
+ Vector2f(inner_w - kSpaceRight, kSpacing * 3 + ((((inner_h - kSpaceBottom) + kSpacing * 3) / 2) - kSpacing * 3) / 2)},
+ kAxisLineColor, kAxisLinesWidth);
+
+ dst.draw_line_strip(
+ {Vector2f(inner_w - kSpaceRight + 3, ((inner_h - kSpaceBottom) + kSpacing * 3) / 2),
+ Vector2f(inner_w - kSpaceRight, ((inner_h - kSpaceBottom) + kSpacing * 3) / 2)},
+ kAxisLineColor, kAxisLinesWidth);
+
+ dst.draw_line_strip(
+ {Vector2f(inner_w - kSpaceRight + 2, inner_h - kSpaceBottom - (inner_h - kSpaceBottom - ((inner_h - kSpaceBottom) + kSpacing * 3) / 2) / 2),
+ Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom - (inner_h - kSpaceBottom - ((inner_h - kSpaceBottom) + kSpacing * 3) / 2) / 2)},
+ kAxisLineColor, kAxisLinesWidth);
+
+ dst.draw_line_strip(
+ {Vector2f(inner_w - kSpaceRight + 3, inner_h - kSpaceBottom),
+ Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
kAxisLineColor, kAxisLinesWidth);
// print the used unit
@@ -303,7 +319,7 @@
needs_update_(true),
lastupdate_(0),
xline_length_(get_inner_w() - kSpaceRight - kSpacing),
- yline_length_(get_inner_h() - kSpaceBottom - kSpacing),
+ yline_length_(get_inner_h() - kSpaceBottom - kSpacing * 3),
time_ms_(0),
highest_scale_(0),
sub_(0),
@@ -463,6 +479,9 @@
dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
Vector2i::zero());
draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
+ // Print the 0
+ draw_value((boost::format("%u") % (0)).str(), RGBColor(255, 0, 0),
+ Vector2i(get_inner_w() - kSpaceRight + 3, get_inner_h() - kSpaceBottom + 10), dst);
}
void WuiPlotArea::draw_plot(RenderTarget& dst,
@@ -484,7 +503,8 @@
// print the maximal value into the top right corner
draw_value(yscale_label, RGBColor(60, 125, 0),
- Vector2i(get_inner_w() - kSpaceRight - 3, kSpacing + 2), dst);
+ Vector2i(get_inner_w() - kSpaceRight + 3, kSpacing + 2), dst);
+
}
/**
@@ -677,7 +697,7 @@
Vector2i::zero());
// yoffset of the zero line
- float const yoffset = kSpacing + ((get_inner_h() - kSpaceBottom) - kSpacing) / 2;
+ float const yoffset = ((get_inner_h() - kSpaceBottom) + kSpacing * 3) / 2;
// draw zero line
dst.draw_line_strip({Vector2f(get_inner_w() - kSpaceRight, yoffset),
@@ -688,8 +708,8 @@
draw_plot(dst, yoffset, std::to_string(highest_scale_), 2 * highest_scale_);
// Print the min value
- draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(125, 0, 0),
- Vector2i(get_inner_w() - kSpaceRight - 3, get_inner_h() - kSpacing - 23), dst);
+ draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(60, 125, 0),
+ Vector2i(get_inner_w() - kSpaceRight + 3, get_inner_h() - kSpaceBottom + 10), dst);
}
/**
=== modified file 'src/wui/ware_statistics_menu.cc'
--- src/wui/ware_statistics_menu.cc 2019-02-23 11:00:49 +0000
+++ src/wui/ware_statistics_menu.cc 2019-03-26 22:42:04 +0000
@@ -34,7 +34,7 @@
#include "wui/plot_area.h"
#include "wui/waresdisplay.h"
-constexpr int kPlotHeight = 130;
+constexpr int kPlotHeight = 145;
constexpr int kPlotWidth = 250;
constexpr int kSpacing = 5;
Follow ups
-
[Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: noreply, 2019-04-24
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: GunChleoc, 2019-04-24
-
[Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: bunnybot, 2019-04-24
-
[Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: bunnybot, 2019-04-24
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: GunChleoc, 2019-04-24
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: Toni Förster, 2019-04-24
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: GunChleoc, 2019-04-24
-
[Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: bunnybot, 2019-04-08
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: GunChleoc, 2019-03-27
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: Toni Förster, 2019-03-27
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: hessenfarmer, 2019-03-27
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: GunChleoc, 2019-03-27
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: Toni Förster, 2019-03-27
-
Re: [Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: hessenfarmer, 2019-03-27
-
[Merge] lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands
From: bunnybot, 2019-03-27