Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start right away with a delay #39

Closed
GijsGoudzwaard opened this issue Jul 26, 2018 · 2 comments
Closed

Start right away with a delay #39

GijsGoudzwaard opened this issue Jul 26, 2018 · 2 comments
Assignees
Labels

Comments

@GijsGoudzwaard
Copy link

In my case I have a slow stream that updates every 5 seconds which i've specified with the delay property. The problem with this is that the data will be fetched after 5 seconds so my users have to wait 5 seconds before they can read the chart. The data is available right away, so is there an option that I can start immediately instead of waiting 5 seconds or preloading that data somehow?

@nagix
Copy link
Owner

nagix commented Aug 1, 2018

You can preload the data in the same way as a normal chart like the example below. You can also update chart.data.datasets anytime (chart.update() needs to be called in that case).

var yourDatasets = preloadDatasets();

var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
  type: 'line',
  data: {
    datasets: yourDatasets
  },
  options: {
    scales: {
      xAxes: [{
        type: 'realtime'
      }]
    },
    plugins: {
      streaming: {
        onRefresh: yourRefreshFunction()
      }
    }
  }
});

@nagix nagix self-assigned this Aug 1, 2018
@nagix nagix added the question label Aug 1, 2018
@GijsGoudzwaard
Copy link
Author

Thanks that worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants