@mui/x-charts 9.0.0-alpha.4 → 9.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/BarChart/BarChart.js +19 -28
- package/BarChart/BarChart.mjs +19 -28
- package/BarChart/BarElement.js +3 -5
- package/BarChart/BarElement.mjs +3 -5
- package/BarChart/BarLabel/BarLabelPlot.d.mts +0 -2
- package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -2
- package/BarChart/BarLabel/BarLabelPlot.js +2 -3
- package/BarChart/BarLabel/BarLabelPlot.mjs +2 -3
- package/BarChart/BarPlot.d.mts +2 -12
- package/BarChart/BarPlot.d.ts +2 -12
- package/BarChart/BarPlot.js +4 -18
- package/BarChart/BarPlot.mjs +4 -18
- package/BarChart/BatchBarPlot/BatchBarPlot.js +0 -27
- package/BarChart/BatchBarPlot/BatchBarPlot.mjs +0 -27
- package/BarChart/IndividualBarPlot.d.mts +1 -2
- package/BarChart/IndividualBarPlot.d.ts +1 -2
- package/BarChart/IndividualBarPlot.js +5 -10
- package/BarChart/IndividualBarPlot.mjs +5 -10
- package/BarChart/seriesConfig/bar/descriptionGetter.d.mts +3 -0
- package/BarChart/seriesConfig/bar/descriptionGetter.d.ts +3 -0
- package/BarChart/seriesConfig/bar/descriptionGetter.js +36 -0
- package/BarChart/seriesConfig/bar/descriptionGetter.mjs +30 -0
- package/BarChart/seriesConfig/index.js +5 -1
- package/BarChart/seriesConfig/index.mjs +5 -1
- package/BarChart/useBarChartProps.js +2 -4
- package/BarChart/useBarChartProps.mjs +2 -4
- package/CHANGELOG.md +107 -1
- package/ChartsContainer/ChartsContainer.js +29 -29
- package/ChartsContainer/ChartsContainer.mjs +29 -29
- package/ChartsLayerContainer/ChartsLayerContainer.js +6 -2
- package/ChartsLayerContainer/ChartsLayerContainer.mjs +7 -2
- package/ChartsSvgLayer/ChartsSvgLayer.js +2 -2
- package/ChartsSvgLayer/ChartsSvgLayer.mjs +2 -2
- package/ChartsXAxis/ChartsGroupedXAxisTicks.js +12 -3
- package/ChartsXAxis/ChartsGroupedXAxisTicks.mjs +12 -3
- package/ChartsXAxis/useAxisTicksProps.d.mts +89 -89
- package/ChartsXAxis/useAxisTicksProps.d.ts +89 -89
- package/ChartsYAxis/ChartsGroupedYAxisTicks.js +12 -3
- package/ChartsYAxis/ChartsGroupedYAxisTicks.mjs +12 -3
- package/ChartsYAxis/useAxisTicksProps.d.mts +89 -89
- package/ChartsYAxis/useAxisTicksProps.d.ts +89 -89
- package/Gauge/Gauge.js +0 -4
- package/Gauge/Gauge.mjs +0 -4
- package/Gauge/GaugeContainer.d.mts +1 -1
- package/Gauge/GaugeContainer.d.ts +1 -1
- package/Gauge/GaugeContainer.js +0 -4
- package/Gauge/GaugeContainer.mjs +0 -4
- package/LineChart/AreaElement.js +5 -1
- package/LineChart/AreaElement.mjs +5 -1
- package/LineChart/CircleMarkElement.js +8 -5
- package/LineChart/CircleMarkElement.mjs +8 -5
- package/LineChart/LineChart.js +21 -19
- package/LineChart/LineChart.mjs +21 -19
- package/LineChart/LineElement.js +5 -1
- package/LineChart/LineElement.mjs +5 -1
- package/LineChart/MarkElement.js +7 -4
- package/LineChart/MarkElement.mjs +7 -4
- package/LineChart/seriesConfig/curveEvaluation.d.mts +11 -0
- package/LineChart/seriesConfig/curveEvaluation.d.ts +11 -0
- package/LineChart/seriesConfig/curveEvaluation.js +134 -0
- package/LineChart/seriesConfig/curveEvaluation.mjs +129 -0
- package/LineChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/LineChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/LineChart/seriesConfig/descriptionGetter.js +37 -0
- package/LineChart/seriesConfig/descriptionGetter.mjs +31 -0
- package/LineChart/seriesConfig/getItemAtPosition.d.mts +7 -0
- package/LineChart/seriesConfig/getItemAtPosition.d.ts +7 -0
- package/LineChart/seriesConfig/getItemAtPosition.js +356 -0
- package/LineChart/seriesConfig/getItemAtPosition.mjs +351 -0
- package/LineChart/seriesConfig/index.js +4 -0
- package/LineChart/seriesConfig/index.mjs +4 -0
- package/PieChart/PieArc.js +2 -3
- package/PieChart/PieArc.mjs +2 -3
- package/PieChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/PieChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/PieChart/seriesConfig/descriptionGetter.js +26 -0
- package/PieChart/seriesConfig/descriptionGetter.mjs +20 -0
- package/PieChart/seriesConfig/index.js +2 -0
- package/PieChart/seriesConfig/index.mjs +2 -0
- package/RadarChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/RadarChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/RadarChart/seriesConfig/descriptionGetter.js +37 -0
- package/RadarChart/seriesConfig/descriptionGetter.mjs +31 -0
- package/RadarChart/seriesConfig/index.js +2 -0
- package/RadarChart/seriesConfig/index.mjs +2 -0
- package/ScatterChart/ScatterChart.js +18 -18
- package/ScatterChart/ScatterChart.mjs +18 -18
- package/ScatterChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/ScatterChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/ScatterChart/seriesConfig/descriptionGetter.js +34 -0
- package/ScatterChart/seriesConfig/descriptionGetter.mjs +28 -0
- package/ScatterChart/seriesConfig/index.js +2 -0
- package/ScatterChart/seriesConfig/index.mjs +2 -0
- package/SparkLineChart/SparkLineChart.js +21 -19
- package/SparkLineChart/SparkLineChart.mjs +21 -19
- package/constants/index.js +0 -2
- package/constants/index.mjs +0 -2
- package/hooks/useInteractionItemProps.d.mts +1 -1
- package/hooks/useInteractionItemProps.d.ts +1 -1
- package/hooks/useInteractionItemProps.js +3 -3
- package/hooks/useInteractionItemProps.mjs +3 -3
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.d.mts +5 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.d.ts +5 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +100 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +96 -0
- package/internals/components/ChartsAccessibilityProxy/index.d.mts +1 -0
- package/internals/components/ChartsAccessibilityProxy/index.d.ts +1 -0
- package/internals/components/ChartsAccessibilityProxy/index.js +16 -0
- package/internals/components/ChartsAccessibilityProxy/index.mjs +1 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.d.mts +5 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.d.ts +5 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.js +71 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.mjs +66 -0
- package/internals/getChartPoint.js +18 -1
- package/internals/getChartPoint.mjs +18 -1
- package/internals/plugins/corePlugins/corePlugins.d.mts +2 -2
- package/internals/plugins/corePlugins/corePlugins.d.ts +2 -2
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.mts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.mts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.mts +22 -7
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +22 -7
- package/internals/plugins/corePlugins/useChartSeries/index.d.mts +2 -1
- package/internals/plugins/corePlugins/useChartSeries/index.d.ts +2 -1
- package/internals/plugins/corePlugins/useChartSeries/index.js +12 -0
- package/internals/plugins/corePlugins/useChartSeries/index.mjs +2 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +1 -8
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -8
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +1 -11
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.mjs +1 -11
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.d.mts +8 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.d.ts +8 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.js +19 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.mjs +14 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.d.mts +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.d.ts +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.js +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.mts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.js +11 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.mts +2 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.ts +2 -0
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.mts +4 -10
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +4 -10
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +28 -19
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.mjs +28 -18
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.d.mts +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.js +11 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.mjs +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.mts +33 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.ts +33 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.js +318 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.mjs +311 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.mts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +63 -8
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.mjs +62 -8
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +12 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +12 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.mts +12 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +12 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +28 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.mjs +27 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.mts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +22 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.d.mts +30 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.d.ts +30 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.js +96 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.mjs +91 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.d.mts +16 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.d.ts +16 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.js +36 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.mjs +31 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.d.mts +15 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.d.ts +15 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.js +45 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.mjs +39 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.mts +11 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +11 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +53 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.mjs +52 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +4 -9
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +4 -9
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +16 -40
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.mjs +19 -43
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianTooltip.selectors.js +20 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianTooltip.selectors.mjs +20 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +36 -30
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +36 -30
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +8 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +8 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +9 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +6 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -0
- package/internals/store/useCharts.d.mts +1 -1
- package/internals/store/useCharts.d.ts +1 -1
- package/locales/elGR.d.mts +76 -0
- package/locales/elGR.d.ts +76 -0
- package/locales/elGR.js +89 -0
- package/locales/elGR.mjs +89 -0
- package/locales/enUS.d.mts +76 -0
- package/locales/enUS.d.ts +76 -0
- package/locales/enUS.js +89 -1
- package/locales/enUS.mjs +89 -1
- package/locales/frFR.d.mts +76 -0
- package/locales/frFR.d.ts +76 -0
- package/locales/frFR.js +89 -0
- package/locales/frFR.mjs +89 -0
- package/locales/nbNO.d.mts +76 -0
- package/locales/nbNO.d.ts +76 -0
- package/locales/nbNO.js +89 -0
- package/locales/nbNO.mjs +89 -0
- package/locales/ptBR.d.mts +76 -0
- package/locales/ptBR.d.ts +76 -0
- package/locales/ptBR.js +89 -0
- package/locales/ptBR.mjs +89 -0
- package/locales/ptPT.d.mts +76 -0
- package/locales/ptPT.d.ts +76 -0
- package/locales/ptPT.js +89 -0
- package/locales/ptPT.mjs +89 -0
- package/locales/svSE.d.mts +76 -0
- package/locales/svSE.d.ts +76 -0
- package/locales/svSE.js +89 -0
- package/locales/svSE.mjs +89 -0
- package/locales/utils/chartsLocaleTextApi.d.mts +189 -0
- package/locales/utils/chartsLocaleTextApi.d.ts +189 -0
- package/locales/utils/getChartsLocalization.d.mts +76 -0
- package/locales/utils/getChartsLocalization.d.ts +76 -0
- package/models/axis.d.mts +11 -5
- package/models/axis.d.ts +11 -5
- package/models/seriesType/config.d.mts +29 -0
- package/models/seriesType/config.d.ts +29 -0
- package/package.json +85 -85
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.computeAxisValue = computeAxisValue;
|
|
8
|
+
exports.resolveAxisSize = resolveAxisSize;
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _defaultValueFormatters = require("../../../defaultValueFormatters");
|
|
10
11
|
var _axis = require("../../../../models/axis");
|
|
@@ -14,6 +15,7 @@ var _getScale = require("../../../getScale");
|
|
|
14
15
|
var _dateHelpers = require("../../../dateHelpers");
|
|
15
16
|
var _getAxisTriggerTooltip = require("./getAxisTriggerTooltip");
|
|
16
17
|
var _scaleGuards = require("../../../scaleGuards");
|
|
18
|
+
var _constants = require("../../../../constants");
|
|
17
19
|
function getRange(drawingArea, axisDirection,
|
|
18
20
|
// | 'rotation' | 'radius',
|
|
19
21
|
reverse) {
|
|
@@ -30,8 +32,45 @@ function shouldIgnoreGapRatios(scale, categoryGapRatio) {
|
|
|
30
32
|
*/
|
|
31
33
|
return paddingPx < 0.1;
|
|
32
34
|
}
|
|
35
|
+
function resolveAxisSize(axis, autoSizes, direction) {
|
|
36
|
+
const size = direction === 'x' ? axis.height : axis.width;
|
|
37
|
+
if (size === 'auto') {
|
|
38
|
+
const autoSize = autoSizes?.[axis.id];
|
|
39
|
+
if (autoSize !== undefined) {
|
|
40
|
+
return autoSize;
|
|
41
|
+
}
|
|
42
|
+
const defaultSize = direction === 'x' ? _constants.DEFAULT_AXIS_SIZE_HEIGHT : _constants.DEFAULT_AXIS_SIZE_WIDTH;
|
|
43
|
+
return defaultSize + (axis.label ? _constants.AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
44
|
+
}
|
|
45
|
+
return size ?? 0;
|
|
46
|
+
}
|
|
33
47
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
34
48
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
49
|
+
/**
|
|
50
|
+
* Recalculates axis offsets using actual resolved sizes (including auto-sizes).
|
|
51
|
+
* This is needed because offsets from defaultizeAxis use placeholder values for auto-sized axes.
|
|
52
|
+
*/
|
|
53
|
+
function recalculateOffsets(allAxis, autoSizes, axisDirection, axesGap) {
|
|
54
|
+
const offsets = {};
|
|
55
|
+
const result = {};
|
|
56
|
+
for (const axis of allAxis) {
|
|
57
|
+
const position = axis.position;
|
|
58
|
+
if (!position) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
offsets[position] ?? (offsets[position] = 0);
|
|
62
|
+
result[axis.id] = offsets[position];
|
|
63
|
+
if (position !== 'none') {
|
|
64
|
+
const size = resolveAxisSize(axis, autoSizes, axisDirection);
|
|
65
|
+
offsets[position] += size + axesGap;
|
|
66
|
+
const zoom = axis.zoom;
|
|
67
|
+
if (zoom?.slider.enabled) {
|
|
68
|
+
offsets[position] += zoom.slider.size;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
35
74
|
function computeAxisValue({
|
|
36
75
|
scales,
|
|
37
76
|
drawingArea,
|
|
@@ -40,7 +79,9 @@ function computeAxisValue({
|
|
|
40
79
|
seriesConfig,
|
|
41
80
|
axisDirection,
|
|
42
81
|
zoomMap,
|
|
43
|
-
domains
|
|
82
|
+
domains,
|
|
83
|
+
autoSizes,
|
|
84
|
+
axesGap = 0
|
|
44
85
|
}) {
|
|
45
86
|
if (allAxis === undefined) {
|
|
46
87
|
return {
|
|
@@ -49,6 +90,7 @@ function computeAxisValue({
|
|
|
49
90
|
};
|
|
50
91
|
}
|
|
51
92
|
const axisIdsTriggeringTooltip = (0, _getAxisTriggerTooltip.getAxisTriggerTooltip)(axisDirection, seriesConfig, formattedSeries, allAxis[0].id);
|
|
93
|
+
const resolvedOffsets = recalculateOffsets(allAxis, autoSizes, axisDirection, axesGap);
|
|
52
94
|
const completeAxis = {};
|
|
53
95
|
allAxis.forEach(eachAxis => {
|
|
54
96
|
const axis = eachAxis;
|
|
@@ -59,9 +101,10 @@ function computeAxisValue({
|
|
|
59
101
|
const rawTickNumber = domains[axis.id].tickNumber;
|
|
60
102
|
const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
|
|
61
103
|
const tickNumber = (0, _ticks.scaleTickNumberByRange)(rawTickNumber, zoomRange);
|
|
104
|
+
const resolvedSize = resolveAxisSize(axis, autoSizes, axisDirection);
|
|
62
105
|
const data = axis.data ?? [];
|
|
106
|
+
const resolvedOffset = resolvedOffsets[axis.id] ?? axis.offset ?? 0;
|
|
63
107
|
if ((0, _scaleGuards.isOrdinalScale)(scale)) {
|
|
64
|
-
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
65
108
|
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
66
109
|
if ((0, _scaleGuards.isBandScale)(scale) && (0, _axis.isBandScaleConfig)(axis)) {
|
|
67
110
|
const desiredCategoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
@@ -69,12 +112,16 @@ function computeAxisValue({
|
|
|
69
112
|
const categoryGapRatio = ignoreGapRatios ? 0 : desiredCategoryGapRatio;
|
|
70
113
|
const barGapRatio = ignoreGapRatios ? 0 : axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
71
114
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
72
|
-
offset: 0,
|
|
73
|
-
height: 0,
|
|
74
115
|
categoryGapRatio,
|
|
75
116
|
barGapRatio,
|
|
76
117
|
triggerTooltip
|
|
77
118
|
}, axis, {
|
|
119
|
+
offset: resolvedOffset
|
|
120
|
+
}, axisDirection === 'x' ? {
|
|
121
|
+
height: resolvedSize
|
|
122
|
+
} : {
|
|
123
|
+
width: resolvedSize
|
|
124
|
+
}, {
|
|
78
125
|
data,
|
|
79
126
|
/* Doing this here is technically wrong, but acceptable in practice.
|
|
80
127
|
* In theory, this should be done in the normalized scale selector, but then we'd need that selector to depend
|
|
@@ -90,10 +137,14 @@ function computeAxisValue({
|
|
|
90
137
|
}
|
|
91
138
|
if ((0, _axis.isPointScaleConfig)(axis)) {
|
|
92
139
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
93
|
-
offset: 0,
|
|
94
|
-
height: 0,
|
|
95
140
|
triggerTooltip
|
|
96
141
|
}, axis, {
|
|
142
|
+
offset: resolvedOffset
|
|
143
|
+
}, axisDirection === 'x' ? {
|
|
144
|
+
height: resolvedSize
|
|
145
|
+
} : {
|
|
146
|
+
width: resolvedSize
|
|
147
|
+
}, {
|
|
97
148
|
data,
|
|
98
149
|
scale,
|
|
99
150
|
tickNumber,
|
|
@@ -115,10 +166,14 @@ function computeAxisValue({
|
|
|
115
166
|
const continuousAxis = axis;
|
|
116
167
|
const scaleType = continuousAxis.scaleType ?? 'linear';
|
|
117
168
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
118
|
-
offset: 0,
|
|
119
|
-
height: 0,
|
|
120
169
|
triggerTooltip
|
|
121
170
|
}, continuousAxis, {
|
|
171
|
+
offset: resolvedOffset
|
|
172
|
+
}, axisDirection === 'x' ? {
|
|
173
|
+
height: resolvedSize
|
|
174
|
+
} : {
|
|
175
|
+
width: resolvedSize
|
|
176
|
+
}, {
|
|
122
177
|
data,
|
|
123
178
|
scaleType,
|
|
124
179
|
scale,
|
|
@@ -7,6 +7,7 @@ import { getScale } from "../../../getScale.mjs";
|
|
|
7
7
|
import { isDateData, createDateFormatter } from "../../../dateHelpers.mjs";
|
|
8
8
|
import { getAxisTriggerTooltip } from "./getAxisTriggerTooltip.mjs";
|
|
9
9
|
import { isBandScale, isOrdinalScale } from "../../../scaleGuards.mjs";
|
|
10
|
+
import { DEFAULT_AXIS_SIZE_HEIGHT, DEFAULT_AXIS_SIZE_WIDTH, AXIS_LABEL_DEFAULT_HEIGHT } from "../../../../constants/index.mjs";
|
|
10
11
|
function getRange(drawingArea, axisDirection,
|
|
11
12
|
// | 'rotation' | 'radius',
|
|
12
13
|
reverse) {
|
|
@@ -23,8 +24,45 @@ function shouldIgnoreGapRatios(scale, categoryGapRatio) {
|
|
|
23
24
|
*/
|
|
24
25
|
return paddingPx < 0.1;
|
|
25
26
|
}
|
|
27
|
+
export function resolveAxisSize(axis, autoSizes, direction) {
|
|
28
|
+
const size = direction === 'x' ? axis.height : axis.width;
|
|
29
|
+
if (size === 'auto') {
|
|
30
|
+
const autoSize = autoSizes?.[axis.id];
|
|
31
|
+
if (autoSize !== undefined) {
|
|
32
|
+
return autoSize;
|
|
33
|
+
}
|
|
34
|
+
const defaultSize = direction === 'x' ? DEFAULT_AXIS_SIZE_HEIGHT : DEFAULT_AXIS_SIZE_WIDTH;
|
|
35
|
+
return defaultSize + (axis.label ? AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
36
|
+
}
|
|
37
|
+
return size ?? 0;
|
|
38
|
+
}
|
|
26
39
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
27
40
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
41
|
+
/**
|
|
42
|
+
* Recalculates axis offsets using actual resolved sizes (including auto-sizes).
|
|
43
|
+
* This is needed because offsets from defaultizeAxis use placeholder values for auto-sized axes.
|
|
44
|
+
*/
|
|
45
|
+
function recalculateOffsets(allAxis, autoSizes, axisDirection, axesGap) {
|
|
46
|
+
const offsets = {};
|
|
47
|
+
const result = {};
|
|
48
|
+
for (const axis of allAxis) {
|
|
49
|
+
const position = axis.position;
|
|
50
|
+
if (!position) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
offsets[position] ??= 0;
|
|
54
|
+
result[axis.id] = offsets[position];
|
|
55
|
+
if (position !== 'none') {
|
|
56
|
+
const size = resolveAxisSize(axis, autoSizes, axisDirection);
|
|
57
|
+
offsets[position] += size + axesGap;
|
|
58
|
+
const zoom = axis.zoom;
|
|
59
|
+
if (zoom?.slider.enabled) {
|
|
60
|
+
offsets[position] += zoom.slider.size;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
28
66
|
export function computeAxisValue({
|
|
29
67
|
scales,
|
|
30
68
|
drawingArea,
|
|
@@ -33,7 +71,9 @@ export function computeAxisValue({
|
|
|
33
71
|
seriesConfig,
|
|
34
72
|
axisDirection,
|
|
35
73
|
zoomMap,
|
|
36
|
-
domains
|
|
74
|
+
domains,
|
|
75
|
+
autoSizes,
|
|
76
|
+
axesGap = 0
|
|
37
77
|
}) {
|
|
38
78
|
if (allAxis === undefined) {
|
|
39
79
|
return {
|
|
@@ -42,6 +82,7 @@ export function computeAxisValue({
|
|
|
42
82
|
};
|
|
43
83
|
}
|
|
44
84
|
const axisIdsTriggeringTooltip = getAxisTriggerTooltip(axisDirection, seriesConfig, formattedSeries, allAxis[0].id);
|
|
85
|
+
const resolvedOffsets = recalculateOffsets(allAxis, autoSizes, axisDirection, axesGap);
|
|
45
86
|
const completeAxis = {};
|
|
46
87
|
allAxis.forEach(eachAxis => {
|
|
47
88
|
const axis = eachAxis;
|
|
@@ -52,9 +93,10 @@ export function computeAxisValue({
|
|
|
52
93
|
const rawTickNumber = domains[axis.id].tickNumber;
|
|
53
94
|
const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
|
|
54
95
|
const tickNumber = scaleTickNumberByRange(rawTickNumber, zoomRange);
|
|
96
|
+
const resolvedSize = resolveAxisSize(axis, autoSizes, axisDirection);
|
|
55
97
|
const data = axis.data ?? [];
|
|
98
|
+
const resolvedOffset = resolvedOffsets[axis.id] ?? axis.offset ?? 0;
|
|
56
99
|
if (isOrdinalScale(scale)) {
|
|
57
|
-
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
58
100
|
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
59
101
|
if (isBandScale(scale) && isBandScaleConfig(axis)) {
|
|
60
102
|
const desiredCategoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
@@ -62,12 +104,16 @@ export function computeAxisValue({
|
|
|
62
104
|
const categoryGapRatio = ignoreGapRatios ? 0 : desiredCategoryGapRatio;
|
|
63
105
|
const barGapRatio = ignoreGapRatios ? 0 : axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
64
106
|
completeAxis[axis.id] = _extends({
|
|
65
|
-
offset: 0,
|
|
66
|
-
height: 0,
|
|
67
107
|
categoryGapRatio,
|
|
68
108
|
barGapRatio,
|
|
69
109
|
triggerTooltip
|
|
70
110
|
}, axis, {
|
|
111
|
+
offset: resolvedOffset
|
|
112
|
+
}, axisDirection === 'x' ? {
|
|
113
|
+
height: resolvedSize
|
|
114
|
+
} : {
|
|
115
|
+
width: resolvedSize
|
|
116
|
+
}, {
|
|
71
117
|
data,
|
|
72
118
|
/* Doing this here is technically wrong, but acceptable in practice.
|
|
73
119
|
* In theory, this should be done in the normalized scale selector, but then we'd need that selector to depend
|
|
@@ -83,10 +129,14 @@ export function computeAxisValue({
|
|
|
83
129
|
}
|
|
84
130
|
if (isPointScaleConfig(axis)) {
|
|
85
131
|
completeAxis[axis.id] = _extends({
|
|
86
|
-
offset: 0,
|
|
87
|
-
height: 0,
|
|
88
132
|
triggerTooltip
|
|
89
133
|
}, axis, {
|
|
134
|
+
offset: resolvedOffset
|
|
135
|
+
}, axisDirection === 'x' ? {
|
|
136
|
+
height: resolvedSize
|
|
137
|
+
} : {
|
|
138
|
+
width: resolvedSize
|
|
139
|
+
}, {
|
|
90
140
|
data,
|
|
91
141
|
scale,
|
|
92
142
|
tickNumber,
|
|
@@ -108,10 +158,14 @@ export function computeAxisValue({
|
|
|
108
158
|
const continuousAxis = axis;
|
|
109
159
|
const scaleType = continuousAxis.scaleType ?? 'linear';
|
|
110
160
|
completeAxis[axis.id] = _extends({
|
|
111
|
-
offset: 0,
|
|
112
|
-
height: 0,
|
|
113
161
|
triggerTooltip
|
|
114
162
|
}, continuousAxis, {
|
|
163
|
+
offset: resolvedOffset
|
|
164
|
+
}, axisDirection === 'x' ? {
|
|
165
|
+
height: resolvedSize
|
|
166
|
+
} : {
|
|
167
|
+
width: resolvedSize
|
|
168
|
+
}, {
|
|
115
169
|
data,
|
|
116
170
|
scaleType,
|
|
117
171
|
scale,
|
|
@@ -28,18 +28,22 @@ function defaultizeXAxis(inAxes, dataset, axesGap) {
|
|
|
28
28
|
const position = axisConfig.position ?? defaultPosition;
|
|
29
29
|
const defaultHeight = _constants.DEFAULT_AXIS_SIZE_HEIGHT + (axisConfig.label ? _constants.AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
30
30
|
const id = axisConfig.id ?? `defaultized-x-axis-${index}`;
|
|
31
|
+
const height = axisConfig.height ?? defaultHeight;
|
|
31
32
|
const sharedConfig = (0, _extends2.default)({
|
|
32
33
|
offset: offsets[position]
|
|
33
34
|
}, axisConfig, {
|
|
34
35
|
id,
|
|
35
36
|
position,
|
|
36
|
-
height
|
|
37
|
+
height,
|
|
37
38
|
zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x', axisConfig.reverse)
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
// Increment the offset for the next axis
|
|
42
|
+
// For 'auto' height, use default height for initial offset calculation
|
|
43
|
+
// The actual auto-size will be computed by selectors
|
|
41
44
|
if (position !== 'none') {
|
|
42
|
-
|
|
45
|
+
const heightForOffset = height === 'auto' ? defaultHeight : height;
|
|
46
|
+
offsets[position] += heightForOffset + axesGap;
|
|
43
47
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
44
48
|
offsets[position] += sharedConfig.zoom.slider.size;
|
|
45
49
|
}
|
|
@@ -78,18 +82,22 @@ function defaultizeYAxis(inAxes, dataset, axesGap) {
|
|
|
78
82
|
const position = axisConfig.position ?? defaultPosition;
|
|
79
83
|
const defaultWidth = _constants.DEFAULT_AXIS_SIZE_WIDTH + (axisConfig.label ? _constants.AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
80
84
|
const id = axisConfig.id ?? `defaultized-y-axis-${index}`;
|
|
85
|
+
const width = axisConfig.width ?? defaultWidth;
|
|
81
86
|
const sharedConfig = (0, _extends2.default)({
|
|
82
87
|
offset: offsets[position]
|
|
83
88
|
}, axisConfig, {
|
|
84
89
|
id,
|
|
85
90
|
position,
|
|
86
|
-
width
|
|
91
|
+
width,
|
|
87
92
|
zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y', axisConfig.reverse)
|
|
88
93
|
});
|
|
89
94
|
|
|
90
95
|
// Increment the offset for the next axis
|
|
96
|
+
// For 'auto' width, use default width for initial offset calculation
|
|
97
|
+
// The actual auto-size will be computed by selectors
|
|
91
98
|
if (position !== 'none') {
|
|
92
|
-
|
|
99
|
+
const widthForOffset = width === 'auto' ? defaultWidth : width;
|
|
100
|
+
offsets[position] += widthForOffset + axesGap;
|
|
93
101
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
94
102
|
offsets[position] += sharedConfig.zoom.slider.size;
|
|
95
103
|
}
|
|
@@ -20,18 +20,22 @@ export function defaultizeXAxis(inAxes, dataset, axesGap) {
|
|
|
20
20
|
const position = axisConfig.position ?? defaultPosition;
|
|
21
21
|
const defaultHeight = DEFAULT_AXIS_SIZE_HEIGHT + (axisConfig.label ? AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
22
22
|
const id = axisConfig.id ?? `defaultized-x-axis-${index}`;
|
|
23
|
+
const height = axisConfig.height ?? defaultHeight;
|
|
23
24
|
const sharedConfig = _extends({
|
|
24
25
|
offset: offsets[position]
|
|
25
26
|
}, axisConfig, {
|
|
26
27
|
id,
|
|
27
28
|
position,
|
|
28
|
-
height
|
|
29
|
+
height,
|
|
29
30
|
zoom: defaultizeZoom(axisConfig.zoom, id, 'x', axisConfig.reverse)
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
// Increment the offset for the next axis
|
|
34
|
+
// For 'auto' height, use default height for initial offset calculation
|
|
35
|
+
// The actual auto-size will be computed by selectors
|
|
33
36
|
if (position !== 'none') {
|
|
34
|
-
|
|
37
|
+
const heightForOffset = height === 'auto' ? defaultHeight : height;
|
|
38
|
+
offsets[position] += heightForOffset + axesGap;
|
|
35
39
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
36
40
|
offsets[position] += sharedConfig.zoom.slider.size;
|
|
37
41
|
}
|
|
@@ -70,18 +74,22 @@ export function defaultizeYAxis(inAxes, dataset, axesGap) {
|
|
|
70
74
|
const position = axisConfig.position ?? defaultPosition;
|
|
71
75
|
const defaultWidth = DEFAULT_AXIS_SIZE_WIDTH + (axisConfig.label ? AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
72
76
|
const id = axisConfig.id ?? `defaultized-y-axis-${index}`;
|
|
77
|
+
const width = axisConfig.width ?? defaultWidth;
|
|
73
78
|
const sharedConfig = _extends({
|
|
74
79
|
offset: offsets[position]
|
|
75
80
|
}, axisConfig, {
|
|
76
81
|
id,
|
|
77
82
|
position,
|
|
78
|
-
width
|
|
83
|
+
width,
|
|
79
84
|
zoom: defaultizeZoom(axisConfig.zoom, id, 'y', axisConfig.reverse)
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
// Increment the offset for the next axis
|
|
88
|
+
// For 'auto' width, use default width for initial offset calculation
|
|
89
|
+
// The actual auto-size will be computed by selectors
|
|
83
90
|
if (position !== 'none') {
|
|
84
|
-
|
|
91
|
+
const widthForOffset = width === 'auto' ? defaultWidth : width;
|
|
92
|
+
offsets[position] += widthForOffset + axesGap;
|
|
85
93
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
86
94
|
offsets[position] += sharedConfig.zoom.slider.size;
|
|
87
95
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
-
import { type ContinuousScaleName, type DefaultedAxis } from "../../../../models/axis.mjs";
|
|
2
|
+
import { type AxisId, type ContinuousScaleName, type DefaultedAxis, type DefaultedXAxis, type DefaultedYAxis } from "../../../../models/axis.mjs";
|
|
3
3
|
import { type ProcessedSeries } from "../../corePlugins/useChartSeries/index.mjs";
|
|
4
4
|
import { type TickParams } from "../../../../hooks/useTicks.mjs";
|
|
5
5
|
/**
|
|
@@ -17,4 +17,14 @@ export declare function calculateInitialDomainAndTickNumber(axis: DefaultedAxis<
|
|
|
17
17
|
export declare function calculateFinalDomain(axis: Pick<DefaultedAxis<ContinuousScaleName>, 'id' | 'domainLimit' | 'scaleType'> & TickParams & {
|
|
18
18
|
min?: NumberValue;
|
|
19
19
|
max?: NumberValue;
|
|
20
|
-
}, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], tickNumber: number): NumberValue[];
|
|
20
|
+
}, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], tickNumber: number): NumberValue[];
|
|
21
|
+
export interface DomainDefinition {
|
|
22
|
+
domain: ReadonlyArray<string | NumberValue>;
|
|
23
|
+
tickNumber?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Computes the domain map for a list of axes.
|
|
27
|
+
* Shared between the rendering selectors and the auto-size domain selectors
|
|
28
|
+
* to ensure consistent domain computation logic.
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeAxisDomainsMap(axes: DefaultedXAxis[] | DefaultedYAxis[] | undefined, formattedSeries: ProcessedSeries, defaultTickNumber: number, extremaMap: Record<AxisId, [number, number]>, axisDirection: 'x' | 'y'): Record<AxisId, DomainDefinition>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
-
import { type ContinuousScaleName, type DefaultedAxis } from "../../../../models/axis.js";
|
|
2
|
+
import { type AxisId, type ContinuousScaleName, type DefaultedAxis, type DefaultedXAxis, type DefaultedYAxis } from "../../../../models/axis.js";
|
|
3
3
|
import { type ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
4
|
import { type TickParams } from "../../../../hooks/useTicks.js";
|
|
5
5
|
/**
|
|
@@ -17,4 +17,14 @@ export declare function calculateInitialDomainAndTickNumber(axis: DefaultedAxis<
|
|
|
17
17
|
export declare function calculateFinalDomain(axis: Pick<DefaultedAxis<ContinuousScaleName>, 'id' | 'domainLimit' | 'scaleType'> & TickParams & {
|
|
18
18
|
min?: NumberValue;
|
|
19
19
|
max?: NumberValue;
|
|
20
|
-
}, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], tickNumber: number): NumberValue[];
|
|
20
|
+
}, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], tickNumber: number): NumberValue[];
|
|
21
|
+
export interface DomainDefinition {
|
|
22
|
+
domain: ReadonlyArray<string | NumberValue>;
|
|
23
|
+
tickNumber?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Computes the domain map for a list of axes.
|
|
27
|
+
* Shared between the rendering selectors and the auto-size domain selectors
|
|
28
|
+
* to ensure consistent domain computation logic.
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeAxisDomainsMap(axes: DefaultedXAxis[] | DefaultedYAxis[] | undefined, formattedSeries: ProcessedSeries, defaultTickNumber: number, extremaMap: Record<AxisId, [number, number]>, axisDirection: 'x' | 'y'): Record<AxisId, DomainDefinition>;
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.calculateFinalDomain = calculateFinalDomain;
|
|
7
7
|
exports.calculateInitialDomainAndTickNumber = calculateInitialDomainAndTickNumber;
|
|
8
|
+
exports.computeAxisDomainsMap = computeAxisDomainsMap;
|
|
9
|
+
var _axis = require("../../../../models/axis");
|
|
8
10
|
var _getScale = require("../../../getScale");
|
|
9
11
|
var _getAxisDomainLimit = require("./getAxisDomainLimit");
|
|
10
12
|
var _ticks = require("../../../ticks");
|
|
@@ -78,4 +80,30 @@ function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
|
78
80
|
return [min, max];
|
|
79
81
|
}
|
|
80
82
|
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Computes the domain map for a list of axes.
|
|
86
|
+
* Shared between the rendering selectors and the auto-size domain selectors
|
|
87
|
+
* to ensure consistent domain computation logic.
|
|
88
|
+
*/
|
|
89
|
+
function computeAxisDomainsMap(axes, formattedSeries, defaultTickNumber, extremaMap, axisDirection) {
|
|
90
|
+
const domains = {};
|
|
91
|
+
axes?.forEach((eachAxis, axisIndex) => {
|
|
92
|
+
const axis = eachAxis;
|
|
93
|
+
if ((0, _axis.isBandScaleConfig)(axis) || (0, _axis.isPointScaleConfig)(axis)) {
|
|
94
|
+
domains[axis.id] = {
|
|
95
|
+
domain: axis.data
|
|
96
|
+
};
|
|
97
|
+
if (axis.ordinalTimeTicks !== undefined) {
|
|
98
|
+
domains[axis.id].tickNumber = (0, _ticks.getTickNumber)(axis, [axis.data?.find(d => d !== null), axis.data?.findLast(d => d !== null)], defaultTickNumber);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const extrema = extremaMap[axis.id];
|
|
103
|
+
if (!extrema) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
domains[axis.id] = calculateInitialDomainAndTickNumber(axis, axisDirection, axisIndex, formattedSeries, extrema, defaultTickNumber);
|
|
107
|
+
});
|
|
108
|
+
return domains;
|
|
81
109
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.mjs";
|
|
1
2
|
import { getScale } from "../../../getScale.mjs";
|
|
2
3
|
import { getAxisDomainLimit } from "./getAxisDomainLimit.mjs";
|
|
3
4
|
import { getTickNumber } from "../../../ticks.mjs";
|
|
@@ -71,4 +72,30 @@ function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
|
71
72
|
return [min, max];
|
|
72
73
|
}
|
|
73
74
|
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Computes the domain map for a list of axes.
|
|
78
|
+
* Shared between the rendering selectors and the auto-size domain selectors
|
|
79
|
+
* to ensure consistent domain computation logic.
|
|
80
|
+
*/
|
|
81
|
+
export function computeAxisDomainsMap(axes, formattedSeries, defaultTickNumber, extremaMap, axisDirection) {
|
|
82
|
+
const domains = {};
|
|
83
|
+
axes?.forEach((eachAxis, axisIndex) => {
|
|
84
|
+
const axis = eachAxis;
|
|
85
|
+
if (isBandScaleConfig(axis) || isPointScaleConfig(axis)) {
|
|
86
|
+
domains[axis.id] = {
|
|
87
|
+
domain: axis.data
|
|
88
|
+
};
|
|
89
|
+
if (axis.ordinalTimeTicks !== undefined) {
|
|
90
|
+
domains[axis.id].tickNumber = getTickNumber(axis, [axis.data?.find(d => d !== null), axis.data?.findLast(d => d !== null)], defaultTickNumber);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const extrema = extremaMap[axis.id];
|
|
95
|
+
if (!extrema) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
domains[axis.id] = calculateInitialDomainAndTickNumber(axis, axisDirection, axisIndex, formattedSeries, extrema, defaultTickNumber);
|
|
99
|
+
});
|
|
100
|
+
return domains;
|
|
74
101
|
}
|
|
@@ -5,8 +5,10 @@ export * from "./useChartCartesianAxisLayout.selectors.mjs";
|
|
|
5
5
|
export * from "./useChartCartesianInteraction.selectors.mjs";
|
|
6
6
|
export * from "./useChartCartesianHighlight.selectors.mjs";
|
|
7
7
|
export * from "./useChartCartesianAxisPreview.selectors.mjs";
|
|
8
|
+
export * from "./useChartAxisAutoSize.selectors.mjs";
|
|
8
9
|
export * from "./useChartCartesianTooltip.selectors.mjs";
|
|
9
10
|
export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.mjs";
|
|
10
11
|
export * from "./computeAxisValue.mjs";
|
|
11
12
|
export * from "./createZoomLookup.mjs";
|
|
12
|
-
export * from "./zoom.types.mjs";
|
|
13
|
+
export * from "./zoom.types.mjs";
|
|
14
|
+
export { computeAxisAutoSize } from "./computeAxisAutoSize.mjs";
|
|
@@ -5,8 +5,10 @@ export * from "./useChartCartesianAxisLayout.selectors.js";
|
|
|
5
5
|
export * from "./useChartCartesianInteraction.selectors.js";
|
|
6
6
|
export * from "./useChartCartesianHighlight.selectors.js";
|
|
7
7
|
export * from "./useChartCartesianAxisPreview.selectors.js";
|
|
8
|
+
export * from "./useChartAxisAutoSize.selectors.js";
|
|
8
9
|
export * from "./useChartCartesianTooltip.selectors.js";
|
|
9
10
|
export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
|
|
10
11
|
export * from "./computeAxisValue.js";
|
|
11
12
|
export * from "./createZoomLookup.js";
|
|
12
|
-
export * from "./zoom.types.js";
|
|
13
|
+
export * from "./zoom.types.js";
|
|
14
|
+
export { computeAxisAutoSize } from "./computeAxisAutoSize.js";
|
|
@@ -6,8 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
useChartCartesianAxis: true,
|
|
8
8
|
defaultizeXAxis: true,
|
|
9
|
-
defaultizeYAxis: true
|
|
9
|
+
defaultizeYAxis: true,
|
|
10
|
+
computeAxisAutoSize: true
|
|
10
11
|
};
|
|
12
|
+
Object.defineProperty(exports, "computeAxisAutoSize", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _computeAxisAutoSize.computeAxisAutoSize;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
11
18
|
Object.defineProperty(exports, "defaultizeXAxis", {
|
|
12
19
|
enumerable: true,
|
|
13
20
|
get: function () {
|
|
@@ -87,6 +94,18 @@ Object.keys(_useChartCartesianAxisPreview).forEach(function (key) {
|
|
|
87
94
|
}
|
|
88
95
|
});
|
|
89
96
|
});
|
|
97
|
+
var _useChartAxisAutoSize = require("./useChartAxisAutoSize.selectors");
|
|
98
|
+
Object.keys(_useChartAxisAutoSize).forEach(function (key) {
|
|
99
|
+
if (key === "default" || key === "__esModule") return;
|
|
100
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
101
|
+
if (key in exports && exports[key] === _useChartAxisAutoSize[key]) return;
|
|
102
|
+
Object.defineProperty(exports, key, {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _useChartAxisAutoSize[key];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
90
109
|
var _useChartCartesianTooltip = require("./useChartCartesianTooltip.selectors");
|
|
91
110
|
Object.keys(_useChartCartesianTooltip).forEach(function (key) {
|
|
92
111
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -135,4 +154,5 @@ Object.keys(_zoom).forEach(function (key) {
|
|
|
135
154
|
return _zoom[key];
|
|
136
155
|
}
|
|
137
156
|
});
|
|
138
|
-
});
|
|
157
|
+
});
|
|
158
|
+
var _computeAxisAutoSize = require("./computeAxisAutoSize");
|
|
@@ -4,8 +4,10 @@ export * from "./useChartCartesianAxisLayout.selectors.mjs";
|
|
|
4
4
|
export * from "./useChartCartesianInteraction.selectors.mjs";
|
|
5
5
|
export * from "./useChartCartesianHighlight.selectors.mjs";
|
|
6
6
|
export * from "./useChartCartesianAxisPreview.selectors.mjs";
|
|
7
|
+
export * from "./useChartAxisAutoSize.selectors.mjs";
|
|
7
8
|
export * from "./useChartCartesianTooltip.selectors.mjs";
|
|
8
9
|
export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.mjs";
|
|
9
10
|
export * from "./computeAxisValue.mjs";
|
|
10
11
|
export * from "./createZoomLookup.mjs";
|
|
11
|
-
export * from "./zoom.types.mjs";
|
|
12
|
+
export * from "./zoom.types.mjs";
|
|
13
|
+
export { computeAxisAutoSize } from "./computeAxisAutoSize.mjs";
|
package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AxisAutoSizeResult } from "./computeAxisAutoSize.mjs";
|
|
2
|
+
import type { AxisId } from "../../../../models/axis.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Selector that computes full auto-size results for X axes that have `height: 'auto'`.
|
|
5
|
+
* Returns a map of axis ID to full result (including group tick sizes for grouped axes).
|
|
6
|
+
*/
|
|
7
|
+
export declare const selectorChartXAxisAutoSizeResults: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.mjs").UseChartCartesianAxisState> & {
|
|
8
|
+
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
9
|
+
}) => Record<AxisId, AxisAutoSizeResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Selector that computes auto-sizes for X axes that have `height: 'auto'`.
|
|
12
|
+
* Returns a map of axis ID to computed height (just the size, not group tick sizes).
|
|
13
|
+
*/
|
|
14
|
+
export declare const selectorChartXAxisAutoSizes: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.mjs").UseChartCartesianAxisState> & {
|
|
15
|
+
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
16
|
+
}) => Record<AxisId, number>;
|
|
17
|
+
/**
|
|
18
|
+
* Selector that computes full auto-size results for Y axes that have `width: 'auto'`.
|
|
19
|
+
* Returns a map of axis ID to full result (including group tick sizes for grouped axes).
|
|
20
|
+
*/
|
|
21
|
+
export declare const selectorChartYAxisAutoSizeResults: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.mjs").UseChartCartesianAxisState> & {
|
|
22
|
+
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
23
|
+
}) => Record<AxisId, AxisAutoSizeResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Selector that computes auto-sizes for Y axes that have `width: 'auto'`.
|
|
26
|
+
* Returns a map of axis ID to computed width (just the size, not group tick sizes).
|
|
27
|
+
*/
|
|
28
|
+
export declare const selectorChartYAxisAutoSizes: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.mjs").UseChartCartesianAxisState> & {
|
|
29
|
+
cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
|
|
30
|
+
}) => Record<AxisId, number>;
|