mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Handle marker shape and color options of scatter plots, #353871.
Lost in translation, Guppi -> GOffice. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16150 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
13b667f971
commit
a5355e2bd4
@ -33,6 +33,7 @@
|
|||||||
#include "gnc-html.h"
|
#include "gnc-html.h"
|
||||||
#include "gnc-engine.h"
|
#include "gnc-engine.h"
|
||||||
#include <goffice/goffice.h>
|
#include <goffice/goffice.h>
|
||||||
|
#include <goffice/graph/gog-chart.h>
|
||||||
#include <goffice/graph/gog-graph.h>
|
#include <goffice/graph/gog-graph.h>
|
||||||
#include <goffice/graph/gog-object.h>
|
#include <goffice/graph/gog-object.h>
|
||||||
#ifdef GOFFICE_WITH_CAIRO
|
#ifdef GOFFICE_WITH_CAIRO
|
||||||
@ -48,6 +49,7 @@
|
|||||||
#include <goffice/graph/gog-plot.h>
|
#include <goffice/graph/gog-plot.h>
|
||||||
#include <goffice/graph/gog-series.h>
|
#include <goffice/graph/gog-series.h>
|
||||||
#include <goffice/utils/go-color.h>
|
#include <goffice/utils/go-color.h>
|
||||||
|
#include <goffice/utils/go-marker.h>
|
||||||
#include <goffice/graph/gog-data-set.h>
|
#include <goffice/graph/gog-data-set.h>
|
||||||
#include <goffice/data/go-data-simple.h>
|
#include <goffice/data/go-data-simple.h>
|
||||||
#include <goffice/app/go-plugin.h>
|
#include <goffice/app/go-plugin.h>
|
||||||
@ -514,8 +516,11 @@ handle_scatter(gnc_html * html, GtkHTMLEmbedded * eb, gpointer unused)
|
|||||||
GogPlot *plot;
|
GogPlot *plot;
|
||||||
GogSeries *series;
|
GogSeries *series;
|
||||||
GOData *sliceData;
|
GOData *sliceData;
|
||||||
|
GogStyle *style;
|
||||||
int datasize;
|
int datasize;
|
||||||
double *xData, *yData;
|
double *xData, *yData;
|
||||||
|
gchar *marker_str, *color_str;
|
||||||
|
gboolean fill = FALSE;
|
||||||
|
|
||||||
gtkhtml_pre_3_10_1_bug_workaround(eb);
|
gtkhtml_pre_3_10_1_bug_workaround(eb);
|
||||||
|
|
||||||
@ -530,6 +535,9 @@ handle_scatter(gnc_html * html, GtkHTMLEmbedded * eb, gpointer unused)
|
|||||||
|
|
||||||
yDataStr = g_hash_table_lookup( eb->params, "y_data" );
|
yDataStr = g_hash_table_lookup( eb->params, "y_data" );
|
||||||
yData = read_doubles( yDataStr, datasize );
|
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))
|
if (!create_basic_plot_elements("GogXYPlot", &graph, &chart, &plot))
|
||||||
@ -538,6 +546,7 @@ handle_scatter(gnc_html * html, GtkHTMLEmbedded * eb, gpointer unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
series = gog_plot_new_series( plot );
|
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 );
|
sliceData = go_data_vector_val_new( xData, datasize, NULL );
|
||||||
gog_series_set_dim( series, 0, sliceData, NULL );
|
gog_series_set_dim( series, 0, sliceData, NULL );
|
||||||
@ -547,6 +556,62 @@ handle_scatter(gnc_html * html, GtkHTMLEmbedded * eb, gpointer unused)
|
|||||||
gog_series_set_dim( series, 1, sliceData, NULL );
|
gog_series_set_dim( series, 1, sliceData, NULL );
|
||||||
go_data_emit_changed (GO_DATA (sliceData));
|
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_titles_from_hash(chart, eb);
|
||||||
set_chart_axis_labels_from_hash(chart, eb);
|
set_chart_axis_labels_from_hash(chart, eb);
|
||||||
|
|
||||||
|
@ -34,18 +34,18 @@
|
|||||||
y-axis-label
|
y-axis-label
|
||||||
;; a list of x-y-value lists.
|
;; a list of x-y-value lists.
|
||||||
data
|
data
|
||||||
;; Valid marker names are:
|
;; Valid marker names are:
|
||||||
;; "none", "circle", "diamond", "cross", "x",
|
;; "none", "circle", "diamond", "cross", "x",
|
||||||
;; "square", "asterisk", "filled circle",
|
;; "square", "asterisk" and some more.
|
||||||
;; "filled square", "filled diamond"
|
|
||||||
;; The full list can be found in
|
;; The full list can be found in
|
||||||
;; guppi3/src/libguppiplot/guppi-marker.c in
|
;; goffice/goffice/utils/go-marker.c, marker_shapes[]
|
||||||
;; guppi_marker_info_array[]
|
;; Marker names prefixed by filled, e.g. "filled square",
|
||||||
|
;; are filled in the same color as the outline
|
||||||
marker
|
marker
|
||||||
;; The color of the marker. Should be a rgba
|
;; The color of the markers outline. Should be a hex string,
|
||||||
;; value as a hex string, as returned by
|
;; as returned by gnc:color-option->hex-string, prefixed by
|
||||||
;; gnc:color-option->hex-string
|
;; #, like "#ff0000" for red
|
||||||
markercolor
|
markercolor
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(define gnc:html-scatter?
|
(define gnc:html-scatter?
|
||||||
@ -164,10 +164,7 @@
|
|||||||
(y-label (gnc:html-scatter-y-axis-label scatter))
|
(y-label (gnc:html-scatter-y-axis-label scatter))
|
||||||
(data (gnc:html-scatter-data scatter))
|
(data (gnc:html-scatter-data scatter))
|
||||||
(marker (gnc:html-scatter-marker scatter))
|
(marker (gnc:html-scatter-marker scatter))
|
||||||
;; Workaround to set the alpha channel, since libguppitank
|
(markercolor (string-append "#" (gnc:html-scatter-markercolor scatter))))
|
||||||
;; requires a rgba value here.
|
|
||||||
(markercolor (string-append (gnc:html-scatter-markercolor scatter)
|
|
||||||
"ff")))
|
|
||||||
(if (and (list? data)
|
(if (and (list? data)
|
||||||
(not (null? data)))
|
(not (null? data)))
|
||||||
(begin
|
(begin
|
||||||
@ -202,7 +199,7 @@
|
|||||||
(if markercolor
|
(if markercolor
|
||||||
(begin
|
(begin
|
||||||
(push " <param name=\"color\" value=\"")
|
(push " <param name=\"color\" value=\"")
|
||||||
(push (string-append "0x" markercolor))
|
(push markercolor)
|
||||||
(push "\">\n")))
|
(push "\">\n")))
|
||||||
(if (and data (list? data))
|
(if (and data (list? data))
|
||||||
(let ((datasize (length data))
|
(let ((datasize (length data))
|
||||||
|
Loading…
Reference in New Issue
Block a user