nuxt-charts 2.2.1 → 3.0.0-beta.0

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.
Files changed (92) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +80 -79
  3. package/dist/module.d.mts +4 -4
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +64 -95
  6. package/dist/runtime/assets/components.css +1 -0
  7. package/dist/runtime/assets/theme.css +1 -0
  8. package/dist/runtime/components/AreaChart.d.vue.ts +19 -0
  9. package/dist/runtime/components/AreaChart.vue +149 -0
  10. package/dist/runtime/components/AreaChart.vue.d.ts +19 -0
  11. package/dist/runtime/components/BarChart.d.vue.ts +19 -0
  12. package/dist/runtime/components/BarChart.vue +175 -0
  13. package/dist/runtime/components/BarChart.vue.d.ts +19 -0
  14. package/dist/runtime/components/BubbleChart.d.vue.ts +19 -0
  15. package/dist/runtime/components/BubbleChart.vue +213 -0
  16. package/dist/runtime/components/BubbleChart.vue.d.ts +19 -0
  17. package/dist/runtime/components/CandlestickChart.d.vue.ts +19 -0
  18. package/dist/runtime/components/CandlestickChart.vue +329 -0
  19. package/dist/runtime/components/CandlestickChart.vue.d.ts +19 -0
  20. package/dist/runtime/components/DonutChart.d.vue.ts +21 -0
  21. package/dist/runtime/components/DonutChart.vue +116 -0
  22. package/dist/runtime/components/DonutChart.vue.d.ts +21 -0
  23. package/dist/runtime/components/FunnelChart.d.vue.ts +19 -0
  24. package/dist/runtime/components/FunnelChart.vue +152 -0
  25. package/dist/runtime/components/FunnelChart.vue.d.ts +19 -0
  26. package/dist/runtime/components/LineChart.d.vue.ts +19 -0
  27. package/dist/runtime/components/LineChart.vue +84 -0
  28. package/dist/runtime/components/LineChart.vue.d.ts +19 -0
  29. package/dist/runtime/components/RadarChart.d.vue.ts +19 -0
  30. package/dist/runtime/components/RadarChart.vue +90 -0
  31. package/dist/runtime/components/RadarChart.vue.d.ts +19 -0
  32. package/dist/runtime/components/RadialBarChart.d.vue.ts +19 -0
  33. package/dist/runtime/components/RadialBarChart.vue +81 -0
  34. package/dist/runtime/components/RadialBarChart.vue.d.ts +19 -0
  35. package/dist/runtime/components/StatusTrackerChart.d.vue.ts +19 -0
  36. package/dist/runtime/components/StatusTrackerChart.vue +147 -0
  37. package/dist/runtime/components/StatusTrackerChart.vue.d.ts +19 -0
  38. package/dist/runtime/components/internal/CandlestickTooltip.d.vue.ts +17 -0
  39. package/dist/runtime/components/internal/CandlestickTooltip.vue +38 -0
  40. package/dist/runtime/components/internal/CandlestickTooltip.vue.d.ts +17 -0
  41. package/dist/runtime/components/internal/CartesianFrame.d.vue.ts +40 -0
  42. package/dist/runtime/components/internal/CartesianFrame.vue +321 -0
  43. package/dist/runtime/components/internal/CartesianFrame.vue.d.ts +40 -0
  44. package/dist/runtime/components/internal/ChartLegend.d.vue.ts +11 -0
  45. package/dist/runtime/components/internal/ChartLegend.vue +22 -0
  46. package/dist/runtime/components/internal/ChartLegend.vue.d.ts +11 -0
  47. package/dist/runtime/components/internal/ChartTooltip.d.vue.ts +3 -0
  48. package/dist/runtime/components/internal/ChartTooltip.vue +39 -0
  49. package/dist/runtime/components/internal/ChartTooltip.vue.d.ts +3 -0
  50. package/dist/runtime/components/internal/CubeBarShape.d.vue.ts +28 -0
  51. package/dist/runtime/components/internal/CubeBarShape.vue +69 -0
  52. package/dist/runtime/components/internal/CubeBarShape.vue.d.ts +28 -0
  53. package/dist/runtime/components/internal/DitherDefs.d.ts +98 -0
  54. package/dist/runtime/components/internal/DitherDefs.js +158 -0
  55. package/dist/runtime/components/internal/FunnelLayeredShape.d.vue.ts +42 -0
  56. package/dist/runtime/components/internal/FunnelLayeredShape.vue +124 -0
  57. package/dist/runtime/components/internal/FunnelLayeredShape.vue.d.ts +42 -0
  58. package/dist/runtime/components/internal/GradientDefs.d.ts +46 -0
  59. package/dist/runtime/components/internal/GradientDefs.js +38 -0
  60. package/dist/runtime/enums.d.ts +65 -0
  61. package/dist/runtime/enums.js +40 -0
  62. package/dist/runtime/types/charts.d.ts +642 -0
  63. package/dist/runtime/types/charts.js +0 -0
  64. package/dist/runtime/types/shared.d.ts +202 -0
  65. package/dist/runtime/types/shared.js +0 -0
  66. package/dist/runtime/types.d.ts +8 -0
  67. package/dist/runtime/types.js +0 -0
  68. package/dist/runtime/utils/axis.d.ts +132 -0
  69. package/dist/runtime/utils/axis.js +93 -0
  70. package/dist/runtime/utils/categories.d.ts +36 -0
  71. package/dist/runtime/utils/categories.js +18 -0
  72. package/dist/runtime/utils/cubes.d.ts +100 -0
  73. package/dist/runtime/utils/cubes.js +73 -0
  74. package/dist/runtime/utils/curve.d.ts +12 -0
  75. package/dist/runtime/utils/curve.js +26 -0
  76. package/dist/runtime/utils/dither.d.ts +55 -0
  77. package/dist/runtime/utils/dither.js +45 -0
  78. package/dist/runtime/utils/gradient.d.ts +12 -0
  79. package/dist/runtime/utils/gradient.js +8 -0
  80. package/dist/runtime/utils/index.d.ts +6 -0
  81. package/dist/runtime/utils/index.js +6 -0
  82. package/dist/runtime/utils/legend.d.ts +27 -0
  83. package/dist/runtime/utils/legend.js +19 -0
  84. package/dist/runtime/utils/marker.d.ts +20 -0
  85. package/dist/runtime/utils/marker.js +21 -0
  86. package/dist/runtime/utils/style.d.ts +14 -0
  87. package/dist/runtime/utils/style.js +10 -0
  88. package/dist/runtime/utils/theme.d.ts +36 -0
  89. package/dist/runtime/utils/theme.js +45 -0
  90. package/package.json +56 -12
  91. package/dist/runtime/vue-chrts.d.ts +0 -1
  92. package/dist/runtime/vue-chrts.js +0 -13
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Shared scaffolding for the cartesian charts (area, bar, line, bubble).
3
+ *
4
+ * Renders the responsive container, the supplied `vccs` chart container, the
5
+ * grid, axes, tooltip and legend from the v2 config props — leaving the series
6
+ * (`<Area>` / `<Bar>` / `<Line>` / `<Scatter>`) to the default slot. This keeps
7
+ * every chart adapter small and the axis/legend/tooltip wiring in one place.
8
+ */
9
+ import { type Component } from "vue";
10
+ import type { CartesianChartBaseProps } from "../../types/charts.js";
11
+ import type { Orientation } from "../../enums.js";
12
+ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
13
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<CartesianChartBaseProps<T> & {
14
+ /** The `vccs` chart container component to render (AreaChart, BarChart, …). */
15
+ container: Component;
16
+ /** Extra props forwarded to the `vccs` chart container. */
17
+ containerProps?: Record<string, unknown>;
18
+ /** Data key for the category (x) axis. */
19
+ xAxisKey?: string;
20
+ /** Bar/area orientation; drives the container `layout`. */
21
+ orientation?: Orientation;
22
+ }> & (typeof globalThis extends {
23
+ __VLS_PROPS_FALLBACK: infer P;
24
+ } ? P : {});
25
+ expose: (exposed: {}) => void;
26
+ attrs: any;
27
+ slots: {
28
+ default?: (props: {}) => any;
29
+ };
30
+ emit: {};
31
+ }>) => import("vue").VNode & {
32
+ __ctx?: Awaited<typeof __VLS_setup>;
33
+ };
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
36
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
37
+ [K in keyof T]: T[K];
38
+ } : {
39
+ [K in keyof T as K]: T[K];
40
+ }) & {};
@@ -0,0 +1,321 @@
1
+ <script setup>
2
+ import { computed, h } from "vue";
3
+ import {
4
+ CartesianGrid,
5
+ Legend,
6
+ ReferenceLine,
7
+ ResponsiveContainer,
8
+ Tooltip,
9
+ XAxis,
10
+ YAxis
11
+ } from "vccs";
12
+ import { legendPositionToLegendProps, resolveLegendWrapperStyle } from "../../utils/legend";
13
+ import {
14
+ AXIS_TICK_MARGIN,
15
+ resolveAxisProps,
16
+ resolveYAxes,
17
+ resolveXAxisHeight,
18
+ resolveYAxisWidth,
19
+ toAxisLabel,
20
+ toTickFormatter,
21
+ toTickProp
22
+ } from "../../utils/axis";
23
+ import { categoriesToSeries } from "../../utils/categories";
24
+ import { toAxisDomain, toCssProperties } from "../../utils/style";
25
+ import { axisTickVars, resolveHoverRadius, resolveHoverVisible, themeToVars } from "../../utils/theme";
26
+ import ChartTooltip from "./ChartTooltip.vue";
27
+ import ChartLegend from "./ChartLegend.vue";
28
+ const props = defineProps({
29
+ data: { type: Array, required: true },
30
+ height: { type: Number, required: true },
31
+ xLabel: { type: String, required: false },
32
+ yLabel: { type: String, required: false },
33
+ padding: { type: Object, required: false },
34
+ categories: { type: Object, required: true },
35
+ xFormatter: { type: Function, required: false },
36
+ yFormatter: { type: Function, required: false },
37
+ tooltipTitleFormatter: { type: Function, required: false },
38
+ xNumTicks: { type: Number, required: false },
39
+ yNumTicks: { type: Number, required: false },
40
+ hideLegend: { type: Boolean, required: false },
41
+ hideTooltip: { type: Boolean, required: false },
42
+ legendPosition: { type: String, required: false },
43
+ legendStyle: { type: [String, Object], required: false },
44
+ xDomainLine: { type: Boolean, required: false },
45
+ yDomainLine: { type: Boolean, required: false },
46
+ xTickLine: { type: Boolean, required: false },
47
+ yTickLine: { type: Boolean, required: false },
48
+ xGridLine: { type: Boolean, required: false },
49
+ yGridLine: { type: Boolean, required: false },
50
+ hideXAxis: { type: Boolean, required: false },
51
+ hideYAxis: { type: Boolean, required: false },
52
+ xDomain: { type: Array, required: false },
53
+ yDomain: { type: Array, required: false },
54
+ duration: { type: Number, required: false },
55
+ xAxisConfig: { type: Object, required: false },
56
+ yAxisConfig: { type: Object, required: false },
57
+ yAxes: { type: Object, required: false },
58
+ tooltip: { type: Object, required: false },
59
+ referenceLines: { type: Array, required: false },
60
+ syncId: { type: String, required: false },
61
+ minMaxTicksOnly: { type: Boolean, required: false },
62
+ xExplicitTicks: { type: Array, required: false },
63
+ yExplicitTicks: { type: Array, required: false },
64
+ crosshairConfig: { type: Object, required: false },
65
+ theme: { type: Object, required: false },
66
+ container: { type: null, required: true },
67
+ containerProps: { type: Object, required: false },
68
+ xAxisKey: { type: String, required: false },
69
+ orientation: { type: String, required: false }
70
+ });
71
+ const legend = computed(() => legendPositionToLegendProps(props.legendPosition));
72
+ const showXGrid = computed(() => props.xGridLine ?? true);
73
+ const showYGrid = computed(() => props.yGridLine ?? true);
74
+ const categoryIndexByValue = computed(() => {
75
+ const map = /* @__PURE__ */ new Map();
76
+ if (props.xAxisKey === void 0) return map;
77
+ props.data.forEach((row, i) => {
78
+ map.set(row[props.xAxisKey], i);
79
+ });
80
+ return map;
81
+ });
82
+ function withCategoryIndex(fn) {
83
+ if (!fn || props.xAxisKey === void 0) return fn;
84
+ return (value, index) => {
85
+ const i = categoryIndexByValue.value.get(value);
86
+ return fn(i ?? value, i ?? index);
87
+ };
88
+ }
89
+ const layout = computed(
90
+ () => props.orientation === "horizontal" ? "vertical" : "horizontal"
91
+ );
92
+ const rawXFormatter = computed(
93
+ () => toTickFormatter(props.xFormatter ?? props.xAxisConfig?.tickFormat)
94
+ );
95
+ const rawYFormatter = computed(
96
+ () => toTickFormatter(props.yFormatter ?? props.yAxisConfig?.tickFormat)
97
+ );
98
+ const categoryFormatter = computed(
99
+ () => withCategoryIndex(layout.value === "vertical" ? rawYFormatter.value : rawXFormatter.value)
100
+ );
101
+ const valueFormatter = computed(
102
+ () => layout.value === "vertical" ? rawXFormatter.value : rawYFormatter.value
103
+ );
104
+ const xAxisDomain = computed(() => toAxisDomain(props.xDomain));
105
+ const yAxisDomain = computed(() => toAxisDomain(props.yDomain));
106
+ const legendWrapperStyle = computed(
107
+ () => resolveLegendWrapperStyle(props.legendPosition, toCssProperties(props.legendStyle))
108
+ );
109
+ const xAxis = computed(
110
+ () => resolveAxisProps(props.xExplicitTicks, props.xAxisConfig, props.minMaxTicksOnly)
111
+ );
112
+ const yAxis = computed(
113
+ () => resolveAxisProps(props.yExplicitTicks, props.yAxisConfig, props.minMaxTicksOnly)
114
+ );
115
+ const showXTickLine = computed(() => props.xAxisConfig?.tickLine ?? props.xTickLine ?? false);
116
+ const showYTickLine = computed(() => props.yAxisConfig?.tickLine ?? props.yTickLine ?? false);
117
+ const xAxisTitle = computed(
118
+ () => toAxisLabel(layout.value === "vertical" ? props.yLabel : props.xLabel, "insideBottom")
119
+ );
120
+ const yAxisTitle = computed(
121
+ () => toAxisLabel(layout.value === "vertical" ? props.xLabel : props.yLabel, "insideLeft", {
122
+ angle: -90
123
+ })
124
+ );
125
+ const isCategoryYAxis = computed(
126
+ () => layout.value === "vertical" && props.xAxisKey !== void 0
127
+ );
128
+ const xAxisHeight = computed(() => resolveXAxisHeight({ hasTitle: !!xAxisTitle.value }));
129
+ const yAxisWidth = computed(
130
+ () => resolveYAxisWidth({ hasTitle: !!yAxisTitle.value, isCategoryAxis: isCategoryYAxis.value })
131
+ );
132
+ const rootStyle = computed(() => ({
133
+ ...themeToVars(props.theme),
134
+ ...axisTickVars("x", xAxis.value.tick),
135
+ ...axisTickVars("y", yAxis.value.tick)
136
+ }));
137
+ const xTickProp = computed(() => toTickProp(xAxis.value.tick));
138
+ const yTickProp = computed(() => toTickProp(yAxis.value.tick));
139
+ const gridStroke = "var(--vc-grid-color)";
140
+ const axisLineStyle = { stroke: "var(--vc-axis-line-color)" };
141
+ const tickLineStyle = { stroke: "var(--vc-axis-line-color)" };
142
+ const cursor = computed(
143
+ () => resolveHoverVisible(props.theme) ? {
144
+ fill: "var(--vc-hover-fill)",
145
+ stroke: "var(--vc-hover-stroke)",
146
+ radius: resolveHoverRadius(props.theme)
147
+ } : false
148
+ );
149
+ const xAxisLine = computed(() => props.xDomainLine ?? true ? axisLineStyle : false);
150
+ const yAxisLine = computed(() => props.yDomainLine ?? true ? axisLineStyle : false);
151
+ const xTickLineProp = computed(() => showXTickLine.value ? tickLineStyle : false);
152
+ const yTickLineProp = computed(() => showYTickLine.value ? tickLineStyle : false);
153
+ const mergedContainerProps = computed(() => ({
154
+ data: props.data,
155
+ layout: layout.value,
156
+ syncId: props.syncId,
157
+ ...props.containerProps
158
+ }));
159
+ const referenceLines = computed(() => props.referenceLines ?? []);
160
+ const SMALL_CATEGORY_AXIS_MAX = 12;
161
+ function resolveCategoryAxisInterval(configured, isCategoryAxis) {
162
+ if (configured !== void 0) return configured;
163
+ if (isCategoryAxis && props.data.length <= SMALL_CATEGORY_AXIS_MAX) return 0;
164
+ return void 0;
165
+ }
166
+ const xAxisInterval = computed(
167
+ () => resolveCategoryAxisInterval(
168
+ layout.value === "vertical" ? yAxis.value.interval : xAxis.value.interval,
169
+ layout.value !== "vertical" && props.xAxisKey !== void 0
170
+ )
171
+ );
172
+ const yAxisInterval = computed(
173
+ () => resolveCategoryAxisInterval(
174
+ layout.value === "vertical" ? xAxis.value.interval : yAxis.value.interval,
175
+ layout.value === "vertical" && props.xAxisKey !== void 0
176
+ )
177
+ );
178
+ const tooltipContent = computed(() => {
179
+ const formatLabel = categoryFormatter.value;
180
+ const titleFormatter = props.tooltipTitleFormatter;
181
+ return (tooltipProps) => {
182
+ let label = tooltipProps.label;
183
+ const row = tooltipProps.payload?.[0]?.payload;
184
+ if (titleFormatter && row != null) {
185
+ label = titleFormatter(row);
186
+ } else if (formatLabel != null && label !== void 0 && label !== "") {
187
+ const rowIndex = row != null ? props.data.indexOf(row) : -1;
188
+ const index = rowIndex >= 0 ? rowIndex : typeof label === "number" ? label : Number(label);
189
+ label = formatLabel(label, Number.isNaN(index) ? 0 : index);
190
+ }
191
+ return h(ChartTooltip, { ...tooltipProps, label });
192
+ };
193
+ });
194
+ const resolvedYAxes = computed(() => {
195
+ if (props.hideYAxis || layout.value === "vertical") return [];
196
+ return resolveYAxes({
197
+ series: categoriesToSeries(props.categories),
198
+ yAxes: props.yAxes,
199
+ minMaxTicksOnly: props.minMaxTicksOnly,
200
+ primary: {
201
+ ...yAxis.value,
202
+ label: props.yLabel,
203
+ domain: yAxisDomain.value,
204
+ tickCount: props.yNumTicks,
205
+ tickFormatter: valueFormatter.value,
206
+ tickLine: showYTickLine.value,
207
+ hide: false
208
+ }
209
+ });
210
+ });
211
+ </script>
212
+
213
+ <template>
214
+ <div class="vue-chrts" :style="rootStyle">
215
+ <ResponsiveContainer width="100%" :height="height">
216
+ <component :is="container" v-bind="mergedContainerProps">
217
+ <CartesianGrid
218
+ v-if="showXGrid || showYGrid"
219
+ :horizontal="showYGrid"
220
+ :vertical="showXGrid"
221
+ :stroke="gridStroke"
222
+ stroke-dasharray="var(--vc-grid-dash)"
223
+ :stroke-width="'var(--vc-grid-width)'"
224
+ />
225
+ <!--
226
+ Horizontal orientation: vccs uses layout="vertical" which swaps the axes.
227
+ The category (dataKey) axis becomes YAxis; the value axis becomes XAxis.
228
+ -->
229
+ <XAxis
230
+ v-if="!hideXAxis"
231
+ :data-key="layout === 'vertical' ? void 0 : xAxisKey"
232
+ :hide="hideXAxis"
233
+ :height="xAxisHeight"
234
+ :tick="xTickProp"
235
+ :tick-margin="AXIS_TICK_MARGIN.x"
236
+ :tick-line="xTickLineProp"
237
+ :axis-line="xAxisLine"
238
+ :tick-count="layout === 'vertical' ? yNumTicks : xNumTicks"
239
+ :tick-formatter="layout === 'vertical' ? valueFormatter : categoryFormatter"
240
+ :domain="layout === 'vertical' ? yAxisDomain : xAxisDomain"
241
+ :ticks="layout === 'vertical' ? yAxis.ticks : xAxis.ticks"
242
+ :interval="layout === 'vertical' ? yAxisInterval : xAxisInterval"
243
+ :label="xAxisTitle"
244
+ :type="layout === 'vertical' ? 'number' : 'category'"
245
+ />
246
+ <!--
247
+ Horizontal orientation keeps the single swapped category y-axis; only
248
+ the standard layout supports several value axes (one per `yAxes` id).
249
+ -->
250
+ <!-- Horizontal orientation (layout="vertical"): the single swapped category y-axis. -->
251
+ <YAxis
252
+ v-if="!hideYAxis && layout === 'vertical'"
253
+ :data-key="xAxisKey"
254
+ :width="yAxisWidth"
255
+ :tick="yTickProp"
256
+ :tick-margin="AXIS_TICK_MARGIN.y"
257
+ :tick-line="yTickLineProp"
258
+ :axis-line="yAxisLine"
259
+ :tick-count="xNumTicks"
260
+ :tick-formatter="categoryFormatter"
261
+ :domain="xAxisDomain"
262
+ :ticks="xAxis.ticks"
263
+ :interval="xAxisInterval"
264
+ :label="yAxisTitle"
265
+ type="category"
266
+ />
267
+ <!-- Standard layout: one value axis per resolved `yAxes` id (shared cutover styling). -->
268
+ <YAxis
269
+ v-for="axis in resolvedYAxes"
270
+ :key="axis.id"
271
+ :y-axis-id="axis.id"
272
+ :orientation="axis.orientation"
273
+ :hide="axis.hide"
274
+ :width="yAxisWidth"
275
+ :tick="toTickProp(axis.tick)"
276
+ :tick-margin="AXIS_TICK_MARGIN.y"
277
+ :tick-line="axis.tickLine ? yTickLineProp : false"
278
+ :axis-line="yAxisLine"
279
+ :tick-count="axis.tickCount"
280
+ :tick-formatter="axis.tickFormatter"
281
+ :domain="axis.domain"
282
+ :ticks="axis.ticks"
283
+ :interval="axis.interval"
284
+ :label="toAxisLabel(axis.label, axis.orientation === 'right' ? 'insideRight' : 'insideLeft', { angle: axis.orientation === 'right' ? 90 : -90 })"
285
+ type="number"
286
+ />
287
+
288
+ <slot />
289
+
290
+ <ReferenceLine
291
+ v-for="(line, i) in referenceLines"
292
+ :key="i"
293
+ :x="line.x"
294
+ :y="line.y"
295
+ :stroke="line.color ?? '#888'"
296
+ :stroke-width="line.strokeWidth ?? 1"
297
+ :stroke-dasharray="line.strokeDasharray"
298
+ :label="line.label"
299
+ />
300
+
301
+ <Tooltip
302
+ v-if="!hideTooltip"
303
+ :content="tooltipContent"
304
+ :cursor="cursor"
305
+ :is-animation-active="false"
306
+ />
307
+ <Legend
308
+ v-if="!hideLegend"
309
+ :align="legend.align"
310
+ :vertical-align="legend.verticalAlign"
311
+ :layout="legend.layout"
312
+ :wrapper-style="legendWrapperStyle"
313
+ >
314
+ <template #content="slotProps">
315
+ <ChartLegend v-bind="slotProps" />
316
+ </template>
317
+ </Legend>
318
+ </component>
319
+ </ResponsiveContainer>
320
+ </div>
321
+ </template>
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Shared scaffolding for the cartesian charts (area, bar, line, bubble).
3
+ *
4
+ * Renders the responsive container, the supplied `vccs` chart container, the
5
+ * grid, axes, tooltip and legend from the v2 config props — leaving the series
6
+ * (`<Area>` / `<Bar>` / `<Line>` / `<Scatter>`) to the default slot. This keeps
7
+ * every chart adapter small and the axis/legend/tooltip wiring in one place.
8
+ */
9
+ import { type Component } from "vue";
10
+ import type { CartesianChartBaseProps } from "../../types/charts.js";
11
+ import type { Orientation } from "../../enums.js";
12
+ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
13
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<CartesianChartBaseProps<T> & {
14
+ /** The `vccs` chart container component to render (AreaChart, BarChart, …). */
15
+ container: Component;
16
+ /** Extra props forwarded to the `vccs` chart container. */
17
+ containerProps?: Record<string, unknown>;
18
+ /** Data key for the category (x) axis. */
19
+ xAxisKey?: string;
20
+ /** Bar/area orientation; drives the container `layout`. */
21
+ orientation?: Orientation;
22
+ }> & (typeof globalThis extends {
23
+ __VLS_PROPS_FALLBACK: infer P;
24
+ } ? P : {});
25
+ expose: (exposed: {}) => void;
26
+ attrs: any;
27
+ slots: {
28
+ default?: (props: {}) => any;
29
+ };
30
+ emit: {};
31
+ }>) => import("vue").VNode & {
32
+ __ctx?: Awaited<typeof __VLS_setup>;
33
+ };
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
36
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
37
+ [K in keyof T]: T[K];
38
+ } : {
39
+ [K in keyof T as K]: T[K];
40
+ }) & {};
@@ -0,0 +1,11 @@
1
+ interface LegendItem {
2
+ value: string;
3
+ color?: string;
4
+ inactive?: boolean;
5
+ }
6
+ type __VLS_Props = {
7
+ payload?: LegendItem[];
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,22 @@
1
+ <script setup>
2
+ defineProps({
3
+ payload: { type: Array, required: false }
4
+ });
5
+ </script>
6
+
7
+ <template>
8
+ <ul class="vc-legend">
9
+ <li
10
+ v-for="item in payload"
11
+ :key="item.value"
12
+ class="vc-legend__item"
13
+ :class="{ 'vc-legend__item--inactive': item.inactive }"
14
+ >
15
+ <span
16
+ class="vc-legend__dot"
17
+ :style="{ background: item.color }"
18
+ />
19
+ <span class="vc-legend__label">{{ item.value }}</span>
20
+ </li>
21
+ </ul>
22
+ </template>
@@ -0,0 +1,11 @@
1
+ interface LegendItem {
2
+ value: string;
3
+ color?: string;
4
+ inactive?: boolean;
5
+ }
6
+ type __VLS_Props = {
7
+ payload?: LegendItem[];
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,39 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ defineOptions({ name: "ChartTooltip", inheritAttrs: false });
4
+ const props = defineProps({
5
+ label: { type: [String, Number], required: false },
6
+ payload: { type: Array, required: true },
7
+ coordinate: { type: Object, required: false },
8
+ active: { type: Boolean, required: true },
9
+ accessibilityLayer: { type: Boolean, required: true }
10
+ });
11
+ const items = computed(
12
+ () => (props.payload ?? []).filter((p) => p.value !== null && p.value !== void 0)
13
+ );
14
+ function formatValue(value) {
15
+ if (typeof value === "number") return value.toLocaleString();
16
+ return String(value);
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <div
22
+ v-if="active && items.length"
23
+ class="vc-tooltip"
24
+ >
25
+ <p v-if="label !== void 0 && label !== ''" class="vc-tooltip__label">
26
+ {{ label }}
27
+ </p>
28
+ <ul class="vc-tooltip__list">
29
+ <li v-for="item in items" :key="item.dataKey" class="vc-tooltip__item">
30
+ <span
31
+ class="vc-tooltip__dot"
32
+ :style="{ background: item.color ?? item.fill ?? item.stroke }"
33
+ />
34
+ <span class="vc-tooltip__name">{{ item.name }}</span>
35
+ <span class="vc-tooltip__value">{{ formatValue(item.value) }}</span>
36
+ </li>
37
+ </ul>
38
+ </div>
39
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { type CubeColumnBand } from "../../utils/cubes.js";
2
+ type __VLS_Props = {
3
+ x?: number | null;
4
+ y?: number | null;
5
+ width?: number;
6
+ height?: number;
7
+ background?: CubeColumnBand | null;
8
+ fill?: string;
9
+ gap?: number;
10
+ radius?: number;
11
+ preferredSize?: number;
12
+ /** When set below preferredSize, cubes shrink from top → bottom. */
13
+ minSize?: number;
14
+ /** Floor opacity when size-tapering (top = 1). Default 0.05. */
15
+ minOpacity?: number;
16
+ emptyColor?: string;
17
+ /** When false, only filled cubes are emitted (stacked layers above the first). */
18
+ includeEmpty?: boolean;
19
+ };
20
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
21
+ gap: number;
22
+ radius: number;
23
+ preferredSize: number;
24
+ emptyColor: string;
25
+ includeEmpty: boolean;
26
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
@@ -0,0 +1,69 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import {
4
+ DEFAULT_CUBE_EMPTY_COLOR,
5
+ DEFAULT_CUBE_GAP,
6
+ DEFAULT_CUBE_RADIUS,
7
+ DEFAULT_CUBE_SIZE,
8
+ layoutCubeColumn
9
+ } from "../../utils/cubes";
10
+ const props = defineProps({
11
+ x: { type: [Number, null], required: false },
12
+ y: { type: [Number, null], required: false },
13
+ width: { type: Number, required: false },
14
+ height: { type: Number, required: false },
15
+ background: { type: [Object, null], required: false },
16
+ fill: { type: String, required: false },
17
+ gap: { type: Number, required: false, default: DEFAULT_CUBE_GAP },
18
+ radius: { type: Number, required: false, default: DEFAULT_CUBE_RADIUS },
19
+ preferredSize: { type: Number, required: false, default: DEFAULT_CUBE_SIZE },
20
+ minSize: { type: Number, required: false },
21
+ minOpacity: { type: Number, required: false },
22
+ emptyColor: { type: String, required: false, default: DEFAULT_CUBE_EMPTY_COLOR },
23
+ includeEmpty: { type: Boolean, required: false, default: true }
24
+ });
25
+ const cubes = computed(() => {
26
+ const hasBackground = props.background && props.background.width > 0 && props.background.height > 0;
27
+ const hasBar = props.x != null && props.y != null && (props.width ?? 0) > 0 && (props.height ?? 0) > 0;
28
+ const column = hasBackground && hasBar ? {
29
+ x: props.x,
30
+ y: props.background.y,
31
+ width: props.width,
32
+ height: props.background.height
33
+ } : hasBackground ? props.background : hasBar ? {
34
+ x: props.x,
35
+ y: props.y,
36
+ width: props.width,
37
+ height: props.height
38
+ } : null;
39
+ if (!column) return [];
40
+ return layoutCubeColumn({
41
+ column,
42
+ valueHeight: Math.max(0, props.height ?? 0),
43
+ segmentY: hasBackground ? props.y ?? void 0 : void 0,
44
+ includeEmpty: props.includeEmpty,
45
+ gap: props.gap,
46
+ radius: props.radius,
47
+ preferredSize: props.preferredSize,
48
+ minSize: props.minSize,
49
+ minOpacity: props.minOpacity
50
+ });
51
+ });
52
+ </script>
53
+
54
+ <template>
55
+ <g class="vc-cube-bar">
56
+ <rect
57
+ v-for="(cube, i) in cubes"
58
+ :key="i"
59
+ :x="cube.x"
60
+ :y="cube.y"
61
+ :width="cube.size"
62
+ :height="cube.size"
63
+ :rx="cube.radius"
64
+ :ry="cube.radius"
65
+ :fill="cube.filled ? fill ?? 'currentColor' : emptyColor"
66
+ :fill-opacity="cube.opacity"
67
+ />
68
+ </g>
69
+ </template>
@@ -0,0 +1,28 @@
1
+ import { type CubeColumnBand } from "../../utils/cubes.js";
2
+ type __VLS_Props = {
3
+ x?: number | null;
4
+ y?: number | null;
5
+ width?: number;
6
+ height?: number;
7
+ background?: CubeColumnBand | null;
8
+ fill?: string;
9
+ gap?: number;
10
+ radius?: number;
11
+ preferredSize?: number;
12
+ /** When set below preferredSize, cubes shrink from top → bottom. */
13
+ minSize?: number;
14
+ /** Floor opacity when size-tapering (top = 1). Default 0.05. */
15
+ minOpacity?: number;
16
+ emptyColor?: string;
17
+ /** When false, only filled cubes are emitted (stacked layers above the first). */
18
+ includeEmpty?: boolean;
19
+ };
20
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
21
+ gap: number;
22
+ radius: number;
23
+ preferredSize: number;
24
+ emptyColor: string;
25
+ includeEmpty: boolean;
26
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;