-
Notifications
You must be signed in to change notification settings - Fork 915
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
Dynamically update vega spec to show VisLayer
s
#3145
Dynamically update vega spec to show VisLayer
s
#3145
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## feature/feature-anywhere #3145 +/- ##
============================================================
- Coverage 66.47% 66.45% -0.02%
============================================================
Files 3222 3225 +3
Lines 61818 61980 +162
Branches 9529 9542 +13
============================================================
+ Hits 41092 41189 +97
- Misses 18445 18499 +54
- Partials 2281 2292 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 10 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
VisLayer
sVisLayer
s
Any reason why this should not show up in the changelog? |
It's going to a feature branch, and will be added as one item in the changelog when merged to |
The feature branches on this repo are held to the same high standards as the main branch; we enforce PRs and all the checks on them. |
I was told the changelog checks can be ignored since it won't make logical sense to add them here and would cause conflicts when eventually merging to the respective branches, and that they will be added when finally merging later on. cc @joshuarrrr |
Coming from #3106 (comment), we may be able to refactor some/all of the config into When we are able to rebase this, I'll look into how that may look. |
97cdb6c
to
258ca8a
Compare
258ca8a
to
252d73d
Compare
282a326
to
fe07f04
Compare
fb304f0
to
cd553e5
Compare
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.
Really good PR @ohltyler. The detailed PR description with context was really helpful in reviewing this. Most of my comments are nits which you can choose to make or not. The only real blocker for me was the showEvents
flag. Its concerning because it in the Vega view itself when its usefulness seems to be limited to time series charts and even in there its applicable only to the event chart that you are augmenting. Can we either find a way to avoid that? or if not at least make it more general purpose?
// Ref: https://vega.github.io/vega-lite/docs/size.html#limitations | ||
updateBaseVisHeight(view) { | ||
// 100 is enough padding for now. May need to adjust once the current scrolling/overflow | ||
// issue is handled. See https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3501 |
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.
nit: can you add a TODO:
here so that its easy to identify in future?
// Ref: https://vega.github.io/vega-lite/docs/size.html#limitations | ||
updateBaseVisHeight(view) { | ||
// 100 is enough padding for now. May need to adjust once the current scrolling/overflow | ||
// issue is handled. See https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3501 |
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.
Also a little more context about this would help. I know you mention in the PR description that this is to fit the events vis, but how does that scale for other plugins that may want to augment the data? what if the chart isnt a time series chart? If i were someone who wanted to augment the data on a pie chart or heat map chart and ran into a similar limitation there, would this be useful for me? or can this be modified to support a more general usecase?
Currently I chose the name |
e1d8757
to
b374d01
Compare
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.
@ohltyler This looks great! A couple minor comments and questions.
src/plugins/vis_type_vega/public/expressions/line_vega_spec_fn.ts
Outdated
Show resolved
Hide resolved
@ashwin-pc I've updated This should make it a bit more clear and intentional |
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
4fa4d70
to
3f4e1e1
Compare
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.
Thanks @ohltyler. i like this implimentation better with the additional showEvents
flag. We can generalize in future when we have other layer types that we support, but for now this works fine :)
Thanks @ohltyler for the refactoring - in particular, the tests are much more readable now. I'm still curious to see if we can get most of the automation passing, so I'll keep an eye on it - regardless I'll aim to merge by EOD. |
Signed-off-by: Tyler Ohlsen [email protected]
Description
This PR adds the logic in the expressions fn to process any existing
VisLayer
s and augment the vega spec as needed. This is done through 2 helper fns which are added inline_vega_spec_fn
:addPointInTimeEventsLayersToTable()
: dynamically updating the source datatable with additional column(s) and data representing a particularPointInTimeEventsLayer
addPointInTimeEventsLayersToSpec()
: dynamically update the vega spec by: (1) adding arule
layer to be visible when hovering over an annotation , (2) addingcircle
layers for eachPointInTimeEventsLayer
, and (3) adding parameters to handle user interaction, including expanding the circle size and making the correspondingrule
visible on the chart.Refactoring changes
The existing functions that were in
line_vega_spec_fn
have moved toexpressions/helpers
. This is to clean up the function file itself, and to be consistent with the helper functions that are now also being imported fromvis_augmenter
. The functions themselves are the same except for a minor change tocreateSpecFromDatatable()
to omit adding layers for columns that areVisLayer
s, since that will now be handled by the newaddPointInTimeEventsLayersToSpec()
fn mentioned above.A note on manual creation of empty buckets
By default, the queries being made to fetch the source visualization data do not include extra parameters like
extended_bounds
orhard_bounds
to return empty buckets. Instead, only buckets with results are returned. The currentvislib
library has standalone logic for extending the chart bounds to match the min/max time range as the given context (the dashboards time range, or vis time range if in edit view). To overlay events on a visualization, we may need to populate time buckets that were previously not included in the source table. Consider the following: given a 30 day time range with 1 day time buckets, and no vis data is present from days 0-5, but there was an event on day 2. In this case, we need to create and populate a bucket for day 2, and add the event there. Currently there is no easy way to inject logic in the source queries to include empty buckets via extra*_bounds
params. For example,extended_bounds
does not filter, and would require the histogram agg to be nested within a filter time range. Also, fordate_histogram
, it is not even offered as a setting via the vis editor - onlyhistogram
offers forextended_bounds
and that is all. So, rather than trying to complicate the underlying queries to accommodateVisLayer
events by covering all scenarios for how to add any extra parameters to the histogram query parameters, we can post-process the source datatable by manually adding rows if there are any missing. Given the interval and min/max bounds, this is not too difficult. It also guarantees that we are matching the same chart bounds that would be achieved by the vislib library.A note on tooltips
Custom tooltips, including how to potentially add icons / other
VisLayer
metadata, will be added as part of #3317. This PR doesn't add any configuration for tooltips on theVisLayer
event datapoints.A note on chart autosizing
Vega-lite has a known limitation where concatenated views cannot use the default
fit
autosize configuration to make the height/width fill in the available space in the parent container. Because of the way we augment the spec withVisLayer
data viavconcat
to have multiple views (one for the base vis and one for the event vis), we need to implement a workaround to still autosize correctly. This is done by adding the following:showEvents
field in theVegaParser
to determine when we want to render this special version of a vega chartfit-x
to automatically determine the width (this works because we are doingvconcat
instead of a horizontal-concatenatedhconcat
spec)updateBaseVisHeight()
to augment the compiled vega spec's signal on the base vis height, and manually set it as a function of the container height. So, whenever the container dimensions change, this will be triggered, and a new height will be determined for the base vis chart. Note we hardcode the event vis height since we have control of the data within it, so we don't need to have any auto-size logic for that chart.For more details on how these layers and interactions will look, see the mockups in #2880
Issues Resolved
Closes #3130
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr