@nordhavnhq/beacon 0.0.0-stage → 0.4.1

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/README.md CHANGED
@@ -1,3 +1,10 @@
1
- # Temporary Holding Version
1
+ # @nordhavnhq/beacon
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Internal package of Nordhavn OS. Published only so our own sites can install it.
4
+
5
+ Not meant for outside use: no support, no stability guarantees, and it needs an
6
+ API key for a Nordhavn OS server.
7
+
8
+ ## License
9
+
10
+ MIT
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The chart contract: what a chart block is (`ChartSpec`, as authored and
3
+ * stored) and what a renderer draws (`ChartData`, the resolved categories and
4
+ * series). Shared by the Nordhavn OS server, the client and every renderer, so a
5
+ * chart means the same thing wherever it is read. Pure data: no dependencies.
6
+ * The zod schemas for these shapes live in `@nordhavnhq/beacon/schema`.
7
+ */
8
+ /**
9
+ * The palette a series colour may pick from. A renderer maps a key to a colour
10
+ * of the theme it runs in; a spec never carries a raw hex.
11
+ */
12
+ declare const PALETTE_KEYS: readonly ["ember", "aurora", "crimson", "dusk", "jade", "cobalt", "iris", "nebula"];
13
+ type PaletteKey = typeof PALETTE_KEYS[number];
14
+ declare const CHART_TYPES: readonly ["bar", "bar-horizontal", "line", "area", "pie", "donut", "share", "heatmap"];
15
+ type ChartType = typeof CHART_TYPES[number];
16
+ /**
17
+ * How a chart reads its data: `cartesian` plots each series over the
18
+ * categories, `part` cuts one series into its categories (one whole), `matrix`
19
+ * is a grid of the categories (columns) by the series (rows).
20
+ */
21
+ type ChartFamily = 'cartesian' | 'part' | 'matrix';
22
+ /** What a chart type is and takes: every editor, parser and renderer reads it from here. */
23
+ interface ChartTypeInfo {
24
+ value: ChartType;
25
+ label: string;
26
+ /** One line on what the type is for (editor hint, agent docs). */
27
+ purpose: string;
28
+ /** A lucide icon name (kebab-case); the host maps it to its icon set. */
29
+ icon: string;
30
+ family: ChartFamily;
31
+ /** Exactly one series (the parts are the categories). */
32
+ singleSeries: boolean;
33
+ /** Series may sit on a left or right value axis. */
34
+ axes: boolean;
35
+ /** Series may stack. */
36
+ stacked: boolean;
37
+ /** Each series wears its own colour (else one hue in tints). */
38
+ seriesColors: boolean;
39
+ /** Value labels on the marks are possible. */
40
+ valueLabels: boolean;
41
+ /** Drawn as HTML that sizes to its content, not into a fixed canvas box. */
42
+ html: boolean;
43
+ /** Default box height in px. */
44
+ height: number;
45
+ }
46
+ declare const CHART_TYPE_INFO: Record<ChartType, ChartTypeInfo>;
47
+ declare function chartTypeInfo(type: ChartType): ChartTypeInfo;
48
+ /** Pie, donut and share: one series cut into its categories. */
49
+ declare function isPartChart(type: ChartType): boolean;
50
+ /** Bar in either direction. */
51
+ declare function isBarChart(type: ChartType): boolean;
52
+ /** Which Y axis a series scales against. Only for the types with `axes`. */
53
+ declare const CHART_AXES: readonly ["left", "right"];
54
+ type ChartAxis = typeof CHART_AXES[number];
55
+ /** Periods a date category can be grouped into. */
56
+ declare const DATE_BUCKET_VALUES: readonly ["day", "week", "month", "quarter", "year"];
57
+ type DateBucket = typeof DATE_BUCKET_VALUES[number];
58
+ /** `auto` picks the period from the date range. */
59
+ declare const BUCKET_MODES: readonly ["auto", "day", "week", "month", "quarter", "year"];
60
+ type BucketMode = typeof BUCKET_MODES[number];
61
+ /** How the records that fall in one category combine into one point. */
62
+ declare const AGGREGATIONS: readonly ["sum", "avg", "count", "min", "max", "first", "last"];
63
+ type Aggregation = typeof AGGREGATIONS[number];
64
+ /** Category order. `default` is chronological for dates, source order otherwise. */
65
+ declare const CHART_SORTS: readonly ["default", "category-asc", "category-desc", "value-desc", "value-asc"];
66
+ type ChartSort = typeof CHART_SORTS[number];
67
+ interface ChartSeriesSpec {
68
+ /** Field slug whose numeric value is the Y value. */
69
+ field: string;
70
+ label?: string;
71
+ /** Omitted: the next colour of the renderer's default rotation. */
72
+ color?: PaletteKey;
73
+ axis: ChartAxis;
74
+ aggregate: Aggregation;
75
+ }
76
+ /** A chart as authored and stored: where its data comes from and how it is shaped. */
77
+ interface ChartSpec {
78
+ title: string;
79
+ chartType: ChartType;
80
+ /** A dataset (`node.dataset`) or a saved query (`queries.<slug>`). */
81
+ source: string;
82
+ /** Field slug for the X axis or the slice labels. */
83
+ categoryField: string;
84
+ /**
85
+ * Field slug to split the first series by: one series per distinct value of
86
+ * this field (top 12 by record count, the rest as "Other"). The rows of a
87
+ * heatmap, the stacks of a bar. Empty: the series are the value fields.
88
+ */
89
+ splitField: string;
90
+ series: ChartSeriesSpec[];
91
+ /** Date categories only. */
92
+ bucket: BucketMode;
93
+ sort: ChartSort;
94
+ /** Keep the top N categories, the rest becomes "Other". 0 is no limit. Non-date only. */
95
+ limit: number;
96
+ /** Date buckets only: emit empty periods so a line stays continuous. */
97
+ fillGaps: boolean;
98
+ stacked: boolean;
99
+ legend: boolean;
100
+ }
101
+ interface ChartSeriesData {
102
+ name: string;
103
+ /** One value per category; null is a gap (nothing measured there). */
104
+ data: Array<number | null>;
105
+ /** A palette key or any CSS colour the host resolved. */
106
+ color?: string;
107
+ axis?: ChartAxis;
108
+ }
109
+ /** A chart as a renderer draws it: the data already resolved and consolidated. */
110
+ interface ChartData {
111
+ type: ChartType;
112
+ categories: string[];
113
+ series: ChartSeriesData[];
114
+ stacked?: boolean;
115
+ legend?: boolean;
116
+ }
117
+
118
+ export { AGGREGATIONS as A, BUCKET_MODES as B, DATE_BUCKET_VALUES as D, PALETTE_KEYS as P, CHART_AXES as c, CHART_SORTS as d, CHART_TYPES as e, CHART_TYPE_INFO as f, chartTypeInfo as q, isBarChart as r, isPartChart as s };
119
+ export type { ChartData as C, Aggregation as a, BucketMode as b, ChartAxis as g, ChartFamily as h, ChartSeriesData as i, ChartSeriesSpec as j, ChartSort as k, ChartSpec as l, ChartType as m, ChartTypeInfo as n, DateBucket as o, PaletteKey as p };
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The chart contract: what a chart block is (`ChartSpec`, as authored and
3
+ * stored) and what a renderer draws (`ChartData`, the resolved categories and
4
+ * series). Shared by the Nordhavn OS server, the client and every renderer, so a
5
+ * chart means the same thing wherever it is read. Pure data: no dependencies.
6
+ * The zod schemas for these shapes live in `@nordhavnhq/beacon/schema`.
7
+ */
8
+ /**
9
+ * The palette a series colour may pick from. A renderer maps a key to a colour
10
+ * of the theme it runs in; a spec never carries a raw hex.
11
+ */
12
+ declare const PALETTE_KEYS: readonly ["ember", "aurora", "crimson", "dusk", "jade", "cobalt", "iris", "nebula"];
13
+ type PaletteKey = typeof PALETTE_KEYS[number];
14
+ declare const CHART_TYPES: readonly ["bar", "bar-horizontal", "line", "area", "pie", "donut", "share", "heatmap"];
15
+ type ChartType = typeof CHART_TYPES[number];
16
+ /**
17
+ * How a chart reads its data: `cartesian` plots each series over the
18
+ * categories, `part` cuts one series into its categories (one whole), `matrix`
19
+ * is a grid of the categories (columns) by the series (rows).
20
+ */
21
+ type ChartFamily = 'cartesian' | 'part' | 'matrix';
22
+ /** What a chart type is and takes: every editor, parser and renderer reads it from here. */
23
+ interface ChartTypeInfo {
24
+ value: ChartType;
25
+ label: string;
26
+ /** One line on what the type is for (editor hint, agent docs). */
27
+ purpose: string;
28
+ /** A lucide icon name (kebab-case); the host maps it to its icon set. */
29
+ icon: string;
30
+ family: ChartFamily;
31
+ /** Exactly one series (the parts are the categories). */
32
+ singleSeries: boolean;
33
+ /** Series may sit on a left or right value axis. */
34
+ axes: boolean;
35
+ /** Series may stack. */
36
+ stacked: boolean;
37
+ /** Each series wears its own colour (else one hue in tints). */
38
+ seriesColors: boolean;
39
+ /** Value labels on the marks are possible. */
40
+ valueLabels: boolean;
41
+ /** Drawn as HTML that sizes to its content, not into a fixed canvas box. */
42
+ html: boolean;
43
+ /** Default box height in px. */
44
+ height: number;
45
+ }
46
+ declare const CHART_TYPE_INFO: Record<ChartType, ChartTypeInfo>;
47
+ declare function chartTypeInfo(type: ChartType): ChartTypeInfo;
48
+ /** Pie, donut and share: one series cut into its categories. */
49
+ declare function isPartChart(type: ChartType): boolean;
50
+ /** Bar in either direction. */
51
+ declare function isBarChart(type: ChartType): boolean;
52
+ /** Which Y axis a series scales against. Only for the types with `axes`. */
53
+ declare const CHART_AXES: readonly ["left", "right"];
54
+ type ChartAxis = typeof CHART_AXES[number];
55
+ /** Periods a date category can be grouped into. */
56
+ declare const DATE_BUCKET_VALUES: readonly ["day", "week", "month", "quarter", "year"];
57
+ type DateBucket = typeof DATE_BUCKET_VALUES[number];
58
+ /** `auto` picks the period from the date range. */
59
+ declare const BUCKET_MODES: readonly ["auto", "day", "week", "month", "quarter", "year"];
60
+ type BucketMode = typeof BUCKET_MODES[number];
61
+ /** How the records that fall in one category combine into one point. */
62
+ declare const AGGREGATIONS: readonly ["sum", "avg", "count", "min", "max", "first", "last"];
63
+ type Aggregation = typeof AGGREGATIONS[number];
64
+ /** Category order. `default` is chronological for dates, source order otherwise. */
65
+ declare const CHART_SORTS: readonly ["default", "category-asc", "category-desc", "value-desc", "value-asc"];
66
+ type ChartSort = typeof CHART_SORTS[number];
67
+ interface ChartSeriesSpec {
68
+ /** Field slug whose numeric value is the Y value. */
69
+ field: string;
70
+ label?: string;
71
+ /** Omitted: the next colour of the renderer's default rotation. */
72
+ color?: PaletteKey;
73
+ axis: ChartAxis;
74
+ aggregate: Aggregation;
75
+ }
76
+ /** A chart as authored and stored: where its data comes from and how it is shaped. */
77
+ interface ChartSpec {
78
+ title: string;
79
+ chartType: ChartType;
80
+ /** A dataset (`node.dataset`) or a saved query (`queries.<slug>`). */
81
+ source: string;
82
+ /** Field slug for the X axis or the slice labels. */
83
+ categoryField: string;
84
+ /**
85
+ * Field slug to split the first series by: one series per distinct value of
86
+ * this field (top 12 by record count, the rest as "Other"). The rows of a
87
+ * heatmap, the stacks of a bar. Empty: the series are the value fields.
88
+ */
89
+ splitField: string;
90
+ series: ChartSeriesSpec[];
91
+ /** Date categories only. */
92
+ bucket: BucketMode;
93
+ sort: ChartSort;
94
+ /** Keep the top N categories, the rest becomes "Other". 0 is no limit. Non-date only. */
95
+ limit: number;
96
+ /** Date buckets only: emit empty periods so a line stays continuous. */
97
+ fillGaps: boolean;
98
+ stacked: boolean;
99
+ legend: boolean;
100
+ }
101
+ interface ChartSeriesData {
102
+ name: string;
103
+ /** One value per category; null is a gap (nothing measured there). */
104
+ data: Array<number | null>;
105
+ /** A palette key or any CSS colour the host resolved. */
106
+ color?: string;
107
+ axis?: ChartAxis;
108
+ }
109
+ /** A chart as a renderer draws it: the data already resolved and consolidated. */
110
+ interface ChartData {
111
+ type: ChartType;
112
+ categories: string[];
113
+ series: ChartSeriesData[];
114
+ stacked?: boolean;
115
+ legend?: boolean;
116
+ }
117
+
118
+ export { AGGREGATIONS as A, BUCKET_MODES as B, DATE_BUCKET_VALUES as D, PALETTE_KEYS as P, CHART_AXES as c, CHART_SORTS as d, CHART_TYPES as e, CHART_TYPE_INFO as f, chartTypeInfo as q, isBarChart as r, isPartChart as s };
119
+ export type { ChartData as C, Aggregation as a, BucketMode as b, ChartAxis as g, ChartFamily as h, ChartSeriesData as i, ChartSeriesSpec as j, ChartSort as k, ChartSpec as l, ChartType as m, ChartTypeInfo as n, DateBucket as o, PaletteKey as p };
@@ -0,0 +1,135 @@
1
+ // src/chart.ts
2
+ var PALETTE_KEYS = ["ember", "aurora", "crimson", "dusk", "jade", "cobalt", "iris", "nebula"];
3
+ var CHART_TYPES = ["bar", "bar-horizontal", "line", "area", "pie", "donut", "share", "heatmap"];
4
+ var CHART_TYPE_INFO = {
5
+ "bar": {
6
+ value: "bar",
7
+ label: "Bar",
8
+ icon: "chart-column",
9
+ family: "cartesian",
10
+ purpose: "Compare values across categories or periods.",
11
+ singleSeries: false,
12
+ axes: true,
13
+ stacked: true,
14
+ seriesColors: true,
15
+ valueLabels: true,
16
+ html: false,
17
+ height: 300
18
+ },
19
+ "bar-horizontal": {
20
+ value: "bar-horizontal",
21
+ label: "Bar (horizontal)",
22
+ icon: "chart-bar",
23
+ family: "cartesian",
24
+ purpose: "Rank categories with long labels, largest on top when sorted by value.",
25
+ singleSeries: false,
26
+ axes: false,
27
+ stacked: true,
28
+ seriesColors: true,
29
+ valueLabels: true,
30
+ html: false,
31
+ height: 300
32
+ },
33
+ "line": {
34
+ value: "line",
35
+ label: "Line",
36
+ icon: "chart-line",
37
+ family: "cartesian",
38
+ purpose: "A trend over time.",
39
+ singleSeries: false,
40
+ axes: true,
41
+ stacked: true,
42
+ seriesColors: true,
43
+ valueLabels: false,
44
+ html: false,
45
+ height: 300
46
+ },
47
+ "area": {
48
+ value: "area",
49
+ label: "Area",
50
+ icon: "chart-area",
51
+ family: "cartesian",
52
+ purpose: "A trend over time with its volume.",
53
+ singleSeries: false,
54
+ axes: true,
55
+ stacked: true,
56
+ seriesColors: true,
57
+ valueLabels: false,
58
+ html: false,
59
+ height: 300
60
+ },
61
+ "pie": {
62
+ value: "pie",
63
+ label: "Pie",
64
+ icon: "chart-pie",
65
+ family: "part",
66
+ purpose: "Parts of one whole, few slices.",
67
+ singleSeries: true,
68
+ axes: false,
69
+ stacked: false,
70
+ seriesColors: false,
71
+ valueLabels: false,
72
+ html: false,
73
+ height: 260
74
+ },
75
+ "donut": {
76
+ value: "donut",
77
+ label: "Donut",
78
+ icon: "circle-dashed",
79
+ family: "part",
80
+ purpose: "Parts of one whole around a centred total (status, category breakdown).",
81
+ singleSeries: true,
82
+ axes: false,
83
+ stacked: false,
84
+ seriesColors: false,
85
+ valueLabels: false,
86
+ html: false,
87
+ height: 260
88
+ },
89
+ "share": {
90
+ value: "share",
91
+ label: "Share bars",
92
+ icon: "align-left",
93
+ family: "part",
94
+ purpose: "Parts of one whole as ranked thin bars with figure and percentage; reads well with many parts.",
95
+ singleSeries: true,
96
+ axes: false,
97
+ stacked: false,
98
+ seriesColors: false,
99
+ valueLabels: false,
100
+ html: true,
101
+ height: 260
102
+ },
103
+ "heatmap": {
104
+ value: "heatmap",
105
+ label: "Heatmap",
106
+ icon: "grid-3x3",
107
+ family: "matrix",
108
+ purpose: "A grid of the categories (columns) by the series (rows), one hue from faint to full.",
109
+ singleSeries: false,
110
+ axes: false,
111
+ stacked: false,
112
+ seriesColors: false,
113
+ valueLabels: true,
114
+ html: false,
115
+ height: 300
116
+ }
117
+ };
118
+ function chartTypeInfo(type) {
119
+ return CHART_TYPE_INFO[type] ?? CHART_TYPE_INFO.bar;
120
+ }
121
+ function isPartChart(type) {
122
+ return chartTypeInfo(type).family === "part";
123
+ }
124
+ function isBarChart(type) {
125
+ return type === "bar" || type === "bar-horizontal";
126
+ }
127
+ var CHART_AXES = ["left", "right"];
128
+ var DATE_BUCKET_VALUES = ["day", "week", "month", "quarter", "year"];
129
+ var BUCKET_MODES = ["auto", ...DATE_BUCKET_VALUES];
130
+ var AGGREGATIONS = ["sum", "avg", "count", "min", "max", "first", "last"];
131
+ var CHART_SORTS = ["default", "category-asc", "category-desc", "value-desc", "value-asc"];
132
+
133
+ export { AGGREGATIONS, BUCKET_MODES, CHART_AXES, CHART_SORTS, CHART_TYPES, CHART_TYPE_INFO, DATE_BUCKET_VALUES, PALETTE_KEYS, chartTypeInfo, isBarChart, isPartChart };
134
+ //# sourceMappingURL=chunk-UNIWH5QN.js.map
135
+ //# sourceMappingURL=chunk-UNIWH5QN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/chart.ts"],"names":[],"mappings":";AAYO,IAAM,YAAA,GAAe,CAAC,OAAA,EAAS,QAAA,EAAU,WAAW,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,MAAA,EAAQ,QAAQ;AAG9F,IAAM,WAAA,GAAc,CAAC,KAAA,EAAO,gBAAA,EAAkB,QAAQ,MAAA,EAAQ,KAAA,EAAO,OAAA,EAAS,OAAA,EAAS,SAAS;AAmChG,IAAM,eAAA,GAAoD;AAAA,EAC/D,KAAA,EAAO;AAAA,IACL,KAAA,EAAO,KAAA;AAAA,IAAO,KAAA,EAAO,KAAA;AAAA,IAAO,IAAA,EA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,EAAiB,cAAc,WAAW","file":"chunk-UNIWH5QN.js","sourcesContent":["/**\n * The chart contract: what a chart block is (`ChartSpec`, as authored and\n * stored) and what a renderer draws (`ChartData`, the resolved categories and\n * series). Shared by the Nordhavn OS server, the client and every renderer, so a\n * chart means the same thing wherever it is read. Pure data: no dependencies.\n * The zod schemas for these shapes live in `@nordhavnhq/beacon/schema`.\n */\n\n/**\n * The palette a series colour may pick from. A renderer maps a key to a colour\n * of the theme it runs in; a spec never carries a raw hex.\n */\nexport const PALETTE_KEYS = ['ember', 'aurora', 'crimson', 'dusk', 'jade', 'cobalt', 'iris', 'nebula'] as const\nexport type PaletteKey = typeof PALETTE_KEYS[number]\n\nexport const CHART_TYPES = ['bar', 'bar-horizontal', 'line', 'area', 'pie', 'donut', 'share', 'heatmap'] as const\nexport type ChartType = typeof CHART_TYPES[number]\n\n/**\n * How a chart reads its data: `cartesian` plots each series over the\n * categories, `part` cuts one series into its categories (one whole), `matrix`\n * is a grid of the categories (columns) by the series (rows).\n */\nexport type ChartFamily = 'cartesian' | 'part' | 'matrix'\n\n/** What a chart type is and takes: every editor, parser and renderer reads it from here. */\nexport interface ChartTypeInfo {\n value: ChartType\n label: string\n /** One line on what the type is for (editor hint, agent docs). */\n purpose: string\n /** A lucide icon name (kebab-case); the host maps it to its icon set. */\n icon: string\n family: ChartFamily\n /** Exactly one series (the parts are the categories). */\n singleSeries: boolean\n /** Series may sit on a left or right value axis. */\n axes: boolean\n /** Series may stack. */\n stacked: boolean\n /** Each series wears its own colour (else one hue in tints). */\n seriesColors: boolean\n /** Value labels on the marks are possible. */\n valueLabels: boolean\n /** Drawn as HTML that sizes to its content, not into a fixed canvas box. */\n html: boolean\n /** Default box height in px. */\n height: number\n}\n\nexport const CHART_TYPE_INFO: Record<ChartType, ChartTypeInfo> = {\n 'bar': {\n value: 'bar', label: 'Bar', icon: 'chart-column', family: 'cartesian',\n purpose: 'Compare values across categories or periods.',\n singleSeries: false, axes: true, stacked: true, seriesColors: true, valueLabels: true, html: false, height: 300,\n },\n 'bar-horizontal': {\n value: 'bar-horizontal', label: 'Bar (horizontal)', icon: 'chart-bar', family: 'cartesian',\n purpose: 'Rank categories with long labels, largest on top when sorted by value.',\n singleSeries: false, axes: false, stacked: true, seriesColors: true, valueLabels: true, html: false, height: 300,\n },\n 'line': {\n value: 'line', label: 'Line', icon: 'chart-line', family: 'cartesian',\n purpose: 'A trend over time.',\n singleSeries: false, axes: true, stacked: true, seriesColors: true, valueLabels: false, html: false, height: 300,\n },\n 'area': {\n value: 'area', label: 'Area', icon: 'chart-area', family: 'cartesian',\n purpose: 'A trend over time with its volume.',\n singleSeries: false, axes: true, stacked: true, seriesColors: true, valueLabels: false, html: false, height: 300,\n },\n 'pie': {\n value: 'pie', label: 'Pie', icon: 'chart-pie', family: 'part',\n purpose: 'Parts of one whole, few slices.',\n singleSeries: true, axes: false, stacked: false, seriesColors: false, valueLabels: false, html: false, height: 260,\n },\n 'donut': {\n value: 'donut', label: 'Donut', icon: 'circle-dashed', family: 'part',\n purpose: 'Parts of one whole around a centred total (status, category breakdown).',\n singleSeries: true, axes: false, stacked: false, seriesColors: false, valueLabels: false, html: false, height: 260,\n },\n 'share': {\n value: 'share', label: 'Share bars', icon: 'align-left', family: 'part',\n purpose: 'Parts of one whole as ranked thin bars with figure and percentage; reads well with many parts.',\n singleSeries: true, axes: false, stacked: false, seriesColors: false, valueLabels: false, html: true, height: 260,\n },\n 'heatmap': {\n value: 'heatmap', label: 'Heatmap', icon: 'grid-3x3', family: 'matrix',\n purpose: 'A grid of the categories (columns) by the series (rows), one hue from faint to full.',\n singleSeries: false, axes: false, stacked: false, seriesColors: false, valueLabels: true, html: false, height: 300,\n },\n}\n\nexport function chartTypeInfo(type: ChartType): ChartTypeInfo {\n return CHART_TYPE_INFO[type] ?? CHART_TYPE_INFO.bar\n}\n\n/** Pie, donut and share: one series cut into its categories. */\nexport function isPartChart(type: ChartType): boolean {\n return chartTypeInfo(type).family === 'part'\n}\n\n/** Bar in either direction. */\nexport function isBarChart(type: ChartType): boolean {\n return type === 'bar' || type === 'bar-horizontal'\n}\n\n/** Which Y axis a series scales against. Only for the types with `axes`. */\nexport const CHART_AXES = ['left', 'right'] as const\nexport type ChartAxis = typeof CHART_AXES[number]\n\n/** Periods a date category can be grouped into. */\nexport const DATE_BUCKET_VALUES = ['day', 'week', 'month', 'quarter', 'year'] as const\nexport type DateBucket = typeof DATE_BUCKET_VALUES[number]\n\n/** `auto` picks the period from the date range. */\nexport const BUCKET_MODES = ['auto', ...DATE_BUCKET_VALUES] as const\nexport type BucketMode = typeof BUCKET_MODES[number]\n\n/** How the records that fall in one category combine into one point. */\nexport const AGGREGATIONS = ['sum', 'avg', 'count', 'min', 'max', 'first', 'last'] as const\nexport type Aggregation = typeof AGGREGATIONS[number]\n\n/** Category order. `default` is chronological for dates, source order otherwise. */\nexport const CHART_SORTS = ['default', 'category-asc', 'category-desc', 'value-desc', 'value-asc'] as const\nexport type ChartSort = typeof CHART_SORTS[number]\n\nexport interface ChartSeriesSpec {\n /** Field slug whose numeric value is the Y value. */\n field: string\n label?: string\n /** Omitted: the next colour of the renderer's default rotation. */\n color?: PaletteKey\n axis: ChartAxis\n aggregate: Aggregation\n}\n\n/** A chart as authored and stored: where its data comes from and how it is shaped. */\nexport interface ChartSpec {\n title: string\n chartType: ChartType\n /** A dataset (`node.dataset`) or a saved query (`queries.<slug>`). */\n source: string\n /** Field slug for the X axis or the slice labels. */\n categoryField: string\n /**\n * Field slug to split the first series by: one series per distinct value of\n * this field (top 12 by record count, the rest as \"Other\"). The rows of a\n * heatmap, the stacks of a bar. Empty: the series are the value fields.\n */\n splitField: string\n series: ChartSeriesSpec[]\n /** Date categories only. */\n bucket: BucketMode\n sort: ChartSort\n /** Keep the top N categories, the rest becomes \"Other\". 0 is no limit. Non-date only. */\n limit: number\n /** Date buckets only: emit empty periods so a line stays continuous. */\n fillGaps: boolean\n stacked: boolean\n legend: boolean\n}\n\nexport interface ChartSeriesData {\n name: string\n /** One value per category; null is a gap (nothing measured there). */\n data: Array<number | null>\n /** A palette key or any CSS colour the host resolved. */\n color?: string\n axis?: ChartAxis\n}\n\n/** A chart as a renderer draws it: the data already resolved and consolidated. */\nexport interface ChartData {\n type: ChartType\n categories: string[]\n series: ChartSeriesData[]\n stacked?: boolean\n legend?: boolean\n}\n"]}