Panel streamz pane customization

From Streamz docs " The Streamz pane uses the default panel resolution to figure out the appropriate way to render the object returned by a Stream".

Lets say the Stream returns JSON object, then the Streamz pane will render JSON, I would like to be able to pass options to the JSON pane. Is there a way to do that?

1 Like

Hi @abdamj

If the options are fixed you can just provide them to the Streamz pane I believe.

If not you can return the specific Panel you want instantiated with the parameters you want.

For example

import json
from numpy import random
import panel as pn
from streamz import Stream
from datetime import datetime

stream = Stream()

value = 0
obj = {}


def update(obj):
    return pn.pane.JSON(
        json.dumps(obj), name="JSON", depth=2, sizing_mode="stretch_width",
    )

streamz_pane = pn.pane.Streamz(stream.map(update), always_watch=True, width=500)
stream.emit(obj)

def emit():
    global value
    value += 1
    global obj
    obj[str(datetime.utcnow())] = random.random()
    stream.emit(obj)


pn.state.add_periodic_callback(emit, period=250, count=50)

streamz_pane.servable()

which looks like

1 Like

@abdamj. Checkout this example also Streaming example. I was quite surprised how easy it was to create.

1 Like

thanks a lot for the pointers, i was able to solve the issue :slight_smile:

1 Like