mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 05:18:12 +08:00
toggleable
This commit is contained in:
@@ -17,6 +17,7 @@ const Histogram = ({
|
|||||||
margin,
|
margin,
|
||||||
isColorBy,
|
isColorBy,
|
||||||
selectionRange,
|
selectionRange,
|
||||||
|
mini,
|
||||||
}) => {
|
}) => {
|
||||||
const svgRef = useRef(null);
|
const svgRef = useRef(null);
|
||||||
const [brush, setBrush] = useState(null);
|
const [brush, setBrush] = useState(null);
|
||||||
@@ -28,6 +29,8 @@ const Histogram = ({
|
|||||||
const { marginLeft, marginRight, marginBottom, marginTop } = margin;
|
const { marginLeft, marginRight, marginBottom, marginTop } = margin;
|
||||||
const { x, y, bins, binStart, binEnd, binWidth } = histogram;
|
const { x, y, bins, binStart, binEnd, binWidth } = histogram;
|
||||||
const svg = d3.select(svgRef.current);
|
const svg = d3.select(svgRef.current);
|
||||||
|
const binPadding = mini ? 0 : -1;
|
||||||
|
const defaultBarColor = mini ? "black" : "#bbb";
|
||||||
|
|
||||||
/* Remove everything */
|
/* Remove everything */
|
||||||
svg.selectAll("*").remove();
|
svg.selectAll("*").remove();
|
||||||
@@ -62,11 +65,13 @@ const Histogram = ({
|
|||||||
.append("rect")
|
.append("rect")
|
||||||
.attr("x", (d, i) => x(binStart(i)) + 1)
|
.attr("x", (d, i) => x(binStart(i)) + 1)
|
||||||
.attr("y", (d) => y(d))
|
.attr("y", (d) => y(d))
|
||||||
.attr("width", (d, i) => x(binEnd(i)) - x(binStart(i)) - 1)
|
.attr("width", (d, i) => x(binEnd(i)) - x(binStart(i)) - binPadding)
|
||||||
.attr("height", (d) => y(0) - y(d))
|
.attr("height", (d) => y(0) - y(d))
|
||||||
.style(
|
.style(
|
||||||
"fill",
|
"fill",
|
||||||
isColorBy ? (d, i) => colorScale(histogramScale(binStart(i))) : "#bbb"
|
isColorBy
|
||||||
|
? (d, i) => colorScale(histogramScale(binStart(i)))
|
||||||
|
: defaultBarColor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,30 @@ class HistogramBrush extends React.PureComponent {
|
|||||||
const marginRight = 54; // space for Y axis & labels
|
const marginRight = 54; // space for Y axis & labels
|
||||||
const marginBottom = 25; // space for X axis & labels
|
const marginBottom = 25; // space for X axis & labels
|
||||||
const marginTop = 3;
|
const marginTop = 3;
|
||||||
this.margin = {
|
|
||||||
marginLeft,
|
const marginLeftMini = 10; // Space for 0 tick label on X axis
|
||||||
marginRight,
|
const marginRightMini = 54; // space for Y axis & labels
|
||||||
marginBottom,
|
const marginBottomMini = 25; // space for X axis & labels
|
||||||
marginTop,
|
const marginTopMini = 3;
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
margin: {
|
||||||
|
marginLeft,
|
||||||
|
marginRight,
|
||||||
|
marginBottom,
|
||||||
|
marginTop,
|
||||||
|
},
|
||||||
|
width: 340 - marginLeft - marginRight,
|
||||||
|
height: 135 - marginTop - marginBottom,
|
||||||
|
marginMini: {
|
||||||
|
marginLeftMini,
|
||||||
|
marginRightMini,
|
||||||
|
marginBottomMini,
|
||||||
|
marginTopMini,
|
||||||
|
},
|
||||||
|
widthMini: 340 - marginLeft - marginRight,
|
||||||
|
heightMini: 135 - marginTop - marginBottom,
|
||||||
};
|
};
|
||||||
this.width = 340 - marginLeft - marginRight;
|
|
||||||
this.height = 135 - marginTop - marginBottom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBrush = (selection, x, eventType) => {
|
onBrush = (selection, x, eventType) => {
|
||||||
@@ -190,6 +206,14 @@ class HistogramBrush extends React.PureComponent {
|
|||||||
|
|
||||||
fetchAsyncProps = async () => {
|
fetchAsyncProps = async () => {
|
||||||
const { annoMatrix } = this.props;
|
const { annoMatrix } = this.props;
|
||||||
|
const {
|
||||||
|
margin,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
marginMini,
|
||||||
|
widthMini,
|
||||||
|
heightMini,
|
||||||
|
} = this.state;
|
||||||
const { isClipped } = annoMatrix;
|
const { isClipped } = annoMatrix;
|
||||||
|
|
||||||
const query = this.createQuery();
|
const query = this.createQuery();
|
||||||
@@ -217,11 +241,12 @@ class HistogramBrush extends React.PureComponent {
|
|||||||
: globals.blue,
|
: globals.blue,
|
||||||
];
|
];
|
||||||
|
|
||||||
const histogram = this.calcHistogramCache(
|
const histogram = this.calcHistogramCache(column, margin, width, height);
|
||||||
|
const miniHistogram = this.calcHistogramCache(
|
||||||
column,
|
column,
|
||||||
this.margin,
|
marginMini,
|
||||||
this.width,
|
widthMini,
|
||||||
this.height
|
heightMini
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSingleValue = summary.min === summary.max;
|
const isSingleValue = summary.min === summary.max;
|
||||||
@@ -235,6 +260,7 @@ class HistogramBrush extends React.PureComponent {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
histogram,
|
histogram,
|
||||||
|
miniHistogram,
|
||||||
range,
|
range,
|
||||||
unclippedRange,
|
unclippedRange,
|
||||||
unclippedRangeColor,
|
unclippedRangeColor,
|
||||||
@@ -314,7 +340,16 @@ class HistogramBrush extends React.PureComponent {
|
|||||||
zebra,
|
zebra,
|
||||||
continuousSelectionRange,
|
continuousSelectionRange,
|
||||||
isObs,
|
isObs,
|
||||||
|
mini,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
const {
|
||||||
|
margin,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
marginMini,
|
||||||
|
widthMini,
|
||||||
|
heightMini,
|
||||||
|
} = this.state;
|
||||||
const fieldForId = field.replace(/\s/g, "_");
|
const fieldForId = field.replace(/\s/g, "_");
|
||||||
const showScatterPlot = isDiffExp || isUserDefined;
|
const showScatterPlot = isDiffExp || isUserDefined;
|
||||||
|
|
||||||
@@ -346,44 +381,51 @@ class HistogramBrush extends React.PureComponent {
|
|||||||
backgroundColor: zebra ? globals.lightestGrey : "white",
|
backgroundColor: zebra ? globals.lightestGrey : "white",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<HistogramHeader
|
{!mini ? (
|
||||||
fieldId={field}
|
<HistogramHeader
|
||||||
isColorBy={isColorAccessor}
|
fieldId={field}
|
||||||
isObs={isObs}
|
isColorBy={isColorAccessor}
|
||||||
onColorByClick={this.handleColorAction(dispatch)}
|
isObs={isObs}
|
||||||
onRemoveClick={isUserDefined ? this.removeHistogram : null}
|
onColorByClick={this.handleColorAction(dispatch)}
|
||||||
isScatterPlotX={isScatterplotXXaccessor}
|
onRemoveClick={isUserDefined ? this.removeHistogram : null}
|
||||||
isScatterPlotY={isScatterplotYYaccessor}
|
isScatterPlotX={isScatterplotXXaccessor}
|
||||||
onScatterPlotXClick={
|
isScatterPlotY={isScatterplotYYaccessor}
|
||||||
showScatterPlot ? this.handleSetGeneAsScatterplotX : null
|
onScatterPlotXClick={
|
||||||
}
|
showScatterPlot ? this.handleSetGeneAsScatterplotX : null
|
||||||
onScatterPlotYClick={
|
}
|
||||||
showScatterPlot ? this.handleSetGeneAsScatterplotY : null
|
onScatterPlotYClick={
|
||||||
}
|
showScatterPlot ? this.handleSetGeneAsScatterplotY : null
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
<Histogram
|
<Histogram
|
||||||
field={field}
|
field={field}
|
||||||
fieldForId={fieldForId}
|
fieldForId={fieldForId}
|
||||||
display={asyncProps.isSingleValue ? "none" : "block"}
|
display={asyncProps.isSingleValue ? "none" : "block"}
|
||||||
histogram={asyncProps.histogram}
|
histogram={
|
||||||
width={this.width}
|
mini ? asyncProps.miniHistogram : asyncProps.histogram
|
||||||
height={this.height}
|
}
|
||||||
|
width={mini ? widthMini : width}
|
||||||
|
height={mini ? heightMini : height}
|
||||||
onBrush={this.onBrush}
|
onBrush={this.onBrush}
|
||||||
onBrushEnd={this.onBrushEnd}
|
onBrushEnd={this.onBrushEnd}
|
||||||
margin={this.margin}
|
margin={mini ? marginMini : margin}
|
||||||
isColorBy={isColorAccessor}
|
isColorBy={isColorAccessor}
|
||||||
selectionRange={continuousSelectionRange}
|
selectionRange={continuousSelectionRange}
|
||||||
|
mini={mini}
|
||||||
/>
|
/>
|
||||||
<HistogramFooter
|
{!mini ? (
|
||||||
displayName={field}
|
<HistogramFooter
|
||||||
hideRanges={asyncProps.isSingleValue}
|
displayName={field}
|
||||||
rangeMin={asyncProps.unclippedRange[0]}
|
hideRanges={asyncProps.isSingleValue}
|
||||||
rangeMax={asyncProps.unclippedRange[1]}
|
rangeMin={asyncProps.unclippedRange[0]}
|
||||||
rangeColorMin={asyncProps.unclippedRangeColor[0]}
|
rangeMax={asyncProps.unclippedRange[1]}
|
||||||
rangeColorMax={asyncProps.unclippedRangeColor[1]}
|
rangeColorMin={asyncProps.unclippedRangeColor[0]}
|
||||||
logFoldChange={logFoldChange}
|
rangeColorMax={asyncProps.unclippedRangeColor[1]}
|
||||||
pvalAdj={pvalAdj}
|
logFoldChange={logFoldChange}
|
||||||
/>
|
pvalAdj={pvalAdj}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import HistogramBrush from "../brushableHistogram";
|
|||||||
|
|
||||||
// import TestMiniHisto from "./test_miniHisto";
|
// import TestMiniHisto from "./test_miniHisto";
|
||||||
import * as globals from "../../globals";
|
import * as globals from "../../globals";
|
||||||
import GeneMenus from "./menus/geneMenus";
|
// import GeneMenus from "./menus/geneMenus";
|
||||||
|
|
||||||
@connect(() => {
|
@connect(() => {
|
||||||
return {};
|
return {};
|
||||||
@@ -41,15 +41,12 @@ class Gene extends React.Component {
|
|||||||
const { gene } = this.props;
|
const { gene } = this.props;
|
||||||
const { geneIsExpanded } = this.state;
|
const { geneIsExpanded } = this.state;
|
||||||
return (
|
return (
|
||||||
<div
|
<div>
|
||||||
style={{
|
<div
|
||||||
display: "flex",
|
style={{
|
||||||
justifyContent: "space-between",
|
marginLeft: 15,
|
||||||
alignItems: "baseline",
|
}}
|
||||||
marginLeft: 15,
|
>
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<Icon
|
<Icon
|
||||||
icon="drag-handle-horizontal"
|
icon="drag-handle-horizontal"
|
||||||
iconSize={12}
|
iconSize={12}
|
||||||
@@ -82,35 +79,23 @@ class Gene extends React.Component {
|
|||||||
{gene}
|
{gene}
|
||||||
</span>
|
</span>
|
||||||
</Truncate>
|
</Truncate>
|
||||||
<HistogramBrush isUserDefined field={gene} mini={!geneIsExpanded} />
|
<AnchorButton
|
||||||
|
minimal
|
||||||
|
small
|
||||||
|
data-testclass="maximize"
|
||||||
|
data-testid={`maximize-${gene}`}
|
||||||
|
onClick={this.handleGeneExpandClick}
|
||||||
|
active={false /* todo gene sets */}
|
||||||
|
intent="none"
|
||||||
|
icon={<Icon icon="maximize" iconSize={10} />}
|
||||||
|
/>
|
||||||
{/* <TestMiniHisto /> */}
|
{/* <TestMiniHisto /> */}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<HistogramBrush isUserDefined field={gene} mini={!geneIsExpanded} />
|
||||||
<GeneMenus genesetsEditable gene={gene} />
|
|
||||||
<AnchorButton
|
{/* <GeneMenus genesetsEditable gene={gene} /> */}
|
||||||
minimal
|
|
||||||
small
|
|
||||||
data-testclass="colorby"
|
|
||||||
data-testid={`colorby-${gene}`}
|
|
||||||
onClick={/* todo gene sets */ () => {}}
|
|
||||||
active={false /* todo gene sets */}
|
|
||||||
intent="none"
|
|
||||||
icon={<Icon icon="tint" iconSize={12} />}
|
|
||||||
/>
|
|
||||||
<AnchorButton
|
|
||||||
minimal
|
|
||||||
small
|
|
||||||
data-testclass="maximize"
|
|
||||||
data-testid={`maximize-${gene}`}
|
|
||||||
onClick={this.handleGeneExpandClick}
|
|
||||||
active={false /* todo gene sets */}
|
|
||||||
intent="none"
|
|
||||||
icon={<Icon icon="maximize" iconSize={10} />}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -118,6 +103,17 @@ class Gene extends React.Component {
|
|||||||
|
|
||||||
export default Gene;
|
export default Gene;
|
||||||
|
|
||||||
|
// <AnchorButton
|
||||||
|
// minimal
|
||||||
|
// small
|
||||||
|
// data-testclass="colorby"
|
||||||
|
// data-testid={`colorby-${gene}`}
|
||||||
|
// onClick={/* todo gene sets */ () => {}}
|
||||||
|
// active={false /* todo gene sets */}
|
||||||
|
// intent="none"
|
||||||
|
// icon={<Icon icon="tint" iconSize={12} />}
|
||||||
|
// />
|
||||||
|
|
||||||
// {geneIsExpanded ? (
|
// {geneIsExpanded ? (
|
||||||
// <FaChevronDown
|
// <FaChevronDown
|
||||||
// data-testclass="gene-expand-is-expanded"
|
// data-testclass="gene-expand-is-expanded"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { memoize } from "../../util/dataframe/util";
|
|||||||
import Truncate from "../util/truncate";
|
import Truncate from "../util/truncate";
|
||||||
// import TestMiniHisto from "./test_miniHisto";
|
// import TestMiniHisto from "./test_miniHisto";
|
||||||
import * as globals from "../../globals";
|
import * as globals from "../../globals";
|
||||||
import GenesetMenus from "./menus/genesetMenus";
|
// import GenesetMenus from "./menus/genesetMenus";
|
||||||
|
|
||||||
@connect((state, ownProps) => {
|
@connect((state, ownProps) => {
|
||||||
return {
|
return {
|
||||||
@@ -145,7 +145,7 @@ class GeneSet extends React.Component {
|
|||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
{/* <TestMiniHisto /> */}
|
{/* <TestMiniHisto /> */}
|
||||||
<GenesetMenus genesetsEditable geneset={setName} />
|
{/* <GenesetMenus genesetsEditable geneset={setName} /> */}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content="Color by geneset"
|
content="Color by geneset"
|
||||||
position={Position.LEFT}
|
position={Position.LEFT}
|
||||||
|
|||||||
Reference in New Issue
Block a user