@ggterm/core 0.2.9 → 0.2.10
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/cli-plot.js +212 -2
- package/dist/cli.js +203 -1
- package/dist/geoms/index.d.ts +1 -0
- package/dist/geoms/index.d.ts.map +1 -1
- package/dist/geoms/ridgeline.d.ts +52 -0
- package/dist/geoms/ridgeline.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +207 -1
- package/dist/pipeline/pipeline.d.ts.map +1 -1
- package/dist/pipeline/render-geoms.d.ts +6 -0
- package/dist/pipeline/render-geoms.d.ts.map +1 -1
- package/dist/stats/density.d.ts +5 -0
- package/dist/stats/density.d.ts.map +1 -1
- package/dist/stats/index.d.ts +1 -1
- package/dist/stats/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli-plot.js
CHANGED
|
@@ -1806,6 +1806,120 @@ function renderGeomViolin(data, geom, _aes, scales, canvas) {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
}
|
|
1808
1808
|
}
|
|
1809
|
+
function renderGeomRidgeline(data, geom, aes, scales, canvas) {
|
|
1810
|
+
const scaleFactor = geom.params.scale ?? 0.9;
|
|
1811
|
+
const alpha = geom.params.alpha ?? 0.8;
|
|
1812
|
+
const showOutline = geom.params.outline ?? true;
|
|
1813
|
+
const fixedFill = geom.params.fill;
|
|
1814
|
+
const fixedColor = geom.params.color;
|
|
1815
|
+
const plotLeft = Math.round(scales.x.range[0]);
|
|
1816
|
+
const plotRight = Math.round(scales.x.range[1]);
|
|
1817
|
+
const plotTop = Math.round(Math.min(scales.y.range[0], scales.y.range[1]));
|
|
1818
|
+
const plotBottom = Math.round(Math.max(scales.y.range[0], scales.y.range[1]));
|
|
1819
|
+
const groups = new Map;
|
|
1820
|
+
const groupKeys = [];
|
|
1821
|
+
for (const row of data) {
|
|
1822
|
+
const key = String(row.y ?? "default");
|
|
1823
|
+
if (!groups.has(key)) {
|
|
1824
|
+
groups.set(key, { data: [], index: Number(row.yIndex) ?? groupKeys.length });
|
|
1825
|
+
groupKeys.push(key);
|
|
1826
|
+
}
|
|
1827
|
+
groups.get(key).data.push(row);
|
|
1828
|
+
}
|
|
1829
|
+
const numGroups = groupKeys.length;
|
|
1830
|
+
if (numGroups === 0)
|
|
1831
|
+
return;
|
|
1832
|
+
const plotHeight = Math.abs(plotBottom - plotTop);
|
|
1833
|
+
const ridgeBaseHeight = plotHeight / numGroups;
|
|
1834
|
+
const defaultColors = [
|
|
1835
|
+
{ r: 79, g: 169, b: 238, a: 1 },
|
|
1836
|
+
{ r: 238, g: 136, b: 102, a: 1 },
|
|
1837
|
+
{ r: 102, g: 204, b: 153, a: 1 },
|
|
1838
|
+
{ r: 204, g: 102, b: 204, a: 1 },
|
|
1839
|
+
{ r: 255, g: 200, b: 87, a: 1 },
|
|
1840
|
+
{ r: 138, g: 201, b: 222, a: 1 },
|
|
1841
|
+
{ r: 255, g: 153, b: 153, a: 1 },
|
|
1842
|
+
{ r: 170, g: 170, b: 170, a: 1 }
|
|
1843
|
+
];
|
|
1844
|
+
let parsedFillColor = null;
|
|
1845
|
+
if (fixedFill) {
|
|
1846
|
+
parsedFillColor = parseColorToRgba(fixedFill);
|
|
1847
|
+
}
|
|
1848
|
+
const sortedKeys = [...groupKeys].sort((a, b) => {
|
|
1849
|
+
const idxA = groups.get(a)?.index ?? 0;
|
|
1850
|
+
const idxB = groups.get(b)?.index ?? 0;
|
|
1851
|
+
return idxB - idxA;
|
|
1852
|
+
});
|
|
1853
|
+
for (const groupKey of sortedKeys) {
|
|
1854
|
+
const group = groups.get(groupKey);
|
|
1855
|
+
if (!group)
|
|
1856
|
+
continue;
|
|
1857
|
+
const groupIndex = group.index;
|
|
1858
|
+
const groupData = group.data;
|
|
1859
|
+
const sorted = [...groupData].sort((a, b) => {
|
|
1860
|
+
const ax = Number(a.x) || 0;
|
|
1861
|
+
const bx = Number(b.x) || 0;
|
|
1862
|
+
return ax - bx;
|
|
1863
|
+
});
|
|
1864
|
+
if (sorted.length < 2)
|
|
1865
|
+
continue;
|
|
1866
|
+
const baseline = plotTop + (groupIndex + 0.5) * ridgeBaseHeight;
|
|
1867
|
+
let fillColor;
|
|
1868
|
+
if (parsedFillColor) {
|
|
1869
|
+
fillColor = parsedFillColor;
|
|
1870
|
+
} else if ((aes.fill || aes.color) && scales.color) {
|
|
1871
|
+
const mappedColor = scales.color.map(groupKey);
|
|
1872
|
+
if (typeof mappedColor === "object" && "r" in mappedColor) {
|
|
1873
|
+
fillColor = mappedColor;
|
|
1874
|
+
} else {
|
|
1875
|
+
fillColor = defaultColors[groupIndex % defaultColors.length];
|
|
1876
|
+
}
|
|
1877
|
+
} else {
|
|
1878
|
+
fillColor = defaultColors[groupIndex % defaultColors.length];
|
|
1879
|
+
}
|
|
1880
|
+
const alphaFillColor = {
|
|
1881
|
+
r: Math.round(fillColor.r * alpha + 255 * (1 - alpha) * 0.1),
|
|
1882
|
+
g: Math.round(fillColor.g * alpha + 255 * (1 - alpha) * 0.1),
|
|
1883
|
+
b: Math.round(fillColor.b * alpha + 255 * (1 - alpha) * 0.1),
|
|
1884
|
+
a: 1
|
|
1885
|
+
};
|
|
1886
|
+
const maxRidgeHeight = ridgeBaseHeight * scaleFactor * 1.5;
|
|
1887
|
+
const outlinePoints = [];
|
|
1888
|
+
for (const row of sorted) {
|
|
1889
|
+
const xVal = Number(row.x);
|
|
1890
|
+
const scaled = Number(row.scaled) || 0;
|
|
1891
|
+
const px = Math.round(scales.x.map(xVal));
|
|
1892
|
+
const ridgeHeight = scaled * maxRidgeHeight;
|
|
1893
|
+
const py = Math.round(baseline - ridgeHeight);
|
|
1894
|
+
if (px < plotLeft || px > plotRight)
|
|
1895
|
+
continue;
|
|
1896
|
+
const fillTop = Math.max(plotTop, py);
|
|
1897
|
+
const fillBottom = Math.min(plotBottom, Math.round(baseline));
|
|
1898
|
+
for (let y = fillTop;y <= fillBottom; y++) {
|
|
1899
|
+
canvas.drawChar(px, y, "█", alphaFillColor);
|
|
1900
|
+
}
|
|
1901
|
+
if (showOutline) {
|
|
1902
|
+
outlinePoints.push({ x: px, y: Math.max(plotTop, py) });
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
if (showOutline && outlinePoints.length > 1) {
|
|
1906
|
+
const outlineColor = fixedColor ? parseColorToRgba(fixedColor) : { r: Math.min(255, fillColor.r + 40), g: Math.min(255, fillColor.g + 40), b: Math.min(255, fillColor.b + 40), a: 1 };
|
|
1907
|
+
for (let i = 0;i < outlinePoints.length - 1; i++) {
|
|
1908
|
+
const p1 = outlinePoints[i];
|
|
1909
|
+
const p2 = outlinePoints[i + 1];
|
|
1910
|
+
if (Math.abs(p2.x - p1.x) <= 1) {
|
|
1911
|
+
if (p1.y >= plotTop && p1.y <= plotBottom) {
|
|
1912
|
+
canvas.drawChar(p1.x, p1.y, "▄", outlineColor);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
const last = outlinePoints[outlinePoints.length - 1];
|
|
1917
|
+
if (last.y >= plotTop && last.y <= plotBottom) {
|
|
1918
|
+
canvas.drawChar(last.x, last.y, "▄", outlineColor);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1809
1923
|
function renderGeomTile(data, geom, aes, scales, canvas) {
|
|
1810
1924
|
const alpha = geom.params.alpha ?? 1;
|
|
1811
1925
|
const plotLeft = Math.round(scales.x.range[0]);
|
|
@@ -2244,6 +2358,10 @@ function renderGeom(data, geom, aes, scales, canvas, coordType) {
|
|
|
2244
2358
|
case "violin":
|
|
2245
2359
|
renderGeomViolin(data, geom, aes, scales, canvas);
|
|
2246
2360
|
break;
|
|
2361
|
+
case "ridgeline":
|
|
2362
|
+
case "joy":
|
|
2363
|
+
renderGeomRidgeline(data, geom, aes, scales, canvas);
|
|
2364
|
+
break;
|
|
2247
2365
|
case "tile":
|
|
2248
2366
|
case "raster":
|
|
2249
2367
|
case "bin2d":
|
|
@@ -3352,6 +3470,52 @@ function stat_ydensity(params = {}) {
|
|
|
3352
3470
|
}
|
|
3353
3471
|
};
|
|
3354
3472
|
}
|
|
3473
|
+
function stat_xdensity(params = {}) {
|
|
3474
|
+
return {
|
|
3475
|
+
type: "xdensity",
|
|
3476
|
+
compute(data, aes) {
|
|
3477
|
+
const groups = new Map;
|
|
3478
|
+
const groupOrder = [];
|
|
3479
|
+
for (const row of data) {
|
|
3480
|
+
const groupKey = String(row[aes.y] ?? "default");
|
|
3481
|
+
const xVal = row[aes.x];
|
|
3482
|
+
if (xVal === null || xVal === undefined)
|
|
3483
|
+
continue;
|
|
3484
|
+
const numX = Number(xVal);
|
|
3485
|
+
if (isNaN(numX))
|
|
3486
|
+
continue;
|
|
3487
|
+
if (!groups.has(groupKey)) {
|
|
3488
|
+
groups.set(groupKey, []);
|
|
3489
|
+
groupOrder.push(groupKey);
|
|
3490
|
+
}
|
|
3491
|
+
groups.get(groupKey).push(numX);
|
|
3492
|
+
}
|
|
3493
|
+
const result = [];
|
|
3494
|
+
let groupIndex = 0;
|
|
3495
|
+
for (const groupKey of groupOrder) {
|
|
3496
|
+
const xValues = groups.get(groupKey);
|
|
3497
|
+
if (xValues.length < 2) {
|
|
3498
|
+
groupIndex++;
|
|
3499
|
+
continue;
|
|
3500
|
+
}
|
|
3501
|
+
const tempData = xValues.map((v) => ({ x: v }));
|
|
3502
|
+
const densityResult = computeDensity(tempData, "x", params);
|
|
3503
|
+
for (const d of densityResult) {
|
|
3504
|
+
result.push({
|
|
3505
|
+
x: d.x,
|
|
3506
|
+
y: groupKey,
|
|
3507
|
+
yIndex: groupIndex,
|
|
3508
|
+
density: d.density,
|
|
3509
|
+
scaled: d.scaled,
|
|
3510
|
+
height: d.scaled
|
|
3511
|
+
});
|
|
3512
|
+
}
|
|
3513
|
+
groupIndex++;
|
|
3514
|
+
}
|
|
3515
|
+
return result;
|
|
3516
|
+
}
|
|
3517
|
+
};
|
|
3518
|
+
}
|
|
3355
3519
|
|
|
3356
3520
|
// src/stats/smooth.ts
|
|
3357
3521
|
function linearRegression(xs, ys) {
|
|
@@ -4224,6 +4388,14 @@ function applyStatTransform(data, geom, aes) {
|
|
|
4224
4388
|
adjust: geom.params.adjust
|
|
4225
4389
|
});
|
|
4226
4390
|
return ydensityStat.compute(data, aes);
|
|
4391
|
+
} else if (geom.stat === "xdensity") {
|
|
4392
|
+
const xdensityStat = stat_xdensity({
|
|
4393
|
+
bw: geom.params.bw,
|
|
4394
|
+
kernel: geom.params.kernel,
|
|
4395
|
+
n: geom.params.n,
|
|
4396
|
+
adjust: geom.params.adjust
|
|
4397
|
+
});
|
|
4398
|
+
return xdensityStat.compute(data, aes);
|
|
4227
4399
|
} else if (geom.stat === "smooth") {
|
|
4228
4400
|
const smoothStat = stat_smooth({
|
|
4229
4401
|
method: geom.params.method,
|
|
@@ -4346,6 +4518,10 @@ function renderToCanvas(spec, options) {
|
|
|
4346
4518
|
scaleData = applyStatTransform(spec.data, geom, spec.aes);
|
|
4347
4519
|
scaleAes = { ...spec.aes, x: "x", y: "y" };
|
|
4348
4520
|
break;
|
|
4521
|
+
} else if (geom.stat === "xdensity") {
|
|
4522
|
+
scaleData = applyStatTransform(spec.data, geom, spec.aes);
|
|
4523
|
+
scaleAes = { ...spec.aes, x: "x", y: "y" };
|
|
4524
|
+
break;
|
|
4349
4525
|
}
|
|
4350
4526
|
}
|
|
4351
4527
|
scaleData = applyCoordTransform(scaleData, scaleAes, spec.coord);
|
|
@@ -4384,6 +4560,8 @@ function renderToCanvas(spec, options) {
|
|
|
4384
4560
|
geomAes = { ...spec.aes, x: "x", y: "y", fill: "fill" };
|
|
4385
4561
|
} else if (geom.stat === "density_2d") {
|
|
4386
4562
|
geomAes = { ...spec.aes, x: "x", y: "y" };
|
|
4563
|
+
} else if (geom.stat === "xdensity") {
|
|
4564
|
+
geomAes = { ...spec.aes, x: "x", y: "y" };
|
|
4387
4565
|
}
|
|
4388
4566
|
geomData = applyCoordTransform(geomData, geomAes, spec.coord);
|
|
4389
4567
|
}
|
|
@@ -5306,8 +5484,32 @@ function geom_qq_line(options = {}) {
|
|
|
5306
5484
|
};
|
|
5307
5485
|
}
|
|
5308
5486
|
|
|
5487
|
+
// src/geoms/ridgeline.ts
|
|
5488
|
+
function geom_ridgeline(options = {}) {
|
|
5489
|
+
return {
|
|
5490
|
+
type: "ridgeline",
|
|
5491
|
+
stat: "xdensity",
|
|
5492
|
+
position: "identity",
|
|
5493
|
+
params: {
|
|
5494
|
+
scale: options.scale ?? 0.9,
|
|
5495
|
+
alpha: options.alpha ?? 0.8,
|
|
5496
|
+
fill: options.fill,
|
|
5497
|
+
color: options.color,
|
|
5498
|
+
adjust: options.adjust ?? 1,
|
|
5499
|
+
n: options.n ?? 128,
|
|
5500
|
+
outline: options.outline ?? true
|
|
5501
|
+
}
|
|
5502
|
+
};
|
|
5503
|
+
}
|
|
5504
|
+
var geom_joy;
|
|
5505
|
+
var init_ridgeline = __esm(() => {
|
|
5506
|
+
geom_joy = geom_ridgeline;
|
|
5507
|
+
});
|
|
5508
|
+
|
|
5309
5509
|
// src/geoms/index.ts
|
|
5310
|
-
var init_geoms = () => {
|
|
5510
|
+
var init_geoms = __esm(() => {
|
|
5511
|
+
init_ridgeline();
|
|
5512
|
+
});
|
|
5311
5513
|
|
|
5312
5514
|
// src/stats/index.ts
|
|
5313
5515
|
var init_stats = __esm(() => {
|
|
@@ -9816,6 +10018,7 @@ __export(exports_src, {
|
|
|
9816
10018
|
geom_smooth: () => geom_smooth,
|
|
9817
10019
|
geom_segment: () => geom_segment,
|
|
9818
10020
|
geom_rug: () => geom_rug,
|
|
10021
|
+
geom_ridgeline: () => geom_ridgeline,
|
|
9819
10022
|
geom_ribbon: () => geom_ribbon,
|
|
9820
10023
|
geom_rect: () => geom_rect,
|
|
9821
10024
|
geom_raster: () => geom_raster,
|
|
@@ -9827,6 +10030,7 @@ __export(exports_src, {
|
|
|
9827
10030
|
geom_linerange: () => geom_linerange,
|
|
9828
10031
|
geom_line: () => geom_line,
|
|
9829
10032
|
geom_label: () => geom_label,
|
|
10033
|
+
geom_joy: () => geom_joy,
|
|
9830
10034
|
geom_hline: () => geom_hline,
|
|
9831
10035
|
geom_histogram: () => geom_histogram,
|
|
9832
10036
|
geom_freqpoly: () => geom_freqpoly,
|
|
@@ -10735,6 +10939,8 @@ var GEOM_TYPES = [
|
|
|
10735
10939
|
"freqpoly",
|
|
10736
10940
|
"boxplot",
|
|
10737
10941
|
"violin",
|
|
10942
|
+
"ridgeline",
|
|
10943
|
+
"joy",
|
|
10738
10944
|
"area",
|
|
10739
10945
|
"ribbon",
|
|
10740
10946
|
"rug",
|
|
@@ -11129,7 +11335,7 @@ Error: Unknown geometry type "${geomType}"`);
|
|
|
11129
11335
|
Available geom types:`);
|
|
11130
11336
|
console.error(` Points/Lines: point, line, path, step, smooth, segment`);
|
|
11131
11337
|
console.error(` Bars/Areas: bar, col, histogram, freqpoly, area, ribbon`);
|
|
11132
|
-
console.error(` Distributions: boxplot, violin, qq, density_2d`);
|
|
11338
|
+
console.error(` Distributions: boxplot, violin, ridgeline, joy, qq, density_2d`);
|
|
11133
11339
|
console.error(` Uncertainty: errorbar, errorbarh, crossbar, linerange, pointrange`);
|
|
11134
11340
|
console.error(` 2D: tile, rect, raster, bin2d, contour, contour_filled`);
|
|
11135
11341
|
console.error(` Text: text, label`);
|
|
@@ -11274,6 +11480,10 @@ If you want a univariate plot, try: histogram, bar, qq, or freqpoly`);
|
|
|
11274
11480
|
case "violin":
|
|
11275
11481
|
plot = plot.geom(geom_violin());
|
|
11276
11482
|
break;
|
|
11483
|
+
case "ridgeline":
|
|
11484
|
+
case "joy":
|
|
11485
|
+
plot = plot.geom(geom_ridgeline());
|
|
11486
|
+
break;
|
|
11277
11487
|
case "bar":
|
|
11278
11488
|
plot = plot.geom(geom_bar());
|
|
11279
11489
|
break;
|
package/dist/cli.js
CHANGED
|
@@ -1806,6 +1806,120 @@ function renderGeomViolin(data, geom, _aes, scales, canvas) {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
}
|
|
1808
1808
|
}
|
|
1809
|
+
function renderGeomRidgeline(data, geom, aes, scales, canvas) {
|
|
1810
|
+
const scaleFactor = geom.params.scale ?? 0.9;
|
|
1811
|
+
const alpha = geom.params.alpha ?? 0.8;
|
|
1812
|
+
const showOutline = geom.params.outline ?? true;
|
|
1813
|
+
const fixedFill = geom.params.fill;
|
|
1814
|
+
const fixedColor = geom.params.color;
|
|
1815
|
+
const plotLeft = Math.round(scales.x.range[0]);
|
|
1816
|
+
const plotRight = Math.round(scales.x.range[1]);
|
|
1817
|
+
const plotTop = Math.round(Math.min(scales.y.range[0], scales.y.range[1]));
|
|
1818
|
+
const plotBottom = Math.round(Math.max(scales.y.range[0], scales.y.range[1]));
|
|
1819
|
+
const groups = new Map;
|
|
1820
|
+
const groupKeys = [];
|
|
1821
|
+
for (const row of data) {
|
|
1822
|
+
const key = String(row.y ?? "default");
|
|
1823
|
+
if (!groups.has(key)) {
|
|
1824
|
+
groups.set(key, { data: [], index: Number(row.yIndex) ?? groupKeys.length });
|
|
1825
|
+
groupKeys.push(key);
|
|
1826
|
+
}
|
|
1827
|
+
groups.get(key).data.push(row);
|
|
1828
|
+
}
|
|
1829
|
+
const numGroups = groupKeys.length;
|
|
1830
|
+
if (numGroups === 0)
|
|
1831
|
+
return;
|
|
1832
|
+
const plotHeight = Math.abs(plotBottom - plotTop);
|
|
1833
|
+
const ridgeBaseHeight = plotHeight / numGroups;
|
|
1834
|
+
const defaultColors = [
|
|
1835
|
+
{ r: 79, g: 169, b: 238, a: 1 },
|
|
1836
|
+
{ r: 238, g: 136, b: 102, a: 1 },
|
|
1837
|
+
{ r: 102, g: 204, b: 153, a: 1 },
|
|
1838
|
+
{ r: 204, g: 102, b: 204, a: 1 },
|
|
1839
|
+
{ r: 255, g: 200, b: 87, a: 1 },
|
|
1840
|
+
{ r: 138, g: 201, b: 222, a: 1 },
|
|
1841
|
+
{ r: 255, g: 153, b: 153, a: 1 },
|
|
1842
|
+
{ r: 170, g: 170, b: 170, a: 1 }
|
|
1843
|
+
];
|
|
1844
|
+
let parsedFillColor = null;
|
|
1845
|
+
if (fixedFill) {
|
|
1846
|
+
parsedFillColor = parseColorToRgba(fixedFill);
|
|
1847
|
+
}
|
|
1848
|
+
const sortedKeys = [...groupKeys].sort((a, b) => {
|
|
1849
|
+
const idxA = groups.get(a)?.index ?? 0;
|
|
1850
|
+
const idxB = groups.get(b)?.index ?? 0;
|
|
1851
|
+
return idxB - idxA;
|
|
1852
|
+
});
|
|
1853
|
+
for (const groupKey of sortedKeys) {
|
|
1854
|
+
const group = groups.get(groupKey);
|
|
1855
|
+
if (!group)
|
|
1856
|
+
continue;
|
|
1857
|
+
const groupIndex = group.index;
|
|
1858
|
+
const groupData = group.data;
|
|
1859
|
+
const sorted = [...groupData].sort((a, b) => {
|
|
1860
|
+
const ax = Number(a.x) || 0;
|
|
1861
|
+
const bx = Number(b.x) || 0;
|
|
1862
|
+
return ax - bx;
|
|
1863
|
+
});
|
|
1864
|
+
if (sorted.length < 2)
|
|
1865
|
+
continue;
|
|
1866
|
+
const baseline = plotTop + (groupIndex + 0.5) * ridgeBaseHeight;
|
|
1867
|
+
let fillColor;
|
|
1868
|
+
if (parsedFillColor) {
|
|
1869
|
+
fillColor = parsedFillColor;
|
|
1870
|
+
} else if ((aes.fill || aes.color) && scales.color) {
|
|
1871
|
+
const mappedColor = scales.color.map(groupKey);
|
|
1872
|
+
if (typeof mappedColor === "object" && "r" in mappedColor) {
|
|
1873
|
+
fillColor = mappedColor;
|
|
1874
|
+
} else {
|
|
1875
|
+
fillColor = defaultColors[groupIndex % defaultColors.length];
|
|
1876
|
+
}
|
|
1877
|
+
} else {
|
|
1878
|
+
fillColor = defaultColors[groupIndex % defaultColors.length];
|
|
1879
|
+
}
|
|
1880
|
+
const alphaFillColor = {
|
|
1881
|
+
r: Math.round(fillColor.r * alpha + 255 * (1 - alpha) * 0.1),
|
|
1882
|
+
g: Math.round(fillColor.g * alpha + 255 * (1 - alpha) * 0.1),
|
|
1883
|
+
b: Math.round(fillColor.b * alpha + 255 * (1 - alpha) * 0.1),
|
|
1884
|
+
a: 1
|
|
1885
|
+
};
|
|
1886
|
+
const maxRidgeHeight = ridgeBaseHeight * scaleFactor * 1.5;
|
|
1887
|
+
const outlinePoints = [];
|
|
1888
|
+
for (const row of sorted) {
|
|
1889
|
+
const xVal = Number(row.x);
|
|
1890
|
+
const scaled = Number(row.scaled) || 0;
|
|
1891
|
+
const px = Math.round(scales.x.map(xVal));
|
|
1892
|
+
const ridgeHeight = scaled * maxRidgeHeight;
|
|
1893
|
+
const py = Math.round(baseline - ridgeHeight);
|
|
1894
|
+
if (px < plotLeft || px > plotRight)
|
|
1895
|
+
continue;
|
|
1896
|
+
const fillTop = Math.max(plotTop, py);
|
|
1897
|
+
const fillBottom = Math.min(plotBottom, Math.round(baseline));
|
|
1898
|
+
for (let y = fillTop;y <= fillBottom; y++) {
|
|
1899
|
+
canvas.drawChar(px, y, "█", alphaFillColor);
|
|
1900
|
+
}
|
|
1901
|
+
if (showOutline) {
|
|
1902
|
+
outlinePoints.push({ x: px, y: Math.max(plotTop, py) });
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
if (showOutline && outlinePoints.length > 1) {
|
|
1906
|
+
const outlineColor = fixedColor ? parseColorToRgba(fixedColor) : { r: Math.min(255, fillColor.r + 40), g: Math.min(255, fillColor.g + 40), b: Math.min(255, fillColor.b + 40), a: 1 };
|
|
1907
|
+
for (let i = 0;i < outlinePoints.length - 1; i++) {
|
|
1908
|
+
const p1 = outlinePoints[i];
|
|
1909
|
+
const p2 = outlinePoints[i + 1];
|
|
1910
|
+
if (Math.abs(p2.x - p1.x) <= 1) {
|
|
1911
|
+
if (p1.y >= plotTop && p1.y <= plotBottom) {
|
|
1912
|
+
canvas.drawChar(p1.x, p1.y, "▄", outlineColor);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
const last = outlinePoints[outlinePoints.length - 1];
|
|
1917
|
+
if (last.y >= plotTop && last.y <= plotBottom) {
|
|
1918
|
+
canvas.drawChar(last.x, last.y, "▄", outlineColor);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1809
1923
|
function renderGeomTile(data, geom, aes, scales, canvas) {
|
|
1810
1924
|
const alpha = geom.params.alpha ?? 1;
|
|
1811
1925
|
const plotLeft = Math.round(scales.x.range[0]);
|
|
@@ -2244,6 +2358,10 @@ function renderGeom(data, geom, aes, scales, canvas, coordType) {
|
|
|
2244
2358
|
case "violin":
|
|
2245
2359
|
renderGeomViolin(data, geom, aes, scales, canvas);
|
|
2246
2360
|
break;
|
|
2361
|
+
case "ridgeline":
|
|
2362
|
+
case "joy":
|
|
2363
|
+
renderGeomRidgeline(data, geom, aes, scales, canvas);
|
|
2364
|
+
break;
|
|
2247
2365
|
case "tile":
|
|
2248
2366
|
case "raster":
|
|
2249
2367
|
case "bin2d":
|
|
@@ -3352,6 +3470,52 @@ function stat_ydensity(params = {}) {
|
|
|
3352
3470
|
}
|
|
3353
3471
|
};
|
|
3354
3472
|
}
|
|
3473
|
+
function stat_xdensity(params = {}) {
|
|
3474
|
+
return {
|
|
3475
|
+
type: "xdensity",
|
|
3476
|
+
compute(data, aes) {
|
|
3477
|
+
const groups = new Map;
|
|
3478
|
+
const groupOrder = [];
|
|
3479
|
+
for (const row of data) {
|
|
3480
|
+
const groupKey = String(row[aes.y] ?? "default");
|
|
3481
|
+
const xVal = row[aes.x];
|
|
3482
|
+
if (xVal === null || xVal === undefined)
|
|
3483
|
+
continue;
|
|
3484
|
+
const numX = Number(xVal);
|
|
3485
|
+
if (isNaN(numX))
|
|
3486
|
+
continue;
|
|
3487
|
+
if (!groups.has(groupKey)) {
|
|
3488
|
+
groups.set(groupKey, []);
|
|
3489
|
+
groupOrder.push(groupKey);
|
|
3490
|
+
}
|
|
3491
|
+
groups.get(groupKey).push(numX);
|
|
3492
|
+
}
|
|
3493
|
+
const result = [];
|
|
3494
|
+
let groupIndex = 0;
|
|
3495
|
+
for (const groupKey of groupOrder) {
|
|
3496
|
+
const xValues = groups.get(groupKey);
|
|
3497
|
+
if (xValues.length < 2) {
|
|
3498
|
+
groupIndex++;
|
|
3499
|
+
continue;
|
|
3500
|
+
}
|
|
3501
|
+
const tempData = xValues.map((v) => ({ x: v }));
|
|
3502
|
+
const densityResult = computeDensity(tempData, "x", params);
|
|
3503
|
+
for (const d of densityResult) {
|
|
3504
|
+
result.push({
|
|
3505
|
+
x: d.x,
|
|
3506
|
+
y: groupKey,
|
|
3507
|
+
yIndex: groupIndex,
|
|
3508
|
+
density: d.density,
|
|
3509
|
+
scaled: d.scaled,
|
|
3510
|
+
height: d.scaled
|
|
3511
|
+
});
|
|
3512
|
+
}
|
|
3513
|
+
groupIndex++;
|
|
3514
|
+
}
|
|
3515
|
+
return result;
|
|
3516
|
+
}
|
|
3517
|
+
};
|
|
3518
|
+
}
|
|
3355
3519
|
|
|
3356
3520
|
// src/stats/smooth.ts
|
|
3357
3521
|
function linearRegression(xs, ys) {
|
|
@@ -4224,6 +4388,14 @@ function applyStatTransform(data, geom, aes) {
|
|
|
4224
4388
|
adjust: geom.params.adjust
|
|
4225
4389
|
});
|
|
4226
4390
|
return ydensityStat.compute(data, aes);
|
|
4391
|
+
} else if (geom.stat === "xdensity") {
|
|
4392
|
+
const xdensityStat = stat_xdensity({
|
|
4393
|
+
bw: geom.params.bw,
|
|
4394
|
+
kernel: geom.params.kernel,
|
|
4395
|
+
n: geom.params.n,
|
|
4396
|
+
adjust: geom.params.adjust
|
|
4397
|
+
});
|
|
4398
|
+
return xdensityStat.compute(data, aes);
|
|
4227
4399
|
} else if (geom.stat === "smooth") {
|
|
4228
4400
|
const smoothStat = stat_smooth({
|
|
4229
4401
|
method: geom.params.method,
|
|
@@ -4346,6 +4518,10 @@ function renderToCanvas(spec, options) {
|
|
|
4346
4518
|
scaleData = applyStatTransform(spec.data, geom, spec.aes);
|
|
4347
4519
|
scaleAes = { ...spec.aes, x: "x", y: "y" };
|
|
4348
4520
|
break;
|
|
4521
|
+
} else if (geom.stat === "xdensity") {
|
|
4522
|
+
scaleData = applyStatTransform(spec.data, geom, spec.aes);
|
|
4523
|
+
scaleAes = { ...spec.aes, x: "x", y: "y" };
|
|
4524
|
+
break;
|
|
4349
4525
|
}
|
|
4350
4526
|
}
|
|
4351
4527
|
scaleData = applyCoordTransform(scaleData, scaleAes, spec.coord);
|
|
@@ -4384,6 +4560,8 @@ function renderToCanvas(spec, options) {
|
|
|
4384
4560
|
geomAes = { ...spec.aes, x: "x", y: "y", fill: "fill" };
|
|
4385
4561
|
} else if (geom.stat === "density_2d") {
|
|
4386
4562
|
geomAes = { ...spec.aes, x: "x", y: "y" };
|
|
4563
|
+
} else if (geom.stat === "xdensity") {
|
|
4564
|
+
geomAes = { ...spec.aes, x: "x", y: "y" };
|
|
4387
4565
|
}
|
|
4388
4566
|
geomData = applyCoordTransform(geomData, geomAes, spec.coord);
|
|
4389
4567
|
}
|
|
@@ -5301,8 +5479,32 @@ function geom_qq_line(options = {}) {
|
|
|
5301
5479
|
};
|
|
5302
5480
|
}
|
|
5303
5481
|
|
|
5482
|
+
// src/geoms/ridgeline.ts
|
|
5483
|
+
function geom_ridgeline(options = {}) {
|
|
5484
|
+
return {
|
|
5485
|
+
type: "ridgeline",
|
|
5486
|
+
stat: "xdensity",
|
|
5487
|
+
position: "identity",
|
|
5488
|
+
params: {
|
|
5489
|
+
scale: options.scale ?? 0.9,
|
|
5490
|
+
alpha: options.alpha ?? 0.8,
|
|
5491
|
+
fill: options.fill,
|
|
5492
|
+
color: options.color,
|
|
5493
|
+
adjust: options.adjust ?? 1,
|
|
5494
|
+
n: options.n ?? 128,
|
|
5495
|
+
outline: options.outline ?? true
|
|
5496
|
+
}
|
|
5497
|
+
};
|
|
5498
|
+
}
|
|
5499
|
+
var geom_joy;
|
|
5500
|
+
var init_ridgeline = __esm(() => {
|
|
5501
|
+
geom_joy = geom_ridgeline;
|
|
5502
|
+
});
|
|
5503
|
+
|
|
5304
5504
|
// src/geoms/index.ts
|
|
5305
|
-
var init_geoms = () => {
|
|
5505
|
+
var init_geoms = __esm(() => {
|
|
5506
|
+
init_ridgeline();
|
|
5507
|
+
});
|
|
5306
5508
|
|
|
5307
5509
|
// src/scales/continuous.ts
|
|
5308
5510
|
function createContinuousScale(aesthetic, options = {}) {
|
package/dist/geoms/index.d.ts
CHANGED
|
@@ -20,4 +20,5 @@ export { geom_contour, geom_contour_filled, geom_density_2d, type ContourOptions
|
|
|
20
20
|
export { geom_errorbar, geom_errorbarh, geom_crossbar, geom_linerange, geom_pointrange, type ErrorbarOptions, } from './errorbar';
|
|
21
21
|
export { geom_rect, geom_abline, type RectOptions, type AblineOptions } from './rect';
|
|
22
22
|
export { geom_qq, geom_qq_line, type QQOptions, type QQLineOptions } from './qq';
|
|
23
|
+
export { geom_ridgeline, geom_joy, type RidgelineOptions } from './ridgeline';
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geoms/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,WAA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AAc,EACd,eAAe,EACf,KAAK,eAAe,GACrB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAA;AACrF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAA;AAChF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* geom_ridgeline - Ridgeline plot geometry (joy plots)
|
|
3
|
+
*
|
|
4
|
+
* Creates stacked density plots for comparing distributions across groups.
|
|
5
|
+
* Each group gets a ridge that can overlap with neighbors for a compact view.
|
|
6
|
+
*/
|
|
7
|
+
import type { Geom } from '../types';
|
|
8
|
+
export interface RidgelineOptions {
|
|
9
|
+
/** Height scale for ridges (default: 0.9, higher = more overlap) */
|
|
10
|
+
scale?: number;
|
|
11
|
+
/** Alpha transparency (default: 0.8) */
|
|
12
|
+
alpha?: number;
|
|
13
|
+
/** Fill color */
|
|
14
|
+
fill?: string;
|
|
15
|
+
/** Border/outline color */
|
|
16
|
+
color?: string;
|
|
17
|
+
/** Bandwidth adjustment factor for density (default: 1) */
|
|
18
|
+
adjust?: number;
|
|
19
|
+
/** Number of points for density estimation (default: 128) */
|
|
20
|
+
n?: number;
|
|
21
|
+
/** Whether to show ridge outlines (default: true) */
|
|
22
|
+
outline?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Render ridgeline plot (joy plot)
|
|
26
|
+
*
|
|
27
|
+
* Ridgeline plots show the distribution of a numeric variable (x)
|
|
28
|
+
* for several groups (y). Each group is displayed as a density curve,
|
|
29
|
+
* stacked vertically with optional overlap.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { gg, geom_ridgeline } from '@ggterm/core'
|
|
34
|
+
*
|
|
35
|
+
* // Basic ridgeline plot
|
|
36
|
+
* gg(data)
|
|
37
|
+
* .aes({ x: 'value', y: 'month' })
|
|
38
|
+
* .geom(geom_ridgeline())
|
|
39
|
+
*
|
|
40
|
+
* // With custom scale (more overlap)
|
|
41
|
+
* gg(data)
|
|
42
|
+
* .aes({ x: 'temperature', y: 'city', fill: 'city' })
|
|
43
|
+
* .geom(geom_ridgeline({ scale: 1.5, alpha: 0.7 }))
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function geom_ridgeline(options?: RidgelineOptions): Geom;
|
|
47
|
+
/**
|
|
48
|
+
* Alias for geom_ridgeline
|
|
49
|
+
* Named after the Joy Division album cover that popularized this visualization
|
|
50
|
+
*/
|
|
51
|
+
export declare const geom_joy: typeof geom_ridgeline;
|
|
52
|
+
//# sourceMappingURL=ridgeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ridgeline.d.ts","sourceRoot":"","sources":["../../src/geoms/ridgeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAEpC,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,6DAA6D;IAC7D,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAenE;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,uBAAiB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export type { AestheticMapping, Canvas, CanvasCell, ComputedPoint, Coord, DataRe
|
|
|
9
9
|
export { TerminalCanvas, createCanvas, DEFAULT_FG, DEFAULT_BG } from './canvas';
|
|
10
10
|
export { renderToCanvas, renderToString, calculateLayout, buildScaleContext, inferContinuousDomain, inferDiscreteDomain, } from './pipeline';
|
|
11
11
|
export type { PlotLayout, ResolvedScale, ScaleContext } from './pipeline';
|
|
12
|
-
export { geom_point, geom_line, geom_path, geom_hline, geom_vline, geom_bar, geom_col, geom_text, geom_label, geom_area, geom_ribbon, geom_histogram, geom_boxplot, geom_segment, geom_curve, geom_smooth, geom_step, geom_rug, geom_violin, geom_tile, geom_raster, geom_bin2d, geom_contour, geom_contour_filled, geom_density_2d, geom_errorbar, geom_errorbarh, geom_crossbar, geom_linerange, geom_pointrange, geom_rect, geom_abline, geom_qq, geom_qq_line, geom_freqpoly, } from './geoms';
|
|
13
|
-
export type { PathOptions, RugOptions, SmoothOptions, StepOptions, ViolinOptions, TileOptions, Bin2dOptions, ContourOptions, ErrorbarOptions, RectOptions, AblineOptions, QQOptions, QQLineOptions, FreqpolyOptions, } from './geoms';
|
|
12
|
+
export { geom_point, geom_line, geom_path, geom_hline, geom_vline, geom_bar, geom_col, geom_text, geom_label, geom_area, geom_ribbon, geom_histogram, geom_boxplot, geom_segment, geom_curve, geom_smooth, geom_step, geom_rug, geom_violin, geom_tile, geom_raster, geom_bin2d, geom_contour, geom_contour_filled, geom_density_2d, geom_errorbar, geom_errorbarh, geom_crossbar, geom_linerange, geom_pointrange, geom_rect, geom_abline, geom_qq, geom_qq_line, geom_freqpoly, geom_ridgeline, geom_joy, } from './geoms';
|
|
13
|
+
export type { PathOptions, RugOptions, SmoothOptions, StepOptions, ViolinOptions, TileOptions, Bin2dOptions, ContourOptions, ErrorbarOptions, RectOptions, AblineOptions, QQOptions, QQLineOptions, FreqpolyOptions, RidgelineOptions, } from './geoms';
|
|
14
14
|
export { position_identity, position_dodge, position_stack, position_fill, position_jitter, applyPositionAdjustment, isStackPosition, isDodgePosition, getPositionType, } from './positions';
|
|
15
15
|
export type { Position, AdjustedPoint, DodgeOptions, JitterOptions, StackOptions, FillOptions, } from './positions';
|
|
16
16
|
export { stat_bin, stat_bin2d, stat_boxplot, stat_density, stat_smooth, stat_summary, stat_qq, stat_qq_line, computeBins, computeBins2d, computeBoxplotStats, computeDensity, computeSmooth, computeSummary, computeQQ, computeQQLine, } from './stats';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGtC,YAAY,EACV,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,UAAU,EACV,UAAU,EACV,MAAM,EACN,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,GACN,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG/E,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAGzE,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,EAER,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,SAAS,EACT,WAAW,EAEX,OAAO,EACP,YAAY,EAEZ,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGtC,YAAY,EACV,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,UAAU,EACV,UAAU,EACV,MAAM,EACN,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,GACN,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG/E,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAGzE,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,EAER,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,e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AEpB,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,YAAY,EACZ,MAAM,EACN,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,YAAY,EACV,eAAe,EACf,cAAc,EACd,QAAQ,EACR,UAAU,EACV,UAAU,EACV,GAAG,EACH,MAAM,EACN,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC9C,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGpD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACnE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1805,6 +1805,120 @@ function renderGeomViolin(data, geom, _aes, scales, canvas) {
|
|
|
1805
1805
|
}
|
|
1806
1806
|
}
|
|
1807
1807
|
}
|
|
1808
|
+
function renderGeomRidgeline(data, geom, aes, scales, canvas) {
|
|
1809
|
+
const scaleFactor = geom.params.scale ?? 0.9;
|
|
1810
|
+
const alpha = geom.params.alpha ?? 0.8;
|
|
1811
|
+
const showOutline = geom.params.outline ?? true;
|
|
1812
|
+
const fixedFill = geom.params.fill;
|
|
1813
|
+
const fixedColor = geom.params.color;
|
|
1814
|
+
const plotLeft = Math.round(scales.x.range[0]);
|
|
1815
|
+
const plotRight = Math.round(scales.x.range[1]);
|
|
1816
|
+
const plotTop = Math.round(Math.min(scales.y.range[0], scales.y.range[1]));
|
|
1817
|
+
const plotBottom = Math.round(Math.max(scales.y.range[0], scales.y.range[1]));
|
|
1818
|
+
const groups = new Map;
|
|
1819
|
+
const groupKeys = [];
|
|
1820
|
+
for (const row of data) {
|
|
1821
|
+
const key = String(row.y ?? "default");
|
|
1822
|
+
if (!groups.has(key)) {
|
|
1823
|
+
groups.set(key, { data: [], index: Number(row.yIndex) ?? groupKeys.length });
|
|
1824
|
+
groupKeys.push(key);
|
|
1825
|
+
}
|
|
1826
|
+
groups.get(key).data.push(row);
|
|
1827
|
+
}
|
|
1828
|
+
const numGroups = groupKeys.length;
|
|
1829
|
+
if (numGroups === 0)
|
|
1830
|
+
return;
|
|
1831
|
+
const plotHeight = Math.abs(plotBottom - plotTop);
|
|
1832
|
+
const ridgeBaseHeight = plotHeight / numGroups;
|
|
1833
|
+
const defaultColors = [
|
|
1834
|
+
{ r: 79, g: 169, b: 238, a: 1 },
|
|
1835
|
+
{ r: 238, g: 136, b: 102, a: 1 },
|
|
1836
|
+
{ r: 102, g: 204, b: 153, a: 1 },
|
|
1837
|
+
{ r: 204, g: 102, b: 204, a: 1 },
|
|
1838
|
+
{ r: 255, g: 200, b: 87, a: 1 },
|
|
1839
|
+
{ r: 138, g: 201, b: 222, a: 1 },
|
|
1840
|
+
{ r: 255, g: 153, b: 153, a: 1 },
|
|
1841
|
+
{ r: 170, g: 170, b: 170, a: 1 }
|
|
1842
|
+
];
|
|
1843
|
+
let parsedFillColor = null;
|
|
1844
|
+
if (fixedFill) {
|
|
1845
|
+
parsedFillColor = parseColorToRgba(fixedFill);
|
|
1846
|
+
}
|
|
1847
|
+
const sortedKeys = [...groupKeys].sort((a, b) => {
|
|
1848
|
+
const idxA = groups.get(a)?.index ?? 0;
|
|
1849
|
+
const idxB = groups.get(b)?.index ?? 0;
|
|
1850
|
+
return idxB - idxA;
|
|
1851
|
+
});
|
|
1852
|
+
for (const groupKey of sortedKeys) {
|
|
1853
|
+
const group = groups.get(groupKey);
|
|
1854
|
+
if (!group)
|
|
1855
|
+
continue;
|
|
1856
|
+
const groupIndex = group.index;
|
|
1857
|
+
const groupData = group.data;
|
|
1858
|
+
const sorted = [...groupData].sort((a, b) => {
|
|
1859
|
+
const ax = Number(a.x) || 0;
|
|
1860
|
+
const bx = Number(b.x) || 0;
|
|
1861
|
+
return ax - bx;
|
|
1862
|
+
});
|
|
1863
|
+
if (sorted.length < 2)
|
|
1864
|
+
continue;
|
|
1865
|
+
const baseline = plotTop + (groupIndex + 0.5) * ridgeBaseHeight;
|
|
1866
|
+
let fillColor;
|
|
1867
|
+
if (parsedFillColor) {
|
|
1868
|
+
fillColor = parsedFillColor;
|
|
1869
|
+
} else if ((aes.fill || aes.color) && scales.color) {
|
|
1870
|
+
const mappedColor = scales.color.map(groupKey);
|
|
1871
|
+
if (typeof mappedColor === "object" && "r" in mappedColor) {
|
|
1872
|
+
fillColor = mappedColor;
|
|
1873
|
+
} else {
|
|
1874
|
+
fillColor = defaultColors[groupIndex % defaultColors.length];
|
|
1875
|
+
}
|
|
1876
|
+
} else {
|
|
1877
|
+
fillColor = defaultColors[groupIndex % defaultColors.length];
|
|
1878
|
+
}
|
|
1879
|
+
const alphaFillColor = {
|
|
1880
|
+
r: Math.round(fillColor.r * alpha + 255 * (1 - alpha) * 0.1),
|
|
1881
|
+
g: Math.round(fillColor.g * alpha + 255 * (1 - alpha) * 0.1),
|
|
1882
|
+
b: Math.round(fillColor.b * alpha + 255 * (1 - alpha) * 0.1),
|
|
1883
|
+
a: 1
|
|
1884
|
+
};
|
|
1885
|
+
const maxRidgeHeight = ridgeBaseHeight * scaleFactor * 1.5;
|
|
1886
|
+
const outlinePoints = [];
|
|
1887
|
+
for (const row of sorted) {
|
|
1888
|
+
const xVal = Number(row.x);
|
|
1889
|
+
const scaled = Number(row.scaled) || 0;
|
|
1890
|
+
const px = Math.round(scales.x.map(xVal));
|
|
1891
|
+
const ridgeHeight = scaled * maxRidgeHeight;
|
|
1892
|
+
const py = Math.round(baseline - ridgeHeight);
|
|
1893
|
+
if (px < plotLeft || px > plotRight)
|
|
1894
|
+
continue;
|
|
1895
|
+
const fillTop = Math.max(plotTop, py);
|
|
1896
|
+
const fillBottom = Math.min(plotBottom, Math.round(baseline));
|
|
1897
|
+
for (let y = fillTop;y <= fillBottom; y++) {
|
|
1898
|
+
canvas.drawChar(px, y, "█", alphaFillColor);
|
|
1899
|
+
}
|
|
1900
|
+
if (showOutline) {
|
|
1901
|
+
outlinePoints.push({ x: px, y: Math.max(plotTop, py) });
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
if (showOutline && outlinePoints.length > 1) {
|
|
1905
|
+
const outlineColor = fixedColor ? parseColorToRgba(fixedColor) : { r: Math.min(255, fillColor.r + 40), g: Math.min(255, fillColor.g + 40), b: Math.min(255, fillColor.b + 40), a: 1 };
|
|
1906
|
+
for (let i = 0;i < outlinePoints.length - 1; i++) {
|
|
1907
|
+
const p1 = outlinePoints[i];
|
|
1908
|
+
const p2 = outlinePoints[i + 1];
|
|
1909
|
+
if (Math.abs(p2.x - p1.x) <= 1) {
|
|
1910
|
+
if (p1.y >= plotTop && p1.y <= plotBottom) {
|
|
1911
|
+
canvas.drawChar(p1.x, p1.y, "▄", outlineColor);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
const last = outlinePoints[outlinePoints.length - 1];
|
|
1916
|
+
if (last.y >= plotTop && last.y <= plotBottom) {
|
|
1917
|
+
canvas.drawChar(last.x, last.y, "▄", outlineColor);
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1808
1922
|
function renderGeomTile(data, geom, aes, scales, canvas) {
|
|
1809
1923
|
const alpha = geom.params.alpha ?? 1;
|
|
1810
1924
|
const plotLeft = Math.round(scales.x.range[0]);
|
|
@@ -2243,6 +2357,10 @@ function renderGeom(data, geom, aes, scales, canvas, coordType) {
|
|
|
2243
2357
|
case "violin":
|
|
2244
2358
|
renderGeomViolin(data, geom, aes, scales, canvas);
|
|
2245
2359
|
break;
|
|
2360
|
+
case "ridgeline":
|
|
2361
|
+
case "joy":
|
|
2362
|
+
renderGeomRidgeline(data, geom, aes, scales, canvas);
|
|
2363
|
+
break;
|
|
2246
2364
|
case "tile":
|
|
2247
2365
|
case "raster":
|
|
2248
2366
|
case "bin2d":
|
|
@@ -3351,6 +3469,52 @@ function stat_ydensity(params = {}) {
|
|
|
3351
3469
|
}
|
|
3352
3470
|
};
|
|
3353
3471
|
}
|
|
3472
|
+
function stat_xdensity(params = {}) {
|
|
3473
|
+
return {
|
|
3474
|
+
type: "xdensity",
|
|
3475
|
+
compute(data, aes) {
|
|
3476
|
+
const groups = new Map;
|
|
3477
|
+
const groupOrder = [];
|
|
3478
|
+
for (const row of data) {
|
|
3479
|
+
const groupKey = String(row[aes.y] ?? "default");
|
|
3480
|
+
const xVal = row[aes.x];
|
|
3481
|
+
if (xVal === null || xVal === undefined)
|
|
3482
|
+
continue;
|
|
3483
|
+
const numX = Number(xVal);
|
|
3484
|
+
if (isNaN(numX))
|
|
3485
|
+
continue;
|
|
3486
|
+
if (!groups.has(groupKey)) {
|
|
3487
|
+
groups.set(groupKey, []);
|
|
3488
|
+
groupOrder.push(groupKey);
|
|
3489
|
+
}
|
|
3490
|
+
groups.get(groupKey).push(numX);
|
|
3491
|
+
}
|
|
3492
|
+
const result = [];
|
|
3493
|
+
let groupIndex = 0;
|
|
3494
|
+
for (const groupKey of groupOrder) {
|
|
3495
|
+
const xValues = groups.get(groupKey);
|
|
3496
|
+
if (xValues.length < 2) {
|
|
3497
|
+
groupIndex++;
|
|
3498
|
+
continue;
|
|
3499
|
+
}
|
|
3500
|
+
const tempData = xValues.map((v) => ({ x: v }));
|
|
3501
|
+
const densityResult = computeDensity(tempData, "x", params);
|
|
3502
|
+
for (const d of densityResult) {
|
|
3503
|
+
result.push({
|
|
3504
|
+
x: d.x,
|
|
3505
|
+
y: groupKey,
|
|
3506
|
+
yIndex: groupIndex,
|
|
3507
|
+
density: d.density,
|
|
3508
|
+
scaled: d.scaled,
|
|
3509
|
+
height: d.scaled
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
groupIndex++;
|
|
3513
|
+
}
|
|
3514
|
+
return result;
|
|
3515
|
+
}
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3354
3518
|
|
|
3355
3519
|
// src/stats/smooth.ts
|
|
3356
3520
|
function linearRegression(xs, ys) {
|
|
@@ -4223,6 +4387,14 @@ function applyStatTransform(data, geom, aes) {
|
|
|
4223
4387
|
adjust: geom.params.adjust
|
|
4224
4388
|
});
|
|
4225
4389
|
return ydensityStat.compute(data, aes);
|
|
4390
|
+
} else if (geom.stat === "xdensity") {
|
|
4391
|
+
const xdensityStat = stat_xdensity({
|
|
4392
|
+
bw: geom.params.bw,
|
|
4393
|
+
kernel: geom.params.kernel,
|
|
4394
|
+
n: geom.params.n,
|
|
4395
|
+
adjust: geom.params.adjust
|
|
4396
|
+
});
|
|
4397
|
+
return xdensityStat.compute(data, aes);
|
|
4226
4398
|
} else if (geom.stat === "smooth") {
|
|
4227
4399
|
const smoothStat = stat_smooth({
|
|
4228
4400
|
method: geom.params.method,
|
|
@@ -4345,6 +4517,10 @@ function renderToCanvas(spec, options) {
|
|
|
4345
4517
|
scaleData = applyStatTransform(spec.data, geom, spec.aes);
|
|
4346
4518
|
scaleAes = { ...spec.aes, x: "x", y: "y" };
|
|
4347
4519
|
break;
|
|
4520
|
+
} else if (geom.stat === "xdensity") {
|
|
4521
|
+
scaleData = applyStatTransform(spec.data, geom, spec.aes);
|
|
4522
|
+
scaleAes = { ...spec.aes, x: "x", y: "y" };
|
|
4523
|
+
break;
|
|
4348
4524
|
}
|
|
4349
4525
|
}
|
|
4350
4526
|
scaleData = applyCoordTransform(scaleData, scaleAes, spec.coord);
|
|
@@ -4383,6 +4559,8 @@ function renderToCanvas(spec, options) {
|
|
|
4383
4559
|
geomAes = { ...spec.aes, x: "x", y: "y", fill: "fill" };
|
|
4384
4560
|
} else if (geom.stat === "density_2d") {
|
|
4385
4561
|
geomAes = { ...spec.aes, x: "x", y: "y" };
|
|
4562
|
+
} else if (geom.stat === "xdensity") {
|
|
4563
|
+
geomAes = { ...spec.aes, x: "x", y: "y" };
|
|
4386
4564
|
}
|
|
4387
4565
|
geomData = applyCoordTransform(geomData, geomAes, spec.coord);
|
|
4388
4566
|
}
|
|
@@ -5305,8 +5483,32 @@ function geom_qq_line(options = {}) {
|
|
|
5305
5483
|
};
|
|
5306
5484
|
}
|
|
5307
5485
|
|
|
5486
|
+
// src/geoms/ridgeline.ts
|
|
5487
|
+
function geom_ridgeline(options = {}) {
|
|
5488
|
+
return {
|
|
5489
|
+
type: "ridgeline",
|
|
5490
|
+
stat: "xdensity",
|
|
5491
|
+
position: "identity",
|
|
5492
|
+
params: {
|
|
5493
|
+
scale: options.scale ?? 0.9,
|
|
5494
|
+
alpha: options.alpha ?? 0.8,
|
|
5495
|
+
fill: options.fill,
|
|
5496
|
+
color: options.color,
|
|
5497
|
+
adjust: options.adjust ?? 1,
|
|
5498
|
+
n: options.n ?? 128,
|
|
5499
|
+
outline: options.outline ?? true
|
|
5500
|
+
}
|
|
5501
|
+
};
|
|
5502
|
+
}
|
|
5503
|
+
var geom_joy;
|
|
5504
|
+
var init_ridgeline = __esm(() => {
|
|
5505
|
+
geom_joy = geom_ridgeline;
|
|
5506
|
+
});
|
|
5507
|
+
|
|
5308
5508
|
// src/geoms/index.ts
|
|
5309
|
-
var init_geoms = () => {
|
|
5509
|
+
var init_geoms = __esm(() => {
|
|
5510
|
+
init_ridgeline();
|
|
5511
|
+
});
|
|
5310
5512
|
|
|
5311
5513
|
// src/stats/index.ts
|
|
5312
5514
|
var init_stats = __esm(() => {
|
|
@@ -9815,6 +10017,7 @@ __export(exports_src, {
|
|
|
9815
10017
|
geom_smooth: () => geom_smooth,
|
|
9816
10018
|
geom_segment: () => geom_segment,
|
|
9817
10019
|
geom_rug: () => geom_rug,
|
|
10020
|
+
geom_ridgeline: () => geom_ridgeline,
|
|
9818
10021
|
geom_ribbon: () => geom_ribbon,
|
|
9819
10022
|
geom_rect: () => geom_rect,
|
|
9820
10023
|
geom_raster: () => geom_raster,
|
|
@@ -9826,6 +10029,7 @@ __export(exports_src, {
|
|
|
9826
10029
|
geom_linerange: () => geom_linerange,
|
|
9827
10030
|
geom_line: () => geom_line,
|
|
9828
10031
|
geom_label: () => geom_label,
|
|
10032
|
+
geom_joy: () => geom_joy,
|
|
9829
10033
|
geom_hline: () => geom_hline,
|
|
9830
10034
|
geom_histogram: () => geom_histogram,
|
|
9831
10035
|
geom_freqpoly: () => geom_freqpoly,
|
|
@@ -10061,6 +10265,7 @@ export {
|
|
|
10061
10265
|
geom_smooth,
|
|
10062
10266
|
geom_segment,
|
|
10063
10267
|
geom_rug,
|
|
10268
|
+
geom_ridgeline,
|
|
10064
10269
|
geom_ribbon,
|
|
10065
10270
|
geom_rect,
|
|
10066
10271
|
geom_raster,
|
|
@@ -10072,6 +10277,7 @@ export {
|
|
|
10072
10277
|
geom_linerange,
|
|
10073
10278
|
geom_line,
|
|
10074
10279
|
geom_label,
|
|
10280
|
+
geom_joy,
|
|
10075
10281
|
geom_hline,
|
|
10076
10282
|
geom_histogram,
|
|
10077
10283
|
geom_freqpoly,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline/pipeline.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAA6C,QAAQ,EAAE,aAAa,EAAQ,MAAM,UAAU,CAAA;AACxG,OAAO,EAAE,cAAc,EAAgB,MAAM,kBAAkB,CAAA;AAkB/D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;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AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,aAAa,GACrB,UAAU,CAgEZ;AA8ID;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,aAAa,GACrB,cAAc,CAsMhB;AAwcD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,aAAa,GACrB,MAAM,CASR"}
|
|
@@ -81,6 +81,12 @@ export declare function renderGeomSegment(data: DataSource, geom: Geom, aes: Aes
|
|
|
81
81
|
* Data should be density curves grouped by x
|
|
82
82
|
*/
|
|
83
83
|
export declare function renderGeomViolin(data: DataSource, geom: Geom, _aes: AestheticMapping, scales: ScaleContext, canvas: TerminalCanvas): void;
|
|
84
|
+
/**
|
|
85
|
+
* Render geom_ridgeline (joy plot)
|
|
86
|
+
* Creates stacked density plots for comparing distributions across groups.
|
|
87
|
+
* Data should be density curves grouped by y (categorical)
|
|
88
|
+
*/
|
|
89
|
+
export declare function renderGeomRidgeline(data: DataSource, geom: Geom, aes: AestheticMapping, scales: ScaleContext, canvas: TerminalCanvas): void;
|
|
84
90
|
/**
|
|
85
91
|
* Render geom_tile (heatmap)
|
|
86
92
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-geoms.d.ts","sourceRoot":"","sources":["../../src/pipeline/render-geoms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAQ,MAAM,UAAU,CAAA;AACxE,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,UAAU,CAAA;AAoGhE;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,gBAAgB,EAC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AM,EAAE,YAAY,EACpB,MAAM,EAAE,cAAc,GACrB,IAAI,CAwFN;AA6BD;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,cAAc,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAsFN"}
|
package/dist/stats/density.d.ts
CHANGED
|
@@ -33,4 +33,9 @@ export declare function stat_density(params?: StatDensityParams): Stat;
|
|
|
33
33
|
* Groups data by x aesthetic (categorical) and computes density on y values
|
|
34
34
|
*/
|
|
35
35
|
export declare function stat_ydensity(params?: StatDensityParams): Stat;
|
|
36
|
+
/**
|
|
37
|
+
* Create stat_xdensity transformation for ridgeline plots
|
|
38
|
+
* Groups data by y aesthetic (categorical) and computes density on x values
|
|
39
|
+
*/
|
|
40
|
+
export declare function stat_xdensity(params?: StatDensityParams): Stat;
|
|
36
41
|
//# sourceMappingURL=density.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"density.d.ts","sourceRoot":"","sources":["../../src/stats/density.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAoB,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAElE,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,yFAAyF;IACzF,MAAM,CAAC,EAAE,UAAU,GAAG,cAAc,GAAG,aAAa,CAAA;IACpD,6DAA6D;IAC7D,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AA8CD,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,KA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B,aAAa,CAAC,MAAM,GAAE,iBAAsB,GAAG,IAAI,CA6ClE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,iBAAsB,GAAG,IAAI,CAuDlE"}
|
package/dist/stats/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { stat_count, computeCount } from './count';
|
|
|
9
9
|
export type { StatCountParams, CountResult } from './count';
|
|
10
10
|
export { stat_boxplot, computeBoxplotStats } from './boxplot';
|
|
11
11
|
export type { StatBoxplotParams, BoxplotResult } from './boxplot';
|
|
12
|
-
export { stat_density, stat_ydensity, computeDensity } from './density';
|
|
12
|
+
export { stat_density, stat_ydensity, stat_xdensity, computeDensity } from './density';
|
|
13
13
|
export type { StatDensityParams, DensityResult } from './density';
|
|
14
14
|
export { stat_density_2d, computeDensity2d } from './density2d';
|
|
15
15
|
export type { StatDensity2dParams, Density2dResult } from './density2d';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stats/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC7C,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC7D,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,C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