add point dilatation on hover (#841)

* enable centroid

* introduce new sizing

* scale point size based off hovered category

* add styling

* fix margins

* disable centroid labels

* remove unused code and add detail to comment

* remove cell dilation on selection toggle

* move hover to name label

* hover on value except for checkbox

* add border radius to value
This commit is contained in:
Severiano Badajoz
2019-07-11 15:33:44 -07:00
committed by GitHub
parent ca20add577
commit 9f0f60b5eb
3 changed files with 45 additions and 15 deletions
@@ -0,0 +1,3 @@
:local(.value):hover {
background: rgba(167, 182, 194, 0.3);
}
+15 -6
View File
@@ -3,6 +3,7 @@ import { connect } from "react-redux";
import React from "react"; import React from "react";
import Occupancy from "./occupancy"; import Occupancy from "./occupancy";
import * as globals from "../../globals"; import * as globals from "../../globals";
import styles from "./categorical.css";
@connect(state => ({ @connect(state => ({
categoricalSelection: state.categoricalSelection, categoricalSelection: state.categoricalSelection,
@@ -107,14 +108,18 @@ class CategoryValue extends React.Component {
return ( return (
<div <div
key={i} key={i}
className={styles.value}
data-testclass="categorical-row"
style={{ style={{
padding: "4px 7px",
display: "flex", display: "flex",
alignItems: "baseline", alignItems: "baseline",
justifyContent: "space-between" justifyContent: "space-between",
marginBottom: "2px",
borderRadius: "2px"
}} }}
data-testclass="categorical-row" onMouseEnter={this.handleMouseEnter}
onMouseEnter={null /* this.handleMouseEnter */} onMouseLeave={this.handleMouseExit}
onMouseLeave={null /* this.handleMouseLeave */}
> >
<div <div
style={{ style={{
@@ -126,7 +131,7 @@ class CategoryValue extends React.Component {
justifyContent: "space-between" justifyContent: "space-between"
}} }}
> >
<label className="bp3-control bp3-checkbox"> <label className="bp3-control bp3-checkbox" style={{ margin: 0 }}>
<input <input
onChange={selected ? this.toggleOff : this.toggleOn} onChange={selected ? this.toggleOff : this.toggleOn}
data-testclass="categorical-value-select" data-testclass="categorical-value-select"
@@ -134,7 +139,11 @@ class CategoryValue extends React.Component {
checked={selected} checked={selected}
type="checkbox" type="checkbox"
/> />
<span className="bp3-control-indicator" /> <span
className="bp3-control-indicator"
onMouseEnter={this.handleMouseExit}
onMouseLeave={this.handleMouseEnter}
/>
<span <span
data-testid={`categorical-value-${metadataField}-${displayString}`} data-testid={`categorical-value-${metadataField}-${displayString}`}
data-testclass="categorical-value" data-testclass="categorical-value"
+27 -9
View File
@@ -52,14 +52,27 @@ class Graph extends React.Component {
return colors; return colors;
}); });
computePointSizes = memoize((len, crossfilter) => { computePointSizes = memoize(
/* (len, crossfilter, metadataField, categoryField) => {
/*
compute webgl dot size for each point compute webgl dot size for each point
*/ */
const sizes = new Float32Array(len);
crossfilter.fillByIsSelected(sizes, 4, 0.2); const sizes = new Float32Array(len);
return sizes; crossfilter.fillByIsSelected(sizes, 4, 0.2);
});
if (metadataField && categoryField) {
const valuesArr = crossfilter.data.col(metadataField).asArray();
for (let i = 0; i < len; i += 1) {
if (valuesArr[i] === categoryField) {
sizes[i] = 10;
}
}
}
return sizes;
}
);
constructor(props) { constructor(props) {
super(props); super(props);
@@ -203,7 +216,13 @@ class Graph extends React.Component {
} }
/* sizes for each point */ /* sizes for each point */
const newSizes = this.computePointSizes(nObs, crossfilter); const { metadataField, categoryField } = centroidLabel;
const newSizes = this.computePointSizes(
nObs,
crossfilter,
metadataField,
categoryField
);
if (renderCache.sizes !== newSizes) { if (renderCache.sizes !== newSizes) {
/* update our cache & GL if the buffer changes */ /* update our cache & GL if the buffer changes */
renderCache.size = newSizes; renderCache.size = newSizes;
@@ -279,13 +298,13 @@ class Graph extends React.Component {
stateChanges = { ...stateChanges, centroidSVG: newCentroidSVG }; stateChanges = { ...stateChanges, centroidSVG: newCentroidSVG };
}; };
// Centroid SVG creation is disabled for now but should go into the first and third cases if enabled
if ( if (
prevProps.responsive.height !== responsive.height || prevProps.responsive.height !== responsive.height ||
prevProps.responsive.width !== responsive.width prevProps.responsive.width !== responsive.width
) { ) {
// If the window size has changed we want to recreate all SVGs // If the window size has changed we want to recreate all SVGs
createToolSVG(); createToolSVG();
createCentroidSVG();
} else if ( } else if (
(responsive.height && responsive.width && !toolSVG) || (responsive.height && responsive.width && !toolSVG) ||
selectionTool !== prevProps.selectionTool || selectionTool !== prevProps.selectionTool ||
@@ -298,7 +317,6 @@ class Graph extends React.Component {
(responsive.height && responsive.width && !centroidSVG) (responsive.height && responsive.width && !centroidSVG)
) { ) {
// First time for centroid or label change // First time for centroid or label change
createCentroidSVG();
} }
/* /*