mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
website: snapshot
This commit is contained in:
@@ -216,6 +216,22 @@ export const colors = {
|
||||
_200w: fuchsia,
|
||||
_4y: pink,
|
||||
},
|
||||
|
||||
/** Script type colors (oldest to newest) */
|
||||
scriptType: {
|
||||
p2pk65: red,
|
||||
p2pk33: orange,
|
||||
p2pkh: yellow,
|
||||
p2ms: lime,
|
||||
p2sh: green,
|
||||
p2wpkh: teal,
|
||||
p2wsh: blue,
|
||||
p2tr: indigo,
|
||||
p2a: purple,
|
||||
opreturn: pink,
|
||||
unknown: violet,
|
||||
empty: fuchsia,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import {
|
||||
fromBaseStatsPattern,
|
||||
fromStatsPattern,
|
||||
fromSupplyPattern,
|
||||
chartsFromFull,
|
||||
chartsFromSum,
|
||||
chartsFromCount,
|
||||
chartsFromValue,
|
||||
chartsFromValueFull,
|
||||
} from "./series.js";
|
||||
import { colors } from "../chart/colors.js";
|
||||
import { Unit } from "../utils/units.js";
|
||||
|
||||
/**
|
||||
* @template {(arg: any, ...args: any[]) => any} F
|
||||
@@ -29,18 +25,6 @@ const bind = (fn) =>
|
||||
(...args) => fn(colors, ...args)
|
||||
);
|
||||
|
||||
/**
|
||||
* Create distribution series for btc/sats/usd from a value pattern with stats (average + percentiles)
|
||||
* @param {FullValuePattern | SumValuePattern} source
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
const distributionBtcSatsUsd = (source) => [
|
||||
...fromStatsPattern(colors, { pattern: source.bitcoin, unit: Unit.btc }),
|
||||
...fromStatsPattern(colors, { pattern: source.sats, unit: Unit.sats }),
|
||||
...fromStatsPattern(colors, { pattern: source.dollars, unit: Unit.usd }),
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Create a context object with all dependencies for building partial options
|
||||
* @param {Object} args
|
||||
@@ -53,13 +37,9 @@ export function createContext({ brk }) {
|
||||
// Series helpers (return series arrays for a single chart)
|
||||
fromBaseStatsPattern: bind(fromBaseStatsPattern),
|
||||
fromStatsPattern: bind(fromStatsPattern),
|
||||
fromSupplyPattern,
|
||||
distributionBtcSatsUsd,
|
||||
// Chart helpers (return chart trees for Sum/Distribution/Cumulative folders)
|
||||
chartsFromFull: bind(chartsFromFull),
|
||||
chartsFromSum: bind(chartsFromSum),
|
||||
chartsFromCount,
|
||||
chartsFromValue,
|
||||
chartsFromValueFull: bind(chartsFromValueFull),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,13 @@
|
||||
import { Unit } from "../utils/units.js";
|
||||
import { entries, includes } from "../utils/array.js";
|
||||
import { colorAt } from "../chart/colors.js";
|
||||
import { line, baseline, dots, dotted } from "./series.js";
|
||||
import {
|
||||
line,
|
||||
baseline,
|
||||
dots,
|
||||
dotted,
|
||||
distributionBtcSatsUsd,
|
||||
} from "./series.js";
|
||||
import {
|
||||
satsBtcUsd,
|
||||
satsBtcUsdFrom,
|
||||
@@ -47,7 +53,7 @@ const ANTPOOL_AND_FRIENDS_IDS = /** @type {const} */ ([
|
||||
* @returns {PartialOptionsGroup}
|
||||
*/
|
||||
export function createMiningSection(ctx) {
|
||||
const { colors, brk, distributionBtcSatsUsd } = ctx;
|
||||
const { colors, brk } = ctx;
|
||||
const { blocks, transactions, pools } = brk.metrics;
|
||||
|
||||
// Pre-compute pool entries with resolved names
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** Network section - On-chain activity and health */
|
||||
|
||||
import { Unit } from "../utils/units.js";
|
||||
import { includes } from "../utils/array.js";
|
||||
import { priceLine } from "./constants.js";
|
||||
import { line, dots } from "./series.js";
|
||||
import { line, dots, fromSupplyPattern } from "./series.js";
|
||||
import { satsBtcUsd, satsBtcUsdFrom } from "./shared.js";
|
||||
import { spendableTypeColors } from "./colors/index.js";
|
||||
|
||||
/**
|
||||
* Create Network section
|
||||
@@ -17,7 +17,6 @@ export function createNetworkSection(ctx) {
|
||||
brk,
|
||||
fromBaseStatsPattern,
|
||||
fromStatsPattern,
|
||||
fromSupplyPattern,
|
||||
chartsFromFull,
|
||||
chartsFromSum,
|
||||
chartsFromValueFull,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** Series helpers for creating chart series blueprints */
|
||||
|
||||
import { colors } from "../chart/colors.js";
|
||||
import { Unit } from "../utils/units.js";
|
||||
|
||||
// ============================================================================
|
||||
@@ -55,13 +56,55 @@ export function price({
|
||||
function percentileSeries(colors, pattern, unit, title) {
|
||||
const { stat } = colors;
|
||||
return [
|
||||
dots({ metric: pattern.max, name: `${title} max`.trim(), color: stat.max, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.min, name: `${title} min`.trim(), color: stat.min, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.median, name: `${title} median`.trim(), color: stat.median, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct75, name: `${title} pct75`.trim(), color: stat.pct75, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct25, name: `${title} pct25`.trim(), color: stat.pct25, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct90, name: `${title} pct90`.trim(), color: stat.pct90, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct10, name: `${title} pct10`.trim(), color: stat.pct10, unit, defaultActive: false }),
|
||||
dots({
|
||||
metric: pattern.max,
|
||||
name: `${title} max`.trim(),
|
||||
color: stat.max,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.min,
|
||||
name: `${title} min`.trim(),
|
||||
color: stat.min,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.median,
|
||||
name: `${title} median`.trim(),
|
||||
color: stat.median,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct75,
|
||||
name: `${title} pct75`.trim(),
|
||||
color: stat.pct75,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct25,
|
||||
name: `${title} pct25`.trim(),
|
||||
color: stat.pct25,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct90,
|
||||
name: `${title} pct90`.trim(),
|
||||
color: stat.pct90,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct10,
|
||||
name: `${title} pct10`.trim(),
|
||||
color: stat.pct10,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -278,7 +321,12 @@ export function fromBaseStatsPattern(
|
||||
) {
|
||||
const { stat } = colors;
|
||||
return [
|
||||
dots({ metric: pattern.base, name: title || "base", color: baseColor, unit }),
|
||||
dots({
|
||||
metric: pattern.base,
|
||||
name: title || "base",
|
||||
color: baseColor,
|
||||
unit,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.average,
|
||||
name: `${title} avg`.trim(),
|
||||
@@ -311,6 +359,17 @@ export function fromStatsPattern(colors, { pattern, unit, title = "" }) {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create distribution series for btc/sats/usd from a value pattern with stats (average + percentiles)
|
||||
* @param {FullValuePattern | SumValuePattern} source
|
||||
* @returns {AnyFetchedSeriesBlueprint[]}
|
||||
*/
|
||||
export const distributionBtcSatsUsd = (source) => [
|
||||
...fromStatsPattern(colors, { pattern: source.bitcoin, unit: Unit.btc }),
|
||||
...fromStatsPattern(colors, { pattern: source.sats, unit: Unit.sats }),
|
||||
...fromStatsPattern(colors, { pattern: source.dollars, unit: Unit.usd }),
|
||||
];
|
||||
|
||||
/**
|
||||
* Create series from a SupplyPattern (sats/bitcoin/dollars, no sum/cumulative)
|
||||
* @param {Object} args
|
||||
@@ -358,13 +417,55 @@ function distributionSeries(colors, pattern, unit) {
|
||||
const { stat } = colors;
|
||||
return [
|
||||
dots({ metric: pattern.average, name: "avg", color: stat.avg, unit }),
|
||||
dots({ metric: pattern.median, name: "median", color: stat.median, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.max, name: "max", color: stat.max, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.min, name: "min", color: stat.min, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct75, name: "pct75", color: stat.pct75, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct25, name: "pct25", color: stat.pct25, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct90, name: "pct90", color: stat.pct90, unit, defaultActive: false }),
|
||||
dots({ metric: pattern.pct10, name: "pct10", color: stat.pct10, unit, defaultActive: false }),
|
||||
dots({
|
||||
metric: pattern.median,
|
||||
name: "median",
|
||||
color: stat.median,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.max,
|
||||
name: "max",
|
||||
color: stat.max,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.min,
|
||||
name: "min",
|
||||
color: stat.min,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct75,
|
||||
name: "pct75",
|
||||
color: stat.pct75,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct25,
|
||||
name: "pct25",
|
||||
color: stat.pct25,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct90,
|
||||
name: "pct90",
|
||||
color: stat.pct90,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
dots({
|
||||
metric: pattern.pct10,
|
||||
name: "pct10",
|
||||
color: stat.pct10,
|
||||
unit,
|
||||
defaultActive: false,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -379,9 +480,27 @@ function distributionSeries(colors, pattern, unit) {
|
||||
*/
|
||||
function btcSatsUsdSeries({ metrics, name, color, defaultActive }) {
|
||||
return [
|
||||
{ metric: metrics.bitcoin, title: name, color, unit: Unit.btc, defaultActive },
|
||||
{ metric: metrics.sats, title: name, color, unit: Unit.sats, defaultActive },
|
||||
{ metric: metrics.dollars, title: name, color, unit: Unit.usd, defaultActive },
|
||||
{
|
||||
metric: metrics.bitcoin,
|
||||
title: name,
|
||||
color,
|
||||
unit: Unit.btc,
|
||||
defaultActive,
|
||||
},
|
||||
{
|
||||
metric: metrics.sats,
|
||||
title: name,
|
||||
color,
|
||||
unit: Unit.sats,
|
||||
defaultActive,
|
||||
},
|
||||
{
|
||||
metric: metrics.dollars,
|
||||
title: name,
|
||||
color,
|
||||
unit: Unit.usd,
|
||||
defaultActive,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -485,7 +604,11 @@ export function chartsFromValue({ pattern, title, color }) {
|
||||
name: "Sum",
|
||||
title,
|
||||
bottom: btcSatsUsdSeries({
|
||||
metrics: { bitcoin: pattern.bitcoin.sum, sats: pattern.sats.sum, dollars: pattern.dollars.sum },
|
||||
metrics: {
|
||||
bitcoin: pattern.bitcoin.sum,
|
||||
sats: pattern.sats.sum,
|
||||
dollars: pattern.dollars.sum,
|
||||
},
|
||||
name: "sum",
|
||||
color,
|
||||
}),
|
||||
@@ -494,7 +617,11 @@ export function chartsFromValue({ pattern, title, color }) {
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
bottom: btcSatsUsdSeries({
|
||||
metrics: { bitcoin: pattern.bitcoin.cumulative, sats: pattern.sats.cumulative, dollars: pattern.dollars.cumulative },
|
||||
metrics: {
|
||||
bitcoin: pattern.bitcoin.cumulative,
|
||||
sats: pattern.sats.cumulative,
|
||||
dollars: pattern.dollars.cumulative,
|
||||
},
|
||||
name: "all-time",
|
||||
color,
|
||||
}),
|
||||
@@ -517,11 +644,19 @@ export function chartsFromValueFull(colors, { pattern, title }) {
|
||||
title,
|
||||
bottom: [
|
||||
...btcSatsUsdSeries({
|
||||
metrics: { bitcoin: pattern.bitcoin.base, sats: pattern.sats.base, dollars: pattern.dollars.base },
|
||||
metrics: {
|
||||
bitcoin: pattern.bitcoin.base,
|
||||
sats: pattern.sats.base,
|
||||
dollars: pattern.dollars.base,
|
||||
},
|
||||
name: "sum",
|
||||
}),
|
||||
...btcSatsUsdSeries({
|
||||
metrics: { bitcoin: pattern.bitcoin.sum, sats: pattern.sats.sum, dollars: pattern.dollars.sum },
|
||||
metrics: {
|
||||
bitcoin: pattern.bitcoin.sum,
|
||||
sats: pattern.sats.sum,
|
||||
dollars: pattern.dollars.sum,
|
||||
},
|
||||
name: "sum",
|
||||
}),
|
||||
],
|
||||
@@ -539,7 +674,11 @@ export function chartsFromValueFull(colors, { pattern, title }) {
|
||||
name: "Cumulative",
|
||||
title: `${title} (Total)`,
|
||||
bottom: btcSatsUsdSeries({
|
||||
metrics: { bitcoin: pattern.bitcoin.cumulative, sats: pattern.sats.cumulative, dollars: pattern.dollars.cumulative },
|
||||
metrics: {
|
||||
bitcoin: pattern.bitcoin.cumulative,
|
||||
sats: pattern.sats.cumulative,
|
||||
dollars: pattern.dollars.cumulative,
|
||||
},
|
||||
name: "all-time",
|
||||
}),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user