I want to remove every three hours from the bottom of the rope chart. I'm using react-chart-js2. I'm using the .map function to display these numbers. Is it possible to display only every three of them? Chart
Here is the code that displays the hours:
const data = { labels: chart.prices?.map(x => moment(x[0]).format('h:mm a')), datasets: [{ data: chart.prices?.map(x => x[1]), backgroundColor: '#ffffff00', borderColor: 'rgb(79 70 229)', borderWidth: '2', pointBorderColor: '#ffffff00', tension: 0.4, fill: { target: "origin", // 3. Set the fill options above: "rgba(79, 70, 229, 0.0625)" } }] } I want only every third number to be displayed
Replace every third item with an empty string.
let hours = chart.prices?.map(x => moment(x[0]).format('h:mm a')); for (let i=0; i<=hours.length; i++) { if((i+1) % 3 == 0){ hours[i] = ""; } }Then in chart.js:
labels: hours,