@graphty/graph-io 0.3.49 → 0.3.50
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/chunks/{approximations-Bzn3L-je.js → approximations-BRXsll0T.js} +2 -2
- package/dist/chunks/{approximations-Bzn3L-je.js.map → approximations-BRXsll0T.js.map} +1 -1
- package/dist/chunks/{block-iptrlMBb.js → block-yl0f_qLO.js} +27 -2
- package/dist/chunks/block-yl0f_qLO.js.map +1 -0
- package/dist/chunks/{context-C3p0RQxR.js → context-DizmppHy.js} +2 -2
- package/dist/chunks/{context-C3p0RQxR.js.map → context-DizmppHy.js.map} +1 -1
- package/dist/chunks/{credentials-DXHx7nwR.js → credentials-CmvJXYeH.js} +58 -9
- package/dist/chunks/credentials-CmvJXYeH.js.map +1 -0
- package/dist/chunks/{descriptor-DLA5kINx.js → descriptor-Dhez_Cew.js} +5 -1
- package/dist/chunks/{descriptor-DLA5kINx.js.map → descriptor-Dhez_Cew.js.map} +1 -1
- package/dist/chunks/{emit-BwHQkZle.js → emit-7Jkpg0yd.js} +132 -4
- package/dist/chunks/emit-7Jkpg0yd.js.map +1 -0
- package/dist/chunks/{exporter-nDfxIK5D.js → exporter-1Ajud15J.js} +4 -4
- package/dist/chunks/{exporter-nDfxIK5D.js.map → exporter-1Ajud15J.js.map} +1 -1
- package/dist/chunks/{exporter-D9yMtocA.js → exporter-B6yvL3wy.js} +3 -3
- package/dist/chunks/{exporter-D9yMtocA.js.map → exporter-B6yvL3wy.js.map} +1 -1
- package/dist/chunks/{exporter-_jrBTnos.js → exporter-CA5q8ROP.js} +4 -4
- package/dist/chunks/{exporter-_jrBTnos.js.map → exporter-CA5q8ROP.js.map} +1 -1
- package/dist/chunks/{exporter-D2CETOMK.js → exporter-CQQZFJ2v.js} +72 -10
- package/dist/chunks/exporter-CQQZFJ2v.js.map +1 -0
- package/dist/chunks/{generic-ymWCETAJ.js → generic-Dc21MAdg.js} +3 -3
- package/dist/chunks/{generic-ymWCETAJ.js.map → generic-Dc21MAdg.js.map} +1 -1
- package/dist/chunks/{importer-CT9mJ1nn.js → importer-C6NVpCXp.js} +7 -6
- package/dist/chunks/importer-C6NVpCXp.js.map +1 -0
- package/dist/chunks/{importer-GREKMdIf.js → importer-CKFe4q54.js} +4 -4
- package/dist/chunks/{importer-GREKMdIf.js.map → importer-CKFe4q54.js.map} +1 -1
- package/dist/chunks/{importer-PqaaKKnY.js → importer-CKbUbsJA.js} +4 -4
- package/dist/chunks/{importer-PqaaKKnY.js.map → importer-CKbUbsJA.js.map} +1 -1
- package/dist/chunks/{importer-DaLTjbds.js → importer-ClCsdgTJ.js} +97 -7
- package/dist/chunks/importer-ClCsdgTJ.js.map +1 -0
- package/dist/chunks/{importer-B92x1xY5.js → importer-CyVZTrf0.js} +3 -3
- package/dist/chunks/{importer-B92x1xY5.js.map → importer-CyVZTrf0.js.map} +1 -1
- package/dist/chunks/{importer-vRq4h3j5.js → importer-DgG4v1Ms.js} +89 -20
- package/dist/chunks/importer-DgG4v1Ms.js.map +1 -0
- package/dist/chunks/{importer-Vn5QvmmJ.js → importer-asFUrIsj.js} +2 -2
- package/dist/chunks/{importer-Vn5QvmmJ.js.map → importer-asFUrIsj.js.map} +1 -1
- package/dist/chunks/{lexicon-Clf4QIyl.js → lexicon-IVRq2Uoo.js} +2 -2
- package/dist/chunks/{lexicon-Clf4QIyl.js.map → lexicon-IVRq2Uoo.js.map} +1 -1
- package/dist/chunks/{round-trip-Zm3_ivgq.js → round-trip-Cy3_SHRZ.js} +2 -2
- package/dist/chunks/{round-trip-Zm3_ivgq.js.map → round-trip-Cy3_SHRZ.js.map} +1 -1
- package/dist/chunks/{sigv4-EokFic1V.js → sigv4-BXwVbza3.js} +3 -3
- package/dist/chunks/{sigv4-EokFic1V.js.map → sigv4-BXwVbza3.js.map} +1 -1
- package/dist/chunks/{styles-CCs214_3.js → styles-CAVmBLgp.js} +4 -4
- package/dist/chunks/{styles-CCs214_3.js.map → styles-CAVmBLgp.js.map} +1 -1
- package/dist/chunks/{styles-DPQQIig4.js → styles-CPczw1Jz.js} +4 -4
- package/dist/chunks/{styles-DPQQIig4.js.map → styles-CPczw1Jz.js.map} +1 -1
- package/dist/chunks/{styles-Cm62yyQX.js → styles-boK6Ln54.js} +65 -30
- package/dist/chunks/styles-boK6Ln54.js.map +1 -0
- package/dist/chunks/{styles-yed-UMFdNqze.js → styles-yed-XeFBQ6VS.js} +8 -8
- package/dist/chunks/{styles-yed-UMFdNqze.js.map → styles-yed-XeFBQ6VS.js.map} +1 -1
- package/dist/cx.js +2 -2
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +7 -4
- package/dist/gexf.js +2 -2
- package/dist/gml.js +8 -8
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +129 -104
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +2 -2
- package/dist/json.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/sources-cypher.js +25 -22
- package/dist/sources-cypher.js.map +1 -1
- package/dist/sources-ndex.js +2 -2
- package/dist/sources-rest.js +20 -4
- package/dist/sources-rest.js.map +1 -1
- package/dist/sources-sparql.js +40 -6
- package/dist/sources-sparql.js.map +1 -1
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +34 -2
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts +6 -1
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +65 -5
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/index.d.ts +3 -1
- package/dist/src/formats/dot/index.d.ts.map +1 -1
- package/dist/src/formats/dot/index.js +2 -1
- package/dist/src/formats/dot/index.js.map +1 -1
- package/dist/src/formats/dot/label-places.d.ts +7 -0
- package/dist/src/formats/dot/label-places.d.ts.map +1 -1
- package/dist/src/formats/dot/label-places.js +9 -3
- package/dist/src/formats/dot/label-places.js.map +1 -1
- package/dist/src/formats/dot/names.d.ts +13 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -1
- package/dist/src/formats/dot/names.js +13 -0
- package/dist/src/formats/dot/names.js.map +1 -1
- package/dist/src/formats/dot/styles.d.ts +10 -0
- package/dist/src/formats/dot/styles.d.ts.map +1 -1
- package/dist/src/formats/dot/styles.js +49 -3
- package/dist/src/formats/dot/styles.js.map +1 -1
- package/dist/src/formats/gml/styles.js +1 -1
- package/dist/src/formats/gml/styles.js.map +1 -1
- package/dist/src/formats/graphml/styles-yed.js +3 -3
- package/dist/src/formats/graphml/styles-yed.js.map +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.js +6 -4
- package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -1
- package/dist/src/formats/json/styles.d.ts.map +1 -1
- package/dist/src/formats/json/styles.js +94 -6
- package/dist/src/formats/json/styles.js.map +1 -1
- package/dist/src/formats/pajek/draw.d.ts +8 -0
- package/dist/src/formats/pajek/draw.d.ts.map +1 -1
- package/dist/src/formats/pajek/draw.js +10 -0
- package/dist/src/formats/pajek/draw.js.map +1 -1
- package/dist/src/formats/pajek/styles.d.ts.map +1 -1
- package/dist/src/formats/pajek/styles.js +142 -25
- package/dist/src/formats/pajek/styles.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/sources/credentials.d.ts +50 -1
- package/dist/src/sources/credentials.d.ts.map +1 -1
- package/dist/src/sources/credentials.js +69 -0
- package/dist/src/sources/credentials.js.map +1 -1
- package/dist/src/sources/cypher/index.d.ts.map +1 -1
- package/dist/src/sources/cypher/index.js +12 -11
- package/dist/src/sources/cypher/index.js.map +1 -1
- package/dist/src/sources/cypher/query-builder.d.ts +6 -6
- package/dist/src/sources/cypher/query-builder.d.ts.map +1 -1
- package/dist/src/sources/cypher/query-builder.js +15 -15
- package/dist/src/sources/cypher/query-builder.js.map +1 -1
- package/dist/src/sources/rest/descriptor.d.ts.map +1 -1
- package/dist/src/sources/rest/descriptor.js +4 -0
- package/dist/src/sources/rest/descriptor.js.map +1 -1
- package/dist/src/sources/rest/openalex.d.ts +4 -2
- package/dist/src/sources/rest/openalex.d.ts.map +1 -1
- package/dist/src/sources/rest/openalex.js +4 -2
- package/dist/src/sources/rest/openalex.js.map +1 -1
- package/dist/src/sources/rest/source.d.ts.map +1 -1
- package/dist/src/sources/rest/source.js +23 -0
- package/dist/src/sources/rest/source.js.map +1 -1
- package/dist/src/sources/run.d.ts +2 -0
- package/dist/src/sources/run.d.ts.map +1 -1
- package/dist/src/sources/run.js +30 -3
- package/dist/src/sources/run.js.map +1 -1
- package/dist/src/sources/sparql/index.d.ts.map +1 -1
- package/dist/src/sources/sparql/index.js +14 -1
- package/dist/src/sources/sparql/index.js.map +1 -1
- package/dist/src/sources/sparql/query.d.ts +2 -1
- package/dist/src/sources/sparql/query.d.ts.map +1 -1
- package/dist/src/sources/sparql/query.js +55 -4
- package/dist/src/sources/sparql/query.js.map +1 -1
- package/dist/src/sources/types.d.ts +29 -0
- package/dist/src/sources/types.d.ts.map +1 -1
- package/dist/src/styles/canon/enums.d.ts.map +1 -1
- package/dist/src/styles/canon/enums.js +8 -0
- package/dist/src/styles/canon/enums.js.map +1 -1
- package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
- package/dist/src/styles/cyjs/cascade.js +124 -0
- package/dist/src/styles/cyjs/cascade.js.map +1 -1
- package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
- package/dist/src/styles/cyjs/defaults-table.js +1 -0
- package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
- package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
- package/dist/src/styles/cyjs/emit.js +30 -1
- package/dist/src/styles/cyjs/emit.js.map +1 -1
- package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
- package/dist/src/styles/cyjs/mappers.js +14 -0
- package/dist/src/styles/cyjs/mappers.js.map +1 -1
- package/dist/src/styles/types.d.ts +65 -0
- package/dist/src/styles/types.d.ts.map +1 -1
- package/dist/src/styles/vocabulary.d.ts.map +1 -1
- package/dist/src/styles/vocabulary.js +21 -0
- package/dist/src/styles/vocabulary.js.map +1 -1
- package/dist/styles.js +6 -6
- package/dist/xgmml.js +3 -3
- package/package.json +2 -2
- package/src/formats/dot/exporter.ts +37 -1
- package/src/formats/dot/importer.ts +75 -4
- package/src/formats/dot/index.ts +3 -1
- package/src/formats/dot/label-places.ts +16 -3
- package/src/formats/dot/names.ts +15 -0
- package/src/formats/dot/styles.ts +55 -3
- package/src/formats/gml/styles.ts +1 -1
- package/src/formats/graphml/styles-yed.ts +3 -3
- package/src/formats/graphml/styles-yfiles3.ts +6 -4
- package/src/formats/json/styles.ts +102 -6
- package/src/formats/pajek/draw.ts +11 -0
- package/src/formats/pajek/styles.ts +151 -26
- package/src/index.ts +7 -0
- package/src/sources/credentials.ts +90 -1
- package/src/sources/cypher/index.ts +12 -11
- package/src/sources/cypher/query-builder.ts +15 -15
- package/src/sources/rest/descriptor.ts +4 -0
- package/src/sources/rest/openalex.ts +4 -2
- package/src/sources/rest/source.ts +25 -0
- package/src/sources/run.ts +35 -3
- package/src/sources/sparql/index.ts +16 -1
- package/src/sources/sparql/query.ts +58 -4
- package/src/sources/types.ts +33 -0
- package/src/styles/canon/enums.ts +9 -0
- package/src/styles/cyjs/cascade.ts +143 -0
- package/src/styles/cyjs/defaults-table.ts +1 -0
- package/src/styles/cyjs/emit.ts +35 -1
- package/src/styles/cyjs/mappers.ts +14 -0
- package/src/styles/types.ts +65 -0
- package/src/styles/vocabulary.ts +21 -0
- package/dist/chunks/block-iptrlMBb.js.map +0 -1
- package/dist/chunks/credentials-DXHx7nwR.js.map +0 -1
- package/dist/chunks/emit-BwHQkZle.js.map +0 -1
- package/dist/chunks/exporter-D2CETOMK.js.map +0 -1
- package/dist/chunks/importer-CT9mJ1nn.js.map +0 -1
- package/dist/chunks/importer-DaLTjbds.js.map +0 -1
- package/dist/chunks/importer-vRq4h3j5.js.map +0 -1
- package/dist/chunks/styles-Cm62yyQX.js.map +0 -1
|
@@ -1354,6 +1354,7 @@ function evaluateTarget(
|
|
|
1354
1354
|
if (kind === "node") {
|
|
1355
1355
|
const read: DrawnRead = { kind, els, cells, order, rendered: input.rendered, notes };
|
|
1356
1356
|
nodeSizes(graph, read, drawn);
|
|
1357
|
+
groupBoxes(graph, read, drawn);
|
|
1357
1358
|
mixedLabelPlaces(graph, read, drawn);
|
|
1358
1359
|
}
|
|
1359
1360
|
if (kind === "edge") {
|
|
@@ -1787,6 +1788,8 @@ const CYJS_EDGE_ONLY: ReadonlySet<string> = new Set([
|
|
|
1787
1788
|
"target-text-margin-y",
|
|
1788
1789
|
"source-text-rotation",
|
|
1789
1790
|
"target-text-rotation",
|
|
1791
|
+
"source-distance-from-node",
|
|
1792
|
+
"target-distance-from-node",
|
|
1790
1793
|
]);
|
|
1791
1794
|
|
|
1792
1795
|
/**
|
|
@@ -2839,6 +2842,146 @@ function nodeSizes(graph: CyjsGraph, read: DrawnRead, values: Record<string, (St
|
|
|
2839
2842
|
}
|
|
2840
2843
|
}
|
|
2841
2844
|
|
|
2845
|
+
/** The words of a compound parent's sizing properties. */
|
|
2846
|
+
const PADDING_OF_PART: CyjsPropertySpec = {
|
|
2847
|
+
property: "_paddingOf",
|
|
2848
|
+
type: "enum",
|
|
2849
|
+
enums: ["width", "height", "average", "min", "max"],
|
|
2850
|
+
};
|
|
2851
|
+
const LABELS_PART: CyjsPropertySpec = { property: "_compoundLabels", type: "enum", enums: ["include", "exclude"] };
|
|
2852
|
+
|
|
2853
|
+
/**
|
|
2854
|
+
* A length or a percentage as Cytoscape.js spells it.
|
|
2855
|
+
* @param text - the value, or null
|
|
2856
|
+
* @returns the number and whether it is a percentage, or null for none or a non-number
|
|
2857
|
+
*/
|
|
2858
|
+
function measureOf(text: StyleValue | null | undefined): { value: number; percent: boolean } | null {
|
|
2859
|
+
if (typeof text !== "string" && typeof text !== "number") {
|
|
2860
|
+
return null;
|
|
2861
|
+
}
|
|
2862
|
+
const value = Number.parseFloat(String(text));
|
|
2863
|
+
return Number.isFinite(value) ? { value, percent: String(text).trim().endsWith("%") } : null;
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
/**
|
|
2867
|
+
* The share of a minimum's growth on the near side (left, top), as Cytoscape.js 3.34.3 `updateCompoundBounds`
|
|
2868
|
+
* splits it: each bias a percentage, a length read as its percentage of the minimum, the near side's share of
|
|
2869
|
+
* their sum; no bias on either side grows both sides alike.
|
|
2870
|
+
* @param near - the near side's bias
|
|
2871
|
+
* @param far - the far side's bias
|
|
2872
|
+
* @param min - the minimum
|
|
2873
|
+
* @returns the near side's share, or null for half
|
|
2874
|
+
*/
|
|
2875
|
+
function biasShare(
|
|
2876
|
+
near: StyleValue | null | undefined,
|
|
2877
|
+
far: StyleValue | null | undefined,
|
|
2878
|
+
min: number,
|
|
2879
|
+
): number | null {
|
|
2880
|
+
const percent = (text: StyleValue | null | undefined): number => {
|
|
2881
|
+
const m = measureOf(text);
|
|
2882
|
+
if (m === null || m.value <= 0) {
|
|
2883
|
+
return 0;
|
|
2884
|
+
}
|
|
2885
|
+
return m.percent ? m.value : (m.value * 100) / min;
|
|
2886
|
+
};
|
|
2887
|
+
const a = percent(near);
|
|
2888
|
+
const total = a + percent(far);
|
|
2889
|
+
return total > 0 ? a / total : null;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
/**
|
|
2893
|
+
* How Cytoscape.js sizes a compound parent round its children (cytoscape.js 3.34.3 `updateCompoundBounds`): its
|
|
2894
|
+
* `padding` past their box (a percentage is of the box, `padding-relative-to`), at least `min-width` by `min-height`
|
|
2895
|
+
* before the padding, grown by the biases' shares, its children's labels counted unless `compound-sizing-wrt-labels`
|
|
2896
|
+
* is `exclude`. Written for every compound parent, so the group is drawn as Cytoscape.js draws it.
|
|
2897
|
+
* @param graph - the core's elements
|
|
2898
|
+
* @param read - the nodes' cells
|
|
2899
|
+
* @param values - the nodes' values; changed in place
|
|
2900
|
+
*/
|
|
2901
|
+
function groupBoxes(graph: CyjsGraph, read: DrawnRead, values: Record<string, (StyleValue | null)[]>): void {
|
|
2902
|
+
const word = (name: string, spec: CyjsPropertySpec = TEXT_PART): (StyleValue | null | undefined)[] =>
|
|
2903
|
+
drawnColumn(read, name, spec);
|
|
2904
|
+
const padding = word("padding");
|
|
2905
|
+
const paddingOf = word("padding-relative-to", PADDING_OF_PART);
|
|
2906
|
+
const labels = word("compound-sizing-wrt-labels", LABELS_PART);
|
|
2907
|
+
const axes = [
|
|
2908
|
+
{ min: word("min-width"), near: word("min-width-bias-left"), far: word("min-width-bias-right") },
|
|
2909
|
+
{ min: word("min-height"), near: word("min-height-bias-top"), far: word("min-height-bias-bottom") },
|
|
2910
|
+
];
|
|
2911
|
+
const names = [
|
|
2912
|
+
["groupMinWidth", "groupMinWidthBiasLeft"],
|
|
2913
|
+
["groupMinHeight", "groupMinHeightBiasTop"],
|
|
2914
|
+
];
|
|
2915
|
+
const n = read.order.length;
|
|
2916
|
+
const put = (p: string, k: number, v: StyleValue): void => {
|
|
2917
|
+
const column = values[p] ?? new Array<StyleValue | null>(n).fill(null);
|
|
2918
|
+
values[p] = column;
|
|
2919
|
+
column[k] = v;
|
|
2920
|
+
};
|
|
2921
|
+
for (let k = 0; k < n; k++) {
|
|
2922
|
+
const core = read.order[k];
|
|
2923
|
+
if (core < 0 || graph.children[core].length === 0) {
|
|
2924
|
+
continue;
|
|
2925
|
+
}
|
|
2926
|
+
for (const [p, v] of groupPaddingValues(padding[k], paddingOf[k])) {
|
|
2927
|
+
put(p, k, v);
|
|
2928
|
+
}
|
|
2929
|
+
put("groupIncludeLabels", k, labels[k] !== "exclude");
|
|
2930
|
+
axes.forEach((axis, a) => {
|
|
2931
|
+
for (const [p, v] of groupMinValues(axis.min[k], axis.near[k], axis.far[k], names[a])) {
|
|
2932
|
+
put(p, k, v);
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
/**
|
|
2939
|
+
* A compound parent's padding as neutral values: a length, or a fraction of the side `padding-relative-to` names.
|
|
2940
|
+
* @param padding - the padding as Cytoscape.js spells it
|
|
2941
|
+
* @param of - its `padding-relative-to`
|
|
2942
|
+
* @returns the properties and their values
|
|
2943
|
+
*/
|
|
2944
|
+
function groupPaddingValues(
|
|
2945
|
+
padding: StyleValue | null | undefined,
|
|
2946
|
+
of: StyleValue | null | undefined,
|
|
2947
|
+
): [string, StyleValue][] {
|
|
2948
|
+
const pad = measureOf(padding);
|
|
2949
|
+
if (pad?.percent !== true) {
|
|
2950
|
+
return [["groupPadding", Math.max(0, pad?.value ?? 0)]];
|
|
2951
|
+
}
|
|
2952
|
+
return [
|
|
2953
|
+
["groupPaddingRatio", Math.max(0, pad.value / 100)],
|
|
2954
|
+
["groupPaddingOf", typeof of === "string" ? of : "width"],
|
|
2955
|
+
];
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
/**
|
|
2959
|
+
* A compound parent's minimum size on one axis and the share of its growth on the near side, as neutral values.
|
|
2960
|
+
* @param min - the minimum as Cytoscape.js spells it
|
|
2961
|
+
* @param near - the near side's bias (left, top)
|
|
2962
|
+
* @param far - the far side's bias
|
|
2963
|
+
* @param names - the neutral names of the minimum and of the near side's share
|
|
2964
|
+
* @returns the properties and their values; none without a minimum
|
|
2965
|
+
*/
|
|
2966
|
+
function groupMinValues(
|
|
2967
|
+
min: StyleValue | null | undefined,
|
|
2968
|
+
near: StyleValue | null | undefined,
|
|
2969
|
+
far: StyleValue | null | undefined,
|
|
2970
|
+
names: readonly string[],
|
|
2971
|
+
): [string, StyleValue][] {
|
|
2972
|
+
const m = measureOf(min);
|
|
2973
|
+
if (m === null || m.percent || m.value <= 0) {
|
|
2974
|
+
return [];
|
|
2975
|
+
}
|
|
2976
|
+
const share = biasShare(near, far, m.value);
|
|
2977
|
+
return share === null
|
|
2978
|
+
? [[names[0], m.value]]
|
|
2979
|
+
: [
|
|
2980
|
+
[names[0], m.value],
|
|
2981
|
+
[names[1], share],
|
|
2982
|
+
];
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2842
2985
|
/** The label alignments read as Cytoscape.js's words. */
|
|
2843
2986
|
const VALIGN_PART: CyjsPropertySpec = {
|
|
2844
2987
|
property: "_valign",
|
package/src/styles/cyjs/emit.ts
CHANGED
|
@@ -224,7 +224,41 @@ function toCyjs(target: StyleTarget, property: string, value: StyleValue): Writt
|
|
|
224
224
|
case "labelBorderWidth":
|
|
225
225
|
return ifNumber(value, (v) => exact({ "text-border-width": v, "text-border-opacity": 1 }));
|
|
226
226
|
default:
|
|
227
|
-
return propertyToCyjs(property, value, specs);
|
|
227
|
+
return groupToCyjs(property, value) ?? propertyToCyjs(property, value, specs);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A compound parent's sizing as Cytoscape.js properties: a bias share as the two sides' percentages.
|
|
233
|
+
* @param property - the neutral property
|
|
234
|
+
* @param value - the value
|
|
235
|
+
* @returns the properties, or null when the property is no group sizing
|
|
236
|
+
*/
|
|
237
|
+
function groupToCyjs(property: string, value: StyleValue): Written | null {
|
|
238
|
+
const percent = (v: number): string => `${num6(v * 100)}%`;
|
|
239
|
+
switch (property) {
|
|
240
|
+
case "groupPadding":
|
|
241
|
+
return ifNumber(value, (v) => exact({ padding: `${num6(v)}px` }));
|
|
242
|
+
case "groupPaddingRatio":
|
|
243
|
+
return ifNumber(value, (v) => exact({ padding: percent(v) }));
|
|
244
|
+
case "groupPaddingOf":
|
|
245
|
+
return exact({ "padding-relative-to": String(value) });
|
|
246
|
+
case "groupMinWidth":
|
|
247
|
+
return ifNumber(value, (v) => exact({ "min-width": `${num6(v)}px` }));
|
|
248
|
+
case "groupMinHeight":
|
|
249
|
+
return ifNumber(value, (v) => exact({ "min-height": `${num6(v)}px` }));
|
|
250
|
+
case "groupMinWidthBiasLeft":
|
|
251
|
+
return ifNumber(value, (v) =>
|
|
252
|
+
exact({ "min-width-bias-left": percent(v), "min-width-bias-right": percent(1 - v) }),
|
|
253
|
+
);
|
|
254
|
+
case "groupMinHeightBiasTop":
|
|
255
|
+
return ifNumber(value, (v) =>
|
|
256
|
+
exact({ "min-height-bias-top": percent(v), "min-height-bias-bottom": percent(1 - v) }),
|
|
257
|
+
);
|
|
258
|
+
case "groupIncludeLabels":
|
|
259
|
+
return exact({ "compound-sizing-wrt-labels": value === false ? "exclude" : "include" });
|
|
260
|
+
default:
|
|
261
|
+
return null;
|
|
228
262
|
}
|
|
229
263
|
}
|
|
230
264
|
|
|
@@ -465,6 +465,18 @@ export const CYJS_NODE_PROPERTIES: ReadonlyMap<string, CyjsPropertySpec> = new M
|
|
|
465
465
|
["height", { property: "height", type: "nodeSize" }],
|
|
466
466
|
// a node is drawn this much larger on every side (`nodeSizes`)
|
|
467
467
|
["padding", { property: "_padding", type: "text" }],
|
|
468
|
+
// how a compound parent is sized round its children (`groupBoxes`)
|
|
469
|
+
[
|
|
470
|
+
"padding-relative-to",
|
|
471
|
+
{ property: "_paddingOf", type: "enum", enums: ["width", "height", "average", "min", "max"] },
|
|
472
|
+
],
|
|
473
|
+
["min-width", { property: "_minWidth", type: "text" }],
|
|
474
|
+
["min-height", { property: "_minHeight", type: "text" }],
|
|
475
|
+
["min-width-bias-left", { property: "_biasLeft", type: "text" }],
|
|
476
|
+
["min-width-bias-right", { property: "_biasRight", type: "text" }],
|
|
477
|
+
["min-height-bias-top", { property: "_biasTop", type: "text" }],
|
|
478
|
+
["min-height-bias-bottom", { property: "_biasBottom", type: "text" }],
|
|
479
|
+
["compound-sizing-wrt-labels", { property: "_compoundLabels", type: "enum", enums: ["include", "exclude"] }],
|
|
468
480
|
[
|
|
469
481
|
"text-valign",
|
|
470
482
|
{ property: "_valign", type: "enum", enums: ["top", "top-inside", "center", "bottom", "bottom-inside"] },
|
|
@@ -538,6 +550,8 @@ export const CYJS_EDGE_PROPERTIES: ReadonlyMap<string, CyjsPropertySpec> = new M
|
|
|
538
550
|
// where the ends meet the nodes, read with the routes (`edgePorts`)
|
|
539
551
|
["source-endpoint", { property: "_sourceEndpoint", type: "text" }],
|
|
540
552
|
["target-endpoint", { property: "_targetEndpoint", type: "text" }],
|
|
553
|
+
["source-distance-from-node", { property: "sourceNodeGap", type: "size" }],
|
|
554
|
+
["target-distance-from-node", { property: "targetNodeGap", type: "size" }],
|
|
541
555
|
// a bundle's control points are this far apart, so the curves' middles half of it (see cyjsNeutral)
|
|
542
556
|
["control-point-step-size", { property: "fanSpacing", type: "size" }],
|
|
543
557
|
["arrow-scale", { property: "arrowSize", type: "positive" }],
|
package/src/styles/types.ts
CHANGED
|
@@ -518,6 +518,37 @@ export interface NodeStyleValues {
|
|
|
518
518
|
readonly chartBorderColor: StyleColor;
|
|
519
519
|
/** How wide a bar's and a box's outline is (a length); unset, none. */
|
|
520
520
|
readonly chartBorderWidth: number;
|
|
521
|
+
/**
|
|
522
|
+
* How far a group drawn round its members (a node other nodes name as their parent, with no box of its own) reaches
|
|
523
|
+
* past their box on every side (a length; Cytoscape.js `padding` on a compound parent). Unset, the reader's own.
|
|
524
|
+
*/
|
|
525
|
+
readonly groupPadding: number;
|
|
526
|
+
/**
|
|
527
|
+
* That padding as a fraction of the members' box instead, measured as `groupPaddingOf` says (Cytoscape.js
|
|
528
|
+
* `padding: 20%`); it wins over `groupPadding`.
|
|
529
|
+
*/
|
|
530
|
+
readonly groupPaddingRatio: number;
|
|
531
|
+
/**
|
|
532
|
+
* What `groupPaddingRatio` is a fraction of: the members' box's `width`, `height`, `average` of the two, `min` or
|
|
533
|
+
* `max` (Cytoscape.js `padding-relative-to`); unset, `width`.
|
|
534
|
+
*/
|
|
535
|
+
readonly groupPaddingOf: string;
|
|
536
|
+
/** The narrowest the members' box is drawn, before the padding (a length; Cytoscape.js `min-width`). */
|
|
537
|
+
readonly groupMinWidth: number;
|
|
538
|
+
/** The shortest the members' box is drawn, before the padding (a length; Cytoscape.js `min-height`). */
|
|
539
|
+
readonly groupMinHeight: number;
|
|
540
|
+
/**
|
|
541
|
+
* The share, 0..1, of the width `groupMinWidth` adds that goes on the left (Cytoscape.js `min-width-bias-left`
|
|
542
|
+
* against `min-width-bias-right`); unset, half.
|
|
543
|
+
*/
|
|
544
|
+
readonly groupMinWidthBiasLeft: number;
|
|
545
|
+
/**
|
|
546
|
+
* The share, 0..1, of the height `groupMinHeight` adds that goes on top, as the reader sees it (Cytoscape.js
|
|
547
|
+
* `min-height-bias-top` against `min-height-bias-bottom`); unset, half.
|
|
548
|
+
*/
|
|
549
|
+
readonly groupMinHeightBiasTop: number;
|
|
550
|
+
/** Whether the members' labels count in the members' box (Cytoscape.js `compound-sizing-wrt-labels`). */
|
|
551
|
+
readonly groupIncludeLabels: boolean;
|
|
521
552
|
/** Whether the node is drawn at all. */
|
|
522
553
|
readonly visible: boolean;
|
|
523
554
|
}
|
|
@@ -701,11 +732,33 @@ export interface EdgeStyleValues {
|
|
|
701
732
|
* distance between them (Gephi: the distance over its arc curveness 1.2).
|
|
702
733
|
*/
|
|
703
734
|
readonly arcRadius: number;
|
|
735
|
+
/**
|
|
736
|
+
* A curved edge drawn as one quadratic curve through a support point a force simulation places among the nodes,
|
|
737
|
+
* wherever they are: `"barnesHut"` or `"forceAtlas2"`, the force law it settles under (vis-network's dynamic smooth
|
|
738
|
+
* edges, under its solvers of those names). Tied to the edge's two nodes by two springs, pushed away by every node
|
|
739
|
+
* and every other support point, pulled toward the middle of the nodes; the numbers below are in the file's units.
|
|
740
|
+
*/
|
|
741
|
+
readonly supportModel: string;
|
|
742
|
+
/** The rest length of a support point's two springs together (a length). */
|
|
743
|
+
readonly supportSpringLength: number;
|
|
744
|
+
/** How hard a support point's springs pull per unit they are stretched. */
|
|
745
|
+
readonly supportSpringConstant: number;
|
|
746
|
+
/**
|
|
747
|
+
* How hard every node and every other support point push a support point away: over the distance squared under
|
|
748
|
+
* barnesHut, over the distance under forceAtlas2.
|
|
749
|
+
*/
|
|
750
|
+
readonly supportRepulsion: number;
|
|
751
|
+
/** How hard a support point is pulled toward the middle of the nodes: a constant pull under barnesHut, in proportion to the distance under forceAtlas2. */
|
|
752
|
+
readonly supportCentralGravity: number;
|
|
704
753
|
/**
|
|
705
754
|
* How far from each of its nodes' outlines the edge's line (and its arrowhead) stops, leaving that much empty
|
|
706
755
|
* (a length; Gephi's `edge.radius`).
|
|
707
756
|
*/
|
|
708
757
|
readonly nodeGap: number;
|
|
758
|
+
/** How far from its source node's outline the edge's line stops, over `nodeGap` at that end (a length). */
|
|
759
|
+
readonly sourceNodeGap: number;
|
|
760
|
+
/** How far from its target node's outline the line (and its arrowhead) stops; see `sourceNodeGap`. */
|
|
761
|
+
readonly targetNodeGap: number;
|
|
709
762
|
/**
|
|
710
763
|
* Where the edge leaves its source node, when not at its center: `x,y` relative to the node's center as fractions
|
|
711
764
|
* of its half width and half height, y up (`"1,0"` is the middle of its right side, `"0,1"` of its top), so the
|
|
@@ -813,6 +866,18 @@ export interface EdgeStyleValues {
|
|
|
813
866
|
readonly sourceLabelRotation: number;
|
|
814
867
|
/** How far the target end's label is turned, in degrees clockwise about its middle; unset, level. */
|
|
815
868
|
readonly targetLabelRotation: number;
|
|
869
|
+
/** The source end's label's font size, in the units of `labelSize`; unset, the label's (`labelSize`). */
|
|
870
|
+
readonly sourceLabelSize: number;
|
|
871
|
+
/** The target end's label's font size; see `sourceLabelSize`. */
|
|
872
|
+
readonly targetLabelSize: number;
|
|
873
|
+
/** The color of the source end's label's words; unset, the label's (`labelColor`). */
|
|
874
|
+
readonly sourceLabelColor: StyleColor;
|
|
875
|
+
/** The color of the target end's label's words; see `sourceLabelColor`. */
|
|
876
|
+
readonly targetLabelColor: StyleColor;
|
|
877
|
+
/** The source end's label's font family, as the file names it; unset, the label's (`labelFont`). */
|
|
878
|
+
readonly sourceLabelFont: string;
|
|
879
|
+
/** The target end's label's font family; see `sourceLabelFont`. */
|
|
880
|
+
readonly targetLabelFont: string;
|
|
816
881
|
/** The label is not drawn while its letters are drawn smaller than this many screen pixels; see the node's. */
|
|
817
882
|
readonly labelMinScreenSize: number;
|
|
818
883
|
/** Whether the label is drawn over every node and edge; see the node's. */
|
package/src/styles/vocabulary.ts
CHANGED
|
@@ -170,6 +170,14 @@ export const STYLE_PROPERTIES: {
|
|
|
170
170
|
["chartLineWidth", "number"],
|
|
171
171
|
["chartBorderColor", "color"],
|
|
172
172
|
["chartBorderWidth", "number"],
|
|
173
|
+
["groupPadding", "number"],
|
|
174
|
+
["groupPaddingRatio", "number"],
|
|
175
|
+
["groupPaddingOf", "text"],
|
|
176
|
+
["groupMinWidth", "number"],
|
|
177
|
+
["groupMinHeight", "number"],
|
|
178
|
+
["groupMinWidthBiasLeft", "number"],
|
|
179
|
+
["groupMinHeightBiasTop", "number"],
|
|
180
|
+
["groupIncludeLabels", "boolean"],
|
|
173
181
|
["visible", "boolean"],
|
|
174
182
|
]),
|
|
175
183
|
edge: new Map<string, StyleValueKind>([
|
|
@@ -229,7 +237,14 @@ export const STYLE_PROPERTIES: {
|
|
|
229
237
|
["fanned", "boolean"],
|
|
230
238
|
["bendCurve", "text"],
|
|
231
239
|
["arcRadius", "number"],
|
|
240
|
+
["supportModel", "text"],
|
|
241
|
+
["supportSpringLength", "number"],
|
|
242
|
+
["supportSpringConstant", "number"],
|
|
243
|
+
["supportRepulsion", "number"],
|
|
244
|
+
["supportCentralGravity", "number"],
|
|
232
245
|
["nodeGap", "number"],
|
|
246
|
+
["sourceNodeGap", "number"],
|
|
247
|
+
["targetNodeGap", "number"],
|
|
233
248
|
["sourcePort", "text"],
|
|
234
249
|
["targetPort", "text"],
|
|
235
250
|
["label", "text"],
|
|
@@ -272,6 +287,12 @@ export const STYLE_PROPERTIES: {
|
|
|
272
287
|
["targetLabelOffsetY", "signed"],
|
|
273
288
|
["sourceLabelRotation", "number"],
|
|
274
289
|
["targetLabelRotation", "number"],
|
|
290
|
+
["sourceLabelSize", "number"],
|
|
291
|
+
["targetLabelSize", "number"],
|
|
292
|
+
["sourceLabelColor", "color"],
|
|
293
|
+
["targetLabelColor", "color"],
|
|
294
|
+
["sourceLabelFont", "text"],
|
|
295
|
+
["targetLabelFont", "text"],
|
|
275
296
|
["labelMinScreenSize", "number"],
|
|
276
297
|
["labelOnTop", "boolean"],
|
|
277
298
|
["visible", "boolean"],
|