Add user-defined category-label colors (#1402)

* Add user-defined category-label colors

Fixes https://github.com/chanzuckerberg/cellxgene/issues/1152

As described in https://github.com/chanzuckerberg/cellxgene/issues/1307

* Respond to feedback from @bkmartinjr in nodejs

* Respond to feedback from @bkmartinjr in python

* Add tests to the server module

* Autoformat python, run linter

* Make colors_get error handling specific

* Respond to feedback from @bkmartinjr

* Respond to feedback from @bkmartinjr

* Fix whitespace

* Fix python lint errrors

* Update documentation

* Add --disable-user-colors option to launch and cxgtool.py

* Fix python formatting

* Rename '--disable-user-colors' to '--disable-custom-colors'
This commit is contained in:
Matt Weiden
2020-04-26 22:52:57 -07:00
committed by GitHub
parent 3c191c3f93
commit 546e272a60
91 changed files with 801 additions and 271 deletions
+12 -12
View File
@@ -27,6 +27,14 @@ const ColorsReducer = (
};
}
case "universe: user color load success": {
const { userColors } = action;
return {
...state,
userColors
};
}
case "reset World to eq Universe": {
/* need to rebuild colors as world may have changed, but don't switch modes */
const { world } = nextSharedState;
@@ -90,7 +98,7 @@ const ColorsReducer = (
case "color by categorical metadata":
case "color by continuous metadata": {
const { world } = prevSharedState;
const { world, colors } = prevSharedState;
/* toggle between this mode and reset */
const resetCurrent =
@@ -99,11 +107,7 @@ const ColorsReducer = (
const colorMode = !resetCurrent ? action.type : null;
const colorAccessor = !resetCurrent ? action.colorAccessor : null;
const { rgb, scale } = ColorHelpers.createColors(
world,
colorMode,
colorAccessor
);
const { rgb, scale } = ColorHelpers.createColors(world, colorMode, colorAccessor, colors.userColors);
return {
...state,
colorMode,
@@ -141,7 +145,7 @@ const ColorsReducer = (
case "annotation: delete label": {
const { world } = nextSharedState;
const { colorMode, colorAccessor } = state;
const { metadataField } = action;
const { metadataField, colors } = action;
if (
colorMode !== "color by categorical metadata" ||
colorAccessor !== metadataField
@@ -149,11 +153,7 @@ const ColorsReducer = (
return state;
/* else, we need to rebuild colors as labels have changed! */
const { rgb, scale } = ColorHelpers.createColors(
world,
colorMode,
colorAccessor
);
const { rgb, scale } = ColorHelpers.createColors(world, colorMode, colorAccessor);
return { ...state, rgb, scale };
}
+1
View File
@@ -12,6 +12,7 @@ const skipOnActions = new Set([
"interface reset started",
"initial data load start",
"universe: column load success",
"universe: user color load success",
"universe exists, but loading is still in progress",
"configuration load complete",
"increment graph render counter",