mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
website: snapshot
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import {
|
||||
fromSumStatsPattern,
|
||||
fromBaseStatsPattern,
|
||||
fromFullStatsPattern,
|
||||
fromStatsPattern,
|
||||
fromCoinbasePattern,
|
||||
fromValuePattern,
|
||||
fromBitcoinPatternWithUnit,
|
||||
fromCountPattern,
|
||||
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,6 +29,18 @@ 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
|
||||
@@ -38,14 +50,16 @@ export function createContext({ brk }) {
|
||||
return {
|
||||
colors,
|
||||
brk,
|
||||
fromSumStatsPattern: bind(fromSumStatsPattern),
|
||||
// Series helpers (return series arrays for a single chart)
|
||||
fromBaseStatsPattern: bind(fromBaseStatsPattern),
|
||||
fromFullStatsPattern: bind(fromFullStatsPattern),
|
||||
fromStatsPattern: bind(fromStatsPattern),
|
||||
fromCoinbasePattern: bind(fromCoinbasePattern),
|
||||
fromValuePattern,
|
||||
fromBitcoinPatternWithUnit,
|
||||
fromCountPattern,
|
||||
fromSupplyPattern,
|
||||
distributionBtcSatsUsd,
|
||||
// Chart helpers (return chart trees for Sum/Distribution/Cumulative folders)
|
||||
chartsFromFull: bind(chartsFromFull),
|
||||
chartsFromSum: bind(chartsFromSum),
|
||||
chartsFromCount,
|
||||
chartsFromValue,
|
||||
chartsFromValueFull: bind(chartsFromValueFull),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user