mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-22 08:28:10 -07:00
website: redesign part 27
This commit is contained in:
@@ -26,7 +26,7 @@ function colorAt(index) {
|
||||
return palette[index % palette.length];
|
||||
}
|
||||
|
||||
/** @param {readonly { label: string, color?: ChartColor, metric: Metric }[]} items */
|
||||
/** @param {readonly { label: string, color?: () => string, metric: ChartMetric }[]} items */
|
||||
export function createCohortSeries(items) {
|
||||
return items.map(({ label, color, metric }, index) => ({
|
||||
label,
|
||||
@@ -38,7 +38,7 @@ export function createCohortSeries(items) {
|
||||
/**
|
||||
* @template {string} Key
|
||||
* @param {readonly (readonly [string, Key])[]} items
|
||||
* @param {(key: Key) => Metric} createMetric
|
||||
* @param {(key: Key) => ChartMetric} createMetric
|
||||
*/
|
||||
export function createCohortSeriesFromKeys(items, createMetric) {
|
||||
return createCohortSeries(
|
||||
@@ -48,6 +48,3 @@ export function createCohortSeriesFromKeys(items, createMetric) {
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
/** @typedef {import("../charts/index.js").ChartSeries["color"]} ChartColor */
|
||||
/** @typedef {import("../charts/index.js").ChartSeries["metric"]} Metric */
|
||||
|
||||
@@ -24,7 +24,7 @@ function createPools(pools) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(window: WindowKey) => TimeframeMetric} createMetric
|
||||
* @param {(window: RollingWindowKey) => TimeframeMetric} createMetric
|
||||
*/
|
||||
function createWindowSeries(createMetric) {
|
||||
return createRollingWindowSeries((window) => () => createMetric(window));
|
||||
@@ -102,7 +102,5 @@ export function createMinorPoolBlocksMinedSeries(pool) {
|
||||
);
|
||||
}
|
||||
|
||||
/** @typedef {import("./rolling-windows.js").RollingWindowKey} WindowKey */
|
||||
/** @typedef {typeof brk.series.pools.major.unknown} MajorPool */
|
||||
/** @typedef {typeof brk.series.pools.minor.blockfills} MinorPool */
|
||||
/** @typedef {import("../charts/timeframes.js").TimeframeMetric} TimeframeMetric */
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { createCohortSeries } from "./cohort-series.js";
|
||||
import { colors } from "../../utils/colors.js";
|
||||
|
||||
const rollingWindows = /** @type {const} */ ([
|
||||
export const rollingWindows = /** @type {const} */ ([
|
||||
["24h", "_24h", colors.sky],
|
||||
["1w", "_1w", colors.cyan],
|
||||
["1m", "_1m", colors.blue],
|
||||
["1y", "_1y", colors.violet],
|
||||
]);
|
||||
|
||||
/** @param {(key: RollingWindowKey) => Metric} createMetric */
|
||||
/** @param {(key: RollingWindowKey) => ChartMetric} createMetric */
|
||||
export function createRollingWindowSeries(createMetric) {
|
||||
return createCohortSeries(
|
||||
rollingWindows.map(([label, key, color]) => ({
|
||||
@@ -18,6 +18,3 @@ export function createRollingWindowSeries(createMetric) {
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
/** @typedef {(typeof rollingWindows)[number][1]} RollingWindowKey */
|
||||
/** @typedef {import("./cohort-series.js").Metric} Metric */
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import { rollingWindows } from "./rolling-windows.js";
|
||||
|
||||
declare global {
|
||||
type RollingWindowKey = (typeof rollingWindows)[number][1];
|
||||
}
|
||||
|
||||
export {};
|
||||
Reference in New Issue
Block a user