Event handling for line graphs #1355
Unanswered
akumari1812
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Sure # Plot / Events
# Handle #events on a #plot card.
# ---
from h2o_wave import main, app, Q, ui, data
@app('/demo')
async def serve(q: Q):
if not q.client.initialized:
q.client.initialized = True
q.page['pricing'] = ui.plot_card(
box='1 1 4 5',
title='Interval',
data=data(fields='product price', rows=[
['spam', 1.49],
['eggs', 2.49],
['ham', 1.99],
], pack=True),
plot=ui.plot([ui.mark(type='line', x='=product', y='=price', y_min=0)]),
events=['select_marks']
)
q.page['details'] = ui.markdown_card(
box='1 6 4 2',
title='Selected Product',
content='Nothing selected.',
)
else:
if q.events.pricing:
q.page['details'].content = f'You selected {q.events.pricing.select_marks}'
await q.page.save() Note that clicking the line returns whole line data, we are thinking about changing that though - #1331 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can we create events for line graphs?
Beta Was this translation helpful? Give feedback.
All reactions