Skip to content

Commit 185d2a2

Browse files
authored
COMPASS-1389 Backport COMPASS-907 when close to 0 or 100% show 1 decimal point accuracy (#1135) (#1140)
1 parent b54a68f commit 185d2a2

File tree

1 file changed

+5
-1
lines changed
  • src/internal-packages/schema/lib/component

1 file changed

+5
-1
lines changed

src/internal-packages/schema/lib/component/type.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ class Type extends React.Component {
103103
};
104104
const subtypes = this._getArraySubTypes();
105105
const label = <span className="schema-field-type-label">{this.props.name}</span>;
106-
const tooltipText = `${this.props.name} (${numeral(this.props.probability).format('0%')})`;
106+
// show integer accuracy by default, but show one decimal point accuracy
107+
// when less than 1% or greater than 99% but no 0% or 100%
108+
const format = (this.props.probability > 0.99 && this.props.probability < 1.0)
109+
|| (this.props.probability > 0 && this.props.probability < 0.01) ? '0.0%' : '0%';
110+
const tooltipText = `${this.props.name} (${numeral(this.props.probability).format(format)})`;
107111
const tooltipOptions = {
108112
'data-for': TOOLTIP_IDS.SCHEMA_PROBABILITY_PERCENT,
109113
'data-tip': tooltipText,

0 commit comments

Comments
 (0)