-
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
Continuous overlay range #16
Conversation
…inuous-overlay-range
Following your request, I made a PR at web-monorepo, @bobular |
Hi @bobular I have updated this PR based on our discussions and your suggestions at VEuPathDB/web-components#454. |
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'll need to do some more testing tomorrow (and we should probably have some unit tests for complex functions like this) but can't we also get rid of this line
? defaults.displayRangeMin != null && defaults.displayRangeMax != null
and the whole block here?
: { | |
min: logScale | |
? (observedMinPos as number) | |
: (min([ | |
isNonZeroBaseline ? undefined : 0, | |
defaults.rangeMin, | |
observedMin as number, | |
]) as number), | |
max: max([defaults.rangeMax, observedMax]) as number, |
If displayRangeMin/Max
are undefined, they should be fine in the lodash min/max.
There's just one defaults.displayRangeMin <= 0
to take care of.
// add zero as an origin | ||
0, | ||
: (min([ | ||
isNonZeroBaseline ? undefined : 0, |
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
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.
maybe also leave a comment saying that lodash.min is being used because it is tolerant of undefined values
@bobular Thank you for your comments! 👍 I think that you are right. Perhaps that part, |
@bobular I have tried your suggestions and didn't notice specific issue. So, a commit is made to remove that part & add a comment concerning lodash.min/.max |
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 is looking great. Nearly there!
We just need to tweak the drawing of the legend gradient bar.
In the following GEMS1 screenshot, you can see that the two "Weight-for-length or -height z-score *" variables are basically the same thing:
This is useful, and it means we can basically overlay with the same variable as one of the main axes:
What this shows is that the zero values are being correctly coloured in the neutral "white" colour. This is because the code is correctly normalising between +/- maxAbs
// L2366 (!) of ScatterplotVisualization.tsx
const normalize = scaleLinear();
// ...
normalize.domain([-maxAbsOverlay, maxAbsOverlay]).range([-1, 1]);
However, the legend needs to be drawn so that the zero values are also white(ish).
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 noticed a type
} else if (gradientColorscaleType === 'sequntial reverse') {
This would be avoided by typing gradientColorscaleType
with the allowed values.
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.
Haha, a typo in my comment. Should have been "typo"!
Thank you for your detailed reviews and tests @bobular 👍 - Didn't have time to reply earlier due to map stuff we worked together 😄 I will change the type (typo haha). Also will try to adjust the legend. |
Hi @moontrip - I'm not sure I understand the question but here is my understanding of how the legend needs to be drawn: The min and max values displayed on the legend (e.g. -30 and +20 in my screenshot above) are correctly sourced, I think. The transform applied to generate the colours in the legend needs to be the same as used in the viz component, e.g. -maxAbs to +maxAbs. Maybe pass the |
I looked at the |
@bobular Thank you for sharing your insights 👍 I will think of it next week. Have a great weekend! |
Hi @bobular I have implemented new colormap based on range for divergent, sequential, and sequential reversed. For your better understanding when reviewing, I summarized how to resolve this in the following. a) at ScatterplotVisualization, RGB values for overlayMin and overlayMax via gradientDivergingColorscaleMap(normalize(overlayMin/Max)) are passed to PlotLegend/plotGradientLegend. Here are screenshots to show current Live site and new divergent colormap (GEMS1 data): I think sequential-related colormaps would also work fine with the logic I implemented but couldn't find appropriate example to demo (mostly starting from 0 or 1). a) current Live site: incorrect range as you initiated in the ticket b) new divergent colormap: as you can see, the color of the min does not start from dark blue |
@bobular After checking the cases of the sequential and sequential reversed, I don't think we need to use my logic for them. So, I simplified the logic and changed accordingly. Now we only use the logic for the divergent case. |
Converting to draft as I'm not sure of the status of this branch. |
Making a new PR at web-monorepo. Detailed discussions were made at VEuPathDB/web-eda#1696.