Skip to content

Commit

Permalink
Fix color by genotype after entropy click
Browse files Browse the repository at this point in the history
This additionally populates the text box after entropy click
  • Loading branch information
trvrb committed Feb 2, 2017
1 parent cdd96f3 commit 188fb9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class App extends React.Component {
sidebar={this.state.sidebarOpen || this.state.sidebarDocked}
changeRoute={this.changeRoute.bind(this)}
location={this.state.location}
router={this.props.router}
/>
</Background>
</Sidebar>
Expand Down
12 changes: 5 additions & 7 deletions src/components/charts/entropy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Card from "../framework/card";
import d3 from "d3";
import { parseGenotype } from "../../util/getGenotype";
import computeResponsive from "../../util/computeResponsive";
import { changeColorBy } from "../../actions/controls";

@connect(state => {
return {
Expand All @@ -22,13 +23,10 @@ class Entropy extends React.Component {
/* check here to see if this.props.browserDimensions has changed and rerender */
}

setColorByQuery(colorBy) {
const newQuery = Object.assign({}, this.props.location.query,
{colorBy: colorBy});
this.props.changeRoute(this.props.location.pathname, newQuery);
setColorByGenotype(colorBy) {
this.props.dispatch(changeColorBy(colorBy, this.props.router))
}


drawEntropy() {
const responsive = computeResponsive({
horizontal: 1,
Expand Down Expand Up @@ -116,7 +114,7 @@ class Entropy extends React.Component {
y={y(e.y)}
width="1" height={y(0) - y(e.y)}
cursor={"pointer"}
onClick={() => {this.setColorByQuery("gt-nuc_" + (e.x + 1));}}
onClick={() => {this.setColorByGenotype("gt-nuc_" + (e.x + 1));}}
fill={"#CCC"}
stroke={"#CCC"}
/>
Expand All @@ -130,7 +128,7 @@ class Entropy extends React.Component {
y={y(e.y)}
width="2.5" height={y(0) - y(e.y)}
cursor={"pointer"}
onClick={() => {this.setColorByQuery("gt-" + e.prot + "_" + (e.codon + 1));}}
onClick={() => {this.setColorByGenotype("gt-" + e.prot + "_" + (e.codon + 1));}}
fill={e.fill}
stroke={"#CCC"}
/>
Expand Down
11 changes: 7 additions & 4 deletions src/components/controls/color-by.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ class ColorBy extends React.Component {
}

genotypeInput() {
let placeholder = "Genome position";
if (this.props.colorBy) {
if (this.props.colorBy.slice(0,2) === "gt") {
placeholder = this.props.colorBy.slice(3);
}
}
if (this.state.selected === "gt") {
return (
<input type="text" placeholder="Genome position"
<input type="text" placeholder={placeholder}
onChange={(e) => this.setGenotypeColorBy(e.target.value)}
/>
);
Expand All @@ -69,9 +75,6 @@ class ColorBy extends React.Component {
}

setGenotypeColorBy(genotype) {
console.log("setGenotypeColorBy");
console.log("genotype");
console.log(genotype);
if (parseGenotype("gt-" + genotype, this.props.geneLength)) {
// We got a valid genotype, set query params and state
this.props.dispatch(changeColorBy("gt-" + genotype, this.props.router))
Expand Down

0 comments on commit 188fb9a

Please sign in to comment.