vccs 0.2.0 → 0.4.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/README.md +151 -0
- package/dist/animation/Animate.d.ts +1 -1
- package/dist/cartesian/area/type.d.ts +3 -3
- package/dist/cartesian/axis/XAxis.d.ts +3 -3
- package/dist/cartesian/bar/type.d.ts +1 -13
- package/dist/cartesian/brush/components/Slide.d.ts +1 -1
- package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
- package/dist/cartesian/brush/type.d.ts +2 -1
- package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +7 -6
- package/dist/cartesian/funnel/type.d.ts +4 -5
- package/dist/cartesian/index.d.ts +1 -0
- package/dist/cartesian/line/Line.d.ts +7 -13
- package/dist/cartesian/line/type.d.ts +4 -17
- package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
- package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
- package/dist/cartesian/reference-dot/index.d.ts +2 -0
- package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
- package/dist/cartesian/scatter/Scatter.d.ts +1 -1
- package/dist/chart/RechartsWrapper.d.ts +7 -3
- package/dist/chart/Surface.d.ts +2 -1
- package/dist/chart/Treemap.d.ts +237 -0
- package/dist/chart/generateCategoricalChart.d.ts +2 -1
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/treemapUtils.d.ts +22 -0
- package/dist/components/Customized.d.ts +23 -0
- package/dist/components/Text.d.ts +20 -5
- package/dist/components/Tooltip.d.ts +47 -3
- package/dist/components/index.d.ts +2 -0
- package/dist/components/label/Label.d.ts +3 -3
- package/dist/components/label/types.d.ts +1 -1
- package/dist/container/Surface.d.ts +3 -2
- package/dist/es/cartesian/area/type.mjs +2 -4
- package/dist/es/cartesian/axis/XAxis.mjs +2 -2
- package/dist/es/cartesian/axis/YAxis.mjs +1 -1
- package/dist/es/cartesian/bar/Bar.mjs +2 -17
- package/dist/es/cartesian/bar/type.mjs +2 -16
- package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +2 -3
- package/dist/es/cartesian/cartesian-grid/const.mjs +7 -1
- package/dist/es/cartesian/funnel/Funnel.mjs +3 -18
- package/dist/es/cartesian/funnel/type.mjs +3 -5
- package/dist/es/cartesian/line/type.mjs +2 -7
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +6 -22
- package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +6 -19
- package/dist/es/chart/RechartsWrapper.mjs +2 -1
- package/dist/es/chart/Treemap.mjs +379 -0
- package/dist/es/chart/generateCategoricalChart.mjs +3 -2
- package/dist/es/chart/treemapUtils.mjs +32 -0
- package/dist/es/components/Customized.mjs +43 -0
- package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/es/components/Tooltip.mjs +14 -7
- package/dist/es/components/label/types.mjs +2 -1
- package/dist/es/components/legend/Legend.mjs +1 -1
- package/dist/es/components/legend/hooks/useLegend.mjs +8 -3
- package/dist/es/container/Surface.mjs +2 -4
- package/dist/es/hooks/publicHooks.mjs +207 -0
- package/dist/es/index.mjs +9 -1
- package/dist/es/polar/pie/Pie.mjs +1 -1
- package/dist/es/polar/pie/type.mjs +2 -4
- package/dist/es/shape/Curve.mjs +2 -1
- package/dist/es/shape/Polygon.mjs +19 -0
- package/dist/es/shape/Rectangle.mjs +0 -4
- package/dist/es/shape/Sector.mjs +4 -6
- package/dist/es/shape/Symbols.mjs +1 -1
- package/dist/es/shape/Trapezoid.mjs +5 -7
- package/dist/es/state/ReportChartProps.mjs +2 -4
- package/dist/es/state/hooks.mjs +21 -1
- package/dist/es/state/referenceElementsSlice.mjs +1 -1
- package/dist/es/state/selectors/axisSelectors.mjs +30 -1
- package/dist/es/state/selectors/tooltipSelectors.mjs +2 -2
- package/dist/es/types/common.mjs +12 -0
- package/dist/es/utils/VueUtils.mjs +1 -1
- package/dist/es/utils/cell.mjs +28 -0
- package/dist/es/utils/createCategoricalInverse.mjs +46 -0
- package/dist/es/utils/scale.mjs +46 -0
- package/dist/hooks/publicHooks.d.ts +143 -0
- package/dist/index.d.ts +1 -0
- package/dist/polar/pie/type.d.ts +2 -2
- package/dist/polar/radar/Radar.d.ts +4 -4
- package/dist/shape/Curve.d.ts +2 -1
- package/dist/shape/Polygon.d.ts +9 -0
- package/dist/shape/Rectangle.d.ts +0 -4
- package/dist/shape/Sector.d.ts +2 -2
- package/dist/shape/Symbols.d.ts +2 -1
- package/dist/shape/Trapezoid.d.ts +9 -10
- package/dist/shape/index.d.ts +1 -0
- package/dist/shape/types.d.ts +4 -5
- package/dist/state/ReportChartProps.d.ts +3 -3
- package/dist/state/rootPropsSlice.d.ts +2 -2
- package/dist/state/selectors/axisSelectors.d.ts +5 -0
- package/dist/types/axis.d.ts +2 -2
- package/dist/types/bar.d.ts +2 -6
- package/dist/types/categorical.d.ts +2 -2
- package/dist/types/common.d.ts +7 -1
- package/dist/types/tooltip.d.ts +2 -2
- package/dist/utils/cell.d.ts +11 -0
- package/dist/utils/createCategoricalInverse.d.ts +16 -0
- package/dist/utils/scale.d.ts +23 -0
- package/package.json +2 -1
|
@@ -5,8 +5,8 @@ export declare const Label: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
5
5
|
type: StringConstructor;
|
|
6
6
|
};
|
|
7
7
|
class: {
|
|
8
|
-
type: StringConstructor;
|
|
9
8
|
default: string;
|
|
9
|
+
type: import('vue').PropType<import('../../types').VueClassValue>;
|
|
10
10
|
};
|
|
11
11
|
viewBox: {
|
|
12
12
|
type: import('vue').PropType<import('./types').ViewBox>;
|
|
@@ -43,8 +43,8 @@ export declare const Label: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
43
43
|
type: StringConstructor;
|
|
44
44
|
};
|
|
45
45
|
class: {
|
|
46
|
-
type: StringConstructor;
|
|
47
46
|
default: string;
|
|
47
|
+
type: import('vue').PropType<import('../../types').VueClassValue>;
|
|
48
48
|
};
|
|
49
49
|
viewBox: {
|
|
50
50
|
type: import('vue').PropType<import('./types').ViewBox>;
|
|
@@ -75,7 +75,7 @@ export declare const Label: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
75
75
|
type: NumberConstructor;
|
|
76
76
|
};
|
|
77
77
|
}>> & Readonly<{}>, {
|
|
78
|
-
class:
|
|
78
|
+
class: import('../../types').VueClassValue;
|
|
79
79
|
offset: number;
|
|
80
80
|
textBreakAll: boolean;
|
|
81
81
|
}, SlotsType<LabelSlots>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, SVGAttributes } from 'vue';
|
|
2
|
+
import { VueClassValue } from '../types';
|
|
2
3
|
interface ViewBox {
|
|
3
4
|
x?: number;
|
|
4
5
|
y?: number;
|
|
@@ -9,7 +10,7 @@ declare const Surface: import('vue').DefineComponent<Omit<SVGAttributes, "viewBo
|
|
|
9
10
|
width: number;
|
|
10
11
|
height: number;
|
|
11
12
|
viewBox?: ViewBox;
|
|
12
|
-
class?:
|
|
13
|
+
class?: VueClassValue;
|
|
13
14
|
style?: CSSProperties;
|
|
14
15
|
title?: string;
|
|
15
16
|
desc?: string;
|
|
@@ -17,7 +18,7 @@ declare const Surface: import('vue').DefineComponent<Omit<SVGAttributes, "viewBo
|
|
|
17
18
|
width: number;
|
|
18
19
|
height: number;
|
|
19
20
|
viewBox?: ViewBox;
|
|
20
|
-
class?:
|
|
21
|
+
class?: VueClassValue;
|
|
21
22
|
style?: CSSProperties;
|
|
22
23
|
title?: string;
|
|
23
24
|
desc?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
import { CurveVueProps } from "../../shape/Curve.mjs";
|
|
2
3
|
//#region src/cartesian/area/type.ts
|
|
3
4
|
var AreaVueProps = {
|
|
@@ -127,10 +128,7 @@ var AreaVueProps = {
|
|
|
127
128
|
default: 0
|
|
128
129
|
},
|
|
129
130
|
name: { type: [String, Number] },
|
|
130
|
-
class:
|
|
131
|
-
type: String,
|
|
132
|
-
default: void 0
|
|
133
|
-
}
|
|
131
|
+
class: classProp
|
|
134
132
|
};
|
|
135
133
|
//#endregion
|
|
136
134
|
export { AreaVueProps };
|
|
@@ -37,7 +37,7 @@ var XAxisImpl = /* @__PURE__ */ defineComponent({
|
|
|
37
37
|
"width": axisSize.value?.width,
|
|
38
38
|
"height": axisSize.value?.height,
|
|
39
39
|
"ticks": cartesianTickItems.value,
|
|
40
|
-
"class": ["v-charts-xAxis xAxis"
|
|
40
|
+
"class": ["v-charts-xAxis xAxis"]
|
|
41
41
|
}), { default: () => [slots.tick ? { tick: slots.tick } : void 0] });
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -178,7 +178,7 @@ var XAxis = /* @__PURE__ */ defineComponent({
|
|
|
178
178
|
},
|
|
179
179
|
domain: { type: Array },
|
|
180
180
|
axisLine: {
|
|
181
|
-
type: Boolean,
|
|
181
|
+
type: [Boolean, Object],
|
|
182
182
|
default: true
|
|
183
183
|
},
|
|
184
184
|
ticks: { type: Array },
|
|
@@ -31,7 +31,7 @@ var YAxisImpl = /* @__PURE__ */ defineComponent({
|
|
|
31
31
|
"width": axisSize.value?.width,
|
|
32
32
|
"height": axisSize.value?.height,
|
|
33
33
|
"ticks": cartesianTickItems.value,
|
|
34
|
-
"class": ["v-charts-yAxis yAxis"
|
|
34
|
+
"class": ["v-charts-yAxis yAxis"]
|
|
35
35
|
}), null);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -12,8 +12,8 @@ import { GraphicalItemClipPath } from "../GraphicalItemClipPath.mjs";
|
|
|
12
12
|
import { BarBackground } from "./components/BarBackground.mjs";
|
|
13
13
|
import { BarRectangles } from "./components/BarRectangles.mjs";
|
|
14
14
|
import { createErrorBarRegistry, provideErrorBarContext, provideErrorBarRegistry } from "../error-bar/ErrorBarContext.mjs";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { extractCellProps, filterOutCells } from "../../utils/cell.mjs";
|
|
16
|
+
import { Teleport, computed, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
17
17
|
//#region src/cartesian/bar/Bar.tsx
|
|
18
18
|
function _isSlot(s) {
|
|
19
19
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
@@ -68,21 +68,6 @@ var Bar = /* @__PURE__ */ defineComponent({
|
|
|
68
68
|
});
|
|
69
69
|
}));
|
|
70
70
|
const graphicalLayerRef = useGraphicalLayerRef(null);
|
|
71
|
-
const extractCellProps = (vnodes) => {
|
|
72
|
-
const result = [];
|
|
73
|
-
for (const vnode of vnodes) if (vnode.type === Cell) result.push(vnode.props ?? {});
|
|
74
|
-
else if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...extractCellProps(vnode.children));
|
|
75
|
-
return result;
|
|
76
|
-
};
|
|
77
|
-
const filterOutCells = (vnodes) => {
|
|
78
|
-
const result = [];
|
|
79
|
-
for (const vnode of vnodes) {
|
|
80
|
-
if (vnode.type === Cell) continue;
|
|
81
|
-
if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...filterOutCells(vnode.children));
|
|
82
|
-
else result.push(vnode);
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
};
|
|
86
71
|
return () => {
|
|
87
72
|
if (!shouldRender.value) return null;
|
|
88
73
|
const defaultContent = slots.default?.() ?? [];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
//#region src/cartesian/bar/type.ts
|
|
2
3
|
var BarVueProps = {
|
|
3
|
-
class:
|
|
4
|
-
type: String,
|
|
5
|
-
default: void 0
|
|
6
|
-
},
|
|
4
|
+
class: classProp,
|
|
7
5
|
barSize: { type: [String, Number] },
|
|
8
6
|
data: {
|
|
9
7
|
type: Array,
|
|
@@ -99,18 +97,6 @@ var BarVueProps = {
|
|
|
99
97
|
type: [String, Number],
|
|
100
98
|
default: 0
|
|
101
99
|
},
|
|
102
|
-
animationBegin: {
|
|
103
|
-
type: Number,
|
|
104
|
-
default: 0
|
|
105
|
-
},
|
|
106
|
-
animationDuration: {
|
|
107
|
-
type: Number,
|
|
108
|
-
default: 1500
|
|
109
|
-
},
|
|
110
|
-
animationEasing: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: "ease"
|
|
113
|
-
},
|
|
114
100
|
transition: {
|
|
115
101
|
type: Object,
|
|
116
102
|
default: {
|
|
@@ -92,8 +92,7 @@ var CartesianAxis = /* @__PURE__ */ defineComponent({
|
|
|
92
92
|
default: "#666"
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
|
-
|
|
96
|
-
setup(props, { attrs, slots }) {
|
|
95
|
+
setup(props, { slots }) {
|
|
97
96
|
const state = reactive({
|
|
98
97
|
fontSize: "",
|
|
99
98
|
letterSpacing: ""
|
|
@@ -269,7 +268,7 @@ var CartesianAxis = /* @__PURE__ */ defineComponent({
|
|
|
269
268
|
if (hide) return null;
|
|
270
269
|
if (width != null && width <= 0 || height != null && height <= 0) return null;
|
|
271
270
|
return createVNode(Layer, {
|
|
272
|
-
"class": ["v-charts-cartesian-axis"
|
|
271
|
+
"class": ["v-charts-cartesian-axis"],
|
|
273
272
|
"ref": (ref) => {
|
|
274
273
|
const elm = ref?.$el;
|
|
275
274
|
if (elm) {
|
|
@@ -90,7 +90,7 @@ var SVGElementPropKeys = [
|
|
|
90
90
|
"target",
|
|
91
91
|
"width",
|
|
92
92
|
"role",
|
|
93
|
-
"
|
|
93
|
+
"tabindex",
|
|
94
94
|
"accentHeight",
|
|
95
95
|
"accumulate",
|
|
96
96
|
"additive",
|
|
@@ -266,11 +266,17 @@ var SVGElementPropKeys = [
|
|
|
266
266
|
"stroke",
|
|
267
267
|
"stroke-dasharray",
|
|
268
268
|
"strokeDashoffset",
|
|
269
|
+
"stroke-dashoffset",
|
|
269
270
|
"strokeLinecap",
|
|
271
|
+
"stroke-linecap",
|
|
270
272
|
"strokeLinejoin",
|
|
273
|
+
"stroke-linejoin",
|
|
271
274
|
"strokeMiterlimit",
|
|
275
|
+
"stroke-miterlimit",
|
|
272
276
|
"strokeOpacity",
|
|
277
|
+
"stroke-opacity",
|
|
273
278
|
"strokeWidth",
|
|
279
|
+
"stroke-width",
|
|
274
280
|
"surfaceScale",
|
|
275
281
|
"systemLanguage",
|
|
276
282
|
"tableValues",
|
|
@@ -7,27 +7,12 @@ import { Animate } from "../../animation/Animate.mjs";
|
|
|
7
7
|
import { SetPolarGraphicalItem } from "../../state/SetGraphicalItem.mjs";
|
|
8
8
|
import { SetLegendPayload } from "../../state/SetLegendPayload.mjs";
|
|
9
9
|
import { SetTooltipEntrySettings } from "../../state/SetTooltipEntrySettings.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { extractCellProps, filterOutCells } from "../../utils/cell.mjs";
|
|
11
11
|
import { Trapezoid } from "../../shape/Trapezoid.mjs";
|
|
12
12
|
import { selectFunnelTrapezoids } from "../../state/selectors/funnelSelectors.mjs";
|
|
13
13
|
import { FunnelVueProps } from "./type.mjs";
|
|
14
|
-
import {
|
|
14
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
15
15
|
//#region src/cartesian/funnel/Funnel.tsx
|
|
16
|
-
function extractCellProps(vnodes) {
|
|
17
|
-
const result = [];
|
|
18
|
-
for (const vnode of vnodes) if (vnode.type === Cell) result.push(vnode.props ?? {});
|
|
19
|
-
else if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...extractCellProps(vnode.children));
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
function filterOutCells(vnodes) {
|
|
23
|
-
const result = [];
|
|
24
|
-
for (const vnode of vnodes) {
|
|
25
|
-
if (vnode.type === Cell) continue;
|
|
26
|
-
if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...filterOutCells(vnode.children));
|
|
27
|
-
else result.push(vnode);
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
16
|
var Funnel = /* @__PURE__ */ defineComponent({
|
|
32
17
|
name: "Funnel",
|
|
33
18
|
props: FunnelVueProps,
|
|
@@ -123,7 +108,7 @@ var Funnel = /* @__PURE__ */ defineComponent({
|
|
|
123
108
|
cellPropsRef.value = cells;
|
|
124
109
|
const nonCellContent = cells.length > 0 ? filterOutCells(defaultContent) : defaultContent;
|
|
125
110
|
const stroke = attrs.stroke ?? props.stroke;
|
|
126
|
-
return createVNode(Layer, { "class": ["v-charts-funnel", props.
|
|
111
|
+
return createVNode(Layer, { "class": ["v-charts-funnel", props.class] }, { default: () => [createVNode(Animate, {
|
|
127
112
|
"isActive": props.isAnimationActive,
|
|
128
113
|
"from": 0,
|
|
129
114
|
"to": 1,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
//#region src/cartesian/funnel/type.ts
|
|
2
3
|
var FunnelVueProps = {
|
|
3
4
|
data: {
|
|
@@ -67,14 +68,11 @@ var FunnelVueProps = {
|
|
|
67
68
|
type: Function,
|
|
68
69
|
default: void 0
|
|
69
70
|
},
|
|
70
|
-
className: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: void 0
|
|
73
|
-
},
|
|
74
71
|
width: {
|
|
75
72
|
type: [Number, String],
|
|
76
73
|
default: void 0
|
|
77
|
-
}
|
|
74
|
+
},
|
|
75
|
+
class: classProp
|
|
78
76
|
};
|
|
79
77
|
//#endregion
|
|
80
78
|
export { FunnelVueProps };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
import { CurveVueProps } from "../../shape/Curve.mjs";
|
|
2
3
|
//#region src/cartesian/line/type.ts
|
|
3
4
|
var LineVueProps = {
|
|
@@ -10,12 +11,6 @@ var LineVueProps = {
|
|
|
10
11
|
],
|
|
11
12
|
default: true
|
|
12
13
|
},
|
|
13
|
-
animationDuration: { type: Number },
|
|
14
|
-
animationEasing: { type: String },
|
|
15
|
-
animationBegin: {
|
|
16
|
-
type: Number,
|
|
17
|
-
default: 0
|
|
18
|
-
},
|
|
19
14
|
animationId: { type: String },
|
|
20
15
|
isAnimationActive: {
|
|
21
16
|
type: Boolean,
|
|
@@ -106,7 +101,7 @@ var LineVueProps = {
|
|
|
106
101
|
default: 0
|
|
107
102
|
},
|
|
108
103
|
name: { type: [String, Number] },
|
|
109
|
-
class:
|
|
104
|
+
class: classProp
|
|
110
105
|
};
|
|
111
106
|
//#endregion
|
|
112
107
|
export { LineVueProps };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
2
|
+
import { isNumOrStr } from "../../utils/validate.mjs";
|
|
2
3
|
import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
|
|
3
4
|
import { selectAxisScale } from "../../state/selectors/axisSelectors.mjs";
|
|
4
5
|
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
@@ -7,22 +8,8 @@ import { Label } from "../../components/label/Label.mjs";
|
|
|
7
8
|
import { Rectangle } from "../../shape/Rectangle.mjs";
|
|
8
9
|
import { addArea, removeArea } from "../../state/referenceElementsSlice.mjs";
|
|
9
10
|
import { useClipPathId } from "../../chart/provideClipPathId.mjs";
|
|
11
|
+
import { rangeMax, rangeMin, scaleValue } from "../../utils/scale.mjs";
|
|
10
12
|
import { computed, createVNode, defineComponent, mergeProps, onMounted, onUnmounted, reactive } from "vue";
|
|
11
|
-
//#region src/cartesian/reference-area/ReferenceArea.tsx
|
|
12
|
-
function scaleValue(scale, value, position) {
|
|
13
|
-
const coord = scale(value);
|
|
14
|
-
if (!isWellBehavedNumber(coord)) return void 0;
|
|
15
|
-
const bandwidth = scale.bandwidth?.() ?? 0;
|
|
16
|
-
return position === "start" ? coord : coord + bandwidth;
|
|
17
|
-
}
|
|
18
|
-
function rangeMin(scale) {
|
|
19
|
-
const r = scale.range();
|
|
20
|
-
return Math.min(r[0], r[1]);
|
|
21
|
-
}
|
|
22
|
-
function rangeMax(scale) {
|
|
23
|
-
const r = scale.range();
|
|
24
|
-
return Math.max(r[0], r[1]);
|
|
25
|
-
}
|
|
26
13
|
var ReferenceArea = /* @__PURE__ */ defineComponent({
|
|
27
14
|
name: "ReferenceArea",
|
|
28
15
|
props: {
|
|
@@ -79,14 +66,11 @@ var ReferenceArea = /* @__PURE__ */ defineComponent({
|
|
|
79
66
|
type: String,
|
|
80
67
|
default: "discard"
|
|
81
68
|
},
|
|
82
|
-
className: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: void 0
|
|
85
|
-
},
|
|
86
69
|
radius: {
|
|
87
70
|
type: [Number, Array],
|
|
88
71
|
default: 0
|
|
89
|
-
}
|
|
72
|
+
},
|
|
73
|
+
class: classProp
|
|
90
74
|
},
|
|
91
75
|
inheritAttrs: false,
|
|
92
76
|
setup(props, { attrs }) {
|
|
@@ -144,7 +128,7 @@ var ReferenceArea = /* @__PURE__ */ defineComponent({
|
|
|
144
128
|
};
|
|
145
129
|
const labelValue = props.label;
|
|
146
130
|
const labelProps = typeof labelValue === "object" && labelValue !== null ? labelValue : {};
|
|
147
|
-
return createVNode(Layer, { "class": ["v-charts-reference-area", props.
|
|
131
|
+
return createVNode(Layer, { "class": ["v-charts-reference-area", props.class] }, { default: () => [createVNode(Rectangle, mergeProps(svgAttrs, {
|
|
148
132
|
"clip-path": clipPath,
|
|
149
133
|
"x": r.x,
|
|
150
134
|
"y": r.y,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { isNumOrStr } from "../../utils/validate.mjs";
|
|
2
|
+
import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
|
|
3
|
+
import { selectAxisScale } from "../../state/selectors/axisSelectors.mjs";
|
|
4
|
+
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
5
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
6
|
+
import { Dot } from "../../shape/Dot.mjs";
|
|
7
|
+
import { Label } from "../../components/label/Label.mjs";
|
|
8
|
+
import { addDot, removeDot } from "../../state/referenceElementsSlice.mjs";
|
|
9
|
+
import { useClipPathId } from "../../chart/provideClipPathId.mjs";
|
|
10
|
+
import { isInRange, scaleCoord } from "../../utils/scale.mjs";
|
|
11
|
+
import { computed, createVNode, defineComponent, mergeProps, onMounted, onUnmounted, reactive } from "vue";
|
|
12
|
+
var ReferenceDot = /* @__PURE__ */ defineComponent({
|
|
13
|
+
name: "ReferenceDot",
|
|
14
|
+
props: {
|
|
15
|
+
x: {
|
|
16
|
+
type: [Number, String],
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
y: {
|
|
20
|
+
type: [Number, String],
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
r: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 10
|
|
26
|
+
},
|
|
27
|
+
xAxisId: {
|
|
28
|
+
type: [Number, String],
|
|
29
|
+
default: 0
|
|
30
|
+
},
|
|
31
|
+
yAxisId: {
|
|
32
|
+
type: [Number, String],
|
|
33
|
+
default: 0
|
|
34
|
+
},
|
|
35
|
+
fill: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "#fff"
|
|
38
|
+
},
|
|
39
|
+
stroke: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: "#ccc"
|
|
42
|
+
},
|
|
43
|
+
label: {
|
|
44
|
+
type: [
|
|
45
|
+
String,
|
|
46
|
+
Number,
|
|
47
|
+
Boolean,
|
|
48
|
+
Object
|
|
49
|
+
],
|
|
50
|
+
default: void 0
|
|
51
|
+
},
|
|
52
|
+
ifOverflow: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "discard"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
inheritAttrs: false,
|
|
58
|
+
slots: Object,
|
|
59
|
+
setup(props, { attrs, slots }) {
|
|
60
|
+
const dispatch = useAppDispatch();
|
|
61
|
+
const isPanorama = useIsPanorama();
|
|
62
|
+
const clipPathId = useClipPathId();
|
|
63
|
+
const settings = reactive({
|
|
64
|
+
xAxisId: props.xAxisId,
|
|
65
|
+
yAxisId: props.yAxisId,
|
|
66
|
+
ifOverflow: props.ifOverflow,
|
|
67
|
+
x: props.x,
|
|
68
|
+
y: props.y,
|
|
69
|
+
r: props.r
|
|
70
|
+
});
|
|
71
|
+
onMounted(() => {
|
|
72
|
+
dispatch(addDot(settings));
|
|
73
|
+
});
|
|
74
|
+
onUnmounted(() => {
|
|
75
|
+
dispatch(removeDot(settings));
|
|
76
|
+
});
|
|
77
|
+
const xAxisScale = useAppSelector((state) => selectAxisScale(state, "xAxis", props.xAxisId, isPanorama));
|
|
78
|
+
const yAxisScale = useAppSelector((state) => selectAxisScale(state, "yAxis", props.yAxisId, isPanorama));
|
|
79
|
+
const dotCoord = computed(() => {
|
|
80
|
+
const xScale = xAxisScale.value;
|
|
81
|
+
const yScale = yAxisScale.value;
|
|
82
|
+
if (!xScale || !yScale) return null;
|
|
83
|
+
if (!isNumOrStr(props.x) || !isNumOrStr(props.y)) return null;
|
|
84
|
+
const cx = scaleCoord(xScale, props.x);
|
|
85
|
+
const cy = scaleCoord(yScale, props.y);
|
|
86
|
+
if (cx == null || cy == null) return null;
|
|
87
|
+
if (props.ifOverflow === "discard") {
|
|
88
|
+
if (!isInRange(xScale, cx) || !isInRange(yScale, cy)) return null;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
cx,
|
|
92
|
+
cy
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
return () => {
|
|
96
|
+
const coord = dotCoord.value;
|
|
97
|
+
if (!coord) return null;
|
|
98
|
+
const { cx, cy } = coord;
|
|
99
|
+
const clipPath = props.ifOverflow === "hidden" ? `url(#${clipPathId})` : void 0;
|
|
100
|
+
const { class: userClass, ...restAttrs } = attrs;
|
|
101
|
+
const svgAttrs = {
|
|
102
|
+
...restAttrs,
|
|
103
|
+
fill: props.fill,
|
|
104
|
+
stroke: props.stroke
|
|
105
|
+
};
|
|
106
|
+
const labelViewBox = {
|
|
107
|
+
x: cx - props.r,
|
|
108
|
+
y: cy - props.r,
|
|
109
|
+
width: props.r * 2,
|
|
110
|
+
height: props.r * 2
|
|
111
|
+
};
|
|
112
|
+
const labelValue = props.label;
|
|
113
|
+
const labelProps = typeof labelValue === "object" && labelValue !== null ? labelValue : {};
|
|
114
|
+
const shapeProps = {
|
|
115
|
+
...svgAttrs,
|
|
116
|
+
cx,
|
|
117
|
+
cy,
|
|
118
|
+
r: props.r,
|
|
119
|
+
clipPath
|
|
120
|
+
};
|
|
121
|
+
return createVNode(Layer, { "class": ["v-charts-reference-dot", userClass] }, { default: () => [slots.shape ? slots.shape(shapeProps) : createVNode(Dot, mergeProps(svgAttrs, {
|
|
122
|
+
"cx": cx,
|
|
123
|
+
"cy": cy,
|
|
124
|
+
"r": props.r,
|
|
125
|
+
"clip-path": clipPath
|
|
126
|
+
}), null), labelValue != null && labelValue !== false && createVNode(Label, mergeProps({
|
|
127
|
+
"viewBox": labelViewBox,
|
|
128
|
+
"value": typeof labelValue === "string" || typeof labelValue === "number" ? labelValue : void 0
|
|
129
|
+
}, labelProps), null)] });
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
//#endregion
|
|
134
|
+
export { ReferenceDot };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
import { isNumOrStr, isWellBehavedNumber } from "../../utils/validate.mjs";
|
|
2
3
|
import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
|
|
3
4
|
import { selectAxisScale, selectXAxisSettings, selectYAxisSettings } from "../../state/selectors/axisSelectors.mjs";
|
|
@@ -7,19 +8,8 @@ import { Layer } from "../../container/Layer.mjs";
|
|
|
7
8
|
import { Label } from "../../components/label/Label.mjs";
|
|
8
9
|
import { addLine, removeLine } from "../../state/referenceElementsSlice.mjs";
|
|
9
10
|
import { useClipPathId } from "../../chart/provideClipPathId.mjs";
|
|
11
|
+
import { isInRange, scaleCoord } from "../../utils/scale.mjs";
|
|
10
12
|
import { computed, createVNode, defineComponent, mergeProps, onMounted, onUnmounted, reactive } from "vue";
|
|
11
|
-
//#region src/cartesian/reference-line/ReferenceLine.tsx
|
|
12
|
-
function scaleCoord(scale, value) {
|
|
13
|
-
const coord = scale(value);
|
|
14
|
-
if (!isWellBehavedNumber(coord)) return;
|
|
15
|
-
return coord + (scale.bandwidth?.() ?? 0) / 2;
|
|
16
|
-
}
|
|
17
|
-
function isInRange(scale, coord) {
|
|
18
|
-
const r = scale.range();
|
|
19
|
-
const min = Math.min(r[0], r[1]);
|
|
20
|
-
const max = Math.max(r[0], r[1]);
|
|
21
|
-
return coord >= min && coord <= max;
|
|
22
|
-
}
|
|
23
13
|
var ReferenceLine = /* @__PURE__ */ defineComponent({
|
|
24
14
|
name: "ReferenceLine",
|
|
25
15
|
props: {
|
|
@@ -64,10 +54,7 @@ var ReferenceLine = /* @__PURE__ */ defineComponent({
|
|
|
64
54
|
type: String,
|
|
65
55
|
default: "discard"
|
|
66
56
|
},
|
|
67
|
-
|
|
68
|
-
type: String,
|
|
69
|
-
default: void 0
|
|
70
|
-
}
|
|
57
|
+
class: classProp
|
|
71
58
|
},
|
|
72
59
|
inheritAttrs: false,
|
|
73
60
|
setup(props, { attrs }) {
|
|
@@ -135,9 +122,9 @@ var ReferenceLine = /* @__PURE__ */ defineComponent({
|
|
|
135
122
|
const clipPath = props.ifOverflow === "hidden" ? `url(#${clipPathId})` : void 0;
|
|
136
123
|
const svgAttrs = {
|
|
137
124
|
...attrs,
|
|
138
|
-
stroke: props.stroke,
|
|
125
|
+
"stroke": props.stroke,
|
|
139
126
|
"stroke-width": props.strokeWidth,
|
|
140
|
-
fill: props.fill
|
|
127
|
+
"fill": props.fill
|
|
141
128
|
};
|
|
142
129
|
const labelViewBox = {
|
|
143
130
|
x: Math.min(p1.x, p2.x),
|
|
@@ -147,7 +134,7 @@ var ReferenceLine = /* @__PURE__ */ defineComponent({
|
|
|
147
134
|
};
|
|
148
135
|
const labelValue = props.label;
|
|
149
136
|
const labelProps = typeof labelValue === "object" && labelValue !== null ? labelValue : {};
|
|
150
|
-
return createVNode(Layer, { "class": ["v-charts-reference-line", props.
|
|
137
|
+
return createVNode(Layer, { "class": ["v-charts-reference-line", props.class] }, { default: () => [createVNode("line", mergeProps(svgAttrs, {
|
|
151
138
|
"clip-path": clipPath,
|
|
152
139
|
"x1": p1.x,
|
|
153
140
|
"y1": p1.y,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classProp } from "../types/common.mjs";
|
|
1
2
|
import { getChartPointer } from "../utils/chart.mjs";
|
|
2
3
|
import { mouseLeaveChart } from "../state/tooltipSlice.mjs";
|
|
3
4
|
import { useAppDispatch } from "../state/hooks.mjs";
|
|
@@ -14,7 +15,7 @@ import { createVNode, defineComponent, ref } from "vue";
|
|
|
14
15
|
var RechartsWrapper = /* @__PURE__ */ defineComponent({
|
|
15
16
|
name: "RechartsWrapper",
|
|
16
17
|
props: {
|
|
17
|
-
class:
|
|
18
|
+
class: classProp,
|
|
18
19
|
height: {
|
|
19
20
|
type: Number,
|
|
20
21
|
required: true
|