website: snapshot

This commit is contained in:
nym21
2026-01-25 20:27:28 +01:00
parent 35bf1afcff
commit fbe99e33cd
6 changed files with 45 additions and 15 deletions

View File

@@ -968,7 +968,6 @@ export function createChainSection(ctx) {
unit: Unit.ratio,
base: 1,
}),
priceLine({ ctx, unit: Unit.ratio, number: 1 }),
],
},
],

View File

@@ -9,7 +9,7 @@ import { line } from "./series.js";
* @param {number} num
* @returns {AnyMetricPattern}
*/
function getConstant(constants, num) {
export function getConstant(constants, num) {
const key =
num >= 0
? `constant${String(num).replace(".", "")}`

View File

@@ -300,17 +300,14 @@ export function createRealizedPriceSeries(list) {
* @returns {AnyFetchedSeriesBlueprint[]}
*/
export function createRealizedPriceRatioSeries(ctx, list) {
return [
...list.map(({ name, tree }) =>
baseline({
metric: tree.realized.realizedPriceExtra.ratio,
name,
unit: Unit.ratio,
base: 1,
}),
),
priceLine({ ctx, unit: Unit.ratio, number: 1 }),
];
return list.map(({ name, tree }) =>
baseline({
metric: tree.realized.realizedPriceExtra.ratio,
name,
unit: Unit.ratio,
base: 1,
}),
);
}
/**

View File

@@ -1106,7 +1106,6 @@ function createSingleBaseSoprChart(ctx, cohort, title) {
defaultActive: false,
base: 1,
}),
priceLine({ ctx, number: 1, unit: Unit.ratio }),
],
};
}

View File

@@ -5,6 +5,8 @@ import { readStored, writeToStorage } from "../utils/storage.js";
import { stringToId } from "../utils/format.js";
import { collect, markUsed, logUnused } from "./unused.js";
import { setQr } from "../panes/share.js";
import { getConstant } from "./constants.js";
import { colors } from "../chart/colors.js";
/**
* @param {BrkClient} brk
@@ -86,6 +88,9 @@ export function initOptions(brk) {
function arrayToMap(arr = []) {
/** @type {Map<Unit, AnyFetchedSeriesBlueprint[]>} */
const map = new Map();
/** @type {Map<Unit, Set<number>>} */
const priceLines = new Map();
for (const blueprint of arr || []) {
if (!blueprint.metric) {
throw new Error(
@@ -101,7 +106,38 @@ export function initOptions(brk) {
map.set(unit, []);
}
map.get(unit)?.push(blueprint);
// Track baseline base values for auto price lines
if (blueprint.type === "Baseline") {
const baseValue = blueprint.options?.baseValue?.price ?? 0;
if (!priceLines.has(unit)) priceLines.set(unit, new Set());
priceLines.get(unit)?.add(baseValue);
}
// Remove from set if manual price line already exists
if (blueprint.type === "Line") {
const path = Object.values(blueprint.metric.by)[0]?.path ?? "";
if (path.includes("constant_")) {
priceLines.get(unit)?.delete(parseFloat(blueprint.title));
}
}
}
// Add price lines at end for remaining values
for (const [unit, values] of priceLines) {
for (const baseValue of values) {
const metric = getConstant(brk.metrics.constants, baseValue);
markUsed(metric);
map.get(unit)?.push({
metric,
title: `${baseValue}`,
color: colors.gray,
unit,
options: { lineStyle: 4, lastValueVisible: false, crosshairMarkerVisible: false },
});
}
}
return map;
}

View File

@@ -41,7 +41,6 @@ export function createOnchainSection(ctx, { indicators, movingAverage }) {
unit: Unit.ratio,
base: 1,
}),
priceLine({ ctx, unit: Unit.ratio, number: 1 }),
],
},
{