Merge lp:~widelands-dev/widelands/cleanup-statistics-plotter into lp:widelands

Proposed by Toni Förster
Status: Merged
Merged at revision: 9075
Proposed branch: lp:~widelands-dev/widelands/cleanup-statistics-plotter
Merge into: lp:widelands
Diff against target: 132 lines (+36/-16)
3 files modified
src/wui/general_statistics_menu.cc (+1/-1)
src/wui/plot_area.cc (+34/-14)
src/wui/ware_statistics_menu.cc (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/cleanup-statistics-plotter
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+365138@code.launchpad.net

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

Description of the change

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.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4654. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/511761507.
Appveyor build 4441. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_cleanup_statistics_plotter-4441.

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

I could agree with the changes except the min value of the y axis (warestatistics) plotted below the x-Axis. There it overwrites the "0" of the x-axis which looks weird. (see newstats_1).

I would vote against having it for b20 as it is no bugfix and we don't want to end up in discussions which branch is small enough to make it into b20. I think we should be equally strict to every branch / developer. For me we should only fix real showstoppers now and having b20 asap. Showstoppers means in my opinion severe bugs that happen frequently. Everything else should be postponed.

Revision history for this message
Toni Förster (stonerl) wrote :

> I could agree with the changes except the min value of the y axis
> (warestatistics) plotted below the x-Axis. There it overwrites the
> "0" of the x-axis which looks weird. (see newstats_1).

I did this on purpose. The 0 doesn't get overwritten, it gets replaces
by the min_value. But let me explain why I came to this design.

The Economy Health Graph is very unintuitive and hard to read. I
noticed this many times when playing with friends, where they didn't
really understand the graph.

The reasons are manifold. First of all the min and max value are inside
the quadrant and therefore are hard to read, because many times they
are overwritten by the plot lines. Secondly the min value is in red and
next to the red zero of the x-axes. Especially for small values the min
value could be mistaken for an erroneously drawn x-axes value.

Since I moved the max value atop the y-axes, the min value was still
in the lower right corner of the quadrant and now it looked even weirder.
Also we would still have the problem that the graph could overwrite the
min value and make it unreadable.

So I decided to remove the 0 from the x-axes and draw the min value
instead. It looked better IMHO but it was still red and easily to be
confused with the time units from the x-axes. Therefore, I decided to give
it the same colour as the max value. This should visually indicate that
both values belong to each other. It also makes it look more symmetrical.

I can provide some pictures with the min value in it original position,
but it really looks out of place there.

> I would vote against having it for b20 as it is no bugfix[...]

That's fine with me.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Since we're down to 1 bug to fix for Build 20, feature freeze needs to be taken very seriously. Any innocent-looking line of code can potentially introduce a breaking bug that would force us to postpone Build 20.

Code LGTM :)

I think having the min value in the statistics from newstats_1 is a good idea, because the bottom value is not 0. Since it bothers hessenfarmer, maybe there is a way to display both?

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

Did you try to display the y-values right of the y-axis instead of centered above and below. this would look familiar to me.

Revision history for this message
Toni Förster (stonerl) wrote :

> maybe there is a way to display both?

I tried this as well, but there isn't enough space. We cannot move the
y-axes label to the right-hand side, because the labels value can be a
anything from a one digit number up to a five digit number. To meet
these requirements, the space to the right-hand side would have to be
either variable or 50 maybe 70 pixel wide.

Either solution would look very awkward.

The numbers are centred atop and beneath the y-axes for single digit
numbers. All additional decimal numbers are prefixed

Since the code is shared between all plots, I think the way it is now is
the best compromise. Aesthetically pleasing, informative, easy to
understand and it fits all graphs.

Furthermore, the economy health graph is the only differential graph and
therefore, needs to be handled a little different from the others.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I think we should make more space to the right.

We could also make the code even more generic. I have been thinking of a function that will take a vector of labels, the line length and whether it's to be plotted vertically or horizontally. Then iterate through the vector and calculate the position according to size of the vector + plot length to draw both the tick and the label text. Some of the labels would be empty.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4688. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/517020546.
Appveyor build 4474. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_cleanup_statistics_plotter-4474.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Do you want to try hour hand at the refactoring that I suggested above before we merge this?

Revision history for this message
Toni Förster (stonerl) wrote :

I'd say we merge it as it is now. I'll look into this when I find more time.

Revision history for this message
GunChleoc (gunchleoc) wrote :

OK, let's have it then :)

@bunnybot merge

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4780. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/523885621.
Appveyor build 4536. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_cleanup_statistics_plotter-4536.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 4780. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/523885621.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Transient failure on Travis

@bunnybot merge force

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/general_statistics_menu.cc'
2--- src/wui/general_statistics_menu.cc 2019-02-23 11:00:49 +0000
3+++ src/wui/general_statistics_menu.cc 2019-04-24 08:25:42 +0000
4@@ -42,7 +42,7 @@
5
6 using namespace Widelands;
7
8-#define PLOT_HEIGHT 130
9+#define PLOT_HEIGHT 145
10 #define NR_BASE_DATASETS 11
11
12 GeneralStatisticsMenu::GeneralStatisticsMenu(InteractiveGameBase& parent,
13
14=== modified file 'src/wui/plot_area.cc'
15--- src/wui/plot_area.cc 2019-02-23 11:00:49 +0000
16+++ src/wui/plot_area.cc 2019-04-24 08:25:42 +0000
17@@ -245,7 +245,7 @@
18 kAxisLineColor, kAxisLinesWidth);
19
20 // Y Axis
21- dst.draw_line_strip({Vector2f(inner_w - kSpaceRight, kSpacing),
22+ dst.draw_line_strip({Vector2f(inner_w - kSpaceRight, kSpacing * 3),
23 Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
24 kAxisLineColor, kAxisLinesWidth);
25 // No Arrow here, since this doesn't continue.
26@@ -260,7 +260,7 @@
27
28 // The space at the end is intentional to have the tick centered
29 // over the number, not to the left
30- if (how_many_ticks != 0) {
31+ if (how_many_ticks != 0 && i != 0) {
32 std::shared_ptr<const UI::RenderedText> xtick = UI::g_fh->render(
33 xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
34 Vector2i pos(posx, inner_h - kSpaceBottom + 10);
35@@ -271,13 +271,29 @@
36 posx -= sub;
37 }
38
39- // draw yticks, one at full, one at half
40- dst.draw_line_strip(
41- {Vector2f(inner_w - kSpaceRight, kSpacing), Vector2f(inner_w - kSpaceRight - 3, kSpacing)},
42- kAxisLineColor, kAxisLinesWidth);
43- dst.draw_line_strip(
44- {Vector2f(inner_w - kSpaceRight, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2),
45- Vector2f(inner_w - kSpaceRight - 3, kSpacing + ((inner_h - kSpaceBottom) - kSpacing) / 2)},
46+ // draw yticks, one at full, one at three-quarter, one at half, one at quarter & 0
47+ dst.draw_line_strip(
48+ {Vector2f(inner_w - kSpaceRight + 3 , kSpacing * 3), Vector2f(inner_w - kSpaceRight - 3, kSpacing * 3)},
49+ kAxisLineColor, kAxisLinesWidth);
50+
51+ dst.draw_line_strip(
52+ {Vector2f(inner_w - kSpaceRight + 2, kSpacing * 3 + ((((inner_h - kSpaceBottom) + kSpacing * 3) / 2) - kSpacing * 3) / 2),
53+ Vector2f(inner_w - kSpaceRight, kSpacing * 3 + ((((inner_h - kSpaceBottom) + kSpacing * 3) / 2) - kSpacing * 3) / 2)},
54+ kAxisLineColor, kAxisLinesWidth);
55+
56+ dst.draw_line_strip(
57+ {Vector2f(inner_w - kSpaceRight + 3, ((inner_h - kSpaceBottom) + kSpacing * 3) / 2),
58+ Vector2f(inner_w - kSpaceRight, ((inner_h - kSpaceBottom) + kSpacing * 3) / 2)},
59+ kAxisLineColor, kAxisLinesWidth);
60+
61+ dst.draw_line_strip(
62+ {Vector2f(inner_w - kSpaceRight + 2, inner_h - kSpaceBottom - (inner_h - kSpaceBottom - ((inner_h - kSpaceBottom) + kSpacing * 3) / 2) / 2),
63+ Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom - (inner_h - kSpaceBottom - ((inner_h - kSpaceBottom) + kSpacing * 3) / 2) / 2)},
64+ kAxisLineColor, kAxisLinesWidth);
65+
66+ dst.draw_line_strip(
67+ {Vector2f(inner_w - kSpaceRight + 3, inner_h - kSpaceBottom),
68+ Vector2f(inner_w - kSpaceRight, inner_h - kSpaceBottom)},
69 kAxisLineColor, kAxisLinesWidth);
70
71 // print the used unit
72@@ -303,7 +319,7 @@
73 needs_update_(true),
74 lastupdate_(0),
75 xline_length_(get_inner_w() - kSpaceRight - kSpacing),
76- yline_length_(get_inner_h() - kSpaceBottom - kSpacing),
77+ yline_length_(get_inner_h() - kSpaceBottom - kSpacing * 3),
78 time_ms_(0),
79 highest_scale_(0),
80 sub_(0),
81@@ -463,6 +479,9 @@
82 dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
83 Vector2i::zero());
84 draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
85+ // Print the 0
86+ draw_value((boost::format("%u") % (0)).str(), RGBColor(255, 0, 0),
87+ Vector2i(get_inner_w() - kSpaceRight + 3, get_inner_h() - kSpaceBottom + 10), dst);
88 }
89
90 void WuiPlotArea::draw_plot(RenderTarget& dst,
91@@ -484,7 +503,8 @@
92
93 // print the maximal value into the top right corner
94 draw_value(yscale_label, RGBColor(60, 125, 0),
95- Vector2i(get_inner_w() - kSpaceRight - 3, kSpacing + 2), dst);
96+ Vector2i(get_inner_w() - kSpaceRight + 3, kSpacing + 2), dst);
97+
98 }
99
100 /**
101@@ -677,7 +697,7 @@
102 Vector2i::zero());
103
104 // yoffset of the zero line
105- float const yoffset = kSpacing + ((get_inner_h() - kSpaceBottom) - kSpacing) / 2;
106+ float const yoffset = ((get_inner_h() - kSpaceBottom) + kSpacing * 3) / 2;
107
108 // draw zero line
109 dst.draw_line_strip({Vector2f(get_inner_w() - kSpaceRight, yoffset),
110@@ -688,8 +708,8 @@
111 draw_plot(dst, yoffset, std::to_string(highest_scale_), 2 * highest_scale_);
112
113 // Print the min value
114- draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(125, 0, 0),
115- Vector2i(get_inner_w() - kSpaceRight - 3, get_inner_h() - kSpacing - 23), dst);
116+ draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(60, 125, 0),
117+ Vector2i(get_inner_w() - kSpaceRight + 3, get_inner_h() - kSpaceBottom + 10), dst);
118 }
119
120 /**
121
122=== modified file 'src/wui/ware_statistics_menu.cc'
123--- src/wui/ware_statistics_menu.cc 2019-02-23 11:00:49 +0000
124+++ src/wui/ware_statistics_menu.cc 2019-04-24 08:25:42 +0000
125@@ -34,7 +34,7 @@
126 #include "wui/plot_area.h"
127 #include "wui/waresdisplay.h"
128
129-constexpr int kPlotHeight = 130;
130+constexpr int kPlotHeight = 145;
131 constexpr int kPlotWidth = 250;
132 constexpr int kSpacing = 5;
133

Subscribers

People subscribed via source and target branches

to status/vote changes: