mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-09 01:18:12 +08:00
Scatterplot smaller, card
This commit is contained in:
@@ -69,16 +69,16 @@ class Scatterplot extends React.Component {
|
|||||||
this.props.scatterplotXXaccessor !== prevProps.scatterplotXXaccessor || // was CLU now FTH1 etc
|
this.props.scatterplotXXaccessor !== prevProps.scatterplotXXaccessor || // was CLU now FTH1 etc
|
||||||
this.props.scatterplotYYaccessor !== prevProps.scatterplotYYaccessor
|
this.props.scatterplotYYaccessor !== prevProps.scatterplotYYaccessor
|
||||||
) {
|
) {
|
||||||
this.drawAxesSVG(this.state.xScale, this.state.yScale);
|
this.drawAxesSVG(this.state.xScale, this.state.yScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.state.xScale &&
|
this.state.xScale &&
|
||||||
this.state.yScale
|
this.state.yScale
|
||||||
) {
|
) {
|
||||||
drawScatterplotCanvas(
|
drawScatterplotCanvas(
|
||||||
this.state.ctx,
|
this.state.ctx,
|
||||||
this.state.xScale,
|
this.state.xScale,
|
||||||
this.state.yScale,
|
this.state.yScale,
|
||||||
this.props.currentCellSelection,
|
this.props.currentCellSelection,
|
||||||
this.props.opacityForDeselectedCells,
|
this.props.opacityForDeselectedCells,
|
||||||
@@ -106,7 +106,7 @@ class Scatterplot extends React.Component {
|
|||||||
return cell.e[nextProps.expression.data.genes.indexOf(nextProps.scatterplotYYaccessor)]
|
return cell.e[nextProps.expression.data.genes.indexOf(nextProps.scatterplotYYaccessor)]
|
||||||
}))
|
}))
|
||||||
.range([height, 0])
|
.range([height, 0])
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
xScale,
|
xScale,
|
||||||
yScale
|
yScale
|
||||||
@@ -114,7 +114,7 @@ class Scatterplot extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawAxesSVG(xScale, yScale) {
|
drawAxesSVG(xScale, yScale) {
|
||||||
|
|
||||||
this.state.svg.selectAll("*").remove();
|
this.state.svg.selectAll("*").remove();
|
||||||
|
|
||||||
// the axes are much cleaner and easier now. No need to rotate and orient the axis, just call axisBottom, axisLeft etc.
|
// the axes are much cleaner and easier now. No need to rotate and orient the axis, just call axisBottom, axisLeft etc.
|
||||||
@@ -123,7 +123,7 @@ class Scatterplot extends React.Component {
|
|||||||
|
|
||||||
var yAxis = d3.axisLeft()
|
var yAxis = d3.axisLeft()
|
||||||
.scale(yScale);
|
.scale(yScale);
|
||||||
|
|
||||||
// adding axes is also simpler now, just translate x-axis to (0,height) and it's alread defined to be a bottom axis.
|
// adding axes is also simpler now, just translate x-axis to (0,height) and it's alread defined to be a bottom axis.
|
||||||
this.state.svg.append('g')
|
this.state.svg.append('g')
|
||||||
.attr('transform', 'translate(0,' + height + ')')
|
.attr('transform', 'translate(0,' + height + ')')
|
||||||
@@ -149,21 +149,28 @@ class Scatterplot extends React.Component {
|
|||||||
.attr('text-anchor', 'end')
|
.attr('text-anchor', 'end')
|
||||||
.attr('class', 'label')
|
.attr('class', 'label')
|
||||||
.text(this.props.scatterplotXXaccessor);
|
.text(this.props.scatterplotXXaccessor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div id="scatterplot_wrapper">
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: "white",
|
||||||
|
borderRadius: 3,
|
||||||
|
marginTop: 15,
|
||||||
|
paddingBottom: 20,
|
||||||
|
boxShadow: "3px 4px 13px 0px rgba(201,201,201,1)",
|
||||||
|
}}
|
||||||
|
id="scatterplot_wrapper">
|
||||||
<div
|
<div
|
||||||
className={styles.scatterplot}
|
className={styles.scatterplot}
|
||||||
id="scatterplot"
|
id="scatterplot"
|
||||||
style={{
|
style={{
|
||||||
width: width + margin.left + margin.right + "px",
|
width: width + margin.left + margin.right + "px",
|
||||||
height: height + margin.top + margin.bottom + "px",
|
height: height + margin.top + margin.bottom + "px",
|
||||||
marginBottom: 60
|
|
||||||
}}
|
}}
|
||||||
>scatter</div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ const setupScatterplot = (
|
|||||||
.attr("height", height * devicePixelRatio)
|
.attr("height", height * devicePixelRatio)
|
||||||
.style("width", width + "px")
|
.style("width", width + "px")
|
||||||
.style("height", height + "px")
|
.style("height", height + "px")
|
||||||
.style("margin-left", 10 + 3 + "px") /* magic number: this seems to be visually correct when it is equal to the amount axis is translated by plus or minus... a little? */
|
.style("margin-left", margin.left + 1 + "px") /* magic number: this seems to be visually correct when it is equal to the amount axis is translated by plus or minus... a little? */
|
||||||
.style("margin-top", margin.top + margin.bottom - 2 + "px")
|
.style("margin-top", margin.top + "px")
|
||||||
|
|
||||||
var ctx = canvas.node().getContext("2d");
|
var ctx = canvas.node().getContext("2d");
|
||||||
ctx.globalCompositeOperation = 'darken';
|
ctx.globalCompositeOperation = 'darken';
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
||||||
const paddingRight = 120;
|
const paddingRight = 120;
|
||||||
const continuousChartWidth = 1200;
|
const continuousChartWidth = 340;
|
||||||
|
|
||||||
export const margin = {top: 66, right: 110, bottom: 20, left: 60};
|
export const margin = {top: 66, right: 110, bottom: 20, left: 60};
|
||||||
export const width = continuousChartWidth - margin.left - margin.right - paddingRight;
|
export const width = 340;
|
||||||
export const height = 680 - margin.top - margin.bottom;
|
export const height = 340 - margin.top - margin.bottom;
|
||||||
export const innerHeight = height - 2;
|
export const innerHeight = height - 2;
|
||||||
|
|
||||||
export const devicePixelRatio = window.devicePixelRatio || 1;
|
export const devicePixelRatio = window.devicePixelRatio || 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user