r16150 - gnucash/trunk/src - Handle marker shape and color options of scatter plots, #353871.
Andreas Köhler
andi5 at cvs.gnucash.org
Sun Jun 3 15:43:42 EDT 2007
Author: andi5
Date: 2007-06-03 15:43:40 -0400 (Sun, 03 Jun 2007)
New Revision: 16150
Trac: http://svn.gnucash.org/trac/changeset/16150
Modified:
gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c
gnucash/trunk/src/report/report-system/html-scatter.scm
Log:
Handle marker shape and color options of scatter plots, #353871.
Lost in translation, Guppi -> GOffice.
Modified: gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c 2007-06-03 19:43:35 UTC (rev 16149)
+++ gnucash/trunk/src/gnome-utils/gnc-html-graph-gog.c 2007-06-03 19:43:40 UTC (rev 16150)
@@ -33,6 +33,7 @@
#include "gnc-html.h"
#include "gnc-engine.h"
#include <goffice/goffice.h>
+#include <goffice/graph/gog-chart.h>
#include <goffice/graph/gog-graph.h>
#include <goffice/graph/gog-object.h>
#ifdef GOFFICE_WITH_CAIRO
@@ -48,6 +49,7 @@
#include <goffice/graph/gog-plot.h>
#include <goffice/graph/gog-series.h>
#include <goffice/utils/go-color.h>
+#include <goffice/utils/go-marker.h>
#include <goffice/graph/gog-data-set.h>
#include <goffice/data/go-data-simple.h>
#include <goffice/app/go-plugin.h>
@@ -514,8 +516,11 @@
GogPlot *plot;
GogSeries *series;
GOData *sliceData;
+ GogStyle *style;
int datasize;
double *xData, *yData;
+ gchar *marker_str, *color_str;
+ gboolean fill = FALSE;
gtkhtml_pre_3_10_1_bug_workaround(eb);
@@ -530,6 +535,9 @@
yDataStr = g_hash_table_lookup( eb->params, "y_data" );
yData = read_doubles( yDataStr, datasize );
+
+ marker_str = g_hash_table_lookup(eb->params, "marker");
+ color_str = g_hash_table_lookup(eb->params, "color");
}
if (!create_basic_plot_elements("GogXYPlot", &graph, &chart, &plot))
@@ -538,6 +546,7 @@
}
series = gog_plot_new_series( plot );
+ style = gog_styled_object_get_style(GOG_STYLED_OBJECT(series));
sliceData = go_data_vector_val_new( xData, datasize, NULL );
gog_series_set_dim( series, 0, sliceData, NULL );
@@ -547,6 +556,62 @@
gog_series_set_dim( series, 1, sliceData, NULL );
go_data_emit_changed (GO_DATA (sliceData));
+ /* set marker shape */
+ if (marker_str) {
+ GOMarkerShape shape;
+
+ if (g_str_has_prefix(marker_str, "filled ")) {
+ fill = TRUE;
+ marker_str += 7;
+ }
+ shape = go_marker_shape_from_str(marker_str);
+ if (shape != GO_MARKER_NONE) {
+ style->marker.auto_shape = FALSE;
+ go_marker_set_shape(style->marker.mark, shape);
+ } else {
+ g_warning("cannot parse marker shape [%s]", marker_str);
+ }
+ }
+
+ /* set marker and line colors */
+ if (color_str) {
+ GdkColor color;
+ if (gdk_color_parse(color_str, &color)) {
+ style->marker.auto_outline_color = FALSE;
+ go_marker_set_outline_color(style->marker.mark, GDK_TO_UINT(color));
+ style->line.auto_color = FALSE;
+ style->line.color = GDK_TO_UINT(color);
+ } else {
+ g_warning("cannot parse color [%s]", color_str);
+ }
+ }
+
+ /* set marker fill colors */
+ if (fill) {
+ style->marker.auto_fill_color = style->marker.auto_outline_color;
+ go_marker_set_fill_color(style->marker.mark,
+ go_marker_get_outline_color(style->marker.mark));
+ } else {
+ GogStyle *chart_style =
+ gog_styled_object_get_style(GOG_STYLED_OBJECT(chart));
+
+ if (chart_style->fill.type == GOG_FILL_STYLE_PATTERN
+ && chart_style->fill.pattern.pattern == GO_PATTERN_SOLID) {
+ style->marker.auto_fill_color = FALSE;
+ go_marker_set_fill_color(style->marker.mark,
+ chart_style->fill.pattern.back);
+ } else if (chart_style->fill.type == GOG_FILL_STYLE_PATTERN
+ && chart_style->fill.pattern.pattern
+ == GO_PATTERN_FOREGROUND_SOLID) {
+ style->marker.auto_fill_color = FALSE;
+ go_marker_set_fill_color(style->marker.mark,
+ chart_style->fill.pattern.fore);
+ } else {
+ g_warning("fill color of markers can only be set like a solid fill "
+ "pattern of the chart");
+ }
+ }
+
set_chart_titles_from_hash(chart, eb);
set_chart_axis_labels_from_hash(chart, eb);
Modified: gnucash/trunk/src/report/report-system/html-scatter.scm
===================================================================
--- gnucash/trunk/src/report/report-system/html-scatter.scm 2007-06-03 19:43:35 UTC (rev 16149)
+++ gnucash/trunk/src/report/report-system/html-scatter.scm 2007-06-03 19:43:40 UTC (rev 16150)
@@ -34,18 +34,18 @@
y-axis-label
;; a list of x-y-value lists.
data
- ;; Valid marker names are:
+ ;; Valid marker names are:
;; "none", "circle", "diamond", "cross", "x",
- ;; "square", "asterisk", "filled circle",
- ;; "filled square", "filled diamond"
+ ;; "square", "asterisk" and some more.
;; The full list can be found in
- ;; guppi3/src/libguppiplot/guppi-marker.c in
- ;; guppi_marker_info_array[]
+ ;; goffice/goffice/utils/go-marker.c, marker_shapes[]
+ ;; Marker names prefixed by filled, e.g. "filled square",
+ ;; are filled in the same color as the outline
marker
- ;; The color of the marker. Should be a rgba
- ;; value as a hex string, as returned by
- ;; gnc:color-option->hex-string
- markercolor
+ ;; The color of the markers outline. Should be a hex string,
+ ;; as returned by gnc:color-option->hex-string, prefixed by
+ ;; #, like "#ff0000" for red
+ markercolor
)))
(define gnc:html-scatter?
@@ -164,10 +164,7 @@
(y-label (gnc:html-scatter-y-axis-label scatter))
(data (gnc:html-scatter-data scatter))
(marker (gnc:html-scatter-marker scatter))
- ;; Workaround to set the alpha channel, since libguppitank
- ;; requires a rgba value here.
- (markercolor (string-append (gnc:html-scatter-markercolor scatter)
- "ff")))
+ (markercolor (string-append "#" (gnc:html-scatter-markercolor scatter))))
(if (and (list? data)
(not (null? data)))
(begin
@@ -202,7 +199,7 @@
(if markercolor
(begin
(push " <param name=\"color\" value=\"")
- (push (string-append "0x" markercolor))
+ (push markercolor)
(push "\">\n")))
(if (and data (list? data))
(let ((datasize (length data))
More information about the gnucash-changes
mailing list