reset colorAccessor and colorMode if colored diffexp gene is removed (#843)

* add action to clear colorMode and colorAccessor if diffexp is removed

* create new colorHelper function

* creater colorHelper for conditionally setting state

* add abbr

* revert abbr
This commit is contained in:
Severiano Badajoz
2019-07-11 14:12:38 -07:00
committed by GitHub
parent 98b07b1284
commit ca20add577
3 changed files with 66 additions and 14 deletions
+24 -2
View File
@@ -15,7 +15,7 @@ create new colors state object. Paramters:
"color by continuous metadata", "color by categorical metadata"
-
*/
function createColors(world, colorMode = null, colorAccessor = null) {
export function createColors(world, colorMode = null, colorAccessor = null) {
switch (colorMode) {
case "color by categorical metadata": {
return createColorsByCategoricalMetadata(world, colorAccessor);
@@ -117,4 +117,26 @@ function createColorsByExpression(world, accessor) {
return { rgb, scale };
}
export default createColors;
export const resetColors = world => {
const { rgb, scale } = createColors(world);
return {
colorMode: null,
colorAccessor: null,
rgb,
scale
};
};
export const checkIfColorByDiffexpAndResetColors = (
prevControls,
state,
prevWorld
) => {
if (prevControls.diffexpGenes.includes(state.colorAccessor)) {
return {
...state,
...resetColors(prevWorld)
};
}
return null;
};
+1 -1
View File
@@ -14,7 +14,7 @@ This is all VERY tightly integrated with reducers and actions, and
exists to support those concepts.
*/
export { default as createColors } from "./colorHelpers";
export * as ColorHelpers from "./colorHelpers";
export * as Universe from "./universe";
export * as World from "./world";
export * as WorldUtil from "./worldUtil";