@linkurious/ogma-linkurious-parser 3.0.11 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ogma/features/captions.d.ts +1 -6
- package/dist/ogma/features/captions.js +0 -33
- package/dist/ogma/features/captions.js.map +1 -1
- package/dist/ogma/features/reactive.d.ts +5 -5
- package/dist/ogma/features/reactive.js +34 -34
- package/dist/ogma/features/reactive.js.map +1 -1
- package/dist/ogma/features/selectors.d.ts +1 -1
- package/dist/ogma/features/selectors.js.map +1 -1
- package/dist/ogma/features/styles.js +6 -16
- package/dist/ogma/features/styles.js.map +1 -1
- package/dist/ogma/features/transformations.d.ts +1 -1
- package/dist/ogma/features/transformations.js +1 -0
- package/dist/ogma/features/transformations.js.map +1 -1
- package/dist/ogma/index.d.ts +17 -7
- package/dist/ogma/index.js +63 -22
- package/dist/ogma/index.js.map +1 -1
- package/dist/styles/edgeAttributes.d.ts +4 -3
- package/dist/styles/edgeAttributes.js +12 -6
- package/dist/styles/edgeAttributes.js.map +1 -1
- package/dist/styles/itemAttributes.d.ts +14 -3
- package/dist/styles/itemAttributes.js +28 -3
- package/dist/styles/itemAttributes.js.map +1 -1
- package/dist/styles/nodeAttributes.d.ts +4 -3
- package/dist/styles/nodeAttributes.js +12 -6
- package/dist/styles/nodeAttributes.js.map +1 -1
- package/dist/tools/ogmaTool.d.ts +1 -1
- package/dist/tools/ogmaTool.js.map +1 -1
- package/dist/tools/tools.d.ts +1 -1
- package/dist/tools/tools.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GenericObject, IEdgeGroupStyle, LkEdgeData, LkNodeData } from '@linkurious/rest-client';
|
|
2
|
-
import { StyleRule, Transformation } from 'ogma';
|
|
2
|
+
import { StyleRule, Transformation } from '@linkurious/ogma';
|
|
3
3
|
import { LKOgma } from '../index';
|
|
4
4
|
export declare class TransformationsViz {
|
|
5
5
|
private _ogma;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformations.js","sourceRoot":"","sources":["../../../src/ogma/features/transformations.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"transformations.js","sourceRoot":"","sources":["../../../src/ogma/features/transformations.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeb,IAAM,wBAAwB,GAS1B;IACF,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE;QACL,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,OAAO;KACd;IACD,KAAK,EAAE,GAAG;CACX,CAAC;AAEF;IAOE,4BAAY,IAAY;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACU,+CAAkB,GAA/B;;;;gBACE,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE;oBACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC;wBAC/D,wBAAwB,EAAE,IAAI;wBAC9B,QAAQ,EAAE,UAAC,IAAI;4BACb,OAAO,KAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;wBACjD,CAAC;wBACD,eAAe,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAApB,CAAoB;wBAC/C,SAAS,EAAE,UAAC,KAAK;4BACf,OAAO;gCACL,IAAI,EAAE;oCACJ,UAAU,EAAE;wCACV,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,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,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;SACtC;IACH,CAAC;IACH,yBAAC;AAAD,CAAC,AArED,IAqEC;AArEY,gDAAkB","sourcesContent":["'use strict';\n\nimport {GenericObject, IEdgeGroupStyle, LkEdgeData, LkNodeData} from '@linkurious/rest-client';\nimport {\n Edge,\n EdgeExtremity,\n EdgeStyle,\n EdgeType,\n PixelSize,\n StyleRule,\n Transformation\n} from '@linkurious/ogma';\n\nimport {LKOgma} from '../index';\n\nconst DEFAULT_EDGE_GROUP_STYLE: {\n color: string;\n shape: {\n body?: EdgeType;\n head?: EdgeExtremity;\n tail?: EdgeExtremity;\n style?: EdgeStyle;\n };\n width: PixelSize;\n} = {\n color: '#000000',\n shape: {\n style: 'dashed',\n head: 'arrow'\n },\n width: 1.5\n};\n\nexport class TransformationsViz {\n private _ogma: LKOgma;\n public groupedEdges: GenericObject<boolean>;\n public edgeGroupStyle!: IEdgeGroupStyle;\n public transformation!: Transformation<LkNodeData, LkEdgeData>;\n public edgeGroupingStyleRule!: StyleRule<LkNodeData, LkEdgeData>;\n\n constructor(ogma: LKOgma) {\n this._ogma = ogma;\n this.groupedEdges = {};\n }\n\n /**\n * create an edge grouping transformation by edge type\n */\n public async initTransformation(): Promise<void> {\n if (this.transformation === undefined) {\n this.transformation = this._ogma.transformations.addEdgeGrouping({\n separateEdgesByDirection: true,\n selector: (edge) => {\n return this.groupedEdges[edge.getData('type')];\n },\n groupIdFunction: (edge) => edge.getData('type'),\n generator: (edges) => {\n return {\n data: {\n properties: {\n originalType: edges.getData('type')[0]\n }\n }\n };\n }\n });\n } else {\n this.transformation.refresh();\n }\n }\n\n /**\n * init edge grouping style\n */\n public async initEdgeGroupingStyle() {\n this.edgeGroupingStyleRule = this._ogma.styles.addRule({\n edgeAttributes: {\n ...DEFAULT_EDGE_GROUP_STYLE,\n ...(this.edgeGroupStyle as any),\n text: {\n content: (edge: Edge<LkEdgeData> | undefined) => {\n if (edge !== undefined && edge.getSubEdges() !== null) {\n const size = edge.getSubEdges()!.filter((e) => !e.hasClass('filtered')).size;\n return `${edge.getData(['properties', 'originalType'])} - ${size}`;\n }\n },\n style: 'bold'\n }\n },\n edgeSelector: (edge) =>\n edge.isVirtual() &&\n edge.getSubEdges() &&\n edge.getSubEdges()!.filter((e) => !e.hasClass('filtered')).size > 0,\n edgeDependencies: {self: {data: true}}\n });\n }\n\n public refreshEdgeGroupingStyle(): void {\n if (this.edgeGroupingStyleRule !== undefined) {\n this.edgeGroupingStyleRule.refresh();\n }\n }\n}\n"]}
|
package/dist/ogma/index.d.ts
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { ForceLayoutMode, HierarchicalLayoutMode, IOgmaConfig, LkEdgeData, LkNodeData, PopulatedVisualization, VizEdge, VizNode } from '@linkurious/rest-client';
|
|
2
|
-
import Ogma, { EdgeList, ForceLayoutOptions, HierarchicalLayoutOptions, NodeList, NonObjectPropertyWatcher, RadialLayoutOptions, RawEdge, RawGraph } from 'ogma';
|
|
2
|
+
import Ogma, { EdgeList, ForceLayoutOptions, HierarchicalLayoutOptions, NodeList, NonObjectPropertyWatcher, RadialLayoutOptions, RawEdge, RawGraph } from '@linkurious/ogma';
|
|
3
3
|
import { StylesViz } from './features/styles';
|
|
4
4
|
import { TransformationsViz } from './features/transformations';
|
|
5
5
|
import { CaptionsViz } from './features/captions';
|
|
6
6
|
import { OgmaStore } from './features/OgmaStore';
|
|
7
|
-
export { default as Ogma } from 'ogma';
|
|
7
|
+
export { default as Ogma } from '@linkurious/ogma';
|
|
8
8
|
export declare const ANIMATION_DURATION = 750;
|
|
9
9
|
interface AddItemOptions {
|
|
10
10
|
batchSize?: number;
|
|
11
11
|
virtual?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare class LKOgma extends Ogma<LkNodeData, LkEdgeData> {
|
|
14
|
-
private
|
|
14
|
+
private _configuration;
|
|
15
15
|
LKStyles: StylesViz;
|
|
16
16
|
LKCaptions: CaptionsViz;
|
|
17
17
|
LKTransformation: TransformationsViz;
|
|
18
18
|
nodeCategoriesWatcher: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;
|
|
19
19
|
edgeTypeWatcher: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;
|
|
20
20
|
store: OgmaStore;
|
|
21
|
-
|
|
21
|
+
private _reactive;
|
|
22
|
+
constructor(_configuration: IOgmaConfig);
|
|
23
|
+
private initOgmaLinkuriousParser;
|
|
22
24
|
/**
|
|
23
25
|
* Initialize selection behavior
|
|
24
26
|
*/
|
|
25
27
|
initSelection(): void;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
+
private setStyles;
|
|
29
|
+
private setCaptions;
|
|
28
30
|
/**
|
|
29
31
|
* Returns Ogma Layout parameters according to visualization layout settings
|
|
30
32
|
* */
|
|
31
33
|
getForceLayoutParams(mode: ForceLayoutMode, duration?: number): ForceLayoutOptions;
|
|
32
|
-
getRadialLayoutParams(rootNode: string, duration?: number): RadialLayoutOptions
|
|
34
|
+
getRadialLayoutParams(rootNode: string, duration?: number): RadialLayoutOptions<unknown, unknown>;
|
|
33
35
|
getHierarchicalLayoutParams(mode: HierarchicalLayoutMode, rootNode: string, duration?: number): HierarchicalLayoutOptions;
|
|
34
36
|
/**
|
|
35
37
|
* Initialize graph.
|
|
@@ -71,4 +73,12 @@ export declare class LKOgma extends Ogma<LkNodeData, LkEdgeData> {
|
|
|
71
73
|
* Do a full reset on ogma and streams of ogma
|
|
72
74
|
*/
|
|
73
75
|
shutDown(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Reset the Ogma instance so that it can be used fresh in the next visulization
|
|
78
|
+
*/
|
|
79
|
+
clearOgmaState(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()
|
|
82
|
+
*/
|
|
83
|
+
setConfigOgma(configuration: IOgmaConfig, init?: boolean): void;
|
|
74
84
|
}
|
package/dist/ogma/index.js
CHANGED
|
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
12
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
15
26
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
27
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
28
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -53,35 +64,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
53
64
|
};
|
|
54
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
66
|
var rest_client_1 = require("@linkurious/rest-client");
|
|
56
|
-
var ogma_1 = __importDefault(require("ogma"));
|
|
67
|
+
var ogma_1 = __importDefault(require("@linkurious/ogma"));
|
|
57
68
|
var __1 = require("..");
|
|
58
69
|
var tools_1 = require("../tools/tools");
|
|
59
70
|
var styles_1 = require("./features/styles");
|
|
60
71
|
var transformations_1 = require("./features/transformations");
|
|
61
72
|
var captions_1 = require("./features/captions");
|
|
62
73
|
var reactive_1 = require("./features/reactive");
|
|
63
|
-
var ogma_2 = require("ogma");
|
|
74
|
+
var ogma_2 = require("@linkurious/ogma");
|
|
64
75
|
exports.Ogma = ogma_2.default;
|
|
65
76
|
exports.ANIMATION_DURATION = 750;
|
|
66
77
|
var LKOgma = /** @class */ (function (_super) {
|
|
67
78
|
__extends(LKOgma, _super);
|
|
68
|
-
function LKOgma(
|
|
79
|
+
function LKOgma(_configuration) {
|
|
69
80
|
var _newTarget = this.constructor;
|
|
70
81
|
var _this =
|
|
71
82
|
// set Ogma global configuration
|
|
72
|
-
_super.call(this,
|
|
73
|
-
_this.
|
|
83
|
+
_super.call(this, _configuration) || this;
|
|
84
|
+
_this._configuration = _configuration;
|
|
85
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
86
|
+
_this.initOgmaLinkuriousParser();
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
LKOgma.prototype.initOgmaLinkuriousParser = function () {
|
|
90
|
+
this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({
|
|
74
91
|
path: 'categories',
|
|
75
92
|
unwindArrays: true,
|
|
76
93
|
filter: 'all'
|
|
77
94
|
});
|
|
78
|
-
|
|
95
|
+
this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({
|
|
79
96
|
path: 'type',
|
|
80
97
|
filter: 'all'
|
|
81
98
|
});
|
|
82
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
83
99
|
// set ogma max zoom value and selection with mouse option (false?)
|
|
84
|
-
|
|
100
|
+
this.setOptions({
|
|
85
101
|
interactions: {
|
|
86
102
|
zoom: {
|
|
87
103
|
maxValue: function (params) {
|
|
@@ -93,18 +109,23 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
93
109
|
}
|
|
94
110
|
}
|
|
95
111
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
// only instantiate the store once when app is starting
|
|
113
|
+
if (this._reactive === undefined) {
|
|
114
|
+
this._reactive = new reactive_1.RxViz(this);
|
|
115
|
+
this.store = this._reactive.store;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// if store already exist, but ogma was reset, create new ogma event listener
|
|
119
|
+
this._reactive.listenToSelectionEvents();
|
|
120
|
+
}
|
|
121
|
+
this.initSelection();
|
|
122
|
+
this.setConfigOgma(this._configuration, true);
|
|
123
|
+
this.LKTransformation = new transformations_1.TransformationsViz(this);
|
|
124
|
+
this.LKStyles.setNodesDefaultHalo();
|
|
125
|
+
this.LKStyles.setEdgesDefaultHalo();
|
|
126
|
+
this.LKStyles.setBadgeRule();
|
|
127
|
+
this.LKStyles.setFilterClass();
|
|
128
|
+
};
|
|
108
129
|
/**
|
|
109
130
|
* Initialize selection behavior
|
|
110
131
|
*/
|
|
@@ -141,7 +162,7 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
141
162
|
}
|
|
142
163
|
});
|
|
143
164
|
};
|
|
144
|
-
LKOgma.prototype.
|
|
165
|
+
LKOgma.prototype.setStyles = function (configuration) {
|
|
145
166
|
var _a, _b, _c, _d, _e, _f;
|
|
146
167
|
this.LKStyles = new styles_1.StylesViz(this, {
|
|
147
168
|
node: ((_c = (_b = (_a = configuration) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.node) || {},
|
|
@@ -150,7 +171,7 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
150
171
|
this.LKStyles.setNodesDefaultStyles();
|
|
151
172
|
this.LKStyles.setEdgesDefaultStyles();
|
|
152
173
|
};
|
|
153
|
-
LKOgma.prototype.
|
|
174
|
+
LKOgma.prototype.setCaptions = function (configuration) {
|
|
154
175
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
155
176
|
var nodeMaxTextLength = (_e = (_d = (_c = (_b = (_a = configuration) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.text) === null || _e === void 0 ? void 0 : _e.maxTextLength;
|
|
156
177
|
var edgeMaxTextLength = (_k = (_j = (_h = (_g = (_f = configuration) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.styles) === null || _h === void 0 ? void 0 : _h.edge) === null || _j === void 0 ? void 0 : _j.text) === null || _k === void 0 ? void 0 : _k.maxTextLength;
|
|
@@ -345,6 +366,26 @@ var LKOgma = /** @class */ (function (_super) {
|
|
|
345
366
|
this.store.clear();
|
|
346
367
|
}
|
|
347
368
|
};
|
|
369
|
+
/**
|
|
370
|
+
* Reset the Ogma instance so that it can be used fresh in the next visulization
|
|
371
|
+
*/
|
|
372
|
+
LKOgma.prototype.clearOgmaState = function () {
|
|
373
|
+
this.reset();
|
|
374
|
+
if (this.store) {
|
|
375
|
+
this.store.clear();
|
|
376
|
+
}
|
|
377
|
+
this.initOgmaLinkuriousParser();
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()
|
|
381
|
+
*/
|
|
382
|
+
LKOgma.prototype.setConfigOgma = function (configuration, init) {
|
|
383
|
+
if (!init) {
|
|
384
|
+
this.setOptions(__assign(__assign({}, configuration.options), { renderer: configuration.renderer }));
|
|
385
|
+
}
|
|
386
|
+
this.setStyles(configuration);
|
|
387
|
+
this.setCaptions(configuration);
|
|
388
|
+
};
|
|
348
389
|
return LKOgma;
|
|
349
390
|
}(ogma_1.default));
|
|
350
391
|
exports.LKOgma = LKOgma;
|
package/dist/ogma/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ogma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAUiC;AACjC,8CAUc;AAEd,wBAA8B;AAC9B,wCAAqC;AAErC,4CAA4C;AAC5C,8DAA8D;AAC9D,gDAAgD;AAChD,gDAA0C;AAG1C,6BAAqC;AAA7B,sBAAA,OAAO,CAAQ;AACV,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAOtC;IAA4B,0BA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LkEdgeData,\n LkNodeData,\n PopulatedVisualization,\n VizEdge,\n VizNode\n} from '@linkurious/rest-client';\nimport Ogma, {\n EdgeList,\n ForceLayoutOptions,\n HierarchicalLayoutOptions,\n NodeList,\n NonObjectPropertyWatcher,\n RadialLayoutOptions,\n RawEdge,\n RawGraph,\n RawNode\n} from 'ogma';\n\nimport {StyleRules} from '..';\nimport {Tools} from '../tools/tools';\n\nimport {StylesViz} from './features/styles';\nimport {TransformationsViz} from './features/transformations';\nimport {CaptionsViz} from './features/captions';\nimport {RxViz} from './features/reactive';\nimport {OgmaStore} from './features/OgmaStore';\n\nexport {default as Ogma} from 'ogma';\nexport const ANIMATION_DURATION = 750;\n\ninterface AddItemOptions {\n batchSize?: number;\n virtual?: boolean;\n}\n\nexport class LKOgma extends Ogma<LkNodeData, LkEdgeData> {\n private _reactive: RxViz;\n public LKStyles!: StylesViz;\n public LKCaptions!: CaptionsViz;\n public LKTransformation: TransformationsViz;\n // Trigger an event with node category changes\n public nodeCategoriesWatcher: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n // Trigger an event with edge type changes\n public edgeTypeWatcher: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n public store: OgmaStore;\n\n constructor(configuration: IOgmaConfig) {\n // set Ogma global configuration\n super(configuration);\n this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({\n path: 'categories',\n unwindArrays: true,\n filter: 'all'\n });\n this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({\n path: 'type',\n filter: 'all'\n });\n Object.setPrototypeOf(this, new.target.prototype);\n // set ogma max zoom value and selection with mouse option (false?)\n this.setOptions({\n interactions: {\n zoom: {\n maxValue: (params: any) => {\n return 128 / params.smallestNodeSize;\n }\n },\n selection: {\n enabled: false\n }\n }\n });\n\n this._reactive = new RxViz(this);\n this.store = this._reactive.store;\n this.initSelection();\n this.initStyles(configuration);\n this.initCaptions(configuration);\n this.LKTransformation = new TransformationsViz(this);\n\n this.LKStyles.setNodesDefaultHalo();\n this.LKStyles.setEdgesDefaultHalo();\n this.LKStyles.setBadgeRule();\n this.LKStyles.setFilterClass();\n }\n\n /**\n * Initialize selection behavior\n */\n public initSelection(): void {\n this.events.onClick((e) => {\n if (e !== undefined && e.button === 'left') {\n if (e.target !== null) {\n const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';\n if (this.keyboard.isKeyPressed(multiSelectionKey)) {\n if (e.target.isNode && this.getSelectedEdges().size > 0) {\n this.getSelectedEdges().setSelected(false);\n }\n if (!e.target.isNode && this.getSelectedNodes().size > 0) {\n this.getSelectedNodes().setSelected(false);\n }\n if (e.target.isSelected()) {\n e.target.setSelected(false);\n } else {\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n }\n }\n });\n }\n\n private initStyles(configuration: IOgmaConfig): void {\n this.LKStyles = new StylesViz(this, {\n node: configuration?.options?.styles?.node || {},\n edge: configuration?.options?.styles?.edge || {}\n });\n this.LKStyles.setNodesDefaultStyles();\n this.LKStyles.setEdgesDefaultStyles();\n }\n\n private initCaptions(configuration: IOgmaConfig): void {\n const nodeMaxTextLength = configuration?.options?.styles?.node?.text?.maxTextLength;\n const edgeMaxTextLength = configuration?.options?.styles?.edge?.text?.maxTextLength;\n this.LKCaptions = new CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);\n }\n\n /**\n * Returns Ogma Layout parameters according to visualization layout settings\n * */\n public getForceLayoutParams(mode: ForceLayoutMode, duration = 0): ForceLayoutOptions {\n let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;\n if (dynamicSteps < 40) {\n dynamicSteps = 40;\n }\n return {\n steps: mode === ForceLayoutMode.FAST ? dynamicSteps : 300,\n alignSiblings: this.getNodes().size > 3,\n duration: duration,\n charge: 20,\n gravity: 0.08,\n theta: this.getNodes().size > 100 ? 0.8 : 0.34\n };\n }\n public getRadialLayoutParams(rootNode: string, duration = 0): RadialLayoutOptions {\n return {\n centralNode: rootNode,\n radiusDelta: 1,\n nodeGap: 10,\n repulsion: this.getNodes().size > 80 ? 1 : 6,\n duration: duration\n };\n }\n\n public getHierarchicalLayoutParams(\n mode: HierarchicalLayoutMode,\n rootNode: string,\n duration = 0\n ): HierarchicalLayoutOptions {\n return {\n direction: mode,\n roots: [rootNode],\n duration: duration\n };\n }\n\n /**\n * Initialize graph.\n * add nodes and edges to the viz and init the selection.\n */\n public async init(visualization: {nodes: Array<VizNode>; edges: Array<VizEdge>}): Promise<void> {\n this.clearGraph();\n let selectedEntityType: EntityType | undefined = undefined;\n let selectedElements: Array<string> = [];\n // need to remove selected in every items before adding them to Ogma\n const fixedNodes = visualization.nodes.map((node) => {\n if (node.attributes.selected) {\n selectedEntityType = EntityType.NODE;\n selectedElements.push(node.id);\n }\n delete node.attributes.selected;\n return node;\n });\n const fixedEdges = visualization.edges.map((edge) => {\n if (edge.attributes !== undefined) {\n if (edge.attributes.selected) {\n if (selectedEntityType === undefined || selectedEntityType === EntityType.NODE) {\n selectedEntityType = EntityType.EDGE;\n selectedElements = [];\n }\n selectedElements.push(edge.id);\n }\n delete edge.attributes.selected;\n }\n return edge;\n });\n await this.addGraphAfterValidation({\n nodes: fixedNodes as Array<RawNode<LkNodeData>>,\n edges: fixedEdges as Array<RawEdge<LkEdgeData>>\n });\n if (selectedEntityType === EntityType.NODE) {\n this.getNodes(selectedElements).setSelected(true);\n } else if (selectedEntityType === EntityType.EDGE) {\n this.getEdges(selectedElements).setSelected(true);\n }\n }\n\n public async initVisualization(visualization: PopulatedVisualization) {\n this.init(visualization);\n const styles = StyleRules.sanitizeStylesIndex(visualization.design.styles);\n this.LKStyles.initNodeColors(styles.node);\n this.LKStyles.initNodesIcons(styles.node);\n this.LKStyles.initNodesSizes(styles.node);\n this.LKStyles.initNodesShapes(styles.node);\n this.LKStyles.initEdgesWidth(styles.edge);\n this.LKStyles.initEdgesShape(styles.edge);\n this.LKStyles.initEdgesColor(styles.edge);\n this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n this.LKTransformation.initTransformation();\n this.LKTransformation.initEdgeGroupingStyle();\n }\n\n /**\n * Adding nodes then adding edges to the graph\n */\n public async addGraphAfterValidation(\n graph: RawGraph<LkNodeData, LkEdgeData>\n ): Promise<{\n nodes: NodeList<LkNodeData>;\n edges: EdgeList<LkEdgeData>;\n }> {\n const addedNodes = await this.addNodes(graph.nodes);\n const addedEdges = await this.addEdges(graph.edges);\n return {\n nodes: addedNodes,\n edges: addedEdges\n };\n }\n\n /**\n * Adding edges to the graph after filtering disconnected ones\n */\n public async addEdges(\n edges: Array<RawEdge<LkEdgeData>>,\n options?: AddItemOptions\n ): Promise<EdgeList> {\n const filteredEdges = edges.filter((edge) => {\n return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;\n });\n return super.addEdges(filteredEdges, options);\n }\n\n /**\n * Return the list of non filtered nodes\n */\n public getNonFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))\n : this.getNodes().filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered nodes\n */\n public getFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => i.hasClass('filtered'))\n : this.getNodes().filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Return the list of non filtered edges\n */\n public getNonFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered edges\n */\n public getFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Do a full reset on ogma and streams of ogma\n */\n public shutDown() {\n this.destroy();\n if (this.store) {\n this.store.clear();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ogma/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAUiC;AACjC,0DAU0B;AAE1B,wBAA8B;AAC9B,wCAAqC;AAErC,4CAA4C;AAC5C,8DAA8D;AAC9D,gDAAgD;AAChD,gDAA0C;AAG1C,yCAAiD;AAAzC,sBAAA,OAAO,CAAQ;AACV,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAOtC;IAA4B,0BAA4B;IAWtD,gBAAoB,cAA2B;;QAA/C;QACE,gCAAgC;QAChC,kBAAM,cAAc,CAAC,SAGtB;QALmB,oBAAc,GAAd,cAAc,CAAa;QAG7C,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,SAAS,CAAC,CAAC;QAClD,KAAI,CAAC,wBAAwB,EAAE,CAAC;;IAClC,CAAC;IAEO,yCAAwB,GAAhC;QACE,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC;YAClE,IAAI,EAAE,YAAY;YAClB,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC;YAC5D,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,oEAAoE;QACpE,IAAI,CAAC,UAAU,CAAC;YACd,YAAY,EAAE;gBACZ,IAAI,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D,CAA4B,cAAI,GAuT/B;AAvTY,wBAAM","sourcesContent":["import {\n EntityType,\n ForceLayoutMode,\n HierarchicalLayoutMode,\n IOgmaConfig,\n LkEdgeData,\n LkNodeData,\n PopulatedVisualization,\n VizEdge,\n VizNode\n} from '@linkurious/rest-client';\nimport Ogma, {\n EdgeList,\n ForceLayoutOptions,\n HierarchicalLayoutOptions,\n NodeList,\n NonObjectPropertyWatcher,\n RadialLayoutOptions,\n RawEdge,\n RawGraph,\n RawNode\n} from '@linkurious/ogma';\n\nimport {StyleRules} from '..';\nimport {Tools} from '../tools/tools';\n\nimport {StylesViz} from './features/styles';\nimport {TransformationsViz} from './features/transformations';\nimport {CaptionsViz} from './features/captions';\nimport {RxViz} from './features/reactive';\nimport {OgmaStore} from './features/OgmaStore';\n\nexport {default as Ogma} from '@linkurious/ogma';\nexport const ANIMATION_DURATION = 750;\n\ninterface AddItemOptions {\n batchSize?: number;\n virtual?: boolean;\n}\n\nexport class LKOgma extends Ogma<LkNodeData, LkEdgeData> {\n public LKStyles!: StylesViz;\n public LKCaptions!: CaptionsViz;\n public LKTransformation!: TransformationsViz;\n // Trigger an event with node category changes\n public nodeCategoriesWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n // Trigger an event with edge type changes\n public edgeTypeWatcher!: NonObjectPropertyWatcher<LkNodeData, LkEdgeData>;\n public store!: OgmaStore;\n private _reactive!: RxViz;\n\n constructor(private _configuration: IOgmaConfig) {\n // set Ogma global configuration\n super(_configuration);\n Object.setPrototypeOf(this, new.target.prototype);\n this.initOgmaLinkuriousParser();\n }\n\n private initOgmaLinkuriousParser(): void {\n this.nodeCategoriesWatcher = this.schema.watchNodeNonObjectProperty({\n path: 'categories',\n unwindArrays: true,\n filter: 'all'\n });\n this.edgeTypeWatcher = this.schema.watchEdgeNonObjectProperty({\n path: 'type',\n filter: 'all'\n });\n // set ogma max zoom value and selection with mouse option (false?)\n this.setOptions({\n interactions: {\n zoom: {\n maxValue: (params: any) => {\n return 128 / params.smallestNodeSize;\n }\n },\n selection: {\n enabled: false\n }\n }\n });\n\n // only instantiate the store once when app is starting\n if (this._reactive === undefined) {\n this._reactive = new RxViz(this);\n this.store = this._reactive.store;\n } else {\n // if store already exist, but ogma was reset, create new ogma event listener\n this._reactive.listenToSelectionEvents();\n }\n this.initSelection();\n this.setConfigOgma(this._configuration, true);\n this.LKTransformation = new TransformationsViz(this);\n\n this.LKStyles.setNodesDefaultHalo();\n this.LKStyles.setEdgesDefaultHalo();\n this.LKStyles.setBadgeRule();\n this.LKStyles.setFilterClass();\n }\n\n /**\n * Initialize selection behavior\n */\n public initSelection(): void {\n this.events.onClick((e) => {\n if (e !== undefined && e.button === 'left') {\n if (e.target !== null) {\n const multiSelectionKey = navigator.platform === 'MacIntel' ? 'cmd' : 'ctrl';\n if (this.keyboard.isKeyPressed(multiSelectionKey)) {\n if (e.target.isNode && this.getSelectedEdges().size > 0) {\n this.getSelectedEdges().setSelected(false);\n }\n if (!e.target.isNode && this.getSelectedNodes().size > 0) {\n this.getSelectedNodes().setSelected(false);\n }\n if (e.target.isSelected()) {\n e.target.setSelected(false);\n } else {\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n e.target.setSelected(true);\n }\n } else {\n this.getSelectedNodes().setSelected(false);\n this.getSelectedEdges().setSelected(false);\n }\n }\n });\n }\n\n private setStyles(configuration: IOgmaConfig): void {\n this.LKStyles = new StylesViz(this, {\n node: configuration?.options?.styles?.node || {},\n edge: configuration?.options?.styles?.edge || {}\n });\n this.LKStyles.setNodesDefaultStyles();\n this.LKStyles.setEdgesDefaultStyles();\n }\n\n private setCaptions(configuration: IOgmaConfig): void {\n const nodeMaxTextLength = configuration?.options?.styles?.node?.text?.maxTextLength;\n const edgeMaxTextLength = configuration?.options?.styles?.edge?.text?.maxTextLength;\n this.LKCaptions = new CaptionsViz(this, nodeMaxTextLength, edgeMaxTextLength);\n }\n\n /**\n * Returns Ogma Layout parameters according to visualization layout settings\n * */\n public getForceLayoutParams(mode: ForceLayoutMode, duration = 0): ForceLayoutOptions {\n let dynamicSteps = 300 - ((300 - 40) / 5000) * this.getNodes().size;\n if (dynamicSteps < 40) {\n dynamicSteps = 40;\n }\n return {\n steps: mode === ForceLayoutMode.FAST ? dynamicSteps : 300,\n alignSiblings: this.getNodes().size > 3,\n duration: duration,\n charge: 20,\n gravity: 0.08,\n theta: this.getNodes().size > 100 ? 0.8 : 0.34\n };\n }\n\n public getRadialLayoutParams(\n rootNode: string,\n duration = 0\n ): RadialLayoutOptions<unknown, unknown> {\n return {\n centralNode: rootNode,\n radiusDelta: 1,\n nodeGap: 10,\n repulsion: this.getNodes().size > 80 ? 1 : 6,\n duration: duration\n };\n }\n\n public getHierarchicalLayoutParams(\n mode: HierarchicalLayoutMode,\n rootNode: string,\n duration = 0\n ): HierarchicalLayoutOptions {\n return {\n direction: mode,\n roots: [rootNode],\n duration: duration\n };\n }\n\n /**\n * Initialize graph.\n * add nodes and edges to the viz and init the selection.\n */\n public async init(visualization: {nodes: Array<VizNode>; edges: Array<VizEdge>}): Promise<void> {\n this.clearGraph();\n let selectedEntityType: EntityType | undefined = undefined;\n let selectedElements: Array<string> = [];\n // need to remove selected in every items before adding them to Ogma\n const fixedNodes = visualization.nodes.map((node) => {\n if (node.attributes.selected) {\n selectedEntityType = EntityType.NODE;\n selectedElements.push(node.id);\n }\n delete node.attributes.selected;\n return node;\n });\n const fixedEdges = visualization.edges.map((edge) => {\n if (edge.attributes !== undefined) {\n if (edge.attributes.selected) {\n if (selectedEntityType === undefined || selectedEntityType === EntityType.NODE) {\n selectedEntityType = EntityType.EDGE;\n selectedElements = [];\n }\n selectedElements.push(edge.id);\n }\n delete edge.attributes.selected;\n }\n return edge;\n });\n await this.addGraphAfterValidation({\n nodes: fixedNodes as Array<RawNode<LkNodeData>>,\n edges: fixedEdges as Array<RawEdge<LkEdgeData>>\n });\n if (selectedEntityType === EntityType.NODE) {\n this.getNodes(selectedElements).setSelected(true);\n } else if (selectedEntityType === EntityType.EDGE) {\n this.getEdges(selectedElements).setSelected(true);\n }\n }\n\n public async initVisualization(visualization: PopulatedVisualization) {\n this.init(visualization);\n const styles = StyleRules.sanitizeStylesIndex(visualization.design.styles);\n this.LKStyles.initNodeColors(styles.node);\n this.LKStyles.initNodesIcons(styles.node);\n this.LKStyles.initNodesSizes(styles.node);\n this.LKStyles.initNodesShapes(styles.node);\n this.LKStyles.initEdgesWidth(styles.edge);\n this.LKStyles.initEdgesShape(styles.edge);\n this.LKStyles.initEdgesColor(styles.edge);\n this.LKCaptions.initVizCaptions({\n node: visualization.nodeFields.captions || {},\n edge: visualization.edgeFields.captions || {}\n });\n this.LKTransformation.groupedEdges = visualization.edgeGrouping;\n this.LKTransformation.initTransformation();\n this.LKTransformation.initEdgeGroupingStyle();\n }\n\n /**\n * Adding nodes then adding edges to the graph\n */\n public async addGraphAfterValidation(\n graph: RawGraph<LkNodeData, LkEdgeData>\n ): Promise<{\n nodes: NodeList<LkNodeData>;\n edges: EdgeList<LkEdgeData>;\n }> {\n const addedNodes = await this.addNodes(graph.nodes);\n const addedEdges = await this.addEdges(graph.edges);\n return {\n nodes: addedNodes,\n edges: addedEdges\n };\n }\n\n /**\n * Adding edges to the graph after filtering disconnected ones\n */\n public async addEdges(\n edges: Array<RawEdge<LkEdgeData>>,\n options?: AddItemOptions\n ): Promise<EdgeList> {\n const filteredEdges = edges.filter((edge) => {\n return this.getNode(edge.source) !== undefined && this.getNode(edge.target) !== undefined;\n });\n return super.addEdges(filteredEdges, options);\n }\n\n /**\n * Return the list of non filtered nodes\n */\n public getNonFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => !i.hasClass('filtered'))\n : this.getNodes().filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered nodes\n */\n public getFilteredNodes(items?: Array<any>): NodeList<LkNodeData, LkEdgeData> {\n return Tools.isDefined(items)\n ? this.getNodes(items).filter((i) => i.hasClass('filtered'))\n : this.getNodes().filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Return the list of non filtered edges\n */\n public getNonFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => !i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => !i.hasClass('filtered'));\n }\n\n /**\n * Return the list of filtered edges\n */\n public getFilteredEdges(items?: Array<any>): EdgeList<LkEdgeData, LkNodeData> {\n return Tools.isDefined(items)\n ? this.getEdges(items).filter((i) => i.hasClass('filtered'))\n : this.getEdges('raw').filter((i) => i.hasClass('filtered'));\n }\n\n /**\n * Do a full reset on ogma and streams of ogma\n */\n public shutDown(): void {\n this.destroy();\n if (this.store) {\n this.store.clear();\n }\n }\n\n /**\n * Reset the Ogma instance so that it can be used fresh in the next visulization\n */\n public clearOgmaState(): void {\n this.reset();\n if (this.store) {\n this.store.clear();\n }\n this.initOgmaLinkuriousParser();\n }\n\n /**\n * Updates the Ogma config when config changes in LKE. If init, options were already set by the Ogma.reset()\n */\n public setConfigOgma(configuration: IOgmaConfig, init?: boolean): void {\n if (!init) {\n this.setOptions({\n ...configuration.options,\n renderer: configuration.renderer\n });\n }\n this.setStyles(configuration);\n this.setCaptions(configuration);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color } from 'ogma';
|
|
1
|
+
import { Color } from '@linkurious/ogma';
|
|
2
2
|
import { LkEdgeData, OgmaEdgeShape } from '@linkurious/rest-client';
|
|
3
3
|
import { StyleRule } from './styleRule';
|
|
4
4
|
import { ItemAttributes } from './itemAttributes';
|
|
@@ -15,7 +15,7 @@ export declare class EdgeAttributes extends ItemAttributes {
|
|
|
15
15
|
/**
|
|
16
16
|
* Return rule that can be applied to the data
|
|
17
17
|
*/
|
|
18
|
-
private matchStyle;
|
|
18
|
+
private static matchStyle;
|
|
19
19
|
/**
|
|
20
20
|
* Generate color for a given edge (call only if _rulesMap.color exists)
|
|
21
21
|
*/
|
|
@@ -32,8 +32,9 @@ export declare class EdgeAttributes extends ItemAttributes {
|
|
|
32
32
|
* return the corresponding width to the value
|
|
33
33
|
* @param value
|
|
34
34
|
* @param rule
|
|
35
|
+
* @param isLog
|
|
35
36
|
*/
|
|
36
|
-
static getAutomaticRangeWidth(value: number, rule: StyleRule): string;
|
|
37
|
+
static getAutomaticRangeWidth(value: number, rule: StyleRule, isLog?: boolean): string;
|
|
37
38
|
/**
|
|
38
39
|
* Return an object containing all node attributes needed by Ogma to style a node
|
|
39
40
|
*/
|
|
@@ -29,7 +29,7 @@ var EdgeAttributes = /** @class */ (function (_super) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Return rule that can be applied to the data
|
|
31
31
|
*/
|
|
32
|
-
EdgeAttributes.
|
|
32
|
+
EdgeAttributes.matchStyle = function (styleRules, data) {
|
|
33
33
|
if (data === undefined) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
@@ -68,7 +68,7 @@ var EdgeAttributes = /** @class */ (function (_super) {
|
|
|
68
68
|
EdgeAttributes.prototype.shape = function (data) {
|
|
69
69
|
var _a;
|
|
70
70
|
if (this._rulesMap.shape !== undefined) {
|
|
71
|
-
return (_a =
|
|
71
|
+
return (_a = EdgeAttributes.matchStyle(this._rulesMap.shape, data)) === null || _a === void 0 ? void 0 : _a.style.shape;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
@@ -77,7 +77,7 @@ var EdgeAttributes = /** @class */ (function (_super) {
|
|
|
77
77
|
EdgeAttributes.prototype.width = function (data) {
|
|
78
78
|
var _a;
|
|
79
79
|
if (this._rulesMap.width !== undefined) {
|
|
80
|
-
var styleRule =
|
|
80
|
+
var styleRule = EdgeAttributes.matchStyle(this._rulesMap.width, data);
|
|
81
81
|
var widthStyle = (_a = styleRule) === null || _a === void 0 ? void 0 : _a.style.width;
|
|
82
82
|
if (tools_1.Tools.isDefined(styleRule) && widthStyle.type === 'autoRange') {
|
|
83
83
|
if (widthStyle.input !== undefined &&
|
|
@@ -85,7 +85,9 @@ var EdgeAttributes = /** @class */ (function (_super) {
|
|
|
85
85
|
widthStyle.min !== undefined) {
|
|
86
86
|
var propertyName = widthStyle.input[1];
|
|
87
87
|
var propertyValue = tools_1.Tools.parseNumber(data.properties[propertyName]);
|
|
88
|
-
|
|
88
|
+
//to update with the correct enum type
|
|
89
|
+
var isLog = widthStyle.scale && widthStyle.scale === 'logarithmic';
|
|
90
|
+
return EdgeAttributes.getAutomaticRangeWidth(propertyValue, styleRule, isLog);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
else {
|
|
@@ -97,9 +99,13 @@ var EdgeAttributes = /** @class */ (function (_super) {
|
|
|
97
99
|
* return the corresponding width to the value
|
|
98
100
|
* @param value
|
|
99
101
|
* @param rule
|
|
102
|
+
* @param isLog
|
|
100
103
|
*/
|
|
101
|
-
EdgeAttributes.getAutomaticRangeWidth = function (value, rule) {
|
|
102
|
-
|
|
104
|
+
EdgeAttributes.getAutomaticRangeWidth = function (value, rule, isLog) {
|
|
105
|
+
if (isLog === void 0) { isLog = false; }
|
|
106
|
+
return isLog
|
|
107
|
+
? this.getAutomaticRangeStyleLog(value, rule.style.width, EdgeWidthExtrema.MIN, EdgeWidthExtrema.MAX)
|
|
108
|
+
: this.getAutomaticRangeStyleLinear(value, rule.style.width, EdgeWidthExtrema.MIN, EdgeWidthExtrema.MAX);
|
|
103
109
|
};
|
|
104
110
|
/**
|
|
105
111
|
* Return an object containing all node attributes needed by Ogma to style a node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edgeAttributes.js","sourceRoot":"","sources":["../../src/styles/edgeAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;AAEb,uDAAkE;AAElE,wCAAqC;AAGrC,mDAA2D;AAE3D,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,sDAAQ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K,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;SACxB,CAAC;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA7HD,CAAoC,+BAAc,GA6HjD;AA7HY,wCAAc","sourcesContent":["'use strict';\nimport {Color} from '@linkurious/ogma';\nimport {LkEdgeData, OgmaEdgeShape} from '@linkurious/rest-client';\n\nimport {Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {BASE_GREY, ItemAttributes} from './itemAttributes';\n\nexport enum EdgeWidthExtrema {\n MIN = 50,\n MAX = 200\n}\n\nexport class EdgeAttributes extends ItemAttributes {\n constructor(rulesMap: {\n color?: Array<StyleRule>;\n shape?: Array<StyleRule>;\n width?: Array<StyleRule>;\n }) {\n super(rulesMap);\n }\n\n /**\n * Return rule that can be applied to the data\n */\n private static matchStyle(styleRules: Array<StyleRule>, data: LkEdgeData): StyleRule | undefined {\n if (data === undefined) {\n return;\n }\n for (let i = 0; i < styleRules.length; ++i) {\n if (styleRules[i].canApplyTo(data)) {\n return styleRules[i];\n }\n }\n }\n\n /**\n * Generate color for a given edge (call only if _rulesMap.color exists)\n */\n public color(data: LkEdgeData): Color {\n if (!Tools.isDefined(data)) {\n return BASE_GREY;\n }\n let color;\n for (let j = 0; j < this._rulesMap.color!.length; ++j) {\n const rule = this._rulesMap.color![j];\n if (rule.canApplyTo(data)) {\n if (typeof rule.style.color === 'string') {\n color = rule.style.color;\n } else if (typeof rule.style.color === 'object') {\n const propValue = Tools.getIn(data, rule.style.color.input);\n color = ItemAttributes.autoColor(`${propValue}`, rule.style.ignoreCase);\n }\n break;\n }\n }\n return Tools.isDefined(color) ? color : BASE_GREY;\n }\n\n /**\n * Generate shape for a given node\n */\n public shape(data: LkEdgeData): OgmaEdgeShape | undefined {\n if (this._rulesMap.shape !== undefined) {\n return EdgeAttributes.matchStyle(this._rulesMap.shape, data)?.style.shape;\n }\n }\n\n /**\n * Generate size for a given node\n */\n public width(data: LkEdgeData): string | undefined {\n if (this._rulesMap.width !== undefined) {\n const styleRule = EdgeAttributes.matchStyle(this._rulesMap.width, data);\n const widthStyle = styleRule?.style.width;\n if (Tools.isDefined(styleRule) && widthStyle.type === 'autoRange') {\n if (\n widthStyle.input !== undefined &&\n widthStyle.max !== undefined &&\n widthStyle.min !== undefined\n ) {\n const propertyName: string = widthStyle.input[1];\n const propertyValue = Tools.parseNumber(data.properties[propertyName]);\n //to update with the correct enum type\n const isLog = widthStyle.scale && widthStyle.scale === 'logarithmic';\n return EdgeAttributes.getAutomaticRangeWidth(propertyValue, styleRule, isLog);\n }\n } else {\n return widthStyle;\n }\n }\n }\n\n /**\n * return the corresponding width to the value\n * @param value\n * @param rule\n * @param isLog\n */\n public static getAutomaticRangeWidth(value: number, rule: StyleRule, isLog = false): string {\n return isLog\n ? this.getAutomaticRangeStyleLog(\n value,\n rule.style.width,\n EdgeWidthExtrema.MIN,\n EdgeWidthExtrema.MAX\n )\n : this.getAutomaticRangeStyleLinear(\n value,\n rule.style.width,\n EdgeWidthExtrema.MIN,\n EdgeWidthExtrema.MAX\n );\n }\n\n /**\n * Return an object containing all node attributes needed by Ogma to style a node\n */\n public all(\n data: LkEdgeData\n ): {\n color: Color;\n shape: OgmaEdgeShape | undefined;\n width: string | undefined;\n } {\n if (!Tools.isDefined(data)) {\n return {\n color: BASE_GREY,\n shape: OgmaEdgeShape.ARROW,\n width: '100%'\n };\n }\n return {\n color: this.color(data),\n shape: this.shape(data),\n width: this.width(data)\n };\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color } from 'ogma';
|
|
1
|
+
import { Color } from '@linkurious/ogma';
|
|
2
2
|
import { StyleRule } from './styleRule';
|
|
3
3
|
import { NodeSizeExtrema } from './nodeAttributes';
|
|
4
4
|
import { EdgeWidthExtrema } from './edgeAttributes';
|
|
@@ -46,13 +46,24 @@ export declare class ItemAttributes {
|
|
|
46
46
|
*/
|
|
47
47
|
static getTypeColor(rule: StyleRule, type: string): string | null;
|
|
48
48
|
/**
|
|
49
|
-
* return the corresponding size to the value
|
|
49
|
+
* return the corresponding size to the value with a linear function
|
|
50
50
|
* @param value
|
|
51
51
|
* @param lower
|
|
52
52
|
* @param higher
|
|
53
53
|
* @param extrema
|
|
54
54
|
*/
|
|
55
|
-
static
|
|
55
|
+
static getAutomaticRangeStyleLinear(value: number, { max, min }: {
|
|
56
|
+
max: number;
|
|
57
|
+
min: number;
|
|
58
|
+
}, lower: EdgeWidthExtrema | NodeSizeExtrema, higher: EdgeWidthExtrema | NodeSizeExtrema): string;
|
|
59
|
+
/**
|
|
60
|
+
* return the corresponding size to the value with a logarithmic function
|
|
61
|
+
* @param value
|
|
62
|
+
* @param lower
|
|
63
|
+
* @param higher
|
|
64
|
+
* @param extrema
|
|
65
|
+
*/
|
|
66
|
+
static getAutomaticRangeStyleLog(value: number, { max, min }: {
|
|
56
67
|
max: number;
|
|
57
68
|
min: number;
|
|
58
69
|
}, lower: EdgeWidthExtrema | NodeSizeExtrema, higher: EdgeWidthExtrema | NodeSizeExtrema): string;
|
|
@@ -86,16 +86,16 @@ var ItemAttributes = /** @class */ (function () {
|
|
|
86
86
|
return null;
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
-
* return the corresponding size to the value
|
|
89
|
+
* return the corresponding size to the value with a linear function
|
|
90
90
|
* @param value
|
|
91
91
|
* @param lower
|
|
92
92
|
* @param higher
|
|
93
93
|
* @param extrema
|
|
94
94
|
*/
|
|
95
|
-
ItemAttributes.
|
|
95
|
+
ItemAttributes.getAutomaticRangeStyleLinear = function (value, _a, lower, higher) {
|
|
96
96
|
var max = _a.max, min = _a.min;
|
|
97
97
|
// apply default style when min equal max
|
|
98
|
-
if (max === min) {
|
|
98
|
+
if (max === min || isNaN(value)) {
|
|
99
99
|
return '100%';
|
|
100
100
|
}
|
|
101
101
|
// calculate the linear function f(x) = ax + b
|
|
@@ -104,6 +104,31 @@ var ItemAttributes = /** @class */ (function () {
|
|
|
104
104
|
var size = Math.floor(value * a + b);
|
|
105
105
|
return size + "%";
|
|
106
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* return the corresponding size to the value with a logarithmic function
|
|
109
|
+
* @param value
|
|
110
|
+
* @param lower
|
|
111
|
+
* @param higher
|
|
112
|
+
* @param extrema
|
|
113
|
+
*/
|
|
114
|
+
ItemAttributes.getAutomaticRangeStyleLog = function (value, _a, lower, higher) {
|
|
115
|
+
var max = _a.max, min = _a.min;
|
|
116
|
+
// apply default style when min equal max
|
|
117
|
+
if (max === min || isNaN(value)) {
|
|
118
|
+
return '100%';
|
|
119
|
+
}
|
|
120
|
+
// apply an offset for all the values (including min and max)
|
|
121
|
+
if (min < 1) {
|
|
122
|
+
value += Math.abs(min) + 1;
|
|
123
|
+
max += Math.abs(min) + 1;
|
|
124
|
+
min += Math.abs(min) + 1;
|
|
125
|
+
}
|
|
126
|
+
// calculate the logarithmic function f(x) = Math.floor(a*log(x) + b)
|
|
127
|
+
var a = (higher - lower) / (Math.log(max) - Math.log(min));
|
|
128
|
+
var b = (lower * Math.log(max) - higher * Math.log(min)) / (Math.log(max) - Math.log(min));
|
|
129
|
+
var size = Math.floor(a * Math.log(value) + b);
|
|
130
|
+
return size + "%";
|
|
131
|
+
};
|
|
107
132
|
return ItemAttributes;
|
|
108
133
|
}());
|
|
109
134
|
exports.ItemAttributes = ItemAttributes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemAttributes.js","sourceRoot":"","sources":["../../src/styles/itemAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAEb,8CAAwB;AAGxB,wCAAqC;AAMxB,QAAA,SAAS,GAAG,SAAS,CAAC;AACtB,QAAA,OAAO,GAAG;IACrB,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IAC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AC,CAAC;YAC3B,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACzB,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC1B;QACD,sEAAsE;QACtE,IAAM,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7D,IAAM,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7F,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAEjD,OAAU,IAAI,MAAG,CAAC;IACpB,CAAC;IACH,qBAAC;AAAD,CAAC,AA7ID,IA6IC;AA7IY,wCAAc","sourcesContent":["'use strict';\n\nimport sha1 from 'sha1';\nimport {Color} from '@linkurious/ogma';\n\nimport {Tools} from '../tools/tools';\n\nimport {StyleRule} from './styleRule';\nimport {NodeSizeExtrema} from './nodeAttributes';\nimport {EdgeWidthExtrema} from './edgeAttributes';\n\nexport const BASE_GREY = '#7f7f7f';\nexport const PALETTE = [\n '#9467bd',\n '#e377c2',\n '#1f77b4',\n '#17becf',\n '#2ca02c',\n '#bcbd22',\n '#d62728',\n '#ff7f0e',\n '#8c564b',\n '#c5b0d5',\n '#f7b6d2',\n '#aec7e8',\n '#9edae5',\n '#98df8a',\n '#dbdb8d',\n '#ff9896',\n '#ffbb78',\n '#c49c94'\n];\n\nexport class ItemAttributes {\n protected colorsCache: Map<string, Color | Array<Color>> = new Map();\n protected _rulesMap: {\n color?: Array<StyleRule>;\n icon?: Array<StyleRule>;\n image?: Array<StyleRule>;\n shape?: Array<StyleRule>;\n size?: Array<StyleRule>;\n width?: Array<StyleRule>;\n } = {};\n\n constructor(rulesMap: {\n color?: Array<StyleRule>;\n icon?: Array<StyleRule>;\n image?: Array<StyleRule>;\n shape?: Array<StyleRule>;\n size?: Array<StyleRule>;\n width?: Array<StyleRule>;\n }) {\n this.refresh(rulesMap);\n }\n\n /**\n * Refresh the rules\n */\n public refresh(rulesMap: {\n color?: Array<StyleRule>;\n icon?: Array<StyleRule>;\n image?: Array<StyleRule>;\n shape?: Array<StyleRule>;\n size?: Array<StyleRule>;\n width?: Array<StyleRule>;\n }): void {\n if (rulesMap.color !== undefined) {\n this.colorsCache = new Map();\n }\n this._rulesMap = {\n color: rulesMap.color ? [...rulesMap.color].reverse() : this._rulesMap.color,\n icon: rulesMap.icon ? [...rulesMap.icon].reverse() : this._rulesMap.icon,\n image: rulesMap.image ? [...rulesMap.image].reverse() : this._rulesMap.image,\n shape: rulesMap.shape ? [...rulesMap.shape].reverse() : this._rulesMap.shape,\n size: rulesMap.size ? [...rulesMap.size].reverse() : this._rulesMap.size,\n width: rulesMap.width ? [...rulesMap.width].reverse() : this._rulesMap.width\n };\n }\n\n /**\n * Return the color for a node when style color is auto\n */\n public static autoColor(value: string, ignoreCase?: boolean): string {\n if (!Tools.isDefined(value)) {\n return BASE_GREY;\n }\n return PALETTE[\n ItemAttributes.getRandomUniqueColorPaletteIndex(value, PALETTE.length, ignoreCase)\n ];\n }\n\n /**\n * Return a number from 0 to number of occurrence in a palette based on a property\n */\n private static getRandomUniqueColorPaletteIndex(\n input: string,\n modulo: number,\n ignoreCase: boolean | undefined\n ): number {\n if (ignoreCase) {\n input = input.toLowerCase();\n }\n return +('0x' + sha1(input).substr(-4)) % modulo;\n }\n\n /**\n * Get color of a type\n */\n public static getTypeColor(rule: StyleRule, type: string): string | null {\n if (typeof rule.style.color === 'object' && rule.style.color.input[0] !== 'properties') {\n return ItemAttributes.autoColor(type, rule.style.color.ignoreCase);\n }\n if (!Tools.isDefined(rule.input) && typeof rule.style.color !== 'object') {\n return rule.style.color;\n }\n return null;\n }\n\n /**\n * return the corresponding size to the value with a linear function\n * @param value\n * @param lower\n * @param higher\n * @param extrema\n */\n public static getAutomaticRangeStyleLinear(\n value: number,\n {max, min}: {max: number; min: number},\n lower: EdgeWidthExtrema | NodeSizeExtrema,\n higher: EdgeWidthExtrema | NodeSizeExtrema\n ): string {\n // apply default style when min equal max\n if (max === min || isNaN(value)) {\n return '100%';\n }\n\n // calculate the linear function f(x) = ax + b\n const a = (higher - lower) / (max - min);\n const b = (lower * max - higher * min) / (max - min);\n const size = Math.floor(value * a + b);\n\n return `${size}%`;\n }\n\n /**\n * return the corresponding size to the value with a logarithmic function\n * @param value\n * @param lower\n * @param higher\n * @param extrema\n */\n public static getAutomaticRangeStyleLog(\n value: number,\n {max, min}: {max: number; min: number},\n lower: EdgeWidthExtrema | NodeSizeExtrema,\n higher: EdgeWidthExtrema | NodeSizeExtrema\n ): string {\n // apply default style when min equal max\n if (max === min || isNaN(value)) {\n return '100%';\n }\n // apply an offset for all the values (including min and max)\n if (min < 1) {\n value += Math.abs(min) + 1;\n max += Math.abs(min) + 1;\n min += Math.abs(min) + 1;\n }\n // calculate the logarithmic function f(x) = Math.floor(a*log(x) + b)\n const a = (higher - lower) / (Math.log(max) - Math.log(min));\n const b = (lower * Math.log(max) - higher * Math.log(min)) / (Math.log(max) - Math.log(min));\n const size = Math.floor(a * Math.log(value) + b);\n\n return `${size}%`;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color } from 'ogma';
|
|
1
|
+
import { Color } from '@linkurious/ogma';
|
|
2
2
|
import { LkNodeData, OgmaNodeShape, IStyleImage, IStyleIcon } from '@linkurious/rest-client';
|
|
3
3
|
import { StyleRule } from './styleRule';
|
|
4
4
|
import { ItemAttributes } from './itemAttributes';
|
|
@@ -20,7 +20,7 @@ export declare class NodeAttributes extends ItemAttributes {
|
|
|
20
20
|
/**
|
|
21
21
|
* Run the callback if an item match with a style in the array of rules
|
|
22
22
|
*/
|
|
23
|
-
private matchStyle;
|
|
23
|
+
private static matchStyle;
|
|
24
24
|
/**
|
|
25
25
|
* Generate color for a given node (call only if _rulesMap.color is defined
|
|
26
26
|
*/
|
|
@@ -44,8 +44,9 @@ export declare class NodeAttributes extends ItemAttributes {
|
|
|
44
44
|
* return the corresponding size to the value
|
|
45
45
|
* @param value
|
|
46
46
|
* @param rule
|
|
47
|
+
* @param isLog
|
|
47
48
|
*/
|
|
48
|
-
static getAutomaticRangeSize(value: number, rule: StyleRule): string;
|
|
49
|
+
static getAutomaticRangeSize(value: number, rule: StyleRule, isLog?: boolean): string;
|
|
49
50
|
/**
|
|
50
51
|
* Return an object containing all node attributes needed by Ogma to style a node
|
|
51
52
|
*/
|