Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Fix Typescript error in force_directed_graph.ts (#74)
Browse files Browse the repository at this point in the history
Fix Typescript error in force_directed_graph.ts
  • Loading branch information
dvvanessastoiber authored Oct 31, 2019
2 parents 738a2ce + 50bdea1 commit 5f05bbd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/force_directed_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as d3 from 'd3';
import {AVisInstance, IVisInstance, assignVis, IVisInstanceOptions} from 'phovea_core/src/vis';
import {mixin} from 'phovea_core/src';
import GraphProxy from 'phovea_core/src/graph/GraphProxy';
import { GraphNode } from 'phovea_core/src/graph/graph';

export interface IForceDirectedGraphOptions extends IVisInstanceOptions {
/**
Expand All @@ -17,6 +18,13 @@ export interface IForceDirectedGraphOptions extends IVisInstanceOptions {
colors?: boolean;
}

/**
* Extends the D3 Node with a Phovea GraphNode property
*/
interface IMixedNode extends d3.layout.force.Node {
v: GraphNode;
}

export class ForceDirectedGraphVis extends AVisInstance implements IVisInstance {
private readonly $node: d3.Selection<any>;

Expand Down Expand Up @@ -107,7 +115,7 @@ export class ForceDirectedGraphVis extends AVisInstance implements IVisInstance
const colors = d3.scale.category10().range().slice();

this.data.impl().then((graph) => {
const nodes = graph.nodes.map((n) => ({v: n}));
const nodes: IMixedNode[] = graph.nodes.map((n) => ({v: n}));
const lookup = d3.map(nodes, (d) => String(d.v.id));
const edges = graph.edges.map((n) => ({
v: n,
Expand Down

0 comments on commit 5f05bbd

Please sign in to comment.