Skip to content

Instantly share code, notes, and snippets.

@keathmilligan keathmilligan/app.component.ts Secret
Created Aug 26, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.