-
Notifications
You must be signed in to change notification settings - Fork 2
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
Improve whitespace for small multiples #575
Conversation
Preview link ready! Built with commit 8ce7bc3 https://deploy-preview-575--cmu-delphi-covidcast.netlify.app |
can you do me a favor and add screenshots or for an interactive change a screencast such that it is easier to see what has changed? |
Also added to #569: |
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.
I'm getting a bunch of warnings in the console now:
WARN Height "container" only works well with autosize "fit" or "fit-y".
can you take a look what is going on?
Well, the change depends on disabling autosize: 'fit', the default, so I
guess we have to change the height: 'container' to something else. Or
maybe is there another way to avoid getting the warnings?
…On Mon, Oct 19, 2020 at 9:01 AM Samuel Gratzl ***@***.***> wrote:
***@***.**** commented on this pull request.
I'm getting a bunch of warnings in the console now:
WARN Height "container" only works well with autosize "fit" or "fit-y".
can you take a look what is going on?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#575 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAELGDKTZVO7QH7PAWQ6EQTSLQ2ELANCNFSM4ST7WCLQ>
.
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
dlaliberte@Google.com <dlaliberte@google.com> Cambridge MA
|
…ng.right, to avoid clipping.
src/modes/overview/vegaSpec.js
Outdated
width: 'container', | ||
height: 'container', | ||
padding: 0, | ||
width: '378', |
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.
it is difficult to specify a precise number, since you don't know how wide the side panel is in every case, since it depends on the screen resolution. Especially on mobile the size is very different. You could use a similar thing patchSpec
as in the detail view, which allow you to specify the width / height based on the container width.
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.
Yes, I didn't like specifying precise numbers, but I just wanted to make it work at first. I'm not sure I like the patchSpec approach either, since it is kind of convoluted, and it requires a different call for each use. It would be better if we could calculate it in a general way from the actual container size, however that is determined. I'll see what I can do.
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.
I'm stuck. I suspect the warning when using 'container' with autosize: 'none' is superfluous, or at least in our case. autosize: 'none' does the right thing regarding padding, and no other mode does that, as far as I can tell. Also, width and height set to 'container' does the right thing regarding determining the correct container size, and nothing else does that. So we need both together.
I don't know if we care about auto sizing based on a change of the container size, if we can handle that another way. If we can do that, then it would make most sense to disable the warning. I don't see any way to do that in the vega-lite code. This 'container' feature is new from about a year ago, so perhaps they haven't worked out all the bugs. I can follow up with the vega-lite people to see what they think.
Catching the log.warn and throwing it away would be one possible workaround.
Alternatively, determining the container width and height ourselves, and passing that in via something like patchSpec could work, but I haven't been able to figure out how to make that happen. The patching has to be done differently from the DetailView case, of course, since the small multiples don't use vconcat, and it doesn't seem to work correctly if I wrap the current spec with a single vconcat so that patch could add another with size constraint. But moreover, the spec itself isn't passed in to the Vega component the same way as for the DetailView, and I can't tell how to make it work given my limited knowledge of svelte. Maybe you could get this working much more quickly than all my thrashing about.
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.
Another alternative to consider is to merge all these small multiples into one chart, using vconcat. That is a substantial change, but I think I could handle the vega part of it.
We could save some vertical space by eliminating all but one of the domain axes, since they are now all the same, and we have the parallel selection across all of the charts.
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.
I added a comment to the vega-lite change that added the log warning. See vega/vega-lite#5441
Dominik replied, supporting my suggestion, and I would guess we should be able get this fixed at some point in vega-lite.
Meanwhile, I am wondering if we could recompute the width and height using a signals. See https://observablehq.com/@dlaliberte/vega-top-level-width-height-padding-autosize-options Looks like it should work at last for Vega, and I believe Vega-Lite works the same. I'll investigate.
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.
Using signals via the vega-embed patch appears to be working, at least partly. I have to add separate signals for both width and height, and separate signals for both resize and load (without the load event, the initial size will be whatever the default value is). When Switching to compare mode, the initial display of the small multiples is the wrong size, and this happens even though I am trying to use the observeResize to dispatch a window resize, in order to trigger the update of the vega chart size(s). I'll futz with this some more to try to get it to behave, but maybe we need some more explicit resize triggers when we know there are events that need to update the charts.
By the way, the map is also not being updated based on the dispatched resizes. Manually resizing the window does produce the desired effect (updating everything) so this is suspicious.
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.
Adding the following in Vega.svelte:
afterUpdate(() => {
if (!patchSpec) {
window.dispatchEvent(new Event('resize'));
}
});
I am able to get the small multiples to behave correctly on the Map Overview page, also when in Compare mode, and when resized for mobile devices or during any resizing events, without affecting the DetailView. However, then I learned that the overview/vegaSpec.js is also used by the top 10 and Region Details pages, which rely on different container sizes. Fortunately, by adding the resize signals for the height as well as width, all views appear to work correctly, except for one: When combining the DetailView with compare mode, then the DetailView chart overflows its container. I suspect the resize events are triggering the patchSpec call to detect the wrong width at that time, before some other adjustment takes place.
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.
From reply to email from netlify:
Replacing the dispatch resize event with your suggested vega.view.resize().runAsync() results in a very messed up display: empty map, and it fails after trying to draw the first small multiple.
By the way, the DetailView sizing problem also occurs even without going into "compare mode", as soon as a small multiple tooltip is shown.
I'm not seeing any performance problem with the multiple resize dispatches, so I suspect the resize events are debounced, and maybe vega is detecting that there is no size change. However, I am seeing an afterUpdate call for each chart just due to showing a tooltip in any one of the charts. That explains the DetailView sizing problem showing up after showing a tooltip.
So I am inclined to think that the DetailView could be fixed to avoid this problem. I'd rather avoid doing the patchSpec call at all, if we can properly detect the container size, while also avoiding use of the arbitrary offsets to "correct" the sizing. I'll look into that.
On Mon, Oct 26, 2020 at 8:28 AM Samuel Gratzl notifications@github.com wrote:
@sgratzl commented on this pull request.
In src/components/Vega.svelte:
@@ -209,6 +237,12 @@
}
});
- afterUpdate(() => {
- if (!patchSpec) {
is there a difference to triggering vega.view.resize().runAsync()? cause in this in case of the small multiples N events are triggered
@@ -147,6 +145,17 @@ export function createSpec(sensor, primaryValue, selections, initialSelection) { | |||
}, | |||
encoding: { | |||
color: colorEncoding(selections), | |||
x: { |
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.
what is the difference to xDateRangeEncoding
? at a first glance, I cannot spot it
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're right. It evolved over several steps, so I'll make it the same here.
But for the next layer, tickCount is 'day', and the whole axis property is repeated as a consequence. Maye I can just use axis: {...(xDateRangeEncoding.axis), tickCount: 'day'}. I'll try it.
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.
Hang on... this change of Detailview/vegaSpec.js is supposed to be part of a different changeset: #574
Don't know how they got mixed up but maybe I forgot to switch branches. Sigh. Now I have to figure out how to uncommit this part, and/or unpush it, or whatever.
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.
This merge of branch 'dev' into dlaliberte/#563 appears to be the reason why my changes to DetailView/vegaSpec.js are part of this change. How do I undo that?
there is no easy option, the simple option is when it happens that you say in the summary of the PR that it is based on another one. and then we have to make sure that the other one is merged first
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.
Apparently I did this before as well, since you noted in a comment that my change included another one. So I am doing something wrong, but I don't know what I did in order to avoid doing it again. For this change, I am going to start over with another branch, and avoid "synching" until I am forced to.
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.
This merge of branch 'dev' into dlaliberte/#563 appears to be the reason why my changes to DetailView/vegaSpec.js are part of this change. How do I undo that?
src/components/Vega.svelte
Outdated
@@ -209,6 +237,12 @@ | |||
} | |||
}); | |||
|
|||
afterUpdate(() => { | |||
if (!patchSpec) { |
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.
is there a difference to triggering vega.view.resize().runAsync()
? cause in this in case of the small multiples N events are triggered
Replacing the dispatch resize event with your suggested
vega.view.resize().runAsync() results in a very messed up display: empty
map, and it fails after trying to draw the first small multiple.
By the way, the DetailView sizing problem also occurs even without going
into "compare mode", as soon as a small multiple tooltip is shown.
I'm not seeing any performance problem with the multiple resize dispatches,
so I suspect the resize events are debounced, and maybe vega is detecting
that there is no size change. However, I am seeing an afterUpdate call
for each chart just due to showing a tooltip in any one of the charts.
That explains the DetailView sizing problem showing up after showing a
tooltip.
So I am inclined to think that the DetailView could be fixed to avoid this
problem. I'd rather avoid doing the patchSpec call at all, if we can
properly detect the container size, while also avoiding use of the
arbitrary offsets to "correct" the sizing. I'll look into that.
…On Mon, Oct 26, 2020 at 8:28 AM Samuel Gratzl ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/components/Vega.svelte
<#575 (comment)>
:
> @@ -209,6 +237,12 @@
}
});
+ afterUpdate(() => {
+ if (!patchSpec) {
is there a difference to triggering vega.view.resize().runAsync()? cause
in this in case of the small multiples N events are triggered
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#575 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAELGDPXWX46JM4AYCQT2ZTSMVTO3ANCNFSM4ST7WCLQ>
.
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
dlaliberte@Google.com <dlaliberte@google.com> Cambridge MA
|
I believe everything is working as it should now, at least for this change. There is severe lag when hovering over the small multiples, however, even though I believe this version should be disabling the 'nearest' mode. Maybe the excess resize events are causing problems, though I wasn't seeing this lag earlier. But #588 works fast and smooth, so we should merge that in first, and then check out this change again after that. |
Seems very responsive now. The main trick was to debounce the dispatch of resize events, so that while moving the mouse over a small multiple, drawing tooltips many times, only one set of resize events is dispatched when you stop moving. Occasionally, the small multiple gets initially displayed with the wrong size, but it quickly updates. |
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.
👍
closes #569
Prerequisites:
dev
branchdev
Summary
Turn off the autosize mode for the small multiples so we can give them all the same padding.