Skip to content

Commit 0057cce

Browse files
committed
Adds half doughnut chart to charts page
1 parent c1d86c4 commit 0057cce

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/pages/miscellaneous/charts/charts.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
<canvas #doughnutCanvas></canvas>
3232
</ion-card-content>
3333
</ion-card>
34+
<ion-card>
35+
<ion-card-header>
36+
Half Doughnut Chart
37+
</ion-card-header>
38+
<ion-card-content>
39+
<canvas #halfDoughnutCanvas></canvas>
40+
</ion-card-content>
41+
</ion-card>
3442
<ion-card>
3543
<ion-card-header>
3644
Line Chart

src/pages/miscellaneous/charts/charts.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Chart from 'chart.js';
99
export class ChartsPage {
1010
@ViewChild('barCanvas') barCanvas;
1111
@ViewChild('doughnutCanvas') doughnutCanvas;
12+
@ViewChild('halfDoughnutCanvas') halfDoughnutCanvas;
1213
@ViewChild('lineCanvas') lineCanvas;
1314
@ViewChild('radarCanvas') radarCanvas;
1415
@ViewChild('polarCanvas') polarCanvas;
@@ -18,6 +19,7 @@ export class ChartsPage {
1819

1920
barChart: any;
2021
doughnutChart: any;
22+
halfDoughnutChart: any;
2123
lineChart: any;
2224
radarChart: any;
2325
polarAreaChart: any;
@@ -30,6 +32,7 @@ export class ChartsPage {
3032
ionViewDidLoad() {
3133
this.barChart = this.getBarChart();
3234
this.doughnutChart = this.getDoughnutChart();
35+
this.halfDoughnutChart = this.getHalfDoughnutChart();
3336
this.lineChart = this.getLineChart();
3437
this.radarChart = this.getRadarChart();
3538

@@ -202,6 +205,32 @@ export class ChartsPage {
202205
return this.getChart(this.doughnutCanvas.nativeElement, "doughnut", data);
203206
}
204207

208+
getHalfDoughnutChart() {
209+
let data = {
210+
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
211+
datasets: [{
212+
label: '# of Votes',
213+
data: [12, 19, 3, 5, 2, 3],
214+
backgroundColor: [
215+
'rgba(255, 99, 132, 0.2)',
216+
'rgba(54, 162, 235, 0.2)',
217+
'rgba(255, 206, 86, 0.2)',
218+
'rgba(75, 192, 192, 0.2)',
219+
'rgba(153, 102, 255, 0.2)',
220+
'rgba(255, 159, 64, 0.2)'
221+
],
222+
hoverBackgroundColor: ["#FF6384", "#36A2EB", "#FFCE56", "#FF6384", "#36A2EB", "#FFCE56"]
223+
}]
224+
};
225+
226+
let options = {
227+
circumference: Math.PI,
228+
rotation: 1.0 * Math.PI
229+
}
230+
231+
return this.getChart(this.halfDoughnutCanvas.nativeElement, "doughnut", data, options);
232+
}
233+
205234
getBarChart() {
206235
let data = {
207236
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],

0 commit comments

Comments
 (0)