Skip to content

Commit

Permalink
Merge pull request #240 from beejunk/issue-238
Browse files Browse the repository at this point in the history
[#238] Updates date-fns formats to fix rank graph
  • Loading branch information
leeschumacher authored Aug 21, 2020
2 parents fac3192 + 3be94f0 commit f9aa7d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/model/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function parseRankGraph(data: Array<number>): RankGraph {
// Create a list of the unique months present in the graph data for labeling
newRankGraph.months = [];
series.forEach((d) => {
let str = dateFormat(d.x, "MMMM YYYY");
let str = dateFormat(d.x, "MMMM yyyy");
if (newRankGraph.months.indexOf(str) === -1) {
newRankGraph.months.push(str);
}
Expand Down
10 changes: 5 additions & 5 deletions src/ui/user/UserRankGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ export default class UserRankGraph extends Component<Props> {
divisor: series.length,
labelInterpolationFnc: function (value, index) {
const d = new Date(value);
const day = dateFormat(d, "DD");
const day = dateFormat(d, "dd");
const month = dateFormat(d, "MMM");

// When we have multiple months of rank data
if (months.length > 2) {
// Only show the year for January and the first month on
// the graph
const format = index < 31 || month === "Jan" ? "MMM YYYY" : "MMM";
const format = index < 31 || month === "Jan" ? "MMM yyy" : "MMM";

// Show the label only on the first day of the month
return day === "01" ? dateFormat(d, format) : null;
Expand All @@ -89,12 +89,12 @@ export default class UserRankGraph extends Component<Props> {
let ratio = series.length / ticks;

if (index === 0) {
format = "MMM D, YYYY";
format = "MMM d, yyyy";
} else {
if (day === "01") {
format = "MMM D";
format = "MMM d";
} else {
format = "MMM D";
format = "MMM d";
}
}
return Math.floor(index % ratio) === 0
Expand Down

0 comments on commit f9aa7d1

Please sign in to comment.