diff --git a/src/app/components/shared/statistic/statistic.component.html b/src/app/components/shared/statistic/statistic.component.html index 8938fac3704534fccefd1a4a006cbc85eea0dff2..a6076eb0c31ed80ded3315cb5866674411b0f10d 100644 --- a/src/app/components/shared/statistic/statistic.component.html +++ b/src/app/components/shared/statistic/statistic.component.html @@ -1,5 +1,8 @@ -<div> - <div style="display: block"> - <canvas id="chart"></canvas> - </div> +<div fxLayout="column" fxLayoutGap="20px" fxLayoutAlign="center center"> + <h3>{{subject}}</h3> + <div> + <div style="display: block"> + <canvas id="chart"></canvas> + </div> + </div> </div> diff --git a/src/app/components/shared/statistic/statistic.component.ts b/src/app/components/shared/statistic/statistic.component.ts index 07a59f5dd17cd3f365b456a79609d916e511c757..02a2f21a35805044bc88d7248c8b76990913a535 100644 --- a/src/app/components/shared/statistic/statistic.component.ts +++ b/src/app/components/shared/statistic/statistic.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Chart } from 'chart.js'; import { ActivatedRoute } from '@angular/router'; import { Content } from '../../../models/content'; +import { ContentService } from '../../../services/http/content.service'; export class ContentStatistic { content: Content; @@ -32,15 +33,19 @@ export class StatisticComponent implements OnInit { labels: string[] = ['a', 'b', 'c', 'd']; data: number[] = [12, 30, 43, 32]; stats: ContentStatistic; - roomId: string; + contentId: string; + subject: string; - constructor(protected route: ActivatedRoute) { } + constructor(protected route: ActivatedRoute, + private contentService: ContentService) { } ngOnInit() { this.route.params.subscribe(params => { - this.roomId = params['contentId']; + this.contentId = params['contentId']; + }); + this.contentService.getContent(this.contentId).subscribe(content => { + this.subject = content.subject; }); - console.log(this.roomId); this.chart = new Chart('chart', { type: 'bar', data: { @@ -51,6 +56,7 @@ export class StatisticComponent implements OnInit { }] }, options: { + title: this.subject, legend: { display: false },