@matthieumordrel/chart-studio 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/chart-capabilities.d.mts +48 -0
- package/dist/core/chart-capabilities.mjs +55 -0
- package/dist/core/{colors.d.ts → colors.d.mts} +5 -3
- package/dist/core/colors.mjs +55 -0
- package/dist/core/config-utils.mjs +79 -0
- package/dist/core/date-utils.mjs +49 -0
- package/dist/core/define-chart-schema.d.mts +106 -0
- package/dist/core/define-chart-schema.mjs +47 -0
- package/dist/core/formatting.mjs +349 -0
- package/dist/core/infer-columns.d.mts +9 -0
- package/dist/core/infer-columns.mjs +481 -0
- package/dist/core/metric-utils.d.mts +13 -0
- package/dist/core/metric-utils.mjs +121 -0
- package/dist/core/pipeline-data-points.mjs +212 -0
- package/dist/core/pipeline-helpers.mjs +85 -0
- package/dist/core/{pipeline.d.ts → pipeline.d.mts} +21 -24
- package/dist/core/pipeline.mjs +153 -0
- package/dist/core/types.d.mts +957 -0
- package/dist/core/use-chart-options.d.mts +64 -0
- package/dist/core/use-chart-options.mjs +7 -0
- package/dist/core/use-chart-resolvers.mjs +34 -0
- package/dist/core/{use-chart.d.ts → use-chart.d.mts} +12 -9
- package/dist/core/use-chart.mjs +299 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +8 -0
- package/dist/ui/chart-axis-ticks.mjs +65 -0
- package/dist/ui/{chart-canvas.d.ts → chart-canvas.d.mts} +13 -6
- package/dist/ui/chart-canvas.mjs +461 -0
- package/dist/ui/chart-context.d.mts +92 -0
- package/dist/ui/chart-context.mjs +112 -0
- package/dist/ui/{chart-date-range-badge.d.ts → chart-date-range-badge.d.mts} +10 -4
- package/dist/ui/chart-date-range-badge.mjs +49 -0
- package/dist/ui/chart-date-range-panel.d.mts +18 -0
- package/dist/ui/chart-date-range-panel.mjs +208 -0
- package/dist/ui/{chart-date-range.d.ts → chart-date-range.d.mts} +10 -4
- package/dist/ui/chart-date-range.mjs +67 -0
- package/dist/ui/chart-debug.d.mts +17 -0
- package/dist/ui/chart-debug.mjs +169 -0
- package/dist/ui/chart-dropdown.mjs +92 -0
- package/dist/ui/{chart-filters-panel.d.ts → chart-filters-panel.d.mts} +12 -5
- package/dist/ui/chart-filters-panel.mjs +132 -0
- package/dist/ui/{chart-filters.d.ts → chart-filters.d.mts} +10 -4
- package/dist/ui/chart-filters.mjs +48 -0
- package/dist/ui/chart-group-by-selector.d.mts +14 -0
- package/dist/ui/chart-group-by-selector.mjs +29 -0
- package/dist/ui/{chart-metric-panel.d.ts → chart-metric-panel.d.mts} +12 -5
- package/dist/ui/chart-metric-panel.mjs +172 -0
- package/dist/ui/chart-metric-selector.d.mts +16 -0
- package/dist/ui/chart-metric-selector.mjs +50 -0
- package/dist/ui/chart-select.mjs +62 -0
- package/dist/ui/{chart-source-switcher.d.ts → chart-source-switcher.d.mts} +10 -4
- package/dist/ui/chart-source-switcher.mjs +54 -0
- package/dist/ui/chart-time-bucket-selector.d.mts +15 -0
- package/dist/ui/chart-time-bucket-selector.mjs +34 -0
- package/dist/ui/chart-toolbar-overflow.d.mts +28 -0
- package/dist/ui/chart-toolbar-overflow.mjs +209 -0
- package/dist/ui/chart-toolbar.d.mts +29 -0
- package/dist/ui/chart-toolbar.mjs +56 -0
- package/dist/ui/chart-type-selector.d.mts +14 -0
- package/dist/ui/chart-type-selector.mjs +33 -0
- package/dist/ui/chart-x-axis-selector.d.mts +14 -0
- package/dist/ui/chart-x-axis-selector.mjs +25 -0
- package/dist/ui/index.d.mts +19 -0
- package/dist/ui/index.mjs +18 -0
- package/dist/ui/toolbar-types.d.mts +7 -0
- package/dist/ui/toolbar-types.mjs +83 -0
- package/package.json +11 -10
- package/dist/core/chart-capabilities.d.ts +0 -60
- package/dist/core/chart-capabilities.d.ts.map +0 -1
- package/dist/core/chart-capabilities.js +0 -54
- package/dist/core/colors.d.ts.map +0 -1
- package/dist/core/colors.js +0 -54
- package/dist/core/config-utils.d.ts +0 -43
- package/dist/core/config-utils.d.ts.map +0 -1
- package/dist/core/config-utils.js +0 -80
- package/dist/core/date-utils.d.ts +0 -29
- package/dist/core/date-utils.d.ts.map +0 -1
- package/dist/core/date-utils.js +0 -58
- package/dist/core/define-chart-schema.d.ts +0 -105
- package/dist/core/define-chart-schema.d.ts.map +0 -1
- package/dist/core/define-chart-schema.js +0 -44
- package/dist/core/formatting.d.ts +0 -47
- package/dist/core/formatting.d.ts.map +0 -1
- package/dist/core/formatting.js +0 -396
- package/dist/core/index.d.ts +0 -17
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -12
- package/dist/core/infer-columns.d.ts +0 -6
- package/dist/core/infer-columns.d.ts.map +0 -1
- package/dist/core/infer-columns.js +0 -512
- package/dist/core/metric-utils.d.ts +0 -43
- package/dist/core/metric-utils.d.ts.map +0 -1
- package/dist/core/metric-utils.js +0 -141
- package/dist/core/pipeline-data-points.d.ts +0 -23
- package/dist/core/pipeline-data-points.d.ts.map +0 -1
- package/dist/core/pipeline-data-points.js +0 -235
- package/dist/core/pipeline-helpers.d.ts +0 -38
- package/dist/core/pipeline-helpers.d.ts.map +0 -1
- package/dist/core/pipeline-helpers.js +0 -97
- package/dist/core/pipeline.d.ts.map +0 -1
- package/dist/core/pipeline.js +0 -156
- package/dist/core/types.d.ts +0 -1109
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -14
- package/dist/core/use-chart-options.d.ts +0 -66
- package/dist/core/use-chart-options.d.ts.map +0 -1
- package/dist/core/use-chart-options.js +0 -4
- package/dist/core/use-chart-resolvers.d.ts +0 -14
- package/dist/core/use-chart-resolvers.d.ts.map +0 -1
- package/dist/core/use-chart-resolvers.js +0 -41
- package/dist/core/use-chart.d.ts.map +0 -1
- package/dist/core/use-chart.js +0 -265
- package/dist/index.d.ts +0 -36
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -35
- package/dist/ui/chart-axis-ticks.d.ts +0 -35
- package/dist/ui/chart-axis-ticks.d.ts.map +0 -1
- package/dist/ui/chart-axis-ticks.js +0 -79
- package/dist/ui/chart-canvas.d.ts.map +0 -1
- package/dist/ui/chart-canvas.js +0 -337
- package/dist/ui/chart-context.d.ts +0 -89
- package/dist/ui/chart-context.d.ts.map +0 -1
- package/dist/ui/chart-context.js +0 -128
- package/dist/ui/chart-date-range-badge.d.ts.map +0 -1
- package/dist/ui/chart-date-range-badge.js +0 -30
- package/dist/ui/chart-date-range-panel.d.ts +0 -25
- package/dist/ui/chart-date-range-panel.d.ts.map +0 -1
- package/dist/ui/chart-date-range-panel.js +0 -125
- package/dist/ui/chart-date-range.d.ts.map +0 -1
- package/dist/ui/chart-date-range.js +0 -37
- package/dist/ui/chart-debug.d.ts +0 -10
- package/dist/ui/chart-debug.d.ts.map +0 -1
- package/dist/ui/chart-debug.js +0 -126
- package/dist/ui/chart-dropdown.d.ts +0 -35
- package/dist/ui/chart-dropdown.d.ts.map +0 -1
- package/dist/ui/chart-dropdown.js +0 -76
- package/dist/ui/chart-filters-panel.d.ts.map +0 -1
- package/dist/ui/chart-filters-panel.js +0 -46
- package/dist/ui/chart-filters.d.ts.map +0 -1
- package/dist/ui/chart-filters.js +0 -26
- package/dist/ui/chart-group-by-selector.d.ts +0 -8
- package/dist/ui/chart-group-by-selector.d.ts.map +0 -1
- package/dist/ui/chart-group-by-selector.js +0 -19
- package/dist/ui/chart-metric-panel.d.ts.map +0 -1
- package/dist/ui/chart-metric-panel.js +0 -118
- package/dist/ui/chart-metric-selector.d.ts +0 -10
- package/dist/ui/chart-metric-selector.d.ts.map +0 -1
- package/dist/ui/chart-metric-selector.js +0 -27
- package/dist/ui/chart-select.d.ts +0 -25
- package/dist/ui/chart-select.d.ts.map +0 -1
- package/dist/ui/chart-select.js +0 -35
- package/dist/ui/chart-source-switcher.d.ts.map +0 -1
- package/dist/ui/chart-source-switcher.js +0 -31
- package/dist/ui/chart-time-bucket-selector.d.ts +0 -9
- package/dist/ui/chart-time-bucket-selector.d.ts.map +0 -1
- package/dist/ui/chart-time-bucket-selector.js +0 -25
- package/dist/ui/chart-toolbar-overflow.d.ts +0 -29
- package/dist/ui/chart-toolbar-overflow.d.ts.map +0 -1
- package/dist/ui/chart-toolbar-overflow.js +0 -109
- package/dist/ui/chart-toolbar.d.ts +0 -45
- package/dist/ui/chart-toolbar.d.ts.map +0 -1
- package/dist/ui/chart-toolbar.js +0 -44
- package/dist/ui/chart-type-selector.d.ts +0 -8
- package/dist/ui/chart-type-selector.d.ts.map +0 -1
- package/dist/ui/chart-type-selector.js +0 -22
- package/dist/ui/chart-x-axis-selector.d.ts +0 -8
- package/dist/ui/chart-x-axis-selector.d.ts.map +0 -1
- package/dist/ui/chart-x-axis-selector.js +0 -14
- package/dist/ui/index.d.ts +0 -25
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -23
- package/dist/ui/toolbar-types.d.ts +0 -43
- package/dist/ui/toolbar-types.d.ts.map +0 -1
- package/dist/ui/toolbar-types.js +0 -50
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { ChartType } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* X-axis kinds understood by chart-studio when validating chart types.
|
|
4
|
-
*/
|
|
5
|
-
export type ChartAxisType = 'date' | 'category' | 'boolean';
|
|
6
|
-
/**
|
|
7
|
-
* Declarative chart-type capability matrix.
|
|
8
|
-
*
|
|
9
|
-
* Centralizing these rules keeps UI controls and state validation aligned as
|
|
10
|
-
* more chart types are added later.
|
|
11
|
-
*/
|
|
12
|
-
export type ChartTypeCapabilities = {
|
|
13
|
-
supportedXAxisTypes: readonly ChartAxisType[];
|
|
14
|
-
supportsGrouping: boolean;
|
|
15
|
-
supportsTimeBucketing: boolean;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Capabilities for each supported chart type.
|
|
19
|
-
*/
|
|
20
|
-
export declare const CHART_TYPE_CONFIG: {
|
|
21
|
-
readonly bar: {
|
|
22
|
-
readonly supportedXAxisTypes: readonly ["date", "category", "boolean"];
|
|
23
|
-
readonly supportsGrouping: true;
|
|
24
|
-
readonly supportsTimeBucketing: true;
|
|
25
|
-
};
|
|
26
|
-
readonly line: {
|
|
27
|
-
readonly supportedXAxisTypes: readonly ["date"];
|
|
28
|
-
readonly supportsGrouping: true;
|
|
29
|
-
readonly supportsTimeBucketing: true;
|
|
30
|
-
};
|
|
31
|
-
readonly area: {
|
|
32
|
-
readonly supportedXAxisTypes: readonly ["date"];
|
|
33
|
-
readonly supportsGrouping: true;
|
|
34
|
-
readonly supportsTimeBucketing: true;
|
|
35
|
-
};
|
|
36
|
-
readonly pie: {
|
|
37
|
-
readonly supportedXAxisTypes: readonly ["category", "boolean"];
|
|
38
|
-
readonly supportsGrouping: false;
|
|
39
|
-
readonly supportsTimeBucketing: false;
|
|
40
|
-
};
|
|
41
|
-
readonly donut: {
|
|
42
|
-
readonly supportedXAxisTypes: readonly ["category", "boolean"];
|
|
43
|
-
readonly supportsGrouping: false;
|
|
44
|
-
readonly supportsTimeBucketing: false;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
type ChartTypeAvailability = {
|
|
48
|
-
hasGroupBy: boolean;
|
|
49
|
-
xAxisType: ChartAxisType | null;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Whether a chart type can represent the current chart state.
|
|
53
|
-
*/
|
|
54
|
-
export declare function isChartTypeAvailable(chartType: ChartType, availability: ChartTypeAvailability): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Chart types valid for the current axis + feature combination.
|
|
57
|
-
*/
|
|
58
|
-
export declare function getAvailableChartTypes(availability: ChartTypeAvailability): ChartType[];
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=chart-capabilities.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chart-capabilities.d.ts","sourceRoot":"","sources":["../../src/core/chart-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAA;AAGzC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,mBAAmB,EAAE,SAAS,aAAa,EAAE,CAAA;IAC7C,gBAAgB,EAAE,OAAO,CAAA;IACzB,qBAAqB,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B+B,CAAA;AAE7D,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,aAAa,GAAG,IAAI,CAAA;CAChC,CAAA;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,qBAAqB,GAClC,OAAO,CAeT;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,qBAAqB,GAAG,SAAS,EAAE,CAEvF"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { CHART_TYPE_ORDER } from './config-utils.js';
|
|
2
|
-
/**
|
|
3
|
-
* Capabilities for each supported chart type.
|
|
4
|
-
*/
|
|
5
|
-
export const CHART_TYPE_CONFIG = {
|
|
6
|
-
bar: {
|
|
7
|
-
supportedXAxisTypes: ['date', 'category', 'boolean'],
|
|
8
|
-
supportsGrouping: true,
|
|
9
|
-
supportsTimeBucketing: true,
|
|
10
|
-
},
|
|
11
|
-
line: {
|
|
12
|
-
supportedXAxisTypes: ['date'],
|
|
13
|
-
supportsGrouping: true,
|
|
14
|
-
supportsTimeBucketing: true,
|
|
15
|
-
},
|
|
16
|
-
area: {
|
|
17
|
-
supportedXAxisTypes: ['date'],
|
|
18
|
-
supportsGrouping: true,
|
|
19
|
-
supportsTimeBucketing: true,
|
|
20
|
-
},
|
|
21
|
-
pie: {
|
|
22
|
-
supportedXAxisTypes: ['category', 'boolean'],
|
|
23
|
-
supportsGrouping: false,
|
|
24
|
-
supportsTimeBucketing: false,
|
|
25
|
-
},
|
|
26
|
-
donut: {
|
|
27
|
-
supportedXAxisTypes: ['category', 'boolean'],
|
|
28
|
-
supportsGrouping: false,
|
|
29
|
-
supportsTimeBucketing: false,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Whether a chart type can represent the current chart state.
|
|
34
|
-
*/
|
|
35
|
-
export function isChartTypeAvailable(chartType, availability) {
|
|
36
|
-
const { hasGroupBy, xAxisType } = availability;
|
|
37
|
-
if (xAxisType === null)
|
|
38
|
-
return false;
|
|
39
|
-
const capabilities = CHART_TYPE_CONFIG[chartType];
|
|
40
|
-
const supportedXAxisTypes = capabilities.supportedXAxisTypes;
|
|
41
|
-
if (!supportedXAxisTypes.includes(xAxisType)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
if (hasGroupBy && !capabilities.supportsGrouping) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Chart types valid for the current axis + feature combination.
|
|
51
|
-
*/
|
|
52
|
-
export function getAvailableChartTypes(availability) {
|
|
53
|
-
return CHART_TYPE_ORDER.filter((chartType) => isChartTypeAvailable(chartType, availability));
|
|
54
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/core/colors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM,CAGtE;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,UAAO,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAMrF"}
|
package/dist/core/colors.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Color assignment for chart series.
|
|
3
|
-
*
|
|
4
|
-
* Uses shadcn chart CSS variables (`--chart-1` through `--chart-5`) by default.
|
|
5
|
-
* Falls back to a built-in OKLCH palette when CSS variables are not available.
|
|
6
|
-
*/
|
|
7
|
-
/** Fallback palette using OKLCH for perceptually uniform colors. */
|
|
8
|
-
const FALLBACK_COLORS = [
|
|
9
|
-
'oklch(0.65 0.15 250)', // blue
|
|
10
|
-
'oklch(0.65 0.15 350)', // rose
|
|
11
|
-
'oklch(0.65 0.15 200)', // cyan
|
|
12
|
-
'oklch(0.65 0.15 70)', // amber
|
|
13
|
-
'oklch(0.65 0.15 150)', // teal
|
|
14
|
-
'oklch(0.65 0.15 30)', // orange
|
|
15
|
-
'oklch(0.65 0.15 300)', // purple
|
|
16
|
-
'oklch(0.65 0.15 120)', // green
|
|
17
|
-
'oklch(0.65 0.12 170)', // mint
|
|
18
|
-
'oklch(0.65 0.12 220)', // slate blue
|
|
19
|
-
];
|
|
20
|
-
/** Shadcn chart CSS variables (5 colors) with safe fallbacks. */
|
|
21
|
-
const SHADCN_CHART_COLORS = [
|
|
22
|
-
`hsl(var(--chart-1, var(--cs-chart-1, 245 72% 57%)))`,
|
|
23
|
-
`hsl(var(--chart-2, var(--cs-chart-2, 271 72% 55%)))`,
|
|
24
|
-
`hsl(var(--chart-3, var(--cs-chart-3, 330 68% 54%)))`,
|
|
25
|
-
`hsl(var(--chart-4, var(--cs-chart-4, 170 65% 38%)))`,
|
|
26
|
-
`hsl(var(--chart-5, var(--cs-chart-5, 30 90% 54%)))`,
|
|
27
|
-
];
|
|
28
|
-
/**
|
|
29
|
-
* Get a color for the Nth series.
|
|
30
|
-
* Cycles through the palette when index exceeds palette length.
|
|
31
|
-
*
|
|
32
|
-
* @param index - Zero-based series index
|
|
33
|
-
* @param useShadcn - Whether to use shadcn CSS variables (default: true)
|
|
34
|
-
* @returns CSS color value
|
|
35
|
-
*/
|
|
36
|
-
export function getSeriesColor(index, useShadcn = true) {
|
|
37
|
-
const palette = useShadcn ? SHADCN_CHART_COLORS : FALLBACK_COLORS;
|
|
38
|
-
return palette[index % palette.length];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Generate a color map for a list of group labels.
|
|
42
|
-
* Assigns colors deterministically based on array order.
|
|
43
|
-
*
|
|
44
|
-
* @param groups - Array of group labels
|
|
45
|
-
* @param useShadcn - Whether to use shadcn CSS variables (default: true)
|
|
46
|
-
* @returns Map from group label to CSS color
|
|
47
|
-
*/
|
|
48
|
-
export function buildColorMap(groups, useShadcn = true) {
|
|
49
|
-
const map = new Map();
|
|
50
|
-
for (let i = 0; i < groups.length; i++) {
|
|
51
|
-
map.set(groups[i], getSeriesColor(i, useShadcn));
|
|
52
|
-
}
|
|
53
|
-
return map;
|
|
54
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ChartType, TimeBucket } from './types.js';
|
|
2
|
-
type IdOption<TId extends string> = {
|
|
3
|
-
id: TId;
|
|
4
|
-
};
|
|
5
|
-
type IdControlConfig<TId extends string> = {
|
|
6
|
-
allowed?: readonly TId[];
|
|
7
|
-
hidden?: readonly TId[];
|
|
8
|
-
default?: TId;
|
|
9
|
-
};
|
|
10
|
-
type ValueControlConfig<TValue extends string> = {
|
|
11
|
-
allowed?: readonly TValue[];
|
|
12
|
-
hidden?: readonly TValue[];
|
|
13
|
-
default?: TValue;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Restrict an ID-keyed option list with `allowed`/`hidden`.
|
|
17
|
-
*
|
|
18
|
-
* When `fallbackToBaseIfEmpty` is enabled, required controls keep their base
|
|
19
|
-
* runtime options even if the config does not match the active source.
|
|
20
|
-
*/
|
|
21
|
-
export declare function restrictConfiguredIdOptions<TId extends string, TOption extends IdOption<TId>>(options: readonly TOption[], config: IdControlConfig<TId> | undefined, fallbackToBaseIfEmpty?: boolean): TOption[];
|
|
22
|
-
/**
|
|
23
|
-
* Resolve one ID-based selection against the current option list.
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolveConfiguredIdSelection<TId extends string>(currentValue: TId | null, options: readonly IdOption<TId>[], configuredDefault: TId | undefined, fallbackValue: TId | null, preferFirstAvailable?: boolean): TId | null;
|
|
26
|
-
/**
|
|
27
|
-
* Restrict a primitive option list with `allowed`/`hidden`.
|
|
28
|
-
*/
|
|
29
|
-
export declare function restrictConfiguredValues<TValue extends string>(values: readonly TValue[], config: ValueControlConfig<TValue> | undefined, fallbackToBaseIfEmpty?: boolean): TValue[];
|
|
30
|
-
/**
|
|
31
|
-
* Resolve one primitive selection against the current option list.
|
|
32
|
-
*/
|
|
33
|
-
export declare function resolveConfiguredValue<TValue extends string>(currentValue: TValue, values: readonly TValue[], configuredDefault: TValue | undefined): TValue;
|
|
34
|
-
/**
|
|
35
|
-
* Ordered time buckets exposed by the headless API.
|
|
36
|
-
*/
|
|
37
|
-
export declare const TIME_BUCKET_ORDER: readonly TimeBucket[];
|
|
38
|
-
/**
|
|
39
|
-
* Ordered chart types exposed by the headless API.
|
|
40
|
-
*/
|
|
41
|
-
export declare const CHART_TYPE_ORDER: readonly ChartType[];
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=config-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.d.ts","sourceRoot":"","sources":["../../src/core/config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACX,MAAM,YAAY,CAAA;AAEnB,KAAK,QAAQ,CAAC,GAAG,SAAS,MAAM,IAAI;IAClC,EAAE,EAAE,GAAG,CAAA;CACR,CAAA;AAED,KAAK,eAAe,CAAC,GAAG,SAAS,MAAM,IAAI;IACzC,OAAO,CAAC,EAAE,SAAS,GAAG,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,SAAS,GAAG,EAAE,CAAA;IACvB,OAAO,CAAC,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B,EAAE,SAAS,SAAS,EAA4C,CAAA"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build the visible runtime option list after applying config restrictions.
|
|
3
|
-
*
|
|
4
|
-
* The pipeline is always:
|
|
5
|
-
* 1. start from runtime-valid options
|
|
6
|
-
* 2. if `allowed` exists, keep only allowed entries in declared order
|
|
7
|
-
* 3. if `hidden` exists, subtract hidden entries
|
|
8
|
-
*
|
|
9
|
-
* When `fallbackToBaseIfEmpty` is enabled, required controls can recover their
|
|
10
|
-
* base runtime options if the config leaves nothing selectable for the active
|
|
11
|
-
* source. This recovery is intentionally separate from default resolution.
|
|
12
|
-
*/
|
|
13
|
-
function restrictConfiguredCollection(items, config, getKey, fallbackToBaseIfEmpty) {
|
|
14
|
-
const keyedItems = new Map(items.map(item => [getKey(item), item]));
|
|
15
|
-
const allowedKeys = config?.allowed;
|
|
16
|
-
const hiddenKeys = config?.hidden ? new Set(config.hidden) : undefined;
|
|
17
|
-
const orderedItems = allowedKeys
|
|
18
|
-
? allowedKeys.flatMap(allowedKey => {
|
|
19
|
-
const match = keyedItems.get(allowedKey);
|
|
20
|
-
return match ? [match] : [];
|
|
21
|
-
})
|
|
22
|
-
: [...items];
|
|
23
|
-
const visibleItems = hiddenKeys
|
|
24
|
-
? orderedItems.filter(item => !hiddenKeys.has(getKey(item)))
|
|
25
|
-
: orderedItems;
|
|
26
|
-
if (fallbackToBaseIfEmpty && visibleItems.length === 0) {
|
|
27
|
-
return [...items];
|
|
28
|
-
}
|
|
29
|
-
return visibleItems;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Restrict an ID-keyed option list with `allowed`/`hidden`.
|
|
33
|
-
*
|
|
34
|
-
* When `fallbackToBaseIfEmpty` is enabled, required controls keep their base
|
|
35
|
-
* runtime options even if the config does not match the active source.
|
|
36
|
-
*/
|
|
37
|
-
export function restrictConfiguredIdOptions(options, config, fallbackToBaseIfEmpty = false) {
|
|
38
|
-
return restrictConfiguredCollection(options, config, option => option.id, fallbackToBaseIfEmpty);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Resolve one ID-based selection against the current option list.
|
|
42
|
-
*/
|
|
43
|
-
export function resolveConfiguredIdSelection(currentValue, options, configuredDefault, fallbackValue, preferFirstAvailable = true) {
|
|
44
|
-
if (currentValue && options.some(option => option.id === currentValue)) {
|
|
45
|
-
return currentValue;
|
|
46
|
-
}
|
|
47
|
-
if (configuredDefault && options.some(option => option.id === configuredDefault)) {
|
|
48
|
-
return configuredDefault;
|
|
49
|
-
}
|
|
50
|
-
if (preferFirstAvailable) {
|
|
51
|
-
return options[0]?.id ?? fallbackValue;
|
|
52
|
-
}
|
|
53
|
-
return fallbackValue;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Restrict a primitive option list with `allowed`/`hidden`.
|
|
57
|
-
*/
|
|
58
|
-
export function restrictConfiguredValues(values, config, fallbackToBaseIfEmpty = false) {
|
|
59
|
-
return restrictConfiguredCollection(values, config, value => value, fallbackToBaseIfEmpty);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Resolve one primitive selection against the current option list.
|
|
63
|
-
*/
|
|
64
|
-
export function resolveConfiguredValue(currentValue, values, configuredDefault) {
|
|
65
|
-
if (values.includes(currentValue)) {
|
|
66
|
-
return currentValue;
|
|
67
|
-
}
|
|
68
|
-
if (configuredDefault && values.includes(configuredDefault)) {
|
|
69
|
-
return configuredDefault;
|
|
70
|
-
}
|
|
71
|
-
return values[0] ?? currentValue;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Ordered time buckets exposed by the headless API.
|
|
75
|
-
*/
|
|
76
|
-
export const TIME_BUCKET_ORDER = ['day', 'week', 'month', 'quarter', 'year'];
|
|
77
|
-
/**
|
|
78
|
-
* Ordered chart types exposed by the headless API.
|
|
79
|
-
*/
|
|
80
|
-
export const CHART_TYPE_ORDER = ['bar', 'line', 'area', 'pie', 'donut'];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Date range utilities for chart-studio.
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for filtering data by date range and computing
|
|
5
|
-
* the min/max date range from a dataset.
|
|
6
|
-
*/
|
|
7
|
-
import type { DateColumn, DateRangeFilter } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Filter data by a date range on a specific date column.
|
|
10
|
-
* Both bounds are inclusive (to is extended to end of day).
|
|
11
|
-
*
|
|
12
|
-
* @param data - Raw data items
|
|
13
|
-
* @param dateColumn - The date column to filter on
|
|
14
|
-
* @param filter - Date range filter with from/to bounds
|
|
15
|
-
* @returns Filtered data items within the date range
|
|
16
|
-
*/
|
|
17
|
-
export declare function filterByDateRange<T>(data: readonly T[], dateColumn: DateColumn<T>, filter: DateRangeFilter): T[];
|
|
18
|
-
/**
|
|
19
|
-
* Compute the min/max date range from data for a given date column.
|
|
20
|
-
*
|
|
21
|
-
* @param data - Data items to scan
|
|
22
|
-
* @param dateColumn - The date column to extract dates from
|
|
23
|
-
* @returns Object with min and max dates (both null if no valid dates)
|
|
24
|
-
*/
|
|
25
|
-
export declare function computeDateRange<T>(data: readonly T[], dateColumn: DateColumn<T>): {
|
|
26
|
-
min: Date | null;
|
|
27
|
-
max: Date | null;
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=date-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../src/core/date-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,YAAY,CAAA;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,MAAM,EAAE,eAAe,GACtB,CAAC,EAAE,CAeL;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB;IAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAA;CAAC,CActC"}
|
package/dist/core/date-utils.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Date range utilities for chart-studio.
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for filtering data by date range and computing
|
|
5
|
-
* the min/max date range from a dataset.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Filter data by a date range on a specific date column.
|
|
9
|
-
* Both bounds are inclusive (to is extended to end of day).
|
|
10
|
-
*
|
|
11
|
-
* @param data - Raw data items
|
|
12
|
-
* @param dateColumn - The date column to filter on
|
|
13
|
-
* @param filter - Date range filter with from/to bounds
|
|
14
|
-
* @returns Filtered data items within the date range
|
|
15
|
-
*/
|
|
16
|
-
export function filterByDateRange(data, dateColumn, filter) {
|
|
17
|
-
const { from, to } = filter;
|
|
18
|
-
if (!from && !to)
|
|
19
|
-
return [...data];
|
|
20
|
-
const toEnd = to ? new Date(to.getFullYear(), to.getMonth(), to.getDate(), 23, 59, 59, 999) : null;
|
|
21
|
-
return data.filter((item) => {
|
|
22
|
-
const raw = dateColumn.accessor(item);
|
|
23
|
-
if (raw == null)
|
|
24
|
-
return false;
|
|
25
|
-
const d = new Date(raw);
|
|
26
|
-
if (Number.isNaN(d.getTime()))
|
|
27
|
-
return false;
|
|
28
|
-
if (from && d < from)
|
|
29
|
-
return false;
|
|
30
|
-
if (toEnd && d > toEnd)
|
|
31
|
-
return false;
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Compute the min/max date range from data for a given date column.
|
|
37
|
-
*
|
|
38
|
-
* @param data - Data items to scan
|
|
39
|
-
* @param dateColumn - The date column to extract dates from
|
|
40
|
-
* @returns Object with min and max dates (both null if no valid dates)
|
|
41
|
-
*/
|
|
42
|
-
export function computeDateRange(data, dateColumn) {
|
|
43
|
-
let min = null;
|
|
44
|
-
let max = null;
|
|
45
|
-
for (const item of data) {
|
|
46
|
-
const raw = dateColumn.accessor(item);
|
|
47
|
-
if (raw == null)
|
|
48
|
-
continue;
|
|
49
|
-
const d = new Date(raw);
|
|
50
|
-
if (Number.isNaN(d.getTime()))
|
|
51
|
-
continue;
|
|
52
|
-
if (!min || d < min)
|
|
53
|
-
min = d;
|
|
54
|
-
if (!max || d > max)
|
|
55
|
-
max = d;
|
|
56
|
-
}
|
|
57
|
-
return { min, max };
|
|
58
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { ChartTypeConfig, DefinedChartSchema, ExactShape, FiltersConfig, GroupByConfig, MetricConfig, ResolvedFilterColumnIdFromSchema, ResolvedGroupByColumnIdFromSchema, ResolvedMetricColumnIdFromSchema, ResolvedXAxisColumnIdFromSchema, SchemaColumnsValidationShape, TimeBucketConfig, XAxisConfig } from './types.js';
|
|
2
|
-
type SchemaFromSections<T, TColumns extends Record<string, unknown> | undefined, TXAxis, TGroupBy, TFilters, TMetric, TChartType, TTimeBucket> = {
|
|
3
|
-
columns?: Extract<TColumns, Record<string, unknown> | undefined>;
|
|
4
|
-
xAxis?: Extract<TXAxis, XAxisConfig<ResolvedXAxisColumnIdFromSchema<T, {
|
|
5
|
-
columns?: TColumns;
|
|
6
|
-
}>> | undefined>;
|
|
7
|
-
groupBy?: Extract<TGroupBy, GroupByConfig<ResolvedGroupByColumnIdFromSchema<T, {
|
|
8
|
-
columns?: TColumns;
|
|
9
|
-
}>> | undefined>;
|
|
10
|
-
filters?: Extract<TFilters, FiltersConfig<ResolvedFilterColumnIdFromSchema<T, {
|
|
11
|
-
columns?: TColumns;
|
|
12
|
-
}>> | undefined>;
|
|
13
|
-
metric?: Extract<TMetric, MetricConfig<ResolvedMetricColumnIdFromSchema<T, {
|
|
14
|
-
columns?: TColumns;
|
|
15
|
-
}>> | undefined>;
|
|
16
|
-
chartType?: Extract<TChartType, ChartTypeConfig | undefined>;
|
|
17
|
-
timeBucket?: Extract<TTimeBucket, TimeBucketConfig | undefined>;
|
|
18
|
-
};
|
|
19
|
-
type DefineChartSchemaInput<T, TColumns extends Record<string, unknown> | undefined, TXAxis, TGroupBy, TFilters, TMetric, TChartType, TTimeBucket> = {
|
|
20
|
-
/**
|
|
21
|
-
* Shape the available chart columns.
|
|
22
|
-
*
|
|
23
|
-
* This is usually the most important part of the schema. Use it to:
|
|
24
|
-
* - rename inferred raw fields with `label`
|
|
25
|
-
* - force a field to a specific `type`
|
|
26
|
-
* - apply `format` or `formatter`
|
|
27
|
-
* - remove a raw field with `false`
|
|
28
|
-
* - add brand new derived columns with `kind: 'derived'`
|
|
29
|
-
*/
|
|
30
|
-
columns?: TColumns & ExactShape<SchemaColumnsValidationShape<T, NoInfer<TColumns>>, NoInfer<TColumns>>;
|
|
31
|
-
/**
|
|
32
|
-
* Restrict which resolved columns may be selected on the X-axis.
|
|
33
|
-
*
|
|
34
|
-
* Use this when you want to expose only a subset of possible X-axis fields.
|
|
35
|
-
*/
|
|
36
|
-
xAxis?: TXAxis & ExactShape<XAxisConfig<ResolvedXAxisColumnIdFromSchema<T, {
|
|
37
|
-
columns?: TColumns;
|
|
38
|
-
}>>, NoInfer<TXAxis>>;
|
|
39
|
-
/**
|
|
40
|
-
* Restrict which resolved columns may be used to split the chart into series.
|
|
41
|
-
*
|
|
42
|
-
* This powers grouped / multi-series charts.
|
|
43
|
-
*/
|
|
44
|
-
groupBy?: TGroupBy & ExactShape<GroupByConfig<ResolvedGroupByColumnIdFromSchema<T, {
|
|
45
|
-
columns?: TColumns;
|
|
46
|
-
}>>, NoInfer<TGroupBy>>;
|
|
47
|
-
/**
|
|
48
|
-
* Restrict which resolved columns appear in the filters UI.
|
|
49
|
-
*
|
|
50
|
-
* Only category and boolean-like columns are eligible here.
|
|
51
|
-
*/
|
|
52
|
-
filters?: TFilters & ExactShape<FiltersConfig<ResolvedFilterColumnIdFromSchema<T, {
|
|
53
|
-
columns?: TColumns;
|
|
54
|
-
}>>, NoInfer<TFilters>>;
|
|
55
|
-
/**
|
|
56
|
-
* Restrict which metrics and aggregate combinations remain selectable.
|
|
57
|
-
*
|
|
58
|
-
* Use this when you want to curate the metric dropdown rather than exposing
|
|
59
|
-
* every available numeric aggregate.
|
|
60
|
-
*/
|
|
61
|
-
metric?: TMetric & ExactShape<MetricConfig<ResolvedMetricColumnIdFromSchema<T, {
|
|
62
|
-
columns?: TColumns;
|
|
63
|
-
}>>, NoInfer<TMetric>>;
|
|
64
|
-
/** Restrict which chart renderers are available to the user. */
|
|
65
|
-
chartType?: TChartType & ExactShape<ChartTypeConfig, NoInfer<TChartType>>;
|
|
66
|
-
/**
|
|
67
|
-
* Restrict which time buckets remain available for date X-axes.
|
|
68
|
-
*
|
|
69
|
-
* Example: allow only `'month'` and `'quarter'`.
|
|
70
|
-
*/
|
|
71
|
-
timeBucket?: TTimeBucket & ExactShape<TimeBucketConfig, NoInfer<TTimeBucket>>;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Define one explicit chart schema with strict exact-object checking.
|
|
75
|
-
*
|
|
76
|
-
* The schema is the single advanced authoring surface for chart-studio:
|
|
77
|
-
* `columns` can override or exclude inferred raw fields and also define derived
|
|
78
|
-
* columns, while the top-level control sections restrict the public chart
|
|
79
|
-
* contract.
|
|
80
|
-
*
|
|
81
|
-
* Typical shape:
|
|
82
|
-
*
|
|
83
|
-
* ```ts
|
|
84
|
-
* const schema = defineChartSchema<Row>()({
|
|
85
|
-
* columns: {
|
|
86
|
-
* createdAt: {type: 'date', label: 'Created'},
|
|
87
|
-
* revenue: {type: 'number', format: 'currency'},
|
|
88
|
-
* margin: {
|
|
89
|
-
* kind: 'derived',
|
|
90
|
-
* type: 'number',
|
|
91
|
-
* label: 'Margin',
|
|
92
|
-
* format: 'percent',
|
|
93
|
-
* accessor: row => row.profit / row.revenue,
|
|
94
|
-
* },
|
|
95
|
-
* },
|
|
96
|
-
* xAxis: {allowed: ['createdAt']},
|
|
97
|
-
* metric: {
|
|
98
|
-
* allowed: [{kind: 'aggregate', columnId: 'revenue', aggregate: 'sum'}],
|
|
99
|
-
* },
|
|
100
|
-
* })
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
export declare function defineChartSchema<T>(): <const TColumns extends Record<string, unknown> | undefined = undefined, const TXAxis = undefined, const TGroupBy = undefined, const TFilters = undefined, const TMetric = undefined, const TChartType = undefined, const TTimeBucket = undefined>(schema: DefineChartSchemaInput<T, TColumns, TXAxis, TGroupBy, TFilters, TMetric, TChartType, TTimeBucket>) => DefinedChartSchema<T, SchemaFromSections<T, TColumns, TXAxis, TGroupBy, TFilters, TMetric, TChartType, TTimeBucket>>;
|
|
104
|
-
export {};
|
|
105
|
-
//# sourceMappingURL=define-chart-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-chart-schema.d.ts","sourceRoot":"","sources":["../../src/core/define-chart-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,+BAA+B,EAC/B,4BAA4B,EAC5B,gBAAgB,EAChB,WAAW,EACZ,MAAM,YAAY,CAAA;AAEnB,KAAK,kBAAkB,CACrB,CAAC,EACD,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACpD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,UAAU,EACV,WAAW,IACT;IACF,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,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S,EAC1B,KAAK,CAAC,QAAQ,GAAG,SAAS,EAC1B,KAAK,CAAC,OAAO,GAAG,SAAS,EACzB,KAAK,CAAC,UAAU,GAAG,SAAS,EAC5B,KAAK,CAAC,WAAW,GAAG,SAAS,EAE7B,QAAQ,sBAAsB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,KACxG,kBAAkB,CACnB,CAAC,EACD,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAC9F,CASF"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Define one explicit chart schema with strict exact-object checking.
|
|
3
|
-
*
|
|
4
|
-
* The schema is the single advanced authoring surface for chart-studio:
|
|
5
|
-
* `columns` can override or exclude inferred raw fields and also define derived
|
|
6
|
-
* columns, while the top-level control sections restrict the public chart
|
|
7
|
-
* contract.
|
|
8
|
-
*
|
|
9
|
-
* Typical shape:
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* const schema = defineChartSchema<Row>()({
|
|
13
|
-
* columns: {
|
|
14
|
-
* createdAt: {type: 'date', label: 'Created'},
|
|
15
|
-
* revenue: {type: 'number', format: 'currency'},
|
|
16
|
-
* margin: {
|
|
17
|
-
* kind: 'derived',
|
|
18
|
-
* type: 'number',
|
|
19
|
-
* label: 'Margin',
|
|
20
|
-
* format: 'percent',
|
|
21
|
-
* accessor: row => row.profit / row.revenue,
|
|
22
|
-
* },
|
|
23
|
-
* },
|
|
24
|
-
* xAxis: {allowed: ['createdAt']},
|
|
25
|
-
* metric: {
|
|
26
|
-
* allowed: [{kind: 'aggregate', columnId: 'revenue', aggregate: 'sum'}],
|
|
27
|
-
* },
|
|
28
|
-
* })
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export function defineChartSchema() {
|
|
32
|
-
/**
|
|
33
|
-
* Brand one schema object while preserving its literal types.
|
|
34
|
-
*
|
|
35
|
-
* This is what lets the schema stay both strongly typed and editor-friendly
|
|
36
|
-
* when it is later passed to `useChart(...)`.
|
|
37
|
-
*/
|
|
38
|
-
return function defineSchema(schema) {
|
|
39
|
-
return {
|
|
40
|
-
...schema,
|
|
41
|
-
__chartSchemaBrand: 'chart-schema-definition',
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ChartColumn, ColumnFormat, TimeBucket } from './types.js';
|
|
2
|
-
/** Formatting surfaces exposed by the chart UI. */
|
|
3
|
-
export type ChartValueSurface = 'axis' | 'tooltip' | 'data-label' | 'raw';
|
|
4
|
-
/** Numeric extent used to choose sensible default precision. */
|
|
5
|
-
export type NumericRange = {
|
|
6
|
-
min: number;
|
|
7
|
-
max: number;
|
|
8
|
-
};
|
|
9
|
-
type FormatColumnLike<T> = {
|
|
10
|
-
type: ChartColumn<T>['type'];
|
|
11
|
-
format?: ColumnFormat;
|
|
12
|
-
formatter?: ChartColumn<T>['formatter'];
|
|
13
|
-
trueLabel?: string;
|
|
14
|
-
falseLabel?: string;
|
|
15
|
-
};
|
|
16
|
-
type FormatValueOptions<T> = {
|
|
17
|
-
column: FormatColumnLike<T>;
|
|
18
|
-
surface: ChartValueSurface;
|
|
19
|
-
timeBucket?: TimeBucket;
|
|
20
|
-
numericRange?: NumericRange | null;
|
|
21
|
-
locale?: string;
|
|
22
|
-
item?: T;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Build a numeric range from chart values.
|
|
26
|
-
*/
|
|
27
|
-
export declare function createNumericRange(values: readonly number[]): NumericRange | null;
|
|
28
|
-
/**
|
|
29
|
-
* Decide whether an axis should keep decimal ticks for the current visible
|
|
30
|
-
* numeric values.
|
|
31
|
-
*/
|
|
32
|
-
export declare function shouldAllowDecimalTicks(values: readonly number[]): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Format one chart value for a specific UI surface.
|
|
35
|
-
*/
|
|
36
|
-
export declare function formatChartValue<T>(value: string | number | boolean | Date | null | undefined, options: FormatValueOptions<T>): string;
|
|
37
|
-
/**
|
|
38
|
-
* Format a date bucket label from the machine-friendly pipeline key.
|
|
39
|
-
*/
|
|
40
|
-
export declare function formatTimeBucketLabel(key: string, bucket: TimeBucket, surface: ChartValueSurface, locale?: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Format the Y-axis or label width estimate with the same surface rules used in
|
|
43
|
-
* the visible chart.
|
|
44
|
-
*/
|
|
45
|
-
export declare function formatNumericSurfaceValue(value: number, surface: ChartValueSurface, numericRange?: NumericRange | null, format?: ColumnFormat, formatter?: ChartColumn<unknown>['formatter'], locale?: string): string;
|
|
46
|
-
export {};
|
|
47
|
-
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/core/formatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAA2C,UAAU,EAAC,MAAM,YAAY,CAAA;AAE9G,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAA;AAEzE,gEAAgE;AAChE,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAuBD,KAAK,gBAAgB,CAAC,CAAC,IAAI;IACzB,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAC5B,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC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