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,
|
tickSize: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const minutesAllocated = [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="graph-container">
|
<div className="graph-container">
|
||||||
<ResponsiveLine
|
<ResponsiveLine
|
||||||
|
@ -76,10 +78,13 @@ export default class Graph extends Component {
|
||||||
format: (epoch) => {
|
format: (epoch) => {
|
||||||
const interval = this.isSmallScreen() ? 7 : 5;
|
const interval = this.isSmallScreen() ? 7 : 5;
|
||||||
const minutesAgo = Math.floor((Date.now() - epoch) / (1000 * 60));
|
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);
|
return ms(Date.now() - epoch);
|
||||||
},
|
},
|
||||||
tickSize: 0,
|
tickSize: 0,
|
||||||
|
|
Loading…
Reference in a new issue