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

289
Views
ChartJS: deshabilite la animación solo para el eje y

Actualmente tengo un gráfico que muestra información en tiempo real. Traté de deshabilitar la animación para el eje y, porque los puntos saltaban a lo largo del eje y, lo que crea un efecto extraño. Pero todavía quiero que los nuevos puntos se desvanezcan suavemente a lo largo del eje x.

Lo probé con esta configuración:

 const chartOptions: ChartOptions = { animations: { x: { duration: 500 }, y: false, }, // ... };

El resultado es ninguna animación en absoluto. No en el eje y, pero tampoco en el eje x. Ya no se ve suave.

Y después de 25 puntos de datos, shift()/push(newDataPoint) en una matriz separada y luego reemplazo toda la matriz de data para el gráfico mientras uso ChartJS con la biblioteca vue-chartjs.

ingrese la descripción de la imagen aquí

Necesito exactamente el mismo comportamiento que en el GIF anterior, excepto que no debe tartamudear sino desplazarse suavemente a lo largo del eje x.

Ejemplo completo de vue-chartjs para referencia

 <script setup lang="ts"> const chartData = ref<ChartData<'line'>>({ labels: [], datasets: [] }) const chartLabels: string[] = Array(maxDataPoints).fill(''); const chartDataPoints: number[] = Array(maxDataPoints).fill(18.3); function fillData() { if (chartDataPoints.length > maxDataPoints) { chartLabels.shift(); chartDataPoints.shift(); } chartLabels.push(new Date().toLocaleString()) chartDataPoints.push(Number((currentDistance.value * 0.1).toFixed(1))) const updatedChartData: ChartData<'line'> = { labels: [...chartLabels], datasets: [ { label: 'Distance', tension: 0.5, data: [...chartDataPoints], } ] } chartData.value = { ...updatedChartData } } onMounted(() => { fillData(); setInterval(() => fillData(), 500) }) const chartOptions: ChartOptions = { responsive: true, maintainAspectRatio: false, //animation: false, animations: { x: { duration: 500 }, y: false, }, scales:{ x: { display: false, }, y: { suggestedMin: 0, suggestedMax: 20, } }, plugins: { legend: { display: false }, }, } </script> <template> <LineChart :chartData="chartData" :chartOptions="chartOptions" /> </template>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Al final, utilicé el complemento chartjs-streaming-plugin de nagix, que hace exactamente lo que estaba buscando.

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!