-
-
Save uno-de-piera/2c15f5bbff593d2ea2e42a05dc8e8cdc 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 } from '@angular/core'; | |
@Component({ | |
selector: 'app-line-chart-demo', | |
templateUrl: './line-chart-demo.component.html' | |
}) | |
export class LineChartDemoComponent { | |
// lineChart | |
public lineChartData: Array<any> = [ | |
{data: [65, 59, 80, 81, 56, 55, 40], label: 'Serie A'}, | |
{data: [28, 48, 40, 19, 86, 27, 90], label: 'Serie B'}, | |
{data: [18, 48, 77, 9, 100, 27, 40], label: 'Serie C'} | |
]; | |
public lineChartLabels: Array<any> = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio']; | |
public lineChartOptions: any = { | |
responsive: true | |
}; | |
public lineChartColors: Array<any> = [ | |
{ // grey | |
backgroundColor: 'rgba(148,159,177,0.2)', | |
borderColor: 'rgba(148,159,177,1)', | |
pointBackgroundColor: 'rgba(148,159,177,1)', | |
pointBorderColor: '#fff', | |
pointHoverBackgroundColor: '#fff', | |
pointHoverBorderColor: 'rgba(148,159,177,0.8)' | |
}, | |
{ // dark grey | |
backgroundColor: 'rgba(77,83,96,0.2)', | |
borderColor: 'rgba(77,83,96,1)', | |
pointBackgroundColor: 'rgba(77,83,96,1)', | |
pointBorderColor: '#fff', | |
pointHoverBackgroundColor: '#fff', | |
pointHoverBorderColor: 'rgba(77,83,96,1)' | |
}, | |
{ // grey | |
backgroundColor: 'rgba(148,159,177,0.2)', | |
borderColor: 'rgba(148,159,177,1)', | |
pointBackgroundColor: 'rgba(148,159,177,1)', | |
pointBorderColor: '#fff', | |
pointHoverBackgroundColor: '#fff', | |
pointHoverBorderColor: 'rgba(148,159,177,0.8)' | |
} | |
]; | |
public lineChartLegend = true; | |
public lineChartType = 'line'; | |
public randomize(): void { | |
const _lineChartData: Array<any> = new Array(this.lineChartData.length); | |
for (let i = 0; i < this.lineChartData.length; i++) { | |
_lineChartData[i] = {data: new Array(this.lineChartData[i].data.length), label: this.lineChartData[i].label}; | |
for (let j = 0; j < this.lineChartData[i].data.length; j++) { | |
_lineChartData[i].data[j] = Math.floor((Math.random() * 100) + 1); | |
} | |
} | |
this.lineChartData = _lineChartData; | |
} | |
// events | |
public chartClicked(e: any): void { | |
console.log(e); | |
} | |
public chartHovered(e: any): void { | |
console.log(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment