mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-04 05:58:12 +08:00
add d3 and scale chromatic imports
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
// jshint esversion: 6
|
// jshint esversion: 6
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
|
||||||
const paddingRight = 120;
|
const paddingRight = 120;
|
||||||
const continuousChartWidth = 1200;
|
const continuousChartWidth = 1200;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import React from "react";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import * as globals from "../../globals";
|
import * as globals from "../../globals";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
import { interpolateViridis } from "d3-scale-chromatic";
|
||||||
|
|
||||||
// create continuous color legend
|
// create continuous color legend
|
||||||
// http://bl.ocks.org/syntagmatic/e8ccca52559796be775553b467593a9f
|
// http://bl.ocks.org/syntagmatic/e8ccca52559796be775553b467593a9f
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import actions from "../../actions";
|
|||||||
import ReactAutocomplete from "react-autocomplete"; /* http://emilebres.github.io/react-virtualized-checkbox/ */
|
import ReactAutocomplete from "react-autocomplete"; /* http://emilebres.github.io/react-virtualized-checkbox/ */
|
||||||
import getContrast from "font-color-contrast"; // https://www.npmjs.com/package/font-color-contrast
|
import getContrast from "font-color-contrast"; // https://www.npmjs.com/package/font-color-contrast
|
||||||
import FaPaintBrush from "react-icons/lib/fa/paint-brush";
|
import FaPaintBrush from "react-icons/lib/fa/paint-brush";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
import { interpolateGreys } from "d3-scale-chromatic";
|
||||||
|
|
||||||
class HeatmapSquare extends React.Component {
|
class HeatmapSquare extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -121,15 +123,13 @@ class HeatmapRow extends React.Component {
|
|||||||
style={{
|
style={{
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
marginRight: 10,
|
marginRight: 10
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{this.props.aveDiff.toFixed(2)}
|
{this.props.aveDiff.toFixed(2)}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
onClick={this.handleSetGeneAsScatterplotX(this.props.gene).bind(
|
onClick={this.handleSetGeneAsScatterplotX(this.props.gene).bind(this)}
|
||||||
this
|
|
||||||
)}
|
|
||||||
style={{
|
style={{
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color:
|
color:
|
||||||
@@ -152,9 +152,7 @@ class HeatmapRow extends React.Component {
|
|||||||
X
|
X
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
onClick={this.handleSetGeneAsScatterplotY(this.props.gene).bind(
|
onClick={this.handleSetGeneAsScatterplotY(this.props.gene).bind(this)}
|
||||||
this
|
|
||||||
)}
|
|
||||||
style={{
|
style={{
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color:
|
color:
|
||||||
@@ -242,7 +240,7 @@ class Heatmap extends React.Component {
|
|||||||
const greyColorScale = d3
|
const greyColorScale = d3
|
||||||
.scaleSequential()
|
.scaleSequential()
|
||||||
.domain(extent)
|
.domain(extent)
|
||||||
.interpolator(d3.interpolateGreys);
|
.interpolator(interpolateGreys);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { setupSVGandBrushElements } from "./setupSVGandBrush";
|
|||||||
import SectionHeader from "../framework/sectionHeader";
|
import SectionHeader from "../framework/sectionHeader";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import actions from "../../actions";
|
import actions from "../../actions";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
|
||||||
import mat4 from "gl-mat4";
|
import mat4 from "gl-mat4";
|
||||||
import fit from "canvas-fit";
|
import fit from "canvas-fit";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import styles from "./graph.css";
|
import styles from "./graph.css";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import * as globals from "../../globals";
|
import * as globals from "../../globals";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
*******************************************
|
*******************************************
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { connect } from "react-redux";
|
|||||||
import scatterplot from "./scatterplot";
|
import scatterplot from "./scatterplot";
|
||||||
import setupScatterplot from "./setupScatterplot";
|
import setupScatterplot from "./setupScatterplot";
|
||||||
import styles from "./scatterplot.css";
|
import styles from "./scatterplot.css";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
|
||||||
import mat4 from "gl-mat4";
|
import mat4 from "gl-mat4";
|
||||||
import fit from "canvas-fit";
|
import fit from "canvas-fit";
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
******************************************
|
******************************************
|
||||||
******************************************/
|
******************************************/
|
||||||
|
|
||||||
|
import * as d3 from "d3";
|
||||||
|
|
||||||
const setupScatterplot = (width, height, margin) => {
|
const setupScatterplot = (width, height, margin) => {
|
||||||
var container = d3.select("#scatterplot");
|
var container = d3.select("#scatterplot");
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import uri from "urijs";
|
|||||||
import * as globals from "../globals";
|
import * as globals from "../globals";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { parseRGB } from "../util/parseRGB";
|
import { parseRGB } from "../util/parseRGB";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
import { interpolateViridis } from "d3-scale-chromatic";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
https://medium.com/@jacobp100/you-arent-using-redux-middleware-enough-94ffe991e6
|
https://medium.com/@jacobp100/you-arent-using-redux-middleware-enough-94ffe991e6
|
||||||
@@ -67,7 +69,7 @@ const updateCellColorsMiddleware = store => {
|
|||||||
.range([1, 0]);
|
.range([1, 0]);
|
||||||
|
|
||||||
_.each(cellsMetadataWithUpdatedColors, (cell, i) => {
|
_.each(cellsMetadataWithUpdatedColors, (cell, i) => {
|
||||||
let c = d3.interpolateViridis(colorScale(cell[action.colorAccessor]));
|
let c = interpolateViridis(colorScale(cell[action.colorAccessor]));
|
||||||
cellsMetadataWithUpdatedColors[i]["__color__"] = c;
|
cellsMetadataWithUpdatedColors[i]["__color__"] = c;
|
||||||
cellsMetadataWithUpdatedColors[i]["__colorRGB__"] = parseRGB(c);
|
cellsMetadataWithUpdatedColors[i]["__colorRGB__"] = parseRGB(c);
|
||||||
});
|
});
|
||||||
@@ -112,7 +114,7 @@ const updateCellColorsMiddleware = store => {
|
|||||||
]); /* invert viridis... probably pass this scale through to others */
|
]); /* invert viridis... probably pass this scale through to others */
|
||||||
|
|
||||||
_.each(cellsMetadataWithUpdatedColors, (cell, i) => {
|
_.each(cellsMetadataWithUpdatedColors, (cell, i) => {
|
||||||
let c = d3.interpolateViridis(
|
let c = interpolateViridis(
|
||||||
colorScale(expressionMap[cell.CellName][indexOfGene])
|
colorScale(expressionMap[cell.CellName][indexOfGene])
|
||||||
);
|
);
|
||||||
cellsMetadataWithUpdatedColors[i]["__color__"] = c;
|
cellsMetadataWithUpdatedColors[i]["__color__"] = c;
|
||||||
|
|||||||
Reference in New Issue
Block a user