Source code

Download source archive ↓

src/openpyxl/chart/marker.py

1# Copyright (c) 2010-2024 openpyxl
2
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5    Typed,
6    Alias,
7)
8
9from openpyxl.descriptors.excel import(
10    ExtensionList,
11    _explicit_none,
12)
13
14from openpyxl.descriptors.nested import (
15    NestedBool,
16    NestedInteger,
17    NestedMinMax,
18    NestedNoneSet,
19)
20
21from .layout import Layout
22from .picture import PictureOptions
23from .shapes import *
24from .text import *
25from .error_bar import *
26
27
28class Marker(Serialisable):
29
30    tagname = "marker"
31
32    symbol = NestedNoneSet(values=(['circle', 'dash', 'diamond', 'dot', 'picture',
33                              'plus', 'square', 'star', 'triangle', 'x', 'auto']),
34                           to_tree=_explicit_none)
35    size = NestedMinMax(min=2, max=72, allow_none=True)
36    spPr = Typed(expected_type=GraphicalProperties, allow_none=True)
37    graphicalProperties = Alias('spPr')
38    extLst = Typed(expected_type=ExtensionList, allow_none=True)
39
40    __elements__ = ('symbol', 'size', 'spPr')
41
42    def __init__(self,
43                 symbol=None,
44                 size=None,
45                 spPr=None,
46                 extLst=None,
47                ):
48        self.symbol = symbol
49        self.size = size
50        if spPr is None:
51            spPr = GraphicalProperties()
52        self.spPr = spPr
53
54
55class DataPoint(Serialisable):
56
57    tagname = "dPt"
58
59    idx = NestedInteger()
60    invertIfNegative = NestedBool(allow_none=True)
61    marker = Typed(expected_type=Marker, allow_none=True)
62    bubble3D = NestedBool(allow_none=True)
63    explosion = NestedInteger(allow_none=True)
64    spPr = Typed(expected_type=GraphicalProperties, allow_none=True)
65    graphicalProperties = Alias('spPr')
66    pictureOptions = Typed(expected_type=PictureOptions, allow_none=True)
67    extLst = Typed(expected_type=ExtensionList, allow_none=True)
68
69    __elements__ = ('idx', 'invertIfNegative', 'marker', 'bubble3D',
70                    'explosion', 'spPr', 'pictureOptions')
71
72    def __init__(self,
73                 idx=None,
74                 invertIfNegative=None,
75                 marker=None,
76                 bubble3D=None,
77                 explosion=None,
78                 spPr=None,
79                 pictureOptions=None,
80                 extLst=None,
81                ):
82        self.idx = idx
83        self.invertIfNegative = invertIfNegative
84        self.marker = marker
85        self.bubble3D = bubble3D
86        self.explosion = explosion
87        if spPr is None:
88            spPr = GraphicalProperties()
89        self.spPr = spPr
90        self.pictureOptions = pictureOptions