render_keplergl
render_keplergl class
Reactively render a kepler.gl map.
Usage Source
render_keplergl(
_fn: Optional[ValueFn[ValueT]] = None,
*,
width: Optional[str] = None,
height: Optional[str] = None,
fill: Optional[bool] = None,
fillable: Optional[bool] = None,
rate_policy: Optional[RatePolicy] = None,
rate_delay: Optional[float] = None,
)@render_keplergl is a decorator that creates a render function – a function that returns the map (or its data) to display and re-runs when the reactive values it reads change:
import pandas as pd
from shinywidgets import render_keplergl
cities = pd.DataFrame(
{"lat": [37.77, 40.71], "lon": [-122.42, -74.01], "city": ["SF", "NYC"]}
)
@render_keplergl
def map():
return citiesThe render function may return either a pandas.DataFrame or geopandas.GeoDataFrame (which is coerced to a keplergl.KeplerGl widget with the data added as a single dataset named "data", the dataId to use in a kepler.gl config; requires pip install 'shinywidgets[keplergl]') or a keplergl.KeplerGl widget. In a filling layout, the map is resized to fit its container, unless the KeplerGl widget was given a height other than kepler.gl’s default (400). An explicit height on the output (see height below) takes precedence over the widget’s own. While the output sizes the map, the browser sets the widget’s height to the size it measures, so change the output’s size rather than setting the widget’s height from Python.
Note
Accessing the rendered widget: the render function gains two read-only attributes: .value, the value it most recently returned, and .widget, the rendered KeplerGl instance. Map configuration can also be read reactively with .read("some_trait") (a shortcut for reactive_read() on .widget).
Responding to user interaction: there are no accessors on this renderer; read the map’s configuration traits with .read().
Mutating the widget: use .widget to update the rendered map in place; trait changes on the widget are synced to the browser. The output sizes the map itself, so change the output’s size rather than setting the widget’s height from Python.
Parameters
width : Optional[str] = None-
A CSS length unit (e.g.,
"400px"or"100%") for the output’s width. height : Optional[str] = None-
A CSS length unit for the output’s height. When
None(the default), the output is designed to fill the height of its parent container (seefillandfillable). fill : Optional[bool] = None-
Whether the output should grow or shrink to fit its parent container. When
None(the default), this isTrueifheightis not specified. fillable : Optional[bool] = None-
Whether the output container should fill available space (scrolling its contents on overflow). When
None(the default), this isTrueifheightis not specified.
See also
output_widget(): in Shiny Core, the UI needs this to hold the output (Shiny Express displays it where the render function is defined).