Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
Manipulate x axis label positioning. React Chartjs 2

I am trying to make a an area chart that has x axis labels displayed above the actual axis itself. Here's an example:

enter image description here

I have the axis labels, but I cannot find a way to move them just above the X axis

Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Filler)

const options = {
  layout: { padding: { top: 50 } },
  responsive: true,
  elements: {
    line: {
      tension: 0.4, // makes the line smoother
    },
    point: {
      radius: 0,
    },
  },
  scales: {
    x: {

      grid: {
        display: false, // hides lines in background
        drawBorder: false,
      },
    },
    y: {
      beginAtZero: true,
      grid: {
        display: false, // hides lines in background
        drawBorder: false,
      },
      ticks: {
        display: false,
      },
    },
  },
}

const chartData = {
  labels: ['JAN', 'FEB', 'MAR', ...],
  datasets: [
    {
      data: [12, 79, 56, ...],
      borderWidth: 5,
    },
  ],
}

export const Graph = () => {
  return (
    <div>
      ....
      <Line plugins={plugins} options={options} data={chartData} />
    </div>
  )
}

I need it to be responsive, being able to change the time window that is graphed. I tried to do an afterDraw() function however that isn't ideal given the need to responsive.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After some digging, I was able to find this solution:

const options: {
...
scales:{ x: position: { y: 20 } }. <------------------ Answer here
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!