2
0

added download button

This commit is contained in:
2018-08-06 17:11:23 +02:00
parent b4e915d1ea
commit 40df45ae0e
7 changed files with 145 additions and 99 deletions

View File

@@ -14,7 +14,7 @@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { ViewChildren, QueryList, Component, ViewChild, Input, SimpleChanges, OnChanges, HostListener } from '@angular/core';
import { ViewChild, QueryList, Component, Input, Output, SimpleChanges, OnChanges, HostListener, EventEmitter } from '@angular/core';
import * as Selection from 'd3-selection';
import * as Shape from 'd3-shape';
import * as Random from 'd3-random';
@@ -38,12 +38,13 @@ export class GraphsComponent implements OnChanges {
public matrix: any | null;
private genShiftPoint: any | null;
private genLoadedAllGraphs: any | null;
@Input() config: any;
@ViewChild('svg') svgElementRef;
@ViewChild(GuillocheDirective) guillocheViewChild: GuillocheDirective;
@ViewChildren(GuillocheDirective) guillocheViewChildren: QueryList<GuillocheDirective>;
@Output() svgChange = new EventEmitter();
@HostListener('window:resize', ['$event'])
private onResize(event) {
@@ -53,6 +54,7 @@ export class GraphsComponent implements OnChanges {
constructor(
private canvasService: CanvasService
) {
this.genLoadedAllGraphs = this.countLoadedGraphs();
}
ngOnChanges(changes: SimpleChanges) {
@@ -65,6 +67,28 @@ export class GraphsComponent implements OnChanges {
this.updateGraphs();
}
public prepareGuillocheExport(guillocheElement) {
const item = this.genLoadedAllGraphs.next().value;
console.log(item);
if (item) {
this.svgChange.emit(this.svgElementRef);
}
}
private *countLoadedGraphs() {
let cycles = 1;
while (true) {
if (cycles < this.graphs.length) {
yield false;
cycles++;
} else {
yield true;
cycles = 1;
}
}
}
private updateGraphs(): void {
const genShiftStart = this.shiftPoint(this.matrix.start, this.config.vectors.start);
const genShiftEnd = this.shiftPoint(this.matrix.end, this.config.vectors.end);