diff --git a/website/scripts/_types.js b/website/scripts/_types.js index 704eac9c8..6031921d7 100644 --- a/website/scripts/_types.js +++ b/website/scripts/_types.js @@ -12,6 +12,8 @@ * * @import { Color } from "./utils/colors.js" * + * @import { HeatmapDataSource, HeatmapCells, 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" * * diff --git a/website/scripts/options/types.js b/website/scripts/options/types.js index 4b7b4cc73..e8ea93182 100644 --- a/website/scripts/options/types.js +++ b/website/scripts/options/types.js @@ -107,6 +107,10 @@ * @typedef {Object} PartialHeatmapOptionSpecific * @property {"heatmap"} kind * @property {string} title + * @property {HeatmapDataSource} data + * @property {HeatmapCells} cells + * @property {HeatmapColorFn} color + * @property {HeatmapTooltipFn} [tooltip] * * @typedef {PartialOption & PartialHeatmapOptionSpecific} PartialHeatmapOption * diff --git a/website/src/heatmap/types.js b/website/src/heatmap/types.js new file mode 100644 index 000000000..6c30bd636 --- /dev/null +++ b/website/src/heatmap/types.js @@ -0,0 +1,27 @@ +/** + * @typedef {Object} HeatmapDataSource + * @property {(signal: AbortSignal) => Promise} list + * @property {(date: string, signal: AbortSignal) => Promise} fetch + * + * @typedef {Object} HeatmapCells + * @property {(args: { dates: string[], width: number, height: number }) => unknown} create + * @property {(grid: unknown, dateIndex: number, snapshot: unknown) => number | undefined} add + * @property {(grid: unknown, col: number, row: number) => unknown} getValue + * + * @typedef {Object} HeatmapColorContext + * @property {boolean} dark + * @property {unknown} grid + * @property {number} col + * @property {number} row + * + * @typedef {(value: unknown, context: HeatmapColorContext) => number} HeatmapColorFn + * + * @typedef {Object} HeatmapTooltipContext + * @property {unknown} grid + * @property {number} col + * @property {number} row + * + * @typedef {(context: HeatmapTooltipContext) => string} HeatmapTooltipFn + */ + +export {};