Add title to donut chart and media queries

This commit is contained in:
Jesse Lucas 2020-03-30 11:54:54 -04:00
parent e5b85ff1a0
commit 933a57af7a
No known key found for this signature in database
GPG Key ID: 9810010C7FDCD3BB
7 changed files with 46 additions and 11 deletions

View File

@ -1,8 +1,8 @@
<div class="{{elevation}} tui-card"> <div class="{{elevation}} tui-card">
<div class="tui-card-title">Devices</div> <div class="tui-card-title">{{title}}</div>
<div class="tui-card-content"> <div class="tui-card-content">
<div fxLayout="row" fxLayoutAlign="space-between stretch"> <div fxLayout="row" fxLayoutAlign="space-between stretch">
<app-donut-chart [elementID]="chartID" fxFlex="30"></app-donut-chart> <app-donut-chart [elementID]="chartID" fxFlex="30" [title]="title"></app-donut-chart>
<div class="items" fxLayout="column" fxLayoutAlign="start end" fxFlex="70"> <div class="items" fxLayout="column" fxLayoutAlign="start end" fxFlex="70">
<app-chart-item *ngFor="let state of states" [state]="state.label" [count]="state.count"> <app-chart-item *ngFor="let state of states" [state]="state.label" [count]="state.count">
</app-chart-item> </app-chart-item>

View File

@ -14,6 +14,7 @@ export class DeviceChartComponent implements OnInit {
chartID: string = 'devicesChart'; chartID: string = 'devicesChart';
elevation: string = cardElevation; elevation: string = cardElevation;
states: { label: string, count: number, color: string }[] = []; states: { label: string, count: number, color: string }[] = [];
title: string = "Devices";
constructor(private deviceService: DeviceService) { } constructor(private deviceService: DeviceService) { }

View File

@ -1,4 +1,7 @@
<div class="chart-container" fxLayout="column" fxLayoutAlign="space-around"> <div class="chart-container">
<canvas id={{elementID}} width="100px" height="100px"></canvas> <canvas id={{elementID}} width="100px" height="100px"></canvas>
<div class="center">{{count}}</div> <div class="center" fxLayout="column" fxLayoutAlign="center center">
<div class="count">{{count}}</div>
<div class="title">{{title}}</div>
</div>
</div> </div>

View File

@ -6,9 +6,38 @@
.center { .center {
position: absolute; position: absolute;
left: 0; top: 0; left: 0; bottom: 0; right: 0;
top: 40%; width: 50%;
width: 100%; height: 50%;
text-align: center; overflow: auto;
font-size:1.8rem; margin: auto;
}
.count {
font-size: calc(1rem + 0.625vw);
}
.title {
font-size: calc(0.5rem + 0.625vw);
display:none;
}
@media (max-width: 640px) {
}
@media (min-width: 640px) and (max-width: 1000px) {
.title {
display:none;
font-size: calc(0.35rem + 0.625vw);
}
.count {
font-size: calc(1.35rem + 0.625vw);
}
}
@media (min-width:1000px) {
.title {
display: inline;
}
} }

View File

@ -9,6 +9,7 @@ import { tooltip } from '../tooltip'
}) })
export class DonutChartComponent { export class DonutChartComponent {
@Input() elementID: string; @Input() elementID: string;
@Input() title: number;
count: number; count: number;
private canvas: any; private canvas: any;

View File

@ -1,8 +1,8 @@
<div class="{{elevation}} tui-card"> <div class="{{elevation}} tui-card">
<div class="tui-card-title">Folders</div> <div class="tui-card-title">{{title}}</div>
<div class="tui-card-content"> <div class="tui-card-content">
<div fxLayout="row" fxLayoutAlign="space-between stretch"> <div fxLayout="row" fxLayoutAlign="space-between stretch">
<app-donut-chart [elementID]="chartID" fxFlex="30"></app-donut-chart> <app-donut-chart [elementID]="chartID" fxFlex="30" [title]="title"></app-donut-chart>
<div class="items" fxLayout="column" fxLayoutAlign="start end" fxFlex="70"> <div class="items" fxLayout="column" fxLayoutAlign="start end" fxFlex="70">
<app-chart-item *ngFor="let state of states" [state]="state.label" [count]="state.count"> <app-chart-item *ngFor="let state of states" [state]="state.label" [count]="state.count">
</app-chart-item> </app-chart-item>

View File

@ -14,6 +14,7 @@ export class FolderChartComponent implements OnInit {
chartID: string = 'foldersChart'; chartID: string = 'foldersChart';
states: { label: string, count: number, color: string }[] = []; states: { label: string, count: number, color: string }[] = [];
elevation: string = cardElevation; elevation: string = cardElevation;
title: string = "Folders";
constructor(private folderService: FolderService) { } constructor(private folderService: FolderService) { }