-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add event lines to plots #18
Conversation
3248fa6
to
edf007d
Compare
edf007d
to
085db17
Compare
client: evolverClient, | ||
}); | ||
|
||
const events = await Evolver.history({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Promise.all to parralleize these two request.
const [historyData, eventsData] = Promise.allSettled([await Evolver.history({whatever}), await Evolver.history({whatever + kinds["event"]})])
<ReferenceLine | ||
key={event} | ||
x={event.timestamp} | ||
label={event.data.message} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label will take a component as prop, and daisyUI provides a tooltip: https://daisyui.com/components/tooltip/,
label = {() => {
return (
<div className="tooltip" data-tip={event.data.message}>
{event.data.message.length > 20 ? `${event.data.message.slice(0, 20)}...` : event.data.message}
</div>
)
}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool, but when I do this I don't see any text at all. I tried with plain div and span elements like this, doesn't seem to show. There may be some requirements it has on the underlying element...
// array of events. Here we drop name, probably change to backend could keep | ||
// the name in the struct | ||
const allEvents = flatMap(events); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, did you test this change with a chart that shows multiple vials' histories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the thing worked around here is that event will be tagged from a particular logger (main device, or controller), e.g.
{ "main_device": [...], "controller": [...]}
each may be tagged with vial (shown only for that plot) or not (global), but we need to bring all those named things into a single array. I think I might change backend shape since either you wan't it all where each element says where it came from, or you are selecting only one, where this structure is redundant 😄
@@ -57,6 +81,14 @@ export const HardwareLineChart = ({ vials, rawData, property = "raw" }) => { | |||
connectNulls={true} | |||
/> | |||
))} | |||
{eventData.map((event) => ( | |||
<ReferenceLine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Made updates and re-requesting review. To do the label thing well looks to require more effort, so I think what we can do is merge this in (if otherwise good) and make label change as an enhancement (it affects only a single line in this PR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
thanks! |
Adds lines to plotter for events.
Notes:
{'name': [{...}], 'name2': [{...}]}
, might want to change backend to[{'name': 'name', ...}, {'name': 'name2', ...}]
. This would replace the awkwardness of theflatmap
currently done on events, and also preserve the name in each record. can do in separate change with backendExample SS: