global: snapshot

This commit is contained in:
nym21
2026-03-22 12:19:06 +01:00
parent f731f0d9d0
commit 514fdc40ee
35 changed files with 732 additions and 745 deletions

View File

@@ -115,7 +115,7 @@ function volumeFolder(activity, color, title) {
/**
* @param {{ transferVolume: TransferVolumePattern }} activity
* @param {CountPattern<any>} adjustedTransferVolume
* @param {CountPattern<number>} adjustedTransferVolume
* @param {Color} color
* @param {(name: string) => string} title
* @returns {PartialOptionsGroup}
@@ -171,7 +171,7 @@ function singleRollingSoprTree(ratio, title, prefix = "") {
}
/**
* @param {CountPattern<any>} valueDestroyed
* @param {CountPattern<number>} valueDestroyed
* @param {(name: string) => string} title
* @returns {PartialOptionsTree}
*/
@@ -180,7 +180,7 @@ function valueDestroyedTree(valueDestroyed, title) {
}
/**
* @param {CountPattern<any>} valueDestroyed
* @param {CountPattern<number>} valueDestroyed
* @param {(name: string) => string} title
* @returns {PartialOptionsGroup}
*/
@@ -189,8 +189,8 @@ function valueDestroyedFolder(valueDestroyed, title) {
}
/**
* @param {CountPattern<any>} valueDestroyed
* @param {CountPattern<any>} adjusted
* @param {CountPattern<number>} valueDestroyed
* @param {CountPattern<number>} adjusted
* @param {(name: string) => string} title
* @returns {PartialOptionsGroup}
*/
@@ -471,7 +471,7 @@ function groupedVolumeFolder(list, all, title, getTransferVolume) {
* @param {A} all
* @param {(name: string) => string} title
* @param {(c: T | A) => { sum: Record<string, AnyValuePattern>, cumulative: AnyValuePattern, inProfit: { sum: Record<string, AnyValuePattern>, cumulative: AnyValuePattern }, inLoss: { sum: Record<string, AnyValuePattern>, cumulative: AnyValuePattern } }} getTransferVolume
* @param {(c: T | A) => CountPattern<any>} getAdjustedTransferVolume
* @param {(c: T | A) => CountPattern<number>} getAdjustedTransferVolume
* @returns {PartialOptionsGroup}
*/
function groupedVolumeFolderWithAdjusted(list, all, title, getTransferVolume, getAdjustedTransferVolume) {
@@ -528,7 +528,7 @@ function groupedSoprCharts(list, all, getRatio, title, prefix = "") {
* @param {readonly T[]} list
* @param {A} all
* @param {(name: string) => string} title
* @param {(c: T | A) => CountPattern<any>} getValueDestroyed
* @param {(c: T | A) => CountPattern<number>} getValueDestroyed
* @returns {PartialOptionsTree}
*/
function groupedValueDestroyedTree(list, all, title, getValueDestroyed) {
@@ -546,7 +546,7 @@ function groupedValueDestroyedTree(list, all, title, getValueDestroyed) {
* @param {readonly T[]} list
* @param {A} all
* @param {(name: string) => string} title
* @param {(c: T | A) => CountPattern<any>} getValueDestroyed
* @param {(c: T | A) => CountPattern<number>} getValueDestroyed
* @returns {PartialOptionsGroup}
*/
function groupedValueDestroyedFolder(list, all, title, getValueDestroyed) {
@@ -559,8 +559,8 @@ function groupedValueDestroyedFolder(list, all, title, getValueDestroyed) {
* @param {readonly T[]} list
* @param {A} all
* @param {(name: string) => string} title
* @param {(c: T | A) => CountPattern<any>} getValueDestroyed
* @param {(c: T | A) => CountPattern<any>} getAdjustedValueDestroyed
* @param {(c: T | A) => CountPattern<number>} getValueDestroyed
* @param {(c: T | A) => CountPattern<number>} getAdjustedValueDestroyed
* @returns {PartialOptionsGroup}
*/
function groupedValueDestroyedFolderWithAdjusted(list, all, title, getValueDestroyed, getAdjustedValueDestroyed) {

View File

@@ -100,6 +100,7 @@ function singleDeltaItems(delta, unit, title, name) {
title,
metric: `${name} Change`,
unit,
legend: "Change",
}),
name: "Change",
},

View File

@@ -525,6 +525,7 @@ function singleBucketFolder({ name, color, pattern }, parentName) {
title,
metric: "Supply Change",
unit: Unit.sats,
legend: "Change",
}),
name: "Change",
},
@@ -610,63 +611,32 @@ function groupedBucketCharts(list, groupTitle) {
},
{
name: "Change",
tree: [
{
name: "Compare",
title: title("Supply Change"),
bottom: ROLLING_WINDOWS.flatMap((w) =>
list.map(({ name, color, pattern }) =>
baseline({
series: pattern.supply.all.delta.absolute[w.key],
name: `${name} ${w.name}`,
color,
unit: Unit.sats,
}),
),
),
},
...ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: title(`${w.title} Supply Change`),
bottom: list.map(({ name, color, pattern }) =>
baseline({
series: pattern.supply.all.delta.absolute[w.key],
name,
color,
unit: Unit.sats,
}),
),
})),
],
tree: ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: title(`${w.title} Supply Change`),
bottom: list.map(({ name, color, pattern }) =>
baseline({
series: pattern.supply.all.delta.absolute[w.key],
name,
color,
unit: Unit.sats,
}),
),
})),
},
{
name: "Growth Rate",
tree: [
{
name: "Compare",
title: title("Supply Growth Rate"),
bottom: ROLLING_WINDOWS.flatMap((w) =>
list.flatMap(({ name, color, pattern }) =>
percentRatio({
pattern: pattern.supply.all.delta.rate[w.key],
name: `${name} ${w.name}`,
color,
}),
),
),
},
...ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: title(`${w.title} Supply Growth Rate`),
bottom: list.flatMap(({ name, color, pattern }) =>
percentRatio({
pattern: pattern.supply.all.delta.rate[w.key],
name,
color,
}),
),
})),
],
tree: ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: title(`${w.title} Supply Growth Rate`),
bottom: list.flatMap(({ name, color, pattern }) =>
percentRatio({
pattern: pattern.supply.all.delta.rate[w.key],
name,
color,
}),
),
})),
},
],
},

View File

@@ -31,7 +31,7 @@ export function createPricesSectionFull({ cohort, title }) {
tree: [
{
name: "Compare",
title: title("Prices"),
title: title("Realized Prices"),
top: [
price({ series: tree.realized.price, name: "Realized", color: colors.realized }),
price({ series: tree.realized.investor.price, name: "Investor", color: colors.investor }),

View File

@@ -399,6 +399,7 @@ function realizedNetFolder({ netPnl, title, extraChange = [] }) {
title,
metric: "Net Realized P&L Change",
unit: Unit.usd,
legend: "Change",
}),
name: "Change",
},

View File

@@ -19,7 +19,7 @@ import { ratioBottomSeries, mapCohortsWithAll, flatMapCohortsWithAll } from "../
*/
function singleDeltaItems(tree, title) {
return [
{ ...sumsTreeBaseline({ windows: mapWindows(tree.realized.cap.delta.absolute, (c) => c.usd), title, metric: "Realized Cap Change", unit: Unit.usd }), name: "Change" },
{ ...sumsTreeBaseline({ windows: mapWindows(tree.realized.cap.delta.absolute, (c) => c.usd), title, metric: "Realized Cap Change", unit: Unit.usd, legend: "Change" }), name: "Change" },
{ ...rollingPercentRatioTree({ windows: tree.realized.cap.delta.rate, title, metric: "Realized Cap Growth Rate" }), name: "Growth Rate" },
];
}

View File

@@ -135,7 +135,7 @@ function createCompareFolder(context, items) {
},
{
name: "Accumulated",
title: `Accumulated Value: ${context}`,
title: `Accumulated Value ($100/day): ${context}`,
top: topPane,
bottom: items.flatMap(({ name, color, stack }) =>
satsBtcUsd({ pattern: stack, name, color }),
@@ -188,7 +188,7 @@ function createLongCompareFolder(context, items) {
},
{
name: "Accumulated",
title: `Accumulated Value: ${context}`,
title: `Accumulated Value ($100/day): ${context}`,
top: topPane,
bottom: items.flatMap(({ name, color, stack }) =>
satsBtcUsd({ pattern: stack, name, color }),
@@ -218,7 +218,7 @@ function createSingleEntryTree(item, returnsBottom) {
},
{
name: "Accumulated",
title: `Accumulated Value: ${titlePrefix}`,
title: `Accumulated Value ($100/day): ${titlePrefix}`,
top,
bottom: satsBtcUsd({ pattern: stack, name: "Value" }),
},
@@ -259,7 +259,7 @@ function createLongSingleEntry(item) {
},
{
name: "Accumulated",
title: `Accumulated Value: ${titlePrefix}`,
title: `Accumulated Value ($100/day): ${titlePrefix}`,
top,
bottom: satsBtcUsd({ pattern: stack, name: "Value" }),
},

View File

@@ -122,7 +122,7 @@ function returnsSubSection(name, periods) {
tree: [
{
name: "Compare",
title: `${name} Returns`,
title: `${name} Price Returns`,
bottom: periods.flatMap((p) =>
percentRatioBaseline({
pattern: p.returns,
@@ -133,8 +133,8 @@ function returnsSubSection(name, periods) {
},
...periods.map((p) => ({
name: periodIdToName(p.id, true),
title: `${periodIdToName(p.id, true)} Returns`,
bottom: percentRatioBaseline({ pattern: p.returns, name: "Total" }),
title: `${periodIdToName(p.id, true)} Price Returns`,
bottom: percentRatioBaseline({ pattern: p.returns, name: "Return" }),
})),
],
};
@@ -153,7 +153,7 @@ function returnsSubSectionWithCagr(name, periods) {
tree: [
{
name: "Compare",
title: `${name} Total Returns`,
title: `${name} Total Price Returns`,
bottom: periods.flatMap((p) =>
percentRatioBaseline({
pattern: p.returns,
@@ -164,8 +164,8 @@ function returnsSubSectionWithCagr(name, periods) {
},
...periods.map((p) => ({
name: periodIdToName(p.id, true),
title: `${periodIdToName(p.id, true)} Total Returns`,
bottom: percentRatioBaseline({ pattern: p.returns, name: "Total" }),
title: `${periodIdToName(p.id, true)} Total Price Returns`,
bottom: percentRatioBaseline({ pattern: p.returns, name: "Return" }),
})),
],
},
@@ -174,7 +174,7 @@ function returnsSubSectionWithCagr(name, periods) {
tree: [
{
name: "Compare",
title: `${name} CAGR`,
title: `${name} Price CAGR`,
bottom: periods.flatMap((p) =>
percentRatioBaseline({
pattern: p.cagr,
@@ -185,7 +185,7 @@ function returnsSubSectionWithCagr(name, periods) {
},
...periods.map((p) => ({
name: periodIdToName(p.id, true),
title: `${periodIdToName(p.id, true)} CAGR`,
title: `${periodIdToName(p.id, true)} Price CAGR`,
bottom: percentRatioBaseline({ pattern: p.cagr, name: "CAGR" }),
})),
],
@@ -469,7 +469,7 @@ export function createMarketSection() {
tree: [
{
name: "Compare",
title: "Returns Comparison",
title: "Price Returns",
bottom: [...shortPeriods, ...longPeriods].flatMap((p) =>
percentRatioBaseline({
pattern: p.returns,
@@ -490,7 +490,7 @@ export function createMarketSection() {
tree: [
{
name: "Compare",
title: "Historical Price Comparison",
title: "Historical Prices",
top: [...shortPeriods, ...longPeriods].map((p) =>
price({
series: p.lookback,
@@ -592,7 +592,7 @@ export function createMarketSection() {
bottom: [
baseline({
series: supply.marketMinusRealizedCapGrowthRate[w.key],
name: w.name,
name: "Spread",
unit: Unit.percentage,
}),
],
@@ -615,7 +615,7 @@ export function createMarketSection() {
tree: [
{
name: "All Periods",
title: "SMA vs EMA Comparison",
title: "SMA vs EMA",
top: smaVsEma.flatMap((p) => [
price({
series: p.sma,
@@ -659,7 +659,7 @@ export function createMarketSection() {
tree: [
{
name: "Compare",
title: "RSI Comparison",
title: "RSI",
bottom: [
...ROLLING_WINDOWS_TO_1M.flatMap((w) =>
indexRatio({
@@ -726,7 +726,7 @@ export function createMarketSection() {
tree: [
{
name: "Compare",
title: "MACD Comparison",
title: "MACD",
bottom: ROLLING_WINDOWS_TO_1M.map((w) =>
line({
series: technical.macd[w.key].line,
@@ -789,7 +789,7 @@ export function createMarketSection() {
bottom: [
line({
series: volatility[w.key],
name: w.name,
name: "Volatility",
color: w.color,
unit: Unit.percentage,
}),

View File

@@ -80,7 +80,7 @@ export function createMiningSection() {
/**
* @param {(metric: string) => string} title
* @param {string} metric
* @param {{ _24h: any, _1w: any, _1m: any, _1y: any, percent: any, ratio: any }} dominance
* @param {DominancePattern} dominance
*/
const dominanceTree = (title, metric, dominance) => ({
name: "Dominance",
@@ -98,12 +98,12 @@ export function createMiningSection() {
...ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: title(`${w.title} ${metric}`),
bottom: percentRatio({ pattern: dominance[w.key], name: w.name, color: w.color }),
bottom: percentRatio({ pattern: dominance[w.key], name: "Dominance", color: w.color }),
})),
{
name: "All Time",
title: title(`${metric} All Time`),
bottom: percentRatio({ pattern: dominance, name: "All Time", color: colors.time.all }),
title: title(`All Time ${metric}`),
bottom: percentRatio({ pattern: dominance, name: "Dominance", color: colors.time.all }),
},
],
});
@@ -251,7 +251,7 @@ export function createMiningSection() {
}),
dotted({
series: blocks.difficulty.hashrate,
name: "Difficulty",
name: "From Difficulty",
color: colors.default,
unit: Unit.hashRate,
}),
@@ -395,25 +395,25 @@ export function createMiningSection() {
name: "Hash Price",
title: "Hash Price",
bottom: [
line({ series: mining.hashrate.price.ths, name: "TH/s", color: colors.usd, unit: Unit.usdPerThsPerDay }),
line({ series: mining.hashrate.price.phs, name: "PH/s", color: colors.usd, unit: Unit.usdPerPhsPerDay }),
dotted({ series: mining.hashrate.price.thsMin, name: "TH/s ATL", color: colors.stat.min, unit: Unit.usdPerThsPerDay }),
dotted({ series: mining.hashrate.price.phsMin, name: "PH/s ATL", color: colors.stat.min, unit: Unit.usdPerPhsPerDay }),
line({ series: mining.hashrate.price.ths, name: "per TH/s", color: colors.usd, unit: Unit.usdPerThsPerDay }),
line({ series: mining.hashrate.price.phs, name: "per PH/s", color: colors.usd, unit: Unit.usdPerPhsPerDay }),
dotted({ series: mining.hashrate.price.thsMin, name: "per TH/s ATL", color: colors.stat.min, unit: Unit.usdPerThsPerDay }),
dotted({ series: mining.hashrate.price.phsMin, name: "per PH/s ATL", color: colors.stat.min, unit: Unit.usdPerPhsPerDay }),
],
},
{
name: "Hash Value",
title: "Hash Value",
bottom: [
line({ series: mining.hashrate.value.ths, name: "TH/s", color: colors.bitcoin, unit: Unit.satsPerThsPerDay }),
line({ series: mining.hashrate.value.phs, name: "PH/s", color: colors.bitcoin, unit: Unit.satsPerPhsPerDay }),
dotted({ series: mining.hashrate.value.thsMin, name: "TH/s ATL", color: colors.stat.min, unit: Unit.satsPerThsPerDay }),
dotted({ series: mining.hashrate.value.phsMin, name: "PH/s ATL", color: colors.stat.min, unit: Unit.satsPerPhsPerDay }),
line({ series: mining.hashrate.value.ths, name: "per TH/s", color: colors.bitcoin, unit: Unit.satsPerThsPerDay }),
line({ series: mining.hashrate.value.phs, name: "per PH/s", color: colors.bitcoin, unit: Unit.satsPerPhsPerDay }),
dotted({ series: mining.hashrate.value.thsMin, name: "per TH/s ATL", color: colors.stat.min, unit: Unit.satsPerThsPerDay }),
dotted({ series: mining.hashrate.value.phsMin, name: "per PH/s ATL", color: colors.stat.min, unit: Unit.satsPerPhsPerDay }),
],
},
{
name: "Recovery",
title: "Mining Recovery",
title: "Hash Price & Value Recovery",
bottom: [
...percentRatio({ pattern: mining.hashrate.price.rebound, name: "Hash Price", color: colors.usd }),
...percentRatio({ pattern: mining.hashrate.value.rebound, name: "Hash Value", color: colors.bitcoin }),

View File

@@ -19,7 +19,7 @@ import {
multiSeriesTree,
percentRatioDots,
} from "./series.js";
import { satsBtcUsd, satsBtcUsdFrom, satsBtcUsdFullTree } from "./shared.js";
import { satsBtcUsd, satsBtcUsdFrom, satsBtcUsdFullTree, formatCohortTitle } from "./shared.js";
/**
* Create Network section
@@ -114,15 +114,17 @@ export function createNetworkSection() {
/**
* @param {AddressableType | "all"} key
* @param {string} titlePrefix
* @param {string} [typeName]
*/
const createAddressSeriesTree = (key, titlePrefix) => [
const createAddressSeriesTree = (key, typeName) => {
const title = formatCohortTitle(typeName);
return [
{
name: "Count",
tree: [
{
name: "Compare",
title: `${titlePrefix}Address Count`,
title: title("Address Count"),
bottom: countMetrics.map((m) =>
line({
series: addrs[m.key][key],
@@ -134,7 +136,7 @@ export function createNetworkSection() {
},
...countMetrics.map((m) => ({
name: m.name,
title: `${titlePrefix}${m.name} Addresses`,
title: title(`${m.name} Addresses`),
bottom: [
line({ series: addrs[m.key][key], name: m.name, unit: Unit.count }),
],
@@ -143,7 +145,7 @@ export function createNetworkSection() {
},
...simpleDeltaTree({
delta: addrs.delta[key],
title: (s) => `${titlePrefix}${s}`,
title,
metric: "Address Count",
unit: Unit.count,
}),
@@ -151,7 +153,7 @@ export function createNetworkSection() {
name: "New",
tree: chartsFromCount({
pattern: addrs.new[key],
title: (s) => `${titlePrefix}${s}`,
title,
metric: "New Addresses",
unit: Unit.count,
}),
@@ -163,7 +165,7 @@ export function createNetworkSection() {
name: "Compare",
tree: ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: `${w.title} ${titlePrefix}Active Addresses`,
title: title(`${w.title} Active Addresses`),
bottom: activityTypes.map((t, i) =>
line({
series: addrs.activity[key][t.key][w.key],
@@ -178,7 +180,7 @@ export function createNetworkSection() {
name: t.name,
tree: averagesArray({
windows: addrs.activity[key][t.key],
title: (s) => `${titlePrefix}${s}`,
title,
metric: `${t.name} Addresses`,
unit: Unit.count,
}),
@@ -186,6 +188,7 @@ export function createNetworkSection() {
],
},
];
};
/** @type {Record<string, typeof scriptTypes[number]>} */
const byKey = Object.fromEntries(scriptTypes.map((t) => [t.key, t]));
@@ -560,7 +563,7 @@ export function createNetworkSection() {
{
name: "Addresses",
tree: [
...createAddressSeriesTree("all", ""),
...createAddressSeriesTree("all"),
{
name: "By Type",
tree: [
@@ -582,7 +585,7 @@ export function createNetworkSection() {
},
...addressTypes.map((t) => ({
name: t.name,
tree: createAddressSeriesTree(t.key, `${t.name} `),
tree: createAddressSeriesTree(t.key, t.name),
})),
],
},

View File

@@ -398,8 +398,8 @@ export function histogram({
/**
* Create series from an AverageHeightMaxMedianMinP10P25P75P90Pattern (height + rolling stats)
* @param {Object} args
* @param {{ height: AnySeriesPattern } & Record<string, any>} args.pattern - Pattern with .height and rolling stats (p10/p25/p75/p90 as _1y24h30d7dPattern)
* @param {string} args.window - Rolling window key (e.g., '_24h', '_7d', '_30d', '_1y')
* @param {{ height: AnySeriesPattern } & WindowedStats<AnySeriesPattern>} args.pattern - Pattern with .height and rolling stats
* @param {string} args.window - Rolling window key (e.g., '_24h', '_1w', '_1m', '_1y')
* @param {Unit} args.unit
* @param {string} [args.title]
* @param {Color} [args.baseColor]
@@ -417,7 +417,7 @@ export function fromBaseStatsPattern({
return [
dots({
series: pattern.height,
name: title || "base",
name: title || "Base",
color: baseColor,
unit,
}),
@@ -427,8 +427,10 @@ export function fromBaseStatsPattern({
/**
* Extract stats at a specific rolling window
* @param {Record<string, any>} pattern - Pattern with pct10/pct25/pct75/pct90 and median/max/min as _1y24h30d7dPattern
* @template T
* @param {WindowedStats<T>} pattern - Pattern with pct10/pct25/pct75/pct90 and median/max/min at each rolling window
* @param {string} window
* @returns {{ median: T, max: T, min: T, pct75: T, pct25: T, pct90: T, pct10: T }}
*/
export function statsAtWindow(pattern, window) {
return {
@@ -450,6 +452,7 @@ export function statsAtWindow(pattern, window) {
* @param {(w: typeof ROLLING_WINDOWS[number]) => string} args.windowTitle
* @param {Unit} args.unit
* @param {string} args.name
* @param {string} args.legend
* @returns {PartialOptionsGroup}
*/
function rollingWindowsTreeBaseline({
@@ -458,6 +461,7 @@ function rollingWindowsTreeBaseline({
windowTitle,
unit,
name,
legend,
}) {
return {
name,
@@ -477,7 +481,7 @@ function rollingWindowsTreeBaseline({
...ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: windowTitle(w),
bottom: [baseline({ series: windows[w.key], name: w.name, unit })],
bottom: [baseline({ series: windows[w.key], name: legend, unit })],
})),
],
};
@@ -605,15 +609,17 @@ export function sumsAndAveragesCumulative({
* @param {(metric: string) => string} [args.title]
* @param {string} args.metric
* @param {Unit} args.unit
* @param {string} [args.legend]
* @returns {PartialOptionsGroup}
*/
export function sumsTreeBaseline({ windows, title = (s) => s, metric, unit }) {
export function sumsTreeBaseline({ windows, title = (s) => s, metric, unit, legend = "Sum" }) {
return rollingWindowsTreeBaseline({
windows,
title: title(metric),
windowTitle: (w) => title(`${w.title} ${metric}`),
unit,
name: "Sums",
legend,
});
}
@@ -639,16 +645,16 @@ export function averagesArray({ windows, title = (s) => s, metric, unit }) {
name: w.name,
title: title(`${w.title} ${metric}`),
bottom: [
line({ series: windows[w.key], name: w.name, color: w.color, unit }),
line({ series: windows[w.key], name: "Average", color: w.color, unit }),
],
})),
];
}
/**
* Create a Distribution folder tree with stats at each rolling window (24h/7d/30d/1y)
* Create a Distribution folder tree with stats at each rolling window (24h/1w/1m/1y)
* @param {Object} args
* @param {Record<string, any>} args.pattern - Pattern with pct10/pct25/... and average/median/... as _1y24h30d7dPattern
* @param {WindowedStats<AnySeriesPattern>} args.pattern - Pattern with pct10/pct25/... and average/median/... at each rolling window
* @param {AnySeriesPattern} [args.base] - Optional base series to show as dots on each chart
* @param {(metric: string) => string} [args.title]
* @param {string} args.metric
@@ -675,7 +681,7 @@ export function distributionWindowsTree({ pattern, base, title = (s) => s, metri
name: w.name,
title: title(`${w.title} ${metric} Distribution`),
bottom: [
...(base ? [line({ series: base, name: "base", unit })] : []),
...(base ? [line({ series: base, name: "Base", unit })] : []),
...percentileSeries({ pattern: statsAtWindow(pattern, w.key), unit }),
],
})),
@@ -871,7 +877,7 @@ export function rollingPercentRatioTree({
...ROLLING_WINDOWS.map((w) => ({
name: w.name,
title: title(`${w.title} ${metric}`),
bottom: percentRatioBaseline({ pattern: windows[w.key], name: w.name }),
bottom: percentRatioBaseline({ pattern: windows[w.key], name: "Rate" }),
})),
],
};
@@ -911,7 +917,7 @@ export function deltaTree({ delta, title = (s) => s, metric, unit, extract }) {
bottom: [
baseline({
series: extract(delta.absolute[w.key]),
name: w.name,
name: "Change",
unit,
}),
],
@@ -1068,7 +1074,7 @@ export function chartsFromBlockAnd6b({ pattern, title = (s) => s, metric, unit }
/**
* Averages + Sums + Cumulative charts
* @param {Object} args
* @param {CountPattern<any>} args.pattern
* @param {CountPattern<number>} args.pattern
* @param {(metric: string) => string} [args.title]
* @param {string} args.metric
* @param {Unit} args.unit
@@ -1090,7 +1096,7 @@ export function chartsFromCount({ pattern, title = (s) => s, metric, unit, color
/**
* Windowed sums + cumulative for multiple named entries (e.g. transaction versions)
* @param {Object} args
* @param {Array<[string, CountPattern<any>]>} args.entries
* @param {Array<[string, CountPattern<number>]>} args.entries
* @param {(metric: string) => string} [args.title]
* @param {string} args.metric
* @param {Unit} args.unit

View File

@@ -203,7 +203,7 @@ export function revenueBtcSatsUsd({ coinbase, subsidy, fee, key }) {
}
/**
* Create sats/btc/usd series from a rolling window (24h/7d/30d/1y sum)
* Create sats/btc/usd series from a rolling window (24h/1w/1m/1y sum)
* @param {Object} args
* @param {AnyValuePattern} args.pattern - A BtcSatsUsdPattern (e.g., source.rolling._24h.sum)
* @param {string} args.name
@@ -540,14 +540,15 @@ export function ratioBottomSeries(ratio) {
* @param {AnyRatioPattern} args.ratio
* @param {Color} args.color
* @param {string} [args.name]
* @param {string} [args.legend]
* @returns {PartialChartOption}
*/
export function createRatioChart({ title, pricePattern, ratio, color, name }) {
export function createRatioChart({ title, pricePattern, ratio, color, name, legend }) {
return {
name: name ?? "Ratio",
title: title(name ?? "Ratio"),
top: [
price({ series: pricePattern, name: "Price", color }),
price({ series: pricePattern, name: legend ?? "Price", color }),
...percentileUsdMap(ratio).map(({ name, prop, color }) =>
price({
series: prop,
@@ -742,6 +743,7 @@ export function createPriceRatioCharts({
pricePattern,
ratio,
color,
legend,
}),
createZScoresFolder({
formatTitle: (name) =>

View File

@@ -100,9 +100,10 @@ export function logUnused(seriesTree, partialOptions) {
if (!all.size) return;
/** @type {Record<string, any>} */
/** @type {Record<string, unknown>} */
const tree = {};
for (const path of all.values()) {
/** @type {Record<string, unknown>} */
let current = tree;
for (let i = 0; i < path.length; i++) {
const part = path[i];
@@ -110,7 +111,7 @@ export function logUnused(seriesTree, partialOptions) {
current[part] = null;
} else {
current[part] = current[part] || {};
current = current[part];
current = /** @type {Record<string, unknown>} */ (current[part]);
}
}
}