mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-29 01:48:26 +00:00
Style donut chart and add total count
This commit is contained in:
parent
485a234263
commit
6158b20a8c
@ -20,9 +20,12 @@ export class DeviceChartComponent implements OnInit {
|
|||||||
ngOnInit(): void { }
|
ngOnInit(): void { }
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
|
let totalCount: number = 0;
|
||||||
this.deviceService.getAll().subscribe(
|
this.deviceService.getAll().subscribe(
|
||||||
device => {
|
device => {
|
||||||
console.log("device", device);
|
// Count the number of folders and set chart
|
||||||
|
totalCount++;
|
||||||
|
this.donutChart.count = totalCount;
|
||||||
|
|
||||||
// Get StateType and convert to string
|
// Get StateType and convert to string
|
||||||
const stateType: Device.StateType = Device.getStateType(device);
|
const stateType: Device.StateType = Device.getStateType(device);
|
||||||
|
@ -1 +1,4 @@
|
|||||||
<canvas id={{elementID}} width="200%" height="100%"></canvas>
|
<div class="chart-container">
|
||||||
|
<canvas id={{elementID}} width="100%" height="100%"></canvas>
|
||||||
|
<div class="center">{{count}}</div>
|
||||||
|
</div>
|
@ -0,0 +1,12 @@
|
|||||||
|
.chart-container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 40%;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
@ -9,6 +9,7 @@ import { tooltip } from '../tooltip'
|
|||||||
})
|
})
|
||||||
export class DonutChartComponent {
|
export class DonutChartComponent {
|
||||||
@Input() elementID: string;
|
@Input() elementID: string;
|
||||||
|
count: number;
|
||||||
|
|
||||||
private canvas: any;
|
private canvas: any;
|
||||||
private ctx: any;
|
private ctx: any;
|
||||||
@ -56,7 +57,6 @@ export class DonutChartComponent {
|
|||||||
this.chart = new Chart(this.ctx, {
|
this.chart = new Chart(this.ctx, {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: ["Up to Date", "Syncing", "Waiting to Sync", "Out of Sync", "Failed Items"],
|
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: [],
|
data: [],
|
||||||
backgroundColor: [
|
backgroundColor: [
|
||||||
@ -68,6 +68,7 @@ export class DonutChartComponent {
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
cutoutPercentage: 70,
|
||||||
responsive: false,
|
responsive: false,
|
||||||
legend: {
|
legend: {
|
||||||
display: false
|
display: false
|
||||||
|
@ -22,8 +22,13 @@ export class FolderChartComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
let totalCount: number = 0;
|
||||||
this.folderService.getAll().subscribe(
|
this.folderService.getAll().subscribe(
|
||||||
folder => {
|
folder => {
|
||||||
|
// Count the number of folders and set chart
|
||||||
|
totalCount++;
|
||||||
|
this.donutChart.count = totalCount;
|
||||||
|
|
||||||
// Get StateType and convert to string
|
// Get StateType and convert to string
|
||||||
const stateType: Folder.StateType = Folder.getStateType(folder);
|
const stateType: Folder.StateType = Folder.getStateType(folder);
|
||||||
const state: string = Folder.stateTypeToString(stateType);
|
const state: string = Folder.stateTypeToString(stateType);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user