Skip to content

Commit

Permalink
[Feature] Handle small/zero metric values in charts
Browse files Browse the repository at this point in the history
  • Loading branch information
levinmr committed Jun 28, 2024
1 parent cb47f25 commit 87bebba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/bundle.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/components/main_charts/RealtimeVisitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function RealtimeVisitors({ dataHrefBase, agency }) {
.call(
renderBlock.loadAndRender().render((selection, data) => {
const totals = data.data[0];
selection.text(formatters.addCommas(+totals.active_visitors));
selection.text(
totals ? formatters.addCommas(+totals.active_visitors) : 0,
);
}),
);
return result;
Expand Down
11 changes: 7 additions & 4 deletions js/components/main_charts/TopCountriesRealtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ function TopCountriesRealtime({ dataHrefBase }) {
}
});
const international = totalVisits - USVisits;
const data = {
"United States & Territories": USVisits,
International: international,
};
const data = {};
if (USVisits) {
data["United States & Territories"] = USVisits;
}
if (international) {
data["International"] = international;
}
return transformers.findProportionsOfMetricFromValue(
transformers.listify(data),
);
Expand Down

0 comments on commit 87bebba

Please sign in to comment.