vccs 0.4.1 → 0.6.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/dist/cartesian/axis/YAxis.d.ts +5 -5
- package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +12 -1
- package/dist/cartesian/cartesianPositionToCSSTranslate.d.ts +15 -0
- package/dist/cartesian/getCartesianPosition.d.ts +45 -0
- package/dist/cartesian/index.d.ts +1 -0
- package/dist/cartesian/type.d.ts +8 -0
- package/dist/chart/{RechartsWrapper.d.ts → ChartsWrapper.d.ts} +16 -1
- package/dist/chart/Surface.d.ts +2 -2
- package/dist/chart/generateCategoricalChart.d.ts +4 -0
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/legend/hooks/useLegend.d.ts +3 -0
- package/dist/components/legend/type.d.ts +18 -2
- package/dist/components/legend/utils.d.ts +9 -0
- package/dist/container/Surface.d.ts +3 -3
- package/dist/es/cartesian/axis/XAxis.mjs +11 -5
- package/dist/es/cartesian/axis/YAxis.mjs +62 -9
- package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +6 -1
- package/dist/es/cartesian/cartesianPositionToCSSTranslate.mjs +28 -0
- package/dist/es/cartesian/getCartesianPosition.mjs +176 -0
- package/dist/es/chart/{RechartsWrapper.mjs → ChartsWrapper.mjs} +26 -6
- package/dist/es/chart/Sankey.mjs +2 -2
- package/dist/es/chart/SunburstChart.mjs +2 -2
- package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +7 -1
- package/dist/es/chart/Treemap.mjs +2 -2
- package/dist/es/chart/generateCategoricalChart.mjs +53 -49
- package/dist/es/components/legend/Legend.mjs +5 -3
- package/dist/es/components/legend/hooks/useLegend.mjs +50 -9
- package/dist/es/components/legend/type.mjs +9 -1
- package/dist/es/components/legend/utils.mjs +12 -1
- package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +2 -11
- package/dist/es/container/Surface.mjs +5 -1
- package/dist/es/hooks/useResponsiveSize.mjs +27 -0
- package/dist/es/hooks/useRoundedSize.mjs +31 -0
- package/dist/es/shape/Sector.mjs +1 -1
- package/dist/es/state/cartesianAxisSlice.mjs +13 -2
- package/dist/es/state/legendSlice.mjs +2 -0
- package/dist/es/state/selectors/axisSelectors.mjs +3 -3
- package/dist/es/state/selectors/barSelectors.mjs +1 -1
- package/dist/es/state/selectors/pieSelectors.mjs +1 -1
- package/dist/es/state/selectors/polarAxisSelectors.mjs +1 -1
- package/dist/es/state/selectors/radialBarSelectors.mjs +1 -1
- package/dist/es/state/selectors/selectChartOffset.mjs +7 -4
- package/dist/es/state/selectors/selectLegendArea.mjs +19 -0
- package/dist/es/state/selectors/tooltipSelectors.mjs +1 -1
- package/dist/es/state/touchEventsMiddleware.mjs +1 -1
- package/dist/es/utils/YAxisUtils.mjs +29 -0
- package/dist/es/utils/chart.mjs +1 -1
- package/dist/es/utils/legend.mjs +23 -1
- package/dist/hooks/useResponsiveSize.d.ts +22 -0
- package/dist/hooks/useRoundedSize.d.ts +22 -0
- package/dist/state/cartesianAxisSlice.d.ts +11 -3
- package/dist/state/legendSlice.d.ts +3 -0
- package/dist/state/selectors/selectLegendArea.d.ts +7 -0
- package/dist/types/axis.d.ts +11 -1
- package/dist/utils/YAxisUtils.d.ts +20 -0
- package/package.json +1 -1
|
@@ -15,8 +15,8 @@ export declare const YAxis: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
15
15
|
default: boolean;
|
|
16
16
|
};
|
|
17
17
|
width: {
|
|
18
|
-
type:
|
|
19
|
-
default:
|
|
18
|
+
type: PropType<number | "auto">;
|
|
19
|
+
default: import('../../types/axis').YAxisWidth;
|
|
20
20
|
};
|
|
21
21
|
hide: {
|
|
22
22
|
type: BooleanConstructor;
|
|
@@ -99,8 +99,8 @@ export declare const YAxis: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
99
99
|
default: boolean;
|
|
100
100
|
};
|
|
101
101
|
width: {
|
|
102
|
-
type:
|
|
103
|
-
default:
|
|
102
|
+
type: PropType<number | "auto">;
|
|
103
|
+
default: import('../../types/axis').YAxisWidth;
|
|
104
104
|
};
|
|
105
105
|
hide: {
|
|
106
106
|
type: BooleanConstructor;
|
|
@@ -172,7 +172,7 @@ export declare const YAxis: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
172
172
|
}>> & Readonly<{}>, {
|
|
173
173
|
tickFormatter: Function;
|
|
174
174
|
unit: string;
|
|
175
|
-
width: number;
|
|
175
|
+
width: number | "auto";
|
|
176
176
|
scale: string | Function;
|
|
177
177
|
padding: Record<string, any>;
|
|
178
178
|
type: string;
|
|
@@ -110,6 +110,11 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
|
|
|
110
110
|
type: StringConstructor;
|
|
111
111
|
default: string;
|
|
112
112
|
};
|
|
113
|
+
/** Additional props to spread to each tick Text element. */
|
|
114
|
+
tickTextProps: {
|
|
115
|
+
type: ObjectConstructor;
|
|
116
|
+
default: any;
|
|
117
|
+
};
|
|
113
118
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
114
119
|
x: {
|
|
115
120
|
type: NumberConstructor;
|
|
@@ -188,6 +193,11 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
|
|
|
188
193
|
type: StringConstructor;
|
|
189
194
|
default: string;
|
|
190
195
|
};
|
|
196
|
+
/** Additional props to spread to each tick Text element. */
|
|
197
|
+
tickTextProps: {
|
|
198
|
+
type: ObjectConstructor;
|
|
199
|
+
default: any;
|
|
200
|
+
};
|
|
191
201
|
}>> & Readonly<{}>, {
|
|
192
202
|
interval: string | number;
|
|
193
203
|
tick: boolean;
|
|
@@ -195,9 +205,9 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
|
|
|
195
205
|
height: number;
|
|
196
206
|
x: number;
|
|
197
207
|
y: number;
|
|
208
|
+
viewBox: Record<string, any>;
|
|
198
209
|
orientation: string;
|
|
199
210
|
stroke: string;
|
|
200
|
-
viewBox: Record<string, any>;
|
|
201
211
|
label: any;
|
|
202
212
|
ticks: readonly CartesianTickItem[];
|
|
203
213
|
hide: boolean;
|
|
@@ -207,4 +217,5 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
|
|
|
207
217
|
tickLine: boolean | Record<string, any>;
|
|
208
218
|
tickSize: number;
|
|
209
219
|
tickMargin: number;
|
|
220
|
+
tickTextProps: Record<string, any>;
|
|
210
221
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TextAnchor, TextVerticalAnchor } from './getCartesianPosition';
|
|
2
|
+
/**
|
|
3
|
+
* CalculatedCartesianPosition returns horizontalAnchor and verticalAnchor
|
|
4
|
+
* which work directly with an SVG text element
|
|
5
|
+
* but for use in HTML context we have to translate them into CSS transform(translate)
|
|
6
|
+
* so this is what this function is doing.
|
|
7
|
+
*
|
|
8
|
+
* horizontalPosition is type: 'start' | 'middle' | 'end' | 'inherit'
|
|
9
|
+
* verticalPosition is type: 'start' | 'middle' | 'end'
|
|
10
|
+
*
|
|
11
|
+
* @param horizontalPosition as returned from {@link getCartesianPosition}
|
|
12
|
+
* @param verticalPosition as returned from {@link getCartesianPosition}
|
|
13
|
+
* @return CSS transform string
|
|
14
|
+
*/
|
|
15
|
+
export declare function cartesianPositionToCSSTranslate(horizontalPosition: TextAnchor, verticalPosition: TextVerticalAnchor): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CartesianViewBoxRequired, TrapezoidViewBox } from './type';
|
|
2
|
+
export type TextAnchor = 'start' | 'middle' | 'end' | 'inherit';
|
|
3
|
+
export type TextVerticalAnchor = 'start' | 'middle' | 'end';
|
|
4
|
+
export declare function cartesianViewBoxToTrapezoid(box: undefined): undefined;
|
|
5
|
+
export declare function cartesianViewBoxToTrapezoid(box: CartesianViewBoxRequired | TrapezoidViewBox): TrapezoidViewBox;
|
|
6
|
+
/**
|
|
7
|
+
* @inline
|
|
8
|
+
*/
|
|
9
|
+
export type CartesianPosition = 'top' | 'left' | 'right' | 'bottom' | 'center' | 'insideLeft' | 'insideRight' | 'insideTop' | 'insideBottom' | 'insideTopLeft' | 'insideBottomLeft' | 'insideTopRight' | 'insideBottomRight' | {
|
|
10
|
+
x: number | string;
|
|
11
|
+
y: number | string;
|
|
12
|
+
};
|
|
13
|
+
export type GetCartesianPositionOptions = {
|
|
14
|
+
viewBox: TrapezoidViewBox | CartesianViewBoxRequired;
|
|
15
|
+
parentViewBox?: CartesianViewBoxRequired;
|
|
16
|
+
/**
|
|
17
|
+
* The offset to the specified "position". Direction of the offset depends on the position.
|
|
18
|
+
*/
|
|
19
|
+
offset?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The position of the element relative to the view box.
|
|
22
|
+
*/
|
|
23
|
+
position?: CartesianPosition;
|
|
24
|
+
/**
|
|
25
|
+
* If true, the returned width and height will be clamped to keep the element within the parentViewBox.
|
|
26
|
+
* This is useful for preventing labels from overflowing the chart area.
|
|
27
|
+
*/
|
|
28
|
+
clamp?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type CalculatedCartesianPosition = {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
horizontalAnchor: TextAnchor;
|
|
34
|
+
verticalAnchor: TextVerticalAnchor;
|
|
35
|
+
width?: number;
|
|
36
|
+
height?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the position and alignment for a generic element in a Cartesian coordinate system.
|
|
40
|
+
*
|
|
41
|
+
* @param options - The options including viewBox, position, and offset.
|
|
42
|
+
* @returns The calculated x, y, alignment and size.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getCartesianPosition(options: GetCartesianPositionOptions): CalculatedCartesianPosition;
|
|
45
|
+
export declare function isOutsidePosition(position: CartesianPosition | undefined): boolean;
|
package/dist/cartesian/type.d.ts
CHANGED
|
@@ -18,4 +18,12 @@ export interface CartesianViewBox {
|
|
|
18
18
|
}
|
|
19
19
|
export type ViewBox = CartesianViewBox | PolarViewBox;
|
|
20
20
|
export type CartesianViewBoxRequired = Required<CartesianViewBox>;
|
|
21
|
+
export interface TrapezoidViewBox {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
upperWidth: number;
|
|
25
|
+
lowerWidth: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
21
29
|
export type Sign = 0 | 1 | -1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropType, StyleValue } from 'vue';
|
|
2
2
|
import { CategoricalChartFunc } from '../types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ChartsWrapper: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
4
4
|
class: {
|
|
5
5
|
type: PropType<import('../types').VueClassValue>;
|
|
6
6
|
default: any;
|
|
@@ -33,6 +33,9 @@ export declare const RechartsWrapper: import('vue').DefineComponent<import('vue'
|
|
|
33
33
|
onMouseUp: {
|
|
34
34
|
type: PropType<CategoricalChartFunc>;
|
|
35
35
|
};
|
|
36
|
+
onResize: {
|
|
37
|
+
type: PropType<(width: number, height: number) => void>;
|
|
38
|
+
};
|
|
36
39
|
onTouchEnd: {
|
|
37
40
|
type: PropType<CategoricalChartFunc>;
|
|
38
41
|
};
|
|
@@ -42,6 +45,10 @@ export declare const RechartsWrapper: import('vue').DefineComponent<import('vue'
|
|
|
42
45
|
onTouchStart: {
|
|
43
46
|
type: PropType<CategoricalChartFunc>;
|
|
44
47
|
};
|
|
48
|
+
responsive: {
|
|
49
|
+
type: BooleanConstructor;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
45
52
|
style: {
|
|
46
53
|
type: PropType<StyleValue>;
|
|
47
54
|
};
|
|
@@ -82,6 +89,9 @@ export declare const RechartsWrapper: import('vue').DefineComponent<import('vue'
|
|
|
82
89
|
onMouseUp: {
|
|
83
90
|
type: PropType<CategoricalChartFunc>;
|
|
84
91
|
};
|
|
92
|
+
onResize: {
|
|
93
|
+
type: PropType<(width: number, height: number) => void>;
|
|
94
|
+
};
|
|
85
95
|
onTouchEnd: {
|
|
86
96
|
type: PropType<CategoricalChartFunc>;
|
|
87
97
|
};
|
|
@@ -91,6 +101,10 @@ export declare const RechartsWrapper: import('vue').DefineComponent<import('vue'
|
|
|
91
101
|
onTouchStart: {
|
|
92
102
|
type: PropType<CategoricalChartFunc>;
|
|
93
103
|
};
|
|
104
|
+
responsive: {
|
|
105
|
+
type: BooleanConstructor;
|
|
106
|
+
default: boolean;
|
|
107
|
+
};
|
|
94
108
|
style: {
|
|
95
109
|
type: PropType<StyleValue>;
|
|
96
110
|
};
|
|
@@ -100,4 +114,5 @@ export declare const RechartsWrapper: import('vue').DefineComponent<import('vue'
|
|
|
100
114
|
};
|
|
101
115
|
}>> & Readonly<{}>, {
|
|
102
116
|
class: import('../types').VueClassValue;
|
|
117
|
+
responsive: boolean;
|
|
103
118
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
package/dist/chart/Surface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyleValue } from 'vue';
|
|
2
2
|
import { VueClassValue } from '../types';
|
|
3
3
|
interface SurfaceProps {
|
|
4
4
|
width: number;
|
|
@@ -10,7 +10,7 @@ interface SurfaceProps {
|
|
|
10
10
|
height?: number;
|
|
11
11
|
};
|
|
12
12
|
class?: VueClassValue;
|
|
13
|
-
style?:
|
|
13
|
+
style?: StyleValue;
|
|
14
14
|
title?: string;
|
|
15
15
|
desc?: string;
|
|
16
16
|
}
|
|
@@ -67,6 +67,10 @@ export declare const CategoricalProps: {
|
|
|
67
67
|
outerRadius: {
|
|
68
68
|
type: (NumberConstructor | StringConstructor)[];
|
|
69
69
|
};
|
|
70
|
+
responsive: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
70
74
|
reverseStackOrder: {
|
|
71
75
|
type: BooleanConstructor;
|
|
72
76
|
default: boolean;
|
|
@@ -268,8 +268,8 @@ export declare const Tooltip: import('vue').DefineComponent<import('vue').Extrac
|
|
|
268
268
|
readonly default: " : ";
|
|
269
269
|
};
|
|
270
270
|
}>> & Readonly<{}>, {
|
|
271
|
-
readonly cursor: boolean | object;
|
|
272
271
|
readonly offset: number;
|
|
272
|
+
readonly cursor: boolean | object;
|
|
273
273
|
readonly style: Record<string, any>;
|
|
274
274
|
readonly isAnimationActive: boolean;
|
|
275
275
|
readonly includeHidden: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSProperties } from 'vue';
|
|
2
|
+
import { LayoutType } from '../../../types';
|
|
2
3
|
import { LegendPayload } from '../../DefaultLegendContent';
|
|
3
4
|
import { LegendProps } from '../type';
|
|
4
5
|
export declare function useLegend(props: LegendProps): {
|
|
@@ -14,6 +15,8 @@ export declare function useLegend(props: LegendProps): {
|
|
|
14
15
|
processedPayload: import('vue').ComputedRef<LegendPayload[]>;
|
|
15
16
|
outerStyle: import('vue').ComputedRef<CSSProperties>;
|
|
16
17
|
legendPortal: import('vue').ComputedRef<HTMLElement>;
|
|
18
|
+
resolvedLayout: import('vue').ComputedRef<LayoutType>;
|
|
19
|
+
positionViewBox: import('vue').ComputedRef<Required<import('../../../cartesian/type').CartesianViewBox>>;
|
|
17
20
|
syncSettings: () => void;
|
|
18
21
|
syncSize: () => void;
|
|
19
22
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, PropType, VNode } from 'vue';
|
|
2
2
|
import { LayoutType, Margin } from '../../types';
|
|
3
|
+
import { CartesianPosition } from '../../cartesian/getCartesianPosition';
|
|
3
4
|
import { LegendType } from '../../types/legend';
|
|
4
5
|
import { HorizontalAlignmentType, LegendPayload, VerticalAlignmentType } from '../DefaultLegendContent';
|
|
5
6
|
import { VuePropsToType, WithSVGProps } from '../../types/common';
|
|
@@ -8,8 +9,8 @@ export interface LegendSlots {
|
|
|
8
9
|
}
|
|
9
10
|
export declare const LegendVueProps: {
|
|
10
11
|
readonly layout: {
|
|
11
|
-
readonly type: PropType<LayoutType>;
|
|
12
|
-
readonly default: "
|
|
12
|
+
readonly type: PropType<LayoutType | "auto">;
|
|
13
|
+
readonly default: "auto";
|
|
13
14
|
};
|
|
14
15
|
readonly align: {
|
|
15
16
|
readonly type: PropType<HorizontalAlignmentType>;
|
|
@@ -19,6 +20,21 @@ export declare const LegendVueProps: {
|
|
|
19
20
|
readonly type: PropType<VerticalAlignmentType>;
|
|
20
21
|
readonly default: "bottom";
|
|
21
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* The position of the legend relative to the chart.
|
|
25
|
+
* If this is defined, it overrides `align` and `verticalAlign`.
|
|
26
|
+
*/
|
|
27
|
+
readonly position: {
|
|
28
|
+
readonly type: PropType<CartesianPosition>;
|
|
29
|
+
readonly default: any;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The offset to the specified `position`. Direction of the offset depends on the position.
|
|
33
|
+
*/
|
|
34
|
+
readonly offset: {
|
|
35
|
+
readonly type: NumberConstructor;
|
|
36
|
+
readonly default: 0;
|
|
37
|
+
};
|
|
22
38
|
readonly width: NumberConstructor;
|
|
23
39
|
readonly height: NumberConstructor;
|
|
24
40
|
readonly iconSize: {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { CSSProperties } from 'vue';
|
|
2
2
|
import { LayoutType, Margin } from '../../types';
|
|
3
|
+
import { CartesianPosition } from '../../cartesian/getCartesianPosition';
|
|
3
4
|
import { HorizontalAlignmentType, VerticalAlignmentType } from '../DefaultLegendContent';
|
|
4
5
|
type PositionInput = {
|
|
5
6
|
layout?: LayoutType;
|
|
6
7
|
align?: HorizontalAlignmentType;
|
|
7
8
|
verticalAlign?: VerticalAlignmentType;
|
|
8
9
|
};
|
|
10
|
+
export declare function getLayoutForPosition(position: CartesianPosition | undefined): LayoutType;
|
|
11
|
+
export declare function getOutsidePositionOffset(position: CartesianPosition | undefined, offset: number, box: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}): {
|
|
15
|
+
top?: number;
|
|
16
|
+
left?: number;
|
|
17
|
+
};
|
|
9
18
|
export declare function getDefaultPosition(style: CSSProperties | undefined, props: PositionInput, margin: Margin, chartWidth: number, chartHeight: number, box: {
|
|
10
19
|
width: number;
|
|
11
20
|
height: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SVGAttributes, StyleValue } from 'vue';
|
|
2
2
|
import { VueClassValue } from '../types';
|
|
3
3
|
interface ViewBox {
|
|
4
4
|
x?: number;
|
|
@@ -11,7 +11,7 @@ declare const Surface: import('vue').DefineComponent<Omit<SVGAttributes, "viewBo
|
|
|
11
11
|
height: number;
|
|
12
12
|
viewBox?: ViewBox;
|
|
13
13
|
class?: VueClassValue;
|
|
14
|
-
style?:
|
|
14
|
+
style?: StyleValue;
|
|
15
15
|
title?: string;
|
|
16
16
|
desc?: string;
|
|
17
17
|
}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Omit<SVGAttributes, "viewBox"> & {
|
|
@@ -19,7 +19,7 @@ declare const Surface: import('vue').DefineComponent<Omit<SVGAttributes, "viewBo
|
|
|
19
19
|
height: number;
|
|
20
20
|
viewBox?: ViewBox;
|
|
21
21
|
class?: VueClassValue;
|
|
22
|
-
style?:
|
|
22
|
+
style?: StyleValue;
|
|
23
23
|
title?: string;
|
|
24
24
|
desc?: string;
|
|
25
25
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -4,7 +4,7 @@ import { implicitXAxis, selectAxisScale, selectTicksOfAxis, selectXAxisPosition,
|
|
|
4
4
|
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
5
5
|
import { addXAxis, removeXAxis } from "../../state/cartesianAxisSlice.mjs";
|
|
6
6
|
import { CartesianAxis } from "../cartesian-axis/CartesianAxis.mjs";
|
|
7
|
-
import { createVNode, defineComponent, mergeProps, watchEffect } from "vue";
|
|
7
|
+
import { createVNode, defineComponent, mergeProps, onUnmounted, watchEffect } from "vue";
|
|
8
8
|
//#region src/cartesian/axis/XAxis.tsx
|
|
9
9
|
/**
|
|
10
10
|
* @fileOverview X Axis
|
|
@@ -78,7 +78,8 @@ var XAxisSettingsDispatcher = /* @__PURE__ */ defineComponent({
|
|
|
78
78
|
},
|
|
79
79
|
setup(props, { slots: dispatcherSlots }) {
|
|
80
80
|
const dispatch = useAppDispatch();
|
|
81
|
-
|
|
81
|
+
let registeredSettings;
|
|
82
|
+
watchEffect(() => {
|
|
82
83
|
const settings = {
|
|
83
84
|
interval: props.interval ?? "preserveEnd",
|
|
84
85
|
id: props.xAxisId,
|
|
@@ -105,10 +106,15 @@ var XAxisSettingsDispatcher = /* @__PURE__ */ defineComponent({
|
|
|
105
106
|
tick: props.tick ?? true,
|
|
106
107
|
tickFormatter: props.tickFormatter
|
|
107
108
|
};
|
|
109
|
+
if (registeredSettings && registeredSettings.id !== settings.id) dispatch(removeXAxis(registeredSettings));
|
|
108
110
|
dispatch(addXAxis(settings));
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
registeredSettings = settings;
|
|
112
|
+
});
|
|
113
|
+
onUnmounted(() => {
|
|
114
|
+
if (registeredSettings) {
|
|
115
|
+
dispatch(removeXAxis(registeredSettings));
|
|
116
|
+
registeredSettings = void 0;
|
|
117
|
+
}
|
|
112
118
|
});
|
|
113
119
|
return () => createVNode(XAxisImpl, props, { default: () => [dispatcherSlots.tick ? { tick: dispatcherSlots.tick } : void 0] });
|
|
114
120
|
}
|
|
@@ -2,9 +2,10 @@ import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
|
|
|
2
2
|
import { selectAxisViewBox } from "../../state/selectors/selectChartOffset.mjs";
|
|
3
3
|
import { implicitYAxis, selectAxisScale, selectTicksOfAxis, selectYAxisPosition, selectYAxisSize } from "../../state/selectors/axisSelectors.mjs";
|
|
4
4
|
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
5
|
-
import { addYAxis, removeYAxis } from "../../state/cartesianAxisSlice.mjs";
|
|
5
|
+
import { addYAxis, removeYAxis, updateYAxisWidth } from "../../state/cartesianAxisSlice.mjs";
|
|
6
6
|
import { CartesianAxis } from "../cartesian-axis/CartesianAxis.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { getCalculatedYAxisWidth } from "../../utils/YAxisUtils.mjs";
|
|
8
|
+
import { createVNode, defineComponent, isVNode, mergeProps, nextTick, onUnmounted, ref, watch, watchEffect } from "vue";
|
|
8
9
|
//#region src/cartesian/axis/YAxis.tsx
|
|
9
10
|
var YAxisImpl = /* @__PURE__ */ defineComponent({
|
|
10
11
|
props: { yAxisId: {
|
|
@@ -15,11 +16,55 @@ var YAxisImpl = /* @__PURE__ */ defineComponent({
|
|
|
15
16
|
setup(props, { attrs }) {
|
|
16
17
|
const isPanorama = useIsPanorama();
|
|
17
18
|
const axisType = "yAxis";
|
|
19
|
+
const dispatch = useAppDispatch();
|
|
18
20
|
const scale = useAppSelector((state) => selectAxisScale(state, axisType, props.yAxisId, isPanorama));
|
|
19
21
|
const axisSize = useAppSelector((state) => selectYAxisSize(state, props.yAxisId));
|
|
20
22
|
const position = useAppSelector((state) => selectYAxisPosition(state, props.yAxisId));
|
|
21
23
|
const cartesianTickItems = useAppSelector((state) => selectTicksOfAxis(state, axisType, props.yAxisId, isPanorama));
|
|
22
24
|
const viewBox = useAppSelector(selectAxisViewBox);
|
|
25
|
+
const chartDataLengthEmpty = useAppSelector((state) => !state.chartData.chartData?.length);
|
|
26
|
+
const cartesianAxisRef = ref(null);
|
|
27
|
+
const isAutoWidth = () => attrs.width === "auto";
|
|
28
|
+
const measureAxisWidth = () => {
|
|
29
|
+
const el = cartesianAxisRef.value?.$el;
|
|
30
|
+
if (!el) return;
|
|
31
|
+
const ticks = el.getElementsByClassName("v-charts-cartesian-axis-tick-value");
|
|
32
|
+
const label = el.getElementsByClassName("v-charts-label")[0];
|
|
33
|
+
return getCalculatedYAxisWidth({
|
|
34
|
+
ticks,
|
|
35
|
+
label,
|
|
36
|
+
labelGapWithTick: 5,
|
|
37
|
+
tickSize: typeof attrs.tickSize === "number" ? attrs.tickSize : 6,
|
|
38
|
+
tickMargin: typeof attrs.tickMargin === "number" ? attrs.tickMargin : 2
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
watch(chartDataLengthEmpty, (empty) => {
|
|
42
|
+
if (empty === false && isAutoWidth()) dispatch(updateYAxisWidth({
|
|
43
|
+
id: props.yAxisId,
|
|
44
|
+
width: 60
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
const updateAutoWidth = () => {
|
|
48
|
+
if (!isAutoWidth() || axisSize.value == null) return;
|
|
49
|
+
const label = attrs.label;
|
|
50
|
+
if (typeof label === "function" || isVNode(label)) return;
|
|
51
|
+
const updatedYAxisWidth = measureAxisWidth();
|
|
52
|
+
if (updatedYAxisWidth == null) return;
|
|
53
|
+
if (Math.round(axisSize.value.width) !== Math.round(updatedYAxisWidth)) dispatch(updateYAxisWidth({
|
|
54
|
+
id: props.yAxisId,
|
|
55
|
+
width: updatedYAxisWidth
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
watch([
|
|
59
|
+
axisSize,
|
|
60
|
+
cartesianTickItems,
|
|
61
|
+
() => attrs.label
|
|
62
|
+
], () => {
|
|
63
|
+
nextTick(updateAutoWidth);
|
|
64
|
+
}, {
|
|
65
|
+
flush: "post",
|
|
66
|
+
immediate: true
|
|
67
|
+
});
|
|
23
68
|
return () => {
|
|
24
69
|
const { ...allOtherProps } = props;
|
|
25
70
|
if (axisSize.value == null || position.value == null) return null;
|
|
@@ -31,7 +76,9 @@ var YAxisImpl = /* @__PURE__ */ defineComponent({
|
|
|
31
76
|
"width": axisSize.value?.width,
|
|
32
77
|
"height": axisSize.value?.height,
|
|
33
78
|
"ticks": cartesianTickItems.value,
|
|
34
|
-
"
|
|
79
|
+
"tickTextProps": isAutoWidth() ? { width: void 0 } : { width: axisSize.value?.width },
|
|
80
|
+
"class": ["v-charts-yAxis yAxis"],
|
|
81
|
+
"ref": cartesianAxisRef
|
|
35
82
|
}), null);
|
|
36
83
|
};
|
|
37
84
|
}
|
|
@@ -53,7 +100,7 @@ var YAxisSettingsDispatcher = /* @__PURE__ */ defineComponent({
|
|
|
53
100
|
includeHidden: Boolean,
|
|
54
101
|
reversed: Boolean,
|
|
55
102
|
ticks: Array,
|
|
56
|
-
width: Number,
|
|
103
|
+
width: [Number, String],
|
|
57
104
|
orientation: String,
|
|
58
105
|
mirror: Boolean,
|
|
59
106
|
hide: Boolean,
|
|
@@ -78,7 +125,8 @@ var YAxisSettingsDispatcher = /* @__PURE__ */ defineComponent({
|
|
|
78
125
|
},
|
|
79
126
|
setup(props) {
|
|
80
127
|
const dispatch = useAppDispatch();
|
|
81
|
-
|
|
128
|
+
let registeredSettings;
|
|
129
|
+
watchEffect(() => {
|
|
82
130
|
const settings = {
|
|
83
131
|
...props,
|
|
84
132
|
interval: props.interval ?? "preserveEnd",
|
|
@@ -89,10 +137,15 @@ var YAxisSettingsDispatcher = /* @__PURE__ */ defineComponent({
|
|
|
89
137
|
minTickGap: props.minTickGap ?? 5,
|
|
90
138
|
tick: props.tick ?? true
|
|
91
139
|
};
|
|
140
|
+
if (registeredSettings && registeredSettings.id !== settings.id) dispatch(removeYAxis(registeredSettings));
|
|
92
141
|
dispatch(addYAxis(settings));
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
142
|
+
registeredSettings = settings;
|
|
143
|
+
});
|
|
144
|
+
onUnmounted(() => {
|
|
145
|
+
if (registeredSettings) {
|
|
146
|
+
dispatch(removeYAxis(registeredSettings));
|
|
147
|
+
registeredSettings = void 0;
|
|
148
|
+
}
|
|
96
149
|
});
|
|
97
150
|
return () => createVNode(YAxisImpl, props, null);
|
|
98
151
|
}
|
|
@@ -113,7 +166,7 @@ var YAxis = /* @__PURE__ */ defineComponent({
|
|
|
113
166
|
default: implicitYAxis.allowDuplicatedCategory
|
|
114
167
|
},
|
|
115
168
|
width: {
|
|
116
|
-
type: Number,
|
|
169
|
+
type: [Number, String],
|
|
117
170
|
default: implicitYAxis.width
|
|
118
171
|
},
|
|
119
172
|
hide: {
|
|
@@ -90,6 +90,10 @@ var CartesianAxis = /* @__PURE__ */ defineComponent({
|
|
|
90
90
|
stroke: {
|
|
91
91
|
type: String,
|
|
92
92
|
default: "#666"
|
|
93
|
+
},
|
|
94
|
+
tickTextProps: {
|
|
95
|
+
type: Object,
|
|
96
|
+
default: void 0
|
|
93
97
|
}
|
|
94
98
|
},
|
|
95
99
|
setup(props, { slots }) {
|
|
@@ -235,7 +239,8 @@ var CartesianAxis = /* @__PURE__ */ defineComponent({
|
|
|
235
239
|
index: i,
|
|
236
240
|
payload: entry,
|
|
237
241
|
visibleTicksCount: finalTicks.length,
|
|
238
|
-
tickFormatter
|
|
242
|
+
tickFormatter,
|
|
243
|
+
...props.tickTextProps
|
|
239
244
|
};
|
|
240
245
|
return createVNode(Layer, {
|
|
241
246
|
"class": "v-charts-cartesian-axis-tick",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/cartesian/cartesianPositionToCSSTranslate.ts
|
|
2
|
+
/**
|
|
3
|
+
* CalculatedCartesianPosition returns horizontalAnchor and verticalAnchor
|
|
4
|
+
* which work directly with an SVG text element
|
|
5
|
+
* but for use in HTML context we have to translate them into CSS transform(translate)
|
|
6
|
+
* so this is what this function is doing.
|
|
7
|
+
*
|
|
8
|
+
* horizontalPosition is type: 'start' | 'middle' | 'end' | 'inherit'
|
|
9
|
+
* verticalPosition is type: 'start' | 'middle' | 'end'
|
|
10
|
+
*
|
|
11
|
+
* @param horizontalPosition as returned from {@link getCartesianPosition}
|
|
12
|
+
* @param verticalPosition as returned from {@link getCartesianPosition}
|
|
13
|
+
* @return CSS transform string
|
|
14
|
+
*/
|
|
15
|
+
function cartesianPositionToCSSTranslate(horizontalPosition, verticalPosition) {
|
|
16
|
+
if (horizontalPosition === "start" && verticalPosition === "start") return "";
|
|
17
|
+
return `translate(${horizontalPosition === "inherit" ? "0" : {
|
|
18
|
+
start: "0",
|
|
19
|
+
middle: "-50%",
|
|
20
|
+
end: "-100%"
|
|
21
|
+
}[horizontalPosition]}, ${{
|
|
22
|
+
start: "0",
|
|
23
|
+
middle: "-50%",
|
|
24
|
+
end: "-100%"
|
|
25
|
+
}[verticalPosition] ?? "0"})`;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { cartesianPositionToCSSTranslate };
|