line-chart.component.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { ChartDataSets, ChartOptions } from 'chart.js';
  2. import { Component, OnInit, Input } from '@angular/core';
  3. import { Label, Color } from 'ng2-charts';
  4. @Component({
  5. selector: 'app-line-chart',
  6. templateUrl: './line-chart.component.html',
  7. styleUrls: ['./line-chart.component.scss']
  8. })
  9. export class LineChartComponent implements OnInit {
  10. @Input() public lineChartData: ChartDataSets;
  11. @Input() public lineChartOptions: ChartOptions;
  12. @Input() public lineChartTitle: string;
  13. @Input() public lineChartLabels: Label[];
  14. @Input() public lineChartColors: Color[] = [
  15. { // light-blue
  16. backgroundColor: '#3c8dbc',
  17. borderColor: '#3c8dbc',
  18. pointBackgroundColor: '#3c8dbc',
  19. pointBorderColor: '#fff',
  20. pointHoverBackgroundColor: '#fff',
  21. pointHoverBorderColor: '#3c8dbc'
  22. },
  23. { // orange
  24. backgroundColor: '#00a65a',
  25. borderColor: '#00a65a',
  26. pointBackgroundColor: '#00a65a',
  27. pointBorderColor: '#fff',
  28. pointHoverBackgroundColor: '#fff',
  29. pointHoverBorderColor: '#00a65a'
  30. },
  31. { // red
  32. backgroundColor: '#f56954',
  33. borderColor: '#f56954',
  34. pointBackgroundColor: '#f56954',
  35. pointBorderColor: '#fff',
  36. pointHoverBackgroundColor: '#fff',
  37. pointHoverBorderColor: '#f56954'
  38. }
  39. ];
  40. @Input() public lineChartLegend = true;
  41. @Input() public lineChartType = 'line';
  42. @Input() public lineChartPlugins = [];
  43. constructor() { }
  44. ngOnInit() {
  45. }
  46. }