libxlsxwriter/src/chart.c in fast_excel-0.2.6 vs libxlsxwriter/src/chart.c in fast_excel-0.3.0
- old
+ new
@@ -1,11 +1,11 @@
/*****************************************************************************
* chart - A library for creating Excel XLSX chart files.
*
* Used in conjunction with the libxlsxwriter library.
*
- * Copyright 2014-2018, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
+ * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
*
*/
#include "xlsxwriter/xmlwriter.h"
#include "xlsxwriter/chart.h"
@@ -572,10 +572,19 @@
{
lxw_xml_declaration(self->file);
}
/*
+ * Write the <c:protection> element.
+ */
+STATIC void
+_chart_write_protection(lxw_chart *self)
+{
+ lxw_xml_empty_tag(self->file, "c:protection", NULL);
+}
+
+/*
* Write the <c:chartSpace> element.
*/
STATIC void
_chart_write_chart_space(lxw_chart *self)
{
@@ -3199,18 +3208,24 @@
/*
* Write the <c:lblAlgn> element.
*/
STATIC void
-_chart_write_label_align(lxw_chart *self)
+_chart_write_label_align(lxw_chart *self, lxw_chart_axis *axis)
{
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
- LXW_PUSH_ATTRIBUTES_STR("val", "ctr");
+ if (axis->label_align == LXW_CHART_AXIS_LABEL_ALIGN_LEFT)
+ LXW_PUSH_ATTRIBUTES_STR("val", "l");
+ else if (axis->label_align == LXW_CHART_AXIS_LABEL_ALIGN_RIGHT)
+ LXW_PUSH_ATTRIBUTES_STR("val", "r");
+ else
+ LXW_PUSH_ATTRIBUTES_STR("val", "ctr");
+
lxw_xml_empty_tag(self->file, "c:lblAlgn", &attributes);
LXW_FREE_ATTRIBUTES();
}
@@ -3583,18 +3598,25 @@
_chart_write_legend_pos(self, "t");
break;
case LXW_CHART_LEGEND_BOTTOM:
_chart_write_legend_pos(self, "b");
break;
+ case LXW_CHART_LEGEND_TOP_RIGHT:
+ _chart_write_legend_pos(self, "tr");
+ break;
case LXW_CHART_LEGEND_OVERLAY_RIGHT:
_chart_write_legend_pos(self, "r");
has_overlay = LXW_TRUE;
break;
case LXW_CHART_LEGEND_OVERLAY_LEFT:
_chart_write_legend_pos(self, "l");
has_overlay = LXW_TRUE;
break;
+ case LXW_CHART_LEGEND_OVERLAY_TOP_RIGHT:
+ _chart_write_legend_pos(self, "tr");
+ has_overlay = LXW_TRUE;
+ break;
default:
_chart_write_legend_pos(self, "r");
}
/* Remove series labels from the legend. */
@@ -4089,11 +4111,11 @@
/* Write the c:auto element. */
_chart_write_auto(self);
/* Write the c:lblAlgn element. */
- _chart_write_label_align(self);
+ _chart_write_label_align(self, self->x_axis);
/* Write the c:lblOffset element. */
_chart_write_label_offset(self);
/* Write the c:tickLblSkip element. */
@@ -4926,19 +4948,24 @@
_chart_write_lang(self);
/* Write the c:style element. */
_chart_write_style(self);
+ /* Write the c:protection element. */
+ if (self->is_protected)
+ _chart_write_protection(self);
+
/* Write the c:chart element. */
_chart_write_chart(self);
/* Write the c:spPr element for the chartarea formatting. */
_chart_write_sp_pr(self, self->chartarea_line, self->chartarea_fill,
self->chartarea_pattern);
/* Write the c:printSettings element. */
- _chart_write_print_settings(self);
+ if (!self->is_chartsheet)
+ _chart_write_print_settings(self);
lxw_xml_end_tag(self->file, "c:chartSpace");
}
/*****************************************************************************
@@ -6036,9 +6063,18 @@
axis->minor_gridlines.line = _chart_convert_line_args(line);
/* If the gridline has a format it should also be visible. */
if (axis->minor_gridlines.line)
axis->minor_gridlines.visible = LXW_TRUE;
+}
+
+/*
+ * Set the chart axis label alignment.
+ */
+void
+chart_axis_set_label_align(lxw_chart_axis *axis, uint8_t align)
+{
+ axis->label_align = align;
}
/*
* Set the chart title.
*/