-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eae676d
commit 8ef9657
Showing
5 changed files
with
322 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
166 changes: 166 additions & 0 deletions
166
src/app/showcase/components/chart/combochart/combochartdemo.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
<div class="content-section introduction"> | ||
<div class="feature-intro"> | ||
<h1>Combo Chart</h1> | ||
<p>Different chart types can be combined in the same graph.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="content-section implementation"> | ||
<div class="card"> | ||
<p-chart type="bar" [data]="data" [options]="chartOptions"></p-chart> | ||
</div> | ||
</div> | ||
|
||
<div class="content-section documentation"> | ||
|
||
|
||
<p-tabView> | ||
<p-tabPanel header="Source"> | ||
<a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/chart/doughnutchart" class="btn-viewsource" target="_blank"> | ||
<span>View on GitHub</span> | ||
</a> | ||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<p-chart type="bar" [data]="data" [options]="chartOptions"></p-chart> | ||
</app-code> | ||
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces> | ||
export class DoughnutChartDemo { | ||
|
||
data: any; | ||
|
||
chartOptions: any; | ||
|
||
subscription: Subscription; | ||
|
||
config: AppConfig; | ||
|
||
constructor(private configService: AppConfigService) {} | ||
|
||
ngOnInit() { | ||
this.data = { | ||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], | ||
datasets: [{ | ||
type: 'line', | ||
label: 'Dataset 1', | ||
borderColor: '#42A5F5', | ||
borderWidth: 2, | ||
fill: false, | ||
data: [ | ||
50, | ||
25, | ||
12, | ||
48, | ||
56, | ||
76, | ||
42 | ||
] | ||
}, { | ||
type: 'bar', | ||
label: 'Dataset 2', | ||
backgroundColor: '#66BB6A', | ||
data: [ | ||
21, | ||
84, | ||
24, | ||
75, | ||
37, | ||
65, | ||
34 | ||
], | ||
borderColor: 'white', | ||
borderWidth: 2 | ||
}, { | ||
type: 'bar', | ||
label: 'Dataset 3', | ||
backgroundColor: '#FFA726', | ||
data: [ | ||
41, | ||
52, | ||
24, | ||
74, | ||
23, | ||
21, | ||
32 | ||
] | ||
}] | ||
}; | ||
this.chartOptions = { | ||
responsive: true, | ||
title: { | ||
display: true, | ||
text: 'Combo Bar Line Chart' | ||
}, | ||
tooltips: { | ||
mode: 'index', | ||
intersect: true | ||
} | ||
}; | ||
|
||
this.config = this.configService.config; | ||
this.updateChartOptions(); | ||
this.subscription = this.configService.configUpdate$.subscribe(config => { | ||
this.config = config; | ||
this.updateChartOptions(); | ||
}); | ||
} | ||
|
||
updateChartOptions() { | ||
if (this.config.dark) | ||
this.applyDarkTheme(); | ||
else | ||
this.applyLightTheme(); | ||
} | ||
|
||
applyLightTheme() { | ||
this.chartOptions = { | ||
legend: { | ||
labels: { | ||
fontColor: '#495057' | ||
} | ||
}, | ||
scales: { | ||
xAxes: [{ | ||
ticks: { | ||
fontColor: '#495057' | ||
} | ||
}], | ||
yAxes: [{ | ||
ticks: { | ||
fontColor: '#495057' | ||
} | ||
}] | ||
} | ||
} | ||
} | ||
|
||
applyDarkTheme() { | ||
this.chartOptions = { | ||
legend: { | ||
labels: { | ||
fontColor: '#ebedef' | ||
} | ||
}, | ||
scales: { | ||
xAxes: [{ | ||
ticks: { | ||
fontColor: '#ebedef' | ||
}, | ||
gridLines: { | ||
color: 'rgba(255,255,255,0.2)' | ||
} | ||
}], | ||
yAxes: [{ | ||
ticks: { | ||
fontColor: '#ebedef' | ||
}, | ||
gridLines: { | ||
color: 'rgba(255,255,255,0.2)' | ||
} | ||
}] | ||
} | ||
}; | ||
} | ||
} | ||
</app-code> | ||
</p-tabPanel> | ||
</p-tabView> | ||
</div> |
145 changes: 145 additions & 0 deletions
145
src/app/showcase/components/chart/combochart/comobochartdemo.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {Subscription} from 'rxjs'; | ||
import {AppConfigService} from '../../../service/appconfigservice'; | ||
import {AppConfig} from '../../../domain/appconfig'; | ||
|
||
@Component({ | ||
templateUrl: './combochartdemo.html' | ||
}) | ||
export class ComboChartDemo { | ||
|
||
data: any; | ||
|
||
chartOptions: any; | ||
|
||
subscription: Subscription; | ||
|
||
config: AppConfig; | ||
|
||
constructor(private configService: AppConfigService) {} | ||
|
||
ngOnInit() { | ||
this.data = { | ||
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], | ||
datasets: [{ | ||
type: 'line', | ||
label: 'Dataset 1', | ||
borderColor: '#42A5F5', | ||
borderWidth: 2, | ||
fill: false, | ||
data: [ | ||
50, | ||
25, | ||
12, | ||
48, | ||
56, | ||
76, | ||
42 | ||
] | ||
}, { | ||
type: 'bar', | ||
label: 'Dataset 2', | ||
backgroundColor: '#66BB6A', | ||
data: [ | ||
21, | ||
84, | ||
24, | ||
75, | ||
37, | ||
65, | ||
34 | ||
], | ||
borderColor: 'white', | ||
borderWidth: 2 | ||
}, { | ||
type: 'bar', | ||
label: 'Dataset 3', | ||
backgroundColor: '#FFA726', | ||
data: [ | ||
41, | ||
52, | ||
24, | ||
74, | ||
23, | ||
21, | ||
32 | ||
] | ||
}] | ||
}; | ||
this.chartOptions = { | ||
responsive: true, | ||
title: { | ||
display: true, | ||
text: 'Combo Bar Line Chart' | ||
}, | ||
tooltips: { | ||
mode: 'index', | ||
intersect: true | ||
} | ||
}; | ||
|
||
this.config = this.configService.config; | ||
this.updateChartOptions(); | ||
this.subscription = this.configService.configUpdate$.subscribe(config => { | ||
this.config = config; | ||
this.updateChartOptions(); | ||
}); | ||
} | ||
|
||
updateChartOptions() { | ||
if (this.config.dark) | ||
this.applyDarkTheme(); | ||
else | ||
this.applyLightTheme(); | ||
} | ||
|
||
applyLightTheme() { | ||
this.chartOptions = { | ||
legend: { | ||
labels: { | ||
fontColor: '#495057' | ||
} | ||
}, | ||
scales: { | ||
xAxes: [{ | ||
ticks: { | ||
fontColor: '#495057' | ||
} | ||
}], | ||
yAxes: [{ | ||
ticks: { | ||
fontColor: '#495057' | ||
} | ||
}] | ||
} | ||
} | ||
} | ||
|
||
applyDarkTheme() { | ||
this.chartOptions = { | ||
legend: { | ||
labels: { | ||
fontColor: '#ebedef' | ||
} | ||
}, | ||
scales: { | ||
xAxes: [{ | ||
ticks: { | ||
fontColor: '#ebedef' | ||
}, | ||
gridLines: { | ||
color: 'rgba(255,255,255,0.2)' | ||
} | ||
}], | ||
yAxes: [{ | ||
ticks: { | ||
fontColor: '#ebedef' | ||
}, | ||
gridLines: { | ||
color: 'rgba(255,255,255,0.2)' | ||
} | ||
}] | ||
} | ||
}; | ||
} | ||
} |