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

85
Vistas
ChartJS stock price line chart config with autoscale

I'm trying to configure ChartJS to show a stock price line chart with months on an x-axis legend and a price on y.

But want to seed end of week stock closure price, so 4-5 data points per month, depending on the month.

Also is there a way to automatically calculate a current date and automatically build labels on a rolling basis.

So far got this:

const config = {
  type: 'line',
  data: data,
};

const labels = ['Aug', '', '', '',  'Sep', '', '', '',  'Oct', '', '', '',  'Nov', '', '', '',  'Dec', '', '', '',  'Jan', '', '', '',  'Feb', '', '', '',  'Mar', '', '', '',  'Apr', '', '', '',  'May', '', '', '',  'Jun', '', '', '',  'Jul']

const data = {
  labels: labels,
  datasets: [{
    label: 'Apple stock price',
    data: [141,139,128,133,136,130,136,125,126,128,129,127,122,125,122,122,131,133,131,126,130,131,128,131,131,128,128,126,128,127,133,130,137],
    fill: false,
    borderColor: 'rgb(75, 192, 192)',
    tension: 0.5
  }]
};

But looks like I need somehow to configure the logarithmic scale for the y-axis as well as better distribute/map weekly prices to months.

Found several examples/answers here but a lot of them are for the question 5-10 years old, so maybe in a newer version this task can be done easier.

about 4 years ago · Juan Pablo Isaza
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