From 924b518492322a64a6bc0ce343b7aa3f362f049d Mon Sep 17 00:00:00 2001 From: Severiano Badajoz Date: Tue, 27 Oct 2020 17:12:13 -0700 Subject: [PATCH] Revert "Remove Continuous vars with 1 value from histogram, add to info drawer (#1927)" (#1953) This reverts commit 242546371b643031d99f3be8fab3ba05f80bc1f4. --- .../components/brushableHistogram/index.js | 36 +++---------------- .../src/components/infoDrawer/infoDrawer.js | 18 +++------- .../src/components/infoDrawer/infoFormat.js | 10 +++--- client/src/reducers/index.js | 3 +- client/src/reducers/singleContinuousValue.js | 14 -------- 5 files changed, 16 insertions(+), 65 deletions(-) delete mode 100644 client/src/reducers/singleContinuousValue.js diff --git a/client/src/components/brushableHistogram/index.js b/client/src/components/brushableHistogram/index.js index e7c6432c..a18608b2 100644 --- a/client/src/components/brushableHistogram/index.js +++ b/client/src/components/brushableHistogram/index.js @@ -450,7 +450,6 @@ const Histogram = ({ isScatterplotYYaccessor: state.controls.scatterplotYYaccessor === field, continuousSelectionRange: state.continuousSelection[myName], isColorAccessor: state.colors.colorAccessor === field, - singleContinuousValues: state.singleContinuousValue.singleContinuousValues, }; }) class HistogramBrush extends React.PureComponent { @@ -609,44 +608,18 @@ class HistogramBrush extends React.PureComponent { }; fetchAsyncProps = async () => { - const { annoMatrix, field, dispatch, singleContinuousValues } = this.props; + const { annoMatrix } = this.props; const { isClipped } = annoMatrix; - if (singleContinuousValues.has(field)) { - return { - histogram: undefined, - range: undefined, - unclippedRange: undefined, - unclippedRangeColor: globals.blue, - isSingleValue: true, - OK2Render: false, - }; - } + const query = this.createQuery(); const df = await annoMatrix.fetch(...query); const column = df.icol(0); + // if we are clipped, fetch both our value and our unclipped value, + // as we need the absolute min/max range, not just the clipped min/max. const summary = column.summarize(); const range = [summary.min, summary.max]; - if (summary.min === summary.max && !isClipped) { - dispatch({ - type: "add single continuous value", - field, - value: summary.min, - }); - return { - histogram: undefined, - range, - unclippedRange: range, - unclippedRangeColor: globals.blue, - isSingleValue: true, - OK2Render: false, - }; - } - - const isSingleValue = summary.min === summary.max; - // if we are clipped, fetch both our value and our unclipped value, - // as we need the absolute min/max range, not just the clipped min/max. let unclippedRange = [...range]; if (isClipped) { const parent = await annoMatrix.viewOf.fetch(...query); @@ -670,6 +643,7 @@ class HistogramBrush extends React.PureComponent { this.height ); + const isSingleValue = summary.min === summary.max; const nonFiniteExtent = summary.min === undefined || summary.max === undefined || diff --git a/client/src/components/infoDrawer/infoDrawer.js b/client/src/components/infoDrawer/infoDrawer.js index aad395bc..9f41ef14 100644 --- a/client/src/components/infoDrawer/infoDrawer.js +++ b/client/src/components/infoDrawer/infoDrawer.js @@ -1,6 +1,7 @@ import React, { PureComponent } from "react"; -import { connect, shallowEqual } from "react-redux"; +import { connect } from "react-redux"; import { Drawer } from "@blueprintjs/core"; + import InfoFormat from "./infoFormat"; import { selectableCategoryNames } from "../../util/stateManager/controlsHelpers"; @@ -12,14 +13,9 @@ import { selectableCategoryNames } from "../../util/stateManager/controlsHelpers aboutURL: state.config?.links?.["about-dataset"], isOpen: state.controls.datasetDrawer, dataPortalProps: state.config?.["corpora_props"] ?? {}, - singleContinuousValues: state.singleContinuousValue.singleContinuousValues, }; }) class InfoDrawer extends PureComponent { - static watchAsync(props, prevProps) { - return !shallowEqual(props.watchProps, prevProps.watchProps); - } - handleClose = () => { const { dispatch } = this.props; @@ -34,22 +30,18 @@ class InfoDrawer extends PureComponent { schema, isOpen, dataPortalProps, - singleContinuousValues, } = this.props; const allCategoryNames = selectableCategoryNames(schema).sort(); - const allSingleValues = new Map(); + const singleValueCategories = new Map(); allCategoryNames.forEach((catName) => { const isUserAnno = schema?.annotations?.obsByName[catName]?.writable; const colSchema = schema.annotations.obsByName[catName]; if (!isUserAnno && colSchema.categories?.length === 1) { - allSingleValues.set(catName, colSchema.categories[0]); + singleValueCategories.set(catName, colSchema.categories[0]); } }); - singleContinuousValues.forEach((value, catName) => { - allSingleValues.set(catName, value); - }); return ( diff --git a/client/src/components/infoDrawer/infoFormat.js b/client/src/components/infoDrawer/infoFormat.js index 04de063b..6909e7cf 100644 --- a/client/src/components/infoDrawer/infoFormat.js +++ b/client/src/components/infoDrawer/infoFormat.js @@ -85,13 +85,13 @@ const ONTOLOGY_KEY = "ontology_term_id"; const CAT_WIDTH = "30%"; const VAL_WIDTH = "35%"; // Render list of metadata attributes found in categorical field -const renderSingleValues = (singleValues) => { - if (singleValues.size === 0) return null; +const renderSingleValueCategories = (singleValueCategories) => { + if (singleValueCategories.size === 0) return null; return ( <>

Dataset Metadata