diff --git a/client/src/components/categorical/value.js b/client/src/components/categorical/value.js index c5a2b8d8..8eec1462 100644 --- a/client/src/components/categorical/value.js +++ b/client/src/components/categorical/value.js @@ -15,6 +15,7 @@ import { import Occupancy from "./occupancy"; import * as globals from "../../globals"; import styles from "./categorical.css"; +import { Tooltip } from "@blueprintjs/core"; @connect(state => ({ categoricalSelection: state.categoricalSelection, @@ -203,6 +204,30 @@ class CategoryValue extends React.Component { categories = schema.annotations.obsByName[colorAccessor]?.categories; } + let truncatedString = null; + + if ( + colorAccessor && + !isColorBy && + displayString.length > globals.categoryLabelDisplayStringShortLength + ) { + truncatedString = `${displayString.slice( + 0, + globals.categoryLabelDisplayStringShortLength / 2 + )}…${displayString.slice( + -globals.categoryLabelDisplayStringShortLength / 2 + )}`; + } else if ( + displayString.length > globals.categoryLabelDisplayStringLongLength + ) { + truncatedString = `${displayString.slice( + 0, + globals.categoryLabelDisplayStringLongLength / 2 + )}…${displayString.slice( + -globals.categoryLabelDisplayStringLongLength / 2 + )}`; + } + return (