@neo4j-ndl/react-graph 2.0.22 → 2.0.23
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/lib/cjs/_generated/style-rules/index.js +10 -1
- package/lib/cjs/_generated/style-rules/index.js.map +1 -1
- package/lib/cjs/_generated/style-rules/literal-schemas.js +16 -1
- package/lib/cjs/_generated/style-rules/literal-schemas.js.map +1 -1
- package/lib/cjs/_generated/style-rules/numeric-utils.js +163 -0
- package/lib/cjs/_generated/style-rules/numeric-utils.js.map +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/stories/graph-visualization-range-styling.story.js +35 -35
- package/lib/cjs/stories/graph-visualization-range-styling.story.js.map +1 -1
- package/lib/cjs/styling/compile-graph-styles.js +68 -22
- package/lib/cjs/styling/compile-graph-styles.js.map +1 -1
- package/lib/cjs/styling/style-types.js +21 -12
- package/lib/cjs/styling/style-types.js.map +1 -1
- package/lib/esm/_generated/style-rules/index.js +2 -1
- package/lib/esm/_generated/style-rules/index.js.map +1 -1
- package/lib/esm/_generated/style-rules/literal-schemas.js +15 -0
- package/lib/esm/_generated/style-rules/literal-schemas.js.map +1 -1
- package/lib/esm/_generated/style-rules/numeric-utils.js +155 -0
- package/lib/esm/_generated/style-rules/numeric-utils.js.map +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/stories/graph-visualization-range-styling.story.js +35 -35
- package/lib/esm/stories/graph-visualization-range-styling.story.js.map +1 -1
- package/lib/esm/styling/compile-graph-styles.js +69 -23
- package/lib/esm/styling/compile-graph-styles.js.map +1 -1
- package/lib/esm/styling/style-types.js +21 -12
- package/lib/esm/styling/style-types.js.map +1 -1
- package/lib/types/_generated/style-rules/index.d.ts +4 -2
- package/lib/types/_generated/style-rules/index.d.ts.map +1 -1
- package/lib/types/_generated/style-rules/literal-schemas.d.ts +13 -0
- package/lib/types/_generated/style-rules/literal-schemas.d.ts.map +1 -1
- package/lib/types/_generated/style-rules/numeric-utils.d.ts +45 -0
- package/lib/types/_generated/style-rules/numeric-utils.d.ts.map +1 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/styling/compile-graph-styles.d.ts.map +1 -1
- package/lib/types/styling/style-types.d.ts +87 -26
- package/lib/types/styling/style-types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* AUTO-GENERATED FILE — DO NOT EDIT.
|
|
24
|
+
* Source of truth: packages/style-rules/src/
|
|
25
|
+
* Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).
|
|
26
|
+
*/
|
|
27
|
+
const BIGINT_ZERO = BigInt(0);
|
|
28
|
+
const BIGINT_ONE = BigInt(1);
|
|
29
|
+
const BIGINT_TWO = BigInt(2);
|
|
30
|
+
const BIGINT_RATIO_SCALE = BigInt('1000000000000000000');
|
|
31
|
+
function bigintPowerOfTen(exponent) {
|
|
32
|
+
return BigInt(`1${'0'.repeat(exponent)}`);
|
|
33
|
+
}
|
|
34
|
+
/** Resolves a native or JSON-safe numeric literal without reducing bigints. */
|
|
35
|
+
export function resolveNumericLiteral(value) {
|
|
36
|
+
return typeof value === 'object' ? BigInt(value.bigint) : value;
|
|
37
|
+
}
|
|
38
|
+
/** Returns whether a value is the JSON-safe bigint literal shape. */
|
|
39
|
+
export function isBigintLiteral(value) {
|
|
40
|
+
return (typeof value === 'object' &&
|
|
41
|
+
value !== null &&
|
|
42
|
+
'bigint' in value &&
|
|
43
|
+
typeof value.bigint === 'string' &&
|
|
44
|
+
/^[+-]?\d+$/.test(value.bigint));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compares numeric values without coercing bigint operands to number.
|
|
48
|
+
* Returns null for NaN, otherwise -1, 0, or 1.
|
|
49
|
+
*/
|
|
50
|
+
export function compareNumericValues(left, right) {
|
|
51
|
+
if ((typeof left === 'number' && Number.isNaN(left)) ||
|
|
52
|
+
(typeof right === 'number' && Number.isNaN(right))) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (left < right) {
|
|
56
|
+
return -1;
|
|
57
|
+
}
|
|
58
|
+
if (left > right) {
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
/** Numeric equality that treats equivalent number and bigint values as equal. */
|
|
64
|
+
export function numericValuesEqual(left, right) {
|
|
65
|
+
return compareNumericValues(left, right) === 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Clamps a numeric value between two endpoints. Inverted endpoints are
|
|
69
|
+
* supported, and the original number/bigint representation is retained.
|
|
70
|
+
*/
|
|
71
|
+
export function clampNumericValue(value, firstBound, secondBound) {
|
|
72
|
+
const boundsOrder = compareNumericValues(firstBound, secondBound);
|
|
73
|
+
if (boundsOrder === null) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const min = boundsOrder <= 0 ? firstBound : secondBound;
|
|
77
|
+
const max = boundsOrder <= 0 ? secondBound : firstBound;
|
|
78
|
+
const minOrder = compareNumericValues(value, min);
|
|
79
|
+
const maxOrder = compareNumericValues(value, max);
|
|
80
|
+
if (minOrder === null || maxOrder === null) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (minOrder < 0) {
|
|
84
|
+
return min;
|
|
85
|
+
}
|
|
86
|
+
if (maxOrder > 0) {
|
|
87
|
+
return max;
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
function numberToRational(value) {
|
|
92
|
+
if (!Number.isFinite(value)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const match = /^([+-]?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/i.exec(value.toString());
|
|
96
|
+
if (!match) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const [, sign, integer, fraction = '', exponentText = '0'] = match;
|
|
100
|
+
const exponent = Number(exponentText) - fraction.length;
|
|
101
|
+
const digits = BigInt(`${sign}${integer}${fraction}`);
|
|
102
|
+
if (exponent >= 0) {
|
|
103
|
+
return {
|
|
104
|
+
denominator: BIGINT_ONE,
|
|
105
|
+
numerator: digits * bigintPowerOfTen(exponent),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
denominator: bigintPowerOfTen(-exponent),
|
|
110
|
+
numerator: digits,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function toRational(value) {
|
|
114
|
+
return typeof value === 'bigint'
|
|
115
|
+
? { denominator: BIGINT_ONE, numerator: value }
|
|
116
|
+
: numberToRational(value);
|
|
117
|
+
}
|
|
118
|
+
function divideBigints(numerator, denominator) {
|
|
119
|
+
if (denominator === BIGINT_ZERO) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const isNegative = numerator < BIGINT_ZERO !== denominator < BIGINT_ZERO;
|
|
123
|
+
const absoluteNumerator = numerator < BIGINT_ZERO ? -numerator : numerator;
|
|
124
|
+
const absoluteDenominator = denominator < BIGINT_ZERO ? -denominator : denominator;
|
|
125
|
+
const integer = absoluteNumerator / absoluteDenominator;
|
|
126
|
+
const remainder = absoluteNumerator % absoluteDenominator;
|
|
127
|
+
const fraction = (remainder * BIGINT_RATIO_SCALE + absoluteDenominator / BIGINT_TWO) /
|
|
128
|
+
absoluteDenominator;
|
|
129
|
+
const result = Number(integer) + Number(fraction) / Number(BIGINT_RATIO_SCALE);
|
|
130
|
+
return isNegative ? -result : result;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Computes `(value - startValue) / (endValue - startValue)` while retaining
|
|
134
|
+
* bigint precision. Only the final dimensionless interpolation weight is
|
|
135
|
+
* converted to number.
|
|
136
|
+
*/
|
|
137
|
+
export function getNumericWeight(startValue, endValue, value) {
|
|
138
|
+
if (typeof startValue === 'number' &&
|
|
139
|
+
typeof endValue === 'number' &&
|
|
140
|
+
typeof value === 'number') {
|
|
141
|
+
const weight = (value - startValue) / (endValue - startValue);
|
|
142
|
+
return Number.isNaN(weight) ? null : weight;
|
|
143
|
+
}
|
|
144
|
+
const start = toRational(startValue);
|
|
145
|
+
const end = toRational(endValue);
|
|
146
|
+
const current = toRational(value);
|
|
147
|
+
if (start === null || end === null || current === null) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const valueDelta = current.numerator * start.denominator -
|
|
151
|
+
start.numerator * current.denominator;
|
|
152
|
+
const rangeDelta = end.numerator * start.denominator - start.numerator * end.denominator;
|
|
153
|
+
return divideBigints(valueDelta * end.denominator, current.denominator * rangeDelta);
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=numeric-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-utils.js","sourceRoot":"","sources":["../../../../src/_generated/style-rules/numeric-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgCH,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,CA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AC;IACxC,MAAM,UAAU,GACd,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC;IAExE,OAAO,aAAa,CAClB,UAAU,GAAG,GAAG,CAAC,WAAW,EAC5B,OAAO,CAAC,WAAW,GAAG,UAAU,CACjC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE — DO NOT EDIT.\n * Source of truth: packages/style-rules/src/\n * Regenerate with `pnpm generate:shared` (runs automatically at build/dev/install).\n */\n\n/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type { BigintLiteral, NumericLiteral } from './literal-schemas';\n\nexport type NumericValue = number | bigint;\n\ntype Rational = {\n denominator: bigint;\n numerator: bigint;\n};\n\nconst BIGINT_ZERO = BigInt(0);\nconst BIGINT_ONE = BigInt(1);\nconst BIGINT_TWO = BigInt(2);\nconst BIGINT_RATIO_SCALE = BigInt('1000000000000000000');\n\nfunction bigintPowerOfTen(exponent: number): bigint {\n return BigInt(`1${'0'.repeat(exponent)}`);\n}\n\n/** Resolves a native or JSON-safe numeric literal without reducing bigints. */\nexport function resolveNumericLiteral(value: NumericLiteral): NumericValue {\n return typeof value === 'object' ? BigInt(value.bigint) : value;\n}\n\n/** Returns whether a value is the JSON-safe bigint literal shape. */\nexport function isBigintLiteral(value: unknown): value is BigintLiteral {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'bigint' in value &&\n typeof value.bigint === 'string' &&\n /^[+-]?\\d+$/.test(value.bigint)\n );\n}\n\n/**\n * Compares numeric values without coercing bigint operands to number.\n * Returns null for NaN, otherwise -1, 0, or 1.\n */\nexport function compareNumericValues(\n left: NumericValue,\n right: NumericValue,\n): -1 | 0 | 1 | null {\n if (\n (typeof left === 'number' && Number.isNaN(left)) ||\n (typeof right === 'number' && Number.isNaN(right))\n ) {\n return null;\n }\n if (left < right) {\n return -1;\n }\n if (left > right) {\n return 1;\n }\n return 0;\n}\n\n/** Numeric equality that treats equivalent number and bigint values as equal. */\nexport function numericValuesEqual(\n left: NumericValue,\n right: NumericValue,\n): boolean {\n return compareNumericValues(left, right) === 0;\n}\n\n/**\n * Clamps a numeric value between two endpoints. Inverted endpoints are\n * supported, and the original number/bigint representation is retained.\n */\nexport function clampNumericValue(\n value: NumericValue,\n firstBound: NumericValue,\n secondBound: NumericValue,\n): NumericValue | null {\n const boundsOrder = compareNumericValues(firstBound, secondBound);\n if (boundsOrder === null) {\n return null;\n }\n const min = boundsOrder <= 0 ? firstBound : secondBound;\n const max = boundsOrder <= 0 ? secondBound : firstBound;\n const minOrder = compareNumericValues(value, min);\n const maxOrder = compareNumericValues(value, max);\n if (minOrder === null || maxOrder === null) {\n return null;\n }\n if (minOrder < 0) {\n return min;\n }\n if (maxOrder > 0) {\n return max;\n }\n return value;\n}\n\nfunction numberToRational(value: number): Rational | null {\n if (!Number.isFinite(value)) {\n return null;\n }\n\n const match = /^([+-]?)(\\d+)(?:\\.(\\d+))?(?:e([+-]?\\d+))?$/i.exec(\n value.toString(),\n );\n if (!match) {\n return null;\n }\n\n const [, sign, integer, fraction = '', exponentText = '0'] = match;\n const exponent = Number(exponentText) - fraction.length;\n const digits = BigInt(`${sign}${integer}${fraction}`);\n if (exponent >= 0) {\n return {\n denominator: BIGINT_ONE,\n numerator: digits * bigintPowerOfTen(exponent),\n };\n }\n return {\n denominator: bigintPowerOfTen(-exponent),\n numerator: digits,\n };\n}\n\nfunction toRational(value: NumericValue): Rational | null {\n return typeof value === 'bigint'\n ? { denominator: BIGINT_ONE, numerator: value }\n : numberToRational(value);\n}\n\nfunction divideBigints(numerator: bigint, denominator: bigint): number | null {\n if (denominator === BIGINT_ZERO) {\n return null;\n }\n\n const isNegative = numerator < BIGINT_ZERO !== denominator < BIGINT_ZERO;\n const absoluteNumerator = numerator < BIGINT_ZERO ? -numerator : numerator;\n const absoluteDenominator =\n denominator < BIGINT_ZERO ? -denominator : denominator;\n const integer = absoluteNumerator / absoluteDenominator;\n const remainder = absoluteNumerator % absoluteDenominator;\n const fraction =\n (remainder * BIGINT_RATIO_SCALE + absoluteDenominator / BIGINT_TWO) /\n absoluteDenominator;\n const result =\n Number(integer) + Number(fraction) / Number(BIGINT_RATIO_SCALE);\n\n return isNegative ? -result : result;\n}\n\n/**\n * Computes `(value - startValue) / (endValue - startValue)` while retaining\n * bigint precision. Only the final dimensionless interpolation weight is\n * converted to number.\n */\nexport function getNumericWeight(\n startValue: NumericValue,\n endValue: NumericValue,\n value: NumericValue,\n): number | null {\n if (\n typeof startValue === 'number' &&\n typeof endValue === 'number' &&\n typeof value === 'number'\n ) {\n const weight = (value - startValue) / (endValue - startValue);\n return Number.isNaN(weight) ? null : weight;\n }\n\n const start = toRational(startValue);\n const end = toRational(endValue);\n const current = toRational(value);\n if (start === null || end === null || current === null) {\n return null;\n }\n\n const valueDelta =\n current.numerator * start.denominator -\n start.numerator * current.denominator;\n const rangeDelta =\n end.numerator * start.denominator - start.numerator * end.denominator;\n\n return divideBigints(\n valueDelta * end.denominator,\n current.denominator * rangeDelta,\n );\n}\n"]}
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,4BAA4B,GAe7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,4BAA4B,GAe7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAoBzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { GraphVisualization } from './graph-visualization';\nexport {\n useGraphVisualizationContext,\n type ColorCount,\n type Gesture,\n type GraphItemMetaData,\n type GraphSelection,\n type GraphVisualizationContextData,\n type InteractionMode,\n type MetadataLookupTable,\n type NeoNode,\n type NeoRel,\n type NodeData,\n type NvlGraph,\n type PortableProperty,\n type RelData,\n type Sidepanel,\n} from './graph-visualization-context';\nexport { isGraphStyleRule } from './styling/style-types';\nexport type {\n GraphStyleRule,\n GraphBigintLiteral,\n GraphNumericLiteral,\n Style as GraphStyle,\n Where as GraphWhere,\n Value as GraphValue,\n CypherValue as GraphCypherValue,\n Caption as GraphCaption,\n CaptionValue as GraphCaptionValue,\n CaptionVariation as GraphCaptionVariation,\n ColorRange as GraphColorRange,\n SizeRange as GraphSizeRange,\n WidthRange as GraphWidthRange,\n UniqueColors as GraphUniqueColors,\n DatetimeLiteral as GraphDatetimeLiteral,\n LocalDatetimeLiteral as GraphLocalDatetimeLiteral,\n TimeLiteral as GraphTimeLiteral,\n} from './styling/style-types';\nexport { compileGraphStyleRules } from './styling/compile-graph-styles';\nexport { parseStyleRules } from './styling/parse-style-rules';\n"]}
|
|
@@ -23,67 +23,67 @@ import { GraphVisualization } from '../graph-visualization';
|
|
|
23
23
|
import { advancedStoryGraph, containerClasses } from './story-data';
|
|
24
24
|
const pokemonRules = [
|
|
25
25
|
{
|
|
26
|
-
match: { label: 'Pokemon' },
|
|
27
26
|
apply: {
|
|
27
|
+
captions: {
|
|
28
|
+
text: [
|
|
29
|
+
{ styles: ['bold'], value: { property: 'name' } },
|
|
30
|
+
{ styles: [], value: ' Lv' },
|
|
31
|
+
{ styles: [], value: { property: 'level' } },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
28
34
|
colorRange: {
|
|
29
|
-
onProperty: 'level',
|
|
30
|
-
minValue: 1,
|
|
31
|
-
minColor: '#3498db',
|
|
32
|
-
midValue: 45,
|
|
33
|
-
midColor: '#f1c40f',
|
|
34
|
-
maxValue: 88,
|
|
35
35
|
maxColor: '#e74c3c',
|
|
36
|
+
maxValue: 88,
|
|
37
|
+
midColor: '#f1c40f',
|
|
38
|
+
midValue: 45,
|
|
39
|
+
minColor: '#3498db',
|
|
40
|
+
minValue: 1,
|
|
41
|
+
onProperty: 'level',
|
|
36
42
|
},
|
|
37
43
|
sizeRange: {
|
|
38
|
-
|
|
39
|
-
minValue: 1,
|
|
44
|
+
maxSize: 50,
|
|
40
45
|
maxValue: 88,
|
|
41
46
|
minSize: 20,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
captions: {
|
|
45
|
-
text: [
|
|
46
|
-
{ value: { property: 'name' }, styles: ['bold'] },
|
|
47
|
-
{ value: ' Lv', styles: [] },
|
|
48
|
-
{ value: { property: 'level' }, styles: [] },
|
|
49
|
-
],
|
|
47
|
+
minValue: 1,
|
|
48
|
+
onProperty: 'level',
|
|
50
49
|
},
|
|
51
50
|
},
|
|
51
|
+
match: { label: 'Pokemon' },
|
|
52
52
|
},
|
|
53
53
|
];
|
|
54
54
|
const caughtRelRules = [
|
|
55
55
|
{
|
|
56
|
-
match: { reltype: 'CAUGHT' },
|
|
57
56
|
apply: {
|
|
57
|
+
captions: {
|
|
58
|
+
size: 1.5,
|
|
59
|
+
text: [
|
|
60
|
+
{ styles: [], value: 'Caught @ Lv' },
|
|
61
|
+
{ styles: ['bold'], value: { property: 'level' } },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
58
64
|
colorRange: {
|
|
59
|
-
onProperty: 'level',
|
|
60
|
-
minValue: 1,
|
|
61
|
-
minColor: '#00d2ff',
|
|
62
|
-
maxValue: 40,
|
|
63
65
|
maxColor: '#ff2d78',
|
|
66
|
+
maxValue: 40,
|
|
67
|
+
minColor: '#00d2ff',
|
|
68
|
+
minValue: 1,
|
|
69
|
+
onProperty: 'level',
|
|
64
70
|
},
|
|
65
71
|
width: { value: 4 },
|
|
66
72
|
widthRange: {
|
|
67
|
-
onProperty: 'level',
|
|
68
|
-
minValue: 1,
|
|
69
73
|
maxValue: 40,
|
|
70
|
-
minWidth: 1,
|
|
71
74
|
maxWidth: 8,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{ value: 'Caught @ Lv', styles: [] },
|
|
76
|
-
{ value: { property: 'level' }, styles: ['bold'] },
|
|
77
|
-
],
|
|
78
|
-
size: 1.5,
|
|
75
|
+
minValue: 1,
|
|
76
|
+
minWidth: 1,
|
|
77
|
+
onProperty: 'level',
|
|
79
78
|
},
|
|
80
79
|
},
|
|
80
|
+
match: { reltype: 'CAUGHT' },
|
|
81
81
|
},
|
|
82
82
|
];
|
|
83
83
|
const otherNodeRules = [
|
|
84
|
-
{
|
|
85
|
-
{
|
|
86
|
-
{
|
|
84
|
+
{ apply: { color: { value: '#95a5a6' } }, match: { label: 'Trainer' } },
|
|
85
|
+
{ apply: { color: { value: '#bdc3c7' } }, match: { label: 'Type' } },
|
|
86
|
+
{ apply: { color: { value: '#bdc3c7' } }, match: { label: 'Gym' } },
|
|
87
87
|
];
|
|
88
88
|
export const colorRangeStyleRules = [
|
|
89
89
|
...pokemonRules,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-visualization-range-styling.story.js","sourceRoot":"","sources":["../../../src/stories/graph-visualization-range-styling.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,YAAY,GAAqB;IACrC;QACE,KAAK,EAAE,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"graph-visualization-range-styling.story.js","sourceRoot":"","sources":["../../../src/stories/graph-visualization-range-styling.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,YAAY,GAAqB;IACrC;QACE,KAAK,EAAE;YACL,QAAQ,EAAE;gBACR,IAAI,EAAE;oBACJ,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;oBACjD,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;oBAC5B,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;iBAC7C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AAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;IACvE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IACpE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;CACpE,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAqB;IACpD,GAAG,YAAY;IACf,GAAG,cAAc;IACjB,GAAG,cAAc;CAClB,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAC7B,KAAC,kBAAkB,IACjB,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAC/B,IAAI,EAAE,kBAAkB,CAAC,IAAI,EAC7B,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,oBAAoB,GAChC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { GraphVisualization } from '../graph-visualization';\nimport { type GraphStyleRule } from '../styling/style-types';\nimport { advancedStoryGraph, containerClasses } from './story-data';\n\nconst pokemonRules: GraphStyleRule[] = [\n {\n apply: {\n captions: {\n text: [\n { styles: ['bold'], value: { property: 'name' } },\n { styles: [], value: ' Lv' },\n { styles: [], value: { property: 'level' } },\n ],\n },\n colorRange: {\n maxColor: '#e74c3c',\n maxValue: 88,\n midColor: '#f1c40f',\n midValue: 45,\n minColor: '#3498db',\n minValue: 1,\n onProperty: 'level',\n },\n sizeRange: {\n maxSize: 50,\n maxValue: 88,\n minSize: 20,\n minValue: 1,\n onProperty: 'level',\n },\n },\n match: { label: 'Pokemon' },\n },\n];\n\nconst caughtRelRules: GraphStyleRule[] = [\n {\n apply: {\n captions: {\n size: 1.5,\n text: [\n { styles: [], value: 'Caught @ Lv' },\n { styles: ['bold'], value: { property: 'level' } },\n ],\n },\n colorRange: {\n maxColor: '#ff2d78',\n maxValue: 40,\n minColor: '#00d2ff',\n minValue: 1,\n onProperty: 'level',\n },\n width: { value: 4 },\n widthRange: {\n maxValue: 40,\n maxWidth: 8,\n minValue: 1,\n minWidth: 1,\n onProperty: 'level',\n },\n },\n match: { reltype: 'CAUGHT' },\n },\n];\n\nconst otherNodeRules: GraphStyleRule[] = [\n { apply: { color: { value: '#95a5a6' } }, match: { label: 'Trainer' } },\n { apply: { color: { value: '#bdc3c7' } }, match: { label: 'Type' } },\n { apply: { color: { value: '#bdc3c7' } }, match: { label: 'Gym' } },\n];\n\nexport const colorRangeStyleRules: GraphStyleRule[] = [\n ...pokemonRules,\n ...caughtRelRules,\n ...otherNodeRules,\n];\n\nconst Component = () => {\n return (\n <div style={{ height: '600px' }}>\n <GraphVisualization\n nodes={advancedStoryGraph.nodes}\n rels={advancedStoryGraph.rels}\n className={containerClasses}\n styleRules={colorRangeStyleRules}\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -32,7 +32,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
32
32
|
import { calculateDefaultNodeColors } from '@neo4j-devtools/word-color';
|
|
33
33
|
import { tokens } from '@neo4j-ndl/base';
|
|
34
34
|
import { color, rgbToHex, validHex } from '@uiw/react-color';
|
|
35
|
-
import {
|
|
35
|
+
import { clampNumericValue, compareNumericValues, getNumericWeight, isBigintLiteral, lerpColor, numericValuesEqual, parseDateString, parseLocalDateString, parseTimeString, resolveNumericLiteral, } from '../_generated/style-rules';
|
|
36
36
|
export const DEFAULT_REL_COLOR = tokens.palette.neutral['40'];
|
|
37
37
|
const NO_LABEL_FALLBACK_COLOR = tokens.palette.neutral['40'];
|
|
38
38
|
export const UNIQUE_COLORS_PALETTE = Object.values(tokens.graph).filter(validHex);
|
|
@@ -109,13 +109,21 @@ function getInterpolatedColor(colorRange, graphItem) {
|
|
|
109
109
|
}
|
|
110
110
|
const minRgb = color(minColor).rgb;
|
|
111
111
|
const maxRgb = color(maxColor).rgb;
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const
|
|
112
|
+
const resolvedMinValue = resolveNumericLiteral(minValue);
|
|
113
|
+
const resolvedMaxValue = resolveNumericLiteral(maxValue);
|
|
114
|
+
const boundsOrder = compareNumericValues(resolvedMinValue, resolvedMaxValue);
|
|
115
|
+
if (boundsOrder === null) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const actualMinValue = boundsOrder <= 0 ? resolvedMinValue : resolvedMaxValue;
|
|
119
|
+
const actualMaxValue = boundsOrder <= 0 ? resolvedMaxValue : resolvedMinValue;
|
|
115
120
|
// Validate mid stop if provided
|
|
116
121
|
let midRgb = undefined;
|
|
122
|
+
const resolvedMidValue = midValue === undefined ? undefined : resolveNumericLiteral(midValue);
|
|
117
123
|
if (midValue !== undefined && midColor !== undefined) {
|
|
118
|
-
const
|
|
124
|
+
const minToMid = compareNumericValues(actualMinValue, resolvedMidValue);
|
|
125
|
+
const midToMax = compareNumericValues(resolvedMidValue, actualMaxValue);
|
|
126
|
+
const isMidInRange = minToMid !== null && midToMax !== null && minToMid <= 0 && midToMax <= 0;
|
|
119
127
|
if (!isMidInRange || !validHex(midColor)) {
|
|
120
128
|
return null;
|
|
121
129
|
}
|
|
@@ -126,25 +134,37 @@ function getInterpolatedColor(colorRange, graphItem) {
|
|
|
126
134
|
return null;
|
|
127
135
|
}
|
|
128
136
|
const rawValue = extractPropertyValue(prop);
|
|
129
|
-
if (typeof rawValue !== 'number') {
|
|
137
|
+
if (typeof rawValue !== 'number' && typeof rawValue !== 'bigint') {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const clampedValue = clampNumericValue(rawValue, actualMinValue, actualMaxValue);
|
|
141
|
+
if (clampedValue === null) {
|
|
130
142
|
return null;
|
|
131
143
|
}
|
|
132
|
-
const clampedValue = Math.max(actualMinValue, Math.min(actualMaxValue, rawValue));
|
|
133
144
|
let rgb;
|
|
134
|
-
if (midRgb !== undefined &&
|
|
135
|
-
const
|
|
136
|
-
|
|
145
|
+
if (midRgb !== undefined && resolvedMidValue !== undefined) {
|
|
146
|
+
const weight = getNumericWeight(resolvedMinValue, resolvedMidValue, clampedValue);
|
|
147
|
+
if (weight === null) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const isBetweenMinAndMid = weight <= 1;
|
|
137
151
|
if (isBetweenMinAndMid) {
|
|
138
|
-
rgb = lerpColor(minRgb, midRgb,
|
|
152
|
+
rgb = lerpColor(minRgb, midRgb, weight);
|
|
139
153
|
}
|
|
140
154
|
else {
|
|
141
|
-
const
|
|
142
|
-
|
|
155
|
+
const secondWeight = getNumericWeight(resolvedMidValue, resolvedMaxValue, clampedValue);
|
|
156
|
+
if (secondWeight === null) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
rgb = lerpColor(midRgb, maxRgb, secondWeight);
|
|
143
160
|
}
|
|
144
161
|
}
|
|
145
162
|
else {
|
|
146
|
-
const
|
|
147
|
-
|
|
163
|
+
const weight = getNumericWeight(resolvedMinValue, resolvedMaxValue, clampedValue);
|
|
164
|
+
if (weight === null) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
rgb = lerpColor(minRgb, maxRgb, weight);
|
|
148
168
|
}
|
|
149
169
|
return rgbToHex(rgb);
|
|
150
170
|
}
|
|
@@ -157,14 +177,20 @@ function getInterpolatedSize(prop, minValue, maxValue, minOut, maxOut) {
|
|
|
157
177
|
return null;
|
|
158
178
|
}
|
|
159
179
|
const rawValue = extractPropertyValue(prop);
|
|
160
|
-
if (typeof rawValue !== 'number') {
|
|
180
|
+
if (typeof rawValue !== 'number' && typeof rawValue !== 'bigint') {
|
|
161
181
|
return null;
|
|
162
182
|
}
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
const clampedValue =
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
const resolvedMinValue = resolveNumericLiteral(minValue);
|
|
184
|
+
const resolvedMaxValue = resolveNumericLiteral(maxValue);
|
|
185
|
+
const clampedValue = clampNumericValue(rawValue, resolvedMinValue, resolvedMaxValue);
|
|
186
|
+
if (clampedValue === null) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const weight = getNumericWeight(resolvedMinValue, resolvedMaxValue, clampedValue);
|
|
190
|
+
if (weight === null) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return minOut * (1 - weight) + maxOut * weight;
|
|
168
194
|
}
|
|
169
195
|
function extractPropertyValue(prop) {
|
|
170
196
|
switch (prop.type) {
|
|
@@ -172,8 +198,21 @@ function extractPropertyValue(prop) {
|
|
|
172
198
|
return JSON.parse(prop.stringified);
|
|
173
199
|
case 'number':
|
|
174
200
|
case 'integer':
|
|
201
|
+
case 'Integer':
|
|
175
202
|
case 'float':
|
|
176
203
|
return Number(prop.stringified);
|
|
204
|
+
case 'bigint':
|
|
205
|
+
case 'BigInt': {
|
|
206
|
+
try {
|
|
207
|
+
const value = prop.stringified.startsWith('"')
|
|
208
|
+
? JSON.parse(prop.stringified)
|
|
209
|
+
: prop.stringified;
|
|
210
|
+
return BigInt(value);
|
|
211
|
+
}
|
|
212
|
+
catch (_a) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
177
216
|
case 'boolean':
|
|
178
217
|
case 'Boolean':
|
|
179
218
|
return prop.stringified === 'true';
|
|
@@ -230,6 +269,10 @@ function evaluateWhere(node, where) {
|
|
|
230
269
|
if (leftVal === null || rightVal === null) {
|
|
231
270
|
return null;
|
|
232
271
|
}
|
|
272
|
+
if ((typeof leftVal === 'number' || typeof leftVal === 'bigint') &&
|
|
273
|
+
(typeof rightVal === 'number' || typeof rightVal === 'bigint')) {
|
|
274
|
+
return numericValuesEqual(leftVal, rightVal);
|
|
275
|
+
}
|
|
233
276
|
return leftVal === rightVal;
|
|
234
277
|
}
|
|
235
278
|
if ('not' in where) {
|
|
@@ -492,6 +535,9 @@ function evaluateValue(value, graphItem) {
|
|
|
492
535
|
if ('time' in value) {
|
|
493
536
|
return parseTimeString(value.time);
|
|
494
537
|
}
|
|
538
|
+
if (isBigintLiteral(value)) {
|
|
539
|
+
return resolveNumericLiteral(value);
|
|
540
|
+
}
|
|
495
541
|
}
|
|
496
542
|
return value;
|
|
497
543
|
}
|
|
@@ -660,11 +706,11 @@ function createByLabelSetFunction(styleMatchers) {
|
|
|
660
706
|
};
|
|
661
707
|
}
|
|
662
708
|
const DEFAULT_REL_STYLE = {
|
|
663
|
-
match: { reltype: null },
|
|
664
709
|
apply: {
|
|
665
|
-
color: { value: DEFAULT_REL_COLOR },
|
|
666
710
|
captions: { text: [{ value: { useType: true } }] },
|
|
711
|
+
color: { value: DEFAULT_REL_COLOR },
|
|
667
712
|
},
|
|
713
|
+
match: { reltype: null },
|
|
668
714
|
};
|
|
669
715
|
export function compileGraphStyleRules(styleRules) {
|
|
670
716
|
const styleMatchers = collectStyleMatchers(styleRules);
|