Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Vis Libraries): Use new libraries #321

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ before_script:
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"

script:
- npm run build
- npm run build:all
- npm run check
- npm test

Expand Down
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ An angular 2+ vis.js project

# Usage

git commit --no-verify

## Installation

```
Expand Down
218 changes: 32 additions & 186 deletions components/network/index.ts
Original file line number Diff line number Diff line change
@@ -1,188 +1,34 @@
import * as Vis from 'vis';

import { VisDataSetOptions, VisDataSetQueueOptions, VisId } from '../timeline/index';

export { VisId } from '../timeline/index';
export type VisNetworkEvents = Vis.NetworkEvents;
export type VisMoveToOptions = Vis.MoveToOptions;

export interface VisClusterOptions extends Vis.ClusterOptions { }
export interface VisOpenClusterOptions extends Vis.OpenClusterOptions { }
export interface VisNetworkData extends Vis.Data { }
export interface VisNode extends Vis.Node { title?: string; }
export interface VisEdge extends Vis.Edge { }
export interface VisNodeSelectionOptions extends Vis.DataSelectionOptions<VisNode> { }
export interface VisEdgeSelectionOptions extends Vis.DataSelectionOptions<VisEdge> { }
export interface VisFitOptions extends Vis.FitOptions { }
export interface VisNetworkOptions extends Vis.Options { }
export interface VisEdgeOptions extends Vis.EdgeOptions { }
export class VisNetwork extends Vis.Network { }
export interface VisNodeOptions extends Vis.NodeOptions { }
export interface VisPosition extends Vis.Position { }

export class VisNodes extends Vis.DataSet<VisNode> {
public constructor(data?: VisNode[], options?: VisDataSetOptions) {
super(data, options);
}

public getLength(): number {
return this.length;
}

public add(data: VisNode | VisNode[], senderId?: VisId): VisId[] {
return super.add(data, senderId);
}

public clear(senderId?: VisId): VisId[] {
return super.clear(senderId);
}

public distinct(field: string): any[] {
return super.distinct(field);
}

public flush(): void {
super.flush();
}

public forEach(callback: (item: VisNode, id: VisId) => void, options?: VisNodeSelectionOptions): void {
super.forEach(callback, options);
}

public getAll(options?: VisNodeSelectionOptions): VisNode[] {
return super.get(options);
}

public getById(id: VisId, options?: VisNodeSelectionOptions): VisNode {
return super.get(id, options);
}

public getByIds(ids: VisId[], options?: VisNodeSelectionOptions): VisNode[] {
return super.get(ids, options);
}

public getDataSet(): VisNodes {
return super.getDataSet() as VisNodes;
}

public getIds(options?: VisNodeSelectionOptions): VisId[] {
return super.getIds(options);
}

public map(callback: (item: VisNode, id: VisId) => any, options?: VisNodeSelectionOptions): any[] {
return super.map(callback, options);
}

public max(field: string): VisNode {
return super.max(field);
}

public min(field: string): VisNode {
return super.min(field);
}

public on(event: string, callback: (event: string, properties: any, senderId: VisId) => void): void {
super.on(event, callback);
}

public off(event: string, callback: (event: string, properties: any, senderId: VisId) => void): void {
super.off(event, callback);
}

public removeItems(ids: VisId[], senderId?: VisId): VisId[] {
return super.remove(ids, senderId);
}

public setOptions(options?: VisDataSetQueueOptions): void {
super.setOptions(options);
}

public update(data: VisNode[], senderId?: VisId): VisId[] {
return super.update(data, senderId);
}
}

export class VisEdges extends Vis.DataSet<VisEdge> {
public constructor(data?: VisEdge[], options?: VisDataSetOptions) {
super(data, options);
}

public getLength(): number {
return this.length;
}

public add(data: VisEdge | VisEdge[], senderId?: VisId): VisId[] {
return super.add(data, senderId);
}

public clear(senderId?: VisId): VisId[] {
return super.clear(senderId);
}

public distinct(field: string): any[] {
return super.distinct(field);
}

public flush(): void {
super.flush();
}

public forEach(callback: (item: VisEdge, id: VisId) => void, options?: VisEdgeSelectionOptions): void {
super.forEach(callback, options);
}

public getAll(options?: VisEdgeSelectionOptions): VisEdge[] {
return super.get(options);
}

public getById(id: VisId, options?: VisEdgeSelectionOptions): VisEdge {
return super.get(id, options);
}

public getByIds(ids: VisId[], options?: VisEdgeSelectionOptions): VisEdge[] {
return super.get(ids, options);
}

public getDataSet(): VisEdges {
return super.getDataSet() as VisEdges;
}

public getIds(options?: VisEdgeSelectionOptions): VisId[] {
return super.getIds(options);
}

public map(callback: (item: VisEdge, id: VisId) => any, options?: VisEdgeSelectionOptions): any[] {
return super.map(callback, options);
}

public max(field: string): VisEdge {
return super.max(field);
}

public min(field: string): VisEdge {
return super.min(field);
}

public on(event: string, callback: (event: string, properties: any, senderId: VisId) => void): void {
super.on(event, callback);
}

public off(event: string, callback: (event: string, properties: any, senderId: VisId) => void): void {
super.off(event, callback);
}

public removeItems(ids: VisId[], senderId?: VisId): VisId[] {
return super.remove(ids, senderId);
}

public setOptions(options?: VisDataSetQueueOptions): void {
super.setOptions(options);
}

public update(data: VisEdge[], senderId?: VisId): VisId[] {
return super.update(data, senderId);
}
}

import {
ClusterOptions,
Data,
DataSet,
Edge,
EdgeOptions,
FitOptions,
MoveToOptions,
Network,
NetworkEvents,
Node,
NodeOptions,
OpenClusterOptions,
Options,
SelectionOptions
} from 'vis-network';
export {
ClusterOptions,
Data,
DataSet,
Edge,
EdgeOptions,
FitOptions,
MoveToOptions,
Network,
NetworkEvents,
Node,
NodeOptions,
OpenClusterOptions,
Options,
SelectionOptions
};
export * from './vis-network.directive';
export * from './vis-network.service';
45 changes: 13 additions & 32 deletions components/network/vis-network.directive.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import {
Directive,
ElementRef,
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output,
SimpleChange } from '@angular/core';
import { Directive, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChange } from '@angular/core';

import { Data, Options } from '.';
import { VisNetworkService } from './vis-network.service';

import {
VisNetworkData,
VisNetworkOptions,
} from './index';

/**
* Use this directive with a div container to show network data.
*
Expand All @@ -26,10 +13,9 @@ import {
* @implements {OnChanges}
*/
@Directive({
selector: '[visNetwork]',
selector: '[visNetwork]'
})
export class VisNetworkDirective implements OnInit, OnDestroy, OnChanges {

/**
* The name or identifier of the network (must be unique in your application).
* This property is used once on init and must not be changed.
Expand All @@ -46,23 +32,23 @@ export class VisNetworkDirective implements OnInit, OnDestroy, OnChanges {
* changes to the reference of this object.
* Changes lead to a call to setData of this network instance.
*
* @type {VisNetworkData}
* @type {Data}
* @memberOf VisNetworkDirective
*/
@Input()
public visNetworkData: VisNetworkData;
public visNetworkData: Data;

/**
* The options that will be used with this network instance.
* Only reference changes to the whole options object will be detected
* but not changes to properties.
* Changes lead to a call to setOptions of the network instance.
*
* @type {VisNetworkOptions}
* @type {VisOptions}
* @memberOf VisNetworkDirective
*/
@Input()
public visNetworkOptions: VisNetworkOptions;
public visNetworkOptions: Options;

/**
* This event will be raised when the network is initialized.
Expand Down Expand Up @@ -92,7 +78,7 @@ export class VisNetworkDirective implements OnInit, OnDestroy, OnChanges {
}

/**
* Create the network when at least visNetwork and visNetworkData
* Create the network when at least visNetwork and visData
* are defined.
*
* @memberOf VisNetworkDirective
Expand All @@ -105,14 +91,13 @@ export class VisNetworkDirective implements OnInit, OnDestroy, OnChanges {

/**
* Update the network data or options on reference changes to
* the visNetworkData or visNetworkOptions properties.
* the visData or visOptions properties.
*
* @param {{[propName: string]: SimpleChange}} changes
*
* @memberOf VisNetworkDirective
*/
public ngOnChanges(changes: {[propName: string]: SimpleChange}): void {

public ngOnChanges(changes: { [propName: string]: SimpleChange }): void {
if (!this.isInitialized && this.visNetwork && this.visNetworkData) {
this.createNetwork();
}
Expand All @@ -121,10 +106,10 @@ export class VisNetworkDirective implements OnInit, OnDestroy, OnChanges {
if (changes.hasOwnProperty(propertyName)) {
const change = changes[propertyName];
if (!change.isFirstChange()) {
if (propertyName === 'visNetworkData') {
if (propertyName === 'visData') {
this.visNetworkService.setData(this.visNetwork, changes[propertyName].currentValue);
}
if (propertyName === 'visNetworkOptions') {
if (propertyName === 'visOptions') {
this.visNetworkService.setOptions(this.visNetwork, changes[propertyName].currentValue);
}
}
Expand All @@ -143,11 +128,7 @@ export class VisNetworkDirective implements OnInit, OnDestroy, OnChanges {
}

private createNetwork(): void {
this.visNetworkService.create(
this.visNetwork,
this.visNetworkContainer,
this.visNetworkData,
this.visNetworkOptions);
this.visNetworkService.create(this.visNetwork, this.visNetworkContainer, this.visNetworkData, this.visNetworkOptions);
this.isInitialized = true;
this.initialized.emit(this.visNetwork);
}
Expand Down
Loading