Skip to main content
This is a display-only control. Users cannot interact with the chart data.
This control is experimental and may have unexpected behavior.
Plotly()

Example

This example creates a bar chart from a dataset and displays it using the Plotly control.
from mirmod.controls import Plotly
from mirmod import miranda
import json 
import plotly.express as px

@wob.init()
def init(self):
	self.df = None

@wob.receiver("data", "Dataset")
def set_dataset(self, i):
	self.df = i

@wob.receiver("state", "plotly", control=Plotly(), hidden=True, connectable=False)
def get_plotly(self, plotly_data):
	pass

@wob.execute()
def execute(self):
	# Create a Plotly figure
	fig = px.bar(self.df)
	fig_json = fig.to_json()

	# Get execution context
	ecx = miranda.get_execution_context()
	ob = ecx.get_current_wob()
	sc = ecx.get_security_context()

	# Update the control with the chart data
	miranda.update_api(
		sc, ob,
		"RECEIVER", "plotly", "state",
		value=fig_json,
		connectable=False,
		hidden=True
	)
	
	# Notify the GUI to refresh the display
	miranda.notify_gui(sc, json.dumps({
		"action": "update[VIEW]",
		"data": { "id": ob.id, "metadata_id": ob.metadata_id }
	}))

Parameters

This control has no configurable parameters. Chart configuration is handled through the Plotly figure object itself.