File
Metadata
selector |
views-breakdown |
templateUrl |
./views-breakdown.component.html |
Methods
addNewGraph
|
addNewGraph()
|
|
|
removeGroup
|
removeGroup(group: number)
|
|
Parameters :
Name |
Type |
Optional |
group |
number
|
no
|
|
graphData
|
graphData: Observable<[]>
|
Type : Observable<[]>
|
|
viewsBreakdown
|
viewsBreakdown: Observable<string[]>
|
Type : Observable<string[]>
|
|
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { FormControl } from '@angular/forms';
import { ViewsFilterService } from '../services/views-filter.service';
import { Video, ViewsFilterState } from '../+state/video-stats.interfaces';
import { DashboardService } from '../services/dashboard.service';
import { ViewsBreakdownService, GraphData } from '../services/views-breakdown.service';
@Component({
selector: 'views-breakdown',
templateUrl: './views-breakdown.component.html'
})
export class ViewsBreakdownComponent {
viewsFilterState: Observable<ViewsFilterState>;
currentVideo: Observable<Video>;
viewsBreakdown: Observable<string[]>;
graphData: Observable<GraphData[]>;
// Could be used as ngModel example if desired.
newGraph: FormControl = new FormControl('age');
constructor(
viewsFilterService: ViewsFilterService,
dashboardService: DashboardService,
private viewsBreakdownService: ViewsBreakdownService) {
this.viewsFilterState = viewsFilterService.filterState;
this.currentVideo = dashboardService.currentVideo;
this.viewsBreakdown = viewsBreakdownService.getBreakdowns();
this.graphData = viewsBreakdownService.getGraphData();
}
addNewGraph() {
this.viewsBreakdownService.addNewGraphAxis(this.newGraph.value);
}
removeGroup(group: number) {
this.viewsBreakdownService.removeGroup(group);
}
}
<div class="card">
<div class="card-content">
<div class="card-title">Views Breakdown</div>
<filter-state-display
[viewsFilterState]="viewsFilterState | async"
(removeGroup)="removeGroup($event)"
></filter-state-display>
<views-breakdown-display
[currentVideo]="currentVideo | async"
[viewsBreakdown]="viewsBreakdown | async"
[graphData]="graphData | async"
>
</views-breakdown-display>
<div class="card">
<div class="card-content">
<div class="card-title">Add New Graph</div>
<p>Select an x-axis and click Render</p>
<div>
<label for="newGraph">Axis:</label>
<select name="newGraph" id="axis" [formControl]="newGraph" class="browser-default">
<option value="age">Age</option>
<option value="date">Day</option>
<option value="region">Region</option>
</select>
<button (click)="addNewGraph()" class="btn waves-effect waves-light">Render</button>
</div>
</div>
</div>
</div>
</div>
Legend
Html element with directive