@mui/x-charts 8.7.0 → 8.9.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 +4 -3
- package/BarChart/BarChart.js +17 -1
- package/BarChart/barClasses.d.ts +1 -1
- package/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/BarChart/useBarPlotData.js +32 -5
- package/CHANGELOG.md +199 -24
- package/ChartContainer/ChartContainer.js +22 -0
- package/ChartContainer/useChartContainerProps.js +8 -2
- package/ChartDataProvider/ChartDataProvider.js +6 -0
- package/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/ChartDataProvider/useChartDataProviderProps.js +6 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +34 -24
- package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +34 -24
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/ChartsLabel/index.d.ts +1 -0
- package/ChartsLabel/index.js +18 -0
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/Gauge/GaugeContainer.d.ts +1 -1
- package/LineChart/LineChart.d.ts +3 -2
- package/LineChart/LineChart.js +23 -1
- package/LineChart/LineHighlightPlot.js +10 -4
- package/LineChart/MarkPlot.js +17 -3
- package/LineChart/useAreaPlotData.js +3 -2
- package/PieChart/PieArcLabelPlot.js +3 -0
- package/PieChart/PieArcPlot.js +3 -0
- package/PieChart/PieChart.d.ts +4 -3
- package/PieChart/PieChart.js +1 -1
- package/PieChart/pieClasses.d.ts +1 -1
- package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/RadarChart/RadarChart.d.ts +2 -1
- package/RadarChart/RadarChart.js +23 -2
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +4 -3
- package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/RadarChart/index.d.ts +1 -1
- package/RadarChart/useRadarChartProps.d.ts +3 -0
- package/RadarChart/useRadarChartProps.js +15 -3
- package/ScatterChart/ScatterChart.d.ts +4 -3
- package/ScatterChart/ScatterChart.js +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/BarChart/BarChart.d.ts +4 -3
- package/esm/BarChart/BarChart.js +17 -1
- package/esm/BarChart/barClasses.d.ts +1 -1
- package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/esm/BarChart/useBarPlotData.js +32 -5
- package/esm/ChartContainer/ChartContainer.js +22 -0
- package/esm/ChartContainer/useChartContainerProps.js +8 -2
- package/esm/ChartDataProvider/ChartDataProvider.js +6 -0
- package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -2
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +36 -26
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +36 -26
- package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/esm/ChartsLabel/index.d.ts +1 -0
- package/esm/ChartsLabel/index.js +1 -0
- package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/esm/Gauge/GaugeContainer.d.ts +1 -1
- package/esm/LineChart/LineChart.d.ts +3 -2
- package/esm/LineChart/LineChart.js +23 -1
- package/esm/LineChart/LineHighlightPlot.js +11 -5
- package/esm/LineChart/MarkPlot.js +17 -3
- package/esm/LineChart/useAreaPlotData.js +3 -2
- package/esm/PieChart/PieArcLabelPlot.js +3 -0
- package/esm/PieChart/PieArcPlot.js +3 -0
- package/esm/PieChart/PieChart.d.ts +4 -3
- package/esm/PieChart/PieChart.js +1 -1
- package/esm/PieChart/pieClasses.d.ts +1 -1
- package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/esm/RadarChart/RadarChart.d.ts +2 -1
- package/esm/RadarChart/RadarChart.js +23 -2
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +4 -3
- package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/esm/RadarChart/index.d.ts +1 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +3 -0
- package/esm/RadarChart/useRadarChartProps.js +15 -3
- package/esm/ScatterChart/ScatterChart.d.ts +4 -3
- package/esm/ScatterChart/ScatterChart.js +1 -1
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/hooks/useAxis.d.ts +2 -2
- package/esm/hooks/useTicks.d.ts +6 -1
- package/esm/hooks/useTicks.js +94 -58
- package/esm/index.js +1 -1
- package/esm/internals/constants.d.ts +3 -0
- package/esm/internals/constants.js +4 -0
- package/esm/internals/getLabel.d.ts +1 -1
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/esm/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +2 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +27 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +14 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +46 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +76 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +48 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +16 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/esm/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/esm/internals/plugins/utils/useLazySelectorEffect.js +70 -0
- package/esm/internals/store/useCharts.d.ts +1 -1
- package/esm/models/axis.d.ts +42 -1
- package/esm/models/axis.js +4 -0
- package/esm/models/index.d.ts +1 -1
- package/esm/models/seriesType/bar.d.ts +11 -1
- package/esm/models/seriesType/common.d.ts +9 -3
- package/esm/models/seriesType/line.d.ts +3 -1
- package/esm/models/seriesType/scatter.d.ts +14 -2
- package/esm/tests/web-components.js +49 -0
- package/esm/themeAugmentation/components.d.ts +3 -0
- package/esm/themeAugmentation/props.d.ts +2 -0
- package/hooks/useAxis.d.ts +2 -2
- package/hooks/useTicks.d.ts +6 -1
- package/hooks/useTicks.js +95 -58
- package/index.js +1 -1
- package/internals/constants.d.ts +3 -0
- package/internals/constants.js +5 -1
- package/internals/getLabel.d.ts +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +8 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +27 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +34 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +10 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +5 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +24 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +46 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +55 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +18 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/internals/plugins/utils/useLazySelectorEffect.js +77 -0
- package/internals/store/useCharts.d.ts +1 -1
- package/models/axis.d.ts +42 -1
- package/models/axis.js +4 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/bar.d.ts +11 -1
- package/models/seriesType/common.d.ts +9 -3
- package/models/seriesType/line.d.ts +3 -1
- package/models/seriesType/scatter.d.ts +14 -2
- package/package.json +5 -5
- package/tests/web-components.js +55 -0
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
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.getTicks = getTicks;
|
|
8
9
|
exports.useTicks = useTicks;
|
|
9
10
|
var React = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _ChartProvider = require("../context/ChartProvider");
|
|
@@ -16,7 +17,7 @@ const offsetRatio = {
|
|
|
16
17
|
end: 1,
|
|
17
18
|
middle: 0.5
|
|
18
19
|
};
|
|
19
|
-
function
|
|
20
|
+
function getTicks(options) {
|
|
20
21
|
const {
|
|
21
22
|
scale,
|
|
22
23
|
tickNumber,
|
|
@@ -24,75 +25,111 @@ function useTicks(options) {
|
|
|
24
25
|
tickInterval,
|
|
25
26
|
tickPlacement = 'extremities',
|
|
26
27
|
tickLabelPlacement: tickLabelPlacementProp,
|
|
27
|
-
|
|
28
|
+
isInside
|
|
28
29
|
} = options;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return [...filteredDomain.map(value => ({
|
|
30
|
+
|
|
31
|
+
// band scale
|
|
32
|
+
if ((0, _isBandScale.isBandScale)(scale)) {
|
|
33
|
+
const domain = scale.domain();
|
|
34
|
+
const tickLabelPlacement = tickLabelPlacementProp ?? 'middle';
|
|
35
|
+
if (scale.bandwidth() > 0) {
|
|
36
|
+
// scale type = 'band'
|
|
37
|
+
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
38
|
+
return [...filteredDomain.map(value => {
|
|
39
|
+
const defaultTickLabel = `${value}`;
|
|
40
|
+
return {
|
|
41
41
|
value,
|
|
42
42
|
formattedValue: valueFormatter?.(value, {
|
|
43
43
|
location: 'tick',
|
|
44
|
-
scale
|
|
45
|
-
|
|
44
|
+
scale,
|
|
45
|
+
tickNumber,
|
|
46
|
+
defaultTickLabel
|
|
47
|
+
}) ?? defaultTickLabel,
|
|
46
48
|
offset: scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[tickPlacement] * scale.step(),
|
|
47
49
|
labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
};
|
|
51
|
+
}), ...(tickPlacement === 'extremities' ? [{
|
|
52
|
+
formattedValue: undefined,
|
|
53
|
+
offset: scale.range()[1],
|
|
54
|
+
labelOffset: 0
|
|
55
|
+
}] : [])];
|
|
56
|
+
}
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
// scale type = 'point'
|
|
59
|
+
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
60
|
+
return filteredDomain.map(value => {
|
|
61
|
+
const defaultTickLabel = `${value}`;
|
|
62
|
+
return {
|
|
58
63
|
value,
|
|
59
64
|
formattedValue: valueFormatter?.(value, {
|
|
60
65
|
location: 'tick',
|
|
61
|
-
scale
|
|
62
|
-
|
|
66
|
+
scale,
|
|
67
|
+
tickNumber,
|
|
68
|
+
defaultTickLabel
|
|
69
|
+
}) ?? defaultTickLabel,
|
|
63
70
|
offset: scale(value),
|
|
64
71
|
labelOffset: 0
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const domain = scale.domain();
|
|
76
|
+
// Skip axis rendering if no data is available
|
|
77
|
+
// - The domains contains Infinity for continuous scales.
|
|
78
|
+
if (domain.some(_isInfinity.isInfinity)) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const tickLabelPlacement = tickLabelPlacementProp;
|
|
82
|
+
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
// Ticks inside the drawing area
|
|
85
|
+
const visibleTicks = [];
|
|
86
|
+
for (let i = 0; i < ticks.length; i += 1) {
|
|
87
|
+
const value = ticks[i];
|
|
88
|
+
const offset = scale(value);
|
|
89
|
+
if (isInside(offset)) {
|
|
90
|
+
/* If d3 returns an empty string, it means that a tick should be shown, but its label shouldn't.
|
|
91
|
+
* This is especially useful in a log scale where we want to show ticks to demonstrate it's a log
|
|
92
|
+
* scale, but don't want to show labels because they would overlap.
|
|
93
|
+
* https://github.com/mui/mui-x/issues/18239 */
|
|
94
|
+
const defaultTickLabel = scale.tickFormat(tickNumber)(value);
|
|
95
|
+
visibleTicks.push({
|
|
96
|
+
value,
|
|
97
|
+
formattedValue: valueFormatter?.(value, {
|
|
98
|
+
location: 'tick',
|
|
99
|
+
scale,
|
|
100
|
+
tickNumber,
|
|
101
|
+
defaultTickLabel
|
|
102
|
+
}) ?? defaultTickLabel,
|
|
103
|
+
offset,
|
|
104
|
+
// Allowing the label to be placed in the middle of a continuous scale is weird.
|
|
105
|
+
// But it is useful in some cases, like funnel categories with a linear scale.
|
|
106
|
+
labelOffset: tickLabelPlacement === 'middle' ? scale(ticks[i - 1] ?? 0) - (offset + scale(ticks[i - 1] ?? 0)) / 2 : 0
|
|
107
|
+
});
|
|
95
108
|
}
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
}
|
|
110
|
+
return visibleTicks;
|
|
111
|
+
}
|
|
112
|
+
function useTicks(options) {
|
|
113
|
+
const {
|
|
114
|
+
scale,
|
|
115
|
+
tickNumber,
|
|
116
|
+
valueFormatter,
|
|
117
|
+
tickInterval,
|
|
118
|
+
tickPlacement = 'extremities',
|
|
119
|
+
tickLabelPlacement,
|
|
120
|
+
direction
|
|
121
|
+
} = options;
|
|
122
|
+
const {
|
|
123
|
+
instance
|
|
124
|
+
} = (0, _ChartProvider.useChartContext)();
|
|
125
|
+
const isInside = direction === 'x' ? instance.isXInside : instance.isYInside;
|
|
126
|
+
return React.useMemo(() => getTicks({
|
|
127
|
+
scale,
|
|
128
|
+
tickNumber,
|
|
129
|
+
tickPlacement,
|
|
130
|
+
tickInterval,
|
|
131
|
+
tickLabelPlacement,
|
|
132
|
+
valueFormatter,
|
|
133
|
+
isInside
|
|
134
|
+
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, valueFormatter, isInside]);
|
|
98
135
|
}
|
package/index.js
CHANGED
package/internals/constants.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ZoomSliderShowTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/zoom.types.js";
|
|
2
2
|
/** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
|
|
3
3
|
export declare const ZOOM_SLIDER_MARGIN = 4;
|
|
4
|
+
/** Size of the zoom slider preview. */
|
|
5
|
+
export declare const ZOOM_SLIDER_PREVIEW_SIZE = 40;
|
|
4
6
|
/** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
|
|
5
7
|
export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
|
|
8
|
+
export declare const DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE: number;
|
|
6
9
|
export declare const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP: ZoomSliderShowTooltip;
|
|
7
10
|
/** Default margin for pie charts. */
|
|
8
11
|
export declare const DEFAULT_PIE_CHART_MARGIN: {
|
package/internals/constants.js
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ZOOM_SLIDER_MARGIN = exports.DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = exports.DEFAULT_PIE_CHART_MARGIN = void 0;
|
|
6
|
+
exports.ZOOM_SLIDER_PREVIEW_SIZE = exports.ZOOM_SLIDER_MARGIN = exports.DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = exports.DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE = exports.DEFAULT_PIE_CHART_MARGIN = void 0;
|
|
7
7
|
/** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
|
|
8
8
|
const ZOOM_SLIDER_MARGIN = exports.ZOOM_SLIDER_MARGIN = 4;
|
|
9
9
|
|
|
10
|
+
/** Size of the zoom slider preview. */
|
|
11
|
+
const ZOOM_SLIDER_PREVIEW_SIZE = exports.ZOOM_SLIDER_PREVIEW_SIZE = 40;
|
|
12
|
+
|
|
10
13
|
/** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
|
|
11
14
|
const DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
|
|
15
|
+
const DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE = exports.DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE = 40 + 2 * ZOOM_SLIDER_MARGIN;
|
|
12
16
|
const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = exports.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = 'hover';
|
|
13
17
|
|
|
14
18
|
/** Default margin for pie charts. */
|
package/internals/getLabel.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getLabel<Location extends string>(value: string | ((location: Location) => string) | undefined, location: Location): string | undefined;
|
|
1
|
+
export declare function getLabel<Location extends string>(value: string | ((location: Location) => string | undefined) | undefined, location: Location): string | undefined;
|
package/internals/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
|
|
|
7
7
|
export { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
8
8
|
export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
|
|
9
9
|
export { useScatterPlotData } from "../ScatterChart/useScatterPlotData.js";
|
|
10
|
+
export { seriesConfig as scatterSeriesConfig } from "../ScatterChart/seriesConfig/index.js";
|
|
10
11
|
export { useLineChartProps } from "../LineChart/useLineChartProps.js";
|
|
11
12
|
export { useAreaPlotData } from "../LineChart/useAreaPlotData.js";
|
|
12
13
|
export { useLinePlotData } from "../LineChart/useLinePlotData.js";
|
package/internals/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var _exportNames = {
|
|
|
9
9
|
useDrawingArea: true,
|
|
10
10
|
useScatterChartProps: true,
|
|
11
11
|
useScatterPlotData: true,
|
|
12
|
+
scatterSeriesConfig: true,
|
|
12
13
|
useLineChartProps: true,
|
|
13
14
|
useAreaPlotData: true,
|
|
14
15
|
useLinePlotData: true,
|
|
@@ -37,6 +38,12 @@ Object.defineProperty(exports, "getCartesianAxisTriggerTooltip", {
|
|
|
37
38
|
return _getAxisTriggerTooltip.getAxisTriggerTooltip;
|
|
38
39
|
}
|
|
39
40
|
});
|
|
41
|
+
Object.defineProperty(exports, "scatterSeriesConfig", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return _seriesConfig.seriesConfig;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
40
47
|
Object.defineProperty(exports, "useAreaPlotData", {
|
|
41
48
|
enumerable: true,
|
|
42
49
|
get: function () {
|
|
@@ -156,6 +163,7 @@ var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
|
156
163
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
157
164
|
var _useScatterChartProps = require("../ScatterChart/useScatterChartProps");
|
|
158
165
|
var _useScatterPlotData = require("../ScatterChart/useScatterPlotData");
|
|
166
|
+
var _seriesConfig = require("../ScatterChart/seriesConfig");
|
|
159
167
|
var _useLineChartProps = require("../LineChart/useLineChartProps");
|
|
160
168
|
var _useAreaPlotData = require("../LineChart/useAreaPlotData");
|
|
161
169
|
var _useLinePlotData = require("../LineChart/useLinePlotData");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type UseChartAnimationSignature } from "./useChartAnimation/index.js";
|
|
2
2
|
import { type UseChartDimensionsSignature } from "./useChartDimensions/index.js";
|
|
3
|
+
import { type UseChartExperimentalFeaturesSignature } from "./useChartExperimentalFeature/index.js";
|
|
3
4
|
import { type UseChartIdSignature, UseChartIdParameters } from "./useChartId/index.js";
|
|
4
5
|
import { type UseChartSeriesSignature } from "./useChartSeries/index.js";
|
|
5
6
|
import { type UseChartInteractionListenerSignature } from "./useChartInteractionListener/index.js";
|
|
@@ -7,6 +8,6 @@ import { type UseChartInteractionListenerSignature } from "./useChartInteraction
|
|
|
7
8
|
* Internal plugins that create the tools used by the other plugins.
|
|
8
9
|
* These plugins are used by the Charts components.
|
|
9
10
|
*/
|
|
10
|
-
export declare const CHART_CORE_PLUGINS: readonly [import("../models/index.js").ChartPlugin<UseChartIdSignature>, import("../models/index.js").ChartPlugin<UseChartDimensionsSignature>, import("../models/index.js").ChartPlugin<UseChartSeriesSignature>, import("../models/index.js").ChartPlugin<UseChartInteractionListenerSignature>, import("../models/index.js").ChartPlugin<UseChartAnimationSignature>];
|
|
11
|
-
export type ChartCorePluginSignatures = [UseChartIdSignature, UseChartDimensionsSignature, UseChartSeriesSignature, UseChartAnimationSignature, UseChartInteractionListenerSignature];
|
|
11
|
+
export declare const CHART_CORE_PLUGINS: readonly [import("../models/index.js").ChartPlugin<UseChartIdSignature>, import("../models/index.js").ChartPlugin<UseChartExperimentalFeaturesSignature>, import("../models/index.js").ChartPlugin<UseChartDimensionsSignature>, import("../models/index.js").ChartPlugin<UseChartSeriesSignature>, import("../models/index.js").ChartPlugin<UseChartInteractionListenerSignature>, import("../models/index.js").ChartPlugin<UseChartAnimationSignature>];
|
|
12
|
+
export type ChartCorePluginSignatures = [UseChartIdSignature, UseChartExperimentalFeaturesSignature, UseChartDimensionsSignature, UseChartSeriesSignature, UseChartAnimationSignature, UseChartInteractionListenerSignature];
|
|
12
13
|
export interface ChartCorePluginParameters extends UseChartIdParameters {}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.CHART_CORE_PLUGINS = void 0;
|
|
7
7
|
var _useChartAnimation = require("./useChartAnimation");
|
|
8
8
|
var _useChartDimensions = require("./useChartDimensions");
|
|
9
|
+
var _useChartExperimentalFeature = require("./useChartExperimentalFeature");
|
|
9
10
|
var _useChartId = require("./useChartId");
|
|
10
11
|
var _useChartSeries = require("./useChartSeries");
|
|
11
12
|
var _useChartInteractionListener = require("./useChartInteractionListener");
|
|
@@ -13,4 +14,4 @@ var _useChartInteractionListener = require("./useChartInteractionListener");
|
|
|
13
14
|
* Internal plugins that create the tools used by the other plugins.
|
|
14
15
|
* These plugins are used by the Charts components.
|
|
15
16
|
*/
|
|
16
|
-
const CHART_CORE_PLUGINS = exports.CHART_CORE_PLUGINS = [_useChartId.useChartId, _useChartDimensions.useChartDimensions, _useChartSeries.useChartSeries, _useChartInteractionListener.useChartInteractionListener, _useChartAnimation.useChartAnimation];
|
|
17
|
+
const CHART_CORE_PLUGINS = exports.CHART_CORE_PLUGINS = [_useChartId.useChartId, _useChartExperimentalFeature.useChartExperimentalFeatures, _useChartDimensions.useChartDimensions, _useChartSeries.useChartSeries, _useChartInteractionListener.useChartInteractionListener, _useChartAnimation.useChartAnimation];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const selectorChartSkipAnimation: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("./useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
1
|
+
export declare const selectorChartSkipAnimation: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("./useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
2
2
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
3
3
|
} & {
|
|
4
4
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -3,7 +3,7 @@ import type { UseChartDimensionsSignature } from "./useChartDimensions.types.js"
|
|
|
3
3
|
import { ChartState } from "../../models/chart.js";
|
|
4
4
|
export declare const selectorChartDimensionsState: ChartRootSelector<UseChartDimensionsSignature>;
|
|
5
5
|
export declare const selectorChartMargin: (state: ChartState<[UseChartDimensionsSignature]>) => import("./useChartDimensions.types.js").ChartMargin;
|
|
6
|
-
export declare const selectorChartDrawingArea: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("./useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
6
|
+
export declare const selectorChartDrawingArea: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
7
7
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
8
|
} & Partial<import("../../../index.js").UseChartCartesianAxisState> & {
|
|
9
9
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -15,7 +15,7 @@ export declare const selectorChartDrawingArea: import("reselect").Selector<impor
|
|
|
15
15
|
top: number;
|
|
16
16
|
bottom: number;
|
|
17
17
|
}, []>;
|
|
18
|
-
export declare const selectorChartPropsSize: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("./useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
18
|
+
export declare const selectorChartPropsSize: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
19
19
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
20
20
|
} & {
|
|
21
21
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -23,7 +23,7 @@ export declare const selectorChartPropsSize: import("reselect").Selector<import(
|
|
|
23
23
|
width: number | undefined;
|
|
24
24
|
height: number | undefined;
|
|
25
25
|
}, any[]>;
|
|
26
|
-
export declare const selectorChartContainerSize: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("./useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
26
|
+
export declare const selectorChartContainerSize: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
27
27
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
28
|
} & {
|
|
29
29
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useChartExperimentalFeatures } from "./useChartExperimentalFeature.js";
|
|
2
|
+
export type { UseChartExperimentalFeaturesSignature, UseChartExperimentalFeaturesParameters } from "./useChartExperimentalFeature.types.js";
|
|
3
|
+
export * from "./useChartExperimentalFeature.selectors.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useChartExperimentalFeatures: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "useChartExperimentalFeatures", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _useChartExperimentalFeature.useChartExperimentalFeatures;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _useChartExperimentalFeature = require("./useChartExperimentalFeature");
|
|
16
|
+
var _useChartExperimentalFeature2 = require("./useChartExperimentalFeature.selectors");
|
|
17
|
+
Object.keys(_useChartExperimentalFeature2).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _useChartExperimentalFeature2[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _useChartExperimentalFeature2[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useChartExperimentalFeatures = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
11
|
+
const useChartExperimentalFeatures = ({
|
|
12
|
+
params,
|
|
13
|
+
store
|
|
14
|
+
}) => {
|
|
15
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
16
|
+
store.update(prevState => {
|
|
17
|
+
return (0, _extends2.default)({}, prevState, {
|
|
18
|
+
experimentalFeatures: params.experimentalFeatures
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}, [store, params.experimentalFeatures]);
|
|
22
|
+
return {};
|
|
23
|
+
};
|
|
24
|
+
exports.useChartExperimentalFeatures = useChartExperimentalFeatures;
|
|
25
|
+
useChartExperimentalFeatures.params = {
|
|
26
|
+
experimentalFeatures: true
|
|
27
|
+
};
|
|
28
|
+
useChartExperimentalFeatures.getInitialState = ({
|
|
29
|
+
experimentalFeatures
|
|
30
|
+
}) => {
|
|
31
|
+
return {
|
|
32
|
+
experimentalFeatures
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChartRootSelector } from "../../utils/selectors.js";
|
|
2
|
+
import type { UseChartExperimentalFeaturesSignature } from "./useChartExperimentalFeature.types.js";
|
|
3
|
+
export declare const selectorChartExperimentalFeaturesState: ChartRootSelector<UseChartExperimentalFeaturesSignature>;
|
|
4
|
+
export declare const selectorPreferStrictDomainInLineCharts: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("./useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
5
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
+
} & {
|
|
7
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
|
+
}, boolean, any[]>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.selectorPreferStrictDomainInLineCharts = exports.selectorChartExperimentalFeaturesState = void 0;
|
|
7
|
+
var _selectors = require("../../utils/selectors");
|
|
8
|
+
const selectorChartExperimentalFeaturesState = state => state.experimentalFeatures;
|
|
9
|
+
exports.selectorChartExperimentalFeaturesState = selectorChartExperimentalFeaturesState;
|
|
10
|
+
const selectorPreferStrictDomainInLineCharts = exports.selectorPreferStrictDomainInLineCharts = (0, _selectors.createSelector)([selectorChartExperimentalFeaturesState], features => Boolean(features?.preferStrictDomainInLineCharts));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChartPluginSignature } from "../../models/index.js";
|
|
2
|
+
export interface ChartExperimentalFeatures {
|
|
3
|
+
/**
|
|
4
|
+
* Default domainLimit to strict for line chart x-axis.
|
|
5
|
+
*/
|
|
6
|
+
preferStrictDomainInLineCharts?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseChartExperimentalFeaturesParameters {
|
|
9
|
+
/**
|
|
10
|
+
* Options to enable features planned for the next major.
|
|
11
|
+
*/
|
|
12
|
+
experimentalFeatures?: ChartExperimentalFeatures;
|
|
13
|
+
}
|
|
14
|
+
export interface UseChartExperimentalFeaturesState {
|
|
15
|
+
experimentalFeatures?: ChartExperimentalFeatures;
|
|
16
|
+
}
|
|
17
|
+
export type UseChartExperimentalFeaturesSignature = ChartPluginSignature<{
|
|
18
|
+
params: UseChartExperimentalFeaturesParameters;
|
|
19
|
+
defaultizedParams: UseChartExperimentalFeaturesParameters;
|
|
20
|
+
state: UseChartExperimentalFeaturesState;
|
|
21
|
+
}>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param {ChartState<[UseChartIdSignature]>} state The state of the chart.
|
|
4
4
|
* @returns {string} The id attribute of the chart.
|
|
5
5
|
*/
|
|
6
|
-
export declare const selectorChartId: import("reselect").Selector<import("./useChartId.types.js").UseChartIdState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
6
|
+
export declare const selectorChartId: import("reselect").Selector<import("./useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
7
7
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
8
|
} & {
|
|
9
9
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -1,12 +1,12 @@
|
|
|
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 selectorChartSeriesProcessed: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & 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<{}> & {
|
|
4
|
+
export declare const selectorChartSeriesProcessed: import("reselect").Selector<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
6
|
} & {
|
|
7
7
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
8
|
}, import("./useChartSeries.types.js").ProcessedSeries<keyof import("../../../index.js").ChartsSeriesConfig>, any[]>;
|
|
9
|
-
export declare const selectorChartSeriesConfig: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & 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<{}> & {
|
|
9
|
+
export declare const selectorChartSeriesConfig: import("reselect").Selector<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<{}> & {
|
|
10
10
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
11
11
|
} & {
|
|
12
12
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
@@ -7,7 +7,7 @@ import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries
|
|
|
7
7
|
import { GetZoomAxisFilters, ZoomData } from "./zoom.types.js";
|
|
8
8
|
export type ComputeResult<T extends ChartsAxisProps> = {
|
|
9
9
|
axis: ComputedAxisConfig<T>;
|
|
10
|
-
axisIds:
|
|
10
|
+
axisIds: AxisId[];
|
|
11
11
|
};
|
|
12
12
|
type ComputeCommonParams<T extends ChartSeriesType = ChartSeriesType> = {
|
|
13
13
|
drawingArea: ChartDrawingArea;
|
|
@@ -16,6 +16,10 @@ type ComputeCommonParams<T extends ChartSeriesType = ChartSeriesType> = {
|
|
|
16
16
|
zoomMap?: Map<AxisId, ZoomData>;
|
|
17
17
|
zoomOptions?: Record<AxisId, DefaultizedZoomOptions>;
|
|
18
18
|
getFilters?: GetZoomAxisFilters;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
21
|
+
*/
|
|
22
|
+
preferStrictDomainInLineCharts?: boolean;
|
|
19
23
|
};
|
|
20
24
|
export declare function computeAxisValue<T extends ChartSeriesType>(options: ComputeCommonParams<T> & {
|
|
21
25
|
axis?: DefaultedYAxis[];
|
|
@@ -16,6 +16,7 @@ var _dateHelpers = require("../../../dateHelpers");
|
|
|
16
16
|
var _zoom = require("./zoom");
|
|
17
17
|
var _getAxisExtremum = require("./getAxisExtremum");
|
|
18
18
|
var _getAxisTriggerTooltip = require("./getAxisTriggerTooltip");
|
|
19
|
+
var _getAxisDomainLimit = require("./getAxisDomainLimit");
|
|
19
20
|
function getRange(drawingArea, axisDirection,
|
|
20
21
|
// | 'rotation' | 'radius',
|
|
21
22
|
axis) {
|
|
@@ -32,7 +33,8 @@ function computeAxisValue({
|
|
|
32
33
|
axisDirection,
|
|
33
34
|
zoomMap,
|
|
34
35
|
zoomOptions,
|
|
35
|
-
getFilters
|
|
36
|
+
getFilters,
|
|
37
|
+
preferStrictDomainInLineCharts
|
|
36
38
|
}) {
|
|
37
39
|
if (allAxis === undefined) {
|
|
38
40
|
return {
|
|
@@ -102,7 +104,7 @@ function computeAxisValue({
|
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
const scaleType = axis.scaleType ?? 'linear';
|
|
105
|
-
const domainLimit = axis.domainLimit ?? 'nice';
|
|
107
|
+
const domainLimit = preferStrictDomainInLineCharts ? (0, _getAxisDomainLimit.getAxisDomainLimit)(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
|
|
106
108
|
const axisExtremums = [axis.min ?? minData, axis.max ?? maxData];
|
|
107
109
|
if (typeof domainLimit === 'function') {
|
|
108
110
|
const {
|
|
@@ -17,6 +17,7 @@ const defaultZoomOptions = exports.defaultZoomOptions = {
|
|
|
17
17
|
filterMode: 'keep',
|
|
18
18
|
slider: {
|
|
19
19
|
enabled: false,
|
|
20
|
+
preview: false,
|
|
20
21
|
size: _constants.DEFAULT_ZOOM_SLIDER_SIZE,
|
|
21
22
|
showTooltip: _constants.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP
|
|
22
23
|
}
|
|
@@ -35,7 +36,9 @@ const defaultizeZoom = (zoom, axisId, axisDirection) => {
|
|
|
35
36
|
axisId,
|
|
36
37
|
axisDirection
|
|
37
38
|
}, defaultZoomOptions, zoom, {
|
|
38
|
-
slider: (0, _extends2.default)({}, defaultZoomOptions.slider,
|
|
39
|
+
slider: (0, _extends2.default)({}, defaultZoomOptions.slider, {
|
|
40
|
+
size: zoom.slider?.preview ?? defaultZoomOptions.slider.preview ? _constants.DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE : _constants.DEFAULT_ZOOM_SLIDER_SIZE
|
|
41
|
+
}, zoom.slider)
|
|
39
42
|
});
|
|
40
43
|
};
|
|
41
44
|
exports.defaultizeZoom = defaultizeZoom;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxisConfig } from "../../../../models/axis.js";
|
|
2
|
+
import { CartesianChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
|
+
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
export declare const getAxisDomainLimit: <T extends CartesianChartSeriesType>(axis: AxisConfig, axisDirection: "x" | "y", axisIndex: number, formattedSeries: ProcessedSeries<T | "line">) => "nice" | "strict" | ((min: number, max: number) => {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAxisDomainLimit = void 0;
|
|
7
|
+
const getAxisDomainLimit = (axis, axisDirection, axisIndex, formattedSeries) => {
|
|
8
|
+
if (axis.domainLimit !== undefined) {
|
|
9
|
+
return axis.domainLimit;
|
|
10
|
+
}
|
|
11
|
+
if (axisDirection === 'x') {
|
|
12
|
+
for (const seriesId of formattedSeries.line?.seriesOrder ?? []) {
|
|
13
|
+
const series = formattedSeries.line.series[seriesId];
|
|
14
|
+
if (series.xAxisId === axis.id || series.xAxisId === undefined && axisIndex === 0) {
|
|
15
|
+
return 'strict';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return 'nice';
|
|
20
|
+
};
|
|
21
|
+
exports.getAxisDomainLimit = getAxisDomainLimit;
|
|
@@ -3,6 +3,8 @@ export type * from "./useChartCartesianAxis.types.js";
|
|
|
3
3
|
export * from "./useChartCartesianAxisRendering.selectors.js";
|
|
4
4
|
export * from "./useChartCartesianAxisLayout.selectors.js";
|
|
5
5
|
export * from "./useChartCartesianInteraction.selectors.js";
|
|
6
|
+
export * from "./useChartCartesianHighlight.selectors.js";
|
|
7
|
+
export * from "./useChartCartesianAxisPreview.selectors.js";
|
|
6
8
|
export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
|
|
7
9
|
export * from "./computeAxisValue.js";
|
|
8
10
|
export * from "./createZoomLookup.js";
|