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.
- package/LICENSE +1 -1
- package/README.md +80 -79
- package/dist/module.d.mts +4 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +64 -95
- package/dist/runtime/assets/components.css +1 -0
- package/dist/runtime/assets/theme.css +1 -0
- package/dist/runtime/components/AreaChart.d.vue.ts +19 -0
- package/dist/runtime/components/AreaChart.vue +149 -0
- package/dist/runtime/components/AreaChart.vue.d.ts +19 -0
- package/dist/runtime/components/BarChart.d.vue.ts +19 -0
- package/dist/runtime/components/BarChart.vue +175 -0
- package/dist/runtime/components/BarChart.vue.d.ts +19 -0
- package/dist/runtime/components/BubbleChart.d.vue.ts +19 -0
- package/dist/runtime/components/BubbleChart.vue +213 -0
- package/dist/runtime/components/BubbleChart.vue.d.ts +19 -0
- package/dist/runtime/components/CandlestickChart.d.vue.ts +19 -0
- package/dist/runtime/components/CandlestickChart.vue +329 -0
- package/dist/runtime/components/CandlestickChart.vue.d.ts +19 -0
- package/dist/runtime/components/DonutChart.d.vue.ts +21 -0
- package/dist/runtime/components/DonutChart.vue +116 -0
- package/dist/runtime/components/DonutChart.vue.d.ts +21 -0
- package/dist/runtime/components/FunnelChart.d.vue.ts +19 -0
- package/dist/runtime/components/FunnelChart.vue +152 -0
- package/dist/runtime/components/FunnelChart.vue.d.ts +19 -0
- package/dist/runtime/components/LineChart.d.vue.ts +19 -0
- package/dist/runtime/components/LineChart.vue +84 -0
- package/dist/runtime/components/LineChart.vue.d.ts +19 -0
- package/dist/runtime/components/RadarChart.d.vue.ts +19 -0
- package/dist/runtime/components/RadarChart.vue +90 -0
- package/dist/runtime/components/RadarChart.vue.d.ts +19 -0
- package/dist/runtime/components/RadialBarChart.d.vue.ts +19 -0
- package/dist/runtime/components/RadialBarChart.vue +81 -0
- package/dist/runtime/components/RadialBarChart.vue.d.ts +19 -0
- package/dist/runtime/components/StatusTrackerChart.d.vue.ts +19 -0
- package/dist/runtime/components/StatusTrackerChart.vue +147 -0
- package/dist/runtime/components/StatusTrackerChart.vue.d.ts +19 -0
- package/dist/runtime/components/internal/CandlestickTooltip.d.vue.ts +17 -0
- package/dist/runtime/components/internal/CandlestickTooltip.vue +38 -0
- package/dist/runtime/components/internal/CandlestickTooltip.vue.d.ts +17 -0
- package/dist/runtime/components/internal/CartesianFrame.d.vue.ts +40 -0
- package/dist/runtime/components/internal/CartesianFrame.vue +321 -0
- package/dist/runtime/components/internal/CartesianFrame.vue.d.ts +40 -0
- package/dist/runtime/components/internal/ChartLegend.d.vue.ts +11 -0
- package/dist/runtime/components/internal/ChartLegend.vue +22 -0
- package/dist/runtime/components/internal/ChartLegend.vue.d.ts +11 -0
- package/dist/runtime/components/internal/ChartTooltip.d.vue.ts +3 -0
- package/dist/runtime/components/internal/ChartTooltip.vue +39 -0
- package/dist/runtime/components/internal/ChartTooltip.vue.d.ts +3 -0
- package/dist/runtime/components/internal/CubeBarShape.d.vue.ts +28 -0
- package/dist/runtime/components/internal/CubeBarShape.vue +69 -0
- package/dist/runtime/components/internal/CubeBarShape.vue.d.ts +28 -0
- package/dist/runtime/components/internal/DitherDefs.d.ts +98 -0
- package/dist/runtime/components/internal/DitherDefs.js +158 -0
- package/dist/runtime/components/internal/FunnelLayeredShape.d.vue.ts +42 -0
- package/dist/runtime/components/internal/FunnelLayeredShape.vue +124 -0
- package/dist/runtime/components/internal/FunnelLayeredShape.vue.d.ts +42 -0
- package/dist/runtime/components/internal/GradientDefs.d.ts +46 -0
- package/dist/runtime/components/internal/GradientDefs.js +38 -0
- package/dist/runtime/enums.d.ts +65 -0
- package/dist/runtime/enums.js +40 -0
- package/dist/runtime/types/charts.d.ts +642 -0
- package/dist/runtime/types/charts.js +0 -0
- package/dist/runtime/types/shared.d.ts +202 -0
- package/dist/runtime/types/shared.js +0 -0
- package/dist/runtime/types.d.ts +8 -0
- package/dist/runtime/types.js +0 -0
- package/dist/runtime/utils/axis.d.ts +132 -0
- package/dist/runtime/utils/axis.js +93 -0
- package/dist/runtime/utils/categories.d.ts +36 -0
- package/dist/runtime/utils/categories.js +18 -0
- package/dist/runtime/utils/cubes.d.ts +100 -0
- package/dist/runtime/utils/cubes.js +73 -0
- package/dist/runtime/utils/curve.d.ts +12 -0
- package/dist/runtime/utils/curve.js +26 -0
- package/dist/runtime/utils/dither.d.ts +55 -0
- package/dist/runtime/utils/dither.js +45 -0
- package/dist/runtime/utils/gradient.d.ts +12 -0
- package/dist/runtime/utils/gradient.js +8 -0
- package/dist/runtime/utils/index.d.ts +6 -0
- package/dist/runtime/utils/index.js +6 -0
- package/dist/runtime/utils/legend.d.ts +27 -0
- package/dist/runtime/utils/legend.js +19 -0
- package/dist/runtime/utils/marker.d.ts +20 -0
- package/dist/runtime/utils/marker.js +21 -0
- package/dist/runtime/utils/style.d.ts +14 -0
- package/dist/runtime/utils/style.js +10 -0
- package/dist/runtime/utils/theme.d.ts +36 -0
- package/dist/runtime/utils/theme.js +45 -0
- package/package.json +56 -12
- package/dist/runtime/vue-chrts.d.ts +0 -1
- package/dist/runtime/vue-chrts.js +0 -13
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
import { type DitherVariant } from "../../utils/dither.js";
|
|
3
|
+
import type { GradientStop } from "../../utils/gradient.js";
|
|
4
|
+
type SeriesItem = {
|
|
5
|
+
dataKey: string;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Renders one tiling `<pattern>` of dots per series inside a `<defs>` block,
|
|
10
|
+
* for the dithered (halftone) area fill.
|
|
11
|
+
*
|
|
12
|
+
* When `fadeStops` is set, also emits a shared vertical opacity mask (and a
|
|
13
|
+
* scoped style that applies it only to `.v-charts-area-area`) so the dither
|
|
14
|
+
* dissolves toward the baseline the same way a gradient fill does — without
|
|
15
|
+
* fading the stroke, which shares attrs with the fill path in `vccs`.
|
|
16
|
+
*
|
|
17
|
+
* Like `GradientDefs`, this is a render-function component on purpose: SVG
|
|
18
|
+
* elements written in an SFC `<template>` that is not lexically nested inside
|
|
19
|
+
* an `<svg>` tag are parsed in the HTML namespace and silently dropped when
|
|
20
|
+
* placed via a component slot. Building them with `h()` sets the correct SVG
|
|
21
|
+
* namespace so `fill="url(#…)"` resolves.
|
|
22
|
+
*/
|
|
23
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
24
|
+
series: {
|
|
25
|
+
type: PropType<SeriesItem[]>;
|
|
26
|
+
required: true;
|
|
27
|
+
};
|
|
28
|
+
variant: {
|
|
29
|
+
type: PropType<DitherVariant>;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
scope: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
required: true;
|
|
35
|
+
};
|
|
36
|
+
/** Tile edge length in px. Smaller tiles read as a finer texture. */
|
|
37
|
+
tile: {
|
|
38
|
+
type: NumberConstructor;
|
|
39
|
+
default: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* When set, compose the dither with a vertical opacity fade (same stops
|
|
43
|
+
* shape as `gradientStops`). Omit for a flat, full-opacity dither.
|
|
44
|
+
*/
|
|
45
|
+
fadeStops: {
|
|
46
|
+
type: PropType<GradientStop[]>;
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Plot height in px. Used to size the wash gradient so it spans the chart
|
|
51
|
+
* rather than repeating with the dot tile.
|
|
52
|
+
*/
|
|
53
|
+
height: {
|
|
54
|
+
type: NumberConstructor;
|
|
55
|
+
default: number;
|
|
56
|
+
};
|
|
57
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
60
|
+
series: {
|
|
61
|
+
type: PropType<SeriesItem[]>;
|
|
62
|
+
required: true;
|
|
63
|
+
};
|
|
64
|
+
variant: {
|
|
65
|
+
type: PropType<DitherVariant>;
|
|
66
|
+
required: true;
|
|
67
|
+
};
|
|
68
|
+
scope: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
required: true;
|
|
71
|
+
};
|
|
72
|
+
/** Tile edge length in px. Smaller tiles read as a finer texture. */
|
|
73
|
+
tile: {
|
|
74
|
+
type: NumberConstructor;
|
|
75
|
+
default: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* When set, compose the dither with a vertical opacity fade (same stops
|
|
79
|
+
* shape as `gradientStops`). Omit for a flat, full-opacity dither.
|
|
80
|
+
*/
|
|
81
|
+
fadeStops: {
|
|
82
|
+
type: PropType<GradientStop[]>;
|
|
83
|
+
default: undefined;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Plot height in px. Used to size the wash gradient so it spans the chart
|
|
87
|
+
* rather than repeating with the dot tile.
|
|
88
|
+
*/
|
|
89
|
+
height: {
|
|
90
|
+
type: NumberConstructor;
|
|
91
|
+
default: number;
|
|
92
|
+
};
|
|
93
|
+
}>> & Readonly<{}>, {
|
|
94
|
+
height: number;
|
|
95
|
+
tile: number;
|
|
96
|
+
fadeStops: GradientStop[];
|
|
97
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
98
|
+
export default _default;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import {
|
|
3
|
+
buildDitherPattern,
|
|
4
|
+
ditherFadeMaskId,
|
|
5
|
+
ditherId,
|
|
6
|
+
dotsId
|
|
7
|
+
} from "../../utils/dither.js";
|
|
8
|
+
export default defineComponent({
|
|
9
|
+
name: "DitherDefs",
|
|
10
|
+
props: {
|
|
11
|
+
series: {
|
|
12
|
+
type: Array,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
variant: { type: String, required: true },
|
|
16
|
+
scope: { type: String, required: true },
|
|
17
|
+
/** Tile edge length in px. Smaller tiles read as a finer texture. */
|
|
18
|
+
tile: { type: Number, default: 8 },
|
|
19
|
+
/**
|
|
20
|
+
* When set, compose the dither with a vertical opacity fade (same stops
|
|
21
|
+
* shape as `gradientStops`). Omit for a flat, full-opacity dither.
|
|
22
|
+
*/
|
|
23
|
+
fadeStops: { type: Array, default: void 0 },
|
|
24
|
+
/**
|
|
25
|
+
* Plot height in px. Used to size the wash gradient so it spans the chart
|
|
26
|
+
* rather than repeating with the dot tile.
|
|
27
|
+
*/
|
|
28
|
+
height: { type: Number, default: 0 }
|
|
29
|
+
},
|
|
30
|
+
setup: (props) => () => {
|
|
31
|
+
const pattern = buildDitherPattern(props.variant, props.tile);
|
|
32
|
+
const stops = props.fadeStops;
|
|
33
|
+
const dotPatterns = props.series.map(
|
|
34
|
+
(series) => h(
|
|
35
|
+
"pattern",
|
|
36
|
+
{
|
|
37
|
+
id: dotsId(series.dataKey, props.scope),
|
|
38
|
+
key: `dots-${series.dataKey}`,
|
|
39
|
+
width: pattern.tile,
|
|
40
|
+
height: pattern.tile,
|
|
41
|
+
patternUnits: "userSpaceOnUse"
|
|
42
|
+
},
|
|
43
|
+
pattern.dots.map(
|
|
44
|
+
(dot, index) => h("circle", {
|
|
45
|
+
key: index,
|
|
46
|
+
cx: dot.cx * pattern.tile,
|
|
47
|
+
cy: dot.cy * pattern.tile,
|
|
48
|
+
r: dot.r * pattern.tile,
|
|
49
|
+
fill: series.color
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
if (!stops?.length) {
|
|
55
|
+
const aliases = props.series.map(
|
|
56
|
+
(series) => h("pattern", {
|
|
57
|
+
id: ditherId(series.dataKey, props.scope),
|
|
58
|
+
key: `alias-${series.dataKey}`,
|
|
59
|
+
width: pattern.tile,
|
|
60
|
+
height: pattern.tile,
|
|
61
|
+
patternUnits: "userSpaceOnUse",
|
|
62
|
+
href: `#${dotsId(series.dataKey, props.scope)}`
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
return h("defs", {}, [...dotPatterns, ...aliases]);
|
|
66
|
+
}
|
|
67
|
+
const height = props.height || 1;
|
|
68
|
+
const fadeMaskId = `${ditherFadeMaskId(props.scope)}-dots`;
|
|
69
|
+
const fadeGradId = `${fadeMaskId}-grad`;
|
|
70
|
+
const fadeDefs = [
|
|
71
|
+
h(
|
|
72
|
+
"linearGradient",
|
|
73
|
+
{ id: fadeGradId, key: "dot-fade-grad", x1: 0, y1: 0, x2: 0, y2: 1 },
|
|
74
|
+
stops.map(
|
|
75
|
+
(stop, index) => h("stop", {
|
|
76
|
+
key: index,
|
|
77
|
+
offset: stop.offset,
|
|
78
|
+
"stop-color": "#fff",
|
|
79
|
+
// Normalise so the texture starts fully opaque and only the *shape*
|
|
80
|
+
// of the ramp is taken from the caller's stops.
|
|
81
|
+
"stop-opacity": stop.stopOpacity / (stops[0]?.stopOpacity || 1)
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
),
|
|
85
|
+
h(
|
|
86
|
+
"mask",
|
|
87
|
+
{ id: fadeMaskId, key: "dot-fade-mask", maskUnits: "userSpaceOnUse" },
|
|
88
|
+
[
|
|
89
|
+
h("rect", {
|
|
90
|
+
x: 0,
|
|
91
|
+
y: 0,
|
|
92
|
+
width: pattern.tile,
|
|
93
|
+
height,
|
|
94
|
+
fill: `url(#${fadeGradId})`
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
)
|
|
98
|
+
];
|
|
99
|
+
const combos = props.series.map((series) => {
|
|
100
|
+
const gradId = `${ditherId(series.dataKey, props.scope)}-wash`;
|
|
101
|
+
return h(
|
|
102
|
+
"pattern",
|
|
103
|
+
{
|
|
104
|
+
id: ditherId(series.dataKey, props.scope),
|
|
105
|
+
key: `combo-${series.dataKey}`,
|
|
106
|
+
x: 0,
|
|
107
|
+
y: 0,
|
|
108
|
+
width: pattern.tile,
|
|
109
|
+
height,
|
|
110
|
+
patternUnits: "userSpaceOnUse"
|
|
111
|
+
},
|
|
112
|
+
[
|
|
113
|
+
h("rect", {
|
|
114
|
+
key: "wash",
|
|
115
|
+
x: 0,
|
|
116
|
+
y: 0,
|
|
117
|
+
width: pattern.tile,
|
|
118
|
+
height,
|
|
119
|
+
fill: `url(#${gradId})`
|
|
120
|
+
}),
|
|
121
|
+
h("rect", {
|
|
122
|
+
key: "dots",
|
|
123
|
+
x: 0,
|
|
124
|
+
y: 0,
|
|
125
|
+
width: pattern.tile,
|
|
126
|
+
height,
|
|
127
|
+
fill: `url(#${dotsId(series.dataKey, props.scope)})`,
|
|
128
|
+
// Fade the texture on the same ramp as the wash, otherwise the dots
|
|
129
|
+
// stay at full strength and the fill never reaches the baseline.
|
|
130
|
+
mask: `url(#${fadeMaskId})`
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
const washGradients = props.series.map(
|
|
136
|
+
(series) => h(
|
|
137
|
+
"linearGradient",
|
|
138
|
+
{
|
|
139
|
+
id: `${ditherId(series.dataKey, props.scope)}-wash`,
|
|
140
|
+
key: `wash-grad-${series.dataKey}`,
|
|
141
|
+
x1: 0,
|
|
142
|
+
y1: 0,
|
|
143
|
+
x2: 0,
|
|
144
|
+
y2: 1
|
|
145
|
+
},
|
|
146
|
+
stops.map(
|
|
147
|
+
(stop, index) => h("stop", {
|
|
148
|
+
key: index,
|
|
149
|
+
offset: stop.offset,
|
|
150
|
+
"stop-color": series.color,
|
|
151
|
+
"stop-opacity": stop.stopOpacity
|
|
152
|
+
})
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
);
|
|
156
|
+
return h("defs", {}, [...dotPatterns, ...washGradients, ...fadeDefs, ...combos]);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type FunnelLayeredDatum = {
|
|
2
|
+
name: string;
|
|
3
|
+
value: number;
|
|
4
|
+
color: string;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
9
|
+
payload?: FunnelLayeredDatum & {
|
|
10
|
+
stageIndex: number;
|
|
11
|
+
stageCount: number;
|
|
12
|
+
maxValue: number;
|
|
13
|
+
nextValue: number;
|
|
14
|
+
};
|
|
15
|
+
parentViewBox?: {
|
|
16
|
+
x?: number;
|
|
17
|
+
y?: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
};
|
|
21
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
22
|
+
mouseenter: (event: MouseEvent, payload: FunnelLayeredDatum) => any;
|
|
23
|
+
mouseleave: () => any;
|
|
24
|
+
mousemove: (event: MouseEvent) => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<{
|
|
26
|
+
payload?: FunnelLayeredDatum & {
|
|
27
|
+
stageIndex: number;
|
|
28
|
+
stageCount: number;
|
|
29
|
+
maxValue: number;
|
|
30
|
+
nextValue: number;
|
|
31
|
+
};
|
|
32
|
+
parentViewBox?: {
|
|
33
|
+
x?: number;
|
|
34
|
+
y?: number;
|
|
35
|
+
width?: number;
|
|
36
|
+
height?: number;
|
|
37
|
+
};
|
|
38
|
+
}> & Readonly<{
|
|
39
|
+
onMouseenter?: ((event: MouseEvent, payload: FunnelLayeredDatum) => any) | undefined;
|
|
40
|
+
onMouseleave?: (() => any) | undefined;
|
|
41
|
+
onMousemove?: ((event: MouseEvent) => any) | undefined;
|
|
42
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
payload: { type: Object, required: false },
|
|
5
|
+
parentViewBox: { type: Object, required: false }
|
|
6
|
+
});
|
|
7
|
+
const emit = defineEmits(["mouseenter", "mousemove", "mouseleave"]);
|
|
8
|
+
const geometry = computed(() => {
|
|
9
|
+
if (!props.payload) return null;
|
|
10
|
+
const { x = 0, y = 0, width = 0, height = 0 } = props.parentViewBox ?? {};
|
|
11
|
+
const segmentWidth = width / props.payload.stageCount;
|
|
12
|
+
const startX = x + segmentWidth * props.payload.stageIndex;
|
|
13
|
+
const endX = startX + segmentWidth;
|
|
14
|
+
const centerY = y + height * 0.54;
|
|
15
|
+
const maxHalfHeight = height * 0.31;
|
|
16
|
+
const startRatio = props.payload.maxValue > 0 ? props.payload.value / props.payload.maxValue : 0;
|
|
17
|
+
const endRatio = props.payload.stageIndex === props.payload.stageCount - 1 ? startRatio : Math.max(0, props.payload.nextValue / props.payload.maxValue);
|
|
18
|
+
const percentage = Math.round(startRatio * 100);
|
|
19
|
+
const path = (scale) => {
|
|
20
|
+
const startHalfHeight = maxHalfHeight * startRatio * scale;
|
|
21
|
+
const endHalfHeight = maxHalfHeight * endRatio * scale;
|
|
22
|
+
const controlOffset = segmentWidth * 0.55;
|
|
23
|
+
return [
|
|
24
|
+
`M ${startX} ${centerY - startHalfHeight}`,
|
|
25
|
+
`C ${startX + controlOffset} ${centerY - startHalfHeight}`,
|
|
26
|
+
`${endX - controlOffset} ${centerY - endHalfHeight}`,
|
|
27
|
+
`${endX} ${centerY - endHalfHeight}`,
|
|
28
|
+
`L ${endX} ${centerY + endHalfHeight}`,
|
|
29
|
+
`C ${endX - controlOffset} ${centerY + endHalfHeight}`,
|
|
30
|
+
`${startX + controlOffset} ${centerY + startHalfHeight}`,
|
|
31
|
+
`${startX} ${centerY + startHalfHeight}`,
|
|
32
|
+
"Z"
|
|
33
|
+
].join(" ");
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
badgeWidth: percentage === 100 ? 70 : 58,
|
|
37
|
+
bottomLabelY: y + height - 16,
|
|
38
|
+
centerY,
|
|
39
|
+
dividerStartY: centerY - maxHalfHeight * startRatio * 1.14,
|
|
40
|
+
dividerEndY: centerY + maxHalfHeight * startRatio * 1.14,
|
|
41
|
+
middleX: startX + segmentWidth / 2,
|
|
42
|
+
path,
|
|
43
|
+
percentage,
|
|
44
|
+
startX,
|
|
45
|
+
topLabelY: y + 30
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
function handleMouseenter(event) {
|
|
49
|
+
if (props.payload) emit("mouseenter", event, props.payload);
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<script>
|
|
54
|
+
export default { name: "FunnelLayeredShape" };
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<g
|
|
59
|
+
v-if="payload && geometry"
|
|
60
|
+
class="vc-funnel-layered-shape"
|
|
61
|
+
@mouseenter="handleMouseenter"
|
|
62
|
+
@mousemove="emit('mousemove', $event)"
|
|
63
|
+
@mouseleave="emit('mouseleave')"
|
|
64
|
+
>
|
|
65
|
+
<path :d="geometry.path(1.14)" :fill="payload.color" opacity="0.22" />
|
|
66
|
+
<path :d="geometry.path(1.07)" :fill="payload.color" opacity="0.5" />
|
|
67
|
+
<path :d="geometry.path(1)" :fill="payload.color" opacity="0.9" />
|
|
68
|
+
|
|
69
|
+
<line
|
|
70
|
+
v-if="payload.stageIndex > 0"
|
|
71
|
+
:x1="geometry.startX"
|
|
72
|
+
:x2="geometry.startX"
|
|
73
|
+
:y1="geometry.dividerStartY"
|
|
74
|
+
:y2="geometry.dividerEndY"
|
|
75
|
+
:stroke="`hsl(var(--background, 0 0% 100%))`"
|
|
76
|
+
:stroke-width="5"
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<text
|
|
80
|
+
:x="geometry.middleX"
|
|
81
|
+
:y="geometry.topLabelY"
|
|
82
|
+
:fill="`hsl(var(--foreground, 222.2 84% 4.9%))`"
|
|
83
|
+
:font-size="16"
|
|
84
|
+
:font-weight="700"
|
|
85
|
+
text-anchor="middle"
|
|
86
|
+
>
|
|
87
|
+
{{ payload.value.toLocaleString() }}
|
|
88
|
+
</text>
|
|
89
|
+
|
|
90
|
+
<rect
|
|
91
|
+
:x="geometry.middleX - geometry.badgeWidth / 2"
|
|
92
|
+
:y="geometry.centerY - 15"
|
|
93
|
+
:width="geometry.badgeWidth"
|
|
94
|
+
:height="30"
|
|
95
|
+
:rx="15"
|
|
96
|
+
:fill="`hsl(var(--background, 0 0% 100%))`"
|
|
97
|
+
fill-opacity="0.82"
|
|
98
|
+
:stroke="`hsl(var(--border, 214.3 31.8% 91.4%))`"
|
|
99
|
+
stroke-opacity="0.7"
|
|
100
|
+
:stroke-width="1"
|
|
101
|
+
/>
|
|
102
|
+
<text
|
|
103
|
+
:x="geometry.middleX"
|
|
104
|
+
:y="geometry.centerY + 5"
|
|
105
|
+
:fill="`hsl(var(--foreground, 222.2 84% 4.9%))`"
|
|
106
|
+
:font-size="14"
|
|
107
|
+
:font-weight="600"
|
|
108
|
+
text-anchor="middle"
|
|
109
|
+
>
|
|
110
|
+
{{ geometry.percentage }}%
|
|
111
|
+
</text>
|
|
112
|
+
|
|
113
|
+
<text
|
|
114
|
+
:x="geometry.middleX"
|
|
115
|
+
:y="geometry.bottomLabelY"
|
|
116
|
+
:fill="`hsl(var(--muted-foreground, 215.4 16.3% 46.9%))`"
|
|
117
|
+
:font-size="15"
|
|
118
|
+
:font-weight="500"
|
|
119
|
+
text-anchor="middle"
|
|
120
|
+
>
|
|
121
|
+
{{ payload.name }}
|
|
122
|
+
</text>
|
|
123
|
+
</g>
|
|
124
|
+
</template>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type FunnelLayeredDatum = {
|
|
2
|
+
name: string;
|
|
3
|
+
value: number;
|
|
4
|
+
color: string;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
9
|
+
payload?: FunnelLayeredDatum & {
|
|
10
|
+
stageIndex: number;
|
|
11
|
+
stageCount: number;
|
|
12
|
+
maxValue: number;
|
|
13
|
+
nextValue: number;
|
|
14
|
+
};
|
|
15
|
+
parentViewBox?: {
|
|
16
|
+
x?: number;
|
|
17
|
+
y?: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
};
|
|
21
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
22
|
+
mouseenter: (event: MouseEvent, payload: FunnelLayeredDatum) => any;
|
|
23
|
+
mouseleave: () => any;
|
|
24
|
+
mousemove: (event: MouseEvent) => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<{
|
|
26
|
+
payload?: FunnelLayeredDatum & {
|
|
27
|
+
stageIndex: number;
|
|
28
|
+
stageCount: number;
|
|
29
|
+
maxValue: number;
|
|
30
|
+
nextValue: number;
|
|
31
|
+
};
|
|
32
|
+
parentViewBox?: {
|
|
33
|
+
x?: number;
|
|
34
|
+
y?: number;
|
|
35
|
+
width?: number;
|
|
36
|
+
height?: number;
|
|
37
|
+
};
|
|
38
|
+
}> & Readonly<{
|
|
39
|
+
onMouseenter?: ((event: MouseEvent, payload: FunnelLayeredDatum) => any) | undefined;
|
|
40
|
+
onMouseleave?: (() => any) | undefined;
|
|
41
|
+
onMousemove?: ((event: MouseEvent) => any) | undefined;
|
|
42
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
import { type GradientStop } from "../../utils/gradient.js";
|
|
3
|
+
type SeriesItem = {
|
|
4
|
+
dataKey: string;
|
|
5
|
+
color: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Renders one vertical `<linearGradient>` per series inside a `<defs>` block.
|
|
9
|
+
*
|
|
10
|
+
* This is a render-function component on purpose: SVG elements like
|
|
11
|
+
* `<linearGradient>` / `<stop>` written in an SFC `<template>` that is *not*
|
|
12
|
+
* lexically nested inside an `<svg>` tag are parsed in the HTML namespace and
|
|
13
|
+
* silently dropped when placed via a component slot. Building them with `h()`
|
|
14
|
+
* sets the correct SVG namespace so the gradient — and therefore the
|
|
15
|
+
* `fill="url(#…)"` reference on each area — resolves.
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
18
|
+
series: {
|
|
19
|
+
type: PropType<SeriesItem[]>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
stops: {
|
|
23
|
+
type: PropType<GradientStop[]>;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
26
|
+
scope: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
required: true;
|
|
29
|
+
};
|
|
30
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
|
+
series: {
|
|
34
|
+
type: PropType<SeriesItem[]>;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
stops: {
|
|
38
|
+
type: PropType<GradientStop[]>;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
scope: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
required: true;
|
|
44
|
+
};
|
|
45
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import { gradientId } from "../../utils/gradient.js";
|
|
3
|
+
export default defineComponent({
|
|
4
|
+
name: "GradientDefs",
|
|
5
|
+
props: {
|
|
6
|
+
series: {
|
|
7
|
+
type: Array,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
stops: { type: Array, required: true },
|
|
11
|
+
scope: { type: String, required: true }
|
|
12
|
+
},
|
|
13
|
+
setup: (props) => () => h(
|
|
14
|
+
"defs",
|
|
15
|
+
{},
|
|
16
|
+
props.series.map(
|
|
17
|
+
(series) => h(
|
|
18
|
+
"linearGradient",
|
|
19
|
+
{
|
|
20
|
+
id: gradientId(series.dataKey, props.scope),
|
|
21
|
+
key: series.dataKey,
|
|
22
|
+
x1: 0,
|
|
23
|
+
y1: 0,
|
|
24
|
+
x2: 0,
|
|
25
|
+
y2: 1
|
|
26
|
+
},
|
|
27
|
+
props.stops.map(
|
|
28
|
+
(stop, index) => h("stop", {
|
|
29
|
+
key: index,
|
|
30
|
+
offset: stop.offset,
|
|
31
|
+
"stop-color": series.color,
|
|
32
|
+
"stop-opacity": stop.stopOpacity
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public enums, preserved from `nuxt-charts` v2 for API compatibility.
|
|
3
|
+
*
|
|
4
|
+
* These are real TS `enum`s so the IDE surfaces member options on `.` and
|
|
5
|
+
* string-literal completion in templates. Each value maps to a `vccs`
|
|
6
|
+
* primitive via the typed lookup tables in `./utils`.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Position of the chart legend.
|
|
10
|
+
*
|
|
11
|
+
* Translated to `vccs` `<Legend>` `align` / `verticalAlign` / `layout`
|
|
12
|
+
* via {@link import('./utils/legend').legendPositionToLegendProps}.
|
|
13
|
+
*/
|
|
14
|
+
export declare enum LegendPosition {
|
|
15
|
+
TopLeft = "top-left",
|
|
16
|
+
TopCenter = "top-center",
|
|
17
|
+
TopRight = "top-right",
|
|
18
|
+
BottomLeft = "bottom-left",
|
|
19
|
+
BottomCenter = "bottom-center",
|
|
20
|
+
BottomRight = "bottom-right"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Curve interpolation used to connect data points in line / area charts.
|
|
24
|
+
*
|
|
25
|
+
* Translated to the `vccs` curve `type` string union via
|
|
26
|
+
* {@link import('./utils/curve').curveTypeToVccs}.
|
|
27
|
+
*/
|
|
28
|
+
export declare enum CurveType {
|
|
29
|
+
Basis = "basis",
|
|
30
|
+
BasisClosed = "basisClosed",
|
|
31
|
+
BasisOpen = "basisOpen",
|
|
32
|
+
Bundle = "bundle",
|
|
33
|
+
Cardinal = "cardinal",
|
|
34
|
+
CardinalClosed = "cardinalClosed",
|
|
35
|
+
CardinalOpen = "cardinalOpen",
|
|
36
|
+
CatmullRom = "catmullRom",
|
|
37
|
+
CatmullRomClosed = "catmullRomClosed",
|
|
38
|
+
CatmullRomOpen = "catmullRomOpen",
|
|
39
|
+
Linear = "linear",
|
|
40
|
+
LinearClosed = "linearClosed",
|
|
41
|
+
MonotoneX = "monotoneX",
|
|
42
|
+
MonotoneY = "monotoneY",
|
|
43
|
+
Natural = "natural",
|
|
44
|
+
Step = "step",
|
|
45
|
+
StepAfter = "stepAfter",
|
|
46
|
+
StepBefore = "stepBefore"
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Orientation of a bar chart's bars.
|
|
50
|
+
*
|
|
51
|
+
* Maps to the `vccs` chart container `layout` prop.
|
|
52
|
+
*/
|
|
53
|
+
export declare enum Orientation {
|
|
54
|
+
Horizontal = "horizontal",
|
|
55
|
+
Vertical = "vertical"
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Shape of a donut / pie chart.
|
|
59
|
+
*
|
|
60
|
+
* `Full` renders a complete ring; `Half` renders a semicircle gauge.
|
|
61
|
+
*/
|
|
62
|
+
export declare enum DonutType {
|
|
63
|
+
Half = "half",
|
|
64
|
+
Full = "full"
|
|
65
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export var LegendPosition = /* @__PURE__ */ ((LegendPosition2) => {
|
|
2
|
+
LegendPosition2["TopLeft"] = "top-left";
|
|
3
|
+
LegendPosition2["TopCenter"] = "top-center";
|
|
4
|
+
LegendPosition2["TopRight"] = "top-right";
|
|
5
|
+
LegendPosition2["BottomLeft"] = "bottom-left";
|
|
6
|
+
LegendPosition2["BottomCenter"] = "bottom-center";
|
|
7
|
+
LegendPosition2["BottomRight"] = "bottom-right";
|
|
8
|
+
return LegendPosition2;
|
|
9
|
+
})(LegendPosition || {});
|
|
10
|
+
export var CurveType = /* @__PURE__ */ ((CurveType2) => {
|
|
11
|
+
CurveType2["Basis"] = "basis";
|
|
12
|
+
CurveType2["BasisClosed"] = "basisClosed";
|
|
13
|
+
CurveType2["BasisOpen"] = "basisOpen";
|
|
14
|
+
CurveType2["Bundle"] = "bundle";
|
|
15
|
+
CurveType2["Cardinal"] = "cardinal";
|
|
16
|
+
CurveType2["CardinalClosed"] = "cardinalClosed";
|
|
17
|
+
CurveType2["CardinalOpen"] = "cardinalOpen";
|
|
18
|
+
CurveType2["CatmullRom"] = "catmullRom";
|
|
19
|
+
CurveType2["CatmullRomClosed"] = "catmullRomClosed";
|
|
20
|
+
CurveType2["CatmullRomOpen"] = "catmullRomOpen";
|
|
21
|
+
CurveType2["Linear"] = "linear";
|
|
22
|
+
CurveType2["LinearClosed"] = "linearClosed";
|
|
23
|
+
CurveType2["MonotoneX"] = "monotoneX";
|
|
24
|
+
CurveType2["MonotoneY"] = "monotoneY";
|
|
25
|
+
CurveType2["Natural"] = "natural";
|
|
26
|
+
CurveType2["Step"] = "step";
|
|
27
|
+
CurveType2["StepAfter"] = "stepAfter";
|
|
28
|
+
CurveType2["StepBefore"] = "stepBefore";
|
|
29
|
+
return CurveType2;
|
|
30
|
+
})(CurveType || {});
|
|
31
|
+
export var Orientation = /* @__PURE__ */ ((Orientation2) => {
|
|
32
|
+
Orientation2["Horizontal"] = "horizontal";
|
|
33
|
+
Orientation2["Vertical"] = "vertical";
|
|
34
|
+
return Orientation2;
|
|
35
|
+
})(Orientation || {});
|
|
36
|
+
export var DonutType = /* @__PURE__ */ ((DonutType2) => {
|
|
37
|
+
DonutType2["Half"] = "half";
|
|
38
|
+
DonutType2["Full"] = "full";
|
|
39
|
+
return DonutType2;
|
|
40
|
+
})(DonutType || {});
|