From c7d079ed0dcc9f5d32e71660c03a7fe675a1513b Mon Sep 17 00:00:00 2001 From: ziajka Date: Mon, 23 Jul 2018 17:57:09 +0200 Subject: [PATCH] Fix default map size --- .../components/map/map.component.ts | 13 +++-------- src/app/cartography/widgets/graph-layout.ts | 4 ++++ src/index.html | 22 +++++++++---------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/app/cartography/components/map/map.component.ts b/src/app/cartography/components/map/map.component.ts index 87430bb8..1a69bff0 100644 --- a/src/app/cartography/components/map/map.component.ts +++ b/src/app/cartography/components/map/map.component.ts @@ -2,7 +2,7 @@ import { Component, ElementRef, HostListener, Input, OnChanges, OnDestroy, OnInit, SimpleChange } from '@angular/core'; import { D3, D3Service } from 'd3-ng2-service'; -import {select, Selection} from 'd3-selection'; +import { select, Selection } from 'd3-selection'; import { Node } from "../../models/node"; import { Link } from "../../models/link"; @@ -10,7 +10,7 @@ import { GraphLayout } from "../../widgets/graph-layout"; import { Context } from "../../models/context"; import { Size } from "../../models/size"; import { Drawing } from "../../models/drawing"; -import {Symbol} from "../../models/symbol"; +import { Symbol } from "../../models/symbol"; @Component({ @@ -30,10 +30,9 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy { private d3: D3; private parentNativeElement: any; private svg: Selection; - - public graphLayout: GraphLayout; private graphContext: Context; + public graphLayout: GraphLayout; constructor(protected element: ElementRef, protected d3Service: D3Service @@ -118,12 +117,6 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy { this.graphContext.size = this.getSize(); } - if (this.graphContext != null) { - this.svg - .attr('width', this.graphContext.size.width) - .attr('height', this.graphContext.size.height); - } - this.graphLayout.setNodes(this.nodes); this.graphLayout.setLinks(this.links); this.graphLayout.setDrawings(this.drawings); diff --git a/src/app/cartography/widgets/graph-layout.ts b/src/app/cartography/widgets/graph-layout.ts index 24f1bb75..1462c713 100644 --- a/src/app/cartography/widgets/graph-layout.ts +++ b/src/app/cartography/widgets/graph-layout.ts @@ -82,6 +82,10 @@ export class GraphLayout implements Widget { } draw(view: SVGSelection, context: Context) { + view + .attr('width', context.size.width) + .attr('height', context.size.height); + const canvas = view .selectAll('g.canvas') .data([context]); diff --git a/src/index.html b/src/index.html index 8f7720e2..72379fa1 100644 --- a/src/index.html +++ b/src/index.html @@ -4,21 +4,21 @@ GNS3 Web UI - +