Bug 265728 - Investment charts not redrawn after being covered
Summary: Investment charts not redrawn after being covered
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: SVN
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-07 21:57 UTC by David Houlden
Modified: 2014-09-26 17:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Unused space around legend text (175.75 KB, image/jpeg)
2011-05-15 16:27 UTC, David Houlden
Details
No unused space around legend (164.47 KB, image/jpeg)
2011-05-15 16:29 UTC, David Houlden
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Houlden 2011-02-07 21:57:26 UTC
Version:           SVN trunk (using KDE 4.5.5) 
OS:                Linux

Open one of the investment charts such as the Investment price Graph.Click on configure then on OK. A customised version of the chart will open. Now close the customised chart or click on the tab to view the original chart. In either case the original chart will be blank. It is not redrawn. Changing the chart to a report then back again will redraw the chart.

Reproducible: Always
Comment 1 Cristian Oneț 2011-05-14 16:28:04 UTC
SVN commit 1231894 by conet:

BUG: 265728
Sorry for the multiple changes (again) astyle keeps getting in my way:
1. Whitespace changes - astyle's fault
2. Removal of takeAxis-deleteAxis - if it's not needed by bar charts it shouldn't be needed by line charts (the chart will delete the axis)
3. The actual bugfix - this is a longer story see bellow

I managed to reproduce the bug described here by running the following steps (note that it will only work on a chart without a legend):
a. Press configure of a custom line chart without a legend (more items the the report setting)
b. Press cancel without changing anything
c. observe that the charts content is not visible
d. there are multiple ways to make it visible, resize the window, toggle chart/report/chart, etc.

The bottom line is that KDChart doesn't handle well charts without legends. So the fix involves changing a feature we already have.
Right now if the number of items was greater then a configuration setting we just hid the legend. Change this to always show the legend with a maximum of items given by the configuration setting... I hope this change feels right to everyone (otherwise we should hide the legend when the setting is 0 and fix KDChart to work without a legend)
This was a long description :)

 M  +7 -17     dialogs/settings/ksettingsreportsdecl.ui  
 M  +3 -23     reports/kreportchartview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1231894
Comment 2 David Houlden 2011-05-14 18:24:43 UTC
Original problem is now fixed for me. Thanks Cristian. I'm not sure if this is related to the fix but I'll report it here anyway for now.
I can configure a chart to display 21 investments and the legend just fits in the height available for the chart. If I then configure it to show 22, something odd happens. The chart gets redrawn and the font used for the legend is now bigger. Only the top 20 lines in the legend are now visible (remember it had room for 21 before) and the bottom of the legend and chart are no longer visible. With no scroll bar it is not possible to get to the bottom of the chart.
Comment 3 Cristian Oneț 2011-05-15 09:54:24 UTC
SVN commit 1232054 by conet:

BUG: 265728
Automatically adjust the maximum height of the legend to the height of the widget that displays the chart. This was the user will see as many items he has configured adjusted to the actual size of the widget. This fixes the second remark posted in this report.
Since I didn't find a way to do this using KDChart configuration I used resizeEvent to adjust the maximumHeight (since we position the legend at East) of the legend.

 M  +18 -0     kreportchartview.cpp  
 M  +6 -0      kreportchartview.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1232054
Comment 4 David Houlden 2011-05-15 11:00:24 UTC
Nice solution, thanks again Cristian. I have however noticed something else. As I increase the number of items in the legend, the font size used in the legend reduces to allow the requested number of items to be displayed. That is what I would expect to happen. However, as the font size reduces, the width of the legend area is increasing. With a large number of items in the legend I get a small font used with a very wide legend area because there is a large gap between the coloured dots and the legend names and another large gap to the right of the legend names. 

If this could be fixed then maybe we don't even need a configuration item at all.
Comment 5 Cristian Oneț 2011-05-15 15:39:03 UTC
I didn't saw the width growth aspect that disturbing (with 20 items using the smallest resolution). Could you attach a screenshot with your findings? Right now the only constraint is set for the legend height which seems right since all legend rows have uniform height. Setting a correct constraint on the legend width would be more difficult since the row length could vary a lot on different datasets.
I also don't think that we can't remove the configuration option since there is a limit to the number of rows that can be readably displayed in the legend and if the user has more datasets in the chart then it's nice that he can keep the legend readable on his machine (the limit is dependent on the resolution).
Comment 6 David Houlden 2011-05-15 16:27:52 UTC
Created attachment 60030 [details]
Unused space around legend text
Comment 7 David Houlden 2011-05-15 16:29:20 UTC
Created attachment 60031 [details]
No unused space around legend
Comment 8 David Houlden 2011-05-15 16:31:30 UTC
Added a couple of screenshots as requested by Cristian.
Comment 9 Cristian Oneț 2011-05-16 20:35:16 UTC
SVN commit 1232281 by conet:

BUG: 265728
Automatically adjust the maximum width of the legend to the width of the widget that displays the chart.

 M  +3 -0      kreportchartview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1232281
Comment 10 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 290820

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 11 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 290820

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

http://commits.kde.org/kmymoney/0f764023d1dfa4dac94f3aae787da976292934cd