import React from "react"; import _ from "lodash"; import Helmet from "react-helmet"; import Container from "./framework/container"; import buttonStyles from "./framework/buttons.css"; import { connect } from "react-redux"; import PulseLoader from "halogen/PulseLoader"; import Categorical from "./categorical/categorical"; import Continuous from "./continuous/continuous"; import Joy from "./joy/joy"; import Graph from "./graph/graph"; import * as globals from "../globals"; import * as actions from "../actions"; import SectionHeader from "./framework/sectionHeader"; @connect((state) => { return { cells: state.cells } }) class Home extends React.Component { constructor(props) { super(props); this.state = { }; } _onURLChanged () { this.props.dispatch({type: 'url changed', url: document.location.href}); }; componentDidMount() { /* listen for url changes, fire one when we start the app up */ window.addEventListener('popstate', this._onURLChanged); this._onURLChanged(); this.props.dispatch(actions.requestCells()) } createExpressionsCountsMap () { const CHANGE_ME_MAGIC_GENE_INDEX = 5; const expressionsCountsMap = {}; /* currently selected gene */ expressionsCountsMap.geneName = this.state.expressions.data.genes[3]; let maxExpressionValue = 0; /* create map of expressions for every cell */ this.state.expressions.data.cells.map((c) => { /* cellname = 234 */ expressionsCountsMap[c.cellname] = c["e"][CHANGE_ME_MAGIC_GENE_INDEX]; /* collect the maximum value as we iterate */ if (c["e"][CHANGE_ME_MAGIC_GENE_INDEX] > maxExpressionValue) { maxExpressionValue = c["e"][CHANGE_ME_MAGIC_GENE_INDEX] } }) expressionsCountsMap.maxValue = maxExpressionValue; return expressionsCountsMap; } render() { // console.log('app:', this.props, this.state) return ( { this.props.cells.loading ?
loading cells
: null } {this.props.cells.error ? "Error loading cells" : null} {false ? : ""}
) } }; export default Home;