From f6df0be54df9664f6c3fdf0088c203f3219d93ed Mon Sep 17 00:00:00 2001 From: Marcos Dornellas Date: Wed, 17 Mar 2021 21:22:45 -0300 Subject: [PATCH] graphics --- .../compliance/compliance.component.html | 2 +- .../components/table/compliance-rating.html | 2 +- src/app/company/services/company.service.ts | 13 +-- src/app/dashboard/dashboard.component.css | 18 +-- src/app/dashboard/dashboard.component.html | 79 ++++++------- src/app/dashboard/dashboard.component.ts | 104 +++++++----------- 6 files changed, 82 insertions(+), 136 deletions(-) diff --git a/src/app/company/components/compliance/compliance.component.html b/src/app/company/components/compliance/compliance.component.html index a7fd891..128c435 100644 --- a/src/app/company/components/compliance/compliance.component.html +++ b/src/app/company/components/compliance/compliance.component.html @@ -57,7 +57,7 @@

{{$index + 1}} - {{standard.value.name}}

- + Nota de avaliação é obrigatório diff --git a/src/app/company/components/table/compliance-rating.html b/src/app/company/components/table/compliance-rating.html index fff39ed..5a7589a 100644 --- a/src/app/company/components/table/compliance-rating.html +++ b/src/app/company/components/table/compliance-rating.html @@ -3,6 +3,6 @@

{{company.name}}

{{standard.name}} - + \ No newline at end of file diff --git a/src/app/company/services/company.service.ts b/src/app/company/services/company.service.ts index 57ad5cc..3564dbf 100644 --- a/src/app/company/services/company.service.ts +++ b/src/app/company/services/company.service.ts @@ -13,6 +13,7 @@ export type CompanyModel = { standards?: Array<{ id: string, name: string + rating: number }> complianceAssessed?: boolean token?: string @@ -31,16 +32,4 @@ export class CompanyService { const { data, success } = await this.client.get>>(`companies`).toPromise(); return data; } - - get(id: number): CompanyModel { - return { - id: '8q397323', - name: 'Marcos teste', - cnpj: 239892392, - email: 'dornellas13@gmail.com', - endHire: '7689732', - startHire: '2828923', - standards: [{id: 'NR-1', name: 'TESTE NR-1' }, {id: 'NR-2', name: 'TESTE NR-2' }], - }; - } } diff --git a/src/app/dashboard/dashboard.component.css b/src/app/dashboard/dashboard.component.css index 18e93de..558bd1e 100644 --- a/src/app/dashboard/dashboard.component.css +++ b/src/app/dashboard/dashboard.component.css @@ -1,17 +1 @@ -.dashboard-card { - position: absolute; - top: 15px; - left: 15px; - right: 15px; - bottom: 15px; -} - -.more-button { - position: absolute; - top: 5px; - right: 10px; -} - -.dashboard-card-content { - text-align: center; -} +.ngx-charts, text { fill: #e0e0e0; } diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index 4f5757c..eb5e49b 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -1,39 +1,40 @@ - - - - +
+ + + + Gráfico de Conformidade + + + + + + + + +

Carregando informações...

+
+
+ +
+ +
+ + diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 19992eb..5f9fd55 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -1,73 +1,15 @@ -import { Component } from '@angular/core'; - -export let multi = [ - { - name: 'NR1', - series: [ - { - name: 'AMBEV', - value: 7 - }, - { - name: 'IFOOD', - value: 1 - } - ] - }, - - { - name: 'NR2', - series: [ - { - name: 'AMBEV', - value: 7 - }, - { - name: 'IFOOD', - value: 5 - } - ] - }, - - { - name: 'NR3', - series: [ - { - name: 'AMBEV', - value: 3 - }, - { - name: 'IFOOD', - value: 10 - } - ] - }, - { - name: 'NR4', - series: [ - { - name: 'STEFANINI', - value: 1 - }, - { - name: 'DEXTRA', - value: 2 - } - ] - } -]; - - +import { Component, OnInit } from '@angular/core'; +import { CompanyService } from '../company/services/company.service'; @Component({ selector: 'app-dashboard', templateUrl: './dashboard.component.html', styleUrls: ['./dashboard.component.css'] }) -export class DashboardComponent { +export class DashboardComponent implements OnInit { multi: any[]; - view: any[] = [800, 400]; + view: any[] = [1980, 600]; // options showXAxis = true; @@ -75,13 +17,43 @@ export class DashboardComponent { gradient = true; showLegend = true; showXAxisLabel = true; - xAxisLabel = 'Normas Técnicas'; + xAxisLabel = 'Consultorias e Acessorias'; showYAxisLabel = true; yAxisLabel = 'Nota de Conformidade'; - legendTitle = 'Consultorias e Acessorias'; + legendTitle = 'Normas Técnicas'; + maxXAxisTickLength = 16; + maxYAxisTickLength = 10; + legendPosition = 'right'; + + colorScheme = { + domain: ['#FF8A80', + '#EA80FC', + '#8C9EFF', + '#80D8FF', + '#A7FFEB', + '#CCFF90', + '#FFFF8D', + '#FF9E80'] + }; + + constructor(private companyService: CompanyService) { + } - constructor() { - Object.assign(this, { multi }); + async ngOnInit(): Promise { + const companies = await this.companyService.getAll(); + this.multi = companies + .filter(a => a.standards.some(b => b.rating > 0)) + .map(company => { + return { + name: company.name, + series: company.standards.map(standard => { + return { + name: `${standard.id} - ${standard.name}`, + value: standard.rating + }; + }) + }; + }); } onSelect(data): void {