Skip to content

feat: add type annotations to generated code #5008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ jobs:
command: |
python -m venv venv
. venv/bin/activate
pip install black==22.3.0
pip install black==25.1.0
- run:
name: Check formatting with black
command: |
27 changes: 4 additions & 23 deletions _plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
@@ -1328,25 +1328,14 @@ def numbers_allowed(self):
return self.colorscale_path is not None

def description(self):

named_clrs_str = "\n".join(
textwrap.wrap(
", ".join(self.named_colors),
width=79 - 16,
initial_indent=" " * 12,
subsequent_indent=" " * 12,
)
)

valid_color_description = """\
The '{plotly_name}' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
{clrs}""".format(
plotly_name=self.plotly_name, clrs=named_clrs_str
- A named CSS color""".format(
plotly_name=self.plotly_name
)

if self.colorscale_path:
@@ -2483,15 +2472,11 @@ def description(self):
that may be specified as:
- An instance of :class:`{module_str}.{class_str}`
- A dict of string/value properties that will be passed
to the {class_str} constructor
Supported dict properties:
{constructor_params_str}"""
to the {class_str} constructor"""
).format(
plotly_name=self.plotly_name,
class_str=self.data_class_str,
module_str=self.module_str,
constructor_params_str=self.data_docs,
)

return desc
@@ -2560,15 +2545,11 @@ def description(self):
{class_str} that may be specified as:
- A list or tuple of instances of {module_str}.{class_str}
- A list or tuple of dicts of string/value properties that
will be passed to the {class_str} constructor
Supported dict properties:
{constructor_params_str}"""
will be passed to the {class_str} constructor"""
).format(
plotly_name=self.plotly_name,
class_str=self.data_class_str,
module_str=self.module_str,
constructor_params_str=self.data_docs,
)

return desc
1 change: 1 addition & 0 deletions _plotly_utils/colors/__init__.py
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
Be careful! If you have a lot of unique numbers in your color column you will
end up with a colormap that is massive and may slow down graphing performance.
"""

import decimal
from numbers import Number

60 changes: 28 additions & 32 deletions codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@
get_data_validator_instance,
)

# Target Python version for code formatting with Black.
# Must be one of the values listed in pyproject.toml.
BLACK_TARGET_VERSION = "py311"


# Import notes
# ------------
@@ -85,7 +89,7 @@ def preprocess_schema(plotly_schema):
items["colorscale"] = items.pop("concentrationscales")


def perform_codegen():
def perform_codegen(reformat=True):
# Set root codegen output directory
# ---------------------------------
# (relative to project root)
@@ -267,36 +271,24 @@ def perform_codegen():
root_datatype_imports.append(f"._deprecations.{dep_clas}")

optional_figure_widget_import = f"""
if sys.version_info < (3, 7) or TYPE_CHECKING:
try:
import ipywidgets as _ipywidgets
from packaging.version import Version as _Version
if _Version(_ipywidgets.__version__) >= _Version("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget
else:
raise ImportError()
except Exception:
from ..missing_anywidget import FigureWidget
else:
__all__.append("FigureWidget")
orig_getattr = __getattr__
def __getattr__(import_name):
if import_name == "FigureWidget":
try:
import ipywidgets
from packaging.version import Version
if Version(ipywidgets.__version__) >= Version("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget
return FigureWidget
else:
raise ImportError()
except Exception:
from ..missing_anywidget import FigureWidget
__all__.append("FigureWidget")
orig_getattr = __getattr__
def __getattr__(import_name):
if import_name == "FigureWidget":
try:
import ipywidgets
from packaging.version import Version
if Version(ipywidgets.__version__) >= Version("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget
return FigureWidget
else:
raise ImportError()
except Exception:
from ..missing_anywidget import FigureWidget
return FigureWidget
return orig_getattr(import_name)
return orig_getattr(import_name)
"""
# ### __all__ ###
for path_parts, class_names in alls.items():
@@ -337,9 +329,13 @@ def __getattr__(import_name):
f.write(graph_objects_init_source)

# ### Run black code formatter on output directories ###
subprocess.call(["black", "--target-version=py36", validators_pkgdir])
subprocess.call(["black", "--target-version=py36", graph_objs_pkgdir])
subprocess.call(["black", "--target-version=py36", graph_objects_path])
if reformat:
target_version = f"--target-version={BLACK_TARGET_VERSION}"
subprocess.call(["black", target_version, validators_pkgdir])
subprocess.call(["black", target_version, graph_objs_pkgdir])
subprocess.call(["black", target_version, graph_objects_path])
else:
print("skipping reformatting")


if __name__ == "__main__":
2 changes: 1 addition & 1 deletion codegen/compatibility.py
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ def __init__(self, *args, **kwargs):
{depr_msg}
\"\"\"
warnings.warn(\"\"\"{depr_msg}\"\"\", DeprecationWarning)
super({class_name}, self).__init__(*args, **kwargs)\n\n\n"""
super().__init__(*args, **kwargs)\n\n\n"""
)

# Return source string
131 changes: 46 additions & 85 deletions codegen/datatypes.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
]


def get_typing_type(plotly_type, array_ok=False):
def get_python_type(plotly_type, array_ok=False, compound_as_none=False):
"""
Get Python type corresponding to a valType string from the plotly schema
@@ -28,7 +28,7 @@ def get_typing_type(plotly_type, array_ok=False):
Python type string
"""
if plotly_type == "data_array":
pytype = "numpy.ndarray"
pytype = "NDArray"
elif plotly_type == "info_array":
pytype = "list"
elif plotly_type == "colorlist":
@@ -43,11 +43,13 @@ def get_typing_type(plotly_type, array_ok=False):
pytype = "int"
elif plotly_type == "boolean":
pytype = "bool"
elif (plotly_type in ("compound", "compound_array")) and compound_as_none:
pytype = None
else:
raise ValueError("Unknown plotly type: %s" % plotly_type)

if array_ok:
return f"{pytype}|numpy.ndarray"
return f"{pytype}|NDArray"
else:
return pytype

@@ -69,11 +71,10 @@ def build_datatype_py(node):
"""

# Validate inputs
# ---------------
assert node.is_compound

# Handle template traces
# ----------------------
#
# We want template trace/layout classes like
# plotly.graph_objs.layout.template.data.Scatter to map to the
# corresponding trace/layout class (e.g. plotly.graph_objs.Scatter).
@@ -85,22 +86,22 @@ def build_datatype_py(node):
return "from plotly.graph_objs import Layout"

# Extract node properties
# -----------------------
undercase = node.name_undercase
datatype_class = node.name_datatype_class
literal_nodes = [n for n in node.child_literals if n.plotly_name in ["type"]]

# Initialze source code buffer
# ----------------------------
buffer = StringIO()

# Imports
# -------
buffer.write("from __future__ import annotations\n")
buffer.write("from typing import Any\n")
buffer.write("from numpy.typing import NDArray\n")
buffer.write(
f"from plotly.basedatatypes "
"from plotly.basedatatypes "
f"import {node.name_base_datatype} as _{node.name_base_datatype}\n"
)
buffer.write(f"import copy as _copy\n")
buffer.write("import copy as _copy\n")

if (
node.name_property in deprecated_mapbox_traces
@@ -109,14 +110,13 @@ def build_datatype_py(node):
buffer.write(f"import warnings\n")

# Write class definition
# ----------------------
buffer.write(
f"""
class {datatype_class}(_{node.name_base_datatype}):\n"""
)

# ### Layout subplot properties ###
### Layout subplot properties
if datatype_class == "Layout":
subplot_nodes = [
node
@@ -171,17 +171,16 @@ def _subplot_re_match(self, prop):
valid_props_list = sorted(
[node.name_property for node in subtype_nodes + literal_nodes]
)
# class properties
buffer.write(
f"""
# class properties
# --------------------
_parent_path_str = '{node.parent_path_str}'
_path_str = '{node.path_str}'
_valid_props = {{"{'", "'.join(valid_props_list)}"}}
"""
)

# ### Property definitions ###
### Property definitions
for subtype_node in subtype_nodes:
if subtype_node.is_array_element:
prop_type = (
@@ -200,9 +199,11 @@ def _subplot_re_match(self, prop):
elif subtype_node.is_mapped:
prop_type = ""
else:
prop_type = get_typing_type(subtype_node.datatype, subtype_node.is_array_ok)
prop_type = get_python_type(
subtype_node.datatype, array_ok=subtype_node.is_array_ok
)

# #### Get property description ####
#### Get property description ####
raw_description = subtype_node.description
property_description = "\n".join(
textwrap.wrap(
@@ -213,12 +214,12 @@ def _subplot_re_match(self, prop):
)
)

# # #### Get validator description ####
# #### Get validator description ####
validator = subtype_node.get_validator_instance()
if validator:
validator_description = reindent_validator_description(validator, 4)

# #### Combine to form property docstring ####
#### Combine to form property docstring ####
if property_description.strip():
property_docstring = f"""{property_description}
@@ -228,12 +229,10 @@ def _subplot_re_match(self, prop):
else:
property_docstring = property_description

# #### Write get property ####
#### Write get property ####
buffer.write(
f"""\
# {subtype_node.name_property}
# {'-' * len(subtype_node.name_property)}
@property
def {subtype_node.name_property}(self):
\"\"\"
@@ -246,7 +245,7 @@ def {subtype_node.name_property}(self):
return self['{subtype_node.name_property}']"""
)

# #### Write set property ####
#### Write set property ####
buffer.write(
f"""
@@ -255,24 +254,20 @@ def {subtype_node.name_property}(self, val):
self['{subtype_node.name_property}'] = val\n"""
)

# ### Literals ###
### Literals
for literal_node in literal_nodes:
buffer.write(
f"""\
# {literal_node.name_property}
# {'-' * len(literal_node.name_property)}
@property
def {literal_node.name_property}(self):
return self._props['{literal_node.name_property}']\n"""
)

# ### Private properties descriptions ###
### Private properties descriptions
valid_props = {node.name_property for node in subtype_nodes}
buffer.write(
f"""
# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return \"\"\"\\"""
@@ -294,15 +289,15 @@ def _prop_descriptions(self):
_mapped_properties = {repr(mapped_properties)}"""
)

# ### Constructor ###
### Constructor
buffer.write(
f"""
def __init__(self"""
)

add_constructor_params(buffer, subtype_nodes, prepend_extras=["arg"])

# ### Constructor Docstring ###
### Constructor Docstring
header = f"Construct a new {datatype_class} object"
class_name = (
f"plotly.graph_objs" f"{node.parent_dotpath_str}." f"{node.name_datatype_class}"
@@ -326,27 +321,25 @@ def __init__(self"""

buffer.write(
f"""
super({datatype_class}, self).__init__('{node.name_property}')
super().__init__('{node.name_property}')
if '_parent' in kwargs:
self._parent = kwargs['_parent']
return
"""
)

if datatype_class == "Layout":
buffer.write(
f"""
# Override _valid_props for instance so that instance can mutate set
# to support subplot properties (e.g. xaxis2)
buffer.write(
f"""
self._valid_props = {{"{'", "'.join(valid_props_list)}"}}
"""
)

# Validate arg
buffer.write(
f"""
# Validate arg
# ------------
if arg is None:
arg = {{}}
elif isinstance(arg, self.__class__):
@@ -359,53 +352,34 @@ def __init__(self"""
constructor must be a dict or
an instance of :class:`{class_name}`\"\"\")
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop('skip_invalid', False)
self._validate = kwargs.pop('_validate', True)
"""
)

buffer.write(
f"""
# Populate data dict with properties
# ----------------------------------"""
)
buffer.write("\n\n")
for subtype_node in subtype_nodes:
name_prop = subtype_node.name_property
buffer.write(
f"""
_v = arg.pop('{name_prop}', None)
_v = {name_prop} if {name_prop} is not None else _v
if _v is not None:"""
)
if datatype_class == "Template" and name_prop == "data":
buffer.write(
"""
# Template.data contains a 'scattermapbox' key, which causes a
# go.Scattermapbox trace object to be created during validation.
# In order to prevent false deprecation warnings from surfacing,
# we suppress deprecation warnings for this line only.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self["data"] = _v"""
f"""
# Template.data contains a 'scattermapbox' key, which causes a
# go.Scattermapbox trace object to be created during validation.
# In order to prevent false deprecation warnings from surfacing,
# we suppress deprecation warnings for this line only.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self._init_provided('{name_prop}', arg, {name_prop})"""
)
else:
buffer.write(
f"""
self['{name_prop}'] = _v"""
self._init_provided('{name_prop}', arg, {name_prop})"""
)

# ### Literals ###
### Literals
if literal_nodes:
buffer.write(
f"""
# Read-only literals
# ------------------
"""
)
buffer.write("\n\n")
for literal_node in literal_nodes:
lit_name = literal_node.name_property
lit_val = repr(literal_node.node_data)
@@ -417,13 +391,7 @@ def __init__(self"""

buffer.write(
f"""
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False
"""
)
@@ -442,7 +410,6 @@ def __init__(self"""
)

# Return source string
# --------------------
return buffer.getvalue()


@@ -496,10 +463,11 @@ def add_constructor_params(
{extra}=None"""
)

for i, subtype_node in enumerate(subtype_nodes):
for subtype_node in subtype_nodes:
py_type = get_python_type(subtype_node.datatype, compound_as_none=True)
buffer.write(
f""",
{subtype_node.name_property}=None"""
{subtype_node.name_property}: {py_type}|None = None"""
)

for extra in append_extras:
@@ -549,11 +517,9 @@ def add_docstring(
"""
# Validate inputs
# ---------------
assert node.is_compound

# Build wrapped description
# -------------------------
node_description = node.description
if node_description:
description_lines = textwrap.wrap(
@@ -566,7 +532,6 @@ def add_docstring(
node_description = "\n".join(description_lines) + "\n\n"

# Write header and description
# ----------------------------
buffer.write(
f"""
\"\"\"
@@ -577,7 +542,7 @@ def add_docstring(
)

# Write parameter descriptions
# ----------------------------

# Write any prepend extras
for p, v in prepend_extras:
v_wrapped = "\n".join(
@@ -616,7 +581,6 @@ def add_docstring(
)

# Write return block and close docstring
# --------------------------------------
buffer.write(
f"""
@@ -645,16 +609,13 @@ def write_datatype_py(outdir, node):
"""

# Build file path
# ---------------
# filepath = opath.join(outdir, "graph_objs", *node.parent_path_parts, "__init__.py")
filepath = opath.join(
outdir, "graph_objs", *node.parent_path_parts, "_" + node.name_undercase + ".py"
)

# Generate source code
# --------------------
datatype_source = build_datatype_py(node)

# Write file
# ----------
write_source_py(datatype_source, filepath, leading_newlines=2)
13 changes: 6 additions & 7 deletions codegen/figure.py
Original file line number Diff line number Diff line change
@@ -61,8 +61,9 @@ def build_figure_py(
trace_nodes = trace_node.child_compound_datatypes

# Write imports
# -------------
# ### Import base class ###
buffer.write("from __future__ import annotations\n")
buffer.write("from typing import Any\n")
buffer.write("from numpy.typing import NDArray\n")
buffer.write(f"from plotly.{base_package} import {base_classname}\n")

# Write class definition
@@ -82,7 +83,7 @@ class {fig_classname}({base_classname}):\n"""
buffer.write(
f"""
def __init__(self, data=None, layout=None,
frames=None, skip_invalid=False, **kwargs):
frames=None, skip_invalid: bool = False, **kwargs):
\"\"\"
Create a new :class:{fig_classname} instance
@@ -108,9 +109,7 @@ def __init__(self, data=None, layout=None,
if a property in the specification of data, layout, or frames
is invalid AND skip_invalid is False
\"\"\"
super({fig_classname} ,self).__init__(data, layout,
frames, skip_invalid,
**kwargs)
super().__init__(data, layout, frames, skip_invalid, **kwargs)
"""
)

@@ -121,7 +120,7 @@ def {wrapped_name}(self, {full_params}) -> "{fig_classname}":
'''
{getattr(BaseFigure, wrapped_name).__doc__}
'''
return super({fig_classname}, self).{wrapped_name}({param_list})
return super().{wrapped_name}({param_list})
"""
)

600 changes: 300 additions & 300 deletions codegen/resources/plot-schema.json

Large diffs are not rendered by default.

24 changes: 9 additions & 15 deletions codegen/utils.py
Original file line number Diff line number Diff line change
@@ -75,16 +75,12 @@ def build_from_imports_py(rel_modules=(), rel_classes=(), init_extra=""):

result = f"""\
import sys
from typing import TYPE_CHECKING
if sys.version_info < (3, 7) or TYPE_CHECKING:
{imports_str}
else:
from _plotly_utils.importers import relative_import
__all__, __getattr__, __dir__ = relative_import(
__name__,
{repr(rel_modules)},
{repr(rel_classes)}
)
from _plotly_utils.importers import relative_import
__all__, __getattr__, __dir__ = relative_import(
__name__,
{repr(rel_modules)},
{repr(rel_classes)}
)
{init_extra}
"""
@@ -126,14 +122,14 @@ def write_init_py(pkg_root, path_parts, rel_modules=(), rel_classes=(), init_ext
def format_description(desc):

# Remove surrounding *s from numbers
desc = re.sub("(^|[\s(,.:])\*([\d.]+)\*([\s),.:]|$)", r"\1\2\3", desc)
desc = re.sub(r"(^|[\s(,.:])\*([\d.]+)\*([\s),.:]|$)", r"\1\2\3", desc)

# replace *true* with True
desc = desc.replace("*true*", "True")
desc = desc.replace("*false*", "False")

# Replace *word* with "word"
desc = re.sub("(^|[\s(,.:])\*(\S+)\*([\s),.:]|$)", r'\1"\2"\3', desc)
desc = re.sub(r"(^|[\s(,.:])\*(\S+)\*([\s),.:]|$)", r'\1"\2"\3', desc)

# Special case strings that don't satisfy regex above
other_strings = [
@@ -456,9 +452,7 @@ def get_validator_params(self):

if self.is_compound:
params["data_class_str"] = repr(self.name_datatype_class)
params["data_docs"] = (
'"""' + self.get_constructor_params_docstring() + '\n"""'
)
params["data_docs"] = '"""\n"""'
else:
assert self.is_simple

18 changes: 7 additions & 11 deletions codegen/validators.py
Original file line number Diff line number Diff line change
@@ -24,15 +24,15 @@ def build_validator_py(node: PlotlyNode):
# ---------------
assert node.is_datatype

# Initialize source code buffer
# -----------------------------
# Initialize
buffer = StringIO()
import_alias = "_bv"

# Imports
# -------
# ### Import package of the validator's superclass ###
import_str = ".".join(node.name_base_validator.split(".")[:-1])
buffer.write(f"import {import_str }\n")
buffer.write(f"import {import_str} as {import_alias}\n")

# Build Validator
# ---------------
@@ -41,11 +41,11 @@ def build_validator_py(node: PlotlyNode):

# ### Write class definition ###
class_name = node.name_validator_class
superclass_name = node.name_base_validator
superclass_name = node.name_base_validator.split(".")[-1]
buffer.write(
f"""
class {class_name}({superclass_name}):
class {class_name}({import_alias}.{superclass_name}):
def __init__(self, plotly_name={params['plotly_name']},
parent_name={params['parent_name']},
**kwargs):"""
@@ -54,8 +54,7 @@ def __init__(self, plotly_name={params['plotly_name']},
# ### Write constructor ###
buffer.write(
f"""
super({class_name}, self).__init__(plotly_name=plotly_name,
parent_name=parent_name"""
super().__init__(plotly_name, parent_name"""
)

# Write out remaining constructor parameters
@@ -198,10 +197,7 @@ def __init__(self, plotly_name={params['plotly_name']},
parent_name={params['parent_name']},
**kwargs):
super(DataValidator, self).__init__(class_strs_map={params['class_strs_map']},
plotly_name=plotly_name,
parent_name=parent_name,
**kwargs)"""
super().__init__({params['class_strs_map']}, plotly_name, parent_name, **kwargs)"""
)

return buffer.getvalue()
67 changes: 38 additions & 29 deletions commands.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from distutils import log
import json
import os
import sys
import time
import platform
import json
import shutil

from subprocess import check_call
from distutils import log
import sys
import time

project_root = os.path.dirname(os.path.abspath(__file__))
node_root = os.path.join(project_root, "js")
is_repo = os.path.exists(os.path.join(project_root, ".git"))
node_modules = os.path.join(node_root, "node_modules")
targets = [
os.path.join(project_root, "plotly", "package_data", "widgetbundle.js"),
USAGE = "usage: python commands.py [updateplotlyjsdev | updateplotlyjs | codegen]"
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
NODE_ROOT = os.path.join(PROJECT_ROOT, "js")
NODE_MODULES = os.path.join(NODE_ROOT, "node_modules")
TARGETS = [
os.path.join(PROJECT_ROOT, "plotly", "package_data", "widgetbundle.js"),
]

npm_path = os.pathsep.join(
NPM_PATH = os.pathsep.join(
[
os.path.join(node_root, "node_modules", ".bin"),
os.path.join(NODE_ROOT, "node_modules", ".bin"),
os.environ.get("PATH", os.defpath),
]
)


# Load plotly.js version from js/package.json
def plotly_js_version():
path = os.path.join(project_root, "js", "package.json")
path = os.path.join(PROJECT_ROOT, "js", "package.json")
with open(path, "rt") as f:
package_json = json.load(f)
version = package_json["dependencies"]["plotly.js"]
@@ -57,33 +57,33 @@ def install_js_deps(local):
)

env = os.environ.copy()
env["PATH"] = npm_path
env["PATH"] = NPM_PATH

if has_npm:
log.info("Installing build dependencies with npm. This may take a while...")
check_call(
[npmName, "install"],
cwd=node_root,
cwd=NODE_ROOT,
stdout=sys.stdout,
stderr=sys.stderr,
)
if local is not None:
plotly_archive = os.path.join(local, "plotly.js.tgz")
check_call(
[npmName, "install", plotly_archive],
cwd=node_root,
cwd=NODE_ROOT,
stdout=sys.stdout,
stderr=sys.stderr,
)
check_call(
[npmName, "run", "build"],
cwd=node_root,
cwd=NODE_ROOT,
stdout=sys.stdout,
stderr=sys.stderr,
)
os.utime(node_modules, None)
os.utime(NODE_MODULES, None)

for t in targets:
for t in TARGETS:
if not os.path.exists(t):
msg = "Missing file: %s" % t
raise ValueError(msg)
@@ -100,7 +100,7 @@ def run_codegen():


def overwrite_schema_local(uri):
path = os.path.join(project_root, "codegen", "resources", "plot-schema.json")
path = os.path.join(PROJECT_ROOT, "codegen", "resources", "plot-schema.json")
shutil.copyfile(uri, path)


@@ -109,13 +109,13 @@ def overwrite_schema(url):

req = requests.get(url)
assert req.status_code == 200
path = os.path.join(project_root, "codegen", "resources", "plot-schema.json")
path = os.path.join(PROJECT_ROOT, "codegen", "resources", "plot-schema.json")
with open(path, "wb") as f:
f.write(req.content)


def overwrite_bundle_local(uri):
path = os.path.join(project_root, "plotly", "package_data", "plotly.min.js")
path = os.path.join(PROJECT_ROOT, "plotly", "package_data", "plotly.min.js")
shutil.copyfile(uri, path)


@@ -125,13 +125,13 @@ def overwrite_bundle(url):
req = requests.get(url)
print("url:", url)
assert req.status_code == 200
path = os.path.join(project_root, "plotly", "package_data", "plotly.min.js")
path = os.path.join(PROJECT_ROOT, "plotly", "package_data", "plotly.min.js")
with open(path, "wb") as f:
f.write(req.content)


def overwrite_plotlyjs_version_file(plotlyjs_version):
path = os.path.join(project_root, "plotly", "offline", "_plotlyjs_version.py")
path = os.path.join(PROJECT_ROOT, "plotly", "offline", "_plotlyjs_version.py")
with open(path, "w") as f:
f.write(
"""\
@@ -274,7 +274,7 @@ def update_schema_bundle_from_master():
overwrite_schema_local(schema_uri)

# Update plotly.js url in package.json
package_json_path = os.path.join(node_root, "package.json")
package_json_path = os.path.join(NODE_ROOT, "package.json")
with open(package_json_path, "r") as f:
package_json = json.load(f)

@@ -299,9 +299,18 @@ def update_plotlyjs_dev():
run_codegen()


if __name__ == "__main__":
if "updateplotlyjsdev" in sys.argv:
def main():
if len(sys.argv) != 2:
print(USAGE, file=sys.stderr)
sys.exit(1)
elif sys.argv[1] == "codegen":
run_codegen()
elif sys.argv[1] == "updateplotlyjsdev":
update_plotlyjs_dev()
elif "updateplotlyjs" in sys.argv:
elif sys.argv[1] == "updateplotlyjs":
print(plotly_js_version())
update_plotlyjs(plotly_js_version())


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions plotly/__init__.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
- exceptions: defines our custom exception classes
"""

import sys
from typing import TYPE_CHECKING
from _plotly_utils.importers import relative_import
30 changes: 30 additions & 0 deletions plotly/basedatatypes.py
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ def _make_underscore_key(key):
return key.replace("-", "_")

key_path2b = list(map(_make_hyphen_key, key_path2))

# Here we want to split up each non-empty string in the list at
# underscores and recombine the strings using chomp_empty_strings so
# that leading, trailing and multiple _ will be preserved
@@ -385,6 +386,18 @@ def _generator(i):
yield x


def _initialize_provided(obj, name, arg, provided):
"""
Initialize a property of this object using the provided value
or a value popped from the arguments dictionary. If neither
is available, do not set the property.
"""
val = arg.pop(name, None)
val = provided if provided is not None else val
if val is not None:
obj[name] = val


class BaseFigure(object):
"""
Base class for all figure types (both widget and non-widget)
@@ -834,6 +847,14 @@ def _ipython_display_(self):
else:
print(repr(self))

def _init_provided(self, name, arg, provided):
"""
Initialize a property of this object using the provided value
or a value popped from the arguments dictionary. If neither
is available, do not set the property.
"""
_initialize_provided(self, name, arg, provided)

def update(self, dict1=None, overwrite=False, **kwargs):
"""
Update the properties of the figure with a dict and/or with
@@ -1591,6 +1612,7 @@ def _add_annotation_like(
)
):
return self

# in case the user specified they wanted an axis to refer to the
# domain of that axis and not the data, append ' domain' to the
# computed axis accordingly
@@ -4329,6 +4351,14 @@ def _get_validator(self, prop):

return ValidatorCache.get_validator(self._path_str, prop)

def _init_provided(self, name, arg, provided):
"""
Initialize a property of this object using the provided value
or a value popped from the arguments dictionary. If neither
is available, do not set the property.
"""
_initialize_provided(self, name, arg, provided)

@property
def _validators(self):
"""
1 change: 1 addition & 0 deletions plotly/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Built-in datasets for demonstration, educational and test purposes.
"""

import os
from importlib import import_module

16 changes: 10 additions & 6 deletions plotly/express/_core.py
Original file line number Diff line number Diff line change
@@ -985,9 +985,11 @@ def make_trace_spec(args, constructor, attrs, trace_patch):

def make_trendline_spec(args, constructor):
trace_spec = TraceSpec(
constructor=go.Scattergl
if constructor == go.Scattergl # could be contour
else go.Scatter,
constructor=(
go.Scattergl
if constructor == go.Scattergl # could be contour
else go.Scatter
),
attrs=["trendline"],
trace_patch=dict(mode="lines"),
marginal=None,
@@ -2456,9 +2458,11 @@ def get_groups_and_orders(args, grouper):
full_sorted_group_names = [
tuple(
[
""
if col == one_group
else sub_group_names[required_grouper.index(col)]
(
""
if col == one_group
else sub_group_names[required_grouper.index(col)]
)
for col in grouper
]
)
3 changes: 1 addition & 2 deletions plotly/express/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Built-in datasets for demonstration, educational and test purposes.
"""
"""Built-in datasets for demonstration, educational and test purposes."""

from plotly.data import *

444 changes: 151 additions & 293 deletions plotly/graph_objects/__init__.py

Large diffs are not rendered by default.

444 changes: 151 additions & 293 deletions plotly/graph_objs/__init__.py

Large diffs are not rendered by default.

1,242 changes: 166 additions & 1,076 deletions plotly/graph_objs/_bar.py

Large diffs are not rendered by default.

653 changes: 110 additions & 543 deletions plotly/graph_objs/_barpolar.py

Large diffs are not rendered by default.

977 changes: 194 additions & 783 deletions plotly/graph_objs/_box.py

Large diffs are not rendered by default.

583 changes: 113 additions & 470 deletions plotly/graph_objs/_candlestick.py

Large diffs are not rendered by default.

952 changes: 86 additions & 866 deletions plotly/graph_objs/_carpet.py

Large diffs are not rendered by default.

826 changes: 109 additions & 717 deletions plotly/graph_objs/_choropleth.py

Large diffs are not rendered by default.

827 changes: 109 additions & 718 deletions plotly/graph_objs/_choroplethmap.py

Large diffs are not rendered by default.

827 changes: 109 additions & 718 deletions plotly/graph_objs/_choroplethmapbox.py

Large diffs are not rendered by default.

963 changes: 139 additions & 824 deletions plotly/graph_objs/_cone.py

Large diffs are not rendered by default.

1,196 changes: 161 additions & 1,035 deletions plotly/graph_objs/_contour.py

Large diffs are not rendered by default.

936 changes: 121 additions & 815 deletions plotly/graph_objs/_contourcarpet.py

Large diffs are not rendered by default.

795 changes: 109 additions & 686 deletions plotly/graph_objs/_densitymap.py

Large diffs are not rendered by default.

796 changes: 109 additions & 687 deletions plotly/graph_objs/_densitymapbox.py

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions plotly/graph_objs/_deprecations.py
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Data, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Annotations(list):
@@ -67,7 +67,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Annotations, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Frames(list):
@@ -92,7 +92,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Frames, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class AngularAxis(dict):
@@ -120,7 +120,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(AngularAxis, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Annotation(dict):
@@ -148,7 +148,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Annotation, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class ColorBar(dict):
@@ -179,7 +179,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(ColorBar, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Contours(dict):
@@ -210,7 +210,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Contours, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class ErrorX(dict):
@@ -241,7 +241,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(ErrorX, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class ErrorY(dict):
@@ -272,7 +272,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(ErrorY, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class ErrorZ(dict):
@@ -297,7 +297,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(ErrorZ, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Font(dict):
@@ -328,7 +328,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Font, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Legend(dict):
@@ -353,7 +353,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Legend, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Line(dict):
@@ -384,7 +384,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Line, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Margin(dict):
@@ -409,7 +409,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Margin, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Marker(dict):
@@ -440,7 +440,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Marker, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class RadialAxis(dict):
@@ -468,7 +468,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(RadialAxis, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Scene(dict):
@@ -493,7 +493,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Scene, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Stream(dict):
@@ -521,7 +521,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Stream, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class XAxis(dict):
@@ -549,7 +549,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(XAxis, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class YAxis(dict):
@@ -577,7 +577,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(YAxis, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class ZAxis(dict):
@@ -602,7 +602,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(ZAxis, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class XBins(dict):
@@ -630,7 +630,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(XBins, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class YBins(dict):
@@ -658,7 +658,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(YBins, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Trace(dict):
@@ -695,7 +695,7 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Trace, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class Histogram2dcontour(dict):
@@ -720,4 +720,4 @@ def __init__(self, *args, **kwargs):
""",
DeprecationWarning,
)
super(Histogram2dcontour, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
5,958 changes: 2,694 additions & 3,264 deletions plotly/graph_objs/_figure.py

Large diffs are not rendered by default.

5,960 changes: 2,694 additions & 3,266 deletions plotly/graph_objs/_figurewidget.py

Large diffs are not rendered by default.

76 changes: 16 additions & 60 deletions plotly/graph_objs/_frame.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseFrameHierarchyType as _BaseFrameHierarchyType
import copy as _copy


class Frame(_BaseFrameHierarchyType):

# class properties
# --------------------
_parent_path_str = ""
_path_str = "frame"
_valid_props = {"baseframe", "data", "group", "layout", "name", "traces"}

# baseframe
# ---------
@property
def baseframe(self):
"""
@@ -34,8 +33,6 @@ def baseframe(self):
def baseframe(self, val):
self["baseframe"] = val

# data
# ----
@property
def data(self):
"""
@@ -52,8 +49,6 @@ def data(self):
def data(self, val):
self["data"] = val

# group
# -----
@property
def group(self):
"""
@@ -74,8 +69,6 @@ def group(self):
def group(self, val):
self["group"] = val

# layout
# ------
@property
def layout(self):
"""
@@ -92,8 +85,6 @@ def layout(self):
def layout(self, val):
self["layout"] = val

# name
# ----
@property
def name(self):
"""
@@ -113,8 +104,6 @@ def name(self):
def name(self, val):
self["name"] = val

# traces
# ------
@property
def traces(self):
"""
@@ -133,8 +122,6 @@ def traces(self):
def traces(self, val):
self["traces"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -163,12 +150,12 @@ def _prop_descriptions(self):
def __init__(
self,
arg=None,
baseframe=None,
data=None,
group=None,
layout=None,
name=None,
traces=None,
baseframe: str | None = None,
data: Any | None = None,
group: str | None = None,
layout: Any | None = None,
name: str | None = None,
traces: Any | None = None,
**kwargs,
):
"""
@@ -204,14 +191,11 @@ def __init__(
-------
Frame
"""
super(Frame, self).__init__("frames")

super().__init__("frames")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -226,42 +210,14 @@ def __init__(
an instance of :class:`plotly.graph_objs.Frame`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("baseframe", None)
_v = baseframe if baseframe is not None else _v
if _v is not None:
self["baseframe"] = _v
_v = arg.pop("data", None)
_v = data if data is not None else _v
if _v is not None:
self["data"] = _v
_v = arg.pop("group", None)
_v = group if group is not None else _v
if _v is not None:
self["group"] = _v
_v = arg.pop("layout", None)
_v = layout if layout is not None else _v
if _v is not None:
self["layout"] = _v
_v = arg.pop("name", None)
_v = name if name is not None else _v
if _v is not None:
self["name"] = _v
_v = arg.pop("traces", None)
_v = traces if traces is not None else _v
if _v is not None:
self["traces"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("baseframe", arg, baseframe)
self._init_provided("data", arg, data)
self._init_provided("group", arg, group)
self._init_provided("layout", arg, layout)
self._init_provided("name", arg, name)
self._init_provided("traces", arg, traces)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
1,029 changes: 147 additions & 882 deletions plotly/graph_objs/_funnel.py

Large diffs are not rendered by default.

709 changes: 107 additions & 602 deletions plotly/graph_objs/_funnelarea.py

Large diffs are not rendered by default.

1,055 changes: 156 additions & 899 deletions plotly/graph_objs/_heatmap.py

Large diffs are not rendered by default.

1,205 changes: 145 additions & 1,060 deletions plotly/graph_objs/_histogram.py

Large diffs are not rendered by default.

1,062 changes: 138 additions & 924 deletions plotly/graph_objs/_histogram2d.py

Large diffs are not rendered by default.

1,154 changes: 140 additions & 1,014 deletions plotly/graph_objs/_histogram2dcontour.py

Large diffs are not rendered by default.

927 changes: 113 additions & 814 deletions plotly/graph_objs/_icicle.py

Large diffs are not rendered by default.

451 changes: 90 additions & 361 deletions plotly/graph_objs/_image.py

Large diffs are not rendered by default.

363 changes: 53 additions & 310 deletions plotly/graph_objs/_indicator.py

Large diffs are not rendered by default.

1,030 changes: 135 additions & 895 deletions plotly/graph_objs/_isosurface.py

Large diffs are not rendered by default.

4,074 changes: 198 additions & 3,876 deletions plotly/graph_objs/_layout.py

Large diffs are not rendered by default.

1,098 changes: 161 additions & 937 deletions plotly/graph_objs/_mesh3d.py

Large diffs are not rendered by default.

578 changes: 113 additions & 465 deletions plotly/graph_objs/_ohlc.py

Large diffs are not rendered by default.

549 changes: 52 additions & 497 deletions plotly/graph_objs/_parcats.py

Large diffs are not rendered by default.

609 changes: 57 additions & 552 deletions plotly/graph_objs/_parcoords.py

Large diffs are not rendered by default.

844 changes: 122 additions & 722 deletions plotly/graph_objs/_pie.py

Large diffs are not rendered by default.

595 changes: 59 additions & 536 deletions plotly/graph_objs/_sankey.py

Large diffs are not rendered by default.

1,295 changes: 164 additions & 1,131 deletions plotly/graph_objs/_scatter.py

Large diffs are not rendered by default.

1,099 changes: 127 additions & 972 deletions plotly/graph_objs/_scatter3d.py

Large diffs are not rendered by default.

873 changes: 116 additions & 757 deletions plotly/graph_objs/_scattercarpet.py

Large diffs are not rendered by default.

863 changes: 119 additions & 744 deletions plotly/graph_objs/_scattergeo.py

Large diffs are not rendered by default.

1,043 changes: 142 additions & 901 deletions plotly/graph_objs/_scattergl.py

Large diffs are not rendered by default.

782 changes: 109 additions & 673 deletions plotly/graph_objs/_scattermap.py

Large diffs are not rendered by default.

782 changes: 109 additions & 673 deletions plotly/graph_objs/_scattermapbox.py

Large diffs are not rendered by default.

900 changes: 122 additions & 778 deletions plotly/graph_objs/_scatterpolar.py

Large diffs are not rendered by default.

814 changes: 118 additions & 696 deletions plotly/graph_objs/_scatterpolargl.py

Large diffs are not rendered by default.

855 changes: 112 additions & 743 deletions plotly/graph_objs/_scattersmith.py

Large diffs are not rendered by default.

884 changes: 119 additions & 765 deletions plotly/graph_objs/_scatterternary.py

Large diffs are not rendered by default.

651 changes: 91 additions & 560 deletions plotly/graph_objs/_splom.py

Large diffs are not rendered by default.

963 changes: 133 additions & 830 deletions plotly/graph_objs/_streamtube.py

Large diffs are not rendered by default.

880 changes: 111 additions & 769 deletions plotly/graph_objs/_sunburst.py

Large diffs are not rendered by default.

939 changes: 131 additions & 808 deletions plotly/graph_objs/_surface.py

Large diffs are not rendered by default.

440 changes: 60 additions & 380 deletions plotly/graph_objs/_table.py

Large diffs are not rendered by default.

936 changes: 111 additions & 825 deletions plotly/graph_objs/_treemap.py

Large diffs are not rendered by default.

766 changes: 136 additions & 630 deletions plotly/graph_objs/_violin.py

Large diffs are not rendered by default.

1,037 changes: 137 additions & 900 deletions plotly/graph_objs/_volume.py

Large diffs are not rendered by default.

1,020 changes: 164 additions & 856 deletions plotly/graph_objs/_waterfall.py

Large diffs are not rendered by default.

56 changes: 18 additions & 38 deletions plotly/graph_objs/bar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
import sys
from typing import TYPE_CHECKING
from _plotly_utils.importers import relative_import

if sys.version_info < (3, 7) or TYPE_CHECKING:
from ._error_x import ErrorX
from ._error_y import ErrorY
from ._hoverlabel import Hoverlabel
from ._insidetextfont import Insidetextfont
from ._legendgrouptitle import Legendgrouptitle
from ._marker import Marker
from ._outsidetextfont import Outsidetextfont
from ._selected import Selected
from ._stream import Stream
from ._textfont import Textfont
from ._unselected import Unselected
from . import hoverlabel
from . import legendgrouptitle
from . import marker
from . import selected
from . import unselected
else:
from _plotly_utils.importers import relative_import

__all__, __getattr__, __dir__ = relative_import(
__name__,
[".hoverlabel", ".legendgrouptitle", ".marker", ".selected", ".unselected"],
[
"._error_x.ErrorX",
"._error_y.ErrorY",
"._hoverlabel.Hoverlabel",
"._insidetextfont.Insidetextfont",
"._legendgrouptitle.Legendgrouptitle",
"._marker.Marker",
"._outsidetextfont.Outsidetextfont",
"._selected.Selected",
"._stream.Stream",
"._textfont.Textfont",
"._unselected.Unselected",
],
)
__all__, __getattr__, __dir__ = relative_import(
__name__,
[".hoverlabel", ".legendgrouptitle", ".marker", ".selected", ".unselected"],
[
"._error_x.ErrorX",
"._error_y.ErrorY",
"._hoverlabel.Hoverlabel",
"._insidetextfont.Insidetextfont",
"._legendgrouptitle.Legendgrouptitle",
"._marker.Marker",
"._outsidetextfont.Outsidetextfont",
"._selected.Selected",
"._stream.Stream",
"._textfont.Textfont",
"._unselected.Unselected",
],
)
204 changes: 40 additions & 164 deletions plotly/graph_objs/bar/_error_x.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class ErrorX(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar"
_path_str = "bar.error_x"
_valid_props = {
@@ -26,8 +27,6 @@ class ErrorX(_BaseTraceHierarchyType):
"width",
}

# array
# -----
@property
def array(self):
"""
@@ -39,16 +38,14 @@ def array(self):
Returns
-------
numpy.ndarray
NDArray
"""
return self["array"]

@array.setter
def array(self, val):
self["array"] = val

# arrayminus
# ----------
@property
def arrayminus(self):
"""
@@ -61,16 +58,14 @@ def arrayminus(self):
Returns
-------
numpy.ndarray
NDArray
"""
return self["arrayminus"]

@arrayminus.setter
def arrayminus(self, val):
self["arrayminus"] = val

# arrayminussrc
# -------------
@property
def arrayminussrc(self):
"""
@@ -90,8 +85,6 @@ def arrayminussrc(self):
def arrayminussrc(self, val):
self["arrayminussrc"] = val

# arraysrc
# --------
@property
def arraysrc(self):
"""
@@ -110,8 +103,6 @@ def arraysrc(self):
def arraysrc(self, val):
self["arraysrc"] = val

# color
# -----
@property
def color(self):
"""
@@ -122,42 +113,7 @@ def color(self):
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A named CSS color
Returns
-------
@@ -169,8 +125,6 @@ def color(self):
def color(self, val):
self["color"] = val

# copy_ystyle
# -----------
@property
def copy_ystyle(self):
"""
@@ -187,8 +141,6 @@ def copy_ystyle(self):
def copy_ystyle(self, val):
self["copy_ystyle"] = val

# symmetric
# ---------
@property
def symmetric(self):
"""
@@ -209,8 +161,6 @@ def symmetric(self):
def symmetric(self, val):
self["symmetric"] = val

# thickness
# ---------
@property
def thickness(self):
"""
@@ -229,8 +179,6 @@ def thickness(self):
def thickness(self, val):
self["thickness"] = val

# traceref
# --------
@property
def traceref(self):
"""
@@ -248,8 +196,6 @@ def traceref(self):
def traceref(self, val):
self["traceref"] = val

# tracerefminus
# -------------
@property
def tracerefminus(self):
"""
@@ -267,13 +213,11 @@ def tracerefminus(self):
def tracerefminus(self, val):
self["tracerefminus"] = val

# type
# ----
@property
def type(self):
"""
Determines the rule used to generate the error bars. If
*constant`, the bar lengths are of a constant value. Set this
"constant", the bar lengths are of a constant value. Set this
constant in `value`. If "percent", the bar lengths correspond
to a percentage of underlying data. Set this percentage in
`value`. If "sqrt", the bar lengths correspond to the square of
@@ -294,8 +238,6 @@ def type(self):
def type(self, val):
self["type"] = val

# value
# -----
@property
def value(self):
"""
@@ -316,8 +258,6 @@ def value(self):
def value(self, val):
self["value"] = val

# valueminus
# ----------
@property
def valueminus(self):
"""
@@ -339,8 +279,6 @@ def valueminus(self):
def valueminus(self, val):
self["valueminus"] = val

# visible
# -------
@property
def visible(self):
"""
@@ -359,8 +297,6 @@ def visible(self):
def visible(self, val):
self["visible"] = val

# width
# -----
@property
def width(self):
"""
@@ -380,8 +316,6 @@ def width(self):
def width(self, val):
self["width"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -416,7 +350,7 @@ def _prop_descriptions(self):
type
Determines the rule used to generate the error bars. If
*constant`, the bar lengths are of a constant value.
"constant", the bar lengths are of a constant value.
Set this constant in `value`. If "percent", the bar
lengths correspond to a percentage of underlying data.
Set this percentage in `value`. If "sqrt", the bar
@@ -445,21 +379,21 @@ def _prop_descriptions(self):
def __init__(
self,
arg=None,
array=None,
arrayminus=None,
arrayminussrc=None,
arraysrc=None,
color=None,
copy_ystyle=None,
symmetric=None,
thickness=None,
traceref=None,
tracerefminus=None,
type=None,
value=None,
valueminus=None,
visible=None,
width=None,
array: NDArray | None = None,
arrayminus: NDArray | None = None,
arrayminussrc: str | None = None,
arraysrc: str | None = None,
color: str | None = None,
copy_ystyle: bool | None = None,
symmetric: bool | None = None,
thickness: int | float | None = None,
traceref: int | None = None,
tracerefminus: int | None = None,
type: Any | None = None,
value: int | float | None = None,
valueminus: int | float | None = None,
visible: bool | None = None,
width: int | float | None = None,
**kwargs,
):
"""
@@ -501,7 +435,7 @@ def __init__(
type
Determines the rule used to generate the error bars. If
*constant`, the bar lengths are of a constant value.
"constant", the bar lengths are of a constant value.
Set this constant in `value`. If "percent", the bar
lengths correspond to a percentage of underlying data.
Set this percentage in `value`. If "sqrt", the bar
@@ -530,14 +464,11 @@ def __init__(
-------
ErrorX
"""
super(ErrorX, self).__init__("error_x")

super().__init__("error_x")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -552,78 +483,23 @@ def __init__(
an instance of :class:`plotly.graph_objs.bar.ErrorX`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("array", None)
_v = array if array is not None else _v
if _v is not None:
self["array"] = _v
_v = arg.pop("arrayminus", None)
_v = arrayminus if arrayminus is not None else _v
if _v is not None:
self["arrayminus"] = _v
_v = arg.pop("arrayminussrc", None)
_v = arrayminussrc if arrayminussrc is not None else _v
if _v is not None:
self["arrayminussrc"] = _v
_v = arg.pop("arraysrc", None)
_v = arraysrc if arraysrc is not None else _v
if _v is not None:
self["arraysrc"] = _v
_v = arg.pop("color", None)
_v = color if color is not None else _v
if _v is not None:
self["color"] = _v
_v = arg.pop("copy_ystyle", None)
_v = copy_ystyle if copy_ystyle is not None else _v
if _v is not None:
self["copy_ystyle"] = _v
_v = arg.pop("symmetric", None)
_v = symmetric if symmetric is not None else _v
if _v is not None:
self["symmetric"] = _v
_v = arg.pop("thickness", None)
_v = thickness if thickness is not None else _v
if _v is not None:
self["thickness"] = _v
_v = arg.pop("traceref", None)
_v = traceref if traceref is not None else _v
if _v is not None:
self["traceref"] = _v
_v = arg.pop("tracerefminus", None)
_v = tracerefminus if tracerefminus is not None else _v
if _v is not None:
self["tracerefminus"] = _v
_v = arg.pop("type", None)
_v = type if type is not None else _v
if _v is not None:
self["type"] = _v
_v = arg.pop("value", None)
_v = value if value is not None else _v
if _v is not None:
self["value"] = _v
_v = arg.pop("valueminus", None)
_v = valueminus if valueminus is not None else _v
if _v is not None:
self["valueminus"] = _v
_v = arg.pop("visible", None)
_v = visible if visible is not None else _v
if _v is not None:
self["visible"] = _v
_v = arg.pop("width", None)
_v = width if width is not None else _v
if _v is not None:
self["width"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("array", arg, array)
self._init_provided("arrayminus", arg, arrayminus)
self._init_provided("arrayminussrc", arg, arrayminussrc)
self._init_provided("arraysrc", arg, arraysrc)
self._init_provided("color", arg, color)
self._init_provided("copy_ystyle", arg, copy_ystyle)
self._init_provided("symmetric", arg, symmetric)
self._init_provided("thickness", arg, thickness)
self._init_provided("traceref", arg, traceref)
self._init_provided("tracerefminus", arg, tracerefminus)
self._init_provided("type", arg, type)
self._init_provided("value", arg, value)
self._init_provided("valueminus", arg, valueminus)
self._init_provided("visible", arg, visible)
self._init_provided("width", arg, width)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
195 changes: 38 additions & 157 deletions plotly/graph_objs/bar/_error_y.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class ErrorY(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar"
_path_str = "bar.error_y"
_valid_props = {
@@ -25,8 +26,6 @@ class ErrorY(_BaseTraceHierarchyType):
"width",
}

# array
# -----
@property
def array(self):
"""
@@ -38,16 +37,14 @@ def array(self):
Returns
-------
numpy.ndarray
NDArray
"""
return self["array"]

@array.setter
def array(self, val):
self["array"] = val

# arrayminus
# ----------
@property
def arrayminus(self):
"""
@@ -60,16 +57,14 @@ def arrayminus(self):
Returns
-------
numpy.ndarray
NDArray
"""
return self["arrayminus"]

@arrayminus.setter
def arrayminus(self, val):
self["arrayminus"] = val

# arrayminussrc
# -------------
@property
def arrayminussrc(self):
"""
@@ -89,8 +84,6 @@ def arrayminussrc(self):
def arrayminussrc(self, val):
self["arrayminussrc"] = val

# arraysrc
# --------
@property
def arraysrc(self):
"""
@@ -109,8 +102,6 @@ def arraysrc(self):
def arraysrc(self, val):
self["arraysrc"] = val

# color
# -----
@property
def color(self):
"""
@@ -121,42 +112,7 @@ def color(self):
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A named CSS color
Returns
-------
@@ -168,8 +124,6 @@ def color(self):
def color(self, val):
self["color"] = val

# symmetric
# ---------
@property
def symmetric(self):
"""
@@ -190,8 +144,6 @@ def symmetric(self):
def symmetric(self, val):
self["symmetric"] = val

# thickness
# ---------
@property
def thickness(self):
"""
@@ -210,8 +162,6 @@ def thickness(self):
def thickness(self, val):
self["thickness"] = val

# traceref
# --------
@property
def traceref(self):
"""
@@ -229,8 +179,6 @@ def traceref(self):
def traceref(self, val):
self["traceref"] = val

# tracerefminus
# -------------
@property
def tracerefminus(self):
"""
@@ -248,13 +196,11 @@ def tracerefminus(self):
def tracerefminus(self, val):
self["tracerefminus"] = val

# type
# ----
@property
def type(self):
"""
Determines the rule used to generate the error bars. If
*constant`, the bar lengths are of a constant value. Set this
"constant", the bar lengths are of a constant value. Set this
constant in `value`. If "percent", the bar lengths correspond
to a percentage of underlying data. Set this percentage in
`value`. If "sqrt", the bar lengths correspond to the square of
@@ -275,8 +221,6 @@ def type(self):
def type(self, val):
self["type"] = val

# value
# -----
@property
def value(self):
"""
@@ -297,8 +241,6 @@ def value(self):
def value(self, val):
self["value"] = val

# valueminus
# ----------
@property
def valueminus(self):
"""
@@ -320,8 +262,6 @@ def valueminus(self):
def valueminus(self, val):
self["valueminus"] = val

# visible
# -------
@property
def visible(self):
"""
@@ -340,8 +280,6 @@ def visible(self):
def visible(self, val):
self["visible"] = val

# width
# -----
@property
def width(self):
"""
@@ -361,8 +299,6 @@ def width(self):
def width(self, val):
self["width"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -395,7 +331,7 @@ def _prop_descriptions(self):
type
Determines the rule used to generate the error bars. If
*constant`, the bar lengths are of a constant value.
"constant", the bar lengths are of a constant value.
Set this constant in `value`. If "percent", the bar
lengths correspond to a percentage of underlying data.
Set this percentage in `value`. If "sqrt", the bar
@@ -424,20 +360,20 @@ def _prop_descriptions(self):
def __init__(
self,
arg=None,
array=None,
arrayminus=None,
arrayminussrc=None,
arraysrc=None,
color=None,
symmetric=None,
thickness=None,
traceref=None,
tracerefminus=None,
type=None,
value=None,
valueminus=None,
visible=None,
width=None,
array: NDArray | None = None,
arrayminus: NDArray | None = None,
arrayminussrc: str | None = None,
arraysrc: str | None = None,
color: str | None = None,
symmetric: bool | None = None,
thickness: int | float | None = None,
traceref: int | None = None,
tracerefminus: int | None = None,
type: Any | None = None,
value: int | float | None = None,
valueminus: int | float | None = None,
visible: bool | None = None,
width: int | float | None = None,
**kwargs,
):
"""
@@ -477,7 +413,7 @@ def __init__(
type
Determines the rule used to generate the error bars. If
*constant`, the bar lengths are of a constant value.
"constant", the bar lengths are of a constant value.
Set this constant in `value`. If "percent", the bar
lengths correspond to a percentage of underlying data.
Set this percentage in `value`. If "sqrt", the bar
@@ -506,14 +442,11 @@ def __init__(
-------
ErrorY
"""
super(ErrorY, self).__init__("error_y")

super().__init__("error_y")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -528,74 +461,22 @@ def __init__(
an instance of :class:`plotly.graph_objs.bar.ErrorY`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("array", None)
_v = array if array is not None else _v
if _v is not None:
self["array"] = _v
_v = arg.pop("arrayminus", None)
_v = arrayminus if arrayminus is not None else _v
if _v is not None:
self["arrayminus"] = _v
_v = arg.pop("arrayminussrc", None)
_v = arrayminussrc if arrayminussrc is not None else _v
if _v is not None:
self["arrayminussrc"] = _v
_v = arg.pop("arraysrc", None)
_v = arraysrc if arraysrc is not None else _v
if _v is not None:
self["arraysrc"] = _v
_v = arg.pop("color", None)
_v = color if color is not None else _v
if _v is not None:
self["color"] = _v
_v = arg.pop("symmetric", None)
_v = symmetric if symmetric is not None else _v
if _v is not None:
self["symmetric"] = _v
_v = arg.pop("thickness", None)
_v = thickness if thickness is not None else _v
if _v is not None:
self["thickness"] = _v
_v = arg.pop("traceref", None)
_v = traceref if traceref is not None else _v
if _v is not None:
self["traceref"] = _v
_v = arg.pop("tracerefminus", None)
_v = tracerefminus if tracerefminus is not None else _v
if _v is not None:
self["tracerefminus"] = _v
_v = arg.pop("type", None)
_v = type if type is not None else _v
if _v is not None:
self["type"] = _v
_v = arg.pop("value", None)
_v = value if value is not None else _v
if _v is not None:
self["value"] = _v
_v = arg.pop("valueminus", None)
_v = valueminus if valueminus is not None else _v
if _v is not None:
self["valueminus"] = _v
_v = arg.pop("visible", None)
_v = visible if visible is not None else _v
if _v is not None:
self["visible"] = _v
_v = arg.pop("width", None)
_v = width if width is not None else _v
if _v is not None:
self["width"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("array", arg, array)
self._init_provided("arrayminus", arg, arrayminus)
self._init_provided("arrayminussrc", arg, arrayminussrc)
self._init_provided("arraysrc", arg, arraysrc)
self._init_provided("color", arg, color)
self._init_provided("symmetric", arg, symmetric)
self._init_provided("thickness", arg, thickness)
self._init_provided("traceref", arg, traceref)
self._init_provided("tracerefminus", arg, tracerefminus)
self._init_provided("type", arg, type)
self._init_provided("value", arg, value)
self._init_provided("valueminus", arg, valueminus)
self._init_provided("visible", arg, visible)
self._init_provided("width", arg, width)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
258 changes: 28 additions & 230 deletions plotly/graph_objs/bar/_hoverlabel.py

Large diffs are not rendered by default.

288 changes: 64 additions & 224 deletions plotly/graph_objs/bar/_insidetextfont.py

Large diffs are not rendered by default.

86 changes: 9 additions & 77 deletions plotly/graph_objs/bar/_legendgrouptitle.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class Legendgrouptitle(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar"
_path_str = "bar.legendgrouptitle"
_valid_props = {"font", "text"}

# font
# ----
@property
def font(self):
"""
@@ -23,52 +22,6 @@ def font(self):
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans", "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
lineposition
Sets the kind of decoration line(s) with text,
such as an "under", "over" or "through" as well
as combinations e.g. "under+over", etc.
shadow
Sets the shape and color of the shadow behind
text. "auto" places minimal shadow and applies
contrast text font color. See
https://developer.mozilla.org/en-
US/docs/Web/CSS/text-shadow for additional
options.
size
style
Sets whether a font should be styled with a
normal or italic face from its family.
textcase
Sets capitalization of text. It can be used to
make text appear in all-uppercase or all-
lowercase, or with each word capitalized.
variant
Sets the variant of the font.
weight
Sets the weight (or boldness) of the font.
Returns
-------
plotly.graph_objs.bar.legendgrouptitle.Font
@@ -79,8 +32,6 @@ def font(self):
def font(self, val):
self["font"] = val

# text
# ----
@property
def text(self):
"""
@@ -100,8 +51,6 @@ def text(self):
def text(self, val):
self["text"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -111,7 +60,9 @@ def _prop_descriptions(self):
Sets the title of the legend group.
"""

def __init__(self, arg=None, font=None, text=None, **kwargs):
def __init__(
self, arg=None, font: None | None = None, text: str | None = None, **kwargs
):
"""
Construct a new Legendgrouptitle object
@@ -130,14 +81,11 @@ def __init__(self, arg=None, font=None, text=None, **kwargs):
-------
Legendgrouptitle
"""
super(Legendgrouptitle, self).__init__("legendgrouptitle")

super().__init__("legendgrouptitle")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -152,26 +100,10 @@ def __init__(self, arg=None, font=None, text=None, **kwargs):
an instance of :class:`plotly.graph_objs.bar.Legendgrouptitle`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("font", None)
_v = font if font is not None else _v
if _v is not None:
self["font"] = _v
_v = arg.pop("text", None)
_v = text if text is not None else _v
if _v is not None:
self["text"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("font", arg, font)
self._init_provided("text", arg, text)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
625 changes: 41 additions & 584 deletions plotly/graph_objs/bar/_marker.py

Large diffs are not rendered by default.

288 changes: 64 additions & 224 deletions plotly/graph_objs/bar/_outsidetextfont.py

Large diffs are not rendered by default.

56 changes: 13 additions & 43 deletions plotly/graph_objs/bar/_selected.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class Selected(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar"
_path_str = "bar.selected"
_valid_props = {"marker", "textfont"}

# marker
# ------
@property
def marker(self):
"""
@@ -21,13 +20,6 @@ def marker(self):
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
color
Sets the marker color of selected points.
opacity
Sets the marker opacity of selected points.
Returns
-------
plotly.graph_objs.bar.selected.Marker
@@ -38,8 +30,6 @@ def marker(self):
def marker(self, val):
self["marker"] = val

# textfont
# --------
@property
def textfont(self):
"""
@@ -49,11 +39,6 @@ def textfont(self):
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties:
color
Sets the text font color of selected points.
Returns
-------
plotly.graph_objs.bar.selected.Textfont
@@ -64,8 +49,6 @@ def textfont(self):
def textfont(self, val):
self["textfont"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -77,7 +60,13 @@ def _prop_descriptions(self):
instance or dict with compatible properties
"""

def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
def __init__(
self,
arg=None,
marker: None | None = None,
textfont: None | None = None,
**kwargs,
):
"""
Construct a new Selected object
@@ -97,14 +86,11 @@ def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
-------
Selected
"""
super(Selected, self).__init__("selected")

super().__init__("selected")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -119,26 +105,10 @@ def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
an instance of :class:`plotly.graph_objs.bar.Selected`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("marker", None)
_v = marker if marker is not None else _v
if _v is not None:
self["marker"] = _v
_v = arg.pop("textfont", None)
_v = textfont if textfont is not None else _v
if _v is not None:
self["textfont"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("marker", arg, marker)
self._init_provided("textfont", arg, textfont)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
44 changes: 13 additions & 31 deletions plotly/graph_objs/bar/_stream.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class Stream(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar"
_path_str = "bar.stream"
_valid_props = {"maxpoints", "token"}

# maxpoints
# ---------
@property
def maxpoints(self):
"""
@@ -32,8 +31,6 @@ def maxpoints(self):
def maxpoints(self, val):
self["maxpoints"] = val

# token
# -----
@property
def token(self):
"""
@@ -54,8 +51,6 @@ def token(self):
def token(self, val):
self["token"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -70,7 +65,13 @@ def _prop_descriptions(self):
for more details.
"""

def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
def __init__(
self,
arg=None,
maxpoints: int | float | None = None,
token: str | None = None,
**kwargs,
):
"""
Construct a new Stream object
@@ -93,14 +94,11 @@ def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
-------
Stream
"""
super(Stream, self).__init__("stream")

super().__init__("stream")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -115,26 +113,10 @@ def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
an instance of :class:`plotly.graph_objs.bar.Stream`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("maxpoints", None)
_v = maxpoints if maxpoints is not None else _v
if _v is not None:
self["maxpoints"] = _v
_v = arg.pop("token", None)
_v = token if token is not None else _v
if _v is not None:
self["token"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("maxpoints", arg, maxpoints)
self._init_provided("token", arg, token)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
288 changes: 64 additions & 224 deletions plotly/graph_objs/bar/_textfont.py

Large diffs are not rendered by default.

59 changes: 13 additions & 46 deletions plotly/graph_objs/bar/_unselected.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class Unselected(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar"
_path_str = "bar.unselected"
_valid_props = {"marker", "textfont"}

# marker
# ------
@property
def marker(self):
"""
@@ -21,15 +20,6 @@ def marker(self):
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
color
Sets the marker color of unselected points,
applied only when a selection exists.
opacity
Sets the marker opacity of unselected points,
applied only when a selection exists.
Returns
-------
plotly.graph_objs.bar.unselected.Marker
@@ -40,8 +30,6 @@ def marker(self):
def marker(self, val):
self["marker"] = val

# textfont
# --------
@property
def textfont(self):
"""
@@ -51,12 +39,6 @@ def textfont(self):
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties:
color
Sets the text font color of unselected points,
applied only when a selection exists.
Returns
-------
plotly.graph_objs.bar.unselected.Textfont
@@ -67,8 +49,6 @@ def textfont(self):
def textfont(self, val):
self["textfont"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
@@ -80,7 +60,13 @@ def _prop_descriptions(self):
instance or dict with compatible properties
"""

def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
def __init__(
self,
arg=None,
marker: None | None = None,
textfont: None | None = None,
**kwargs,
):
"""
Construct a new Unselected object
@@ -101,14 +87,11 @@ def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
-------
Unselected
"""
super(Unselected, self).__init__("unselected")

super().__init__("unselected")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -123,26 +106,10 @@ def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
an instance of :class:`plotly.graph_objs.bar.Unselected`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("marker", None)
_v = marker if marker is not None else _v
if _v is not None:
self["marker"] = _v
_v = arg.pop("textfont", None)
_v = textfont if textfont is not None else _v
if _v is not None:
self["textfont"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("marker", arg, marker)
self._init_provided("textfont", arg, textfont)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
9 changes: 2 additions & 7 deletions plotly/graph_objs/bar/hoverlabel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import sys
from typing import TYPE_CHECKING
from _plotly_utils.importers import relative_import

if sys.version_info < (3, 7) or TYPE_CHECKING:
from ._font import Font
else:
from _plotly_utils.importers import relative_import

__all__, __getattr__, __dir__ = relative_import(__name__, [], ["._font.Font"])
__all__, __getattr__, __dir__ = relative_import(__name__, [], ["._font.Font"])
288 changes: 64 additions & 224 deletions plotly/graph_objs/bar/hoverlabel/_font.py

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions plotly/graph_objs/bar/legendgrouptitle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import sys
from typing import TYPE_CHECKING
from _plotly_utils.importers import relative_import

if sys.version_info < (3, 7) or TYPE_CHECKING:
from ._font import Font
else:
from _plotly_utils.importers import relative_import

__all__, __getattr__, __dir__ = relative_import(__name__, [], ["._font.Font"])
__all__, __getattr__, __dir__ = relative_import(__name__, [], ["._font.Font"])
189 changes: 37 additions & 152 deletions plotly/graph_objs/bar/legendgrouptitle/_font.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations
from typing import Any
from numpy.typing import NDArray
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy


class Font(_BaseTraceHierarchyType):

# class properties
# --------------------
_parent_path_str = "bar.legendgrouptitle"
_path_str = "bar.legendgrouptitle.font"
_valid_props = {
@@ -20,8 +21,6 @@ class Font(_BaseTraceHierarchyType):
"weight",
}

# color
# -----
@property
def color(self):
"""
@@ -30,42 +29,7 @@ def color(self):
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A named CSS color
Returns
-------
@@ -77,23 +41,14 @@ def color(self):
def color(self, val):
self["color"] = val

# family
# ------
@property
def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts if they aren't available on
the system. The Chart Studio Cloud (at https://chart-
studio.plotly.com or on-premise) generates images on a server,
where only a select number of fonts are installed and
supported. These include "Arial", "Balto", "Courier New",
"Droid Sans", "Droid Serif", "Droid Sans Mono", "Gravitas One",
"Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow",
"Raleway", "Times New Roman".
browser. The web browser can only apply a font if it is
available on the system where it runs. Provide multiple font
families, separated by commas, to indicate the order in which
to apply fonts if they aren't available.
The 'family' property is a string and must be specified as:
- A non-empty string
@@ -108,8 +63,6 @@ def family(self):
def family(self, val):
self["family"] = val

# lineposition
# ------------
@property
def lineposition(self):
"""
@@ -133,8 +86,6 @@ def lineposition(self):
def lineposition(self, val):
self["lineposition"] = val

# shadow
# ------
@property
def shadow(self):
"""
@@ -157,8 +108,6 @@ def shadow(self):
def shadow(self, val):
self["shadow"] = val

# size
# ----
@property
def size(self):
"""
@@ -175,8 +124,6 @@ def size(self):
def size(self, val):
self["size"] = val

# style
# -----
@property
def style(self):
"""
@@ -197,8 +144,6 @@ def style(self):
def style(self, val):
self["style"] = val

# textcase
# --------
@property
def textcase(self):
"""
@@ -220,8 +165,6 @@ def textcase(self):
def textcase(self, val):
self["textcase"] = val

# variant
# -------
@property
def variant(self):
"""
@@ -242,8 +185,6 @@ def variant(self):
def variant(self, val):
self["variant"] = val

# weight
# ------
@property
def weight(self):
"""
@@ -264,27 +205,18 @@ def weight(self):
def weight(self, val):
self["weight"] = val

# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
color
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The Chart
Studio Cloud (at https://chart-studio.plotly.com or on-
premise) generates images on a server, where only a
select number of fonts are installed and supported.
These include "Arial", "Balto", "Courier New", "Droid
Sans", "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT
Sans Narrow", "Raleway", "Times New Roman".
the web browser. The web browser can only apply a font
if it is available on the system where it runs. Provide
multiple font families, separated by commas, to
indicate the order in which to apply fonts if they
aren't available.
lineposition
Sets the kind of decoration line(s) with text, such as
an "under", "over" or "through" as well as combinations
@@ -312,15 +244,15 @@ def _prop_descriptions(self):
def __init__(
self,
arg=None,
color=None,
family=None,
lineposition=None,
shadow=None,
size=None,
style=None,
textcase=None,
variant=None,
weight=None,
color: str | None = None,
family: str | None = None,
lineposition: Any | None = None,
shadow: str | None = None,
size: int | float | None = None,
style: Any | None = None,
textcase: Any | None = None,
variant: Any | None = None,
weight: int | None = None,
**kwargs,
):
"""
@@ -338,18 +270,11 @@ def __init__(
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The Chart
Studio Cloud (at https://chart-studio.plotly.com or on-
premise) generates images on a server, where only a
select number of fonts are installed and supported.
These include "Arial", "Balto", "Courier New", "Droid
Sans", "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT
Sans Narrow", "Raleway", "Times New Roman".
the web browser. The web browser can only apply a font
if it is available on the system where it runs. Provide
multiple font families, separated by commas, to
indicate the order in which to apply fonts if they
aren't available.
lineposition
Sets the kind of decoration line(s) with text, such as
an "under", "over" or "through" as well as combinations
@@ -377,14 +302,11 @@ def __init__(
-------
Font
"""
super(Font, self).__init__("font")

super().__init__("font")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return

# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
@@ -399,54 +321,17 @@ def __init__(
an instance of :class:`plotly.graph_objs.bar.legendgrouptitle.Font`"""
)

# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)

# Populate data dict with properties
# ----------------------------------
_v = arg.pop("color", None)
_v = color if color is not None else _v
if _v is not None:
self["color"] = _v
_v = arg.pop("family", None)
_v = family if family is not None else _v
if _v is not None:
self["family"] = _v
_v = arg.pop("lineposition", None)
_v = lineposition if lineposition is not None else _v
if _v is not None:
self["lineposition"] = _v
_v = arg.pop("shadow", None)
_v = shadow if shadow is not None else _v
if _v is not None:
self["shadow"] = _v
_v = arg.pop("size", None)
_v = size if size is not None else _v
if _v is not None:
self["size"] = _v
_v = arg.pop("style", None)
_v = style if style is not None else _v
if _v is not None:
self["style"] = _v
_v = arg.pop("textcase", None)
_v = textcase if textcase is not None else _v
if _v is not None:
self["textcase"] = _v
_v = arg.pop("variant", None)
_v = variant if variant is not None else _v
if _v is not None:
self["variant"] = _v
_v = arg.pop("weight", None)
_v = weight if weight is not None else _v
if _v is not None:
self["weight"] = _v

# Process unknown kwargs
# ----------------------
self._init_provided("color", arg, color)
self._init_provided("family", arg, family)
self._init_provided("lineposition", arg, lineposition)
self._init_provided("shadow", arg, shadow)
self._init_provided("size", arg, size)
self._init_provided("style", arg, style)
self._init_provided("textcase", arg, textcase)
self._init_provided("variant", arg, variant)
self._init_provided("weight", arg, weight)
self._process_kwargs(**dict(arg, **kwargs))

# Reset skip_invalid
# ------------------
self._skip_invalid = False
18 changes: 4 additions & 14 deletions plotly/graph_objs/bar/marker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import sys
from typing import TYPE_CHECKING
from _plotly_utils.importers import relative_import

if sys.version_info < (3, 7) or TYPE_CHECKING:
from ._colorbar import ColorBar
from ._line import Line
from ._pattern import Pattern
from . import colorbar
else:
from _plotly_utils.importers import relative_import

__all__, __getattr__, __dir__ = relative_import(
__name__,
[".colorbar"],
["._colorbar.ColorBar", "._line.Line", "._pattern.Pattern"],
)
__all__, __getattr__, __dir__ = relative_import(
__name__, [".colorbar"], ["._colorbar.ColorBar", "._line.Line", "._pattern.Pattern"]
)
Loading