0

my environment: React with React-charts2

I want to limit the labels number when i have more labels, example: 1 year total range

This screen is that the date length is thirty days, and the limit rule is that three days are replaced by one field, how can i achieve?

my other charts rules is:

const tickIntervalRule = () => {
        let tick;
        switch (true) {
          case dateDistance < 16:
            tick = 1; // will default value
            break;
          case 16 <= dateDistance && dateDistance <= 30:
            tick = 3; // 30/3 reutrn 10 labels
            break;
          case 31 <= dateDistance && dateDistance <= 90:
            tick = 10; // 90/10 reutrn 9 labels
            break;
          case 91 <= dateDistance && dateDistance <= 365:
            tick = 30; // 365/30 reutrn 12 labels
            break;
          case dateDistance > 365:
            tick = 60; // 365/60 reutrn 6 labels
            break;
          default:
        }
        return tick;
      };

expected look screen shot: 30days dateRange in charts

  • more likely this question https://stackoverflow.com/questions/29925431/chartjs-draw-chart-with-label-by-month-data-by-day – Michael Luo Nov 21 '22 at 08:31
  • 1
    Does this answer your question? [ChartJS - Draw chart with label by month, data by day](https://stackoverflow.com/questions/29925431/chartjs-draw-chart-with-label-by-month-data-by-day) – treckstar Nov 23 '22 at 13:17

0 Answers0