Conversation
|
Thanks, I certainly see the value of adding async status updates! I do wonder if we can adopt an approach that is consistent across Mosaic applications. It is a bit complicated because in some cases an interface component might consist of a single client while in other cases (as with a Plot with multiple marks) we're actually dealing with a group of clients. Perhaps we can add a stand-alone status handler as an API library element, and extend Plot to use that? Then other single- or multi-client components could use the same infrastructure for consistency. Happy to consider any thoughts on how to approach this is an elegant way. Meanwhile, this PR includes some other aspects that we might want to remove or handle separately, such as the changes involving directives and plot spec parsing. |
|
@spren9er do you want to revise this pull request? |
Why is this pull request necessary?
When using vgplot, there is currently no way to keep track of the status of a single plot (e.g. is plot refreshing or already done?).
Statuses could be helpful for showing a spinner, while data is updating (see example below).
In a component framework, it could make sense to work with a
Plotclass directly (one component renders a single plot). Also, in that way an already existing element (SVGSVGElementorHTMLDivElement) can be used, instead of a newly generated one ofvg.plot.What does this pull request cover?
This pull request adds more convenience methods for building and working with a
Plotinstance.Plotclassstatus: attribute (one ofidle,pendingQueryorpendingRender)connect: method for connecting allPlotmarks to coordinatoraddDirectives: method for adding directives toPlotaddEventListener: method for adding event listener forstatusvalueremoveEventListener: method for removing event listener forstatusvalueparsePlotSpectoparse-spec.jsfor creating aPlotinstance from JSON specificationHow to create a
Plotinstance?Create a
Plotinstance directly from classCreate a
Plotinstance from JSON specification viaparsePlotSpecThen, on an existing
Plotinstance, one can add an event listener for status updates.Finally, all marks need to be connected to Mosaic coordinator with
connectmethod.Breaking changes
None, as existing API has not changed.
Example: Rendering a dashboard with several Mosaic plots
When using several single vgplot plots in a dashboard, it is sometimes unclear which plots are still updating and which have already been re-rendered. A small example (more plots → more confusion):
mosaic-plot-observer-before-small.mov
Using status events of
Plot, we can indicate that a plot is outdated (here via spinner and transparency).mosaic-plot-observer-after-small.mov
Note about this pull request
This pull request was created, because of the specific need of embedding vgplot plots in a pure SVG dashboard application. Feel free to do whatever you like with it.
If
Plotclasses should not be used directly in above way or it is against vgplot philosophy, just ignore it.