abdamj
November 10, 2020, 9:09am
1
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
Marc
November 10, 2020, 6:51pm
2
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
Marc
November 10, 2020, 7:59pm
3
@abdamj . Checkout this example also Streaming example . I was quite surprised how easy it was to create.
1 Like
abdamj
November 12, 2020, 2:41pm
4
thanks a lot for the pointers, i was able to solve the issue
1 Like