@mstone6969/graph 0.1.0 → 0.2.0
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/README.md +111 -14
- package/dist/ExcelWriter-3ZSYUH4T.cjs +154 -0
- package/dist/GraphType.js +24 -38
- package/dist/PdfWriter-6HJFYMCO.cjs +205 -0
- package/dist/catalog-YWX6FHRM.cjs +8 -0
- package/dist/catalog.js +5 -1
- package/dist/charts/bars/index.js +2 -12
- package/dist/charts/comparison/EffectForestPlot.js +1 -1
- package/dist/charts/comparison/index.js +1 -8
- package/dist/charts/demography/Nomogram.js +3 -3
- package/dist/charts/density/HexbinChart.js +6 -4
- package/dist/charts/diagrams/ArchitectureCanvas.js +68 -0
- package/dist/charts/diagrams/ArchitectureDiagram.js +331 -0
- package/dist/charts/diagrams/ArchitectureLayout.js +106 -0
- package/dist/charts/diagrams/ArchitectureLinkLabels.js +78 -0
- package/dist/charts/diagrams/ArchitectureModel.js +108 -0
- package/dist/charts/diagrams/ArchitectureRouter.js +348 -0
- package/dist/charts/diagrams/ArchitectureSamples.js +312 -0
- package/dist/charts/diagrams/ArchitectureShapes.js +130 -0
- package/dist/charts/diagrams/ArchitectureText.js +25 -0
- package/dist/charts/diagrams/DiagramText.js +38 -0
- package/dist/charts/diagrams/EntityRelationshipDiagram.js +465 -0
- package/dist/charts/diagrams/ErCrowsFoot.js +33 -0
- package/dist/charts/diagrams/ErSamples.js +205 -0
- package/dist/charts/diagrams/ErSchema.js +122 -0
- package/dist/charts/diagrams/LogicCircuit.js +154 -0
- package/dist/charts/diagrams/LogicCircuitLayout.js +600 -0
- package/dist/charts/diagrams/LogicCircuitSamples.js +66 -0
- package/dist/charts/diagrams/LogicGateDiagram.js +216 -0
- package/dist/charts/diagrams/LogicGateSymbol.js +113 -0
- package/dist/charts/diagrams/NetworkTopologyDiagram.js +247 -0
- package/dist/charts/diagrams/SequenceDiagram.js +351 -0
- package/dist/charts/diagrams/SequenceLayout.js +422 -0
- package/dist/charts/diagrams/SequenceModel.js +221 -0
- package/dist/charts/diagrams/TopologyLayout.js +143 -0
- package/dist/charts/diagrams/architectureEnums.js +50 -0
- package/dist/charts/diagrams/index.js +26 -0
- package/dist/charts/diagrams/logicEnums.js +42 -0
- package/dist/charts/diagrams/sequenceEnums.js +40 -0
- package/dist/charts/distribution/HistogramChart.js +25 -3
- package/dist/charts/distribution/index.js +1 -3
- package/dist/charts/earthscience/HovmollerDiagram.js +477 -0
- package/dist/charts/earthscience/HovmollerEnums.js +42 -0
- package/dist/charts/earthscience/HovmollerField.js +180 -0
- package/dist/charts/earthscience/HovmollerSample.js +40 -0
- package/dist/charts/earthscience/HovmollerSpeed.js +71 -0
- package/dist/charts/earthscience/index.js +10 -2
- package/dist/charts/engineering/ConstellationDiagram.js +26 -6
- package/dist/charts/engineering/EyeDiagram.js +2 -1
- package/dist/charts/engineering/PoleZeroPlot.js +32 -8
- package/dist/charts/financial/RelativeStrengthRotation.js +434 -0
- package/dist/charts/financial/RelativeStrengthRotationMath.js +71 -0
- package/dist/charts/financial/RelativeStrengthRotationSamples.js +27 -0
- package/dist/charts/financial/index.js +5 -3
- package/dist/charts/flow/index.js +1 -5
- package/dist/charts/frameworks/AnsoffMatrix.js +523 -0
- package/dist/charts/frameworks/FrameworkText.js +98 -0
- package/dist/charts/frameworks/NpsGauge.js +279 -0
- package/dist/charts/frameworks/NpsSurvey.js +58 -0
- package/dist/charts/frameworks/PerceptualMap.js +419 -0
- package/dist/charts/frameworks/PerceptualProjection.js +142 -0
- package/dist/charts/frameworks/PositioningSamples.js +191 -0
- package/dist/charts/frameworks/RaciMatrix.js +458 -0
- package/dist/charts/frameworks/RaciPlan.js +81 -0
- package/dist/charts/frameworks/RaciSamples.js +76 -0
- package/dist/charts/frameworks/SwotMatrix.js +358 -0
- package/dist/charts/frameworks/SwotSamples.js +85 -0
- package/dist/charts/frameworks/VanWestendorpChart.js +187 -0
- package/dist/charts/frameworks/VanWestendorpSurvey.js +197 -0
- package/dist/charts/frameworks/index.js +26 -0
- package/dist/charts/frameworks/raciEnums.js +30 -0
- package/dist/charts/frameworks/swotEnums.js +34 -0
- package/dist/charts/genomics/CircosPlot.js +1 -1
- package/dist/charts/geoflows/GeoFlowChart.js +2 -2
- package/dist/charts/geoflows/GeoFlowSample.js +2 -1
- package/dist/charts/geomaps/FloorPlanMap.js +324 -0
- package/dist/charts/geomaps/FloorPlanModel.js +179 -0
- package/dist/charts/geomaps/FloorPlanSamples.js +416 -0
- package/dist/charts/geomaps/GeoLand.js +2 -2
- package/dist/charts/geomaps/GeoSamples.js +2 -1
- package/dist/charts/geomaps/GraticuleMap.js +2 -2
- package/dist/charts/geomaps/RoomLabelFit.js +200 -0
- package/dist/charts/geomaps/TissotMap.js +2 -2
- package/dist/charts/geomaps/index.js +8 -4
- package/dist/charts/hierarchy/SunburstChart.js +17 -10
- package/dist/charts/hierarchy/index.js +2 -11
- package/dist/charts/indicators/BulletChart.js +8 -2
- package/dist/charts/indicators/SpeedometerChart.js +1 -1
- package/dist/charts/indicators/ThermometerChart.js +1 -1
- package/dist/charts/lifescience/LoessFit.js +113 -0
- package/dist/charts/lifescience/MaPlot.js +337 -0
- package/dist/charts/lifescience/MaPlotSamples.js +35 -0
- package/dist/charts/lifescience/OncoGlyph.js +137 -0
- package/dist/charts/lifescience/OncoPrint.js +373 -0
- package/dist/charts/lifescience/OncoPrintMatrix.js +107 -0
- package/dist/charts/lifescience/OncoPrintSamples.js +142 -0
- package/dist/charts/lifescience/PedigreeChart.js +306 -0
- package/dist/charts/lifescience/PedigreeLayout.js +261 -0
- package/dist/charts/lifescience/PedigreeRows.js +70 -0
- package/dist/charts/lifescience/PedigreeSamples.js +161 -0
- package/dist/charts/lifescience/PedigreeSymbol.js +47 -0
- package/dist/charts/lifescience/RamachandranPlot.js +364 -0
- package/dist/charts/lifescience/RamachandranRegions.js +2712 -0
- package/dist/charts/lifescience/RamachandranSamples.js +235 -0
- package/dist/charts/lifescience/index.js +25 -0
- package/dist/charts/lifescience/pedigreeEnums.js +21 -0
- package/dist/charts/lifescience/ramachandranEnums.js +34 -0
- package/dist/charts/linesareas/DualAxisChart.js +1 -1
- package/dist/charts/linesareas/LineEnums.js +1 -15
- package/dist/charts/linesareas/MultiLineChart.js +1 -1
- package/dist/charts/linesareas/TrendChart.js +15 -5
- package/dist/charts/linesareas/index.js +2 -6
- package/dist/charts/massive/MassiveChart.js +3 -2
- package/dist/charts/mathematical/FourierSeriesChart.js +7 -1
- package/dist/charts/mathematical/index.js +2 -6
- package/dist/charts/matrix/GridPlot.js +27 -2
- package/dist/charts/matrix/TilegramChart.js +2 -2
- package/dist/charts/mlcharts/AttentionGrid.js +79 -0
- package/dist/charts/mlcharts/AttentionHeatmap.js +329 -0
- package/dist/charts/mlcharts/AttentionModel.js +132 -0
- package/dist/charts/mlcharts/AttentionSamples.js +82 -0
- package/dist/charts/mlcharts/CellNumber.js +8 -0
- package/dist/charts/mlcharts/CurveDiagnosticSamples.js +95 -0
- package/dist/charts/mlcharts/CurvePickMark.js +31 -0
- package/dist/charts/mlcharts/DecisionBoundaryChart.js +316 -0
- package/dist/charts/mlcharts/DecisionSamples.js +60 -0
- package/dist/charts/mlcharts/DecisionSurface.js +130 -0
- package/dist/charts/mlcharts/DistinctTicks.js +13 -0
- package/dist/charts/mlcharts/ElbowMath.js +153 -0
- package/dist/charts/mlcharts/ElbowPlot.js +273 -0
- package/dist/charts/mlcharts/ExplainabilitySamples.js +70 -0
- package/dist/charts/mlcharts/FeatureImportanceChart.js +150 -0
- package/dist/charts/mlcharts/ImportanceRanking.js +98 -0
- package/dist/charts/mlcharts/LearningCurveChart.js +276 -0
- package/dist/charts/mlcharts/LearningCurveMath.js +92 -0
- package/dist/charts/mlcharts/PartialDependence.js +92 -0
- package/dist/charts/mlcharts/PartialDependencePlot.js +225 -0
- package/dist/charts/mlcharts/WideLabel.js +28 -0
- package/dist/charts/mlcharts/curveDiagnosticEnums.js +37 -0
- package/dist/charts/mlcharts/index.js +32 -0
- package/dist/charts/proportion/index.js +5 -9
- package/dist/charts/scatter/CategoryScatterBase.js +1 -4
- package/dist/charts/scatter/ConnectedScatter.js +7 -4
- package/dist/charts/scatter/MarginalScatter.js +13 -8
- package/dist/charts/scatter/index.js +4 -17
- package/dist/charts/scientific/SpectrogramChart.js +9 -3
- package/dist/charts/scientific/index.js +2 -2
- package/dist/charts/signals/index.js +3 -13
- package/dist/charts/statistics/LorenzCurve.js +7 -4
- package/dist/charts/threebars/Candlestick3DChart.js +18 -2
- package/dist/charts/threeglobe/GlobeChart.js +2 -2
- package/dist/charts/threeglobe/GlobeSamples.js +2 -1
- package/dist/charts/threeglobe/RingGlobe.js +1 -1
- package/dist/charts/threenetwork/ConeTreeChart.js +2 -1
- package/dist/charts/threenetwork/Gantt3DChart.js +3 -2
- package/dist/charts/threesurfaces/Ridgeline3DChart.js +22 -4
- package/dist/charts/threevolume/LorenzAttractor.js +19 -0
- package/dist/charts/threevolume/VolumeRaycastChart.js +4 -3
- package/dist/charts/threevolume/volumeEnums.js +1 -0
- package/dist/charts/timeline/index.js +2 -10
- package/dist/chunk-753UBLV2.cjs +33 -0
- package/dist/chunk-VX54A7KA.cjs +17 -0
- package/dist/{chunk-W5GAAAZY.cjs → chunk-WAODDPYX.cjs} +24874 -17620
- package/dist/chunk-Z3JPIJSC.cjs +338 -0
- package/dist/core/CartesianChart.js +87 -11
- package/dist/core/Chart.js +63 -15
- package/dist/core/Chart2D.js +54 -17
- package/dist/core/Chart3D.js +56 -20
- package/dist/core/ChartExportError.js +2 -0
- package/dist/core/ChartExporter.js +50 -8
- package/dist/core/ColumnCheck.js +53 -0
- package/dist/core/Context2D.js +29 -15
- package/dist/core/Context3D.js +7 -2
- package/dist/core/ExcelWriter.js +152 -0
- package/dist/core/ExportText.js +28 -0
- package/dist/core/MarkOrigin.js +88 -0
- package/dist/core/MarkStyle.js +294 -0
- package/dist/core/Palette.js +27 -7
- package/dist/core/PdfPage.js +13 -0
- package/dist/core/PdfWriter.js +245 -0
- package/dist/core/Scales.js +52 -2
- package/dist/core/SceneOverlay.js +4 -4
- package/dist/core/TextFit.js +37 -0
- package/dist/core/Theme.js +28 -1
- package/dist/core/enums.js +33 -1
- package/dist/core/pathMorph.js +15 -0
- package/dist/data/SampleData.js +1 -17
- package/dist/data/WorldSample.js +23 -0
- package/dist/index.cjs +810 -691
- package/dist/index.d.cts +8390 -2925
- package/dist/index.d.ts +8392 -2927
- package/dist/index.js +106 -56
- package/dist/react/ChartView.js +18 -8
- package/dist/react/GraphHandle.js +2 -0
- package/dist/react/components.js +74 -116
- package/package.json +13 -3
- package/dist/catalog-4UP2YFNR.cjs +0 -7
- package/dist/charts/bars/BulletBar.js +0 -184
- package/dist/charts/bars/ErrorBarColumn.js +0 -147
- package/dist/charts/bars/HistogramBar.js +0 -217
- package/dist/charts/bars/MarimekkoBar.js +0 -191
- package/dist/charts/bars/ParetoBar.js +0 -143
- package/dist/charts/comparison/PanelChart.js +0 -70
- package/dist/charts/comparison/SmallMultipleBars.js +0 -134
- package/dist/charts/comparison/SpanChart.js +0 -118
- package/dist/charts/comparison/TrellisChart.js +0 -158
- package/dist/charts/distribution/RidgeSlabs3DChart.js +0 -169
- package/dist/charts/financial/Candlestick3D.js +0 -157
- package/dist/charts/flow/BumpFlow.js +0 -212
- package/dist/charts/flow/StreamFlow.js +0 -174
- package/dist/charts/geomaps/ThiessenMap.js +0 -106
- package/dist/charts/hierarchy/ConeTree3D.js +0 -135
- package/dist/charts/hierarchy/Hierarchy3DChart.js +0 -27
- package/dist/charts/hierarchy/SpherePack3D.js +0 -81
- package/dist/charts/hierarchy/SunburstTower3D.js +0 -93
- package/dist/charts/hierarchy/TreemapSkyline3D.js +0 -98
- package/dist/charts/linesareas/ConnectedScatterTime.js +0 -206
- package/dist/charts/linesareas/SmallMultipleLines.js +0 -153
- package/dist/charts/mathematical/ParametricSurface3D.js +0 -234
- package/dist/charts/mathematical/StrangeAttractor3D.js +0 -251
- package/dist/charts/proportion/ConeFunnel.js +0 -126
- package/dist/charts/proportion/ExtrudedPieChart.js +0 -123
- package/dist/charts/scatter/BeeswarmScatter.js +0 -151
- package/dist/charts/scatter/BinnedScatterBase.js +0 -51
- package/dist/charts/scatter/ContourScatter.js +0 -116
- package/dist/charts/scatter/GridBinScatter.js +0 -98
- package/dist/charts/scatter/HexbinScatter.js +0 -74
- package/dist/charts/scatter/StripScatter.js +0 -107
- package/dist/charts/scatter/SunflowerScatter.js +0 -109
- package/dist/charts/signals/ConstellationChart.js +0 -153
- package/dist/charts/signals/CorrelogramChart.js +0 -171
- package/dist/charts/signals/EyeDiagramChart.js +0 -155
- package/dist/charts/signals/PoleZeroChart.js +0 -164
- package/dist/charts/signals/SpectrogramChart.js +0 -79
- package/dist/charts/timeline/CalendarSkylineChart.js +0 -128
- package/dist/charts/timeline/ScheduleBlocksChart.js +0 -119
- package/dist/charts/timeline/SpiralTimeline.js +0 -154
- package/dist/charts/timeline/StreamTimeline.js +0 -141
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { forceCollide, forceLink, forceManyBody, forceSimulation, forceX, forceY, hierarchy, mean, tree } from "d3";
|
|
2
|
+
// src/charts/diagrams/TopologyLayout.ts
|
|
3
|
+
var SWEEPS = 12;
|
|
4
|
+
var RELAX = 8;
|
|
5
|
+
/** Device positions for a network diagram, as index-aligned points whose cells stay inside the area. */
|
|
6
|
+
var TopologyLayout = class TopologyLayout {
|
|
7
|
+
/**
|
|
8
|
+
* Layered: `tiers[i]` fixes each device's layer, as in the core, distribution and access model,
|
|
9
|
+
* and barycentre sweeps (Sugiyama, 1981) order each layer to cut crossings.
|
|
10
|
+
*/
|
|
11
|
+
static tiered(tiers, links, area, horizontal) {
|
|
12
|
+
const levels = [...new Set(tiers)].sort((a, b) => a - b);
|
|
13
|
+
const layers = levels.map((level) => tiers.flatMap((tier, i) => tier === level ? [i] : []));
|
|
14
|
+
const near = tiers.map(() => []);
|
|
15
|
+
for (const [a, b] of links) {
|
|
16
|
+
near[a].push(b);
|
|
17
|
+
near[b].push(a);
|
|
18
|
+
}
|
|
19
|
+
const place = new Array(tiers.length).fill(0);
|
|
20
|
+
const stamp = () => layers.forEach((layer) => layer.forEach((device, i) => {
|
|
21
|
+
place[device] = (i + .5) / layer.length;
|
|
22
|
+
}));
|
|
23
|
+
stamp();
|
|
24
|
+
for (let sweep = 0; sweep < SWEEPS; sweep++) for (const layer of sweep % 2 ? [...layers].reverse() : layers) {
|
|
25
|
+
const score = new Map(layer.map((device) => [device, mean(near[device].filter((other) => tiers[other] !== tiers[device]).map((other) => place[other])) ?? place[device]]));
|
|
26
|
+
layer.sort((a, b) => score.get(a) - score.get(b) || a - b);
|
|
27
|
+
layer.forEach((device, i) => {
|
|
28
|
+
place[device] = (i + .5) / layer.length;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const length = horizontal ? area.height : area.width, cell = horizontal ? area.cell.height : area.cell.width;
|
|
32
|
+
const spread = layers.map((layer) => TopologyLayout.#relax(layer, near, place, tiers, length, cell));
|
|
33
|
+
const depth = horizontal ? area.width : area.height, step = levels.length ? depth / levels.length : depth;
|
|
34
|
+
const points = new Array(tiers.length);
|
|
35
|
+
layers.forEach((layer, l) => layer.forEach((device, i) => {
|
|
36
|
+
const along = step * (l + .5), across = spread[l][i];
|
|
37
|
+
points[device] = horizontal ? {
|
|
38
|
+
x: along,
|
|
39
|
+
y: across
|
|
40
|
+
} : {
|
|
41
|
+
x: across,
|
|
42
|
+
y: along
|
|
43
|
+
};
|
|
44
|
+
}));
|
|
45
|
+
return points;
|
|
46
|
+
}
|
|
47
|
+
/** Slides a layer's devices toward their neighbours without changing their order or closing the gaps. */
|
|
48
|
+
static #relax(layer, near, place, tiers, length, cell) {
|
|
49
|
+
const gap = Math.min(length / layer.length, cell + 16), low = cell / 2, high = length - cell / 2;
|
|
50
|
+
let at = layer.map((_, i) => length * (i + .5) / layer.length);
|
|
51
|
+
for (let round = 0; round < RELAX; round++) {
|
|
52
|
+
const wish = layer.map((device, i) => mean(near[device].filter((other) => tiers[other] !== tiers[device]).map((other) => place[other] * length)) ?? at[i]);
|
|
53
|
+
const up = [...wish], down = [...wish];
|
|
54
|
+
up[0] = Math.max(up[0], low);
|
|
55
|
+
for (let i = 1; i < up.length; i++) up[i] = Math.max(up[i], up[i - 1] + gap);
|
|
56
|
+
down[down.length - 1] = Math.min(down[down.length - 1], high);
|
|
57
|
+
for (let i = down.length - 2; i >= 0; i--) down[i] = Math.min(down[i], down[i + 1] - gap);
|
|
58
|
+
at = up.map((value, i) => (value + down[i]) / 2);
|
|
59
|
+
at[at.length - 1] = Math.min(at[at.length - 1], high);
|
|
60
|
+
for (let i = at.length - 2; i >= 0; i--) at[i] = Math.min(at[i], at[i + 1] - gap);
|
|
61
|
+
at[0] = Math.max(at[0], low);
|
|
62
|
+
for (let i = 1; i < at.length; i++) at[i] = Math.max(at[i], at[i - 1] + gap);
|
|
63
|
+
layer.forEach((device, i) => {
|
|
64
|
+
place[device] = at[i] / length;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return at;
|
|
68
|
+
}
|
|
69
|
+
/** Radial tree (Eades, 1992) of the shortest-hop tree from `root`: rings count hops, and each branch gets an arc for its leaves. */
|
|
70
|
+
static radial(count, links, root, area) {
|
|
71
|
+
const near = Array.from({ length: count }, () => []);
|
|
72
|
+
for (const [a, b] of links) {
|
|
73
|
+
near[a].push(b);
|
|
74
|
+
near[b].push(a);
|
|
75
|
+
}
|
|
76
|
+
const seen = /* @__PURE__ */ new Set();
|
|
77
|
+
const grow = (start) => {
|
|
78
|
+
const top = {
|
|
79
|
+
index: start,
|
|
80
|
+
children: []
|
|
81
|
+
}, queue = [top];
|
|
82
|
+
seen.add(start);
|
|
83
|
+
while (queue.length) {
|
|
84
|
+
const at = queue.shift();
|
|
85
|
+
for (const next of near[at.index]) {
|
|
86
|
+
if (seen.has(next)) continue;
|
|
87
|
+
seen.add(next);
|
|
88
|
+
const child = {
|
|
89
|
+
index: next,
|
|
90
|
+
children: []
|
|
91
|
+
};
|
|
92
|
+
at.children.push(child);
|
|
93
|
+
queue.push(child);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return top;
|
|
97
|
+
};
|
|
98
|
+
const crowns = [root, ...Array.from({ length: count }, (_, i) => i)].flatMap((start) => seen.has(start) ? [] : [grow(start)]);
|
|
99
|
+
const whole = crowns.length === 1 ? crowns[0] : {
|
|
100
|
+
index: -1,
|
|
101
|
+
children: crowns
|
|
102
|
+
};
|
|
103
|
+
const laid = tree().size([2 * Math.PI, 1]).separation((a, b) => (a.parent === b.parent ? 1 : 2) / Math.max(1, a.depth))(hierarchy(whole, (branch) => branch.children));
|
|
104
|
+
const rings = Math.max(1, laid.height);
|
|
105
|
+
const ry = Math.max(1, area.height / 2 - area.cell.height / 2), rx = Math.max(1, area.width / 2 - area.cell.width / 2);
|
|
106
|
+
const points = new Array(count);
|
|
107
|
+
for (const node of laid.descendants()) {
|
|
108
|
+
if (node.data.index < 0) continue;
|
|
109
|
+
const hop = node.depth / rings;
|
|
110
|
+
points[node.data.index] = {
|
|
111
|
+
x: area.width / 2 + Math.sin(node.x) * rx * hop,
|
|
112
|
+
y: area.height / 2 - Math.cos(node.x) * ry * hop
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return points;
|
|
116
|
+
}
|
|
117
|
+
/** Force-directed placement (Fruchterman and Reingold, 1991, by d3-force), started from `seed` so it repeats exactly and untangles less. */
|
|
118
|
+
static force(seed, links, area) {
|
|
119
|
+
const { width, height, cell } = area;
|
|
120
|
+
const movers = seed.map((point, index) => ({
|
|
121
|
+
index,
|
|
122
|
+
x: point.x - width / 2,
|
|
123
|
+
y: point.y - height / 2
|
|
124
|
+
}));
|
|
125
|
+
const reach = Math.max(cell.width, cell.height), span = Math.sqrt(width * height / Math.max(1, seed.length));
|
|
126
|
+
const simulation = forceSimulation(movers).stop().force("link", forceLink(links.map(([source, target]) => ({
|
|
127
|
+
source,
|
|
128
|
+
target
|
|
129
|
+
}))).distance(Math.max(reach, span * .9)).strength(.4)).force("charge", forceManyBody().strength(-span * 6)).force("collide", forceCollide(reach * .62)).force("x", forceX(0).strength(.05 * height / Math.max(width, 1))).force("y", forceY(0).strength(.05 * width / Math.max(height, 1)));
|
|
130
|
+
for (let i = 0; i < 300; i++) {
|
|
131
|
+
simulation.tick();
|
|
132
|
+
for (const mover of movers) {
|
|
133
|
+
mover.x = Math.max(cell.width / 2 - width / 2, Math.min(width / 2 - cell.width / 2, mover.x));
|
|
134
|
+
mover.y = Math.max(cell.height / 2 - height / 2, Math.min(height / 2 - cell.height / 2, mover.y));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return movers.map((mover) => ({
|
|
138
|
+
x: mover.x + width / 2,
|
|
139
|
+
y: mover.y + height / 2
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export { TopologyLayout };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/charts/diagrams/architectureEnums.ts
|
|
2
|
+
/** C4 element types, plus the plain grouping box. `Database` is a container drawn as a cylinder. */
|
|
3
|
+
var ArchitectureKind = /* @__PURE__ */ function(ArchitectureKind) {
|
|
4
|
+
ArchitectureKind["Person"] = "person";
|
|
5
|
+
ArchitectureKind["System"] = "system";
|
|
6
|
+
ArchitectureKind["Container"] = "container";
|
|
7
|
+
ArchitectureKind["Database"] = "database";
|
|
8
|
+
ArchitectureKind["Component"] = "component";
|
|
9
|
+
ArchitectureKind["Boundary"] = "boundary";
|
|
10
|
+
return ArchitectureKind;
|
|
11
|
+
}({});
|
|
12
|
+
/** The C4 zoom level: each one opens the element type above it into a boundary. */
|
|
13
|
+
var ArchitectureLevel = /* @__PURE__ */ function(ArchitectureLevel) {
|
|
14
|
+
ArchitectureLevel["Context"] = "context";
|
|
15
|
+
ArchitectureLevel["Containers"] = "containers";
|
|
16
|
+
ArchitectureLevel["Components"] = "components";
|
|
17
|
+
return ArchitectureLevel;
|
|
18
|
+
}({});
|
|
19
|
+
var ArchitectureDirection = /* @__PURE__ */ function(ArchitectureDirection) {
|
|
20
|
+
ArchitectureDirection["TopDown"] = "top-down";
|
|
21
|
+
ArchitectureDirection["LeftRight"] = "left-right";
|
|
22
|
+
return ArchitectureDirection;
|
|
23
|
+
}({});
|
|
24
|
+
/** `Direct` draws straight where the way is clear and goes around boxes where it is not. */
|
|
25
|
+
var ArchitectureRouting = /* @__PURE__ */ function(ArchitectureRouting) {
|
|
26
|
+
ArchitectureRouting["Orthogonal"] = "orthogonal";
|
|
27
|
+
ArchitectureRouting["Direct"] = "direct";
|
|
28
|
+
return ArchitectureRouting;
|
|
29
|
+
}({});
|
|
30
|
+
/** `Full` adds each element's description, which is what makes its box taller. */
|
|
31
|
+
var ArchitectureDetail = /* @__PURE__ */ function(ArchitectureDetail) {
|
|
32
|
+
ArchitectureDetail["Full"] = "full";
|
|
33
|
+
ArchitectureDetail["Names"] = "names";
|
|
34
|
+
return ArchitectureDetail;
|
|
35
|
+
}({});
|
|
36
|
+
var NetworkDeviceKind = /* @__PURE__ */ function(NetworkDeviceKind) {
|
|
37
|
+
NetworkDeviceKind["Cloud"] = "cloud";
|
|
38
|
+
NetworkDeviceKind["Router"] = "router";
|
|
39
|
+
NetworkDeviceKind["Switch"] = "switch";
|
|
40
|
+
NetworkDeviceKind["Server"] = "server";
|
|
41
|
+
NetworkDeviceKind["Database"] = "database";
|
|
42
|
+
return NetworkDeviceKind;
|
|
43
|
+
}({});
|
|
44
|
+
var TopologyArrangement = /* @__PURE__ */ function(TopologyArrangement) {
|
|
45
|
+
TopologyArrangement["Tiered"] = "tiered";
|
|
46
|
+
TopologyArrangement["Radial"] = "radial";
|
|
47
|
+
TopologyArrangement["Force"] = "force";
|
|
48
|
+
return TopologyArrangement;
|
|
49
|
+
}({});
|
|
50
|
+
export { ArchitectureDetail, ArchitectureDirection, ArchitectureKind, ArchitectureLevel, ArchitectureRouting, NetworkDeviceKind, TopologyArrangement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ArchitectureDetail, ArchitectureDirection, ArchitectureKind, ArchitectureLevel, ArchitectureRouting, NetworkDeviceKind, TopologyArrangement } from "./architectureEnums.js";
|
|
2
|
+
import { ArchitectureModel } from "./ArchitectureModel.js";
|
|
3
|
+
import { DiagramText } from "./DiagramText.js";
|
|
4
|
+
import { ArchitectureFlow, ArchitectureRouter } from "./ArchitectureRouter.js";
|
|
5
|
+
import { ArchitectureDiagram } from "./ArchitectureDiagram.js";
|
|
6
|
+
import { LogicGateKind, LogicLayering, LogicState, LogicStateLabels, LogicSymbolStyle } from "./logicEnums.js";
|
|
7
|
+
import { LogicCircuit } from "./LogicCircuit.js";
|
|
8
|
+
import { LogicGateSymbol } from "./LogicGateSymbol.js";
|
|
9
|
+
import { LogicCircuitLayout } from "./LogicCircuitLayout.js";
|
|
10
|
+
import { LogicCircuitSamples } from "./LogicCircuitSamples.js";
|
|
11
|
+
import { LogicGateDiagram } from "./LogicGateDiagram.js";
|
|
12
|
+
import { TopologyLayout } from "./TopologyLayout.js";
|
|
13
|
+
import { NetworkTopologyDiagram } from "./NetworkTopologyDiagram.js";
|
|
14
|
+
import { ErCardinality, ErSchema } from "./ErSchema.js";
|
|
15
|
+
import { EntityRelationshipDiagram, ErDetail } from "./EntityRelationshipDiagram.js";
|
|
16
|
+
import { SequenceFragmentKind, SequenceMessageKind, SequenceNoteSide, SequenceNumbering, SequenceParticipantKind, SequenceSpacing } from "./sequenceEnums.js";
|
|
17
|
+
import { SequenceDiagram } from "./SequenceDiagram.js";
|
|
18
|
+
// src/charts/diagrams/index.ts
|
|
19
|
+
var diagramsCatalog = [
|
|
20
|
+
LogicGateDiagram,
|
|
21
|
+
EntityRelationshipDiagram,
|
|
22
|
+
ArchitectureDiagram,
|
|
23
|
+
NetworkTopologyDiagram,
|
|
24
|
+
SequenceDiagram
|
|
25
|
+
];
|
|
26
|
+
export { ArchitectureDetail, ArchitectureDiagram, ArchitectureDirection, ArchitectureFlow, ArchitectureKind, ArchitectureLevel, ArchitectureModel, ArchitectureRouter, ArchitectureRouting, DiagramText, EntityRelationshipDiagram, ErCardinality, ErDetail, ErSchema, LogicCircuit, LogicCircuitLayout, LogicCircuitSamples, LogicGateDiagram, LogicGateKind, LogicGateSymbol, LogicLayering, LogicState, LogicStateLabels, LogicSymbolStyle, NetworkDeviceKind, NetworkTopologyDiagram, SequenceDiagram, SequenceFragmentKind, SequenceMessageKind, SequenceNoteSide, SequenceNumbering, SequenceParticipantKind, SequenceSpacing, TopologyArrangement, TopologyLayout, diagramsCatalog };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/charts/diagrams/logicEnums.ts
|
|
2
|
+
/** Primitive of a logic circuit. `Unknown` marks a row whose type was not recognised. */
|
|
3
|
+
var LogicGateKind = /* @__PURE__ */ function(LogicGateKind) {
|
|
4
|
+
LogicGateKind["Input"] = "input";
|
|
5
|
+
LogicGateKind["Output"] = "output";
|
|
6
|
+
LogicGateKind["And"] = "and";
|
|
7
|
+
LogicGateKind["Or"] = "or";
|
|
8
|
+
LogicGateKind["Not"] = "not";
|
|
9
|
+
LogicGateKind["Nand"] = "nand";
|
|
10
|
+
LogicGateKind["Nor"] = "nor";
|
|
11
|
+
LogicGateKind["Xor"] = "xor";
|
|
12
|
+
LogicGateKind["Xnor"] = "xnor";
|
|
13
|
+
LogicGateKind["Buffer"] = "buffer";
|
|
14
|
+
LogicGateKind["Unknown"] = "unknown";
|
|
15
|
+
return LogicGateKind;
|
|
16
|
+
}({});
|
|
17
|
+
/** Ternary signal value: `Unknown` is X, an undriven or unresolved net. */
|
|
18
|
+
var LogicState = /* @__PURE__ */ function(LogicState) {
|
|
19
|
+
LogicState["False"] = "0";
|
|
20
|
+
LogicState["True"] = "1";
|
|
21
|
+
LogicState["Unknown"] = "X";
|
|
22
|
+
return LogicState;
|
|
23
|
+
}({});
|
|
24
|
+
/** ANSI/IEEE 91 distinctive shapes, or IEC 60617 rectangles with a function qualifier. */
|
|
25
|
+
var LogicSymbolStyle = /* @__PURE__ */ function(LogicSymbolStyle) {
|
|
26
|
+
LogicSymbolStyle["Ansi"] = "ansi";
|
|
27
|
+
LogicSymbolStyle["Iec"] = "iec";
|
|
28
|
+
return LogicSymbolStyle;
|
|
29
|
+
}({});
|
|
30
|
+
/** Which end gates are pushed to when they have slack: as soon as inputs allow, or as late as outputs allow. */
|
|
31
|
+
var LogicLayering = /* @__PURE__ */ function(LogicLayering) {
|
|
32
|
+
LogicLayering["Inputs"] = "early";
|
|
33
|
+
LogicLayering["Outputs"] = "late";
|
|
34
|
+
return LogicLayering;
|
|
35
|
+
}({});
|
|
36
|
+
/** Where the state text goes: on every net, or only on the circuit's terminals. */
|
|
37
|
+
var LogicStateLabels = /* @__PURE__ */ function(LogicStateLabels) {
|
|
38
|
+
LogicStateLabels["Nets"] = "nets";
|
|
39
|
+
LogicStateLabels["Terminals"] = "terminals";
|
|
40
|
+
return LogicStateLabels;
|
|
41
|
+
}({});
|
|
42
|
+
export { LogicGateKind, LogicLayering, LogicState, LogicStateLabels, LogicSymbolStyle };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/charts/diagrams/sequenceEnums.ts
|
|
2
|
+
/** UML message sorts. `Self` is a call a lifeline makes on itself. */
|
|
3
|
+
var SequenceMessageKind = /* @__PURE__ */ function(SequenceMessageKind) {
|
|
4
|
+
SequenceMessageKind["Sync"] = "sync";
|
|
5
|
+
SequenceMessageKind["Async"] = "async";
|
|
6
|
+
SequenceMessageKind["Return"] = "return";
|
|
7
|
+
SequenceMessageKind["Self"] = "self";
|
|
8
|
+
return SequenceMessageKind;
|
|
9
|
+
}({});
|
|
10
|
+
var SequenceFragmentKind = /* @__PURE__ */ function(SequenceFragmentKind) {
|
|
11
|
+
SequenceFragmentKind["Alt"] = "alt";
|
|
12
|
+
SequenceFragmentKind["Opt"] = "opt";
|
|
13
|
+
SequenceFragmentKind["Loop"] = "loop";
|
|
14
|
+
return SequenceFragmentKind;
|
|
15
|
+
}({});
|
|
16
|
+
var SequenceParticipantKind = /* @__PURE__ */ function(SequenceParticipantKind) {
|
|
17
|
+
SequenceParticipantKind["Object"] = "object";
|
|
18
|
+
SequenceParticipantKind["Actor"] = "actor";
|
|
19
|
+
return SequenceParticipantKind;
|
|
20
|
+
}({});
|
|
21
|
+
var SequenceNoteSide = /* @__PURE__ */ function(SequenceNoteSide) {
|
|
22
|
+
SequenceNoteSide["Over"] = "over";
|
|
23
|
+
SequenceNoteSide["Left"] = "left";
|
|
24
|
+
SequenceNoteSide["Right"] = "right";
|
|
25
|
+
return SequenceNoteSide;
|
|
26
|
+
}({});
|
|
27
|
+
/** `Nested` numbers calls by their depth (1, 1.1, 1.2), as UML's decimal message numbers do. */
|
|
28
|
+
var SequenceNumbering = /* @__PURE__ */ function(SequenceNumbering) {
|
|
29
|
+
SequenceNumbering["None"] = "none";
|
|
30
|
+
SequenceNumbering["Flat"] = "flat";
|
|
31
|
+
SequenceNumbering["Nested"] = "nested";
|
|
32
|
+
return SequenceNumbering;
|
|
33
|
+
}({});
|
|
34
|
+
/** `Fitted` widens each gap only as far as its labels need; `Even` makes every gap the widest one. */
|
|
35
|
+
var SequenceSpacing = /* @__PURE__ */ function(SequenceSpacing) {
|
|
36
|
+
SequenceSpacing["Fitted"] = "fitted";
|
|
37
|
+
SequenceSpacing["Even"] = "even";
|
|
38
|
+
return SequenceSpacing;
|
|
39
|
+
}({});
|
|
40
|
+
export { SequenceFragmentKind, SequenceMessageKind, SequenceNoteSide, SequenceNumbering, SequenceParticipantKind, SequenceSpacing };
|
|
@@ -6,6 +6,18 @@ import { DistributionStats } from "./DistributionStats.js";
|
|
|
6
6
|
import { BinRule, DistributionFit, DistributionLayout, FrequencyScale, HistogramShape, KernelKind, KernelSmoothing } from "./enums.js";
|
|
7
7
|
import { max } from "d3";
|
|
8
8
|
// src/charts/distribution/HistogramChart.ts
|
|
9
|
+
var ROUND_STEPS = [
|
|
10
|
+
1,
|
|
11
|
+
1.5,
|
|
12
|
+
2,
|
|
13
|
+
2.5,
|
|
14
|
+
3,
|
|
15
|
+
4,
|
|
16
|
+
5,
|
|
17
|
+
6,
|
|
18
|
+
8,
|
|
19
|
+
10
|
|
20
|
+
];
|
|
9
21
|
/** Shows the shape of a distribution by counting values into bins; the first chart to reach for with one numeric column. */
|
|
10
22
|
var HistogramChart = class extends BinnedChart {
|
|
11
23
|
static meta = {
|
|
@@ -61,9 +73,18 @@ var HistogramChart = class extends BinnedChart {
|
|
|
61
73
|
...super.defaults(),
|
|
62
74
|
layout: DistributionLayout.Pooled,
|
|
63
75
|
shape: HistogramShape.Bars,
|
|
64
|
-
fit: DistributionFit.None
|
|
76
|
+
fit: DistributionFit.None,
|
|
77
|
+
roundBins: false
|
|
65
78
|
};
|
|
66
79
|
}
|
|
80
|
+
edges(samples) {
|
|
81
|
+
const edges = super.edges(samples);
|
|
82
|
+
if (!this.options.roundBins || edges.length < 2) return edges;
|
|
83
|
+
const raw = edges[1] - edges[0], power = 10 ** Math.floor(Math.log10(raw));
|
|
84
|
+
const step = ROUND_STEPS.reduce((best, candidate) => Math.abs(candidate * power - raw) < Math.abs(best - raw) ? candidate * power : best, power);
|
|
85
|
+
const first = Math.floor(edges[0] / step), count = Math.ceil(edges[edges.length - 1] / step) - first;
|
|
86
|
+
return Array.from({ length: Math.max(1, count) + 1 }, (_, i) => (first + i) * step);
|
|
87
|
+
}
|
|
67
88
|
get pooled() {
|
|
68
89
|
return this.options.layout === DistributionLayout.Pooled;
|
|
69
90
|
}
|
|
@@ -91,9 +112,10 @@ var HistogramChart = class extends BinnedChart {
|
|
|
91
112
|
fitLine(samples) {
|
|
92
113
|
const { fit, frequency } = this.options;
|
|
93
114
|
const sample = samples[0];
|
|
94
|
-
if (!sample || fit === DistributionFit.None) return [];
|
|
115
|
+
if (!sample || fit === DistributionFit.None || !this.pooled || frequency === FrequencyScale.Cumulative) return [];
|
|
95
116
|
const edges = this.edges(samples), s = sample.summary;
|
|
96
|
-
const
|
|
117
|
+
const width = edges[1] - edges[0];
|
|
118
|
+
const unit = frequency === FrequencyScale.Density ? 1 : frequency === FrequencyScale.Percent ? width : s.n * width;
|
|
97
119
|
const curve = fit === DistributionFit.Kde ? DistributionStats.density(sample.values, KernelKind.Gaussian, KernelSmoothing.Balanced) : [];
|
|
98
120
|
const steps = 80;
|
|
99
121
|
return Array.from({ length: 81 }, (_, i) => {
|
|
@@ -16,7 +16,6 @@ import { LetterValuePlot } from "./LetterValuePlot.js";
|
|
|
16
16
|
import { ParetoChart } from "./ParetoChart.js";
|
|
17
17
|
import { QuantileDotplot } from "./QuantileDotplot.js";
|
|
18
18
|
import { RaincloudChart } from "./RaincloudChart.js";
|
|
19
|
-
import { RidgeSlabs3DChart } from "./RidgeSlabs3DChart.js";
|
|
20
19
|
import { RidgelineChart } from "./RidgelineChart.js";
|
|
21
20
|
import { SinaPlot } from "./SinaPlot.js";
|
|
22
21
|
import { StemLeaf } from "./StemLeaf.js";
|
|
@@ -47,7 +46,6 @@ var distributionCatalog = [
|
|
|
47
46
|
BackToBackHistogram,
|
|
48
47
|
BeanPlot,
|
|
49
48
|
DensityStrip,
|
|
50
|
-
RidgeSlabs3DChart,
|
|
51
49
|
Violin3DChart
|
|
52
50
|
];
|
|
53
|
-
export { BackToBackHistogram, BarcodeAlign, BarcodeLength, BarcodeOverlay, BarcodePlot, BeanLine, BeanPlot, BeeswarmChart, BinRule, BoxPlot, BoxStyle, BoxWidth, BoxenChart, BoxenScale, CdfBand, CdfForm, CdfLine, CumulativeDistribution, DensityChart, DensityScaling, DensitySide, DensityStrip, DistributionFit, DistributionLayout, DotBinning, DotLayout, DotStackDirection, Dotplot, FrequencyPolygon, FrequencyScale, GroupOrder, HalfEyePlot, HistogramChart, HistogramShape, IntervalSet, KernelKind, KernelSmoothing, LeafMark, LetterDepth, LetterForm, LetterValuePlot, ParetoChart, ParetoCutoff, ParetoLine, ParetoTail, PointEstimate, QuantileDotplot, RainStyle, RaincloudChart, Ridge3DForm, RidgeMarker, RidgeMode, RidgeScaling,
|
|
51
|
+
export { BackToBackHistogram, BarcodeAlign, BarcodeLength, BarcodeOverlay, BarcodePlot, BeanLine, BeanPlot, BeeswarmChart, BinRule, BoxPlot, BoxStyle, BoxWidth, BoxenChart, BoxenScale, CdfBand, CdfForm, CdfLine, CumulativeDistribution, DensityChart, DensityScaling, DensitySide, DensityStrip, DistributionFit, DistributionLayout, DotBinning, DotLayout, DotStackDirection, Dotplot, FrequencyPolygon, FrequencyScale, GroupOrder, HalfEyePlot, HistogramChart, HistogramShape, IntervalSet, KernelKind, KernelSmoothing, LeafMark, LetterDepth, LetterForm, LetterValuePlot, ParetoChart, ParetoCutoff, ParetoLine, ParetoTail, PointEstimate, QuantileDotplot, RainStyle, RaincloudChart, Ridge3DForm, RidgeMarker, RidgeMode, RidgeScaling, RidgelineChart, SinaOverlay, SinaPlot, SinaSpread, SlabForm, StemLayout, StemLeaf, StripJitter, StripMark, StripPlot, StripSummary, StripeForm, StripeMarker, StripeProfile, SwarmLanes, SwarmSide, Violin3DChart, Violin3DForm, ViolinChart, ViolinInner, WhiskerRule, distributionCatalog };
|