nuxt-charts 2.2.1 → 3.0.0-beta.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.
Files changed (94) 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 +117 -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/ChartContainer.d.ts +91 -0
  45. package/dist/runtime/components/internal/ChartContainer.js +111 -0
  46. package/dist/runtime/components/internal/ChartLegend.d.vue.ts +11 -0
  47. package/dist/runtime/components/internal/ChartLegend.vue +22 -0
  48. package/dist/runtime/components/internal/ChartLegend.vue.d.ts +11 -0
  49. package/dist/runtime/components/internal/ChartTooltip.d.vue.ts +3 -0
  50. package/dist/runtime/components/internal/ChartTooltip.vue +39 -0
  51. package/dist/runtime/components/internal/ChartTooltip.vue.d.ts +3 -0
  52. package/dist/runtime/components/internal/CubeBarShape.d.vue.ts +28 -0
  53. package/dist/runtime/components/internal/CubeBarShape.vue +69 -0
  54. package/dist/runtime/components/internal/CubeBarShape.vue.d.ts +28 -0
  55. package/dist/runtime/components/internal/DitherDefs.d.ts +98 -0
  56. package/dist/runtime/components/internal/DitherDefs.js +158 -0
  57. package/dist/runtime/components/internal/FunnelLayeredShape.d.vue.ts +42 -0
  58. package/dist/runtime/components/internal/FunnelLayeredShape.vue +124 -0
  59. package/dist/runtime/components/internal/FunnelLayeredShape.vue.d.ts +42 -0
  60. package/dist/runtime/components/internal/GradientDefs.d.ts +46 -0
  61. package/dist/runtime/components/internal/GradientDefs.js +38 -0
  62. package/dist/runtime/enums.d.ts +65 -0
  63. package/dist/runtime/enums.js +40 -0
  64. package/dist/runtime/types/charts.d.ts +642 -0
  65. package/dist/runtime/types/charts.js +0 -0
  66. package/dist/runtime/types/shared.d.ts +202 -0
  67. package/dist/runtime/types/shared.js +0 -0
  68. package/dist/runtime/types.d.ts +8 -0
  69. package/dist/runtime/types.js +0 -0
  70. package/dist/runtime/utils/axis.d.ts +132 -0
  71. package/dist/runtime/utils/axis.js +93 -0
  72. package/dist/runtime/utils/categories.d.ts +36 -0
  73. package/dist/runtime/utils/categories.js +18 -0
  74. package/dist/runtime/utils/cubes.d.ts +100 -0
  75. package/dist/runtime/utils/cubes.js +73 -0
  76. package/dist/runtime/utils/curve.d.ts +12 -0
  77. package/dist/runtime/utils/curve.js +26 -0
  78. package/dist/runtime/utils/dither.d.ts +55 -0
  79. package/dist/runtime/utils/dither.js +45 -0
  80. package/dist/runtime/utils/gradient.d.ts +12 -0
  81. package/dist/runtime/utils/gradient.js +8 -0
  82. package/dist/runtime/utils/index.d.ts +6 -0
  83. package/dist/runtime/utils/index.js +6 -0
  84. package/dist/runtime/utils/legend.d.ts +27 -0
  85. package/dist/runtime/utils/legend.js +19 -0
  86. package/dist/runtime/utils/marker.d.ts +20 -0
  87. package/dist/runtime/utils/marker.js +21 -0
  88. package/dist/runtime/utils/style.d.ts +14 -0
  89. package/dist/runtime/utils/style.js +10 -0
  90. package/dist/runtime/utils/theme.d.ts +36 -0
  91. package/dist/runtime/utils/theme.js +45 -0
  92. package/package.json +56 -12
  93. package/dist/runtime/vue-chrts.d.ts +0 -1
  94. 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
+ Tooltip,
8
+ XAxis,
9
+ YAxis
10
+ } from "vccs";
11
+ import ChartContainer from "./ChartContainer";
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
+ <ChartContainer 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
+ </ChartContainer>
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,91 @@
1
+ import { type PropType, type VNode } from "vue";
2
+ type Size = number | string;
3
+ /**
4
+ * Drop-in replacement for `vccs`' `ResponsiveContainer`.
5
+ *
6
+ * Upstream renders children through `resolveDynamicComponent(() => renderChildren())`,
7
+ * which produces a new component type every render and so unmounts + remounts the
8
+ * whole chart subtree. Charts that dispatch on `mouseenter` (radial bar, radar) then
9
+ * loop forever — remount recreates the `<path>` under the cursor, which refires
10
+ * `mouseenter` — and freeze the tab. Rendering the cloned children directly keeps
11
+ * the subtree stable.
12
+ */
13
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
+ width: {
15
+ type: PropType<Size>;
16
+ default: string;
17
+ };
18
+ height: {
19
+ type: PropType<Size>;
20
+ default: string;
21
+ };
22
+ aspect: {
23
+ type: NumberConstructor;
24
+ default: undefined;
25
+ };
26
+ minWidth: {
27
+ type: PropType<Size>;
28
+ default: number;
29
+ };
30
+ minHeight: {
31
+ type: PropType<Size>;
32
+ default: undefined;
33
+ };
34
+ maxHeight: {
35
+ type: PropType<Size>;
36
+ default: undefined;
37
+ };
38
+ id: {
39
+ type: StringConstructor;
40
+ default: undefined;
41
+ };
42
+ onResize: {
43
+ type: PropType<(width: number, height: number) => void>;
44
+ default: undefined;
45
+ };
46
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
47
+ [key: string]: any;
48
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
49
+ width: {
50
+ type: PropType<Size>;
51
+ default: string;
52
+ };
53
+ height: {
54
+ type: PropType<Size>;
55
+ default: string;
56
+ };
57
+ aspect: {
58
+ type: NumberConstructor;
59
+ default: undefined;
60
+ };
61
+ minWidth: {
62
+ type: PropType<Size>;
63
+ default: number;
64
+ };
65
+ minHeight: {
66
+ type: PropType<Size>;
67
+ default: undefined;
68
+ };
69
+ maxHeight: {
70
+ type: PropType<Size>;
71
+ default: undefined;
72
+ };
73
+ id: {
74
+ type: StringConstructor;
75
+ default: undefined;
76
+ };
77
+ onResize: {
78
+ type: PropType<(width: number, height: number) => void>;
79
+ default: undefined;
80
+ };
81
+ }>> & Readonly<{}>, {
82
+ width: Size;
83
+ height: Size;
84
+ aspect: number;
85
+ minWidth: Size;
86
+ minHeight: Size;
87
+ maxHeight: Size;
88
+ id: string;
89
+ onResize: (width: number, height: number) => void;
90
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
91
+ export default _default;
@@ -0,0 +1,111 @@
1
+ import {
2
+ cloneVNode,
3
+ computed,
4
+ defineComponent,
5
+ Fragment,
6
+ h,
7
+ onBeforeUnmount,
8
+ onMounted,
9
+ ref
10
+ } from "vue";
11
+ const isPercent = (value) => typeof value === "string" && value.endsWith("%");
12
+ const toCssSize = (value) => value == null ? void 0 : typeof value === "number" ? `${value}px` : value;
13
+ function flatten(vnodes) {
14
+ const result = [];
15
+ for (const vnode of vnodes) {
16
+ if (vnode.type === Fragment && Array.isArray(vnode.children))
17
+ result.push(...flatten(vnode.children));
18
+ else result.push(vnode);
19
+ }
20
+ return result;
21
+ }
22
+ export default defineComponent({
23
+ name: "ChartContainer",
24
+ inheritAttrs: false,
25
+ props: {
26
+ width: { type: [Number, String], default: "100%" },
27
+ height: { type: [Number, String], default: "100%" },
28
+ aspect: { type: Number, default: void 0 },
29
+ minWidth: { type: [Number, String], default: 0 },
30
+ minHeight: { type: [Number, String], default: void 0 },
31
+ maxHeight: { type: [Number, String], default: void 0 },
32
+ id: { type: String, default: void 0 },
33
+ onResize: { type: Function, default: void 0 }
34
+ },
35
+ setup(props, { slots }) {
36
+ const containerRef = ref();
37
+ const sizes = ref({ width: -1, height: -1 });
38
+ const calculatedWidth = computed(
39
+ () => isPercent(props.width) ? sizes.value.width : Number(props.width)
40
+ );
41
+ const calculatedHeight = computed(() => {
42
+ if (props.aspect && props.aspect > 0 && (props.height == null || props.height === "auto"))
43
+ return calculatedWidth.value / props.aspect;
44
+ return isPercent(props.height) ? sizes.value.height : Number(props.height);
45
+ });
46
+ const finalWidth = computed(() => {
47
+ if (props.aspect && props.aspect > 0 && (props.width == null || props.width === "auto"))
48
+ return calculatedHeight.value * props.aspect;
49
+ return calculatedWidth.value;
50
+ });
51
+ const isReady = computed(() => sizes.value.width >= 0 && sizes.value.height >= 0);
52
+ const containerStyle = computed(() => ({
53
+ width: toCssSize(props.width),
54
+ height: toCssSize(props.height),
55
+ minWidth: toCssSize(props.minWidth),
56
+ minHeight: toCssSize(props.minHeight),
57
+ maxHeight: toCssSize(props.maxHeight)
58
+ }));
59
+ function setSize(width, height) {
60
+ const next = { width: Math.round(width), height: Math.round(height) };
61
+ if (next.width === sizes.value.width && next.height === sizes.value.height) return;
62
+ sizes.value = next;
63
+ props.onResize?.(next.width, next.height);
64
+ }
65
+ let observer = null;
66
+ onMounted(() => {
67
+ const el = containerRef.value;
68
+ if (!el) return;
69
+ const rect = el.getBoundingClientRect();
70
+ setSize(rect.width, rect.height);
71
+ observer = new ResizeObserver((entries) => {
72
+ const { width, height } = entries[0].contentRect;
73
+ setSize(width, height);
74
+ });
75
+ observer.observe(el);
76
+ });
77
+ onBeforeUnmount(() => {
78
+ observer?.disconnect();
79
+ observer = null;
80
+ });
81
+ function renderChildren() {
82
+ if (!isReady.value) return [];
83
+ const raw = slots.default?.();
84
+ if (!raw) return [];
85
+ return flatten(raw).map(
86
+ (child, index) => cloneVNode(child, {
87
+ width: finalWidth.value,
88
+ height: calculatedHeight.value,
89
+ key: child.key || `chart-container-child-${index}`,
90
+ style: {
91
+ maxWidth: `${sizes.value.width}px`,
92
+ maxHeight: `${sizes.value.height}px`,
93
+ width: "100%",
94
+ height: "100%",
95
+ ...child.props?.style
96
+ }
97
+ })
98
+ );
99
+ }
100
+ return () => h(
101
+ "div",
102
+ {
103
+ id: props.id,
104
+ ref: containerRef,
105
+ class: "vcharts-responsive-container",
106
+ style: containerStyle.value
107
+ },
108
+ renderChildren()
109
+ );
110
+ }
111
+ });
@@ -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;