1#Autogenerated schema
2from openpyxl.descriptors.serialisable import Serialisable
3from openpyxl.descriptors import (
4 Typed,
5 Bool,
6 MinMax,
7 Integer,
8 NoneSet,
9 Float,
10 Alias,
11 Sequence,
12)
13from openpyxl.descriptors.excel import ExtensionList, Percentage
14from openpyxl.descriptors.nested import (
15 NestedBool,
16 NestedMinMax,
17 NestedInteger,
18 NestedFloat,
19 NestedNoneSet,
20 NestedSet,
21)
22from openpyxl.descriptors.sequence import ValueSequence
23
24from ._chart import ChartBase
25from .axis import ChartLines
26from .descriptors import NestedGapAmount
27from .series import Series
28from .label import DataLabelList
29
30
31class _PieChartBase(ChartBase):
32
33 varyColors = NestedBool(allow_none=True)
34 ser = Sequence(expected_type=Series, allow_none=True)
35 dLbls = Typed(expected_type=DataLabelList, allow_none=True)
36 dataLabels = Alias("dLbls")
37
38 _series_type = "pie"
39
40 __elements__ = ('varyColors', 'ser', 'dLbls')
41
42 def __init__(self,
43 varyColors=True,
44 ser=(),
45 dLbls=None,
46 ):
47 self.varyColors = varyColors
48 self.ser = ser
49 self.dLbls = dLbls
50 super().__init__()
51
52
53
54class PieChart(_PieChartBase):
55
56 tagname = "pieChart"
57
58 varyColors = _PieChartBase.varyColors
59 ser = _PieChartBase.ser
60 dLbls = _PieChartBase.dLbls
61
62 firstSliceAng = NestedMinMax(min=0, max=360)
63 extLst = Typed(expected_type=ExtensionList, allow_none=True)
64
65 __elements__ = _PieChartBase.__elements__ + ('firstSliceAng', )
66
67 def __init__(self,
68 firstSliceAng=0,
69 extLst=None,
70 **kw
71 ):
72 self.firstSliceAng = firstSliceAng
73 super().__init__(**kw)
74
75
76class PieChart3D(_PieChartBase):
77
78 tagname = "pie3DChart"
79
80 varyColors = _PieChartBase.varyColors
81 ser = _PieChartBase.ser
82 dLbls = _PieChartBase.dLbls
83
84 extLst = Typed(expected_type=ExtensionList, allow_none=True)
85
86 __elements__ = _PieChartBase.__elements__
87
88
89class DoughnutChart(_PieChartBase):
90
91 tagname = "doughnutChart"
92
93 varyColors = _PieChartBase.varyColors
94 ser = _PieChartBase.ser
95 dLbls = _PieChartBase.dLbls
96
97 firstSliceAng = NestedMinMax(min=0, max=360)
98 holeSize = NestedMinMax(min=1, max=90, allow_none=True)
99 extLst = Typed(expected_type=ExtensionList, allow_none=True)
100
101 __elements__ = _PieChartBase.__elements__ + ('firstSliceAng', 'holeSize')
102
103 def __init__(self,
104 firstSliceAng=0,
105 holeSize=10,
106 extLst=None,
107 **kw
108 ):
109 self.firstSliceAng = firstSliceAng
110 self.holeSize = holeSize
111 super().__init__(**kw)
112
113
114class CustomSplit(Serialisable):
115
116 tagname = "custSplit"
117
118 secondPiePt = ValueSequence(expected_type=int)
119
120 __elements__ = ('secondPiePt',)
121
122 def __init__(self,
123 secondPiePt=(),
124 ):
125 self.secondPiePt = secondPiePt
126
127
128class ProjectedPieChart(_PieChartBase):
129
130 """
131 From the spec 21.2.2.126
132
133 This element contains the pie of pie or bar of pie series on this
134 chart. Only the first series shall be displayed. The splitType element
135 shall determine whether the splitPos and custSplit elements apply.
136 """
137
138 tagname = "ofPieChart"
139
140 varyColors = _PieChartBase.varyColors
141 ser = _PieChartBase.ser
142 dLbls = _PieChartBase.dLbls
143
144 ofPieType = NestedSet(values=(['pie', 'bar']))
145 type = Alias('ofPieType')
146 gapWidth = NestedGapAmount()
147 splitType = NestedNoneSet(values=(['auto', 'cust', 'percent', 'pos', 'val']))
148 splitPos = NestedFloat(allow_none=True)
149 custSplit = Typed(expected_type=CustomSplit, allow_none=True)
150 secondPieSize = NestedMinMax(min=5, max=200, allow_none=True)
151 serLines = Typed(expected_type=ChartLines, allow_none=True)
152 join_lines = Alias('serLines')
153 extLst = Typed(expected_type=ExtensionList, allow_none=True)
154
155 __elements__ = _PieChartBase.__elements__ + ('ofPieType', 'gapWidth',
156 'splitType', 'splitPos', 'custSplit', 'secondPieSize', 'serLines')
157
158 def __init__(self,
159 ofPieType="pie",
160 gapWidth=None,
161 splitType="auto",
162 splitPos=None,
163 custSplit=None,
164 secondPieSize=75,
165 serLines=None,
166 extLst=None,
167 **kw
168 ):
169 self.ofPieType = ofPieType
170 self.gapWidth = gapWidth
171 self.splitType = splitType
172 self.splitPos = splitPos
173 self.custSplit = custSplit
174 self.secondPieSize = secondPieSize
175 if serLines is None:
176 self.serLines = ChartLines()
177 super().__init__(**kw)