Bug 290820 - Each line in report legend is a different size
Summary: Each line in report legend is a different size
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: git (master)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-06 19:26 UTC by Ian Neal
Modified: 2014-09-29 17:22 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screenshot of badly formatted legend (10.02 KB, image/png)
2012-01-06 19:26 UTC, Ian Neal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Neal 2012-01-06 19:26:39 UTC
Created attachment 67522 [details]
Screenshot of badly formatted legend

Version:           git master (using KDE 4.7.4) 
OS:                Linux

The report contains a badly formatted legend.

Reproducible: Always

Steps to Reproduce:
1/ Create a forecast report with a number of different accounts selected that vary in name length
2/ Run report and look at legend

Actual Results:  
1/ Legend with a variety of font sizes

Expected Results:  
1/ Legend with all lines being the same font size

I guess there are a number of ways of resolving this:
1/ Pick the smallest font to be able to fit the longest line in and use that for all lines
2/ Truncate lines over a certain length and then use the smallest font to be able to fit the longest line in and use that for all lines (maybe a configurable maximum length)
3/ Have a configurable fixed font size for reports (either global and/or per report)
Comment 1 David Houlden 2012-01-06 21:24:34 UTC
Just for information, if I remember correctly, this started with the fix to one of my bug reports https://bugs.kde.org/show_bug.cgi?id=265728 

I think it may have been SVN commit 1232281 because I provided some screen shots on that bug report which don't show the behaviour Ian describes.
Comment 2 Thomas Baumgart 2012-01-22 07:07:55 UTC
I did some code reading today, and found out, that this is actually completely controlled by KDChart, the library we use to draw the graphs. AFAICT, there is no parameter to control the behavior, but then again I am not an expert for that code.
Comment 3 Cristian Oneț 2014-09-25 20:08:39 UTC
Git commit 63acd350ebb55063efc706a0a441a510c4e43120 by Cristian Oneț.
Committed on 25/09/2014 at 20:03.
Pushed by conet into branch 'master'.

Don't shrink the font used to render a ledgend entry.

It turns out that we can control this using the 'autoShrink' property.
Aushrink was disabled and the alignment was changed to left this way
we can avoid the issues described in without setting a maximum width
Related: bug 265728

while keeping a uniform font size for each legend entry as described

M  +5    -8    kmymoney/reports/kreportchartview.cpp

http://commits.kde.org/kmymoney/63acd350ebb55063efc706a0a441a510c4e43120
Comment 4 David Houlden 2014-09-26 00:08:07 UTC
This last commit feels like a step backwards to me. I now have charts where 40% of the total width is used by the legend. Previously it was about 20%. This is on investment price charts where there are some investment funds with quite long names. I much preferred the previous behavior.
Comment 5 Cristian Oneț 2014-09-26 04:33:33 UTC
Do you prefer cliping the investment name to the right to obtain more space?
Comment 6 David Houlden 2014-09-26 07:42:59 UTC
We would have to be careful with clipping the name. The names can be the same at the beginning. e.g. "Company Name Fund One" and "Company Name Fund Two". I really did think the previous behaviour was a reasonable compromise but I have a couple of suggestions. Can we reduce the legend font size. It is very large at the moment compared to say the values on the chart axis. Where is the size coming from? Is it using a default? What about making the legend a fixed percentage of the chart width and then calculate a font size from the longest name which fits in the width. That font could then be applied to all label lines. The legend percentage width could be made configurable so the user could set it to achieve a reasonable font size for the labels.
Comment 7 Cristian Oneț 2014-09-26 07:54:43 UTC
I'll try using a smaller size font.
Comment 8 Cristian Oneț 2014-09-26 17:54:55 UTC
Git commit 0f764023d1dfa4dac94f3aae787da976292934cd by Cristian Oneț.
Committed on 26/09/2014 at 17:48.
Pushed by conet into branch 'master'.

Improve the previous ledger rendering related commits.

It seems that our font settings were useless because we were making
them before adding the legend. Chart::addLegend was overwriting our
font settings with sizes 20 and 24 (relative sizes which meant that
the fonts get larger if the rendered area is increased).

Now we set the font size after adding the legend so it is set
correctly to the size of the general font (an absolute value) so
the other size related workarounds are no longer necessary.
Related: bug 265728

M  +14   -22   kmymoney/reports/kreportchartview.cpp
M  +0    -6    kmymoney/reports/kreportchartview.h

http://commits.kde.org/kmymoney/0f764023d1dfa4dac94f3aae787da976292934cd
Comment 9 David Houlden 2014-09-26 20:22:17 UTC
Thanks Cristian. It looks much better now. I still have some legends which are much wider than they were but I can reduce the fund names a bit to get round that. On the positive side I also have some legends which now take up less space. Just one more question. There is a configuration option for reports called "Maximum number of legend items to display". Is this needed after your most recent fixes? I think the option may have got added as part of the resolution for bug 265728.
Comment 10 Alvaro Soliverez 2014-09-26 20:34:31 UTC
That has to do with the height of the legends. Since this has to do with the width, that setting is probably still needed.
Comment 11 Cristian Oneț 2014-09-27 02:42:22 UTC
There's still the possibility to have too many items in the ledger so the limit is still needed. I'm thinking of adding the following behavior. If the chart has only one data set (like the net worth) we should not add the legend, what do you think?
Comment 12 Alvaro Soliverez 2014-09-27 02:52:30 UTC
It makes sense, as it would improve the detail of the chart, and the legend adds no new information
Comment 13 Cristian Oneț 2014-09-27 02:59:53 UTC
OK, then I'll do it.
Comment 14 David Houlden 2014-09-27 11:10:06 UTC
(In reply to Cristian Oneț from comment #11)
> There's still the possibility to have too many items in the ledger so the
> limit is still needed. I'm thinking of adding the following behavior. If the
> chart has only one data set (like the net worth) we should not add the
> legend, what do you think?

Yes, you are right. I just had a play with that settiing and I can see why it is still needed. Good idea to suppress the legend when it is not useful.
Comment 15 Cristian Oneț 2014-09-29 17:22:53 UTC
Git commit 02d2ebcb6f780baa0a5bec4d27e98cf6a5783d92 by Cristian Oneț.
Committed on 29/09/2014 at 17:17.
Pushed by conet into branch 'master'.

Show the report chart legend only if at least two datasets are drawn.

M  +5    -0    kmymoney/reports/kreportchartview.cpp

http://commits.kde.org/kmymoney/02d2ebcb6f780baa0a5bec4d27e98cf6a5783d92