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