@mui/x-charts 8.13.1 → 8.14.1

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.
Files changed (134) hide show
  1. package/BarChart/BarChart.js +44 -36
  2. package/BarChart/useBarPlotData.js +20 -33
  3. package/CHANGELOG.md +204 -1
  4. package/ChartContainer/ChartContainer.js +68 -56
  5. package/ChartsTooltip/ChartsTooltipContainer.js +2 -0
  6. package/ChartsXAxis/useAxisTicksProps.d.ts +197 -355
  7. package/ChartsYAxis/useAxisTicksProps.d.ts +197 -355
  8. package/Gauge/Gauge.js +2 -9
  9. package/Gauge/GaugeReferenceArc.d.ts +4 -1
  10. package/Gauge/GaugeReferenceArc.js +12 -3
  11. package/Gauge/GaugeValueArc.d.ts +4 -1
  12. package/Gauge/GaugeValueArc.js +16 -8
  13. package/Gauge/GaugeValueText.js +3 -1
  14. package/LineChart/LineChart.js +44 -36
  15. package/PieChart/PieArc.d.ts +18 -4
  16. package/PieChart/PieArc.js +11 -5
  17. package/PieChart/PieArcPlot.js +3 -1
  18. package/ScatterChart/ScatterChart.js +44 -36
  19. package/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
  20. package/SparkLineChart/SparkLineChart.js +44 -36
  21. package/esm/BarChart/BarChart.js +44 -36
  22. package/esm/BarChart/useBarPlotData.js +20 -33
  23. package/esm/ChartContainer/ChartContainer.js +68 -56
  24. package/esm/ChartsTooltip/ChartsTooltipContainer.js +2 -0
  25. package/esm/ChartsXAxis/useAxisTicksProps.d.ts +197 -355
  26. package/esm/ChartsYAxis/useAxisTicksProps.d.ts +197 -355
  27. package/esm/Gauge/Gauge.js +2 -9
  28. package/esm/Gauge/GaugeReferenceArc.d.ts +4 -1
  29. package/esm/Gauge/GaugeReferenceArc.js +11 -2
  30. package/esm/Gauge/GaugeValueArc.d.ts +4 -1
  31. package/esm/Gauge/GaugeValueArc.js +16 -8
  32. package/esm/Gauge/GaugeValueText.js +3 -1
  33. package/esm/LineChart/LineChart.js +44 -36
  34. package/esm/PieChart/PieArc.d.ts +18 -4
  35. package/esm/PieChart/PieArc.js +11 -5
  36. package/esm/PieChart/PieArcPlot.js +3 -1
  37. package/esm/ScatterChart/ScatterChart.js +44 -36
  38. package/esm/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
  39. package/esm/SparkLineChart/SparkLineChart.js +44 -36
  40. package/esm/hooks/animation/useAnimate.js +5 -3
  41. package/esm/hooks/useScale.d.ts +5 -1
  42. package/esm/index.js +1 -1
  43. package/esm/internals/Flatbush.bench.d.ts +1 -0
  44. package/esm/internals/Flatbush.bench.js +42 -0
  45. package/esm/internals/Flatbush.d.ts +63 -0
  46. package/esm/internals/Flatbush.js +468 -0
  47. package/esm/internals/animation/useAnimateInternal.d.ts +1 -1
  48. package/esm/internals/animation/useAnimateInternal.js +1 -1
  49. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +8 -8
  50. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +4 -2
  51. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +9 -11
  52. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -28
  53. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +4 -5
  54. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +3 -24
  55. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +20 -0
  56. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +77 -0
  57. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +4 -65
  58. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +7 -104
  59. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
  60. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
  61. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -3
  62. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +31 -39
  63. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +185 -6
  64. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +199 -47
  65. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
  66. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
  67. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +33 -0
  68. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +40 -81
  69. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +10 -3
  70. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -4
  71. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -2
  72. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +6 -0
  73. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +5 -1
  74. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +9 -1
  75. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -1
  76. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -1
  77. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  78. package/esm/internals/scaleGuards.d.ts +12 -6
  79. package/esm/internals/symlogScale.js +5 -0
  80. package/esm/locales/enUS.js +4 -4
  81. package/esm/locales/ptBR.js +97 -99
  82. package/esm/models/axis.d.ts +39 -17
  83. package/esm/models/axis.js +3 -0
  84. package/esm/models/seriesType/scatter.d.ts +2 -0
  85. package/esm/themeAugmentation/components.d.ts +3 -0
  86. package/esm/themeAugmentation/overrides.d.ts +2 -0
  87. package/hooks/animation/useAnimate.js +4 -3
  88. package/hooks/useScale.d.ts +5 -1
  89. package/index.js +1 -1
  90. package/internals/Flatbush.bench.d.ts +1 -0
  91. package/internals/Flatbush.bench.js +44 -0
  92. package/internals/Flatbush.d.ts +63 -0
  93. package/internals/Flatbush.js +477 -0
  94. package/internals/animation/useAnimateInternal.d.ts +1 -1
  95. package/internals/animation/useAnimateInternal.js +1 -1
  96. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +7 -7
  97. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +4 -2
  98. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +9 -11
  99. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -28
  100. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +4 -5
  101. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +3 -25
  102. package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +20 -0
  103. package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +84 -0
  104. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +4 -65
  105. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -108
  106. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
  107. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
  108. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -3
  109. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +29 -37
  110. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +185 -6
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +200 -47
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
  113. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
  114. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +39 -0
  115. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +39 -80
  116. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +10 -3
  117. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -4
  118. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -2
  119. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +6 -0
  120. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +5 -1
  121. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +9 -1
  122. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -2
  123. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -1
  124. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -1
  125. package/internals/scaleGuards.d.ts +12 -6
  126. package/internals/symlogScale.js +5 -0
  127. package/locales/enUS.js +4 -4
  128. package/locales/ptBR.js +97 -99
  129. package/models/axis.d.ts +39 -17
  130. package/models/axis.js +4 -0
  131. package/models/seriesType/scatter.d.ts +2 -0
  132. package/package.json +7 -6
  133. package/themeAugmentation/components.d.ts +3 -0
  134. package/themeAugmentation/overrides.d.ts +2 -0
@@ -1,5 +1,8 @@
1
+ import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
1
2
  import { ZoomData } from "./zoom.types.js";
2
- import { AxisId } from "../../../../models/axis.js";
3
+ import { AxisId, D3Scale } from "../../../../models/axis.js";
4
+ import { SeriesId } from "../../../../models/seriesType/common.js";
5
+ import { Flatbush } from "../../../Flatbush.js";
3
6
  export declare const createZoomMap: (zoom: readonly ZoomData[]) => Map<AxisId, ZoomData>;
4
7
  /**
5
8
  * Following selectors are not exported because they exist in the MIT chart only to ba able to reuse the Zoom state from the pro.
@@ -14,6 +17,7 @@ export declare const selectorChartZoomMap: import("reselect").Selector<import(".
14
17
  } & {
15
18
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
16
19
  }, Map<AxisId, ZoomData> | undefined, []>;
20
+ export declare const selectorChartAxisZoomData: import("reselect").Selector<any, ZoomData | undefined, [axisId: AxisId]>;
17
21
  export declare const selectorChartZoomOptionsLookup: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
18
22
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
19
23
  } & {
@@ -33,21 +37,55 @@ export declare const selectorDefaultYAxisTickNumber: import("reselect").Selector
33
37
  } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
34
38
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
35
39
  }, number, []>;
36
- export declare const selectorChartXScales: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
40
+ type DomainDefinition = {
41
+ domain: ReadonlyArray<string | NumberValue>;
42
+ tickNumber?: number;
43
+ };
44
+ export declare const selectorChartXDomains: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
37
45
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
38
46
  } & Partial<{}> & {
39
47
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
40
- }, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, []>;
41
- export declare const selectorChartYScales: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
48
+ }, Record<AxisId, DomainDefinition>, []>;
49
+ export declare const selectorChartYDomains: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
42
50
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
43
51
  } & Partial<{}> & {
44
52
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
45
- }, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, []>;
53
+ }, Record<AxisId, DomainDefinition>, []>;
46
54
  export declare const selectorChartZoomAxisFilters: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
47
55
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
48
56
  } & {
49
57
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
50
58
  } & Partial<{}>, import("./zoom.types.js").GetZoomAxisFilters | undefined, []>;
59
+ export declare const selectorChartFilteredXDomains: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
60
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
61
+ } & Partial<{}> & {
62
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
63
+ }, Record<AxisId, readonly (string | NumberValue)[]>, []>;
64
+ export declare const selectorChartFilteredYDomains: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
65
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
66
+ } & Partial<{}> & {
67
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
68
+ }, Record<AxisId, readonly (string | NumberValue)[]>, []>;
69
+ export declare const selectorChartNormalizedXScales: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
70
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
71
+ } & Partial<{}> & {
72
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
73
+ }, Record<AxisId, D3Scale>, []>;
74
+ export declare const selectorChartNormalizedYScales: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
75
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
76
+ } & Partial<{}> & {
77
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
78
+ }, Record<AxisId, D3Scale>, []>;
79
+ export declare const selectorChartXScales: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
80
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
81
+ } & Partial<{}> & {
82
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
83
+ }, Record<AxisId, D3Scale>, []>;
84
+ export declare const selectorChartYScales: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
85
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
86
+ } & Partial<{}> & {
87
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
88
+ }, Record<AxisId, D3Scale>, []>;
51
89
  /**
52
90
  * The only interesting selectors that merge axis data and zoom if provided.
53
91
  */
@@ -62,4 +100,145 @@ export declare const selectorChartYAxis: import("reselect").Selector<import("../
62
100
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
63
101
  }, import("./computeAxisValue.js").ComputeResult<import("../../../index.js").ChartsYAxisProps>, []>;
64
102
  export declare const selectorChartAxis: import("reselect").Selector<any, import("../../../index.js").ComputedAxis<keyof import("../../../index.js").AxisScaleConfig, any, import("../../../index.js").ChartsXAxisProps>, [axisId: AxisId]>;
65
- export declare const selectorChartRawAxis: import("reselect").Selector<any, import("../../../index.js").DefaultedXAxis | import("../../../index.js").DefaultedYAxis | undefined, [axisId: AxisId]>;
103
+ export declare const selectorChartRawAxis: import("reselect").Selector<any, ({
104
+ offset?: number;
105
+ } & {
106
+ id: AxisId;
107
+ data?: readonly any[] | undefined;
108
+ dataKey?: string;
109
+ valueFormatter?: (<TScaleName extends keyof import("../../../index.js").AxisScaleConfig>(value: any, context: import("../../../index.js").AxisValueFormatterContext<TScaleName>) => string) | undefined;
110
+ hideTooltip?: boolean;
111
+ reverse?: boolean;
112
+ domainLimit?: "nice" | "strict" | ((min: number, max: number) => {
113
+ min: number;
114
+ max: number;
115
+ });
116
+ ignoreTooltip?: boolean;
117
+ } & Omit<Partial<import("../../../index.js").ChartsXAxisProps>, "axisId"> & Partial<Omit<{
118
+ scaleType: "time";
119
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleTime<number, number>;
120
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
121
+ } | {
122
+ scaleType: "linear";
123
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleLinear<number, number>;
124
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
125
+ } | {
126
+ scaleType: "log";
127
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleLogarithmic<number, number>;
128
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
129
+ } | {
130
+ scaleType: "symlog";
131
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleSymLog<number, number>;
132
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
133
+ constant?: number;
134
+ } | {
135
+ scaleType: "pow";
136
+ scale: import("@mui/x-charts-vendor/d3-scale").ScalePower<number, number>;
137
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
138
+ } | {
139
+ scaleType: "sqrt";
140
+ scale: import("@mui/x-charts-vendor/d3-scale").ScalePower<number, number>;
141
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
142
+ } | {
143
+ scaleType: "utc";
144
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleTime<number, number>;
145
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
146
+ } | ({
147
+ scaleType: "band";
148
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleBand<{
149
+ toString(): string;
150
+ }>;
151
+ categoryGapRatio: number;
152
+ barGapRatio: number;
153
+ colorMap?: import("../../../../models/colorMapping.js").OrdinalColorConfig | import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
154
+ } & import("../../../index.js").AxisGroups & Pick<import("../../../../hooks/useTicks.js").TickParams, "tickPlacement" | "tickLabelPlacement">) | ({
155
+ scaleType: "point";
156
+ scale: import("@mui/x-charts-vendor/d3-scale").ScalePoint<{
157
+ toString(): string;
158
+ }>;
159
+ colorMap?: import("../../../../models/colorMapping.js").OrdinalColorConfig | import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
160
+ } & import("../../../index.js").AxisGroups), "scale">> & {
161
+ position?: "top" | "bottom" | "none";
162
+ height?: number;
163
+ } & import("../../../../hooks/useTicks.js").TickParams & import("../../../index.js").AxisConfigExtension & {
164
+ zoom: import("./useChartCartesianAxis.types.js").DefaultizedZoomOptions | undefined;
165
+ }) | ({
166
+ offset?: number;
167
+ } & {
168
+ id: AxisId;
169
+ data?: readonly any[] | undefined;
170
+ dataKey?: string;
171
+ valueFormatter?: (<TScaleName extends keyof import("../../../index.js").AxisScaleConfig>(value: any, context: import("../../../index.js").AxisValueFormatterContext<TScaleName>) => string) | undefined;
172
+ hideTooltip?: boolean;
173
+ reverse?: boolean;
174
+ domainLimit?: "nice" | "strict" | ((min: number, max: number) => {
175
+ min: number;
176
+ max: number;
177
+ });
178
+ ignoreTooltip?: boolean;
179
+ } & Omit<Partial<import("../../../index.js").ChartsYAxisProps>, "axisId"> & Partial<Omit<{
180
+ scaleType: "time";
181
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleTime<number, number>;
182
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
183
+ } | {
184
+ scaleType: "linear";
185
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleLinear<number, number>;
186
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
187
+ } | {
188
+ scaleType: "log";
189
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleLogarithmic<number, number>;
190
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
191
+ } | {
192
+ scaleType: "symlog";
193
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleSymLog<number, number>;
194
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
195
+ constant?: number;
196
+ } | {
197
+ scaleType: "pow";
198
+ scale: import("@mui/x-charts-vendor/d3-scale").ScalePower<number, number>;
199
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
200
+ } | {
201
+ scaleType: "sqrt";
202
+ scale: import("@mui/x-charts-vendor/d3-scale").ScalePower<number, number>;
203
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
204
+ } | {
205
+ scaleType: "utc";
206
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleTime<number, number>;
207
+ colorMap?: import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
208
+ } | ({
209
+ scaleType: "band";
210
+ scale: import("@mui/x-charts-vendor/d3-scale").ScaleBand<{
211
+ toString(): string;
212
+ }>;
213
+ categoryGapRatio: number;
214
+ barGapRatio: number;
215
+ colorMap?: import("../../../../models/colorMapping.js").OrdinalColorConfig | import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
216
+ } & import("../../../index.js").AxisGroups & Pick<import("../../../../hooks/useTicks.js").TickParams, "tickPlacement" | "tickLabelPlacement">) | ({
217
+ scaleType: "point";
218
+ scale: import("@mui/x-charts-vendor/d3-scale").ScalePoint<{
219
+ toString(): string;
220
+ }>;
221
+ colorMap?: import("../../../../models/colorMapping.js").OrdinalColorConfig | import("../../../../models/colorMapping.js").ContinuousColorConfig | import("../../../../models/colorMapping.js").PiecewiseColorConfig;
222
+ } & import("../../../index.js").AxisGroups), "scale">> & {
223
+ position?: "left" | "right" | "none";
224
+ width?: number;
225
+ } & import("../../../../hooks/useTicks.js").TickParams & import("../../../index.js").AxisConfigExtension & {
226
+ zoom: import("./useChartCartesianAxis.types.js").DefaultizedZoomOptions | undefined;
227
+ }) | undefined, [axisId: AxisId]>;
228
+ export declare const selectorChartDefaultXAxisId: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
229
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
230
+ } & {
231
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
232
+ }, AxisId, []>;
233
+ export declare const selectorChartDefaultYAxisId: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
234
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
235
+ } & {
236
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
237
+ }, AxisId, []>;
238
+ export declare const selectorChartSeriesEmptyFlatbushMap: () => Map<SeriesId, Flatbush>;
239
+ export declare const selectorChartSeriesFlatbushMap: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<{}> & {
240
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
241
+ } & {
242
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
243
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState>, Map<SeriesId, Flatbush>, any[]>;
244
+ export {};
@@ -1,14 +1,21 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
2
3
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
3
4
  import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
4
5
  import { createSelector } from "../../utils/selectors.js";
5
6
  import { computeAxisValue } from "./computeAxisValue.js";
6
- import { createAxisFilterMapper, createGetAxisFilters } from "./createAxisFilterMapper.js";
7
+ import { createContinuousScaleGetAxisFilter, createDiscreteScaleGetAxisFilter, createGetAxisFilters } from "./createAxisFilterMapper.js";
7
8
  import { createZoomLookup } from "./createZoomLookup.js";
9
+ import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
8
10
  import { selectorChartRawXAxis, selectorChartRawYAxis } from "./useChartCartesianAxisLayout.selectors.js";
9
11
  import { selectorPreferStrictDomainInLineCharts } from "../../corePlugins/useChartExperimentalFeature/index.js";
10
- import { getXAxesScales, getYAxesScales } from "./getAxisScale.js";
11
12
  import { getDefaultTickNumber } from "../../../ticks.js";
13
+ import { getNormalizedAxisScale, getRange } from "./getAxisScale.js";
14
+ import { isOrdinalScale } from "../../../scaleGuards.js";
15
+ import { zoomScaleRange } from "./zoom.js";
16
+ import { getAxisExtrema } from "./getAxisExtrema.js";
17
+ import { calculateFinalDomain, calculateInitialDomainAndTickNumber } from "./domain.js";
18
+ import { Flatbush } from "../../../Flatbush.js";
12
19
  export const createZoomMap = zoom => {
13
20
  const zoomItemMap = new Map();
14
21
  zoom.forEach(zoomItem => {
@@ -24,68 +31,187 @@ const selectorChartZoomState = state => state.zoom;
24
31
 
25
32
  export const selectorChartZoomIsInteracting = createSelector([selectorChartZoomState], zoom => zoom?.isInteracting);
26
33
  export const selectorChartZoomMap = createSelector([selectorChartZoomState], zoom => zoom?.zoomData && createZoomMap(zoom?.zoomData));
34
+ export const selectorChartAxisZoomData = createSelector([selectorChartZoomMap, (_, axisId) => axisId], (zoomMap, axisId) => zoomMap?.get(axisId));
27
35
  export const selectorChartZoomOptionsLookup = createSelector([selectorChartRawXAxis, selectorChartRawYAxis], (xAxis, yAxis) => _extends({}, createZoomLookup('x')(xAxis), createZoomLookup('y')(yAxis)));
28
36
  export const selectorChartAxisZoomOptionsLookup = createSelector([selectorChartZoomOptionsLookup, (_, axisId) => axisId], (axisLookup, axisId) => axisLookup[axisId]);
29
- const selectorChartXFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup], (zoomMap, zoomOptions) => zoomMap && zoomOptions && createAxisFilterMapper(zoomMap, zoomOptions, 'x'));
30
- const selectorChartYFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup], (zoomMap, zoomOptions) => zoomMap && zoomOptions && createAxisFilterMapper(zoomMap, zoomOptions, 'y'));
31
37
  export const selectorDefaultXAxisTickNumber = createSelector([selectorChartDrawingArea], function selectorDefaultXAxisTickNumber(drawingArea) {
32
38
  return getDefaultTickNumber(drawingArea.width);
33
39
  });
34
40
  export const selectorDefaultYAxisTickNumber = createSelector([selectorChartDrawingArea], function selectorDefaultYAxisTickNumber(drawingArea) {
35
41
  return getDefaultTickNumber(drawingArea.height);
36
42
  });
37
- export const selectorChartXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts, selectorDefaultXAxisTickNumber], function selectorChartXScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts, defaultTickNumber) {
38
- return getXAxesScales({
39
- drawingArea,
40
- formattedSeries,
41
- axis,
42
- seriesConfig,
43
- zoomMap,
44
- preferStrictDomainInLineCharts,
45
- defaultTickNumber
43
+ export const selectorChartXDomains = createSelector([selectorChartRawXAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorPreferStrictDomainInLineCharts, selectorDefaultXAxisTickNumber], function selectorChartXDomains(axes, formattedSeries, seriesConfig, preferStrictDomainInLineCharts, defaultTickNumber) {
44
+ const axisDirection = 'x';
45
+ const domains = {};
46
+ axes?.forEach((eachAxis, axisIndex) => {
47
+ const axis = eachAxis;
48
+ if (isBandScaleConfig(axis) || isPointScaleConfig(axis)) {
49
+ domains[axis.id] = {
50
+ domain: axis.data
51
+ };
52
+ return;
53
+ }
54
+ const axisExtrema = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
55
+ domains[axis.id] = calculateInitialDomainAndTickNumber(axis, 'x', axisIndex, formattedSeries, axisExtrema, defaultTickNumber, preferStrictDomainInLineCharts);
46
56
  });
57
+ return domains;
47
58
  });
48
- export const selectorChartYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts, selectorDefaultYAxisTickNumber], function selectorChartYScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts, defaultTickNumber) {
49
- return getYAxesScales({
50
- drawingArea,
51
- formattedSeries,
52
- axis,
53
- seriesConfig,
54
- zoomMap,
55
- preferStrictDomainInLineCharts,
56
- defaultTickNumber
59
+ export const selectorChartYDomains = createSelector([selectorChartRawYAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorPreferStrictDomainInLineCharts, selectorDefaultYAxisTickNumber], function selectorChartYDomains(axes, formattedSeries, seriesConfig, preferStrictDomainInLineCharts, defaultTickNumber) {
60
+ const axisDirection = 'y';
61
+ const domains = {};
62
+ axes?.forEach((eachAxis, axisIndex) => {
63
+ const axis = eachAxis;
64
+ if (isBandScaleConfig(axis) || isPointScaleConfig(axis)) {
65
+ domains[axis.id] = {
66
+ domain: axis.data
67
+ };
68
+ return;
69
+ }
70
+ const axisExtrema = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
71
+ domains[axis.id] = calculateInitialDomainAndTickNumber(axis, 'y', axisIndex, formattedSeries, axisExtrema, defaultTickNumber, preferStrictDomainInLineCharts);
57
72
  });
73
+ return domains;
58
74
  });
59
- export const selectorChartZoomAxisFilters = createSelector([selectorChartXFilter, selectorChartYFilter, selectorChartRawXAxis, selectorChartRawYAxis, selectorChartXScales, selectorChartYScales], (xMapper, yMapper, xAxis, yAxis, xScales, yScales) => {
60
- if (xMapper === undefined || yMapper === undefined) {
61
- // Early return if there is no zoom.
75
+ export const selectorChartZoomAxisFilters = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartRawXAxis, selectorChartRawYAxis, selectorChartXDomains, selectorChartYDomains], (zoomMap, zoomOptions, xAxis, yAxis, xDomains, yDomains) => {
76
+ if (!zoomMap || !zoomOptions) {
62
77
  return undefined;
63
78
  }
64
- const xFilters = xAxis?.reduce((acc, axis) => {
65
- const filter = xMapper(axis.id, axis.data, xScales[axis.id].scale);
66
- if (filter !== null) {
67
- acc[axis.id] = filter;
79
+ let hasFilter = false;
80
+ const filters = {};
81
+ const axes = [...(xAxis ?? []), ...(yAxis ?? [])];
82
+ for (let i = 0; i < axes.length; i += 1) {
83
+ const axis = axes[i];
84
+ if (!zoomOptions[axis.id] || zoomOptions[axis.id].filterMode !== 'discard') {
85
+ continue;
68
86
  }
69
- return acc;
70
- }, {});
71
- const yFilters = yAxis?.reduce((acc, axis) => {
72
- const filter = yMapper(axis.id, axis.data, yScales[axis.id].scale);
73
- if (filter !== null) {
74
- acc[axis.id] = filter;
87
+ const zoom = zoomMap.get(axis.id);
88
+ if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
89
+ // No zoom, or zoom with all data visible
90
+ continue;
75
91
  }
76
- return acc;
77
- }, {});
78
- if (Object.keys(xFilters ?? {}).length === 0 && Object.keys(yFilters ?? {}).length === 0) {
92
+ const axisDirection = i < (xAxis?.length ?? 0) ? 'x' : 'y';
93
+ if (axis.scaleType === 'band' || axis.scaleType === 'point') {
94
+ filters[axis.id] = createDiscreteScaleGetAxisFilter(axis.data, zoom.start, zoom.end, axisDirection);
95
+ } else {
96
+ const {
97
+ domain
98
+ } = axisDirection === 'x' ? xDomains[axis.id] : yDomains[axis.id];
99
+ filters[axis.id] = createContinuousScaleGetAxisFilter(
100
+ // For continuous scales, the domain is always a two-value array.
101
+ domain, zoom.start, zoom.end, axisDirection, axis.data);
102
+ }
103
+ hasFilter = true;
104
+ }
105
+ if (!hasFilter) {
79
106
  return undefined;
80
107
  }
81
- return createGetAxisFilters(_extends({}, xFilters, yFilters));
108
+ return createGetAxisFilters(filters);
109
+ });
110
+ export const selectorChartFilteredXDomains = createSelector([selectorChartRawXAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts, selectorChartXDomains], (axes, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, domains) => {
111
+ const filteredDomains = {};
112
+ axes?.forEach((axis, axisIndex) => {
113
+ const domain = domains[axis.id].domain;
114
+ if (isBandScaleConfig(axis) || isPointScaleConfig(axis)) {
115
+ filteredDomains[axis.id] = domain;
116
+ return;
117
+ }
118
+ const zoom = zoomMap?.get(axis.id);
119
+ const zoomOption = zoomOptions?.[axis.id];
120
+ const filter = zoom === undefined && !zoomOption ? getFilters : undefined; // Do not apply filtering if zoom is already defined.
121
+
122
+ if (!filter) {
123
+ filteredDomains[axis.id] = domain;
124
+ return;
125
+ }
126
+ const rawTickNumber = domains[axis.id].tickNumber;
127
+ const axisExtrema = getAxisExtrema(axis, 'x', seriesConfig, axisIndex, formattedSeries, filter);
128
+ filteredDomains[axis.id] = calculateFinalDomain(axis, 'x', axisIndex, formattedSeries, axisExtrema, rawTickNumber, preferStrictDomainInLineCharts);
129
+ });
130
+ return filteredDomains;
131
+ }, {
132
+ memoizeOptions: {
133
+ resultEqualityCheck: (a, b) => isDeepEqual(a, b)
134
+ }
135
+ });
136
+ export const selectorChartFilteredYDomains = createSelector([selectorChartRawYAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts, selectorChartYDomains], (axes, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, domains) => {
137
+ const filteredDomains = {};
138
+ axes?.forEach((axis, axisIndex) => {
139
+ const domain = domains[axis.id].domain;
140
+ if (isBandScaleConfig(axis) || isPointScaleConfig(axis)) {
141
+ filteredDomains[axis.id] = domain;
142
+ return;
143
+ }
144
+ const zoom = zoomMap?.get(axis.id);
145
+ const zoomOption = zoomOptions?.[axis.id];
146
+ const filter = zoom === undefined && !zoomOption ? getFilters : undefined; // Do not apply filtering if zoom is already defined.
147
+
148
+ if (!filter) {
149
+ filteredDomains[axis.id] = domain;
150
+ return;
151
+ }
152
+ const rawTickNumber = domains[axis.id].tickNumber;
153
+ const axisExtrema = getAxisExtrema(axis, 'y', seriesConfig, axisIndex, formattedSeries, filter);
154
+ filteredDomains[axis.id] = calculateFinalDomain(axis, 'y', axisIndex, formattedSeries, axisExtrema, rawTickNumber, preferStrictDomainInLineCharts);
155
+ });
156
+ return filteredDomains;
157
+ }, {
158
+ memoizeOptions: {
159
+ resultEqualityCheck: (a, b) => isDeepEqual(a, b)
160
+ }
161
+ });
162
+ export const selectorChartNormalizedXScales = createSelector([selectorChartRawXAxis, selectorChartFilteredXDomains], function selectorChartNormalizedXScales(axes, filteredDomains) {
163
+ const scales = {};
164
+ axes?.forEach(eachAxis => {
165
+ const axis = eachAxis;
166
+ const domain = filteredDomains[axis.id];
167
+ scales[axis.id] = getNormalizedAxisScale(axis, domain);
168
+ });
169
+ return scales;
170
+ });
171
+ export const selectorChartNormalizedYScales = createSelector([selectorChartRawYAxis, selectorChartFilteredYDomains], function selectorChartNormalizedYScales(axes, filteredDomains) {
172
+ const scales = {};
173
+ axes?.forEach(eachAxis => {
174
+ const axis = eachAxis;
175
+ const domain = filteredDomains[axis.id];
176
+ scales[axis.id] = getNormalizedAxisScale(axis, domain);
177
+ });
178
+ return scales;
179
+ });
180
+ export const selectorChartXScales = createSelector([selectorChartRawXAxis, selectorChartNormalizedXScales, selectorChartDrawingArea, selectorChartZoomMap], function selectorChartXScales(axes, normalizedScales, drawingArea, zoomMap) {
181
+ const scales = {};
182
+ axes?.forEach(eachAxis => {
183
+ const axis = eachAxis;
184
+ const zoom = zoomMap?.get(axis.id);
185
+ const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
186
+ const range = getRange(drawingArea, 'x', axis);
187
+ const scale = normalizedScales[axis.id].copy();
188
+ const zoomedRange = zoomScaleRange(range, zoomRange);
189
+ scale.range(zoomedRange);
190
+ scales[axis.id] = scale;
191
+ });
192
+ return scales;
193
+ });
194
+ export const selectorChartYScales = createSelector([selectorChartRawYAxis, selectorChartNormalizedYScales, selectorChartDrawingArea, selectorChartZoomMap], function selectorChartYScales(axes, normalizedScales, drawingArea, zoomMap) {
195
+ const scales = {};
196
+ axes?.forEach(eachAxis => {
197
+ const axis = eachAxis;
198
+ const zoom = zoomMap?.get(axis.id);
199
+ const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
200
+ const range = getRange(drawingArea, 'y', axis);
201
+ const scale = normalizedScales[axis.id].copy();
202
+ const scaleRange = isOrdinalScale(scale) ? range.reverse() : range;
203
+ const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
204
+ scale.range(zoomedRange);
205
+ scales[axis.id] = scale;
206
+ });
207
+ return scales;
82
208
  });
83
209
 
84
210
  /**
85
211
  * The only interesting selectors that merge axis data and zoom if provided.
86
212
  */
87
213
 
88
- export const selectorChartXAxis = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts, selectorChartXScales], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, scales) => computeAxisValue({
214
+ export const selectorChartXAxis = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartXDomains, selectorChartXScales], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, domains, scales) => computeAxisValue({
89
215
  scales,
90
216
  drawingArea,
91
217
  formattedSeries,
@@ -93,11 +219,9 @@ export const selectorChartXAxis = createSelector([selectorChartRawXAxis, selecto
93
219
  seriesConfig,
94
220
  axisDirection: 'x',
95
221
  zoomMap,
96
- zoomOptions,
97
- getFilters,
98
- preferStrictDomainInLineCharts
222
+ domains
99
223
  }));
100
- export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts, selectorChartYScales], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, scales) => computeAxisValue({
224
+ export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartYDomains, selectorChartYScales], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, domains, scales) => computeAxisValue({
101
225
  scales,
102
226
  drawingArea,
103
227
  formattedSeries,
@@ -105,9 +229,7 @@ export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selecto
105
229
  seriesConfig,
106
230
  axisDirection: 'y',
107
231
  zoomMap,
108
- zoomOptions,
109
- getFilters,
110
- preferStrictDomainInLineCharts
232
+ domains
111
233
  }));
112
234
  export const selectorChartAxis = createSelector([selectorChartXAxis, selectorChartYAxis, (_, axisId) => axisId], (xAxes, yAxes, axisId) => xAxes?.axis[axisId] ?? yAxes?.axis[axisId]);
113
235
  export const selectorChartRawAxis = createSelector([selectorChartRawXAxis, selectorChartRawYAxis, (state, axisId) => axisId], (xAxes, yAxes, axisId) => {
@@ -116,4 +238,34 @@ export const selectorChartRawAxis = createSelector([selectorChartRawXAxis, selec
116
238
  return undefined;
117
239
  }
118
240
  return axis;
241
+ });
242
+ export const selectorChartDefaultXAxisId = createSelector([selectorChartRawXAxis], xAxes => xAxes[0].id);
243
+ export const selectorChartDefaultYAxisId = createSelector([selectorChartRawYAxis], yAxes => yAxes[0].id);
244
+ const EMPTY_MAP = new Map();
245
+ export const selectorChartSeriesEmptyFlatbushMap = () => EMPTY_MAP;
246
+ export const selectorChartSeriesFlatbushMap = createSelector([selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId], function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId) {
247
+ // FIXME: Do we want to support non-scatter series here?
248
+ const validSeries = allSeries.scatter;
249
+ const flatbushMap = new Map();
250
+ if (!validSeries) {
251
+ return flatbushMap;
252
+ }
253
+ validSeries.seriesOrder.forEach(seriesId => {
254
+ const {
255
+ data,
256
+ xAxisId = defaultXAxisId,
257
+ yAxisId = defaultYAxisId
258
+ } = validSeries.series[seriesId];
259
+ const flatbush = new Flatbush(data.length);
260
+ const originalXScale = xAxesScaleMap[xAxisId];
261
+ const originalYScale = yAxesScaleMap[yAxisId];
262
+ for (const datum of data) {
263
+ // Add the points using a [0, 1] range so that we don't need to recreate the Flatbush structure when zooming.
264
+ // This doesn't happen in practice, though, because currently the scales depend on the drawing area.
265
+ flatbush.add(originalXScale(datum.x), originalYScale(datum.y));
266
+ }
267
+ flatbush.finish();
268
+ flatbushMap.set(seriesId, flatbush);
269
+ });
270
+ return flatbushMap;
119
271
  });
@@ -34,7 +34,10 @@ export const selectorChartAxisInteraction = createSelector([selectorChartsIntera
34
34
  */
35
35
 
36
36
  function valueGetter(value, axes, indexes, ids = axes.axisIds[0]) {
37
- return Array.isArray(ids) ? ids.map((id, axisIndex) => getAxisValue(axes.axis[id], value, indexes[axisIndex])) : getAxisValue(axes.axis[ids], value, indexes);
37
+ return Array.isArray(ids) ? ids.map((id, axisIndex) => {
38
+ const axis = axes.axis[id];
39
+ return getAxisValue(axis.scale, axis.data, value, indexes[axisIndex]);
40
+ }) : getAxisValue(axes.axis[ids].scale, axes.axis[ids].data, value, indexes);
38
41
  }
39
42
  export const selectorChartsInteractionXAxisValue = createSelector([selectorChartsInteractionPointerX, selectorChartXAxis, selectorChartsInteractionXAxisIndex, optionalGetAxisId], (x, xAxes, xIndex, id) => {
40
43
  if (x === null || xAxes.axisIds.length === 0) {
@@ -0,0 +1,5 @@
1
+ import { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
2
+ import { ScatterValueType } from "../../../../models/seriesType/scatter.js";
3
+ import { Flatbush } from "../../../Flatbush.js";
4
+ import { D3Scale } from "../../../../models/axis.js";
5
+ export declare function findClosestPoints(flatbush: Flatbush, drawingArea: Pick<ChartDrawingArea, 'top' | 'left' | 'width' | 'height'>, seriesData: readonly ScatterValueType[], xScale: D3Scale, yScale: D3Scale, xZoomStart: number, xZoomEnd: number, yZoomStart: number, yZoomEnd: number, svgPointX: number, svgPointY: number, maxRadius?: number, maxResults?: number): number[];
@@ -0,0 +1,33 @@
1
+ import { isOrdinalScale } from "../../../scaleGuards.js";
2
+ export function findClosestPoints(flatbush, drawingArea, seriesData, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPointX, svgPointY, maxRadius = Infinity, maxResults = 1) {
3
+ const originalXScale = xScale.copy();
4
+ const originalYScale = yScale.copy();
5
+ originalXScale.range([0, 1]);
6
+ originalYScale.range([0, 1]);
7
+ const excludeIfOutsideDrawingArea = function excludeIfOutsideDrawingArea(index) {
8
+ const x = originalXScale(seriesData[index].x);
9
+ const y = originalYScale(seriesData[index].y);
10
+ return x >= xZoomStart && x <= xZoomEnd && y >= yZoomStart && y <= yZoomEnd;
11
+ };
12
+
13
+ // We need to convert the distance from the original range [0, 1] to the current drawing area
14
+ // so the comparison is done on pixels instead of normalized values.
15
+ // fx and fy are the factors to convert the distance from [0, 1] to the current drawing area.
16
+ const fx = xScale.range()[1] - xScale.range()[0];
17
+ const fy = yScale.range()[1] - yScale.range()[0];
18
+ const fxSq = fx * fx;
19
+ const fySq = fy * fy;
20
+ function sqDistFn(dx, dy) {
21
+ return fxSq * dx * dx + fySq * dy * dy;
22
+ }
23
+ const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex].x));
24
+ const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex].y));
25
+ return flatbush.neighbors(pointX, pointY, maxResults, maxRadius != null ? maxRadius * maxRadius : Infinity, excludeIfOutsideDrawingArea, sqDistFn);
26
+ }
27
+ function invertScale(scale, value, getDataPoint) {
28
+ if (isOrdinalScale(scale)) {
29
+ const dataIndex = scale.bandwidth() === 0 ? Math.floor((value - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((value - Math.min(...scale.range())) / scale.step());
30
+ return getDataPoint(dataIndex);
31
+ }
32
+ return scale.invert(value);
33
+ }