prevent duplicate ticks on x axis

This commit is contained in:
slice 2018-07-13 19:54:05 -07:00
parent b525404d9b
commit 8f744326b2
No known key found for this signature in database
GPG Key ID: 1508C19D7436A26D
1 changed files with 7 additions and 2 deletions

View File

@ -60,6 +60,8 @@ export default class Graph extends Component {
tickSize: 0,
};
const minutesAllocated = [];
return (
<div className="graph-container">
<ResponsiveLine
@ -76,10 +78,13 @@ export default class Graph extends Component {
format: (epoch) => {
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,