From dcfa1bafb0d60273bc179ab55bb2a4eb4c84d1b4 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Tue, 1 Sep 2015 14:48:48 +1000 Subject: [PATCH 1/2] INT-407 round down probability for type bars to provent line break in type distribution bars, e.g. with a distribution of [50, 16.666, 16.666, 16.666] which would round to [50, 17, 17, 17] and sum up to 101%. --- src/field-list/type-list-item.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/field-list/type-list-item.js b/src/field-list/type-list-item.js index b03c3a487bf..cb19f1e71e2 100644 --- a/src/field-list/type-list-item.js +++ b/src/field-list/type-list-item.js @@ -38,7 +38,8 @@ module.exports = View.extend(tooltipMixin, { probability_percentage: { deps: ['model.probability'], fn: function() { - return numeral(this.model.probability).format('0.00%'); + // round down probability so that the bar widths can never sum up to > 100% + return numeral(Math.floor(this.model.probability * 100.0) / 100.0).format('0.00%'); } }, tooltip_message: { From 931cb71826dab97ddc68afdf111aff4e455da7ba Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Tue, 1 Sep 2015 15:08:59 +1000 Subject: [PATCH 2/2] even better, use exact values for percentages, the browser will do the right thing. --- src/field-list/type-list-item.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/field-list/type-list-item.js b/src/field-list/type-list-item.js index cb19f1e71e2..9e810405e14 100644 --- a/src/field-list/type-list-item.js +++ b/src/field-list/type-list-item.js @@ -38,8 +38,8 @@ module.exports = View.extend(tooltipMixin, { probability_percentage: { deps: ['model.probability'], fn: function() { - // round down probability so that the bar widths can never sum up to > 100% - return numeral(Math.floor(this.model.probability * 100.0) / 100.0).format('0.00%'); + // no rounding, use exact proportions for relative widths + return this.model.probability * 100 + '%'; } }, tooltip_message: {