Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setChart(data: Array): void {
if (this.chart) {
this.chart.destroy();
}
this.chart = new Chart('chart', {
type: this.chartTypeForm.value,
data: {
datasets: [{
data: this.itemClasses.map(c => c.quantity),
backgroundColor: this.colors
}],
labels: this.itemClasses.map(c => `${ c.name } x ${c.quantity}`)
}
// options: options
});
}
createDoughnutChart() {
this.myChart = new Chart(this.chartCanvas.nativeElement, {
type: 'doughnut',
data: {
labels: this.getLabels(),
datasets: [{
label: 'Resultados',
data: this.getValues(),
backgroundColor: this.backgroundColor,
hoverBackgroundColor: this.hoverBackgroundColor
}]
}
});
}
private initChartObj() {
this.chartObj = new Chart(this.el.nativeElement.getContext('2d'), {
type: 'horizontalBar',
data: this.makeDataOption(),
options: this.makeNormalOption()
});
}
private makeDataOption(): any {
ionViewDidLoad(){
this.chart = new Chart(this.progressChart.nativeElement, {
type: 'doughnut',
data: {
datasets: [{
data: [this.piggy.percentage, 100 - this.piggy.percentage],
backgroundColor: [
"#00FF00"
]
}],
}
});
}
}
private createChart() {
if (this.chart) {
this.chart.destroy();
}
if (this.canvas) {
const ctx = this.canvas.nativeElement;
this.chart = new Chart(ctx, this.configuration);
}
}
}
setChart(): void {
if (this.chart) {
this.chart.destroy();
}
this.chart = new Chart(this.storageName, this.getChartConfig());
}
public getChartBuilder(ctx: string/*, data:any[], options:any*/): Chart {
const chartConfig = this.getChartConfiguration();
return new chartJs.Chart(ctx, chartConfig);
}