+
+ These histograms show the distribution of{" "}
+ {colorAccessor} within each category.
+
+ The x axis is the same for each histogram, while the y axis is
+ scaled to the highest bin within each histogram.
+
+
+
);
}
}
diff --git a/client/src/components/categorical/value.js b/client/src/components/categorical/value.js
index b538e611..9a50698b 100644
--- a/client/src/components/categorical/value.js
+++ b/client/src/components/categorical/value.js
@@ -2,7 +2,6 @@
import { connect } from "react-redux";
import React from "react";
import Occupancy from "./occupancy";
-import { countCategoryValues2D } from "../../util/stateManager/worldUtil";
import * as globals from "../../globals";
@connect(state => ({
@@ -22,6 +21,33 @@ class CategoryValue extends React.Component {
});
};
+ shouldComponentUpdate = nextProps => {
+ /*
+ Checks to see if at least one of the following changed:
+ * world state
+ * the color accessor (what is currently being colored by)
+ * if this catagorical value's selection status has changed
+
+ If and only if true, update the component
+ */
+ const { props } = this;
+ const { metadataField, categoryIndex, categoricalSelection } = props;
+ const { categoricalSelection: newCategoricalSelection } = nextProps;
+
+ const valueSelectionChange =
+ categoricalSelection[metadataField].categoryValueSelected[
+ categoryIndex
+ ] !==
+ newCategoricalSelection[metadataField].categoryValueSelected[
+ categoryIndex
+ ];
+
+ const worldChange = props.world !== nextProps.world;
+ const colorAccessorChange = props.colorAccessor !== nextProps.colorAccessor;
+
+ return valueSelectionChange || worldChange || colorAccessorChange;
+ };
+
toggleOn = () => {
const { dispatch, metadataField, categoryIndex } = this.props;
dispatch({
@@ -57,8 +83,7 @@ class CategoryValue extends React.Component {
colorAccessor,
colorScale,
i,
- schema,
- world
+ schema
} = this.props;
if (!categoricalSelection) return null;
@@ -74,20 +99,11 @@ class CategoryValue extends React.Component {
/* this is the color scale, so add swatches below */
const isColorBy = metadataField === colorAccessor;
let categories = null;
- let occupancy = null;
if (isColorBy && schema) {
categories = schema.annotations.obsByName[colorAccessor]?.categories;
}
- if (colorAccessor && !isColorBy && categoricalSelection[colorAccessor]) {
- occupancy = countCategoryValues2D(
- metadataField,
- colorAccessor,
- world.obsAnnotations
- );
- }
-
return (