Skip to content

Commit

Permalink
UI fix on d3 chart y axis format and kg chart default height (#264)
Browse files Browse the repository at this point in the history
- Show original number when y tick is less than 1 to avoid showing 0.5 as 500m.
- Make default "show more" height larger so the "show more" box is hidden in chart view.
  • Loading branch information
shifucun authored Aug 7, 2020
1 parent ff8bc05 commit 7b2e708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion static/js/chart/draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ function addYAxis(
yticks[1] - yticks[0],
yticks[yticks.length - 1]
);
const tText = d3.formatPrefix(`.${p}`, yScale.domain()[1])(d);
let tText = String(d);
// When the y value is less than one, use the original value.
// Otherwise 0.3 is formatted into 300m which is confusing to 300M.
if (d > 1) {
tText = d3.formatPrefix(`.${p}`, yScale.domain()[1])(d);
}
const dollar = unit === "$" ? "$" : "";
const percent = unit === "%" ? "%" : "";
return `${dollar}${tText}${percent}`;
Expand Down
2 changes: 1 addition & 1 deletion static/js/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const POPULATION = "StatisticalPopulation";
const OBSERVATION = "Observation";
const COMPARATIVE_OBSERVATION = "ComparativeObservation";

const MAX_CARD_HEIGHT = 400;
const MAX_CARD_HEIGHT = 450;

const /** !Array<string> */ STATS = [
"measuredValue",
Expand Down

0 comments on commit 7b2e708

Please sign in to comment.