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

152
Views
La línea del gráfico no aparece en un gráfico semi-logarítmico usando chart.js

Estoy usando react-chartjs-2 para crear un gráfico semi-logarítmico usando algunos datos simples. Probé muchos ejemplos pero en el gráfico final no se dibuja la línea ni veo ningún error en la consola del navegador. Estoy usando Next.js y Tailwind CSS para este proyecto.

También intenté usar las técnicas descritas en los gráficos de series temporales, pero tampoco funcionan.

He descubierto cómo crear el eje y las marcas, ahora, ¿cómo dibujo la línea?

Aquí está mi código.

índice.js

 import { Chart as ChartJS, CategoryScale, LogarithmicScale, LogarithmicScaleOptions, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, } from "chart.js"; import { Line } from "react-chartjs-2"; ChartJS.register( LogarithmicScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend ); export const options = { scales: { x: { display: true, type: "logarithmic", min: 0.000001, max: 1, }, y: { display: true, min: 400, max: 2500, }, }, responsive: true, plugins: { legend: { position: "top", }, title: { display: true, text: "5W-10R", }, }, }; const vmax = [2000, 1750, 1500, 1250, 1000, 750, 500]; const tm = [ 0.0000125, 0.00001633, 0.00002222, 0.000032, 0.00005, 0.0002, 0.0008, ]; export const data = { tm, datasets: [ { label: "Dataset 1", data: vmax, borderColor: "rgb(255, 99, 132)", backgroundColor: "rgba(255, 99, 132, 0.5)", }, ], }; export default function Home({}) { return ( <div className=""> <div className="flex flex-col items-center justify-center min-h-screen py-2"> <main className="flex flex-col items-center w-full flex-1 px-10 "> <Line options={options} data={data} /> </main> </div> </div> ); }

Resultado: ingrese la descripción de la imagen aquí

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

0

No pasa una opción a la matriz de etiquetas, pasa la variable tm , lo que significa que la usará como clave, debe pasarla como:

 const data = { labels: tm, datasets: [] }
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!