mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-08 23:38:13 +08:00
Add categorical to controls
This commit is contained in:
Vendored
+40
-4
@@ -5,6 +5,7 @@ const Controls = (state = {
|
|||||||
allCellsOnClient: null, /* this comes from cells endpoint, this is world */
|
allCellsOnClient: null, /* this comes from cells endpoint, this is world */
|
||||||
currentCellSelection: null, /* this comes from user actions, this is current cell selection */
|
currentCellSelection: null, /* this comes from user actions, this is current cell selection */
|
||||||
graphMap: null,
|
graphMap: null,
|
||||||
|
categoricalAsBooleansMap: null,
|
||||||
colorAccessor: null,
|
colorAccessor: null,
|
||||||
colorScale: null,
|
colorScale: null,
|
||||||
graphBrushSelection: null,
|
graphBrushSelection: null,
|
||||||
@@ -12,9 +13,9 @@ const Controls = (state = {
|
|||||||
axesHaveBeenDrawn: false,
|
axesHaveBeenDrawn: false,
|
||||||
}, action) => {
|
}, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
/* * * * * * * * * * * * * * * * * *
|
/**********************************
|
||||||
Keep a copy of data
|
Keep a copy of 'universe'
|
||||||
* * * * * * * * * * * * * * * * * */
|
***********************************/
|
||||||
case "initialize success":
|
case "initialize success":
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
_ranges: action.data.data.ranges
|
_ranges: action.data.data.ranges
|
||||||
@@ -27,11 +28,32 @@ const Controls = (state = {
|
|||||||
cell["__selected__"] = true;
|
cell["__selected__"] = true;
|
||||||
cell["__color__"] = "rgba(0,0,0,1)" /* initial color for all cells in all charts */
|
cell["__color__"] = "rgba(0,0,0,1)" /* initial color for all cells in all charts */
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
construct a copy of the ranges object that only has categorical
|
||||||
|
replace all counts with bool flags
|
||||||
|
ie., everything starts out checked
|
||||||
|
we mutate this map in the actions below
|
||||||
|
*/
|
||||||
|
const categoricalAsBooleansMap = {};
|
||||||
|
_.each(action.data.data.ranges, (value, key) => {
|
||||||
|
if (
|
||||||
|
key !== "CellName" &&
|
||||||
|
value.options /* it's categorical, it has options instead of ranges */
|
||||||
|
) {
|
||||||
|
const optionsAsBooleans = {}
|
||||||
|
_.each(value.options, (_value, _key) => {
|
||||||
|
optionsAsBooleans[_key] = true;
|
||||||
|
})
|
||||||
|
categoricalAsBooleansMap[key] = optionsAsBooleans;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// console.log("Copy of ranges obj w/ bools instead of counts:", categoricalAsBooleansMap)
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
allCellsOnClient: action.data.data,
|
allCellsOnClient: action.data.data,
|
||||||
currentCellSelection,
|
currentCellSelection,
|
||||||
graphMap,
|
graphMap,
|
||||||
|
categoricalAsBooleansMap,
|
||||||
graphBrushSelection: null, /* if we are getting new cells from the server, the layout (probably? definitely?) just changed, so this is now irrelevant, and we WILL need to call a function to reset state of this kind when cells success happens */
|
graphBrushSelection: null, /* if we are getting new cells from the server, the layout (probably? definitely?) just changed, so this is now irrelevant, and we WILL need to call a function to reset state of this kind when cells success happens */
|
||||||
});
|
});
|
||||||
/* * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * *
|
||||||
@@ -55,8 +77,21 @@ const Controls = (state = {
|
|||||||
case "graph brush deselect":
|
case "graph brush deselect":
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
graphBrushSelection: null,
|
graphBrushSelection: null,
|
||||||
currentCellSelection: action.newSelection
|
currentCellSelection: action.newSelection /* this comes from middleware */
|
||||||
})
|
})
|
||||||
|
case "categorical metadata filter select":
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
categoricalAsBooleansMap: action.newCategoricalAsBooleansMap, /* this comes from middleware */
|
||||||
|
currentCellSelection: action.newSelection /* this comes from middleware */
|
||||||
|
})
|
||||||
|
case "categorical metadata filter deselect":
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
categoricalAsBooleansMap: action.newCategoricalAsBooleansMap, /* this comes from middleware */
|
||||||
|
currentCellSelection: action.newSelection /* this comes from middleware */
|
||||||
|
})
|
||||||
|
/*******************************
|
||||||
|
Color Scale
|
||||||
|
*******************************/
|
||||||
case "color by continuous metadata":
|
case "color by continuous metadata":
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
colorAccessor: action.colorAccessor,
|
colorAccessor: action.colorAccessor,
|
||||||
@@ -72,6 +107,7 @@ const Controls = (state = {
|
|||||||
colorAccessor: action.colorAccessor, /* pass the scale through additionally, and it's a legend! */
|
colorAccessor: action.colorAccessor, /* pass the scale through additionally, and it's a legend! */
|
||||||
currentCellSelection: action.currentSelectionWithUpdatedColors /* this comes from middleware */
|
currentCellSelection: action.currentSelectionWithUpdatedColors /* this comes from middleware */
|
||||||
})
|
})
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user