mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 05:18:12 +08:00
draw scatterplot is now the inside of the loop, bring in queue
This commit is contained in:
@@ -9,6 +9,48 @@ import {
|
|||||||
} from "./util";
|
} from "./util";
|
||||||
|
|
||||||
const drawScatterplotCanvas = (
|
const drawScatterplotCanvas = (
|
||||||
|
context,
|
||||||
|
xScale,
|
||||||
|
yScale,
|
||||||
|
currentCellSelection,
|
||||||
|
opacityForDeselectedCells,
|
||||||
|
expression,
|
||||||
|
scatterplotXXaccessor,
|
||||||
|
scatterplotYYaccessor,
|
||||||
|
_currentCellSelectionMap,
|
||||||
|
) => {
|
||||||
|
|
||||||
|
return (cell) => {
|
||||||
|
|
||||||
|
/*
|
||||||
|
this is necessary until we are no longer getting expression for all cells, but only for 'world'
|
||||||
|
...which will mean refetching when we regraph, or 'go back up to all cells'
|
||||||
|
*/
|
||||||
|
if (!_currentCellSelectionMap[cell.cellname]) { return }
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
/* context.arc(x,y,r,sAngle,eAngle,counterclockwise); */
|
||||||
|
context.arc(
|
||||||
|
xScale(cell.e[expression.data.genes.indexOf(scatterplotXXaccessor)]), /* x */
|
||||||
|
yScale(cell.e[expression.data.genes.indexOf(scatterplotYYaccessor)]), /* y */
|
||||||
|
_currentCellSelectionMap[cell.cellname]["__selected__"] ? 3 : 1.5, /* r */
|
||||||
|
0, /* sAngle */
|
||||||
|
2 * Math.PI /* eAngle */
|
||||||
|
);
|
||||||
|
|
||||||
|
context.fillStyle = _currentCellSelectionMap[cell.cellname]["__color__"]
|
||||||
|
|
||||||
|
if (_currentCellSelectionMap[cell.cellname]["__selected__"]) {
|
||||||
|
context.globalAlpha = 1;
|
||||||
|
} else {
|
||||||
|
context.globalAlpha = opacityForDeselectedCells;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const drawScatterplotCanvasUsingRenderQueue = (
|
||||||
context,
|
context,
|
||||||
xScale,
|
xScale,
|
||||||
yScale,
|
yScale,
|
||||||
@@ -19,40 +61,25 @@ const drawScatterplotCanvas = (
|
|||||||
scatterplotYYaccessor
|
scatterplotYYaccessor
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
/* clear canvas */
|
|
||||||
context.clearRect(0, 0, width, height);
|
|
||||||
|
|
||||||
const _currentCellSelectionMap = _.keyBy(currentCellSelection, "CellName"); /* move me to the reducer */
|
const _currentCellSelectionMap = _.keyBy(currentCellSelection, "CellName"); /* move me to the reducer */
|
||||||
|
|
||||||
expression.data.cells.forEach((cell, i) => {
|
const _renderLinesWithFunctionReturnedByQueue = renderQueue(
|
||||||
|
drawScatterplotCanvas(
|
||||||
/*
|
context,
|
||||||
this is necessary until we are no longer getting expression for all cells, but only for 'world'
|
xScale,
|
||||||
...which will mean refetching when we regraph, or 'go back up to all cells'
|
yScale,
|
||||||
*/
|
currentCellSelection,
|
||||||
|
opacityForDeselectedCells,
|
||||||
if (!_currentCellSelectionMap[cell.cellname]) { return }
|
expression,
|
||||||
|
scatterplotXXaccessor,
|
||||||
context.beginPath();
|
scatterplotYYaccessor,
|
||||||
/* context.arc(x,y,r,sAngle,eAngle,counterclockwise); */
|
_currentCellSelectionMap,
|
||||||
context.arc(
|
)
|
||||||
xScale(cell.e[expression.data.genes.indexOf(scatterplotXXaccessor)]), /* x */
|
)
|
||||||
yScale(cell.e[expression.data.genes.indexOf(scatterplotYYaccessor)]), /* y */
|
|
||||||
_currentCellSelectionMap[cell.cellname]["__selected__"] ? 3 : 1.5, /* r */
|
|
||||||
0, /* sAngle */
|
|
||||||
2 * Math.PI /* eAngle */
|
|
||||||
);
|
|
||||||
|
|
||||||
context.fillStyle = _currentCellSelectionMap[cell.cellname]["__color__"]
|
|
||||||
|
|
||||||
if (_currentCellSelectionMap[cell.cellname]["__selected__"]) {
|
_renderLinesWithFunctionReturnedByQueue(expression.data.cells)
|
||||||
context.globalAlpha = 1;
|
return _renderLinesWithFunctionReturnedByQueue;
|
||||||
} else {
|
|
||||||
context.globalAlpha = opacityForDeselectedCells;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.fill();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default _.debounce(drawScatterplotCanvas, 50)
|
export default _.debounce(drawScatterplotCanvasUsingRenderQueue, 50)
|
||||||
|
|||||||
Reference in New Issue
Block a user