class documentation

class PlotlyView(View): (source)

Constructor: PlotlyView(**kwargs)

View In Hierarchy

Displays a Plotly chart.

All event handlers have the following default params:

  • id: the corresponding data.ids[idx]
  • path: the path of the property
  • relative_path: the relative path of the property
  • schema: the schema of the property
  • view: the value of the PlotlyView
  • event: the event name (eg. onClick, onSelected, onDoubleClick)
  • value: the value of the clicked point (only pie chart-like plots)
  • label: the label of the clicked point (only pie chart-like plots)
  • shift_pressed: whether the shift key was pressed

Examples:

def render(self, ctx):
    panel.plot("my_plot", on_click=self.on_click, on_selected=self.on_selected)

def print_params(self, ctx, params):
    for key, value in params.items():
        ctx.print(f"{key}: {value}")

def on_click(self, ctx):
    # available params
    self.print_prams(ctx, {
        "id": "id", # the corresponding data.ids[idx]
        "idx": 1, # the index of the clicked point
        "label": "label", # label (eg. on pie charts)
        "shift_pressed": false, # whether the shift key was pressed
        "trace": "my_trace", # data[trace_idx].name
        "trace_idx": 0,
        "value": "my_value", # data[trace_idx].values[idx] (eg. on a pie chart)
        "x": 2, # data[trace_idx].x[idx] (the x value on most plot types)
        "y": 3, # data[trace_idx].y[idx] (the y value on most plot types)
        "z": 4, # data[trace_idx].z[idx] (the z value on 3d plots eg. heatmap)
    })

def on_selected(self, ctx):
    prin(ctx.params['data'])
    # [
    #     {
    #       "trace": "trace 0", # data[trace_idx].name
    #       "trace_idx": 0, # the index of the trace
    #       "idx": 1, # the index of the selected point
    #       "id": "one", # the corresponding data.ids[idx]
    #       "x": 2, # the x value of the selected point
    #       "y": 15, # the y value of the selected point
    #       "z": 22 # the z value of the selected point
    #     }
    # ]
Parameters
datathe chart data
configthe chart config
layoutthe chart layout
on_clickevent handler for click events
on_selectedevent handler for selected events
on_double_clickevent handler for double click events
Method __init__ Undocumented
Method to_json Undocumented
Instance Variable config Undocumented
Instance Variable data Undocumented
Instance Variable layout Undocumented

Inherited from View:

Method clone Undocumented
Method kwargs_to_json Undocumented
Instance Variable caption Undocumented
Instance Variable component Undocumented
Instance Variable componentsProps Undocumented
Instance Variable container Undocumented
Instance Variable description Undocumented
Instance Variable label Undocumented
Instance Variable placeholder Undocumented
Instance Variable read_only Undocumented
Instance Variable space Undocumented
Instance Variable _kwargs Undocumented
def __init__(self, **kwargs): (source)
def to_json(self): (source)

Undocumented

Undocumented

Undocumented

Undocumented