layerchart 2.0.0-next.0 → 2.0.0-next.2
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/actions/movable.d.ts +28 -0
- package/dist/actions/movable.js +91 -0
- package/dist/components/AnnotationLine.svelte +155 -0
- package/dist/components/AnnotationLine.svelte.d.ts +28 -0
- package/dist/components/AnnotationPoint.svelte +121 -0
- package/dist/components/AnnotationPoint.svelte.d.ts +32 -0
- package/dist/components/AnnotationRange.svelte +147 -0
- package/dist/components/AnnotationRange.svelte.d.ts +40 -0
- package/dist/components/Arc.svelte +344 -151
- package/dist/components/Arc.svelte.d.ts +138 -0
- package/dist/components/Area.svelte +165 -149
- package/dist/components/Area.svelte.d.ts +45 -0
- package/dist/components/Axis.svelte +287 -174
- package/dist/components/Axis.svelte.d.ts +116 -0
- package/dist/components/Bar.svelte +163 -107
- package/dist/components/Bar.svelte.d.ts +48 -0
- package/dist/components/Bars.svelte +54 -68
- package/dist/components/Bars.svelte.d.ts +27 -0
- package/dist/components/Blur.svelte +31 -7
- package/dist/components/Blur.svelte.d.ts +23 -21
- package/dist/components/Bounds.svelte +49 -19
- package/dist/components/Bounds.svelte.d.ts +24 -50
- package/dist/components/BrushContext.svelte +296 -168
- package/dist/components/BrushContext.svelte.d.ts +97 -65
- package/dist/components/Calendar.svelte +116 -59
- package/dist/components/Calendar.svelte.d.ts +50 -31
- package/dist/components/Chart.svelte +1289 -398
- package/dist/components/Chart.svelte.d.ts +535 -410
- package/dist/components/ChartClipPath.svelte +37 -15
- package/dist/components/ChartClipPath.svelte.d.ts +21 -19
- package/dist/components/Circle.svelte +124 -85
- package/dist/components/Circle.svelte.d.ts +52 -0
- package/dist/components/CircleClipPath.svelte +76 -16
- package/dist/components/CircleClipPath.svelte.d.ts +46 -0
- package/dist/components/ClipPath.svelte +60 -15
- package/dist/components/ClipPath.svelte.d.ts +40 -27
- package/dist/components/ColorRamp.svelte +75 -9
- package/dist/components/ColorRamp.svelte.d.ts +37 -19
- package/dist/components/ComputedStyles.svelte +17 -5
- package/dist/components/ComputedStyles.svelte.d.ts +11 -19
- package/dist/components/Connector.svelte +149 -0
- package/dist/components/Connector.svelte.d.ts +51 -0
- package/dist/components/Dagre.svelte +211 -122
- package/dist/components/Dagre.svelte.d.ts +119 -56
- package/dist/components/ForceSimulation.svelte +215 -90
- package/dist/components/ForceSimulation.svelte.d.ts +82 -35
- package/dist/components/Frame.svelte +33 -13
- package/dist/components/Frame.svelte.d.ts +13 -17
- package/dist/components/GeoCircle.svelte +29 -16
- package/dist/components/GeoCircle.svelte.d.ts +22 -24
- package/dist/components/GeoContext.svelte +113 -72
- package/dist/components/GeoContext.svelte.d.ts +49 -41
- package/dist/components/GeoEdgeFade.svelte +47 -12
- package/dist/components/GeoEdgeFade.svelte.d.ts +17 -19
- package/dist/components/GeoPath.svelte +157 -127
- package/dist/components/GeoPath.svelte.d.ts +48 -36
- package/dist/components/GeoPoint.svelte +52 -20
- package/dist/components/GeoPoint.svelte.d.ts +25 -22
- package/dist/components/GeoSpline.svelte +75 -26
- package/dist/components/GeoSpline.svelte.d.ts +29 -20
- package/dist/components/GeoTile.svelte +100 -49
- package/dist/components/GeoTile.svelte.d.ts +38 -23
- package/dist/components/GeoVisible.svelte +17 -9
- package/dist/components/GeoVisible.svelte.d.ts +10 -18
- package/dist/components/Graticule.svelte +28 -13
- package/dist/components/Graticule.svelte.d.ts +11 -52
- package/dist/components/Grid.svelte +226 -114
- package/dist/components/Grid.svelte.d.ts +70 -0
- package/dist/components/Group.svelte +132 -105
- package/dist/components/Group.svelte.d.ts +53 -0
- package/dist/components/Highlight.svelte +409 -307
- package/dist/components/Highlight.svelte.d.ts +107 -0
- package/dist/components/Hull.svelte +96 -45
- package/dist/components/Hull.svelte.d.ts +40 -30
- package/dist/components/Labels.svelte +125 -46
- package/dist/components/Labels.svelte.d.ts +70 -27
- package/dist/components/Legend.svelte +374 -190
- package/dist/components/Legend.svelte.d.ts +95 -44
- package/dist/components/Line.svelte +163 -125
- package/dist/components/Line.svelte.d.ts +75 -0
- package/dist/components/LinearGradient.svelte +153 -78
- package/dist/components/LinearGradient.svelte.d.ts +66 -31
- package/dist/components/Link.svelte +160 -104
- package/dist/components/Link.svelte.d.ts +54 -0
- package/dist/components/Marker.svelte +100 -39
- package/dist/components/Marker.svelte.d.ts +59 -27
- package/dist/components/MarkerWrapper.svelte +35 -0
- package/dist/components/MarkerWrapper.svelte.d.ts +18 -0
- package/dist/components/MonthPath.svelte +65 -20
- package/dist/components/MonthPath.svelte.d.ts +23 -17
- package/dist/components/MotionPath.svelte +80 -24
- package/dist/components/MotionPath.svelte.d.ts +46 -27
- package/dist/components/Pack.svelte +53 -17
- package/dist/components/Pack.svelte.d.ts +42 -21
- package/dist/components/Partition.svelte +64 -22
- package/dist/components/Partition.svelte.d.ts +49 -26
- package/dist/components/Pattern.svelte +297 -11
- package/dist/components/Pattern.svelte.d.ts +103 -19
- package/dist/components/Pie.svelte +122 -76
- package/dist/components/Pie.svelte.d.ts +65 -51
- package/dist/components/Point.svelte +20 -9
- package/dist/components/Point.svelte.d.ts +16 -20
- package/dist/components/Points.svelte +148 -137
- package/dist/components/Points.svelte.d.ts +45 -34
- package/dist/components/RadialGradient.svelte +143 -70
- package/dist/components/RadialGradient.svelte.d.ts +69 -31
- package/dist/components/Rect.svelte +121 -102
- package/dist/components/Rect.svelte.d.ts +36 -0
- package/dist/components/RectClipPath.svelte +82 -18
- package/dist/components/RectClipPath.svelte.d.ts +55 -0
- package/dist/components/Rule.svelte +105 -62
- package/dist/components/Rule.svelte.d.ts +40 -19
- package/dist/components/Sankey.svelte +132 -55
- package/dist/components/Sankey.svelte.d.ts +61 -31
- package/dist/components/Spline.svelte +281 -218
- package/dist/components/Spline.svelte.d.ts +95 -0
- package/dist/components/Text.svelte +437 -176
- package/dist/components/Text.svelte.d.ts +130 -0
- package/dist/components/Threshold.svelte +48 -16
- package/dist/components/Threshold.svelte.d.ts +29 -31
- package/dist/components/TileImage.svelte +103 -30
- package/dist/components/TileImage.svelte.d.ts +48 -23
- package/dist/components/TransformContext.svelte +365 -171
- package/dist/components/TransformControls.svelte +50 -26
- package/dist/components/TransformControls.svelte.d.ts +27 -19
- package/dist/components/Tree.svelte +74 -33
- package/dist/components/Tree.svelte.d.ts +42 -30
- package/dist/components/Treemap.svelte +119 -42
- package/dist/components/Treemap.svelte.d.ts +75 -27
- package/dist/components/Voronoi.svelte +106 -75
- package/dist/components/Voronoi.svelte.d.ts +40 -41
- package/dist/components/charts/ArcChart.svelte +464 -0
- package/dist/components/charts/ArcChart.svelte.d.ts +90 -0
- package/dist/components/charts/AreaChart.svelte +450 -393
- package/dist/components/charts/AreaChart.svelte.d.ts +61 -0
- package/dist/components/charts/BarChart.svelte +454 -389
- package/dist/components/charts/BarChart.svelte.d.ts +76 -0
- package/dist/components/charts/ChartAnnotations.svelte +37 -0
- package/dist/components/charts/ChartAnnotations.svelte.d.ts +10 -0
- package/dist/components/charts/DefaultTooltip.svelte +60 -0
- package/dist/components/charts/DefaultTooltip.svelte.d.ts +10 -0
- package/dist/components/charts/LineChart.svelte +369 -314
- package/dist/components/charts/LineChart.svelte.d.ts +53 -0
- package/dist/components/charts/PieChart.svelte +458 -316
- package/dist/components/charts/PieChart.svelte.d.ts +137 -353
- package/dist/components/charts/ScatterChart.svelte +334 -296
- package/dist/components/charts/ScatterChart.svelte.d.ts +39 -0
- package/dist/components/charts/index.d.ts +8 -0
- package/dist/components/charts/index.js +7 -0
- package/dist/components/charts/types.d.ts +253 -0
- package/dist/components/charts/utils.svelte.d.ts +30 -0
- package/dist/components/charts/utils.svelte.js +55 -0
- package/dist/components/index.d.ts +76 -4
- package/dist/components/index.js +76 -5
- package/dist/components/layout/Canvas.svelte +321 -155
- package/dist/components/layout/Canvas.svelte.d.ts +104 -55
- package/dist/components/layout/Html.svelte +82 -42
- package/dist/components/layout/Html.svelte.d.ts +39 -28
- package/dist/components/layout/Layer.svelte +39 -0
- package/dist/components/layout/Layer.svelte.d.ts +17 -0
- package/dist/components/layout/Svg.svelte +122 -70
- package/dist/components/layout/Svg.svelte.d.ts +53 -34
- package/dist/components/layout/WebGL.svelte +135 -0
- package/dist/components/layout/WebGL.svelte.d.ts +50 -0
- package/dist/components/tooltip/Tooltip.svelte +246 -78
- package/dist/components/tooltip/Tooltip.svelte.d.ts +149 -31
- package/dist/components/tooltip/TooltipContext.svelte +409 -271
- package/dist/components/tooltip/TooltipContext.svelte.d.ts +86 -55
- package/dist/components/tooltip/TooltipHeader.svelte +100 -11
- package/dist/components/tooltip/TooltipHeader.svelte.d.ts +43 -23
- package/dist/components/tooltip/TooltipItem.svelte +167 -27
- package/dist/components/tooltip/TooltipItem.svelte.d.ts +63 -31
- package/dist/components/tooltip/TooltipList.svelte +22 -3
- package/dist/components/tooltip/TooltipList.svelte.d.ts +6 -17
- package/dist/components/tooltip/TooltipSeparator.svelte +27 -1
- package/dist/components/tooltip/TooltipSeparator.svelte.d.ts +6 -15
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +6 -0
- package/dist/components/tooltip/tooltipMetaContext.d.ts +79 -0
- package/dist/components/tooltip/tooltipMetaContext.js +139 -0
- package/dist/components/types.d.ts +1 -0
- package/dist/components/types.js +1 -0
- package/dist/docs/Blockquote.svelte.d.ts +18 -14
- package/dist/docs/Code.svelte.d.ts +26 -22
- package/dist/docs/ConnectorSweepMenuField.svelte +17 -0
- package/dist/docs/ConnectorSweepMenuField.svelte.d.ts +7 -0
- package/dist/docs/ConnectorTypeMenuField.svelte +17 -0
- package/dist/docs/ConnectorTypeMenuField.svelte.d.ts +7 -0
- package/dist/docs/CurveMenuField.svelte +14 -3
- package/dist/docs/CurveMenuField.svelte.d.ts +9 -18
- package/dist/docs/GeoDebug.svelte +47 -42
- package/dist/docs/GeoDebug.svelte.d.ts +4 -16
- package/dist/docs/Header1.svelte.d.ts +27 -16
- package/dist/docs/Json.svelte.d.ts +20 -16
- package/dist/docs/Layout.svelte.d.ts +18 -13
- package/dist/docs/Link.svelte.d.ts +33 -21
- package/dist/docs/PathDataMenuField.svelte +14 -10
- package/dist/docs/PathDataMenuField.svelte.d.ts +8 -18
- package/dist/docs/Preview.svelte +20 -7
- package/dist/docs/Preview.svelte.d.ts +12 -22
- package/dist/docs/TilesetField.svelte.d.ts +21 -17
- package/dist/docs/TransformDebug.svelte +5 -6
- package/dist/docs/TransformDebug.svelte.d.ts +18 -14
- package/dist/docs/ViewSourceButton.svelte.d.ts +21 -17
- package/dist/types/d3-shape-extentions.d.ts +7 -0
- package/dist/utils/afterTick.d.ts +5 -0
- package/dist/utils/afterTick.js +8 -0
- package/dist/utils/arcText.svelte.d.ts +57 -0
- package/dist/utils/arcText.svelte.js +262 -0
- package/dist/utils/array.d.ts +9 -1
- package/dist/utils/array.js +13 -0
- package/dist/utils/attributes.d.ts +29 -0
- package/dist/utils/attributes.js +40 -0
- package/dist/utils/canvas.js +47 -10
- package/dist/utils/chart.d.ts +78 -0
- package/dist/utils/chart.js +512 -0
- package/dist/utils/color.d.ts +1 -0
- package/dist/utils/color.js +8 -0
- package/dist/utils/common.d.ts +3 -5
- package/dist/utils/common.js +3 -2
- package/dist/utils/connectorUtils.d.ts +21 -0
- package/dist/utils/connectorUtils.js +111 -0
- package/dist/utils/createId.d.ts +7 -0
- package/dist/utils/createId.js +9 -0
- package/dist/utils/debug.d.ts +1 -0
- package/dist/utils/debug.js +84 -0
- package/dist/utils/filterObject.d.ts +9 -0
- package/dist/utils/filterObject.js +12 -0
- package/dist/utils/graph/dagre.d.ts +34 -0
- package/dist/utils/graph/dagre.js +78 -0
- package/dist/utils/graph/dagre.test.d.ts +1 -0
- package/dist/utils/{graph.test.js → graph/dagre.test.js} +19 -33
- package/dist/utils/graph/sankey.d.ts +28 -0
- package/dist/utils/{graph.js → graph/sankey.js} +13 -41
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/key.svelte.d.ts +3 -0
- package/dist/utils/key.svelte.js +11 -0
- package/dist/utils/legendPayload.d.ts +7 -0
- package/dist/utils/legendPayload.js +8 -0
- package/dist/utils/motion.svelte.d.ts +140 -0
- package/dist/utils/motion.svelte.js +180 -0
- package/dist/utils/motion.test.d.ts +1 -0
- package/dist/utils/motion.test.js +213 -0
- package/dist/utils/{rect.d.ts → rect.svelte.d.ts} +7 -4
- package/dist/utils/rect.svelte.js +105 -0
- package/dist/utils/scales.svelte.d.ts +90 -0
- package/dist/utils/{scales.js → scales.svelte.js} +100 -39
- package/dist/utils/stack.d.ts +2 -3
- package/dist/utils/stack.js +1 -1
- package/dist/utils/string.js +87 -0
- package/dist/utils/ticks.d.ts +8 -2
- package/dist/utils/ticks.js +28 -0
- package/dist/utils/ticks.test.d.ts +1 -0
- package/dist/utils/ticks.test.js +67 -0
- package/dist/utils/types.d.ts +81 -0
- package/package.json +25 -24
- package/dist/components/ChartContext.svelte +0 -295
- package/dist/components/ChartContext.svelte.d.ts +0 -139
- package/dist/components/TransformContext.svelte.d.ts +0 -158
- package/dist/stores/motionStore.d.ts +0 -30
- package/dist/stores/motionStore.js +0 -62
- package/dist/utils/graph.d.ts +0 -37
- package/dist/utils/rect.js +0 -107
- package/dist/utils/scales.d.ts +0 -66
- /package/dist/{utils/graph.test.d.ts → components/charts/types.js} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { line as d3Line, curveLinear } from 'd3-shape';
|
|
2
|
+
function isSamePoint(p1, p2) {
|
|
3
|
+
return Math.abs(p1.x - p2.x) < 1e-6 && Math.abs(p1.y - p2.y) < 1e-6;
|
|
4
|
+
}
|
|
5
|
+
function createDirectPath(source, target) {
|
|
6
|
+
if (isSamePoint(source, target))
|
|
7
|
+
return '';
|
|
8
|
+
return `M ${source.x} ${source.y} L ${target.x} ${target.y}`;
|
|
9
|
+
}
|
|
10
|
+
function isNearZero(value) {
|
|
11
|
+
return Math.abs(value) < 1e-6;
|
|
12
|
+
}
|
|
13
|
+
function createSquarePath({ source, target, sweep }) {
|
|
14
|
+
if (sweep === 'horizontal-vertical') {
|
|
15
|
+
return `M ${source.x} ${source.y} L ${target.x} ${source.y} L ${target.x} ${target.y}`;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return `M ${source.x} ${source.y} L ${source.x} ${target.y} L ${target.x} ${target.y}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function createBeveledPath(opts) {
|
|
22
|
+
const { radius, dx, dy, source, target, sweep } = opts;
|
|
23
|
+
const effectiveRadius = Math.max(0, Math.min(radius, Math.abs(dx), Math.abs(dy)));
|
|
24
|
+
if (isNearZero(effectiveRadius)) {
|
|
25
|
+
return createSquarePath(opts);
|
|
26
|
+
}
|
|
27
|
+
const signX = Math.sign(dx);
|
|
28
|
+
const signY = Math.sign(dy);
|
|
29
|
+
if (sweep === 'horizontal-vertical') {
|
|
30
|
+
const pBeforeCorner = { x: target.x - effectiveRadius * signX, y: source.y };
|
|
31
|
+
const pAfterCorner = { x: target.x, y: source.y + effectiveRadius * signY };
|
|
32
|
+
return `M ${source.x} ${source.y} L ${pBeforeCorner.x} ${pBeforeCorner.y} L ${pAfterCorner.x} ${pAfterCorner.y} L ${target.x} ${target.y}`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const pBeforeCorner = { x: source.x, y: target.y - effectiveRadius * signY };
|
|
36
|
+
const pAfterCorner = { x: source.x + effectiveRadius * signX, y: target.y };
|
|
37
|
+
return `M ${source.x} ${source.y} L ${pBeforeCorner.x} ${pBeforeCorner.y} L ${pAfterCorner.x} ${pAfterCorner.y} L ${target.x} ${target.y}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function createRoundedPath(opts) {
|
|
41
|
+
const { radius, dx, dy, source, target, sweep } = opts;
|
|
42
|
+
const effectiveRadius = Math.max(0, Math.min(radius, Math.abs(dx), Math.abs(dy)));
|
|
43
|
+
if (isNearZero(effectiveRadius)) {
|
|
44
|
+
return createSquarePath(opts);
|
|
45
|
+
}
|
|
46
|
+
const signX = Math.sign(dx);
|
|
47
|
+
const signY = Math.sign(dy);
|
|
48
|
+
if (sweep === 'horizontal-vertical') {
|
|
49
|
+
const pBeforeCorner = { x: target.x - effectiveRadius * signX, y: source.y };
|
|
50
|
+
const pAfterCorner = { x: target.x, y: source.y + effectiveRadius * signY };
|
|
51
|
+
const sweepFlag = signX * signY > 0 ? 1 : 0;
|
|
52
|
+
return `M ${source.x} ${source.y} L ${pBeforeCorner.x} ${pBeforeCorner.y} A ${effectiveRadius} ${effectiveRadius} 0 0 ${sweepFlag} ${pAfterCorner.x} ${pAfterCorner.y} L ${target.x} ${target.y}`;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const pBeforeCorner = { x: source.x, y: target.y - effectiveRadius * signY };
|
|
56
|
+
const pAfterCorner = { x: source.x + effectiveRadius * signX, y: target.y };
|
|
57
|
+
const sweepFlag = signX * signY > 0 ? 0 : 1;
|
|
58
|
+
return `M ${source.x} ${source.y} L ${pBeforeCorner.x} ${pBeforeCorner.y} A ${effectiveRadius} ${effectiveRadius} 0 0 ${sweepFlag} ${pAfterCorner.x} ${pAfterCorner.y} L ${target.x} ${target.y}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const pathStrategies = {
|
|
62
|
+
square: createSquarePath,
|
|
63
|
+
beveled: createBeveledPath,
|
|
64
|
+
rounded: createRoundedPath,
|
|
65
|
+
};
|
|
66
|
+
export function getConnectorPresetPath(opts) {
|
|
67
|
+
const { source, target, type } = opts;
|
|
68
|
+
if (isSamePoint(source, target))
|
|
69
|
+
return '';
|
|
70
|
+
const dx = target.x - source.x;
|
|
71
|
+
const dy = target.y - source.y;
|
|
72
|
+
// straight line cases
|
|
73
|
+
if (type === 'straight' || isNearZero(dx) || isNearZero(dy)) {
|
|
74
|
+
return createDirectPath(source, target);
|
|
75
|
+
}
|
|
76
|
+
return (pathStrategies[type] || pathStrategies.square)({ ...opts, dx, dy });
|
|
77
|
+
}
|
|
78
|
+
const FALLBACK_PATH = 'M0,0L0,0';
|
|
79
|
+
export function getConnectorD3Path({ source, target, sweep, curve }) {
|
|
80
|
+
const dx = target.x - source.x;
|
|
81
|
+
const dy = target.y - source.y;
|
|
82
|
+
const line = d3Line().curve(curve);
|
|
83
|
+
let points = [];
|
|
84
|
+
const isAligned = isNearZero(dx) || isNearZero(dy);
|
|
85
|
+
if (sweep === 'none' || isAligned) {
|
|
86
|
+
points = [
|
|
87
|
+
[source.x, source.y],
|
|
88
|
+
[target.x, target.y],
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
else if (sweep === 'horizontal-vertical') {
|
|
92
|
+
points = [
|
|
93
|
+
[source.x, source.y],
|
|
94
|
+
[target.x, source.y],
|
|
95
|
+
[target.x, target.y],
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
else if (sweep === 'vertical-horizontal') {
|
|
99
|
+
points = [
|
|
100
|
+
[source.x, source.y],
|
|
101
|
+
[source.x, target.y],
|
|
102
|
+
[target.x, target.y],
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
if (points.length === 2 && isNearZero(dx) && isNearZero(dx))
|
|
106
|
+
return FALLBACK_PATH;
|
|
107
|
+
const d = line(points);
|
|
108
|
+
if (!d || d.includes('NaN'))
|
|
109
|
+
return FALLBACK_PATH;
|
|
110
|
+
return d;
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printDebug(obj: Record<string, any>): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { rgb } from 'd3-color';
|
|
2
|
+
import { toTitleCase } from './string.js';
|
|
3
|
+
import { findScaleName } from './chart.js';
|
|
4
|
+
const indent = ' ';
|
|
5
|
+
function printObject(obj) {
|
|
6
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
7
|
+
console.log(`${indent}${key}:`, value);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function getRgb(clr) {
|
|
11
|
+
const { r, g, b, opacity: o } = rgb(clr);
|
|
12
|
+
if (![r, g, b].every((c) => c >= 0 && c <= 255)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return { r, g, b, o };
|
|
16
|
+
}
|
|
17
|
+
function printValues(scale, method, extraSpace = '') {
|
|
18
|
+
const values = scale[method]();
|
|
19
|
+
const colorValues = colorizeArray(values);
|
|
20
|
+
if (colorValues) {
|
|
21
|
+
printColorArray(colorValues, method, values);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.log(`${indent}${indent}${toTitleCase(method)}:${extraSpace}`, values);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function printColorArray(colorValues, method, values) {
|
|
28
|
+
console.log(`${indent}${indent}${toTitleCase(method)}: %cArray%c(${values.length}) ` +
|
|
29
|
+
colorValues[0] +
|
|
30
|
+
'%c ]', 'color: #1377e4', 'color: #737373', 'color: #1478e4', ...colorValues[1], 'color: #1478e4');
|
|
31
|
+
}
|
|
32
|
+
function colorizeArray(arr) {
|
|
33
|
+
const colors = [];
|
|
34
|
+
const a = arr.map((d, i) => {
|
|
35
|
+
const rgbo = getRgb(d);
|
|
36
|
+
if (rgbo !== false) {
|
|
37
|
+
colors.push(rgbo);
|
|
38
|
+
// Add a space to the last item
|
|
39
|
+
const space = i === arr.length - 1 ? ' ' : '';
|
|
40
|
+
return `%c ${d}${space}`;
|
|
41
|
+
}
|
|
42
|
+
return d;
|
|
43
|
+
});
|
|
44
|
+
if (colors.length) {
|
|
45
|
+
return [
|
|
46
|
+
`%c[ ${a.join(', ')}`,
|
|
47
|
+
colors.map((d) => `background-color: rgba(${d.r}, ${d.g}, ${d.b}, ${d.o}); color:${contrast(d)};`),
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function printScale(s, scale, acc) {
|
|
53
|
+
const scaleName = findScaleName(scale);
|
|
54
|
+
console.log(`${indent}${s}:`);
|
|
55
|
+
console.log(`${indent}${indent}Accessor: "${acc.toString()}"`);
|
|
56
|
+
console.log(`${indent}${indent}Type: ${scaleName}`);
|
|
57
|
+
printValues(scale, 'domain');
|
|
58
|
+
printValues(scale, 'range', ' ');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Calculate human-perceived lightness from RGB
|
|
62
|
+
* This doesn't take opacity into account
|
|
63
|
+
* https://stackoverflow.com/a/596243
|
|
64
|
+
*/
|
|
65
|
+
function contrast({ r, g, b }) {
|
|
66
|
+
const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
67
|
+
return luminance > 0.6 ? 'black' : 'white';
|
|
68
|
+
}
|
|
69
|
+
export function printDebug(obj) {
|
|
70
|
+
console.log('/********* LayerChart Debug ************/');
|
|
71
|
+
console.log('Bounding box:');
|
|
72
|
+
printObject(obj.boundingBox);
|
|
73
|
+
console.log('Data:');
|
|
74
|
+
console.log(indent, obj.data);
|
|
75
|
+
if (obj.flatData) {
|
|
76
|
+
console.log('flatData:');
|
|
77
|
+
console.log(indent, obj.flatData);
|
|
78
|
+
}
|
|
79
|
+
console.log('Scales:');
|
|
80
|
+
Object.keys(obj.activeGetters).forEach((g) => {
|
|
81
|
+
printScale(g, obj[`${g}Scale`], obj[g]);
|
|
82
|
+
});
|
|
83
|
+
console.log('/************ End LayerChart Debug ***************/\n');
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove undefined fields from an object
|
|
3
|
+
* @param obj The object to filter
|
|
4
|
+
* @param comparisonObk An object that, for any key, if the key is not present on that object, the
|
|
5
|
+
* key will be filtered out. Note, this ignores the value on that object
|
|
6
|
+
*/
|
|
7
|
+
export declare function filterObject(obj: object, comparisonObj?: {}): {
|
|
8
|
+
[k: string]: any;
|
|
9
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove undefined fields from an object
|
|
3
|
+
* @param obj The object to filter
|
|
4
|
+
* @param comparisonObk An object that, for any key, if the key is not present on that object, the
|
|
5
|
+
* key will be filtered out. Note, this ignores the value on that object
|
|
6
|
+
*/
|
|
7
|
+
export function filterObject(obj, comparisonObj = {}) {
|
|
8
|
+
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
|
|
9
|
+
// @ts-expect-error - shh
|
|
10
|
+
return value !== undefined && comparisonObj[key] === undefined;
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import dagre from '@dagrejs/dagre';
|
|
2
|
+
import { type DagreProps } from '../../components/Dagre.svelte';
|
|
3
|
+
/**
|
|
4
|
+
* Build `dagre.graphlib.Graph` instance from DagreGraphData (`{ nodes, edges }`)
|
|
5
|
+
*/
|
|
6
|
+
export declare function dagreGraph(data: DagreProps['data'], { nodes, nodeId, edges, directed, multigraph, compound, ranker, direction, align, rankSeparation, nodeSeparation, edgeSeparation, nodeWidth, nodeHeight, edgeLabelWidth, edgeLabelHeight, edgeLabelPosition, edgeLabelOffset, filterNodes, }?: {
|
|
7
|
+
nodes?: DagreProps['nodes'];
|
|
8
|
+
nodeId?: DagreProps['nodeId'];
|
|
9
|
+
edges?: DagreProps['edges'];
|
|
10
|
+
directed?: DagreProps['directed'];
|
|
11
|
+
multigraph?: DagreProps['multigraph'];
|
|
12
|
+
compound?: DagreProps['compound'];
|
|
13
|
+
ranker?: DagreProps['ranker'];
|
|
14
|
+
direction?: DagreProps['direction'];
|
|
15
|
+
align?: DagreProps['align'];
|
|
16
|
+
rankSeparation?: DagreProps['rankSeparation'];
|
|
17
|
+
nodeSeparation?: DagreProps['nodeSeparation'];
|
|
18
|
+
edgeSeparation?: DagreProps['edgeSeparation'];
|
|
19
|
+
nodeWidth?: DagreProps['nodeWidth'];
|
|
20
|
+
nodeHeight?: DagreProps['nodeHeight'];
|
|
21
|
+
edgeLabelWidth?: DagreProps['edgeLabelWidth'];
|
|
22
|
+
edgeLabelHeight?: DagreProps['edgeLabelHeight'];
|
|
23
|
+
edgeLabelPosition?: DagreProps['edgeLabelPosition'];
|
|
24
|
+
edgeLabelOffset?: DagreProps['edgeLabelOffset'];
|
|
25
|
+
filterNodes?: DagreProps['filterNodes'];
|
|
26
|
+
}): dagre.graphlib.Graph<{}>;
|
|
27
|
+
/**
|
|
28
|
+
* Get all upstream predecessors for dagre nodeId
|
|
29
|
+
*/
|
|
30
|
+
export declare function dagreAncestors(graph: dagre.graphlib.Graph, nodeId: string, maxDepth?: number, currentDepth?: number): dagre.Node[];
|
|
31
|
+
/**
|
|
32
|
+
* Get all downstream descendants for dagre nodeId
|
|
33
|
+
*/
|
|
34
|
+
export declare function dagreDescendants(graph: dagre.graphlib.Graph, nodeId: string, maxDepth?: number, currentDepth?: number): dagre.Node[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import dagre from '@dagrejs/dagre';
|
|
2
|
+
import { Align, EdgeLabelPosition, RankDir } from '../../components/Dagre.svelte';
|
|
3
|
+
/**
|
|
4
|
+
* Build `dagre.graphlib.Graph` instance from DagreGraphData (`{ nodes, edges }`)
|
|
5
|
+
*/
|
|
6
|
+
export function dagreGraph(data, { nodes = (d) => d.nodes, nodeId = (d) => d.id, edges = (d) => d.edges, directed = true, multigraph = false, compound = false, ranker = 'network-simplex', direction = 'top-bottom', align, rankSeparation = 50, nodeSeparation = 50, edgeSeparation = 10, nodeWidth = 100, nodeHeight = 50, edgeLabelWidth = 100, edgeLabelHeight = 20, edgeLabelPosition = 'center', edgeLabelOffset = 10, filterNodes = () => true, } = {}) {
|
|
7
|
+
let g = new dagre.graphlib.Graph({ directed, multigraph, compound });
|
|
8
|
+
g.setGraph({
|
|
9
|
+
ranker: ranker,
|
|
10
|
+
rankdir: RankDir[direction],
|
|
11
|
+
align: align ? Align[align] : undefined,
|
|
12
|
+
ranksep: rankSeparation,
|
|
13
|
+
nodesep: nodeSeparation,
|
|
14
|
+
edgesep: edgeSeparation,
|
|
15
|
+
});
|
|
16
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
17
|
+
const dataNodes = nodes(data);
|
|
18
|
+
for (const n of dataNodes) {
|
|
19
|
+
const id = nodeId(n);
|
|
20
|
+
g.setNode(nodeId(n), {
|
|
21
|
+
id,
|
|
22
|
+
label: typeof n.label === 'string' ? n.label : id,
|
|
23
|
+
width: nodeWidth,
|
|
24
|
+
height: nodeHeight,
|
|
25
|
+
...(typeof n.label === 'object' ? n.label : null),
|
|
26
|
+
});
|
|
27
|
+
if (n.parent) {
|
|
28
|
+
g.setParent(id, n.parent);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const nodeEdges = edges(data);
|
|
32
|
+
for (const e of nodeEdges) {
|
|
33
|
+
const { source, target, label, ...rest } = e;
|
|
34
|
+
g.setEdge(e.source, e.target, label
|
|
35
|
+
? {
|
|
36
|
+
label: label,
|
|
37
|
+
labelpos: EdgeLabelPosition[edgeLabelPosition],
|
|
38
|
+
labeloffset: edgeLabelOffset,
|
|
39
|
+
width: edgeLabelWidth,
|
|
40
|
+
height: edgeLabelHeight,
|
|
41
|
+
...rest,
|
|
42
|
+
}
|
|
43
|
+
: {});
|
|
44
|
+
}
|
|
45
|
+
if (filterNodes) {
|
|
46
|
+
g = g.filterNodes((nodeId) => filterNodes(nodeId, g));
|
|
47
|
+
}
|
|
48
|
+
dagre.layout(g);
|
|
49
|
+
return g;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all upstream predecessors for dagre nodeId
|
|
53
|
+
*/
|
|
54
|
+
export function dagreAncestors(graph, nodeId, maxDepth = Infinity, currentDepth = 0) {
|
|
55
|
+
if (currentDepth === maxDepth) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const predecessors = graph.predecessors(nodeId) ?? [];
|
|
59
|
+
return [
|
|
60
|
+
...predecessors,
|
|
61
|
+
// @ts-expect-error: Types from dagre appear incorrect
|
|
62
|
+
...predecessors.flatMap((pId) => dagreAncestors(graph, pId, maxDepth, currentDepth + 1)),
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get all downstream descendants for dagre nodeId
|
|
67
|
+
*/
|
|
68
|
+
export function dagreDescendants(graph, nodeId, maxDepth = Infinity, currentDepth = 0) {
|
|
69
|
+
if (currentDepth === maxDepth) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const predecessors = graph.successors(nodeId) ?? [];
|
|
73
|
+
return [
|
|
74
|
+
...predecessors,
|
|
75
|
+
// @ts-expect-error: Types from dagre appear incorrect
|
|
76
|
+
...predecessors.flatMap((pId) => dagreDescendants(graph, pId, maxDepth, currentDepth + 1)),
|
|
77
|
+
];
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import
|
|
3
|
-
import { ancestors, descendants } from './graph.js';
|
|
2
|
+
import { dagreGraph, dagreAncestors, dagreDescendants } from './dagre.js';
|
|
4
3
|
const exampleGraph = {
|
|
5
4
|
nodes: [
|
|
6
5
|
{ id: 'A' },
|
|
@@ -25,60 +24,47 @@ const exampleGraph = {
|
|
|
25
24
|
{ source: 'H', target: 'I' },
|
|
26
25
|
],
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
const g = new dagre.graphlib.Graph();
|
|
30
|
-
g.setGraph({});
|
|
31
|
-
data.nodes.forEach((n) => {
|
|
32
|
-
g.setNode(n.id, {
|
|
33
|
-
label: n.id,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
data.edges.forEach((e) => {
|
|
37
|
-
g.setEdge(e.source, e.target);
|
|
38
|
-
});
|
|
39
|
-
return g;
|
|
40
|
-
}
|
|
41
|
-
describe('accessors', () => {
|
|
27
|
+
describe('dagreAncestors', () => {
|
|
42
28
|
it('start of graph ', () => {
|
|
43
|
-
const graph =
|
|
44
|
-
const actual =
|
|
29
|
+
const graph = dagreGraph(exampleGraph);
|
|
30
|
+
const actual = dagreAncestors(graph, 'L');
|
|
45
31
|
expect(actual).length(0);
|
|
46
32
|
});
|
|
47
33
|
it('middle of graph ', () => {
|
|
48
|
-
const graph =
|
|
49
|
-
const actual =
|
|
34
|
+
const graph = dagreGraph(exampleGraph);
|
|
35
|
+
const actual = dagreAncestors(graph, 'E');
|
|
50
36
|
expect(actual).to.have.members(['A', 'B', 'C', 'D']);
|
|
51
37
|
});
|
|
52
38
|
it('end of graph ', () => {
|
|
53
|
-
const graph =
|
|
54
|
-
const actual =
|
|
39
|
+
const graph = dagreGraph(exampleGraph);
|
|
40
|
+
const actual = dagreAncestors(graph, 'I');
|
|
55
41
|
expect(actual).to.have.members(['A', 'B', 'C', 'D', 'E', 'G', 'H']);
|
|
56
42
|
});
|
|
57
43
|
it('max depth', () => {
|
|
58
|
-
const graph =
|
|
59
|
-
const actual =
|
|
44
|
+
const graph = dagreGraph(exampleGraph);
|
|
45
|
+
const actual = dagreAncestors(graph, 'H', 2);
|
|
60
46
|
expect(actual).to.have.members(['B', 'D', 'E', 'G']);
|
|
61
47
|
});
|
|
62
48
|
});
|
|
63
|
-
describe('
|
|
49
|
+
describe('dagreDescendants', () => {
|
|
64
50
|
it('start of graph ', () => {
|
|
65
|
-
const graph =
|
|
66
|
-
const actual =
|
|
51
|
+
const graph = dagreGraph(exampleGraph);
|
|
52
|
+
const actual = dagreDescendants(graph, 'A');
|
|
67
53
|
expect(actual).to.have.members(['B', 'E', 'F', 'H', 'I']);
|
|
68
54
|
});
|
|
69
55
|
it('middle of graph ', () => {
|
|
70
|
-
const graph =
|
|
71
|
-
const actual =
|
|
56
|
+
const graph = dagreGraph(exampleGraph);
|
|
57
|
+
const actual = dagreDescendants(graph, 'E');
|
|
72
58
|
expect(actual).to.have.members(['H', 'I']);
|
|
73
59
|
});
|
|
74
60
|
it('end of graph ', () => {
|
|
75
|
-
const graph =
|
|
76
|
-
const actual =
|
|
61
|
+
const graph = dagreGraph(exampleGraph);
|
|
62
|
+
const actual = dagreDescendants(graph, 'I');
|
|
77
63
|
expect(actual).length(0);
|
|
78
64
|
});
|
|
79
65
|
it('max depth', () => {
|
|
80
|
-
const graph =
|
|
81
|
-
const actual =
|
|
66
|
+
const graph = dagreGraph(exampleGraph);
|
|
67
|
+
const actual = dagreDescendants(graph, 'B', 2);
|
|
82
68
|
expect(actual).to.have.members(['E', 'F', 'H']);
|
|
83
69
|
});
|
|
84
70
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SankeyExtraProperties, SankeyGraph, SankeyLink, SankeyNodeMinimal } from 'd3-sankey';
|
|
2
|
+
import type { hierarchy as d3Hierarchy } from 'd3-hierarchy';
|
|
3
|
+
/**
|
|
4
|
+
* Convert CSV rows in format: 'source,target,value' to SankeyGraph
|
|
5
|
+
*/
|
|
6
|
+
export declare function sankeyGraphFromCsv(csv: string): SankeyGraph<any, any>;
|
|
7
|
+
/**
|
|
8
|
+
* Convert d3-hierarchy to graph (nodes/links)
|
|
9
|
+
*/
|
|
10
|
+
export declare function sankeyGraphFromHierarchy(hierarchy: ReturnType<typeof d3Hierarchy>): {
|
|
11
|
+
nodes: import("d3-hierarchy").HierarchyNode<unknown>[];
|
|
12
|
+
links: {
|
|
13
|
+
value: number | undefined;
|
|
14
|
+
source: import("d3-hierarchy").HierarchyNode<unknown>;
|
|
15
|
+
target: import("d3-hierarchy").HierarchyNode<unknown>;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Create graph from node (and target node/links downward)
|
|
20
|
+
*/
|
|
21
|
+
export declare function sankeyGraphFromNode(node: SankeyNodeMinimal<any, any>): {
|
|
22
|
+
nodes: any[];
|
|
23
|
+
links: any[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Get distinct nodes from link.source and link.target
|
|
27
|
+
*/
|
|
28
|
+
export declare function sankeyNodesFromLinks<N extends SankeyExtraProperties, L extends SankeyExtraProperties>(links: Array<SankeyLink<N, L>>): any[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { csvParseRows } from 'd3-dsv';
|
|
2
|
-
import dagre from '@dagrejs/dagre';
|
|
3
2
|
/**
|
|
4
3
|
* Convert CSV rows in format: 'source,target,value' to SankeyGraph
|
|
5
4
|
*/
|
|
6
|
-
export function
|
|
5
|
+
export function sankeyGraphFromCsv(csv) {
|
|
7
6
|
const links = csvParseRows(csv, ([source, target, value /*, linkColor = color*/]) => source && target
|
|
8
7
|
? {
|
|
9
8
|
source,
|
|
@@ -13,12 +12,12 @@ export function graphFromCsv(csv) {
|
|
|
13
12
|
// color: linkColor,
|
|
14
13
|
}
|
|
15
14
|
: null);
|
|
16
|
-
return { nodes:
|
|
15
|
+
return { nodes: sankeyNodesFromLinks(links), links };
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
18
|
* Convert d3-hierarchy to graph (nodes/links)
|
|
20
19
|
*/
|
|
21
|
-
export function
|
|
20
|
+
export function sankeyGraphFromHierarchy(hierarchy) {
|
|
22
21
|
return {
|
|
23
22
|
nodes: hierarchy.descendants(),
|
|
24
23
|
links: hierarchy.links().map((link) => ({ ...link, value: link.target.value })),
|
|
@@ -27,33 +26,34 @@ export function graphFromHierarchy(hierarchy) {
|
|
|
27
26
|
/**
|
|
28
27
|
* Create graph from node (and target node/links downward)
|
|
29
28
|
*/
|
|
30
|
-
export function
|
|
29
|
+
export function sankeyGraphFromNode(node) {
|
|
31
30
|
const nodes = [node];
|
|
32
31
|
const links = [];
|
|
33
|
-
node.sourceLinks
|
|
32
|
+
for (const link of node.sourceLinks ?? []) {
|
|
34
33
|
nodes.push(link.target);
|
|
35
34
|
links.push(link);
|
|
36
35
|
if (link.target.sourceLinks.length) {
|
|
37
|
-
const targetData =
|
|
36
|
+
const targetData = sankeyGraphFromNode(link.target);
|
|
38
37
|
// Only add new nodes
|
|
39
|
-
targetData.nodes
|
|
38
|
+
for (const node of targetData.nodes) {
|
|
40
39
|
if (!nodes.includes(node)) {
|
|
41
40
|
nodes.push(node);
|
|
42
41
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
42
|
+
}
|
|
43
|
+
// Only add new links
|
|
44
|
+
for (const link of targetData.links) {
|
|
45
45
|
if (!links.includes(link)) {
|
|
46
46
|
links.push(link);
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
return { nodes, links };
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Get distinct nodes from link.source and link.target
|
|
55
55
|
*/
|
|
56
|
-
export function
|
|
56
|
+
export function sankeyNodesFromLinks(links) {
|
|
57
57
|
const nodesByName = new Map();
|
|
58
58
|
for (const link of links) {
|
|
59
59
|
if (!nodesByName.has(link.source)) {
|
|
@@ -65,31 +65,3 @@ export function nodesFromLinks(links) {
|
|
|
65
65
|
}
|
|
66
66
|
return Array.from(nodesByName.values());
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Get all upstream predecessors for dagre nodeId
|
|
70
|
-
*/
|
|
71
|
-
export function ancestors(graph, nodeId, maxDepth = Infinity, currentDepth = 0) {
|
|
72
|
-
if (currentDepth === maxDepth) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
const predecessors = graph.predecessors(nodeId) ?? [];
|
|
76
|
-
return [
|
|
77
|
-
...predecessors,
|
|
78
|
-
// @ts-expect-error: Types from dagre appear incorrect
|
|
79
|
-
...predecessors.flatMap((pId) => ancestors(graph, pId, maxDepth, currentDepth + 1)),
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get all downstream descendants for dagre nodeId
|
|
84
|
-
*/
|
|
85
|
-
export function descendants(graph, nodeId, maxDepth = Infinity, currentDepth = 0) {
|
|
86
|
-
if (currentDepth === maxDepth) {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
const predecessors = graph.successors(nodeId) ?? [];
|
|
90
|
-
return [
|
|
91
|
-
...predecessors,
|
|
92
|
-
// @ts-expect-error: Types from dagre appear incorrect
|
|
93
|
-
...predecessors.flatMap((pId) => descendants(graph, pId, maxDepth, currentDepth + 1)),
|
|
94
|
-
];
|
|
95
|
-
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './canvas.js';
|
|
2
2
|
export * from './common.js';
|
|
3
3
|
export * from './geo.js';
|
|
4
|
-
export * from './graph.js';
|
|
5
4
|
export * from './hierarchy.js';
|
|
6
5
|
export * from './math.js';
|
|
7
6
|
export * from './path.js';
|
|
@@ -9,3 +8,6 @@ export * from './pivot.js';
|
|
|
9
8
|
export * from './stack.js';
|
|
10
9
|
export * from './ticks.js';
|
|
11
10
|
export * from './threshold.js';
|
|
11
|
+
export * from './types.js';
|
|
12
|
+
export * from './graph/dagre.js';
|
|
13
|
+
export * from './graph/sankey.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './canvas.js';
|
|
2
2
|
export * from './common.js';
|
|
3
3
|
export * from './geo.js';
|
|
4
|
-
export * from './graph.js';
|
|
5
4
|
export * from './hierarchy.js';
|
|
6
5
|
export * from './math.js';
|
|
7
6
|
export * from './path.js';
|
|
@@ -9,3 +8,6 @@ export * from './pivot.js';
|
|
|
9
8
|
export * from './stack.js';
|
|
10
9
|
export * from './ticks.js';
|
|
11
10
|
export * from './threshold.js';
|
|
11
|
+
export * from './types.js';
|
|
12
|
+
export * from './graph/dagre.js';
|
|
13
|
+
export * from './graph/sankey.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { objectId } from '@layerstack/utils/object';
|
|
2
|
+
// TODO: investigate if this is necessary with Svelte 5
|
|
3
|
+
export function createKey(getValue) {
|
|
4
|
+
const value = $derived(getValue());
|
|
5
|
+
const key = $derived(value && typeof value === 'object' ? objectId(value) : value);
|
|
6
|
+
return {
|
|
7
|
+
get current() {
|
|
8
|
+
return key;
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from 'runed';
|
|
2
|
+
const _LegendPayloadContext = new Context('LegendContext');
|
|
3
|
+
export function setLegendPayloadContext(payload) {
|
|
4
|
+
return _LegendPayloadContext.set(payload);
|
|
5
|
+
}
|
|
6
|
+
export function getLegendPayloadContext() {
|
|
7
|
+
return _LegendPayloadContext.getOr([]);
|
|
8
|
+
}
|