-
-
Save keathmilligan/d36b46dd07697ea4e8eb662195fa273e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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