From 8f744326b2519665350609f53f7e71e0b9cc9740 Mon Sep 17 00:00:00 2001 From: slice Date: Fri, 13 Jul 2018 19:54:05 -0700 Subject: [PATCH] prevent duplicate ticks on x axis --- priv/frontend/src/components/Graph.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/priv/frontend/src/components/Graph.js b/priv/frontend/src/components/Graph.js index c50167b..c8a1c5e 100644 --- a/priv/frontend/src/components/Graph.js +++ b/priv/frontend/src/components/Graph.js @@ -60,6 +60,8 @@ export default class Graph extends Component { tickSize: 0, }; + const minutesAllocated = []; + return (
{ const interval = this.isSmallScreen() ? 7 : 5; const minutesAgo = Math.floor((Date.now() - epoch) / (1000 * 60)); - if (minutesAgo % interval !== 0 || minutesAgo === 0) { - return undefined; + + if (minutesAgo % interval !== 0 || minutesAgo === 0 + || minutesAllocated.includes(minutesAgo)) { + return ''; } + minutesAllocated.push(minutesAgo); return ms(Date.now() - epoch); }, tickSize: 0,