mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-08 14:11:56 -07:00
heatmaps: part 15
This commit is contained in:
@@ -233,21 +233,14 @@ impl Query {
|
||||
let indexer = self.indexer();
|
||||
let safe_height = safe.height.to_usize();
|
||||
let total_outputs = safe.txout_index.to_usize();
|
||||
let first_txout_index = &indexer.vecs.outputs.first_txout_index;
|
||||
|
||||
let out_start = indexer
|
||||
.vecs
|
||||
.outputs
|
||||
.first_txout_index
|
||||
let out_start = first_txout_index
|
||||
.collect_one_at(range.start)
|
||||
.unwrap()
|
||||
.to_usize();
|
||||
let out_end = if range.end < safe_height {
|
||||
indexer
|
||||
.vecs
|
||||
.outputs
|
||||
.first_txout_index
|
||||
.collect_one_at(range.end)
|
||||
.unwrap()
|
||||
first_txout_index.collect_one_at(range.end).unwrap()
|
||||
} else {
|
||||
TxOutIndex::from(total_outputs)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* @import { Color } from "./utils/colors.js"
|
||||
*
|
||||
* @import { HeatmapAxis, HeatmapPointSource, HeatmapGridFactory, HeatmapColorFn, HeatmapTooltipFn } from "../src/heatmap/types.js"
|
||||
* @import { HeatmapAxis, HeatmapDefaults, HeatmapPointSource, HeatmapGridFactory, HeatmapColorFn, HeatmapTooltipFn } from "../src/heatmap/types.js"
|
||||
*
|
||||
* @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, AnySeriesBlueprint, SeriesType, AnyFetchedSeriesBlueprint, ExplorerOption, UrlOption, PartialOptionsGroup, OptionsGroup, PartialOptionsTree, UtxoCohortObject, AddrCohortObject, CohortObject, CohortGroupObject, FetchedLineSeriesBlueprint, FetchedBaselineSeriesBlueprint, FetchedHistogramSeriesBlueprint, FetchedDotsBaselineSeriesBlueprint, PatternAll, PatternFull, PatternWithAdjusted, PatternWithPercentiles, PatternBasic, PatternBasicWithMarketCap, PatternBasicWithoutMarketCap, PatternWithoutRelative, CohortAll, CohortFull, CohortWithAdjusted, CohortWithPercentiles, CohortBasic, CohortBasicWithMarketCap, CohortBasicWithoutMarketCap, CohortWithoutRelative, CohortAddr, CohortLongTerm, CohortAgeRange, CohortAgeRangeWithMatured, CohortGroupFull, CohortGroupWithAdjusted, CohortGroupWithPercentiles, CohortGroupLongTerm, CohortGroupAgeRange, CohortGroupBasic, CohortGroupBasicWithMarketCap, CohortGroupBasicWithoutMarketCap, CohortGroupWithoutRelative, CohortGroupAddr, UtxoCohortGroupObject, AddrCohortGroupObject, FetchedDotsSeriesBlueprint, HeatmapOption, FetchedCandlestickSeriesBlueprint, FetchedPriceSeriesBlueprint, AnyPricePattern, AnyValuePattern } from "./options/partial.js"
|
||||
*
|
||||
|
||||
@@ -111,11 +111,12 @@
|
||||
* @property {HeatmapGridFactory} grid
|
||||
* @property {HeatmapColorFn} color
|
||||
* @property {HeatmapAxis} [axis]
|
||||
* @property {HeatmapDefaults} [defaults]
|
||||
* @property {HeatmapTooltipFn} [tooltip]
|
||||
*
|
||||
* @typedef {PartialOption & PartialHeatmapOptionSpecific} PartialHeatmapOption
|
||||
*
|
||||
* @typedef {Required<Omit<PartialHeatmapOption, "axis" | "tooltip">> & Pick<PartialHeatmapOption, "axis" | "tooltip"> & ProcessedOptionAddons} HeatmapOption
|
||||
* @typedef {PartialHeatmapOption & ProcessedOptionAddons} HeatmapOption
|
||||
*
|
||||
* @typedef {Object} PartialUrlOptionSpecific
|
||||
* @property {"link"} [kind]
|
||||
|
||||
@@ -347,8 +347,20 @@ function updateDateControls(option) {
|
||||
const currentYear = new Date().getUTCFullYear();
|
||||
const fromChoices = createFromChoices(currentYear);
|
||||
const toChoices = createToChoices(currentYear);
|
||||
const defaultFromChoice = fromChoices.at(-1) ?? fromChoices[0];
|
||||
const defaultToChoice = toChoices[0];
|
||||
const fallbackFromChoice = fromChoices.at(-1) ?? fromChoices[0];
|
||||
const fallbackToChoice = toChoices[0];
|
||||
const defaultFromChoice = findChoiceByKey(
|
||||
fromChoices,
|
||||
option.defaults?.from ?? "",
|
||||
fallbackFromChoice,
|
||||
rangeChoiceLabel,
|
||||
);
|
||||
const defaultToChoice = findChoiceByKey(
|
||||
toChoices,
|
||||
option.defaults?.to ?? "",
|
||||
fallbackToChoice,
|
||||
rangeChoiceLabel,
|
||||
);
|
||||
|
||||
const persistedFrom = createHeatmapPersistedValue(
|
||||
option,
|
||||
@@ -437,8 +449,20 @@ function updateYControls(option) {
|
||||
return;
|
||||
}
|
||||
|
||||
const defaultMinChoice = choices[0];
|
||||
const defaultMaxChoice = choices.at(-1) ?? choices[0];
|
||||
const fallbackMinChoice = choices[0];
|
||||
const fallbackMaxChoice = choices.at(-1) ?? choices[0];
|
||||
const defaultMinChoice = findChoiceByKey(
|
||||
choices,
|
||||
String(option.defaults?.yMin ?? ""),
|
||||
fallbackMinChoice,
|
||||
axisChoiceKey,
|
||||
);
|
||||
const defaultMaxChoice = findChoiceByKey(
|
||||
choices,
|
||||
String(option.defaults?.yMax ?? ""),
|
||||
fallbackMaxChoice,
|
||||
axisChoiceKey,
|
||||
);
|
||||
const persistedMin = createHeatmapPersistedValue(
|
||||
option,
|
||||
"y-min",
|
||||
|
||||
@@ -63,6 +63,15 @@ function createOracleHeatmapOption(mode, name) {
|
||||
format: formatAmount,
|
||||
},
|
||||
},
|
||||
defaults:
|
||||
mode === "payments"
|
||||
? {
|
||||
from: "2015",
|
||||
to: "today",
|
||||
yMin: -5,
|
||||
yMax: 2,
|
||||
}
|
||||
: undefined,
|
||||
tooltip: defaultTooltip,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
* @property {number} start
|
||||
* @property {number} end
|
||||
*
|
||||
* @typedef {Object} HeatmapDefaults
|
||||
* @property {string} [from]
|
||||
* @property {string} [to]
|
||||
* @property {number} [yMin]
|
||||
* @property {number} [yMax]
|
||||
*
|
||||
* @typedef {Object} HeatmapGridAddResult
|
||||
* @property {number} col
|
||||
* @property {boolean} maxChanged
|
||||
|
||||
Reference in New Issue
Block a user