aboutsummaryrefslogtreecommitdiff
path: root/venv/lib/python3.8/site-packages/plotly/express/_special_inputs.py
blob: c1b3d4d102f8c1081fe5cfa94e510d84782fcac1 (plain)
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
class IdentityMap(object):
    """
    `dict`-like object which acts as if the value for any key is the key itself. Objects
    of this class can be passed in to arguments like `color_discrete_map` to
    use the provided data values as colors, rather than mapping them to colors cycled
    from `color_discrete_sequence`. This works for any `_map` argument to Plotly Express
    functions, such as `line_dash_map` and `symbol_map`.
    """

    def __getitem__(self, key):
        return key

    def __contains__(self, key):
        return True

    def copy(self):
        return self


class Constant(object):
    """
    Objects of this class can be passed to Plotly Express functions that expect column
    identifiers or list-like objects to indicate that this attribute should take on a
    constant value. An optional label can be provided.
    """

    def __init__(self, value, label=None):
        self.value = value
        self.label = label


class Range(object):
    """
    Objects of this class can be passed to Plotly Express functions that expect column
    identifiers or list-like objects to indicate that this attribute should be mapped
    onto integers starting at 0. An optional label can be provided.
    """

    def __init__(self, label=None):
        self.label = label