Add a rendering parameter to ag_chart_create_svg()
Based upon this parameter a <rect> is included in the resulting SVG document, providing a background color, and so is the chart CSS.
This commit is contained in:
parent
2cf75ede55
commit
7fe6a16401
@ -1393,7 +1393,11 @@ ag_chart_sort_planets_by_position(GswePlanetData *planet1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
|
ag_chart_create_svg(
|
||||||
|
AgChart *chart,
|
||||||
|
gsize *length,
|
||||||
|
gboolean rendering,
|
||||||
|
GError **err)
|
||||||
{
|
{
|
||||||
xmlDocPtr doc = create_save_doc(chart),
|
xmlDocPtr doc = create_save_doc(chart),
|
||||||
xslt_doc,
|
xslt_doc,
|
||||||
@ -1406,7 +1410,8 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
|
|||||||
antiscia_node = NULL,
|
antiscia_node = NULL,
|
||||||
node = NULL;
|
node = NULL;
|
||||||
gchar *value,
|
gchar *value,
|
||||||
*save_content = NULL;
|
*save_content = NULL,
|
||||||
|
**params;
|
||||||
const gchar *xslt_content;
|
const gchar *xslt_content;
|
||||||
GList *houses,
|
GList *houses,
|
||||||
*house,
|
*house,
|
||||||
@ -1710,15 +1715,22 @@ ag_chart_create_svg(AgChart *chart, gsize *length, GError **err)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params = g_new0(gchar *, 3);
|
||||||
|
params[0] = "rendering";
|
||||||
|
params[1] = (rendering) ? "'yes'" : "'no'";
|
||||||
|
|
||||||
// libxml2 messes up the output, as it prints decimal floating point
|
// libxml2 messes up the output, as it prints decimal floating point
|
||||||
// numbers in a localized format. It is not good in locales that use a
|
// numbers in a localized format. It is not good in locales that use a
|
||||||
// character for decimal separator other than a dot. So let's just use the
|
// character for decimal separator other than a dot. So let's just use the
|
||||||
// C locale until the SVG is generated.
|
// C locale until the SVG is generated.
|
||||||
current_locale = uselocale(newlocale(LC_ALL, "C", 0));
|
current_locale = uselocale(newlocale(LC_ALL, "C", 0));
|
||||||
svg_doc = xsltApplyStylesheet(xslt_proc, doc, NULL);
|
|
||||||
|
svg_doc = xsltApplyStylesheet(xslt_proc, doc, (const char **)params);
|
||||||
|
|
||||||
uselocale(current_locale);
|
uselocale(current_locale);
|
||||||
xsltFreeStylesheet(xslt_proc);
|
xsltFreeStylesheet(xslt_proc);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
g_free(params);
|
||||||
|
|
||||||
// Now, svg_doc contains the generated SVG file
|
// Now, svg_doc contains the generated SVG file
|
||||||
|
|
||||||
@ -1752,7 +1764,7 @@ ag_chart_export_svg_to_file(AgChart *chart, GFile *file, GError **err)
|
|||||||
gchar *svg;
|
gchar *svg;
|
||||||
gsize length;
|
gsize length;
|
||||||
|
|
||||||
if ((svg = ag_chart_create_svg(chart, &length, err)) == NULL) {
|
if ((svg = ag_chart_create_svg(chart, &length, TRUE, err)) == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ const gchar *ag_chart_get_city(AgChart *chart);
|
|||||||
|
|
||||||
gchar *ag_chart_create_svg(AgChart *chart,
|
gchar *ag_chart_create_svg(AgChart *chart,
|
||||||
gsize *length,
|
gsize *length,
|
||||||
|
gboolean rendering,
|
||||||
GError **err);
|
GError **err);
|
||||||
|
|
||||||
GList *ag_chart_get_planets(AgChart *chart);
|
GList *ag_chart_get_planets(AgChart *chart);
|
||||||
|
@ -496,6 +496,7 @@ ag_window_redraw_chart(AgWindow *window)
|
|||||||
gchar *svg_content = ag_chart_create_svg(
|
gchar *svg_content = ag_chart_create_svg(
|
||||||
priv->chart,
|
priv->chart,
|
||||||
&length,
|
&length,
|
||||||
|
FALSE,
|
||||||
&err
|
&err
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -134,3 +134,7 @@ line.antiscion {
|
|||||||
stroke: #000000;
|
stroke: #000000;
|
||||||
stroke-dasharray: 20,10;
|
stroke-dasharray: 20,10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#background {
|
||||||
|
fill: #ffffff;
|
||||||
|
}
|
||||||
|
@ -69,6 +69,15 @@
|
|||||||
version="1.0">
|
version="1.0">
|
||||||
<xsl:attribute name="width"><xsl:value-of select="$image_size"/></xsl:attribute>
|
<xsl:attribute name="width"><xsl:value-of select="$image_size"/></xsl:attribute>
|
||||||
<xsl:attribute name="height"><xsl:value-of select="$image_size"/></xsl:attribute>
|
<xsl:attribute name="height"><xsl:value-of select="$image_size"/></xsl:attribute>
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$rendering='yes'">
|
||||||
|
<style type="text/css">
|
||||||
|
<xi:include href="gres://ui/chart-default.css" parse="text"/>
|
||||||
|
</style>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
<title>
|
<title>
|
||||||
<xsl:value-of select="concat(
|
<xsl:value-of select="concat(
|
||||||
'Natal chart of ',
|
'Natal chart of ',
|
||||||
@ -116,6 +125,16 @@
|
|||||||
<polygon points="0.0,0.0 7.0,-2.0 5.0,0.0 7.0,2.0" />
|
<polygon points="0.0,0.0 7.0,-2.0 5.0,0.0 7.0,2.0" />
|
||||||
</marker>
|
</marker>
|
||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$rendering='yes'">
|
||||||
|
<rect id="background" x="0" y="0">
|
||||||
|
<xsl:attribute name="width"><xsl:value-of select="$image_size"/></xsl:attribute>
|
||||||
|
<xsl:attribute name="height"><xsl:value-of select="$image_size"/></xsl:attribute>
|
||||||
|
</rect>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
<g id="chart">
|
<g id="chart">
|
||||||
<xsl:attribute name="transform"><xsl:value-of select="concat('translate(', $image_size div 2, ',', $image_size div 2, ')')" /></xsl:attribute>
|
<xsl:attribute name="transform"><xsl:value-of select="concat('translate(', $image_size div 2, ',', $image_size div 2, ')')" /></xsl:attribute>
|
||||||
<g id="moonless_chart">
|
<g id="moonless_chart">
|
||||||
|
Loading…
Reference in New Issue
Block a user