Source code

Download source archive ↓

src/openpyxl/chart/descriptors.py

1# Copyright (c) 2010-2024 openpyxl
2
3
4
5from openpyxl.descriptors.nested import (
6    NestedMinMax
7    )
8
9from openpyxl.descriptors import Typed
10
11from .data_source import NumFmt
12
13"""
14Utility descriptors for the chart module.
15For convenience but also clarity.
16"""
17
18class NestedGapAmount(NestedMinMax):
19
20    allow_none = True
21    min = 0
22    max = 500
23
24
25class NestedOverlap(NestedMinMax):
26
27    allow_none = True
28    min = -100
29    max = 100
30
31
32class NumberFormatDescriptor(Typed):
33    """
34    Allow direct assignment of format code
35    """
36
37    expected_type = NumFmt
38    allow_none = True
39
40    def __set__(self, instance, value):
41        if isinstance(value, str):
42            value = NumFmt(value)
43        super().__set__(instance, value)