Here comes the diff file. In the meantime, I'll keep looking into the labeling of values on the barchart plot (that seems a bit more difficult).
Thanks Davide 2008/2/12 Ian Lewis <[EMAIL PROTECTED]>: > David, > > If you made the changes in the local SVN repo then you can do: > > svn diff > gridlines.diff > > and send us the gridlines.diff file. > > Thanks, > Ian > > 2008/2/12, Davide Imbeni <[EMAIL PROTECTED]>: > > > > Hi again, > > > > I started to look into goffice, and dealt with the grid option, as a > > start > > (easy things first...). > > > > I think I got it working in a pretty enough way (for me). I added a few > > lines in src/gnome-utils/gnc-html-graph-gog.c that actually draw the > > y-major-grid on some grayed background, and added the relevant option > > "Background Grid" in the Display Tab of the barchart report. > > All in all, changed (as few lines as possible) > > src/gnome-utils/gnc-html-graph-gog.c > > src/report/report-system/html-barchart.scm > > src/report/report-system/report-system.scm > > src/report/standard-reports/category-barchart.scm > > > > Now the questions: > > > > How do I submit this changes to you, so as to get feedback/comments and > > eventually, hopefully, have this little piece of code included in the > > trunk? > > Please assume very basic knowledge of svn and diff... > > > > Since I modified some gnucash code rather than creating a custom report, > > if > > I don't get them incorporated I will loose my changes when gnucash > > evolves, > > right? > > > > BTW, I was working on r16930, downloaded via SVN. > > > > Thanks > > > > Davide > > > > > > > > On Feb 7, 2008 6:32 PM, Davide Imbeni <[EMAIL PROTECTED]> wrote: > > > > > Thanks for your indications. > > > I will start to work on it and report as soon as I have something > > ready, > > > or (more likely) additional doubts. > > > As I said, I will first have to learn A LOT, so don't expect fast > > > patches... > > > > > > Thank you > > > > > > Davide > > > > > > > > > > > > On Feb 7, 2008 6:08 PM, Josh Sled <[EMAIL PROTECTED]> wrote: > > > > > > > "Davide Imbeni" <[EMAIL PROTECTED]> writes: > > > > > I would like to change slightly the appearance of the plots in > > > > bar-chart > > > > > reports. > > > > > As it is now it's a bit difficult to get an idea of the level of > > the > > > > bars (a > > > > > part from the first one on the left), so I would like to add a > > grid to > > > > the > > > > > plot or, even better, have the actual numeric values visible (e.g. > > > > when > > > > > clicking on the corresponding bar, or when pointing it without > > > > clicking, or > > > > > even as a label close to it) > > > > > > > > These things would be provided by modifying how we call libgoffice, > > > > which > > > > provides the actual plotting. The primary binding code between > > gnucash > > > > and > > > > goffice is in src/gnome-utils/gnc-html-graph-gog.c. > > > > > > > > The interface between the reports and that code is through a couple > > of > > > > levels… > > > > > > > > The report (scm code) will emit an <object> tag with <param> tags > > for > > > > the > > > > various parameters. See src/report/report-system/html-barchart.scm. > > > > > > > > GtkHtml is configured for <object> tags (with a particular class-id) > > to > > > > be > > > > handled by the aforementioned gnc-html-graph-gog code. It then > > parses > > > > the > > > > params/data, and converts it into goffice's interface, and renders > > the > > > > report > > > > into a pixmap. The pixmap is then returned to GtkHtml as the > > rendering > > > > of > > > > the <object> tag. > > > > > > > > > I don't know anything about scheme, guile, and extremely little > > about > > > > html, > > > > > and before continuing my research, I would like to get directions > > and > > > > > suggestions from the experts. > > > > > > > > > > Where to start from? Do I have to dig into scheme? Shall I create > > a > > > > custom > > > > > report or change something in the stylesheet? > > > > > > > > - Make sure you know what's supported by goffice, and the details of > > > > what it > > > > needs (for, say, labels on chart segments). > > > > - Modify the pie/bar-chart generator code for those new parameters. > > > > - Modify the gnc-html-graph-gog code for those new parameters. > > > > - Modify the reports to use the new pie/bar-chart generator code. > > > > > > > > > > > > We're here and happy to help if you have any questions. > > > > > > > > -- > > > > ...jsled > > > > http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo > > [EMAIL PROTECTED] > > > > > > > > > > > > _______________________________________________ > > gnucash-devel mailing list > > gnucash-devel@gnucash.org > > https://lists.gnucash.org/mailman/listinfo/gnucash-devel > > > >
Index: src/report/standard-reports/category-barchart.scm =================================================================== --- src/report/standard-reports/category-barchart.scm (revision 16930) +++ src/report/standard-reports/category-barchart.scm (working copy) @@ -81,6 +81,7 @@ (define optname-plot-width (N_ "Plot Width")) (define optname-plot-height (N_ "Plot Height")) (define optname-sort-method (N_ "Sort Method")) +(define optname-y-major-grid (N_ "Background Grid")) (define (options-generator account-types reverse-balance?) (let* ((options (gnc:new-options)) @@ -146,6 +147,12 @@ "c" (N_ "Maximum number of bars in the chart") 8 2 24 0 1)) + (add-option + (gnc:make-simple-boolean-option + gnc:pagename-display optname-y-major-grid + "b" + (N_ "Add background grid (Y axis)") #f)) + (gnc:options-add-plot-size! options gnc:pagename-display optname-plot-width optname-plot-height "d" 400 400) @@ -199,6 +206,7 @@ (account-levels (get-option gnc:pagename-accounts optname-levels)) (stacked? (get-option gnc:pagename-display optname-stacked)) + (y-major-grid? (get-option gnc:pagename-display optname-y-major-grid)) (show-fullname? (get-option gnc:pagename-display optname-fullname)) (max-slices (inexact->exact (get-option gnc:pagename-display optname-slices))) @@ -420,6 +428,7 @@ chart (gnc-commodity-get-mnemonic report-currency)) (gnc:html-barchart-set-row-labels-rotated?! chart #t) (gnc:html-barchart-set-stacked?! chart stacked?) + (gnc:html-barchart-set-y-major-grid?! chart y-major-grid?) ;; If this is a stacked barchart, then reverse the legend. ;; Doesn't do what you'd expect. - DRH ;; It does work, but needs Guppi 0.40.4. - cstim Index: src/report/report-system/html-barchart.scm =================================================================== --- src/report/report-system/html-barchart.scm (revision 16930) +++ src/report/report-system/html-barchart.scm (working copy) @@ -41,7 +41,8 @@ button-3-bar-urls button-1-legend-urls button-2-legend-urls - button-3-legend-urls))) + button-3-legend-urls + y-major-grid?))) (define gnc:html-barchart? (record-predicate <html-barchart>)) @@ -56,7 +57,7 @@ (define (gnc:make-html-barchart) (gnc:make-html-barchart-internal -1 -1 #f #f #f #f '() '() '() - #f #f #f '() #f #f #f #f #f #f)) + #f #f #f '() #f #f #f #f #f #f #f)) (define gnc:html-barchart-data (record-accessor <html-barchart> 'data)) @@ -136,6 +137,12 @@ (define gnc:html-barchart-set-subtitle! (record-modifier <html-barchart> 'subtitle)) +(define gnc:html-barchart-y-major-grid? + (record-accessor <html-barchart> 'y-major-grid?)) + +(define gnc:html-barchart-set-y-major-grid?! + (record-modifier <html-barchart> 'y-major-grid?)) + ;; Note: ATM you can specify one url per column, but this url will be ;; used for all of the rows. Otherwise we could have cols*rows urls ;; (quite a lot), but this first requires fixing @@ -428,6 +435,10 @@ (push (if (gnc:html-barchart-stacked? barchart) "1\">\n" "0\">\n")) + (push " <param name=\"y_major_grid\" value=\"") + (push (if (gnc:html-barchart-y-major-grid? barchart) + "1\">\n" + "0\">\n")) (push " <param name=\"legend_reversed\" value=\"") (push (if (gnc:html-barchart-legend-reversed? barchart) "1\">\n" Index: src/report/report-system/report-system.scm =================================================================== --- src/report/report-system/report-system.scm (revision 16930) +++ src/report/report-system/report-system.scm (working copy) @@ -182,6 +182,8 @@ (export gnc:html-barchart-set-row-labels-rotated?!) (export gnc:html-barchart-stacked?) (export gnc:html-barchart-set-stacked?!) +(export gnc:html-barchart-y-major-grid?) +(export gnc:html-barchart-set-y-major-grid?!) (export gnc:html-barchart-col-labels) (export gnc:html-barchart-set-col-labels!) (export gnc:html-barchart-col-colors) Index: src/gnome-utils/gnc-html-graph-gog.c =================================================================== --- src/gnome-utils/gnc-html-graph-gog.c (revision 16930) +++ src/gnome-utils/gnc-html-graph-gog.c (working copy) @@ -394,6 +394,7 @@ * col_colors:string[] * rotate_row_labels:boolean * stacked:boolean + * y_major_grid:boolean **/ static gboolean handle_barchart(gnc_html * html, GtkHTMLEmbedded * eb, gpointer unused) @@ -410,6 +411,7 @@ gboolean stacked = FALSE; char *bar_type = "normal"; int bar_overlap = 0 /*percent*/; // seperate bars; no overlap. + gboolean y_major_grid = FALSE; gtkhtml_pre_3_10_1_bug_workaround (eb); @@ -418,7 +420,7 @@ // series-elements => segments [gnc:rows] { char *data_rows_str, *data_cols_str, *data_str, *col_labels_str, *row_labels_str; - char *col_colors_str, *rotate_row_labels_str = NULL, *stacked_str = NULL; + char *col_colors_str, *rotate_row_labels_str = NULL, *stacked_str = NULL, *y_major_grid_str = NULL; data_rows_str = g_hash_table_lookup (eb->params, "data_rows"); data_cols_str = g_hash_table_lookup (eb->params, "data_cols"); @@ -428,9 +430,11 @@ col_colors_str = g_hash_table_lookup (eb->params, "col_colors"); rotate_row_labels_str = g_hash_table_lookup (eb->params, "rotate_row_labels"); stacked_str = g_hash_table_lookup (eb->params, "stacked"); + y_major_grid_str = g_hash_table_lookup (eb->params, "y_major_grid"); rotate_row_labels = (gboolean) atoi (rotate_row_labels_str); stacked = (gboolean) atoi (stacked_str); + y_major_grid = (gboolean) atoi (y_major_grid_str); #if 0 // too strong at the moment. g_return_val_if_fail (data_rows_str != NULL @@ -462,7 +466,7 @@ g_object_set (G_OBJECT (plot), //"vary_style_by_element", TRUE, "type", bar_type, - "overlap_percentage", bar_overlap, + "overlap_percentage", bar_overlap, NULL); label_data = go_data_vector_str_new ((char const * const *)row_labels, data_rows, NULL); { @@ -507,6 +511,13 @@ gog_style_set_text_angle (style, 90.0); } + if (y_major_grid) { + gog_object_add_by_name(chart,"Grid", NULL); + GogObject *object = gog_object_get_child_by_role ( + chart, gog_object_find_role_by_name (chart, "Y-Axis")); + gog_object_add_by_name (GOG_OBJECT (object),"MajorGrid", NULL); + } + set_chart_titles_from_hash (chart, eb); set_chart_axis_labels_from_hash (chart, eb);
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel