Bug 383161 - Broken net worth graph in case data contains only the same value
Summary: Broken net worth graph in case data contains only the same value
Status: RESOLVED DUPLICATE of bug 338642
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: unspecified
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-05 09:15 UTC by Ralf Habacker
Modified: 2017-08-07 08:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.8.1


Attachments
kmymoney test file (24.92 KB, text/xml)
2017-08-05 09:15 UTC, Ralf Habacker
Details
Net worth graph on master (23.49 KB, image/png)
2017-08-06 06:09 UTC, NSLW
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2017-08-05 09:15:11 UTC
Created attachment 107083 [details]
kmymoney test file

After updating kdchart to 2.6 in 4.8 branch (see bug 382427) kmymoney shows a broken net worse graph in case the graph contains only data with the same value

How to reproduce: 
1. compile kmymoney from 4.8 branch
2. download kmymoney test file from this bug
3. start kmymoney and open file downloaded with 2.
4. Choose Reports -> net worth test report

What happens ?
There is no graph shown and the x axis labels are displayed at the top of the page

What is expected ?
kmymoney should show the complete graph
Comment 1 Ralf Habacker 2017-08-05 09:17:17 UTC
Git commit df06a0d0e44c4b21c9675abff4f7809534b65e05 by Ralf Habacker.
Committed on 05/08/2017 at 09:16.
Pushed by habacker into branch '4.8'.

Fix 'Broken net worth graph in case data contains only the same value'

If chart model contains only data with the same value KDChart 2.6
automatically adjust the vertical range to a non visible area
and displays x axis labels at the top of the diagram.

The fix is to disable "auto adjust vertical range to data". The used
value has been empirically determined.

FIXED-IN:4.8.1

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

https://commits.kde.org/kmymoney/df06a0d0e44c4b21c9675abff4f7809534b65e05
Comment 2 NSLW 2017-08-05 19:05:00 UTC
Ralf, it would be better if you would test master version before 'producing' bug.

*** This bug has been marked as a duplicate of bug 338642 ***
Comment 3 Ralf Habacker 2017-08-05 21:35:20 UTC
(In reply to NSLW from comment #2)
> Ralf, it would be better if you would test master version before 'producing'
> bug.
> *** This bug has been marked as a duplicate of bug 338642 ***

I don't think that this is the same bug as 338642. 

git master now contains a short KChart widget test. You may modify kmymoney/reports/tests/chart-test.cpp as shown below:

  QVector< double > vec0,  vec1, vec2;
-  vec0 << 5 << 1 << 3 << 4 << 1;
-  vec1 << 3 << 6 << 2 << 4 << 8;
-  vec2 << 0 << 7 << 1 << 2 << 1;´
+// vec0 << 5 << 1 << 3 << 4 << 1;
+// vec1 << 3 << 6 << 2 << 4 << 8;
+  vec3 << 7 << 7 << 7 << 7 << 7;

and let the app run which shows the mentioned behavior.

Then modify

  CartesianAxis *yAxis = new CartesianAxis (widget.lineDiagram() );
+ static_cast<CartesianCoordinatePlane*>(widget.lineDiagram()->coordinatePlane())->setAutoAdjustVerticalRangeToData(101);

and run again - bug is fixed

then modify again

- static_cast<CartesianCoordinatePlane*>(widget.lineDiagram()->coordinatePlane())->setAutoAdjustVerticalRangeToData(101);
+ static_cast<CartesianCoordinatePlane*>(widget.lineDiagram()->coordinatePlane())->setAutoAdjustVerticalRangeToData(2);

and compile and run again - bug is not fixed.

If you can confirm please restore bug state.
Comment 4 Ralf Habacker 2017-08-05 21:39:02 UTC
(In reply to Ralf Habacker from comment #3)
> 
>   QVector< double > vec0,  vec1, vec2;
> -  vec0 << 5 << 1 << 3 << 4 << 1;
> -  vec1 << 3 << 6 << 2 << 4 << 8;
> -  vec2 << 0 << 7 << 1 << 2 << 1;´
> +// vec0 << 5 << 1 << 3 << 4 << 1;
> +// vec1 << 3 << 6 << 2 << 4 << 8;
> +  vec3 << 7 << 7 << 7 << 7 << 7;
This should be vec2 instead, sorry.
Comment 5 NSLW 2017-08-06 06:09:02 UTC
Created attachment 107099 [details]
Net worth graph on master

(In reply to Ralf Habacker from comment #3)
> I don't think that this is the same bug as 338642. 


I tested your file on master (see attached image) and it doesn't pose problem for me. All test passed as well.
With your patch you caused to lose one of nice feature I introduced there and additionally introduced a big segmentation fault, crash or something like that.

Not all of graphs are on CartesianCoordinatePlane and you make static_cast for all of them there.

Your behaviour is irritating. You don't test your code (this is great example), you don't consult your code (see bug #383165) and the code you're pushing is misleading (see commit cb841612e11349aca26b6c4af4ff7dced9a95357). Your work is very much obfuscated, so come to order or stop doing that.
Comment 6 Ralf Habacker 2017-08-07 08:59:07 UTC
Git commit 6e5b5fd698aac46906e37b2ba3ac0c1e2fc5edfb by Ralf Habacker.
Committed on 07/08/2017 at 08:58.
Pushed by habacker into branch '4.8'.

Do not use static cast to avoid crashes in case the plane does not have the expected type

Thanks to Lukasz Wojnilowicz for pointing out.

M  +4    -2    kmymoney/reports/kreportchartview.cpp

https://commits.kde.org/kmymoney/6e5b5fd698aac46906e37b2ba3ac0c1e2fc5edfb