prevent duplicate ticks on x axis
This commit is contained in:
parent
b525404d9b
commit
8f744326b2
1 changed files with 7 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue