Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

94
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda