2
0

logic splitted into directives and components

This commit is contained in:
2018-05-23 09:14:52 +02:00
parent 06764e3e7f
commit b18c196610
14 changed files with 148 additions and 22 deletions

View File

@@ -0,0 +1,48 @@
import { ViewChildren, QueryList, Component, AfterViewInit, ViewChild, Input, OnInit } from '@angular/core';
import * as Selection from 'd3-selection';
import * as Shape from 'd3-shape';
import * as Random from 'd3-random';
import * as Drag from 'd3-drag';
// import { GuillocheComponent } from './../components/guilloche.component';
import { GuillocheDirective } from './../directives/guilloche.directive';
import { Graph } from '../models/graph.model';
@Component({
selector: 'app-graphs',
templateUrl: './graphs.component.html',
styleUrls: ['./graphs.component.scss']
})
export class GraphsComponent implements AfterViewInit, OnInit {
// public width: number;
// public height: number;
public graphs: Graph[];
public svg: any;
@Input() config: any;
@ViewChild('svg') svgElementRef;
@ViewChild(GuillocheDirective) guillocheViewChild: GuillocheDirective;
@ViewChildren(GuillocheDirective) guillocheViewChildren: QueryList<GuillocheDirective>;
ngOnInit() {
// this.width = 0;
// this.height = 0;
this.graphs = [...[{
id: 'first',
start: {coords: { x: 0, y: 0 }, direction: this.config.start.direction },
end: { coords: { x: 0, y: -10 }, direction: this.config.end.direction}
}, {
id: 'second',
start: {coords: { x: 0, y: 0 }, direction: this.config.end.direction },
end: { coords: { x: 0, y: -10 }, direction: this.config.start.direction}
}]];
}
ngAfterViewInit() {
this.svg = Selection.select(this.svgElementRef.nativeElement);
console.log('graph component', this.guillocheViewChildren.toArray());
}
}