|
| 1 | +import { Component } from '@angular/core'; |
| 2 | + |
| 3 | +@Component({ |
| 4 | + selector: 'app-charts', |
| 5 | + templateUrl: './charts.component.html', |
| 6 | + styleUrls: ['./charts.component.scss'] |
| 7 | +}) |
| 8 | +export class ChartsComponent { |
| 9 | + |
| 10 | + months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; |
| 11 | + |
| 12 | + chartBarData = { |
| 13 | + labels: [...this.months].slice(0, 7), |
| 14 | + datasets: [ |
| 15 | + { |
| 16 | + label: 'GitHub Commits', |
| 17 | + backgroundColor: '#f87979', |
| 18 | + data: [40, 20, 12, 39, 17, 42, 79] |
| 19 | + } |
| 20 | + ] |
| 21 | + }; |
| 22 | + |
| 23 | + // chartBarOptions = { |
| 24 | + // maintainAspectRatio: false, |
| 25 | + // }; |
| 26 | + |
| 27 | + chartLineData = { |
| 28 | + labels: [...this.months].slice(0, 7), |
| 29 | + datasets: [ |
| 30 | + { |
| 31 | + label: 'My First dataset', |
| 32 | + backgroundColor: 'rgba(220, 220, 220, 0.2)', |
| 33 | + borderColor: 'rgba(220, 220, 220, 1)', |
| 34 | + pointBackgroundColor: 'rgba(220, 220, 220, 1)', |
| 35 | + pointBorderColor: '#fff', |
| 36 | + data: [this.randomData, this.randomData, this.randomData, this.randomData, this.randomData, this.randomData, this.randomData] |
| 37 | + }, |
| 38 | + { |
| 39 | + label: 'My Second dataset', |
| 40 | + backgroundColor: 'rgba(151, 187, 205, 0.2)', |
| 41 | + borderColor: 'rgba(151, 187, 205, 1)', |
| 42 | + pointBackgroundColor: 'rgba(151, 187, 205, 1)', |
| 43 | + pointBorderColor: '#fff', |
| 44 | + data: [this.randomData, this.randomData, this.randomData, this.randomData, this.randomData, this.randomData, this.randomData] |
| 45 | + } |
| 46 | + ] |
| 47 | + }; |
| 48 | + |
| 49 | + chartLineOptions = { |
| 50 | + maintainAspectRatio: false, |
| 51 | + }; |
| 52 | + |
| 53 | + chartDoughnutData = { |
| 54 | + labels: ['VueJs', 'EmberJs', 'ReactJs', 'Angular'], |
| 55 | + datasets: [ |
| 56 | + { |
| 57 | + backgroundColor: ['#41B883', '#E46651', '#00D8FF', '#DD1B16'], |
| 58 | + data: [40, 20, 80, 10] |
| 59 | + } |
| 60 | + ] |
| 61 | + }; |
| 62 | + |
| 63 | + // chartDoughnutOptions = { |
| 64 | + // aspectRatio: 1, |
| 65 | + // responsive: true, |
| 66 | + // maintainAspectRatio: false, |
| 67 | + // radius: '100%' |
| 68 | + // }; |
| 69 | + |
| 70 | + chartPieData = { |
| 71 | + labels: ['Red', 'Green', 'Yellow'], |
| 72 | + datasets: [ |
| 73 | + { |
| 74 | + data: [300, 50, 100], |
| 75 | + backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56'], |
| 76 | + hoverBackgroundColor: ['#FF6384', '#36A2EB', '#FFCE56'] |
| 77 | + } |
| 78 | + ] |
| 79 | + }; |
| 80 | + |
| 81 | + // chartPieOptions = { |
| 82 | + // aspectRatio: 1, |
| 83 | + // responsive: true, |
| 84 | + // maintainAspectRatio: false, |
| 85 | + // radius: '100%' |
| 86 | + // }; |
| 87 | + |
| 88 | + chartPolarAreaData = { |
| 89 | + labels: ['Red', 'Green', 'Yellow', 'Grey', 'Blue'], |
| 90 | + datasets: [ |
| 91 | + { |
| 92 | + data: [11, 16, 7, 3, 14], |
| 93 | + backgroundColor: ['#FF6384', '#4BC0C0', '#FFCE56', '#E7E9ED', '#36A2EB'] |
| 94 | + } |
| 95 | + ] |
| 96 | + }; |
| 97 | + |
| 98 | + chartRadarData = { |
| 99 | + labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'], |
| 100 | + datasets: [ |
| 101 | + { |
| 102 | + label: '2020', |
| 103 | + backgroundColor: 'rgba(179,181,198,0.2)', |
| 104 | + borderColor: 'rgba(179,181,198,1)', |
| 105 | + pointBackgroundColor: 'rgba(179,181,198,1)', |
| 106 | + pointBorderColor: '#fff', |
| 107 | + pointHoverBackgroundColor: '#fff', |
| 108 | + pointHoverBorderColor: 'rgba(179,181,198,1)', |
| 109 | + tooltipLabelColor: 'rgba(179,181,198,1)', |
| 110 | + data: [65, 59, 90, 81, 56, 55, 40] |
| 111 | + }, |
| 112 | + { |
| 113 | + label: '2021', |
| 114 | + backgroundColor: 'rgba(255,99,132,0.2)', |
| 115 | + borderColor: 'rgba(255,99,132,1)', |
| 116 | + pointBackgroundColor: 'rgba(255,99,132,1)', |
| 117 | + pointBorderColor: '#fff', |
| 118 | + pointHoverBackgroundColor: '#fff', |
| 119 | + pointHoverBorderColor: 'rgba(255,99,132,1)', |
| 120 | + tooltipLabelColor: 'rgba(255,99,132,1)', |
| 121 | + data: [this.randomData, this.randomData, this.randomData, this.randomData, this.randomData, this.randomData, this.randomData] |
| 122 | + } |
| 123 | + ] |
| 124 | + }; |
| 125 | + |
| 126 | + // chartRadarOptions = { |
| 127 | + // aspectRatio: 1.5, |
| 128 | + // responsive: true, |
| 129 | + // maintainAspectRatio: false, |
| 130 | + // }; |
| 131 | + |
| 132 | + get randomData() { |
| 133 | + return Math.round(Math.random() * 100); |
| 134 | + } |
| 135 | + |
| 136 | +} |
0 commit comments