Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4803fd7
upload folder
alkadi-mh Nov 30, 2020
815c608
fixes
alkadi-mh Feb 1, 2021
f185950
Saving and restoring states
alkadi-mh Mar 15, 2021
01dab16
restoring controls values
alkadi-mh Apr 17, 2021
446d925
fix NumberQuery number issue
benjbach Jul 28, 2021
68c50b4
fix color and shape issue for nodes
benjbach Jul 29, 2021
1cdda68
make ScalarTimeSeries more solid
benjbach Jul 30, 2021
c0ef16b
you can now create visualizations by just calling them with their nam…
benjbach Jul 30, 2021
5e359b2
you can now create visualizations by just calling them with their nam…
benjbach Jul 30, 2021
33f31e3
you can now create visualizations by just calling them
benjbach Jul 30, 2021
9ac0cd8
you can now create visualizations by just calling them with their nam…
benjbach Jul 30, 2021
41ee943
you can now create visualizations by just calling them
benjbach Jul 30, 2021
d495eab
expose exporters
benjbach Jul 30, 2021
876ab7b
expose exporters
benjbach Jul 30, 2021
c2e05c9
expose importer functions
benjbach Jul 30, 2021
b8fca12
?
benjbach Aug 1, 2021
b784e2e
make sure all is up to day
benjbach Aug 2, 2021
bf42af0
remove src from npm
benjbach Aug 2, 2021
dc857ca
remove /src from npm package
benjbach Aug 2, 2021
211211f
add src from npm
benjbach Aug 2, 2021
a4d364c
add /src from npm package
benjbach Aug 2, 2021
2798c70
add /src from npm package
benjbach Aug 2, 2021
5cd56a3
add src from npm
benjbach Aug 2, 2021
3f63d47
zoom/pan logs
alkadi-mh Aug 14, 2021
4700e67
merge changes
alkadi-mh Aug 14, 2021
4c2258e
Delete package-lock.json
alkadi-mh Aug 14, 2021
169769d
updates
alkadi-mh Aug 14, 2021
f7973c5
zoom/pan logs
alkadi-mh Aug 14, 2021
1df975d
updates
alkadi-mh Aug 14, 2021
d5dd449
logs update
alkadi-mh Aug 15, 2021
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 docs/assets/js/main.js

Large diffs are not rendered by default.

163 changes: 94 additions & 69 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vistorian-core",
"version": "0.0.2-alpha",
"version": "0.0.12",
"description": "Vistorian-core is a java script / (Typescript) library and a programming framework for interactive network visualizations with:",
"private": false,
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -28,13 +28,13 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/networkcube/vistorian-core.git"
"url": "git+https://github.com/alkadi-mh/vistorian-core.git"
},
"collaborators": [
"Jean-Daniel Fekete <Jean-Daniel.Fekete@inria.fr",
"Alexandra Ibarra Cuesta"
],
"homepage": "https://github.com/networkcube/vistorian-core#readme",
"homepage": "https://github.com/alkadi-mh/vistorian-core.git#readme",
"bundledDependencies": [
"moment"
],
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
input: 'build/src/index.js',
external: [
'd3',
'lz-string',
'lz-string',
'reorder.js',
'netclustering',
'swiftset',
Expand Down
79 changes: 52 additions & 27 deletions src/dynamicgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@ export class DynamicGraph {
this.nodeArrays.filter.push(false);
this.nodeArrays.locations.push(new ScalarTimeSeries<number>());
this.nodeArrays.attributes.push(new Object());
this.nodeArrays.colors.push('')
this.nodeArrays.shapes.push('')
this.nodeArrays.color.push('')
this.nodeArrays.shape.push('')
if (isValidIndex(data.nodeSchema.label)) {
this.nodeArrays.label.push(row[data.nodeSchema.label]);
} else {
Expand Down Expand Up @@ -778,7 +778,7 @@ export class DynamicGraph {
// check shapes
if (isValidIndex(data.nodeSchema.shape)) {
var shape = row[data.nodeSchema.shape];
this.nodeArrays.shapes.push(shape);
this.nodeArrays.shape.push(shape);
}

// gather node type
Expand Down Expand Up @@ -1030,7 +1030,7 @@ export class DynamicGraph {
for (var i = 0; i < this.linkArrays.length; i++) {
for (var j = 0; j < this.timeArrays.length; j++) {
if(this.linkArrays.weights[i]) {
if (this.linkArrays.weights[i].serie.hasOwnProperty(this.timeArrays.id[j].toString())) {
if (this.linkArrays.weights[i].toArray().hasOwnProperty(this.timeArrays.id[j].toString())) {
this.timeArrays.links[j].push(this.linkArrays.id[i]);
}
}
Expand All @@ -1040,7 +1040,7 @@ export class DynamicGraph {
//Build a color mapping
const colorSet = new Set(['#e4549b', '#a33a36', '#bd6221', '#dfba47', '#b5b867', '#479b7f', '#335b8e', '#78387d']);
var colorMappings: { [color: string]: string; } = {};
(this.nodeArrays as any).color.forEach(function (color: any) {
this.nodeArrays.color.forEach(function (color: any) {
if (!colorMappings[color]) {
let colorSetAsArray = Array.from(colorSet)
var generatedColor = colorSetAsArray[Math.floor(Math.random() * colorSetAsArray.length)]
Expand All @@ -1050,14 +1050,14 @@ export class DynamicGraph {
});

//Add color values to nodeArray colors
for(var i=0; i<(this.nodeArrays as any).color.length; i++) {
(this.nodeArrays as any).color[i] = [(this.nodeArrays as any).color[i], colorMappings[(this.nodeArrays as any).color[i]]];
for(var i=0; i<this.nodeArrays.color.length; i++) {
this.nodeArrays.color[i] = this.nodeArrays.color[i], colorMappings[this.nodeArrays.color[i]];
}

//Build a shape mapping
const shapeSet = new Set(['cross', 'diamond', 'square', 'triangle-down', 'triangle-up']);
var shapeMappings: { [shape: string]: string; } = {};
(this.nodeArrays as any).shape.forEach(function (shape: any) {
this.nodeArrays.shape.forEach(function (shape: any) {
if (!shapeMappings[shape]) {
let shapeSetAsArray = Array.from(shapeSet)
var generatedShape = shapeSetAsArray[Math.floor(Math.random() * shapeSetAsArray.length)]
Expand All @@ -1067,8 +1067,8 @@ export class DynamicGraph {
});

//Add shapes to nodeArray shapes
for(var i=0; i<(this.nodeArrays as any).shape.length; i++) {
(this.nodeArrays as any).shape[i] = [(this.nodeArrays as any).shape[i], shapeMappings[(this.nodeArrays as any).shape[i]]];
for(var i=0; i<this.nodeArrays.shape.length; i++) {
this.nodeArrays.shape[i] = this.nodeArrays.shape[i], shapeMappings[this.nodeArrays.shape[i]];
}
console.log(" TEST ")
console.log(this)
Expand Down Expand Up @@ -1870,8 +1870,8 @@ export class NodeArray extends AttributeArray {
locations: ScalarTimeSeries<number>[] = []
filter: boolean[] = [];
nodeType: string[] = [];
colors: string[] = [];
shapes: string[] = [];
color: string[] = [];
shape: string[] = [];
}

export class LinkArray extends AttributeArray {
Expand Down Expand Up @@ -2295,7 +2295,7 @@ export class BasicElement {
* steps in the format key->value. I.e. the value for the
* time step with ID 3 is accessed by this.3 */
export class ScalarTimeSeries<T>{
serie: any = {};
private serie: any = {};

/** @returns a ScalarTimeSeries for the specified period. */
period(t1: Time, t2: Time): ScalarTimeSeries<T> {
Expand All @@ -2318,14 +2318,17 @@ export class ScalarTimeSeries<T>{
/** @returns the value for a specified time point. */
get(t: Time): any { // before T!!
if (this.serie[t.id()] == undefined)
return; // this is avoid!!
return ; // this is avoid!!
return this.serie[t.id()];
}

size(): number {
return this.toArray().length;
}

getSerie(): Object[]{
return this.serie;
}

/** Returns all values as array.
* @param removeDuplicates
Expand Down Expand Up @@ -2664,27 +2667,29 @@ export class NumberQuery extends Query {
}

min(): number {
var min: number = this._elements[0];
this._elements = this.makeNumbers(this._elements);
var min: number = parseInt(this._elements[0]+'');
for (var i = 1; i < this._elements.length; i++) {
if (this._elements[i] != undefined)
min = Math.min(min, this._elements[i]);
min = Math.min(min, parseInt(this._elements[i]+''));
}
return min;
}
max(): number {
var max: number = this._elements[0];
var max: number = parseInt(this._elements[0]+'');
for (var i = 1; i < this._elements.length; i++) {
if (this._elements[i] != undefined)
max = Math.max(max, this._elements[i]);
max = Math.max(max, parseInt(this._elements[i]+''));
}
return max;
}
mean(): number {
this._elements = this.makeNumbers(this._elements);
var v = 0;
var count = 0;
for (var i = 0; i < this._elements.length; i++) {
if (typeof this._elements[i] == 'number') {
v += this._elements[i];
v += parseInt(this._elements[i]+'');
count++;
}
}
Expand All @@ -2694,7 +2699,7 @@ export class NumberQuery extends Query {
var sum = 0;
for (var i = 0; i < this._elements.length; i++) {
if (typeof this._elements[i] == 'number') {
sum += this._elements[i];
sum += parseInt(this._elements[i]+'');
}
}
return sum;
Expand All @@ -2714,6 +2719,23 @@ export class NumberQuery extends Query {
}
return this;
}

makeNumbers(elements:number[]): number[]
{
if(elements && elements.length > 0){
var first = elements[0]
if(typeof first == 'string'){
var numberElements:number[] = []
for (var i = 0; i < elements.length; i++){
numberElements.push(parseFloat(elements[i]+''))
}
console.log('string array converted', numberElements)
return numberElements;
}
}

return elements;
}

}

Expand Down Expand Up @@ -3128,22 +3150,25 @@ export class Node extends BasicElement {
var serie: ScalarTimeSeries<number>;
if (t2 != undefined && t1 != undefined)
serie = (<ScalarTimeSeries<number>>this.attr('locations')).period(t1, t2);
// return this.attr('locations').period(t1, t2);
else if (t1 != undefined)
serie = (<ScalarTimeSeries<number>>(this.attr('locations')).get(t1));
// return this.attr('locations').get(t1);
else
serie = (<ScalarTimeSeries<number>>this.attr('locations'));
// return this.attr('locations');

serie = serie.serie;
// replace numbers by times
var serie2 = new ScalarTimeSeries<Location>();
for (var t in serie) {
var serie2 = serie.getSerie();
// replace numbers by locations
var serie3 = new ScalarTimeSeries<Location>();
for (var t in serie2) {
var time = this.g.time(parseInt(t));
var location = this.g.location((serie as any)[t]);
var location = this.g.location((serie2 as any)[t]);
if (time != undefined && location != undefined) {
serie2.set(time, location);
serie3.set(time, location);
}
}
return serie2;
return serie3;
}


Expand Down
Loading