@mui/x-charts 8.19.0 → 8.21.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.d.ts +1 -1
- package/BarChart/BarChart.js +18 -0
- package/BarChart/BarLabel/BarLabel.types.d.ts +4 -3
- package/BarChart/BarLabel/BarLabelItem.d.ts +5 -4
- package/BarChart/BarLabel/BarLabelPlot.d.ts +25 -6
- package/BarChart/BarLabel/BarLabelPlot.js +10 -9
- package/BarChart/BarLabel/getBarLabel.d.ts +5 -4
- package/BarChart/BarLabel/getBarLabel.js +3 -4
- package/BarChart/BarPlot.js +4 -3
- package/BarChart/checkBarChartScaleErrors.d.ts +7 -0
- package/BarChart/{checkScaleErrors.js → checkBarChartScaleErrors.js} +6 -7
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +5 -3
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.js +3 -4
- package/BarChart/seriesConfig/index.js +2 -2
- package/BarChart/types.d.ts +6 -3
- package/BarChart/useBarPlotData.js +17 -45
- package/CHANGELOG.md +174 -0
- package/ChartContainer/ChartContainer.js +28 -0
- package/ChartsGrid/ChartsHorizontalGrid.js +8 -2
- package/ChartsGrid/ChartsVerticalGrid.js +8 -2
- package/ChartsTooltip/ChartsTooltipContainer.js +2 -1
- package/ChartsXAxis/ChartsSingleXAxisTicks.js +2 -0
- package/ChartsXAxis/ChartsXAxisImpl.js +2 -0
- package/ChartsXAxis/useAxisTicksProps.d.ts +198 -117
- package/ChartsXAxis/useAxisTicksProps.js +2 -0
- package/ChartsYAxis/ChartsSingleYAxisTicks.js +2 -0
- package/ChartsYAxis/ChartsYAxisImpl.js +2 -0
- package/ChartsYAxis/useAxisTicksProps.d.ts +198 -117
- package/ChartsYAxis/useAxisTicksProps.js +2 -0
- package/LineChart/LineChart.js +18 -0
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +2 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +2 -2
- package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +7 -0
- package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.js +26 -0
- package/RadarChart/seriesConfig/index.js +2 -0
- package/RadarChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/RadarChart/seriesConfig/tooltipPosition.js +80 -0
- package/ScatterChart/ScatterChart.js +18 -0
- package/SparkLineChart/SparkLineChart.js +18 -0
- package/esm/BarChart/BarChart.d.ts +1 -1
- package/esm/BarChart/BarChart.js +18 -0
- package/esm/BarChart/BarLabel/BarLabel.types.d.ts +4 -3
- package/esm/BarChart/BarLabel/BarLabelItem.d.ts +5 -4
- package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +25 -6
- package/esm/BarChart/BarLabel/BarLabelPlot.js +9 -9
- package/esm/BarChart/BarLabel/getBarLabel.d.ts +5 -4
- package/esm/BarChart/BarLabel/getBarLabel.js +2 -2
- package/esm/BarChart/BarPlot.js +4 -3
- package/esm/BarChart/checkBarChartScaleErrors.d.ts +7 -0
- package/esm/BarChart/{checkScaleErrors.js → checkBarChartScaleErrors.js} +5 -6
- package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +5 -3
- package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.js +2 -3
- package/esm/BarChart/seriesConfig/index.js +1 -1
- package/esm/BarChart/types.d.ts +6 -3
- package/esm/BarChart/useBarPlotData.js +17 -45
- package/esm/ChartContainer/ChartContainer.js +28 -0
- package/esm/ChartsGrid/ChartsHorizontalGrid.js +8 -2
- package/esm/ChartsGrid/ChartsVerticalGrid.js +8 -2
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +2 -1
- package/esm/ChartsXAxis/ChartsSingleXAxisTicks.js +2 -0
- package/esm/ChartsXAxis/ChartsXAxisImpl.js +2 -0
- package/esm/ChartsXAxis/useAxisTicksProps.d.ts +198 -117
- package/esm/ChartsXAxis/useAxisTicksProps.js +2 -0
- package/esm/ChartsYAxis/ChartsSingleYAxisTicks.js +2 -0
- package/esm/ChartsYAxis/ChartsYAxisImpl.js +2 -0
- package/esm/ChartsYAxis/useAxisTicksProps.d.ts +198 -117
- package/esm/ChartsYAxis/useAxisTicksProps.js +2 -0
- package/esm/LineChart/LineChart.js +18 -0
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +1 -1
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -1
- package/esm/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +7 -0
- package/esm/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.js +18 -0
- package/esm/RadarChart/seriesConfig/index.js +2 -0
- package/esm/RadarChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/esm/RadarChart/seriesConfig/tooltipPosition.js +74 -0
- package/esm/ScatterChart/ScatterChart.js +18 -0
- package/esm/SparkLineChart/SparkLineChart.js +18 -0
- package/esm/hooks/useInteractionItemProps.d.ts +0 -5
- package/esm/hooks/useInteractionItemProps.js +0 -11
- package/esm/hooks/useIsHydrated.js +1 -1
- package/esm/hooks/useTicks.d.ts +15 -2
- package/esm/hooks/useTicks.js +44 -6
- package/esm/index.js +1 -1
- package/esm/internals/domUtils.d.ts +6 -3
- package/esm/internals/getBandSize.d.ts +13 -0
- package/esm/internals/getBandSize.js +23 -0
- package/esm/internals/getWordsByLines.d.ts +2 -1
- package/esm/internals/index.d.ts +5 -0
- package/esm/internals/index.js +5 -0
- package/esm/internals/plugins/corePlugins/useChartSeries/index.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +25 -10
- package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.js +49 -12
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +5 -7
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +19 -4
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +23 -4
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +5 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +5 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +1 -2
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +2 -4
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +16 -12
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +7 -7
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +4 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +37 -22
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +15 -10
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +10 -7
- package/esm/internals/plugins/models/seriesConfig/index.d.ts +1 -0
- package/esm/internals/plugins/models/seriesConfig/index.js +1 -0
- package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +5 -0
- package/esm/internals/plugins/models/seriesConfig/seriesLayout.types.d.ts +6 -0
- package/esm/internals/plugins/models/seriesConfig/seriesLayout.types.js +1 -0
- package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +6 -4
- package/esm/internals/seriesSelectorOfType.d.ts +3 -3
- package/esm/internals/seriesSelectorOfType.js +1 -1
- package/esm/models/axis.d.ts +5 -0
- package/esm/models/seriesType/bar.d.ts +3 -2
- package/esm/models/seriesType/config.d.ts +10 -0
- package/esm/models/seriesType/index.d.ts +1 -0
- package/hooks/useInteractionItemProps.d.ts +0 -5
- package/hooks/useInteractionItemProps.js +1 -13
- package/hooks/useIsHydrated.js +1 -1
- package/hooks/useTicks.d.ts +15 -2
- package/hooks/useTicks.js +45 -6
- package/index.js +1 -1
- package/internals/domUtils.d.ts +6 -3
- package/internals/getBandSize.d.ts +13 -0
- package/internals/getBandSize.js +29 -0
- package/internals/getWordsByLines.d.ts +2 -1
- package/internals/index.d.ts +5 -0
- package/internals/index.js +48 -0
- package/internals/plugins/corePlugins/useChartSeries/index.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +25 -10
- package/internals/plugins/corePlugins/useChartSeries/processSeries.js +53 -14
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +4 -6
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +19 -4
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +23 -4
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +5 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +2 -2
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +1 -2
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +1 -1
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +2 -4
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +16 -12
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +7 -7
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +35 -20
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +15 -10
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +10 -6
- package/internals/plugins/models/seriesConfig/index.d.ts +1 -0
- package/internals/plugins/models/seriesConfig/index.js +11 -0
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +5 -0
- package/internals/plugins/models/seriesConfig/seriesLayout.types.d.ts +6 -0
- package/internals/plugins/models/seriesConfig/seriesLayout.types.js +5 -0
- package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +6 -4
- package/internals/seriesSelectorOfType.d.ts +3 -3
- package/internals/seriesSelectorOfType.js +1 -1
- package/models/axis.d.ts +5 -0
- package/models/seriesType/bar.d.ts +3 -2
- package/models/seriesType/config.d.ts +10 -0
- package/models/seriesType/index.d.ts +1 -0
- package/package.json +4 -4
- package/BarChart/checkScaleErrors.d.ts +0 -10
- package/esm/BarChart/checkScaleErrors.d.ts +0 -10
package/hooks/useTicks.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ export interface TickParams {
|
|
|
39
39
|
* @default 'middle'
|
|
40
40
|
*/
|
|
41
41
|
tickLabelPlacement?: 'middle' | 'tick';
|
|
42
|
+
/**
|
|
43
|
+
* The minimum space between ticks when using an ordinal scale. It defines the minimum distance in pixels between two ticks.
|
|
44
|
+
* @default 0
|
|
45
|
+
*/
|
|
46
|
+
tickSpacing?: number;
|
|
42
47
|
}
|
|
43
48
|
export type TickItemType = {
|
|
44
49
|
/**
|
|
@@ -49,13 +54,21 @@ export type TickItemType = {
|
|
|
49
54
|
offset: number;
|
|
50
55
|
labelOffset: number;
|
|
51
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Returns a new domain where each tick is at least {@link tickSpacing}px from the next one.
|
|
59
|
+
* Assumes tick spacing is greater than 0.
|
|
60
|
+
* @param domain Domain of the scale.
|
|
61
|
+
* @param range Range of the scale.
|
|
62
|
+
* @param tickSpacing Spacing in pixels.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyTickSpacing<T>(domain: T[], range: [number, number], tickSpacing: number): T[];
|
|
52
65
|
export declare function getTicks(options: {
|
|
53
66
|
scale: D3Scale;
|
|
54
67
|
valueFormatter?: AxisConfig['valueFormatter'];
|
|
55
68
|
isInside: (offset: number) => boolean;
|
|
56
|
-
} & Pick<TickParams, 'tickInterval' | 'tickPlacement' | 'tickLabelPlacement'> & Required<Pick<TickParams, 'tickNumber'>>): TickItemType[];
|
|
69
|
+
} & Pick<TickParams, 'tickInterval' | 'tickPlacement' | 'tickLabelPlacement' | 'tickSpacing'> & Required<Pick<TickParams, 'tickNumber'>>): TickItemType[];
|
|
57
70
|
export declare function useTicks(options: {
|
|
58
71
|
scale: D3Scale;
|
|
59
72
|
valueFormatter?: AxisConfig['valueFormatter'];
|
|
60
73
|
direction: 'x' | 'y';
|
|
61
|
-
} & Pick<TickParams, 'tickInterval' | 'tickPlacement' | 'tickLabelPlacement'> & Required<Pick<TickParams, 'tickNumber'>>): TickItemType[];
|
|
74
|
+
} & Pick<TickParams, 'tickInterval' | 'tickPlacement' | 'tickLabelPlacement' | 'tickSpacing'> & Required<Pick<TickParams, 'tickNumber'>>): TickItemType[];
|
package/hooks/useTicks.js
CHANGED
|
@@ -5,6 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.applyTickSpacing = applyTickSpacing;
|
|
8
9
|
exports.getTicks = getTicks;
|
|
9
10
|
exports.useTicks = useTicks;
|
|
10
11
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -17,6 +18,25 @@ const offsetRatio = {
|
|
|
17
18
|
end: 1,
|
|
18
19
|
middle: 0.5
|
|
19
20
|
};
|
|
21
|
+
function getTickPosition(scale, value, placement) {
|
|
22
|
+
return scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[placement] * scale.step();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns a new domain where each tick is at least {@link tickSpacing}px from the next one.
|
|
27
|
+
* Assumes tick spacing is greater than 0.
|
|
28
|
+
* @param domain Domain of the scale.
|
|
29
|
+
* @param range Range of the scale.
|
|
30
|
+
* @param tickSpacing Spacing in pixels.
|
|
31
|
+
*/
|
|
32
|
+
function applyTickSpacing(domain, range, tickSpacing) {
|
|
33
|
+
const rangeSpan = Math.abs(range[1] - range[0]);
|
|
34
|
+
const every = Math.ceil(domain.length / (rangeSpan / tickSpacing));
|
|
35
|
+
if (Number.isNaN(every) || every <= 1) {
|
|
36
|
+
return domain;
|
|
37
|
+
}
|
|
38
|
+
return domain.filter((_, index) => index % every === 0);
|
|
39
|
+
}
|
|
20
40
|
function getTicks(options) {
|
|
21
41
|
const {
|
|
22
42
|
scale,
|
|
@@ -25,6 +45,7 @@ function getTicks(options) {
|
|
|
25
45
|
tickInterval,
|
|
26
46
|
tickPlacement = 'extremities',
|
|
27
47
|
tickLabelPlacement: tickLabelPlacementProp,
|
|
48
|
+
tickSpacing,
|
|
28
49
|
isInside
|
|
29
50
|
} = options;
|
|
30
51
|
|
|
@@ -32,10 +53,27 @@ function getTicks(options) {
|
|
|
32
53
|
if ((0, _scaleGuards.isOrdinalScale)(scale)) {
|
|
33
54
|
const domain = scale.domain();
|
|
34
55
|
const tickLabelPlacement = tickLabelPlacementProp ?? 'middle';
|
|
56
|
+
let filteredDomain = domain;
|
|
57
|
+
if (typeof tickInterval === 'object' && tickInterval != null) {
|
|
58
|
+
filteredDomain = tickInterval;
|
|
59
|
+
} else {
|
|
60
|
+
if (typeof tickInterval === 'function') {
|
|
61
|
+
filteredDomain = filteredDomain.filter(tickInterval);
|
|
62
|
+
}
|
|
63
|
+
if (tickSpacing !== undefined && tickSpacing > 0) {
|
|
64
|
+
filteredDomain = applyTickSpacing(filteredDomain, scale.range(), tickSpacing);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
35
67
|
if (scale.bandwidth() > 0) {
|
|
36
68
|
// scale type = 'band'
|
|
37
|
-
|
|
38
|
-
|
|
69
|
+
|
|
70
|
+
const isReversed = scale.range()[0] > scale.range()[1];
|
|
71
|
+
// Indexes are inclusive regarding the entire band.
|
|
72
|
+
const startIndex = filteredDomain.findIndex(value => {
|
|
73
|
+
return isInside(getTickPosition(scale, value, isReversed ? 'start' : 'end'));
|
|
74
|
+
});
|
|
75
|
+
const endIndex = filteredDomain.findLastIndex(value => isInside(getTickPosition(scale, value, isReversed ? 'end' : 'start')));
|
|
76
|
+
return [...filteredDomain.slice(startIndex, endIndex + 1).map(value => {
|
|
39
77
|
const defaultTickLabel = `${value}`;
|
|
40
78
|
return {
|
|
41
79
|
value,
|
|
@@ -45,10 +83,10 @@ function getTicks(options) {
|
|
|
45
83
|
tickNumber,
|
|
46
84
|
defaultTickLabel
|
|
47
85
|
}) ?? defaultTickLabel,
|
|
48
|
-
offset:
|
|
86
|
+
offset: getTickPosition(scale, value, tickPlacement),
|
|
49
87
|
labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
|
|
50
88
|
};
|
|
51
|
-
}), ...(tickPlacement === 'extremities' ? [{
|
|
89
|
+
}), ...(tickPlacement === 'extremities' && endIndex === domain.length - 1 && isInside(scale.range()[1]) ? [{
|
|
52
90
|
formattedValue: undefined,
|
|
53
91
|
offset: scale.range()[1],
|
|
54
92
|
labelOffset: 0
|
|
@@ -56,7 +94,6 @@ function getTicks(options) {
|
|
|
56
94
|
}
|
|
57
95
|
|
|
58
96
|
// scale type = 'point'
|
|
59
|
-
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
60
97
|
return filteredDomain.map(value => {
|
|
61
98
|
const defaultTickLabel = `${value}`;
|
|
62
99
|
return {
|
|
@@ -124,6 +161,7 @@ function useTicks(options) {
|
|
|
124
161
|
tickInterval,
|
|
125
162
|
tickPlacement = 'extremities',
|
|
126
163
|
tickLabelPlacement,
|
|
164
|
+
tickSpacing,
|
|
127
165
|
direction
|
|
128
166
|
} = options;
|
|
129
167
|
const {
|
|
@@ -136,7 +174,8 @@ function useTicks(options) {
|
|
|
136
174
|
tickPlacement,
|
|
137
175
|
tickInterval,
|
|
138
176
|
tickLabelPlacement,
|
|
177
|
+
tickSpacing,
|
|
139
178
|
valueFormatter,
|
|
140
179
|
isInside
|
|
141
|
-
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, valueFormatter, isInside]);
|
|
180
|
+
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, tickSpacing, valueFormatter, isInside]);
|
|
142
181
|
}
|
package/index.js
CHANGED
package/internals/domUtils.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
export interface SVGCSSProperties extends Omit<React.CSSProperties, 'dominantBaseline'> {
|
|
3
|
+
dominantBaseline?: React.SVGAttributes<SVGTextElement>['dominantBaseline'];
|
|
4
|
+
}
|
|
2
5
|
export declare function clearStringMeasurementCache(): void;
|
|
3
6
|
/**
|
|
4
7
|
* Converts a style object into a string to be used as a cache key
|
|
5
8
|
* @param style React style object
|
|
6
9
|
* @returns CSS styling string
|
|
7
10
|
*/
|
|
8
|
-
export declare function getStyleString(style:
|
|
11
|
+
export declare function getStyleString(style: SVGCSSProperties): string;
|
|
9
12
|
/**
|
|
10
13
|
*
|
|
11
14
|
* @param text The string to estimate
|
|
12
15
|
* @param style The style applied
|
|
13
16
|
* @returns width and height of the text
|
|
14
17
|
*/
|
|
15
|
-
export declare const getStringSize: (text: string | number, style?:
|
|
18
|
+
export declare const getStringSize: (text: string | number, style?: SVGCSSProperties) => {
|
|
16
19
|
width: number;
|
|
17
20
|
height: number;
|
|
18
21
|
};
|
|
19
|
-
export declare function batchMeasureStrings(texts: Iterable<string | number>, style?:
|
|
22
|
+
export declare function batchMeasureStrings(texts: Iterable<string | number>, style?: SVGCSSProperties): Map<string | number, {
|
|
20
23
|
width: number;
|
|
21
24
|
height: number;
|
|
22
25
|
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solution of the equations
|
|
3
|
+
* W = barWidth * N + offset * (N-1)
|
|
4
|
+
* offset / (offset + barWidth) = r
|
|
5
|
+
* @param bandWidth (W) The width available to place bars.
|
|
6
|
+
* @param groupCount (N) The number of bars to place in that space.
|
|
7
|
+
* @param gapRatio (r) The ratio of the gap between bars over the bar width.
|
|
8
|
+
* @returns The bar width and the offset between bars.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getBandSize(bandWidth: number, groupCount: number, gapRatio: number): {
|
|
11
|
+
barWidth: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBandSize = getBandSize;
|
|
7
|
+
/**
|
|
8
|
+
* Solution of the equations
|
|
9
|
+
* W = barWidth * N + offset * (N-1)
|
|
10
|
+
* offset / (offset + barWidth) = r
|
|
11
|
+
* @param bandWidth (W) The width available to place bars.
|
|
12
|
+
* @param groupCount (N) The number of bars to place in that space.
|
|
13
|
+
* @param gapRatio (r) The ratio of the gap between bars over the bar width.
|
|
14
|
+
* @returns The bar width and the offset between bars.
|
|
15
|
+
*/
|
|
16
|
+
function getBandSize(bandWidth, groupCount, gapRatio) {
|
|
17
|
+
if (gapRatio === 0) {
|
|
18
|
+
return {
|
|
19
|
+
barWidth: bandWidth / groupCount,
|
|
20
|
+
offset: 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const barWidth = bandWidth / (groupCount + (groupCount - 1) * gapRatio);
|
|
24
|
+
const offset = gapRatio * barWidth;
|
|
25
|
+
return {
|
|
26
|
+
barWidth,
|
|
27
|
+
offset
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
export type ChartsTextBaseline = 'hanging' | 'central' | 'auto' | 'text-after-edge' | 'text-before-edge';
|
|
2
3
|
export type ChartsTextAnchor = 'start' | 'middle' | 'end';
|
|
3
|
-
export interface ChartsTextStyle extends React.CSSProperties {
|
|
4
|
+
export interface ChartsTextStyle extends Omit<React.CSSProperties, 'dominantBaseline'> {
|
|
4
5
|
angle?: number;
|
|
5
6
|
/**
|
|
6
7
|
* The text baseline
|
package/internals/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./components/ChartsAxesGradients/index.js";
|
|
2
2
|
export * from "../ChartsLabel/ChartsLabelMark.js";
|
|
3
3
|
export * from "./components/NotRendered.js";
|
|
4
|
+
export * from "../BarChart/BarLabel/BarLabelPlot.js";
|
|
5
|
+
export * from "../BarChart/BarClipPath.js";
|
|
4
6
|
export { useSeries } from "../hooks/useSeries.js";
|
|
5
7
|
export { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
|
|
6
8
|
export { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
@@ -16,6 +18,7 @@ export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
|
|
|
16
18
|
export * from "../ChartContainer/useChartContainerProps.js";
|
|
17
19
|
export * from "../ChartDataProvider/useChartDataProviderProps.js";
|
|
18
20
|
export * from "./seriesSelectorOfType.js";
|
|
21
|
+
export { useSkipAnimation } from "../hooks/useSkipAnimation.js";
|
|
19
22
|
export * from "./plugins/corePlugins/useChartId/index.js";
|
|
20
23
|
export * from "./plugins/corePlugins/useChartSeries/index.js";
|
|
21
24
|
export * from "./plugins/corePlugins/useChartDimensions/index.js";
|
|
@@ -56,6 +59,8 @@ export * from "./dateHelpers.js";
|
|
|
56
59
|
export * from "./invertScale.js";
|
|
57
60
|
export * from "./scaleGuards.js";
|
|
58
61
|
export * from "./findMinMax.js";
|
|
62
|
+
export { checkBarChartScaleErrors } from "../BarChart/checkBarChartScaleErrors.js";
|
|
63
|
+
export { getBandSize } from "./getBandSize.js";
|
|
59
64
|
export { getAxisExtrema } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js";
|
|
60
65
|
export * from "../context/ChartProvider/index.js";
|
|
61
66
|
export * from "../context/ChartsSlotsContext.js";
|
package/internals/index.js
CHANGED
|
@@ -16,16 +16,31 @@ var _exportNames = {
|
|
|
16
16
|
useBarChartProps: true,
|
|
17
17
|
useBarPlotData: true,
|
|
18
18
|
useRadarChartProps: true,
|
|
19
|
+
useSkipAnimation: true,
|
|
19
20
|
getCartesianAxisTriggerTooltip: true,
|
|
20
21
|
getCartesianAxisIndex: true,
|
|
22
|
+
checkBarChartScaleErrors: true,
|
|
23
|
+
getBandSize: true,
|
|
21
24
|
getAxisExtrema: true
|
|
22
25
|
};
|
|
26
|
+
Object.defineProperty(exports, "checkBarChartScaleErrors", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _checkBarChartScaleErrors.checkBarChartScaleErrors;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
23
32
|
Object.defineProperty(exports, "getAxisExtrema", {
|
|
24
33
|
enumerable: true,
|
|
25
34
|
get: function () {
|
|
26
35
|
return _getAxisExtrema.getAxisExtrema;
|
|
27
36
|
}
|
|
28
37
|
});
|
|
38
|
+
Object.defineProperty(exports, "getBandSize", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _getBandSize.getBandSize;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
29
44
|
Object.defineProperty(exports, "getCartesianAxisIndex", {
|
|
30
45
|
enumerable: true,
|
|
31
46
|
get: function () {
|
|
@@ -110,6 +125,12 @@ Object.defineProperty(exports, "useSeries", {
|
|
|
110
125
|
return _useSeries.useSeries;
|
|
111
126
|
}
|
|
112
127
|
});
|
|
128
|
+
Object.defineProperty(exports, "useSkipAnimation", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () {
|
|
131
|
+
return _useSkipAnimation.useSkipAnimation;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
113
134
|
var _ChartsAxesGradients = require("./components/ChartsAxesGradients");
|
|
114
135
|
Object.keys(_ChartsAxesGradients).forEach(function (key) {
|
|
115
136
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -146,6 +167,30 @@ Object.keys(_NotRendered).forEach(function (key) {
|
|
|
146
167
|
}
|
|
147
168
|
});
|
|
148
169
|
});
|
|
170
|
+
var _BarLabelPlot = require("../BarChart/BarLabel/BarLabelPlot");
|
|
171
|
+
Object.keys(_BarLabelPlot).forEach(function (key) {
|
|
172
|
+
if (key === "default" || key === "__esModule") return;
|
|
173
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
174
|
+
if (key in exports && exports[key] === _BarLabelPlot[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _BarLabelPlot[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
var _BarClipPath = require("../BarChart/BarClipPath");
|
|
183
|
+
Object.keys(_BarClipPath).forEach(function (key) {
|
|
184
|
+
if (key === "default" || key === "__esModule") return;
|
|
185
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
186
|
+
if (key in exports && exports[key] === _BarClipPath[key]) return;
|
|
187
|
+
Object.defineProperty(exports, key, {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function () {
|
|
190
|
+
return _BarClipPath[key];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
149
194
|
var _useSeries = require("../hooks/useSeries");
|
|
150
195
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
151
196
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
@@ -194,6 +239,7 @@ Object.keys(_seriesSelectorOfType).forEach(function (key) {
|
|
|
194
239
|
}
|
|
195
240
|
});
|
|
196
241
|
});
|
|
242
|
+
var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
197
243
|
var _useChartId = require("./plugins/corePlugins/useChartId");
|
|
198
244
|
Object.keys(_useChartId).forEach(function (key) {
|
|
199
245
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -652,6 +698,8 @@ Object.keys(_findMinMax).forEach(function (key) {
|
|
|
652
698
|
}
|
|
653
699
|
});
|
|
654
700
|
});
|
|
701
|
+
var _checkBarChartScaleErrors = require("../BarChart/checkBarChartScaleErrors");
|
|
702
|
+
var _getBandSize = require("./getBandSize");
|
|
655
703
|
var _getAxisExtrema = require("./plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema");
|
|
656
704
|
var _ChartProvider = require("../context/ChartProvider");
|
|
657
705
|
Object.keys(_ChartProvider).forEach(function (key) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { useChartSeries } from "./useChartSeries.js";
|
|
2
|
-
export type { UseChartSeriesSignature, UseChartSeriesParameters, UseChartSeriesDefaultizedParameters, ProcessedSeries } from "./useChartSeries.types.js";
|
|
2
|
+
export type { UseChartSeriesSignature, UseChartSeriesParameters, UseChartSeriesDefaultizedParameters, ProcessedSeries, SeriesLayout } from "./useChartSeries.types.js";
|
|
3
3
|
export * from "./useChartSeries.selectors.js";
|
|
@@ -1,23 +1,38 @@
|
|
|
1
|
+
import { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
|
|
1
2
|
import { AllSeriesType } from "../../../../models/seriesType/index.js";
|
|
2
3
|
import { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
|
|
3
4
|
import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { DefaultizedSeriesGroups, ProcessedSeries, SeriesLayout } from "./useChartSeries.types.js";
|
|
5
6
|
/**
|
|
6
|
-
* This
|
|
7
|
-
*
|
|
8
|
-
* It also add defaultized values such as the ids, colors
|
|
7
|
+
* This method groups series by type and adds defaultized values such as the ids and colors.
|
|
8
|
+
* It does NOT apply the series processors - that happens in a selector.
|
|
9
9
|
* @param series The array of series provided by the developer
|
|
10
10
|
* @param colors The color palette used to defaultize series colors
|
|
11
|
-
* @returns An object structuring all the series by type.
|
|
11
|
+
* @returns An object structuring all the series by type with default values.
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const defaultizeSeries: <TSeriesType extends ChartSeriesType>({
|
|
14
14
|
series,
|
|
15
15
|
colors,
|
|
16
|
-
seriesConfig
|
|
17
|
-
dataset
|
|
16
|
+
seriesConfig
|
|
18
17
|
}: {
|
|
19
18
|
series: Readonly<AllSeriesType<TSeriesType>[]>;
|
|
20
19
|
colors: readonly string[];
|
|
21
20
|
seriesConfig: ChartSeriesConfig<TSeriesType>;
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
}) => DefaultizedSeriesGroups<TSeriesType>;
|
|
22
|
+
/**
|
|
23
|
+
* Applies series processors to the defaultized series groups.
|
|
24
|
+
* This should be called in a selector to compute processed series on-demand.
|
|
25
|
+
* @param defaultizedSeries The defaultized series groups
|
|
26
|
+
* @param seriesConfig The series configuration
|
|
27
|
+
* @param dataset The optional dataset
|
|
28
|
+
* @returns Processed series with all transformations applied
|
|
29
|
+
*/
|
|
30
|
+
export declare const applySeriesProcessors: <TSeriesType extends ChartSeriesType>(defaultizedSeries: DefaultizedSeriesGroups<TSeriesType>, seriesConfig: ChartSeriesConfig<TSeriesType>, dataset?: Readonly<DatasetType>) => ProcessedSeries<TSeriesType>;
|
|
31
|
+
/**
|
|
32
|
+
* Applies series processors with drawing area to series if defined.
|
|
33
|
+
* @param processedSeries The processed series groups
|
|
34
|
+
* @param seriesConfig The series configuration
|
|
35
|
+
* @param drawingArea The drawing area
|
|
36
|
+
* @returns Processed series with all transformations applied
|
|
37
|
+
*/
|
|
38
|
+
export declare const applySeriesLayout: <TSeriesType extends ChartSeriesType>(processedSeries: ProcessedSeries<TSeriesType>, seriesConfig: ChartSeriesConfig<TSeriesType>, drawingArea: ChartDrawingArea) => SeriesLayout<TSeriesType>;
|
|
@@ -3,26 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.defaultizeSeries = exports.applySeriesProcessors = exports.applySeriesLayout = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* This
|
|
9
|
-
*
|
|
10
|
-
* It also add defaultized values such as the ids, colors
|
|
8
|
+
* This method groups series by type and adds defaultized values such as the ids and colors.
|
|
9
|
+
* It does NOT apply the series processors - that happens in a selector.
|
|
11
10
|
* @param series The array of series provided by the developer
|
|
12
11
|
* @param colors The color palette used to defaultize series colors
|
|
13
|
-
* @returns An object structuring all the series by type.
|
|
12
|
+
* @returns An object structuring all the series by type with default values.
|
|
14
13
|
*/
|
|
15
|
-
const
|
|
14
|
+
const defaultizeSeries = ({
|
|
16
15
|
series,
|
|
17
16
|
colors,
|
|
18
|
-
seriesConfig
|
|
19
|
-
dataset
|
|
17
|
+
seriesConfig
|
|
20
18
|
}) => {
|
|
21
19
|
// Group series by type
|
|
22
20
|
const seriesGroups = {};
|
|
23
|
-
// Notice the line about uses `ChartSeriesType` instead of TSeriesType.
|
|
24
|
-
// That's probably because the series.type is not propagated from the generic but hardcoded in the config.
|
|
25
|
-
|
|
26
21
|
series.forEach((seriesData, seriesIndex) => {
|
|
27
22
|
const seriesWithDefaultValues = seriesConfig[seriesData.type].getSeriesWithDefaultValues(seriesData, seriesIndex, colors);
|
|
28
23
|
const id = seriesWithDefaultValues.id;
|
|
@@ -38,14 +33,58 @@ const preprocessSeries = ({
|
|
|
38
33
|
seriesGroups[seriesData.type].series[id] = seriesWithDefaultValues;
|
|
39
34
|
seriesGroups[seriesData.type].seriesOrder.push(id);
|
|
40
35
|
});
|
|
36
|
+
return seriesGroups;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Applies series processors to the defaultized series groups.
|
|
41
|
+
* This should be called in a selector to compute processed series on-demand.
|
|
42
|
+
* @param defaultizedSeries The defaultized series groups
|
|
43
|
+
* @param seriesConfig The series configuration
|
|
44
|
+
* @param dataset The optional dataset
|
|
45
|
+
* @returns Processed series with all transformations applied
|
|
46
|
+
*/
|
|
47
|
+
exports.defaultizeSeries = defaultizeSeries;
|
|
48
|
+
const applySeriesProcessors = (defaultizedSeries, seriesConfig, dataset) => {
|
|
41
49
|
const processedSeries = {};
|
|
50
|
+
|
|
42
51
|
// Apply formatter on a type group
|
|
43
52
|
Object.keys(seriesConfig).forEach(type => {
|
|
44
|
-
const group =
|
|
53
|
+
const group = defaultizedSeries[type];
|
|
45
54
|
if (group !== undefined) {
|
|
46
|
-
processedSeries[type] = seriesConfig[type]?.seriesProcessor?.(group, dataset) ??
|
|
55
|
+
processedSeries[type] = seriesConfig[type]?.seriesProcessor?.(group, dataset) ?? group;
|
|
47
56
|
}
|
|
48
57
|
});
|
|
49
58
|
return processedSeries;
|
|
50
59
|
};
|
|
51
|
-
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Applies series processors with drawing area to series if defined.
|
|
63
|
+
* @param processedSeries The processed series groups
|
|
64
|
+
* @param seriesConfig The series configuration
|
|
65
|
+
* @param drawingArea The drawing area
|
|
66
|
+
* @returns Processed series with all transformations applied
|
|
67
|
+
*/
|
|
68
|
+
exports.applySeriesProcessors = applySeriesProcessors;
|
|
69
|
+
const applySeriesLayout = (processedSeries, seriesConfig, drawingArea) => {
|
|
70
|
+
let processingDetected = false;
|
|
71
|
+
const seriesLayout = {};
|
|
72
|
+
|
|
73
|
+
// Apply processors on series type per group
|
|
74
|
+
Object.keys(processedSeries).forEach(type => {
|
|
75
|
+
const processor = seriesConfig[type]?.seriesLayout;
|
|
76
|
+
const thisSeries = processedSeries[type];
|
|
77
|
+
if (processor !== undefined && thisSeries !== undefined) {
|
|
78
|
+
const newValue = processor(thisSeries, drawingArea);
|
|
79
|
+
if (newValue && newValue !== processedSeries[type]) {
|
|
80
|
+
processingDetected = true;
|
|
81
|
+
seriesLayout[type] = newValue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (!processingDetected) {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
return seriesLayout;
|
|
89
|
+
};
|
|
90
|
+
exports.applySeriesLayout = applySeriesLayout;
|
|
@@ -32,11 +32,10 @@ const useChartSeries = ({
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
store.set('series', (0, _extends2.default)({}, store.state.series, {
|
|
35
|
-
|
|
35
|
+
defaultizedSeries: (0, _processSeries.defaultizeSeries)({
|
|
36
36
|
series,
|
|
37
37
|
colors: typeof colors === 'function' ? colors(theme) : colors,
|
|
38
|
-
seriesConfig
|
|
39
|
-
dataset
|
|
38
|
+
seriesConfig
|
|
40
39
|
}),
|
|
41
40
|
dataset
|
|
42
41
|
}));
|
|
@@ -67,11 +66,10 @@ useChartSeries.getInitialState = ({
|
|
|
67
66
|
return {
|
|
68
67
|
series: {
|
|
69
68
|
seriesConfig,
|
|
70
|
-
|
|
69
|
+
defaultizedSeries: (0, _processSeries.defaultizeSeries)({
|
|
71
70
|
series,
|
|
72
71
|
colors: typeof colors === 'function' ? colors(theme) : colors,
|
|
73
|
-
seriesConfig
|
|
74
|
-
dataset
|
|
72
|
+
seriesConfig
|
|
75
73
|
}),
|
|
76
74
|
dataset
|
|
77
75
|
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { ChartRootSelector } from "../../utils/selectors.js";
|
|
2
2
|
import { UseChartSeriesSignature } from "./useChartSeries.types.js";
|
|
3
3
|
export declare const selectorChartSeriesState: ChartRootSelector<UseChartSeriesSignature>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const selectorChartDefaultizedSeries: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
5
5
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
-
}) => import("./useChartSeries.types.js").
|
|
6
|
+
}) => import("./useChartSeries.types.js").DefaultizedSeriesGroups<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
7
7
|
export declare const selectorChartSeriesConfig: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
8
8
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
9
|
}) => import("../../models/index.js").ChartSeriesConfig<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
10
10
|
/**
|
|
11
11
|
* Get the dataset from the series state.
|
|
12
|
-
* @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
|
|
13
12
|
* @returns {DatasetType | undefined} The dataset.
|
|
14
13
|
*/
|
|
15
14
|
export declare const selectorChartDataset: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
16
15
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
17
|
-
}) => readonly import("../../../index.js").DatasetElementType<unknown>[] | undefined;
|
|
16
|
+
}) => readonly import("../../../index.js").DatasetElementType<unknown>[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get the processed series after applying series processors.
|
|
19
|
+
* This selector computes the processed series on-demand from the defaultized series.
|
|
20
|
+
* @returns {ProcessedSeries} The processed series.
|
|
21
|
+
*/
|
|
22
|
+
export declare const selectorChartSeriesProcessed: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
23
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
24
|
+
}) => import("./useChartSeries.types.js").ProcessedSeries<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the processed series after applying series processors.
|
|
27
|
+
* This selector computes the processed series on-demand from the defaultized series.
|
|
28
|
+
* @returns {ProcessedSeries} The processed series.
|
|
29
|
+
*/
|
|
30
|
+
export declare const selectorChartSeriesLayout: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
31
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
32
|
+
}) => import("./useChartSeries.types.js").SeriesLayout<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
@@ -3,16 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartSeriesState = exports.selectorChartSeriesProcessed = exports.selectorChartSeriesConfig = exports.selectorChartDataset = void 0;
|
|
6
|
+
exports.selectorChartSeriesState = exports.selectorChartSeriesProcessed = exports.selectorChartSeriesLayout = exports.selectorChartSeriesConfig = exports.selectorChartDefaultizedSeries = exports.selectorChartDataset = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
|
+
var _processSeries = require("./processSeries");
|
|
9
|
+
var _useChartDimensions = require("../useChartDimensions/useChartDimensions.selectors");
|
|
8
10
|
const selectorChartSeriesState = state => state.series;
|
|
9
11
|
exports.selectorChartSeriesState = selectorChartSeriesState;
|
|
10
|
-
const
|
|
12
|
+
const selectorChartDefaultizedSeries = exports.selectorChartDefaultizedSeries = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.defaultizedSeries);
|
|
11
13
|
const selectorChartSeriesConfig = exports.selectorChartSeriesConfig = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.seriesConfig);
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Get the dataset from the series state.
|
|
15
|
-
* @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
|
|
16
17
|
* @returns {DatasetType | undefined} The dataset.
|
|
17
18
|
*/
|
|
18
|
-
const selectorChartDataset = exports.selectorChartDataset = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.dataset);
|
|
19
|
+
const selectorChartDataset = exports.selectorChartDataset = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.dataset);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the processed series after applying series processors.
|
|
23
|
+
* This selector computes the processed series on-demand from the defaultized series.
|
|
24
|
+
* @returns {ProcessedSeries} The processed series.
|
|
25
|
+
*/
|
|
26
|
+
const selectorChartSeriesProcessed = exports.selectorChartSeriesProcessed = (0, _store.createSelectorMemoized)(selectorChartDefaultizedSeries, selectorChartSeriesConfig, selectorChartDataset, function selectorChartSeriesProcessed(defaultizedSeries, seriesConfig, dataset) {
|
|
27
|
+
return (0, _processSeries.applySeriesProcessors)(defaultizedSeries, seriesConfig, dataset);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the processed series after applying series processors.
|
|
32
|
+
* This selector computes the processed series on-demand from the defaultized series.
|
|
33
|
+
* @returns {ProcessedSeries} The processed series.
|
|
34
|
+
*/
|
|
35
|
+
const selectorChartSeriesLayout = exports.selectorChartSeriesLayout = (0, _store.createSelectorMemoized)(selectorChartSeriesProcessed, selectorChartSeriesConfig, _useChartDimensions.selectorChartDrawingArea, function selectorChartSeriesLayout(processedSeries, seriesConfig, drawingArea) {
|
|
36
|
+
return (0, _processSeries.applySeriesLayout)(processedSeries, seriesConfig, drawingArea);
|
|
37
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AllSeriesType } from "../../../../models/seriesType/index.js";
|
|
2
2
|
import { ChartsColorPalette } from "../../../../colorPalettes/index.js";
|
|
3
|
-
import { ChartPluginSignature, ChartSeriesConfig } from "../../models/index.js";
|
|
3
|
+
import { ChartPluginSignature, ChartSeriesConfig, SeriesLayoutGetterResult } from "../../models/index.js";
|
|
4
4
|
import { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
|
|
5
|
-
import { SeriesProcessorResult } from "../../models/seriesConfig/seriesProcessor.types.js";
|
|
5
|
+
import { SeriesProcessorParams, SeriesProcessorResult } from "../../models/seriesConfig/seriesProcessor.types.js";
|
|
6
6
|
export interface UseChartSeriesParameters<T extends ChartSeriesType = ChartSeriesType> {
|
|
7
7
|
/**
|
|
8
8
|
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
@@ -36,9 +36,11 @@ export type UseChartSeriesDefaultizedParameters<T extends ChartSeriesType = Char
|
|
|
36
36
|
theme: 'light' | 'dark';
|
|
37
37
|
};
|
|
38
38
|
export type ProcessedSeries<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesProcessorResult<type> };
|
|
39
|
+
export type SeriesLayout<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesLayoutGetterResult<type> };
|
|
40
|
+
export type DefaultizedSeriesGroups<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesProcessorParams<type> };
|
|
39
41
|
export interface UseChartSeriesState<T extends ChartSeriesType = ChartSeriesType> {
|
|
40
42
|
series: {
|
|
41
|
-
|
|
43
|
+
defaultizedSeries: DefaultizedSeriesGroups<T>;
|
|
42
44
|
seriesConfig: ChartSeriesConfig<T>;
|
|
43
45
|
dataset?: Readonly<DatasetType>;
|
|
44
46
|
};
|