-
Notifications
You must be signed in to change notification settings - Fork 162
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
Color tree by measurements #1924
Changes from 1 commit
d90c503
6c2e53b
15dabdf
14a5650
1391b9b
acf11a4
a4b4d9c
69853e2
8b2773e
74eac4a
c0b7e91
e1c74a4
9a5a183
3c35ed5
c2db2bb
17d411c
ade2c20
440cddd
ff28517
795efc7
9a4c328
5d51e9c
0dbc4e3
fb3eba0
a2cfe54
bb44c2a
82e6f6d
9f6b032
27cdbb0
e52f48d
972ed91
e586a6c
921161c
aead1cf
daccd78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,10 +65,18 @@ interface Query extends MeasurementsQuery { | |
[key: string]: string | string[] | ||
} | ||
|
||
|
||
const hasMeasurementColorAttr = "_hasMeasurementColor"; | ||
const hasMeasurementColorValue = "true"; | ||
interface MeasurementsNodeAttrs { | ||
[strain: string]: { | ||
[measurementsColorBy: string]: { | ||
value: number | ||
[key: string]: { | ||
// number for the average measurements value | ||
// 'true' for the presence of measurements coloring | ||
value: number | typeof hasMeasurementColorValue | ||
} | ||
[hasMeasurementColorAttr]: { | ||
value: typeof hasMeasurementColorValue | ||
} | ||
} | ||
} | ||
|
@@ -666,6 +674,9 @@ function createMeasurementsColoringData( | |
nodeAttrs[strain] = { | ||
[measurementColorBy]: { | ||
value: averageMeasurementValue | ||
}, | ||
[hasMeasurementColorAttr]: { | ||
value: hasMeasurementColorValue | ||
} | ||
}; | ||
} | ||
|
@@ -687,6 +698,10 @@ function createMeasurementsColoringData( | |
title: `Measurements (${groupingValue})`, | ||
type: "continuous", | ||
scale: measurementsColorScale, | ||
}, | ||
[hasMeasurementColorAttr]: { | ||
title: `Has measurements for ${groupingValue}`, | ||
type: "boolean", | ||
} | ||
} | ||
}; | ||
|
@@ -726,7 +741,7 @@ function updateMeasurementsColorData( | |
} | ||
dispatch({ | ||
type: REMOVE_METADATA, | ||
nodeAttrsToRemove: [encodeMeasurementColorBy(oldColorGrouping)], | ||
nodeAttrsToRemove: [hasMeasurementColorAttr, encodeMeasurementColorBy(oldColorGrouping)], | ||
}) | ||
} | ||
/* If there is a valid new color grouping, then add the measurement metadata and coloring */ | ||
|
@@ -748,7 +763,7 @@ export const applyMeasurementsColorBy = ( | |
*/ | ||
batch(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, things can get complicated if the node.attrs key names are the same but the underlying values changed. A concrete example is changing measurements collections. They might have the same reference strain (which means they have the same node.attrs key), but completely different measurements so the data needs to be completely updated. It's cleaner to remove old data then apply the new data instead of trying to keep track of which nodes needs to be updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's worth changing what you've done (which includes a good docstring) but an alternative approach to consider for patterns like this if we use them again is to make "remove metadata" a thunk which checks that the attr being removed isn't currently used as a coloring, and if it is then thee thunk can do something about it. |
||
if (controls.measurementsColorGrouping !== undefined) { | ||
dispatch({type: REMOVE_METADATA, nodeAttrsToRemove: [encodeMeasurementColorBy(controls.measurementsColorGrouping)]}); | ||
dispatch({type: REMOVE_METADATA, nodeAttrsToRemove: [hasMeasurementColorAttr, encodeMeasurementColorBy(controls.measurementsColorGrouping)]}); | ||
} | ||
if (controls.measurementsColorGrouping !== groupingValue) { | ||
dispatch({type: CHANGE_MEASUREMENTS_COLOR_GROUPING, controls:{measurementsColorGrouping: groupingValue}}); | ||
|
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.
Probably beyond this PR, but this makes me think about some improvements to the filter badges - they haven't seen any development since they were first introduced and filtering has become a much bigger part of workflows since then.
It'd be nice to show the title not the key when hovering, and even nicer if we could somehow render this in the badge itself, as a badge simply showing "true" isn't very intuitive. We already do both of these in the sidebar
![image](https://private-user-images.githubusercontent.com/8350992/404698296-5d72da9d-e814-4733-a091-1351e7610a91.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMTcxMDMsIm5iZiI6MTczOTMxNjgwMywicGF0aCI6Ii84MzUwOTkyLzQwNDY5ODI5Ni01ZDcyZGE5ZC1lODE0LTQ3MzMtYTA5MS0xMzUxZTc2MTBhOTEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMjMzMzIzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MWI5ZGFjNGY4MjAwYjFiYTA1ZTAwZWRlNzE3MjEzZjU3MTMxYTkwZTZkYjAyYzk2MDliYWNhNDgzZDZmNjU2ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.JoI8peCVLyzgfN4SQvo49JLubhh5tNhmJr1Ty3I7v3M)
Would this (the
_hasMeasurementsColor
filter) be better as part of the separate measurements filtering section?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.
Agree, these would be nice, but it might overcrowd the badges with the longer titles. We can revisit the design of the filter badges separately.
I think it makes sense to keep the
_hasMeasurementsColor
filter in the overall filters since it is filtering the tree node attributes. The measurements filtering section is specific to filtering measurements records in the measurements panel.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.
Ahh, this is clarifying. Thanks!