move colorScale and colorAccessor to redux to make it global

This commit is contained in:
Colin Megill
2017-11-17 14:59:28 -08:00
parent e18f57e6f2
commit 42bef3d6cd
7 changed files with 61 additions and 39 deletions
+23 -3
View File
@@ -1,18 +1,38 @@
const Controls = (state = {
color: null,
colorAccessor: null,
colorScale: null,
continuousSelection: null,
graphBrushSelection: null
graphBrushSelection: null,
axesHaveBeenDrawn: false,
}, action) => {
switch (action.type) {
case "color changed":
return Object.assign({}, state, {
color: action.data,
colorAccessor: action.colorAccessor,
colorScale: d3.scaleLinear()
.domain([0, action.rangeMaxForColorAccessor])
.range([1,0])
});
case "continuous selection using parallel coords brushing": {
return Object.assign({}, state, {
continuousSelection: action.data,
});
}
/* on load, set the selection to 'all', if reactive is true */
case "initialize success":
let allCellNames = null;
if (action.data.data.reactive) { /* we have metadata, get all cell names */
allCellNames = action.data.data.metadata.map((cell) => {
return cell.CellName
})
}
return Object.assign({}, state, {
continuousSelection: allCellNames
});
case "parallel coordinates axes have been drawn":
return Object.assign({}, state, {
axesHaveBeenDrawn: true
});
case "graph brush selection change":
return Object.assign({}, state, {
graphBrushSelection: action.brushCoords