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

176
Vistas
Can't Draw Horizontal Line on Graph Using ChartJS Annotation Plugin and Primevue Chart

I'm working in Vue 3 Composition and trying to draw a horizontal line across my ChartJS graph using the ChartJS annotation plugin. (https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/types/line.html)

I'm using Primevue Chart component as the implementation of ChartJS.

I have imported import annotationPlugin from 'chartjs-plugin-annotation'; and import Chart from 'primevue/chart'; and made my component like:

<Chart    
  type="line"
 :data="data"
 :options="options"
 :plugins="annotationPlugin"
/>

This is what my chart options look like:

const options = ref({
      plugins: {
        autocolors: false,
        annotation: {
          annotations: {
            line1: {
              type: 'line',
              yMin: 125,
              yMax: 125,
              borderColor: 'rgb(255, 99, 132)',
              borderWidth: 2,
            },
          },
        },
      },
    });

My graph successfully renders, but there is no horizontal line and no errors.

I think I'm following the documentation correctly, but there must be something I'm missing. Thanks in advance!

Graph without horizontal line

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

We hit a similar problem and needed to make sure we globally register the annotation plugin in our project root.

Without this, the annotation silently fails just as you are describing:

import { Chart } from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
Chart.register(annotationPlugin);

Also, just referencing the annotation in your options object is enough. No need for the plugins argument to the Chart component itself here:

<Chart    
  type="line"
 :data="data"
 :options="options"
 :plugins="annotationPlugin"
/>

Source: https://www.chartjs.org/chartjs-plugin-annotation/latest/guide/integration.html#bundlers-webpack-rollup-etc

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