Source code for meerkat.interactive.app.src.lib.component.plotly.line_3d

from typing import List, Union

from meerkat import env
from meerkat.dataframe import DataFrame
from meerkat.interactive.endpoint import Endpoint, EndpointProperty
from meerkat.tools.lazy_loader import LazyLoader
from meerkat.tools.utils import classproperty, requires

from ...abstract import Component

px = LazyLoader("plotly.express")


[docs]class Line3D(Component): df: DataFrame keyidxs: List[Union[str, int]] on_click: EndpointProperty = None selected: List[str] = [] on_select: Endpoint = None json_desc: str = ""
[docs] @requires("plotly.express") def __init__( self, df: DataFrame, *, x=None, y=None, z=None, color=None, on_click: EndpointProperty = None, selected: List[str] = [], on_select: Endpoint = None, **kwargs, ): """See https://plotly.com/python-api- reference/generated/plotly.express.line_3d.html for more details.""" if not env.is_package_installed("plotly"): raise ValueError( "Plotly components require plotly. Install with `pip install plotly`." ) if df.primary_key_name is None: raise ValueError("Dataframe must have a primary key") fig = px.line_3d(df.to_pandas(), x=x, y=y, z=z, color=color, **kwargs) super().__init__( df=df, keyidxs=df.primary_key.values.tolist(), on_click=on_click, selected=selected, on_select=on_select, json_desc=fig.to_json(), )
@classproperty def namespace(cls): return "plotly" def _get_ipython_height(self): return "800px"