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

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 LineMapbox(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, *, lat=None, lon=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_mapbox.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_mapbox( df.to_pandas(), lat=lat, lon=lon, 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"