MCPcopy Index your code
hub / github.com/microsoft/SandDance / makeDateRange

Function makeDateRange

packages/sanddance/src/date.ts:7–26  ·  view source on GitHub ↗
(tickTexts: VegaDeckGl.types.TickText[], columnStats: ColumnStats)

Source from the content-addressed store, hash-verified

5import { Spec } from 'vega-typings';
6
7export function makeDateRange(tickTexts: VegaDeckGl.types.TickText[], columnStats: ColumnStats) {
8 if (tickTexts.length === 1) {
9 const d3TimeFormat = getD3TimeFormat(columnStats.min, columnStats.max);
10 tickTexts[0].text = vegaTimeFormat([[columnStats.min, columnStats.max]], d3TimeFormat)[0];
11 } else {
12 const d3TimeFormat = getD3TimeFormat(tickTexts[0].value as number, tickTexts[1].value as number);
13 const pairs = tickTexts.map((t, i) => {
14 const min = t.value as number;
15 let max: number;
16 if (i === tickTexts.length - 1) {
17 max = columnStats.max;
18 } else {
19 max = tickTexts[i + 1].value as number;
20 }
21 return [min, max] as [number, number];
22 });
23 const formattedPairs = vegaTimeFormat(pairs, d3TimeFormat);
24 formattedPairs.forEach((formattedPair, i) => tickTexts[i].text = formattedPair);
25 }
26}
27
28const second = 1000;
29const minute = second * 60;

Callers

nothing calls this directly

Calls 3

getD3TimeFormatFunction · 0.85
vegaTimeFormatFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected