Skip to content

Commit

Permalink
add label to nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
A Rod authored and A Rod committed Oct 19, 2020
1 parent 5922512 commit b07a3d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
10 changes: 4 additions & 6 deletions src/app/friend/graph-box/graph-box.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import * as d3 from 'd3';
import { Component, OnInit } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { Contact } from 'src/app/models/contact/contact.model';
import { Friend } from 'src/app/models/friend/friend.model';
import { selectFriend, selectContacts } from '../store/selector/friend.selectors';
import { FriendState } from '../store/reducer/friend.reducer';
import {select, Store} from '@ngrx/store';
import { Observable, combineLatest } from 'rxjs';
import { mergeMap } from 'rxjs/operators';
import { selectContacts, selectFriend } from '../store/selector/friend.selectors';


@Component({
Expand Down
3 changes: 2 additions & 1 deletion src/app/friend/graph/graph.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ svg {
}

circle {
fill: #88f;
fill: #88f;
stroke: #444;

&.selected {
fill: #f88;
Expand Down
13 changes: 2 additions & 11 deletions src/app/friend/graph/graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Outpu
import * as d3 from 'd3';
import { Contact } from 'src/app/models/contact/contact.model';
import { Friend } from 'src/app/models/friend/friend.model';
import { selectFriend, selectContacts } from '../store/selector/friend.selectors';
import { FriendState } from '../store/reducer/friend.reducer';
import {select, Store} from '@ngrx/store';
import { Observable, combineLatest } from 'rxjs';
import { mergeMap } from 'rxjs/operators';



Expand All @@ -17,9 +12,7 @@ import { mergeMap } from 'rxjs/operators';
})
export class GraphComponent implements OnChanges, OnInit, AfterViewInit {

@Output() select: EventEmitter<string> = new EventEmitter<string>();
@Input() nodes: Friend[] = [];
@Input() selectedNodes: Friend[] = [];
@Input() edges: Contact[] = [];
@ViewChild('graphContainer') graphContainer;

Expand Down Expand Up @@ -48,19 +41,17 @@ export class GraphComponent implements OnChanges, OnInit, AfterViewInit {
}

private selectNode = () => {
console.log("click")
const point = d3.mouse(this.graphContainer.nativeElement);
const node = this.simulation.find(point[0], point[1], 5) as Friend;
let node2 = this.simulation.find(d3.event.x, d3.event.y,5)
const node = this.simulation.find(point[0], point[1], 20) as Friend;

if (node) {
this.selectedNode = node
} else {
this.selectedNode = null
}
console.log("MOUNSE: ",this.stringify(point))
console.log("EVENT: ",d3.event.x,d3.event.y)
console.log("FROM MOUNSE: ",this.stringify(node))
console.log("FROM EVENT: ",this.stringify(node2))

}

Expand Down

0 comments on commit b07a3d6

Please sign in to comment.