graph now renders from global cell selection, significant perf boost

This commit is contained in:
Colin Megill
2017-11-27 03:14:10 -08:00
parent bfa03e77b4
commit 1b72e8dab3
3 changed files with 26 additions and 9 deletions
+14 -6
View File
@@ -60,15 +60,15 @@ export const setupGraphElements = (
******************************************/ ******************************************/
export const drawGraph = ( export const drawGraph = (
data,
context, context,
expressionsCountsMap, expressionsCountsMap,
colorAccessor, colorAccessor,
ranges, ranges,
metadata, metadata,
continuousSelection, currentCellSelection,
graphBrushSelection, graphBrushSelection,
colorScale, colorScale,
graphMap, /* tmp remove when structure exists on server */
) => { ) => {
/* clear canvas */ /* clear canvas */
@@ -81,12 +81,20 @@ export const drawGraph = (
// .domain([0, expressionsCountsMap.maxValue]) // .domain([0, expressionsCountsMap.maxValue])
// .range([1,0]) // .range([1,0])
if (continuousSelection) { const data = [];
data = _.filter(data, (d) => {return continuousSelection.indexOf(d[0]) > -1 })
} _.each(currentCellSelection, (metadata, i) => {
if (graphMap[metadata["CellName"]]) { /* fails silently, sometimes this is undefined, in which case the graph array should be shorter than the metadata array, check in reducer */
data.push([
metadata["CellName"],
graphMap[metadata["CellName"]][0],
graphMap[metadata["CellName"]][1]
])
}
})
/* shuffle the data to overcome render order hiding cells, & filter first */ /* shuffle the data to overcome render order hiding cells, & filter first */
data = d3.shuffle(data); /* make me a control */ // data = d3.shuffle(data); /* make me a control */
const _metadata = _.keyBy(metadata, "CellName"); /* move me to the reducer */ const _metadata = _.keyBy(metadata, "CellName"); /* move me to the reducer */
+5 -3
View File
@@ -19,6 +19,8 @@ import ColorControl from "../controls/color";
colorAccessor: state.controls.colorAccessor, colorAccessor: state.controls.colorAccessor,
colorScale: state.controls.colorScale, colorScale: state.controls.colorScale,
continuousSelection: state.controls.continuousSelection, continuousSelection: state.controls.continuousSelection,
graphMap: state.controls.graphMap,
currentCellSelection: state.controls.currentCellSelection,
graphBrushSelection: state.controls.graphBrushSelection graphBrushSelection: state.controls.graphBrushSelection
} }
}) })
@@ -79,15 +81,15 @@ class Graph extends React.Component {
// nextProps.expressionsCountsMap && // nextProps.expressionsCountsMap &&
) { ) {
drawGraph( drawGraph(
nextProps.vertices,
this.state.ctx, this.state.ctx,
nextProps.expressionsCountsMap, nextProps.expressionsCountsMap,
nextProps.colorAccessor, nextProps.colorAccessor,
nextProps.ranges, /* assumption that this exists if vertices does both are on cells */ nextProps.ranges, /* assumption that this exists if vertices does both are on cells */
nextProps.metadata, nextProps.metadata,
nextProps.continuousSelection, /* continuousSelected should probably inform a global 'is active' array rather than be consumed so specifically here */ nextProps.currentCellSelection, /* continuousSelected should probably inform a global 'is active' array rather than be consumed so specifically here */
nextProps.graphBrushSelection, nextProps.graphBrushSelection,
nextProps.colorScale, nextProps.colorScale,
nextProps.graphMap,
) )
} }
} }
@@ -102,7 +104,7 @@ class Graph extends React.Component {
render() { render() {
return ( return (
<div id="graphWrapper"> <div id="graphWrapper" style={{height: 600 /* move this to globals */}}>
<SectionHeader text="Graph"/> <SectionHeader text="Graph"/>
<ColorControl/> <ColorControl/>
<div id="graphAttachPoint"> </div> <div id="graphAttachPoint"> </div>
+7
View File
@@ -48,6 +48,13 @@ const Controls = (state = {
return Object.assign({}, state, { return Object.assign({}, state, {
graphBrushSelection: null graphBrushSelection: null
}) })
case "color changed":
return Object.assign({}, state, {
colorAccessor: action.colorAccessor,
colorScale: d3.scaleLinear()
.domain([0, action.rangeMaxForColorAccessor])
.range([1,0])
});
default: default:
return state; return state;
} }