1# Copyright (c) 2010-2024 openpyxl
2
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5 Typed,
6 Set,
7 Bool,
8 Integer,
9 Sequence,
10 Alias,
11)
12
13from openpyxl.descriptors.excel import ExtensionList
14from openpyxl.descriptors.nested import (
15 NestedMinMax,
16 NestedSet,
17 NestedBool,
18)
19
20from ._chart import ChartBase
21from .descriptors import NestedGapAmount
22from .axis import TextAxis, NumericAxis, SeriesAxis, ChartLines
23from .label import DataLabelList
24from .series import Series
25
26
27class _AreaChartBase(ChartBase):
28
29 grouping = NestedSet(values=(['percentStacked', 'standard', 'stacked']))
30 varyColors = NestedBool(nested=True, allow_none=True)
31 ser = Sequence(expected_type=Series, allow_none=True)
32 dLbls = Typed(expected_type=DataLabelList, allow_none=True)
33 dataLabels = Alias("dLbls")
34 dropLines = Typed(expected_type=ChartLines, allow_none=True)
35
36 _series_type = "area"
37
38 __elements__ = ('grouping', 'varyColors', 'ser', 'dLbls', 'dropLines')
39
40 def __init__(self,
41 grouping="standard",
42 varyColors=None,
43 ser=(),
44 dLbls=None,
45 dropLines=None,
46 ):
47 self.grouping = grouping
48 self.varyColors = varyColors
49 self.ser = ser
50 self.dLbls = dLbls
51 self.dropLines = dropLines
52 super().__init__()
53
54
55class AreaChart(_AreaChartBase):
56
57 tagname = "areaChart"
58
59 grouping = _AreaChartBase.grouping
60 varyColors = _AreaChartBase.varyColors
61 ser = _AreaChartBase.ser
62 dLbls = _AreaChartBase.dLbls
63 dropLines = _AreaChartBase.dropLines
64
65 # chart properties actually used by containing classes
66 x_axis = Typed(expected_type=TextAxis)
67 y_axis = Typed(expected_type=NumericAxis)
68
69 extLst = Typed(expected_type=ExtensionList, allow_none=True)
70
71 __elements__ = _AreaChartBase.__elements__ + ('axId',)
72
73 def __init__(self,
74 axId=None,
75 extLst=None,
76 **kw
77 ):
78 self.x_axis = TextAxis()
79 self.y_axis = NumericAxis()
80 super().__init__(**kw)
81
82
83class AreaChart3D(AreaChart):
84
85 tagname = "area3DChart"
86
87 grouping = _AreaChartBase.grouping
88 varyColors = _AreaChartBase.varyColors
89 ser = _AreaChartBase.ser
90 dLbls = _AreaChartBase.dLbls
91 dropLines = _AreaChartBase.dropLines
92
93 gapDepth = NestedGapAmount()
94
95 x_axis = Typed(expected_type=TextAxis)
96 y_axis = Typed(expected_type=NumericAxis)
97 z_axis = Typed(expected_type=SeriesAxis, allow_none=True)
98
99 __elements__ = AreaChart.__elements__ + ('gapDepth', )
100
101 def __init__(self, gapDepth=None, **kw):
102 self.gapDepth = gapDepth
103 super(AreaChart3D, self).__init__(**kw)
104 self.x_axis = TextAxis()
105 self.y_axis = NumericAxis()
106 self.z_axis = SeriesAxis()