chartjs-plugin-downsample icon indicating copy to clipboard operation
chartjs-plugin-downsample copied to clipboard

sample not spread over the chart

Open hodbauer opened this issue 4 years ago • 2 comments

Hello, I'm using next versions of chart.js:

chart.js: 2.8.0
chartjs-plugin-zoom: 0.7.0
chartjs-plugin-downsample: 1.1.0

I have the next configuration for my graph:

const config = {
  type: 'line',
  options: {
    downsample: {
      enabled: true
    },
    plugins: {
      zoom: {
        zoom: {
          enabled: true,
          mode: 'x'
        }
      }
    }
  }
}

I create a graph and only after a few milliseconds the data arrived from a server. I have thousands of points (almost 20K points).

After I update the graph with the data i call chart.update() to render the data.

As I expected, there is only 1000 points that displayed on the canvas, but the points appears only in the beginning of the graph (unfortunately I cannot add snapshot of the situation), it's mean that the x axes has a relevant range for all my points but the data not spread from begin to end. As a workaround to check what went wrong I call manually to chart.downsample(1000) and then chart.update() and it fix the problem, but I dont think that this should be the solution.

can I get any hint what i do wrong?

hodbauer avatar Jul 11 '19 14:07 hodbauer

Running into the same problem... ended up doing the same, stealing the downsample() function, and doing it manually. Something is not properly behaving in the script.

kmlbgn avatar Jan 13 '20 10:01 kmlbgn

I realize this issue was opened quite some time ago, but in case it is still any help, does the newly-added data render as expected if the configuration has preferOriginalData: true?

const config = {
  type: 'line',
  options: {
    downsample: {
      enabled: true,
      preferOriginalData: true,
    },
    plugins: {
      zoom: {
        zoom: {
          enabled: true,
          mode: 'x'
        }
      }
    }
  }
}

I've added a new sample here for https://github.com/AlbinoDrought/chartjs-plugin-downsample/issues/10#issuecomment-695146250 that adds data dynamically and it requires preferOriginalData: true to work.

AlbinoDrought avatar Sep 19 '20 01:09 AlbinoDrought