mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 09:08:12 +08:00
performance - remove scaling from inner render loop
This commit is contained in:
@@ -78,11 +78,19 @@ export const graphXScale = scaleLinear(
|
|||||||
[0, 1],
|
[0, 1],
|
||||||
[0 + graphMargin.left, graphWidth - graphMargin.right]
|
[0 + graphMargin.left, graphWidth - graphMargin.right]
|
||||||
);
|
);
|
||||||
|
graphXScale.invert = scaleLinear(
|
||||||
|
[0 + graphMargin.left, graphWidth - graphMargin.right],
|
||||||
|
[0, 1]
|
||||||
|
);
|
||||||
// d3.scaleLinear().domain([0,1]).range([graphHeight - graphMargin.bottom, 0 + graphMargin.top])
|
// d3.scaleLinear().domain([0,1]).range([graphHeight - graphMargin.bottom, 0 + graphMargin.top])
|
||||||
export const graphYScale = scaleLinear(
|
export const graphYScale = scaleLinear(
|
||||||
[0, 1],
|
[0, 1],
|
||||||
[graphHeight - graphMargin.bottom, 0 + graphMargin.top]
|
[graphHeight - graphMargin.bottom, 0 + graphMargin.top]
|
||||||
);
|
);
|
||||||
|
graphYScale.invert = scaleLinear(
|
||||||
|
[graphHeight - graphMargin.bottom, 0 + graphMargin.top],
|
||||||
|
[0, 1]
|
||||||
|
);
|
||||||
|
|
||||||
export const ordinalColors = [
|
export const ordinalColors = [
|
||||||
"#0ac115",
|
"#0ac115",
|
||||||
|
|||||||
@@ -73,18 +73,31 @@ const updateCellSelectionMiddleware = store => {
|
|||||||
? action.brushCoords
|
? action.brushCoords
|
||||||
: s.controls.graphBrushSelection;
|
: s.controls.graphBrushSelection;
|
||||||
|
|
||||||
|
const northwestX = globals.graphXScale.invert(
|
||||||
|
graphBrushSelection.northwestX
|
||||||
|
);
|
||||||
|
const southeastX = globals.graphXScale.invert(
|
||||||
|
graphBrushSelection.southeastX
|
||||||
|
);
|
||||||
|
const northwestY = globals.graphYScale.invert(
|
||||||
|
graphBrushSelection.northwestY
|
||||||
|
);
|
||||||
|
const southeastY = globals.graphYScale.invert(
|
||||||
|
graphBrushSelection.southeastY
|
||||||
|
);
|
||||||
|
|
||||||
const graphVec = s.controls.graphVec;
|
const graphVec = s.controls.graphVec;
|
||||||
for (let i = 0; i < newSelection.length; i++) {
|
for (let i = 0; i < newSelection.length; i++) {
|
||||||
const cell = newSelection[i];
|
const cell = newSelection[i];
|
||||||
const cellId = cell.__cellIndex__;
|
const cellId = cell.__cellIndex__;
|
||||||
const x = globals.graphXScale(graphVec[2 * cellId]);
|
const x = graphVec[2 * cellId];
|
||||||
const y = globals.graphYScale(graphVec[2 * cellId + 1]);
|
const y = graphVec[2 * cellId + 1];
|
||||||
|
|
||||||
const pointIsInsideBrushBounds =
|
const pointIsInsideBrushBounds =
|
||||||
x >= graphBrushSelection.northwestX &&
|
x >= northwestX &&
|
||||||
x <= graphBrushSelection.southeastX &&
|
x <= southeastX &&
|
||||||
y >= graphBrushSelection.northwestY &&
|
y <= northwestY &&
|
||||||
y <= graphBrushSelection.southeastY;
|
y >= southeastY;
|
||||||
|
|
||||||
if (!pointIsInsideBrushBounds) {
|
if (!pointIsInsideBrushBounds) {
|
||||||
cell.__selected__ = false;
|
cell.__selected__ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user