Compute default values for all attributes not specified in the input figure and returns the output as a "full" figure. This function calls Plotly.js via Kaleido to populate unspecified attributes. This function is intended for interactive use during development to learn more about h
(
fig: Union[dict, plotly.graph_objects.Figure],
warn: bool = True,
as_dict: bool = False,
)
| 725 | |
| 726 | |
| 727 | def full_figure_for_development( |
| 728 | fig: Union[dict, plotly.graph_objects.Figure], |
| 729 | warn: bool = True, |
| 730 | as_dict: bool = False, |
| 731 | ) -> Union[plotly.graph_objects.Figure, dict]: |
| 732 | """ |
| 733 | Compute default values for all attributes not specified in the input figure and |
| 734 | returns the output as a "full" figure. This function calls Plotly.js via Kaleido |
| 735 | to populate unspecified attributes. This function is intended for interactive use |
| 736 | during development to learn more about how Plotly.js computes default values and is |
| 737 | not generally necessary or recommended for production use. |
| 738 | |
| 739 | Parameters |
| 740 | ---------- |
| 741 | fig: |
| 742 | Figure object or dict representing a figure |
| 743 | |
| 744 | warn: bool |
| 745 | If False, suppress warnings about not using this in production. |
| 746 | |
| 747 | as_dict: bool |
| 748 | If True, output is a dict with some keys that go.Figure can't parse. |
| 749 | If False, output is a go.Figure with unparseable keys skipped. |
| 750 | |
| 751 | Returns |
| 752 | ------- |
| 753 | plotly.graph_objects.Figure or dict |
| 754 | The full figure |
| 755 | """ |
| 756 | |
| 757 | # Raise informative error message if Kaleido is not installed |
| 758 | if not kaleido_available(): |
| 759 | raise ValueError( |
| 760 | """ |
| 761 | Full figure generation requires the Kaleido package, |
| 762 | which can be installed using pip: |
| 763 | |
| 764 | $ pip install --upgrade kaleido |
| 765 | """ |
| 766 | ) |
| 767 | |
| 768 | if warn: |
| 769 | warnings.warn( |
| 770 | "full_figure_for_development is not recommended or necessary for " |
| 771 | "production use in most circumstances. \n" |
| 772 | "To suppress this warning, set warn=False" |
| 773 | ) |
| 774 | |
| 775 | if kaleido_available() and kaleido_major() > 0: |
| 776 | # Kaleido v1 |
| 777 | bytes = kaleido.calc_fig_sync( |
| 778 | fig, |
| 779 | opts=dict(format="json"), |
| 780 | ) |
| 781 | fig = json.loads(bytes.decode("utf-8")) |
| 782 | else: |
| 783 | # Kaleido v0 |
| 784 | if ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS: |
nothing calls this directly
no test coverage detected