vccs 0.1.0 → 0.2.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/funnel/Funnel.d.ts +2 -0
- package/dist/cartesian/funnel/index.d.ts +2 -0
- package/dist/cartesian/funnel/type.d.ts +74 -5
- package/dist/cartesian/index.d.ts +1 -0
- package/dist/chart/FunnelChart.d.ts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/es/animation/Animate.mjs +48 -22
- package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
- package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
- package/dist/es/cartesian/area/Area.mjs +42 -31
- package/dist/es/cartesian/area/ClipRect.mjs +79 -58
- package/dist/es/cartesian/area/RenderArea.mjs +142 -108
- package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
- package/dist/es/cartesian/area/type.mjs +11 -11
- package/dist/es/cartesian/area/utils.mjs +69 -49
- package/dist/es/cartesian/axis/XAxis.mjs +87 -73
- package/dist/es/cartesian/axis/YAxis.mjs +67 -56
- package/dist/es/cartesian/bar/Bar.mjs +93 -71
- package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
- package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
- package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
- package/dist/es/cartesian/bar/type.mjs +9 -9
- package/dist/es/cartesian/bar/utils.mjs +97 -70
- package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
- package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
- package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
- package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
- package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
- package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
- package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
- package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
- package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
- package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
- package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
- package/dist/es/cartesian/funnel/Funnel.mjs +177 -0
- package/dist/es/cartesian/funnel/type.mjs +80 -0
- package/dist/es/cartesian/funnel/utils.mjs +102 -0
- package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
- package/dist/es/cartesian/line/Line.mjs +41 -37
- package/dist/es/cartesian/line/StaticLine.mjs +191 -122
- package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
- package/dist/es/cartesian/line/type.mjs +11 -11
- package/dist/es/cartesian/line/utils.mjs +27 -26
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +86 -69
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +99 -77
- package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
- package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
- package/dist/es/cartesian/useNeedsClip.mjs +18 -9
- package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
- package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
- package/dist/es/chart/AreaChart.mjs +5 -5
- package/dist/es/chart/BarChart.mjs +5 -5
- package/dist/es/chart/ComposedChart.mjs +5 -5
- package/dist/es/chart/FunnelChart.mjs +11 -0
- package/dist/es/chart/LegendPortalContext.mjs +3 -3
- package/dist/es/chart/LineChart.mjs +5 -5
- package/dist/es/chart/PieChart.mjs +5 -5
- package/dist/es/chart/RadarChart.mjs +5 -5
- package/dist/es/chart/RadialBarChart.mjs +5 -5
- package/dist/es/chart/RechartsWrapper.mjs +111 -88
- package/dist/es/chart/ScatterChart.mjs +5 -5
- package/dist/es/chart/Surface.mjs +3 -3
- package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
- package/dist/es/chart/TooltipPortalContext.mjs +3 -3
- package/dist/es/chart/const.mjs +2 -2
- package/dist/es/chart/generateCategoricalChart.mjs +97 -88
- package/dist/es/chart/provideClipPathId.mjs +12 -7
- package/dist/es/components/Cell.mjs +16 -4
- package/dist/es/components/Text.mjs +3 -3
- package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
- package/dist/es/components/Tooltip.mjs +274 -199
- package/dist/es/components/label/Label.mjs +30 -26
- package/dist/es/components/label/LabelList.mjs +45 -39
- package/dist/es/components/label/types.mjs +8 -5
- package/dist/es/components/label/utils.mjs +194 -162
- package/dist/es/components/legend/Legend.mjs +82 -71
- package/dist/es/components/legend/LegendSymbol.mjs +40 -38
- package/dist/es/components/legend/hooks/useLegend.mjs +66 -46
- package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
- package/dist/es/components/legend/type.mjs +2 -2
- package/dist/es/components/legend/utils.mjs +19 -11
- package/dist/es/components/utils.mjs +35 -22
- package/dist/es/container/ClipPath.mjs +14 -14
- package/dist/es/container/Layer.mjs +9 -7
- package/dist/es/container/ResponsiveContainer.mjs +3 -3
- package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
- package/dist/es/container/Surface.mjs +23 -19
- package/dist/es/container/useSizeContext.mjs +3 -3
- package/dist/es/context/ChartDataContextProvider.mjs +19 -13
- package/dist/es/context/PanoramaContextProvider.mjs +15 -10
- package/dist/es/context/accessibilityContext.mjs +3 -3
- package/dist/es/context/cartesianLabelListContext.mjs +3 -3
- package/dist/es/context/chartLayoutContext.mjs +33 -30
- package/dist/es/context/cursorLayerContext.mjs +3 -3
- package/dist/es/context/graphicalLayerContext.mjs +3 -3
- package/dist/es/context/labelLayerContext.mjs +3 -3
- package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
- package/dist/es/context/useTooltipAxis.mjs +14 -12
- package/dist/es/events/useChartSynchronisation.mjs +91 -66
- package/dist/es/hooks/useIsAnimating.mjs +28 -0
- package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
- package/dist/es/index.mjs +46 -42
- package/dist/es/polar/pie/Pie.mjs +131 -115
- package/dist/es/polar/pie/type.mjs +6 -6
- package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
- package/dist/es/polar/radar/PolarGrid.mjs +72 -59
- package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
- package/dist/es/polar/radar/Radar.mjs +181 -145
- package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
- package/dist/es/polar/radial-bar/type.mjs +9 -9
- package/dist/es/shape/Cross.mjs +11 -10
- package/dist/es/shape/Curve.mjs +69 -43
- package/dist/es/shape/Dot.mjs +12 -11
- package/dist/es/shape/Rectangle.mjs +41 -26
- package/dist/es/shape/Sector.mjs +103 -75
- package/dist/es/shape/Symbols.mjs +45 -34
- package/dist/es/shape/Trapezoid.mjs +52 -0
- package/dist/es/state/ReportChartProps.mjs +21 -20
- package/dist/es/state/ReportMainChartProps.mjs +26 -21
- package/dist/es/state/ReportPolarOptions.mjs +23 -22
- package/dist/es/state/SetGraphicalItem.mjs +42 -27
- package/dist/es/state/SetLegendPayload.mjs +17 -13
- package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
- package/dist/es/state/brushSlice.mjs +12 -8
- package/dist/es/state/cartesianAxisSlice.mjs +23 -17
- package/dist/es/state/chartDataSlice.mjs +18 -13
- package/dist/es/state/externalEventsMiddleware.mjs +25 -15
- package/dist/es/state/graphicalItemsSlice.mjs +29 -25
- package/dist/es/state/hooks.mjs +4 -3
- package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
- package/dist/es/state/layoutSlice.mjs +18 -12
- package/dist/es/state/legendSlice.mjs +19 -14
- package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
- package/dist/es/state/optionsSlice.mjs +14 -11
- package/dist/es/state/polarAxisSlice.mjs +15 -13
- package/dist/es/state/polarOptionsSlice.mjs +8 -6
- package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
- package/dist/es/state/referenceElementsSlice.mjs +21 -19
- package/dist/es/state/rootPropsSlice.mjs +20 -9
- package/dist/es/state/selectors/areaSelectors.mjs +65 -55
- package/dist/es/state/selectors/axisSelectors.mjs +755 -569
- package/dist/es/state/selectors/barSelectors.mjs +225 -162
- package/dist/es/state/selectors/brushSelectors.mjs +15 -14
- package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
- package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
- package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
- package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
- package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
- package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
- package/dist/es/state/selectors/common.mjs +2 -2
- package/dist/es/state/selectors/containerSelectors.mjs +5 -2
- package/dist/es/state/selectors/dataSelectors.mjs +28 -9
- package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
- package/dist/es/state/selectors/legendSelectors.mjs +7 -6
- package/dist/es/state/selectors/lineSelectors.mjs +54 -47
- package/dist/es/state/selectors/pickAxisId.mjs +2 -2
- package/dist/es/state/selectors/pickAxisType.mjs +2 -2
- package/dist/es/state/selectors/pieSelectors.mjs +116 -81
- package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
- package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
- package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
- package/dist/es/state/selectors/polarSelectors.mjs +79 -62
- package/dist/es/state/selectors/radarSelectors.mjs +111 -91
- package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
- package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
- package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
- package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
- package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
- package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
- package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
- package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
- package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
- package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
- package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
- package/dist/es/state/selectors/selectors.mjs +94 -75
- package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
- package/dist/es/state/selectors/touchSelectors.mjs +17 -14
- package/dist/es/state/store.mjs +46 -46
- package/dist/es/state/tooltipSlice.mjs +64 -37
- package/dist/es/state/touchEventsMiddleware.mjs +35 -29
- package/dist/es/state/utils/useReportScale.mjs +16 -13
- package/dist/es/synchronisation/syncSelectors.mjs +3 -3
- package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
- package/dist/es/types/event.mjs +164 -2
- package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
- package/dist/es/utils/VueUtils.mjs +35 -14
- package/dist/es/utils/attrs.mjs +43 -26
- package/dist/es/utils/cartesian.mjs +47 -15
- package/dist/es/utils/chart.mjs +298 -197
- package/dist/es/utils/const.mjs +30 -2
- package/dist/es/utils/createContext.mjs +28 -9
- package/dist/es/utils/data-utils.mjs +9 -8
- package/dist/es/utils/data.mjs +35 -21
- package/dist/es/utils/events.mjs +5 -3
- package/dist/es/utils/getLinearRegression.mjs +28 -11
- package/dist/es/utils/grid.mjs +20 -5
- package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
- package/dist/es/utils/legend.mjs +13 -12
- package/dist/es/utils/log.mjs +10 -7
- package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
- package/dist/es/utils/polar.mjs +37 -30
- package/dist/es/utils/props.mjs +16 -10
- package/dist/es/utils/resolveDefaultProps.mjs +23 -4
- package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
- package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
- package/dist/es/utils/scale/utils/utils.mjs +43 -24
- package/dist/es/utils/style.mjs +24 -13
- package/dist/es/utils/tick.mjs +34 -23
- package/dist/es/utils/tooltip/translate.mjs +63 -49
- package/dist/es/utils/validate.mjs +40 -29
- package/dist/hooks/useIsAnimating.d.ts +14 -0
- package/dist/shape/Trapezoid.d.ts +31 -0
- package/dist/shape/index.d.ts +1 -0
- package/dist/state/graphicalItemsSlice.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,84 +1,111 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { mathSign
|
|
3
|
-
import { getBaseValueOfBar
|
|
4
|
-
import { toRaw
|
|
5
|
-
import { isNaN
|
|
6
|
-
import { invariant
|
|
1
|
+
import { isNullish, isNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { mathSign } from "../../utils/data.mjs";
|
|
3
|
+
import { getBaseValueOfBar, getCateCoordinateOfBar, getValueByDataKey, truncateByDomain } from "../../utils/chart.mjs";
|
|
4
|
+
import { toRaw } from "vue";
|
|
5
|
+
import { isNaN } from "es-toolkit/compat";
|
|
6
|
+
import { invariant } from "es-toolkit";
|
|
7
7
|
//#region src/cartesian/bar/utils.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Safely gets minPointSize from the minPointSize prop if it is a function
|
|
10
|
+
* @param minPointSize minPointSize as passed to the Bar component
|
|
11
|
+
* @param defaultValue default minPointSize
|
|
12
|
+
* @returns minPointSize
|
|
13
|
+
*/
|
|
14
|
+
function minPointSizeCallback(minPointSize, defaultValue = 0) {
|
|
15
|
+
return (value, index) => {
|
|
16
|
+
if (isNumber(minPointSize)) return minPointSize;
|
|
17
|
+
const isValueNumberOrNil = isNumber(value) || isNullish(value);
|
|
18
|
+
if (isValueNumberOrNil) return minPointSize(value, index);
|
|
19
|
+
invariant(isValueNumberOrNil, `minPointSize callback function received a value with type of ${typeof value}. Currently only numbers or null/undefined are supported.`);
|
|
20
|
+
return defaultValue;
|
|
13
21
|
};
|
|
14
22
|
}
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
x:
|
|
19
|
-
y:
|
|
20
|
-
width:
|
|
21
|
-
height:
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
var defaultMinPointSize = 0;
|
|
24
|
+
function computeBarRectangles({ layout, barSettings: { dataKey, minPointSize: minPointSizeProp }, pos, bandSize, xAxis, yAxis, xAxisTicks, yAxisTicks, stackedData, displayedData, offset }) {
|
|
25
|
+
const parentViewBox = {
|
|
26
|
+
x: offset.left,
|
|
27
|
+
y: offset.top,
|
|
28
|
+
width: offset.width,
|
|
29
|
+
height: offset.height
|
|
30
|
+
};
|
|
31
|
+
const numericAxis = layout === "horizontal" ? yAxis : xAxis;
|
|
32
|
+
const stackedDomain = stackedData ? numericAxis.scale.domain() : null;
|
|
33
|
+
const baseValue = getBaseValueOfBar({ numericAxis });
|
|
34
|
+
const stackedBarStart = numericAxis.scale(baseValue);
|
|
35
|
+
return displayedData.map((rawEntry, index) => {
|
|
36
|
+
const entry = toRaw(rawEntry);
|
|
37
|
+
let value, x, y, width, height, background;
|
|
38
|
+
if (stackedData) value = truncateByDomain(stackedData[index], stackedDomain);
|
|
39
|
+
else {
|
|
40
|
+
value = getValueByDataKey(entry, dataKey);
|
|
41
|
+
if (!Array.isArray(value)) value = [baseValue, value];
|
|
42
|
+
}
|
|
43
|
+
const minPointSize = minPointSizeCallback(minPointSizeProp, defaultMinPointSize)(value[1], index);
|
|
44
|
+
if (layout === "horizontal") {
|
|
45
|
+
const [baseValueScale, currentValueScale] = [yAxis.scale(value[0]), yAxis.scale(value[1])];
|
|
46
|
+
x = getCateCoordinateOfBar({
|
|
47
|
+
axis: xAxis,
|
|
48
|
+
ticks: xAxisTicks,
|
|
49
|
+
bandSize,
|
|
50
|
+
offset: pos.offset,
|
|
51
|
+
entry,
|
|
52
|
+
index
|
|
53
|
+
});
|
|
54
|
+
y = currentValueScale ?? baseValueScale ?? void 0;
|
|
55
|
+
width = pos.size;
|
|
56
|
+
const computedHeight = baseValueScale - currentValueScale;
|
|
57
|
+
height = isNaN(computedHeight) ? 0 : computedHeight;
|
|
58
|
+
background = {
|
|
59
|
+
x,
|
|
60
|
+
y: offset.top,
|
|
61
|
+
width,
|
|
62
|
+
height: offset.height
|
|
63
|
+
};
|
|
64
|
+
if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
|
|
65
|
+
const delta = mathSign(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
|
|
66
|
+
y -= delta;
|
|
67
|
+
height += delta;
|
|
46
68
|
}
|
|
47
69
|
} else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
const [baseValueScale, currentValueScale] = [xAxis.scale(value[0]), xAxis.scale(value[1])];
|
|
71
|
+
x = baseValueScale;
|
|
72
|
+
y = getCateCoordinateOfBar({
|
|
73
|
+
axis: yAxis,
|
|
74
|
+
ticks: yAxisTicks,
|
|
75
|
+
bandSize,
|
|
76
|
+
offset: pos.offset,
|
|
77
|
+
entry,
|
|
78
|
+
index
|
|
79
|
+
});
|
|
80
|
+
width = currentValueScale - baseValueScale;
|
|
81
|
+
height = pos.size;
|
|
82
|
+
background = {
|
|
83
|
+
x: offset.left,
|
|
84
|
+
y,
|
|
85
|
+
width: offset.width,
|
|
86
|
+
height
|
|
87
|
+
};
|
|
88
|
+
if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
|
|
89
|
+
const delta = mathSign(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
|
|
90
|
+
width += delta;
|
|
64
91
|
}
|
|
65
92
|
}
|
|
66
93
|
return {
|
|
67
|
-
x
|
|
68
|
-
y
|
|
69
|
-
width
|
|
70
|
-
height
|
|
71
|
-
stackedBarStart:
|
|
72
|
-
value:
|
|
73
|
-
payload:
|
|
74
|
-
background
|
|
94
|
+
x,
|
|
95
|
+
y,
|
|
96
|
+
width,
|
|
97
|
+
height,
|
|
98
|
+
stackedBarStart: stackedBarStart ?? 0,
|
|
99
|
+
value: stackedData ? value : value[1],
|
|
100
|
+
payload: entry,
|
|
101
|
+
background,
|
|
75
102
|
tooltipPosition: {
|
|
76
|
-
x:
|
|
77
|
-
y:
|
|
103
|
+
x: x + width / 2,
|
|
104
|
+
y: y + height / 2
|
|
78
105
|
},
|
|
79
|
-
parentViewBox
|
|
106
|
+
parentViewBox
|
|
80
107
|
};
|
|
81
108
|
});
|
|
82
109
|
}
|
|
83
110
|
//#endregion
|
|
84
|
-
export {
|
|
111
|
+
export { computeBarRectangles };
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { isNumber
|
|
2
|
-
import { filterProps
|
|
3
|
-
import { Layer
|
|
4
|
-
import
|
|
5
|
-
import { Label
|
|
6
|
-
import { getTicks
|
|
7
|
-
import { createVNode
|
|
8
|
-
import { get
|
|
1
|
+
import { isNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { filterProps } from "../../utils/VueUtils.mjs";
|
|
3
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
4
|
+
import Text_default from "../../components/Text.mjs";
|
|
5
|
+
import { Label } from "../../components/label/Label.mjs";
|
|
6
|
+
import { getTicks } from "../utils/get-ticks.mjs";
|
|
7
|
+
import { createVNode, defineComponent, mergeProps, reactive } from "vue";
|
|
8
|
+
import { get } from "es-toolkit/compat";
|
|
9
9
|
//#region src/cartesian/cartesian-axis/CartesianAxis.tsx
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @fileOverview Cartesian Axis
|
|
12
|
+
*/
|
|
13
|
+
/** The orientation of the axis in correspondence to the chart */
|
|
14
|
+
/** A unit to be appended to a value */
|
|
15
|
+
/** The formatter function of tick */
|
|
16
|
+
var CartesianAxis = /* @__PURE__ */ defineComponent({
|
|
11
17
|
name: "CartesianAxis",
|
|
12
18
|
props: {
|
|
13
19
|
x: {
|
|
@@ -42,19 +48,19 @@ var d = /* @__PURE__ */ s({
|
|
|
42
48
|
},
|
|
43
49
|
tick: {
|
|
44
50
|
type: Boolean,
|
|
45
|
-
default:
|
|
51
|
+
default: true
|
|
46
52
|
},
|
|
47
53
|
axisLine: {
|
|
48
54
|
type: [Boolean, Object],
|
|
49
|
-
default: () =>
|
|
55
|
+
default: () => true
|
|
50
56
|
},
|
|
51
57
|
tickLine: {
|
|
52
58
|
type: [Boolean, Object],
|
|
53
|
-
default: () =>
|
|
59
|
+
default: () => true
|
|
54
60
|
},
|
|
55
61
|
mirror: {
|
|
56
62
|
type: Boolean,
|
|
57
|
-
default:
|
|
63
|
+
default: false
|
|
58
64
|
},
|
|
59
65
|
tickMargin: {
|
|
60
66
|
type: Number,
|
|
@@ -86,161 +92,205 @@ var d = /* @__PURE__ */ s({
|
|
|
86
92
|
default: "#666"
|
|
87
93
|
}
|
|
88
94
|
},
|
|
89
|
-
inheritAttrs:
|
|
90
|
-
setup(
|
|
91
|
-
|
|
95
|
+
inheritAttrs: false,
|
|
96
|
+
setup(props, { attrs, slots }) {
|
|
97
|
+
const state = reactive({
|
|
92
98
|
fontSize: "",
|
|
93
99
|
letterSpacing: ""
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
});
|
|
101
|
+
const getTickLineCoord = (data) => {
|
|
102
|
+
const { x, y, width, height, orientation, tickSize, mirror, tickMargin } = props;
|
|
103
|
+
let x1, x2, y1, y2, tx, ty;
|
|
104
|
+
const sign = mirror ? -1 : 1;
|
|
105
|
+
const finalTickSize = data.tickSize || tickSize;
|
|
106
|
+
const tickCoord = isNumber(data.tickCoord) ? data.tickCoord : data.coordinate;
|
|
107
|
+
switch (orientation) {
|
|
97
108
|
case "top":
|
|
98
|
-
|
|
109
|
+
x1 = x2 = data.coordinate;
|
|
110
|
+
y2 = y + +!mirror * height;
|
|
111
|
+
y1 = y2 - sign * finalTickSize;
|
|
112
|
+
ty = y1 - sign * tickMargin;
|
|
113
|
+
tx = tickCoord;
|
|
99
114
|
break;
|
|
100
115
|
case "left":
|
|
101
|
-
|
|
116
|
+
y1 = y2 = data.coordinate;
|
|
117
|
+
x2 = x + +!mirror * width;
|
|
118
|
+
x1 = x2 - sign * finalTickSize;
|
|
119
|
+
tx = x1 - sign * tickMargin;
|
|
120
|
+
ty = tickCoord;
|
|
102
121
|
break;
|
|
103
122
|
case "right":
|
|
104
|
-
|
|
123
|
+
y1 = y2 = data.coordinate;
|
|
124
|
+
x2 = x + +mirror * width;
|
|
125
|
+
x1 = x2 + sign * finalTickSize;
|
|
126
|
+
tx = x1 + sign * tickMargin;
|
|
127
|
+
ty = tickCoord;
|
|
105
128
|
break;
|
|
106
129
|
default:
|
|
107
|
-
|
|
130
|
+
x1 = x2 = data.coordinate;
|
|
131
|
+
y2 = y + +mirror * height;
|
|
132
|
+
y1 = y2 + sign * finalTickSize;
|
|
133
|
+
ty = y1 + sign * tickMargin;
|
|
134
|
+
tx = tickCoord;
|
|
108
135
|
break;
|
|
109
136
|
}
|
|
110
137
|
return {
|
|
111
138
|
line: {
|
|
112
|
-
x1
|
|
113
|
-
y1
|
|
114
|
-
x2
|
|
115
|
-
y2
|
|
139
|
+
x1,
|
|
140
|
+
y1,
|
|
141
|
+
x2,
|
|
142
|
+
y2
|
|
116
143
|
},
|
|
117
144
|
tick: {
|
|
118
|
-
x:
|
|
119
|
-
y:
|
|
145
|
+
x: tx,
|
|
146
|
+
y: ty
|
|
120
147
|
}
|
|
121
148
|
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
149
|
+
};
|
|
150
|
+
const getTickTextAnchor = () => {
|
|
151
|
+
const { orientation, mirror } = props;
|
|
152
|
+
let textAnchor;
|
|
153
|
+
switch (orientation) {
|
|
125
154
|
case "left":
|
|
126
|
-
|
|
155
|
+
textAnchor = mirror ? "start" : "end";
|
|
127
156
|
break;
|
|
128
157
|
case "right":
|
|
129
|
-
|
|
158
|
+
textAnchor = mirror ? "end" : "start";
|
|
130
159
|
break;
|
|
131
160
|
default:
|
|
132
|
-
|
|
161
|
+
textAnchor = "middle";
|
|
133
162
|
break;
|
|
134
163
|
}
|
|
135
|
-
return
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
164
|
+
return textAnchor;
|
|
165
|
+
};
|
|
166
|
+
const getTickVerticalAnchor = () => {
|
|
167
|
+
const { orientation, mirror } = props;
|
|
168
|
+
switch (orientation) {
|
|
139
169
|
case "left":
|
|
140
170
|
case "right": return "middle";
|
|
141
|
-
case "top": return
|
|
142
|
-
default: return
|
|
171
|
+
case "top": return mirror ? "start" : "end";
|
|
172
|
+
default: return mirror ? "end" : "start";
|
|
143
173
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
174
|
+
};
|
|
175
|
+
const renderAxisLine = () => {
|
|
176
|
+
const { x, y, width, height, orientation, mirror, axisLine } = props;
|
|
177
|
+
let lineProps = {
|
|
178
|
+
...filterProps(props, false),
|
|
179
|
+
...filterProps(axisLine, false),
|
|
148
180
|
fill: "none",
|
|
149
181
|
x1: 0,
|
|
150
182
|
y1: 0,
|
|
151
183
|
x2: 0,
|
|
152
184
|
y2: 0
|
|
153
185
|
};
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
...
|
|
158
|
-
x1:
|
|
159
|
-
y1:
|
|
160
|
-
x2:
|
|
161
|
-
y2:
|
|
186
|
+
if (orientation === "top" || orientation === "bottom") {
|
|
187
|
+
const needHeight = +(orientation === "top" && !mirror || orientation === "bottom" && mirror);
|
|
188
|
+
lineProps = {
|
|
189
|
+
...lineProps,
|
|
190
|
+
x1: x,
|
|
191
|
+
y1: y + needHeight * height,
|
|
192
|
+
x2: x + width,
|
|
193
|
+
y2: y + needHeight * height
|
|
162
194
|
};
|
|
163
195
|
} else {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
...
|
|
167
|
-
x1:
|
|
168
|
-
y1:
|
|
169
|
-
x2:
|
|
170
|
-
y2:
|
|
196
|
+
const needWidth = +(orientation === "left" && !mirror || orientation === "right" && mirror);
|
|
197
|
+
lineProps = {
|
|
198
|
+
...lineProps,
|
|
199
|
+
x1: x + needWidth * width,
|
|
200
|
+
y1: y,
|
|
201
|
+
x2: x + needWidth * width,
|
|
202
|
+
y2: y + height
|
|
171
203
|
};
|
|
172
204
|
}
|
|
173
|
-
return
|
|
205
|
+
return createVNode("line", mergeProps(lineProps, { "class": ["v-charts-cartesian-axis-line", get(axisLine, "class")] }), null);
|
|
174
206
|
};
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
207
|
+
function renderTickItem(props, value) {
|
|
208
|
+
const className = ["v-charts-cartesian-axis-tick-value", props.class];
|
|
209
|
+
return createVNode(Text_default, mergeProps(props, {
|
|
210
|
+
"class": className,
|
|
211
|
+
"value": value
|
|
179
212
|
}), null);
|
|
180
213
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
214
|
+
const renderTicks = (props, fontSize, letterSpacing) => {
|
|
215
|
+
const { tickLine, stroke, tick, tickFormatter, unit } = props;
|
|
216
|
+
const finalTicks = getTicks(props, fontSize, letterSpacing);
|
|
217
|
+
const textAnchor = getTickTextAnchor();
|
|
218
|
+
const verticalAnchor = getTickVerticalAnchor();
|
|
219
|
+
const axisProps = filterProps(props, false);
|
|
220
|
+
const customTickProps = filterProps(tick, false);
|
|
221
|
+
const tickLineProps = {
|
|
222
|
+
...axisProps,
|
|
184
223
|
fill: "none",
|
|
185
|
-
...
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
224
|
+
...filterProps(tickLine, false)
|
|
225
|
+
};
|
|
226
|
+
const items = finalTicks.map((entry, i) => {
|
|
227
|
+
const { line: lineCoord, tick: tickCoord } = getTickLineCoord(entry);
|
|
228
|
+
const tickProps = {
|
|
229
|
+
textAnchor,
|
|
230
|
+
verticalAnchor,
|
|
231
|
+
...axisProps,
|
|
191
232
|
stroke: "none",
|
|
192
|
-
fill:
|
|
193
|
-
...
|
|
194
|
-
...
|
|
195
|
-
index:
|
|
196
|
-
payload:
|
|
197
|
-
visibleTicksCount:
|
|
198
|
-
tickFormatter
|
|
233
|
+
fill: stroke,
|
|
234
|
+
...customTickProps,
|
|
235
|
+
...tickCoord,
|
|
236
|
+
index: i,
|
|
237
|
+
payload: entry,
|
|
238
|
+
visibleTicksCount: finalTicks.length,
|
|
239
|
+
tickFormatter
|
|
199
240
|
};
|
|
200
|
-
return
|
|
201
|
-
class: "v-charts-cartesian-axis-tick",
|
|
202
|
-
key: `tick-${
|
|
203
|
-
}, { default: () => [
|
|
204
|
-
...
|
|
205
|
-
value:
|
|
206
|
-
}) :
|
|
241
|
+
return createVNode(Layer, {
|
|
242
|
+
"class": "v-charts-cartesian-axis-tick",
|
|
243
|
+
"key": `tick-${entry.value}-${entry.coordinate}-${entry.tickCoord}`
|
|
244
|
+
}, { default: () => [tickLine && createVNode("line", mergeProps(tickLineProps, lineCoord, { "class": ["v-charts-cartesian-axis-tick-line", get(tickLine, "class")] }), null), tick && (slots.tick ? slots.tick({
|
|
245
|
+
...tickProps,
|
|
246
|
+
value: entry.value
|
|
247
|
+
}) : renderTickItem(tickProps, `${typeof tickFormatter === "function" ? tickFormatter(entry.value, i) : entry.value}${unit || ""}`))] });
|
|
207
248
|
});
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
249
|
+
return items.length > 0 ? createVNode("g", { "class": "v-charts-cartesian-axis-ticks" }, [items]) : null;
|
|
250
|
+
};
|
|
251
|
+
const renderLabel = () => {
|
|
252
|
+
const { label, x, y, width, height } = props;
|
|
253
|
+
if (!label) return null;
|
|
254
|
+
const axisViewBox = {
|
|
255
|
+
x,
|
|
256
|
+
y,
|
|
257
|
+
width,
|
|
258
|
+
height
|
|
217
259
|
};
|
|
218
|
-
|
|
219
|
-
value:
|
|
220
|
-
viewBox:
|
|
221
|
-
}, null)
|
|
260
|
+
if (typeof label === "string" || typeof label === "number") return createVNode(Label, {
|
|
261
|
+
"value": label,
|
|
262
|
+
"viewBox": axisViewBox
|
|
263
|
+
}, null);
|
|
264
|
+
if (typeof label === "object") return createVNode(Label, mergeProps(label, { "viewBox": axisViewBox }), null);
|
|
265
|
+
return null;
|
|
222
266
|
};
|
|
223
267
|
return () => {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
268
|
+
const { axisLine, width, height, hide } = props;
|
|
269
|
+
if (hide) return null;
|
|
270
|
+
if (width != null && width <= 0 || height != null && height <= 0) return null;
|
|
271
|
+
return createVNode(Layer, {
|
|
272
|
+
"class": ["v-charts-cartesian-axis", attrs.class],
|
|
273
|
+
"ref": (ref) => {
|
|
274
|
+
const elm = ref?.$el;
|
|
275
|
+
if (elm) {
|
|
276
|
+
const tick = elm?.getElementsByClassName("v-charts-cartesian-axis-tick-value")[0];
|
|
277
|
+
if (tick) {
|
|
278
|
+
const calculatedFontSize = window.getComputedStyle(tick).fontSize;
|
|
279
|
+
const calculatedLetterSpacing = window.getComputedStyle(tick).letterSpacing;
|
|
280
|
+
if (calculatedFontSize !== state.fontSize || calculatedLetterSpacing !== state.letterSpacing) {
|
|
281
|
+
state.fontSize = window.getComputedStyle(tick).fontSize;
|
|
282
|
+
state.letterSpacing = window.getComputedStyle(tick).letterSpacing;
|
|
283
|
+
}
|
|
234
284
|
}
|
|
235
285
|
}
|
|
236
286
|
}
|
|
237
287
|
}, { default: () => [
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
288
|
+
axisLine && renderAxisLine(),
|
|
289
|
+
renderTicks(props, state.fontSize, state.letterSpacing),
|
|
290
|
+
renderLabel()
|
|
241
291
|
] });
|
|
242
292
|
};
|
|
243
293
|
}
|
|
244
294
|
});
|
|
245
295
|
//#endregion
|
|
246
|
-
export {
|
|
296
|
+
export { CartesianAxis };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createVNode
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
2
|
//#region src/cartesian/cartesian-grid/Background.tsx
|
|
3
|
-
var
|
|
3
|
+
var Background = /* @__PURE__ */ defineComponent({
|
|
4
4
|
name: "Background",
|
|
5
|
-
inheritAttrs:
|
|
5
|
+
inheritAttrs: false,
|
|
6
6
|
props: {
|
|
7
7
|
fill: String,
|
|
8
8
|
fillOpacity: Number,
|
|
@@ -12,19 +12,22 @@ var n = /* @__PURE__ */ t({
|
|
|
12
12
|
height: Number,
|
|
13
13
|
ry: Number
|
|
14
14
|
},
|
|
15
|
-
setup(
|
|
16
|
-
return () =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
setup(props) {
|
|
16
|
+
return () => {
|
|
17
|
+
if (!props.fill || props.fill === "none") return null;
|
|
18
|
+
return createVNode("rect", {
|
|
19
|
+
"x": props.x,
|
|
20
|
+
"y": props.y,
|
|
21
|
+
"ry": props.ry,
|
|
22
|
+
"width": props.width,
|
|
23
|
+
"height": props.height,
|
|
24
|
+
"stroke": "none",
|
|
25
|
+
"fill": props.fill,
|
|
26
|
+
"fill-opacity": props.fillOpacity,
|
|
27
|
+
"class": "v-charts-cartesian-grid-bg"
|
|
28
|
+
}, null);
|
|
29
|
+
};
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
32
|
//#endregion
|
|
30
|
-
export {
|
|
33
|
+
export { Background as default };
|