Add an image_size parameter to ag_chart_create_svg()

This is required so we can generate a fixed size image, e.g. for the
chart preview.
This commit is contained in:
Gergely Polonkai 2014-09-27 22:21:50 +02:00
parent 84b622c622
commit 6d996af704
3 changed files with 21 additions and 3 deletions

View File

@ -1417,6 +1417,7 @@ ag_chart_create_svg(AgChart *chart,
gsize *length,
gboolean rendering,
AgDisplayTheme *theme,
guint image_size,
GError **err)
{
xmlDocPtr doc = create_save_doc(chart),
@ -1762,9 +1763,15 @@ ag_chart_create_svg(AgChart *chart,
params[3] = g_strdup_printf("\"%s\"", css);
g_free(css);
params[4] = "chart-size";
params[5] = g_strdup_printf("%d", AG_CHART_DEFAULT_RING_SIZE);
params[6] = "image-size";
params[7] = "0";
if (image_size == 0) {
params[5] = g_strdup_printf("%d", AG_CHART_DEFAULT_RING_SIZE);
params[7] = g_strdup("0");
} else {
params[5] = g_strdup("0");
params[7] = g_strdup_printf("%d", image_size);
}
params[8] = "icon-size";
params[9] = g_strdup_printf("%d", AG_CHART_DEFAULT_ICON_SIZE);
@ -1781,6 +1788,7 @@ ag_chart_create_svg(AgChart *chart,
xmlFreeDoc(doc);
g_free(params[3]);
g_free(params[5]);
g_free(params[7]);
g_free(params[9]);
g_free(params);
@ -1819,7 +1827,14 @@ ag_chart_export_svg_to_file(AgChart *chart,
gchar *svg;
gsize length;
if ((svg = ag_chart_create_svg(chart, &length, TRUE, theme, err)) == NULL) {
if ((svg = ag_chart_create_svg(
chart,
&length,
TRUE,
theme,
0,
err
)) == NULL) {
return;
}
@ -1854,6 +1869,7 @@ ag_chart_export_jpg_to_file(AgChart *chart,
&svg_length,
TRUE,
theme,
0,
err
)) == NULL) {
return;

View File

@ -120,6 +120,7 @@ gchar *ag_chart_create_svg(AgChart *chart,
gsize *length,
gboolean rendering,
AgDisplayTheme *theme,
guint image_size,
GError **err);
GList *ag_chart_get_planets(AgChart *chart);

View File

@ -532,6 +532,7 @@ ag_window_redraw_chart(AgWindow *window)
&length,
FALSE,
NULL,
0,
&err
);