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

92
Vistas
Implementing Data Decimation in vue chartjs

I've been trying and failing to implement data decimation in vue chartJS, I'm assuming parsing is the hurdle stopping me as it is the one requirement I cant seem to fulfil.

  1. The dataset must have an indexAxis of 'x'
  2. The dataset must be a line
  3. The X axis for the dataset must be either a 'linear' or 'time' type axis
  4. Data must not need parsing, i.e. parsing must be false
  5. The dataset object must be mutable. The plugin stores the original data as dataset._data and then defines a new data property on the dataset.

My current chart options are:

oilOptions: {
    responsive: true,
    scales: {
        y: {
            ... // Formatting and title
        },
        x: {
            type: 'time'
            ... // Formatting and title
        }
    },
    plugins: {
        title: {
            ...
        },
        zoom: {
            ...
        },
        decimation: {
            enabled: true,
            algorithm: 'lttb',
            samples: 500
        }

The dataset is historical Brent oil price data structured like:

{
    labels: [
        "1987-05-20",
        "1987-05-21",
        ...
     ],
     datasets: [
        label: "Brent Oil Price",
        fill: false,
        borderWidth: 2,
        borderColor: "rgb(75, 192, 192)",
        tension: 0.5,
        pointRadius: 0,
        // parsing: false (This stops data from rendering anyway)
        data: [
                18,
                18,
                ...
        ]
     ]

I'm using vue-chartjs but that shouldn't be an issue.

Any help would be appreciated, my other option would be to reduce the data on the backend before passing it to the client, or have a separately saved reduced data set on my DB.

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

0

No parsing means that you need to provide the data like the internal format so no labels array and objects in your data array like so:

{
  datasets: [{
    label: "Brent Oil Price",
    fill: false,
    borderWidth: 2,
    borderColor: "rgb(75, 192, 192)",
    tension: 0.5,
    pointRadius: 0,
    parsing: false
    data: [{
        x: '1987-05-20',
        y: 5
      },
      {
        x: '1987-05-21',
        y: 6
      }
    ]
  }]
}

The internal data format can be found in the docs 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