-
Notifications
You must be signed in to change notification settings - Fork 0
Add a legend component #19
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
==========================================
+ Coverage 96.79% 96.86% +0.06%
==========================================
Files 14 15 +1
Lines 281 319 +38
Branches 73 84 +11
==========================================
+ Hits 272 309 +37
- Misses 9 10 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
EmmaLRussell
left a comment
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 looks really nice - I like the way you have both the line and fill colours included in the legend.
The outline in the legend does look a little different from the line style in the plot, and it feels like it could be a slightly closer match. I think the style on the plot is thicker? It also looks slightly darker to my eye but that's an illusion, the stroke color itself is identical!
When focussing on disease, "All 117 VIMC countries" is at the top in the plot, but at the bottom in the legend - would be better if these matched. Will this be fixed in vimc-9191?
When focussing on geography, with a country selected, the order of the legend is Region, Country, Global. It feels like it would make more sense to either go from the largest scale to the smallest or vice versa (so Global, Region, Country or Country, Region, Global). I'd favour country first since that's what the user has selected.
src/components/ColorLegend.vue
Outdated
| }) | ||
|
|
||
| const colorBoxStyle = (color: HEX) => { | ||
| const { fillColor, fillOpacity, strokeColor } = colorStore.colorPropertiesForFillColor(color); |
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.
Do we need both fill color and opacity here? Could we not just get the fillColor out of the store as an rgba color and not need to do the further construction?
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.
skadi-chart's lines interface takes fill opacity as a separate property from fill colour, which is why the interface of the colorStore has ended up the way it is. The colorStore could expose another property in the return value of colorPropertiesForFillColor called fillColorWithOpacity or something, containing the rgba version, to make it responsible for more color logic in general.
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.
Actually I'd rather keep the colorPropertiesForFillColor interface matching the skadi-chart Line interface, so I'll make this a little method in the store converting hex + opacity to rgba.
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.
Actually actually, I've gone with the suggestion of doing fillColor canonically as an rgba, i.e. the a channel will handle opacity for the legend and for skadi-chart, and the 'opacity' property for skadi-chart will be ignored (set to 1).
src/components/ColorLegend.vue
Outdated
|
|
||
| <style scoped> | ||
| .legend-color-box { | ||
| min-width: 1rem; |
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.
Why min-width rather than just 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.
No reason
I did fiddle around with the thickness of the legend outline to try to appear to match the plot thickness. Something going on here is the illusion caused by a very jaggedy ridgeline edge, which can sometimes look thicker (because it overlaps itself) than it 'really' is. Currently, the legend borders are 2px, twice the ridgeline outlines.
The plot rows and legend are both unordered at the moment. I'm explicitly not concerned with ordering anything yet, because I'm planning for the legend and the plot to both get their ordering from a common source once that's implemented.
Ah, I can in fact implement some ordering for this, because this isn't to do with plot row ordering. [some time passes] OK done. |
Add a legend component.
This will only display colors/labels for values that are actually displayed, i.e. not those without data. This behaviour follows from the way we create the ridgelines in
useHistogramLines.ts, that is, we transform data into lines rather than working from an assumption about what data categories to expect. Those lines' metadata are then used as the basis for creating a color mapping, so we should expect to always have a 1-to-1 mapping from colors to line categories.The fill color of the legend squares has an opacity added (via the alpha channel of rgba) so as to match the actual fill color used in the plot.
Added ES2023 to compiler options so that I could use
Array.prototype.toReversed.