-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I'm currently streaming data from the tornado backend to a couple of perspective widgets in a html file (thank you for the plentiful examples!) one of which is a rolling time series scatter plot with multiple series. Currently, I believe, the mapping of colours/markers in the X/Y scatter plot is basically just the enumeration of whatever data exists in the table at a given time. This is causing my series to change colour/marker if one of the columns in the table is all null for some period of time. Is it possible to declare these styling attributes via some other config?
I wonder if it is within scope for perspective to allow configuring the plots from table values (for example like holoviews does - https://holoviews.org/user_guide/Style_Mapping.html)?
An example (the labels of L2 and L3 will flicker between orange and green depending on what is present in the data):
Set x-axis = timestamp, y-axis=value
import asyncio
import perspective
import random
import datetime
async def update(table):
while True:
now = datetime.datetime.now()
data = [{"value": 1, "label": "L1", "timestamp": now}]
for label in ("L1", "L2", "L3"):
val = random.random()
if val > 0.9:
data.append({"value": val, "label": label, "timestamp": now})
table.update(data)
await asyncio.sleep(0.1)
schema = {
"timestamp": datetime.datetime,
'value': float,
'label': str,
}
table = perspective.Table(schema, limit=10)
widget = perspective.PerspectiveWidget(table, column_pivots=['label'], plugin="X/Y Scatter")
asyncio.get_event_loop().create_task(update(table))
widget # show