After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 704525 - When you have a mix of chart types (bar charts and pie charts) then the pie charts do not work if the last chart is a bar chart
When you have a mix of chart types (bar charts and pie charts) then the pie c...
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Reports
2.5.x
Other Linux
: Normal normal
: ---
Assigned To: gnucash-reports-maint
gnucash-reports-maint
Depends on:
Blocks:
 
 
Reported: 2013-07-19 07:44 UTC by Carsten Rinke
Modified: 2018-06-29 23:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot GnuCash 2.5.3 Ubuntu 12.04 (152.00 KB, image/png)
2013-07-19 07:44 UTC, Carsten Rinke
  Details
Substring filter function with range (3.06 KB, patch)
2013-08-17 10:12 UTC, Carsten Rinke
committed Details | Review
Add call to gnc:substring-replace-from-to before returning the HTML string (1.13 KB, patch)
2013-08-17 10:17 UTC, Carsten Rinke
committed Details | Review

Description Carsten Rinke 2013-07-19 07:44:15 UTC
Created attachment 249586 [details]
Screenshot GnuCash 2.5.3 Ubuntu 12.04

Run the Welcome Sample Report from the Sample & Custom menu.
The Expense and Income charts will be displayed as bar charts even though they
have been added as pie charts (see attachment). Effect: There is no data in the
charts.

I tried the following:
Create a new custom multicolumn report and add an expense pie chart and an
expense bar chart.

Order A:
1. Expense Pie Chart
2. Expense Bar Chart
-> same effect has above.

Order B:
1. Expense Bar Chart
2. Expense Pie Chart
-> works as expected
Comment 1 Geert Janssens 2013-08-04 18:50:34 UTC
I have looked into this a bit further.

Order B is failing as well in a different way. While the bar chart is effectively displayed as a bar chart, the data is not showing, or maybe all packed in one vertical data point coinciding with the left edge of the graph. So currently having multiple charts in one multi-column report is not working. This is both so directly in gnucash and when loading the exported report in Firefox.

The root cause seems to be that the jquery and jqplot scripts are included multiple times. If I manually comment out all but the first inclusion of these scripts and then load the report in Firefox, the reports display nicely.

So the trick is to include the two scripts only once. But that turns out to be challenging in itself in the current report system code. My first few attempts have failed and I'm out of time for a while.

If you can figure out how to do this, I'll be happy to apply your patch.

Otherwise I'll revisit this issue at a later time.
Comment 2 Carsten Rinke 2013-08-17 10:12:14 UTC
Created attachment 251987 [details] [review]
Substring filter function with range

I checked out that removing the file names is sufficient to get things going, so not the complete lines where the scripts are loaded need to be removed (with complete path), but only the file name part needs to be removed to get things going. At least that keeps the implementation stable in case the path changes, and, as I see it, removing a substring is simpler than to identifying a whole line.

Therefore, I propose to add a substring filter function that replaces substrings within a given range of occurences.

This is based on the already existing function gnc:substring-replace and is called gnc:substring-replace-from-to.
More detailed implementation info has been added to the code as comments (similar as done for the existing functions.)

This function can be used to manipulate the resulting HTML code, filtering out all occurences of "jquery.min.js" and "jquery.jqplot.js" except for the first ones.
Comment 3 Carsten Rinke 2013-08-17 10:17:58 UTC
Created attachment 251989 [details] [review]
Add call to gnc:substring-replace-from-to before returning the HTML string

The call to gnc:substring-replace-from-to as specified in the patch above could be added to the gnc:report-run.

This patch filters out all occurrences of jquery.min.js and jquery.jqplot.js except for the first occurrences.

Successfully tested with
- GnuCash 2.5.3
- Ubuntu 12.04
Comment 4 Geert Janssens 2013-08-18 21:37:01 UTC
Comment on attachment 251987 [details] [review]
Substring filter function with range

Thank you for your patch.

A comment on your premise:
> I checked out that removing the file names is sufficient to get things going,
> so not the complete lines where the scripts are loaded need to be removed (with
> complete path), but only the file name part needs to be removed to get things
> going. At least that keeps the implementation stable in case the path changes,
> and, as I see it, removing a substring is simpler than to identifying a whole
> line.

This is not completely correct. I agree that removing only the file name part is sufficient to fix the problem. But your assumption that this is a safer fix than removing the complete path is incorrect for several reasons:

1. Between the time the html code is generated and the time the replace function is called, the path can't change. The call in report.scm to gnc:substring-replace-from-to can use the same function call as the chart functions to get exactly the same full path name.

2. Only searching on a substring is ok now, but may cause unexpected results if someone in the future adds a comment in the generated html code that also mentions jquery or jqplot. If such a comment happens to appear before the first real inclusion, all the chart reports suddenly fail to work. To be fair, this could also happen when we search for the complete path including the script opening and closing tags, but that is already more unlikely to happen.

But regardless, I think your hack is good enough as a workaround until someone comes up with a proper fix. I have one in mind: only include the jquery and jqplot script tags in the html head section for all chart reports and the multicolumn report. The other script tags can still go in the body or the separate chart reports. In principle the head tags of the separate subreports should be omitted when they are included in the multicolumn report, so that way we also can guarantee that jquery and jqplot are included only once. Unfortunately this solution is blocked by bug 706266.

As that bug is still to be investigated, I have applied your patches and included a comment in report.scm documenting the motivation for the hack.
Comment 5 John Ralls 2018-06-29 23:17:37 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=704525. Please update any external references or bookmarks.