Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda