Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/xlsxwriter/chart_area.py: 15%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1###############################################################################
2#
3# ChartArea - A class for writing the Excel XLSX Area charts.
4#
5# SPDX-License-Identifier: BSD-2-Clause
6# Copyright 2013-2024, John McNamara, jmcnamara@cpan.org
7#
9from . import chart
12class ChartArea(chart.Chart):
13 """
14 A class for writing the Excel XLSX Area charts.
17 """
19 ###########################################################################
20 #
21 # Public API.
22 #
23 ###########################################################################
25 def __init__(self, options=None):
26 """
27 Constructor.
29 """
30 super(ChartArea, self).__init__()
32 if options is None:
33 options = {}
35 self.subtype = options.get("subtype")
37 if not self.subtype:
38 self.subtype = "standard"
40 self.cross_between = "midCat"
41 self.show_crosses = False
43 # Override and reset the default axis values.
44 if self.subtype == "percent_stacked":
45 self.y_axis["defaults"]["num_format"] = "0%"
47 # Set the available data label positions for this chart type.
48 self.label_position_default = "center"
49 self.label_positions = {"center": "ctr"}
51 self.set_y_axis({})
53 ###########################################################################
54 #
55 # Private API.
56 #
57 ###########################################################################
59 def _write_chart_type(self, args):
60 # Override the virtual superclass method with a chart specific method.
61 # Write the c:areaChart element.
62 self._write_area_chart(args)
64 ###########################################################################
65 #
66 # XML methods.
67 #
68 ###########################################################################
69 #
70 def _write_area_chart(self, args):
71 # Write the <c:areaChart> element.
73 if args["primary_axes"]:
74 series = self._get_primary_axes_series()
75 else:
76 series = self._get_secondary_axes_series()
78 if not len(series):
79 return
81 subtype = self.subtype
83 if subtype == "percent_stacked":
84 subtype = "percentStacked"
86 self._xml_start_tag("c:areaChart")
88 # Write the c:grouping element.
89 self._write_grouping(subtype)
91 # Write the series elements.
92 for data in series:
93 self._write_ser(data)
95 # Write the c:dropLines element.
96 self._write_drop_lines()
98 # Write the c:axId elements
99 self._write_axis_ids(args)
101 self._xml_end_tag("c:areaChart")