Skip to content

Instantly share code, notes, and snippets.

@keathmilligan
Created August 26, 2017 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keathmilligan/d36b46dd07697ea4e8eb662195fa273e to your computer and use it in GitHub Desktop.
Save keathmilligan/d36b46dd07697ea4e8eb662195fa273e to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
private chartData: Array<any>;
constructor() {}
ngOnInit() {
// give everything a chance to get loaded before starting the animation to reduce choppiness
setTimeout(() => {
this.generateData();
// change the data periodically
setInterval(() => this.generateData(), 3000);
}, 1000);
}
generateData() {
this.chartData = [];
for (let i = 0; i < (8 + Math.floor(Math.random() * 10)); i++) {
this.chartData.push([
`Index ${i}`,
Math.floor(Math.random() * 100)
]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment