-
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
Implement advanced map marker configuration menu #285
Merged
Merged
Changes from 10 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
4d25b60
Create component for configuring categorical markers
jernestmyers 2416577
Wire up new table for barplot categorical marker configs
jernestmyers 37c7151
Add CategoricalMarkerConfigurationTable to donut config menu
jernestmyers e038f2e
Clean up types related to allValues overlay data
jernestmyers 4d03d4a
Add a barplot marker preview for categorical vars
jernestmyers 1d3c312
Ensure 'All other values' is at end of selectedValues and clean up so…
jernestmyers 7e49adb
Add donut marker preview for categorical marker config
jernestmyers a5188f7
Display histogram in marker config menu for continuous vars
jernestmyers ebd1ea0
Merge branch 'main' into 190-advanced-map-marker-config
jernestmyers 50bf469
Remove some ts-ignores
jernestmyers 64ce841
Merge branch 'main' into 190-advanced-map-marker-config
jernestmyers aad6f1b
Wire up marker preview for continuous vars
jernestmyers 5181895
Clean up some of the marker preview logic
jernestmyers 784f218
Change from allValuesSorted to just allValues
jernestmyers 3ed3ca2
Remove ts-ignores from advanced marker config work
jernestmyers c5c37be
Use standalone markers for all previews and add some styling
jernestmyers fa7daad
Tweak selectedValues logic and add documentation
jernestmyers d4706b5
Change type name for getValues function params
jernestmyers 9e99c84
Wire up selectAll and deselectAll handlers
jernestmyers dd8049a
Add indeterminate state to (de)selectAll toggle
jernestmyers 5516fcd
Wire up marker binning method options for continuous vars
jernestmyers cf08fa6
Wire up log scale toggle for map markers
jernestmyers e089aee
Clean up map marker binningMethod typing
jernestmyers 25a3747
Add binning controls to pie marker config menu
jernestmyers dee48f1
Change menu verbiage from Map Type to Configure Map
jernestmyers 50762c7
Clean up unused imports and replace hardcoded value with defined cons…
jernestmyers 647f47e
Add not-yet-functional counts toggle to marker config menu
jernestmyers b1f71ae
Overlay warning if user selects too many values for categorical vars …
jernestmyers b991dae
Merge main and resolve conflicts
jernestmyers 0f08b40
Fix paths to coreui
jernestmyers f634684
Improve naming and add number formatting
jernestmyers 6334e9b
Remove allValues property and revert its related logic
jernestmyers 2b4e966
Refactor categorical values logic and implement filtered/visible toggle
jernestmyers 80faf09
Remove ts-ignores
jernestmyers 0ba4e3e
Add log scale to categorical bar plot marker previews
jernestmyers 3247e0a
Fix bug when deselecting values where 'All other values' label is irr…
jernestmyers 923fbf5
Implement column sorting and preserve sort state between filtered/vis…
jernestmyers 121d986
Refactor useStandaloneMapMarkers interface to remove isMarkerPreview …
jernestmyers 0c6840e
Clean up and document code
jernestmyers 8338e5a
Simplify logic and improve documentation
jernestmyers cdb2aa3
Guard against TooManySelectionOverlay displaying erroneously and add …
jernestmyers faff8cf
Remove magic number, improve logic and improve documentation
jernestmyers 69d5cf9
Fix bug in onMultipleRowSelect callback re: UNSELECTED_TOKEN value
jernestmyers cbdd30c
Clean up selectedValues type
jernestmyers 87d8baa
Abstract uncontrolledSelections logic into a hook
jernestmyers b95bc83
Merge branch 'main' into 190-advanced-map-marker-config
jernestmyers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...libs/eda/src/lib/map/analysis/MarkerConfiguration/CategoricalMarkerConfigurationTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import Mesa from '@veupathdb/wdk-client/lib/Components/Mesa'; | ||
import { OverlayConfig, AllValuesDefinition } from '../../../core'; | ||
import { Tooltip } from '@veupathdb/components/lib/components/widgets/Tooltip'; | ||
import { BarPlotMarkerConfiguration } from './BarPlotMarkerConfigurationMenu'; | ||
import { PieMarkerConfiguration } from './PieMarkerConfigurationMenu'; | ||
import { ColorPaletteDefault } from '@veupathdb/components/lib/types/plots'; | ||
|
||
type Props = { | ||
overlayConfiguration: OverlayConfig; | ||
onChange: ( | ||
configuration: BarPlotMarkerConfiguration | PieMarkerConfiguration | ||
) => void; | ||
configuration: BarPlotMarkerConfiguration | PieMarkerConfiguration; | ||
}; | ||
|
||
export function CategoricalMarkerConfigurationTable({ | ||
overlayConfiguration, | ||
configuration, | ||
onChange, | ||
}: Props) { | ||
if (overlayConfiguration.overlayType !== 'categorical') return <></>; | ||
const { overlayType, overlayValues, allValuesSorted } = overlayConfiguration; | ||
const selected = new Set(overlayValues); | ||
const totalCount = allValuesSorted.reduce( | ||
(prev, curr) => prev + curr.count, | ||
0 | ||
); | ||
|
||
function handleSelection(data: AllValuesDefinition) { | ||
if ( | ||
overlayValues.length <= ColorPaletteDefault.length - 1 && | ||
overlayType === 'categorical' | ||
) { | ||
if (selected.has(data.label)) return; | ||
const lastItem = [...overlayValues].pop() ?? ''; // TEMP until better solution | ||
onChange({ | ||
...configuration, | ||
selectedValues: overlayValues | ||
.slice(0, overlayValues.length - 1) | ||
.concat(data.label, lastItem), | ||
allValues: allValuesSorted, | ||
}); | ||
} else { | ||
alert(`Only ${ColorPaletteDefault.length - 1} values can be selected`); | ||
} | ||
} | ||
|
||
function handleDeselection(data: AllValuesDefinition) { | ||
if (overlayType === 'categorical') | ||
onChange({ | ||
...configuration, | ||
selectedValues: overlayValues.filter((val) => val !== data.label), | ||
allValues: allValuesSorted, | ||
}); | ||
} | ||
|
||
const tableState = { | ||
options: { | ||
isRowSelected: (value: AllValuesDefinition) => selected.has(value.label), | ||
}, | ||
eventHandlers: { | ||
onRowSelect: handleSelection, | ||
onRowDeselect: handleDeselection, | ||
}, | ||
actions: [], | ||
rows: allValuesSorted as AllValuesDefinition[], | ||
columns: [ | ||
{ | ||
key: 'values', | ||
name: 'Values', | ||
renderCell: (data: { row: AllValuesDefinition }) => ( | ||
<>{data.row.label}</> | ||
), | ||
}, | ||
{ | ||
key: 'counts', | ||
name: 'Counts', | ||
renderCell: (data: { row: AllValuesDefinition }) => ( | ||
<>{data.row.count}</> | ||
), | ||
}, | ||
{ | ||
key: 'distribution', | ||
name: 'Distribution', | ||
renderCell: (data: { row: AllValuesDefinition }) => ( | ||
<Distribution count={data.row.count} filteredTotal={totalCount} /> | ||
), | ||
}, | ||
], | ||
}; | ||
return <Mesa state={tableState} />; | ||
} | ||
|
||
type DistributionProps = { | ||
count: number; | ||
filteredTotal: number; | ||
}; | ||
|
||
function Distribution({ count, filteredTotal }: DistributionProps) { | ||
return ( | ||
<Tooltip title={`${count} out of ${filteredTotal}`}> | ||
<div | ||
style={{ | ||
width: '99%', | ||
position: 'relative', | ||
cursor: 'pointer', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: (count / filteredTotal) * 100 + '%', | ||
backgroundColor: 'black', | ||
minWidth: 1, | ||
position: 'absolute', | ||
height: '1em', | ||
}} | ||
></div> | ||
</div> | ||
</Tooltip> | ||
); | ||
} |
Oops, something went wrong.
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.
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.
https://blog.codinghorror.com/rule-of-three/
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.
Perhaps I'll change it to a "maybe 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.
🙃
Just wanted to derp by the water
colorcooler 👋 . I've been painting recently... but with acrylics..