Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Plot
class directly (one component renders a single plot). Also, in that way an already existing element (SVGSVGElement
orHTMLDivElement
) 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
Plot
instance.Plot
classstatus
: attribute (one ofidle
,pendingQuery
orpendingRender
)connect
: method for connecting allPlot
marks to coordinatoraddDirectives
: method for adding directives toPlot
addEventListener
: method for adding event listener forstatus
valueremoveEventListener
: method for removing event listener forstatus
valueparsePlotSpec
toparse-spec.js
for creating aPlot
instance from JSON specificationHow to create a
Plot
instance?Create a
Plot
instance directly from classCreate a
Plot
instance from JSON specification viaparsePlotSpec
Then, on an existing
Plot
instance, one can add an event listener for status updates.Finally, all marks need to be connected to Mosaic coordinator with
connect
method.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
Plot
classes should not be used directly in above way or it is against vgplot philosophy, just ignore it.