Add config to rx.plotly component (#2745)
This commit is contained in:
parent
2062c1dd05
commit
842c7e6882
@ -32,6 +32,9 @@ class Plotly(PlotlyLib):
|
||||
# The layout of the graph.
|
||||
layout: Var[Dict]
|
||||
|
||||
# The config of the graph.
|
||||
config: Var[Dict]
|
||||
|
||||
# The width of the graph.
|
||||
width: Var[str]
|
||||
|
||||
|
@ -103,6 +103,7 @@ class Plotly(PlotlyLib):
|
||||
*children,
|
||||
data: Optional[Union[Var[Figure], Figure]] = None, # type: ignore
|
||||
layout: Optional[Union[Var[Dict], Dict]] = None,
|
||||
config: Optional[Union[Var[Dict], Dict]] = None,
|
||||
width: Optional[Union[Var[str], str]] = None,
|
||||
height: Optional[Union[Var[str], str]] = None,
|
||||
use_resize_handler: Optional[Union[Var[bool], bool]] = None,
|
||||
@ -165,6 +166,7 @@ class Plotly(PlotlyLib):
|
||||
*children: The children of the component.
|
||||
data: The figure to display. This can be a plotly figure or a plotly data json.
|
||||
layout: The layout of the graph.
|
||||
config: The config of the graph.
|
||||
width: The width of the graph.
|
||||
height: The height of the graph.
|
||||
use_resize_handler: If true, the graph will resize when the window is resized.
|
||||
|
@ -1,5 +1,6 @@
|
||||
import numpy as np
|
||||
import plotly.graph_objects as go
|
||||
import reflex as rx
|
||||
import pytest
|
||||
|
||||
from reflex.utils.serializers import serialize, serialize_figure
|
||||
@ -31,3 +32,14 @@ def test_serialize_plotly(plotly_fig: go.Figure):
|
||||
value = serialize(plotly_fig)
|
||||
assert isinstance(value, list)
|
||||
assert value == serialize_figure(plotly_fig)
|
||||
|
||||
|
||||
def test_plotly_config_option(plotly_fig: go.Figure):
|
||||
"""Test that the plotly component can be created with a config option.
|
||||
|
||||
Args:
|
||||
plotly_fig: The figure to display.
|
||||
"""
|
||||
|
||||
# This tests just confirm that the component can be created with a config option.
|
||||
_ = rx.plotly(data=plotly_fig, config={"showLink": True})
|
Loading…
Reference in New Issue
Block a user