Setting Dashboard Variables on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.Dashboard variables can be filled on the server before rendering, through the
Set variable values in the event.
How it works. Values chosen on the server are injected into the dashboard before rendering, so the client shows data it never had to supply.
onPrepareVariables event.Set variable values in the event.
def prepareVariables(args: StiVariablesEventArgs):
if len(args.variables) > 0:
args.variables['Patient'].value = 'Mary Roe'
args.variables['Observation'].value = datetime(2024, 3, 1)
args.variables['Visits'].value = 5
viewer.onPrepareVariables += prepareVariablesonPrepareVariables— receives the dashboard's variables before rendering; assign each by name.- Value types must match the template (str, int,
datetime, …).
How it works. Values chosen on the server are injected into the dashboard before rendering, so the client shows data it never had to supply.