@mui/x-charts 8.14.0 → 8.15.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.
Files changed (164) hide show
  1. package/BarChart/BarChart.js +8 -0
  2. package/BarChart/BarChart.plugins.d.ts +2 -1
  3. package/BarChart/BarChart.plugins.js +2 -1
  4. package/BarChart/useBarChartProps.js +4 -2
  5. package/BarChart/useBarPlotData.js +20 -33
  6. package/CHANGELOG.md +202 -0
  7. package/ChartContainer/ChartContainer.js +8 -0
  8. package/ChartContainer/useChartContainerProps.js +4 -2
  9. package/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
  10. package/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +9 -0
  11. package/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
  12. package/ChartsBrushOverlay/ChartsBrushOverlay.js +102 -0
  13. package/ChartsBrushOverlay/index.d.ts +4 -0
  14. package/ChartsBrushOverlay/index.js +19 -0
  15. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  16. package/ChartsReferenceLine/ChartsXReferenceLine.js +13 -8
  17. package/ChartsReferenceLine/ChartsYReferenceLine.js +13 -8
  18. package/ChartsReferenceLine/common.d.ts +3 -1
  19. package/ChartsReferenceLine/common.js +3 -1
  20. package/ChartsTooltip/ChartsTooltipContainer.js +20 -2
  21. package/ChartsXAxis/getVisibleLabels.js +45 -25
  22. package/Gauge/Gauge.js +2 -9
  23. package/Gauge/GaugeReferenceArc.d.ts +4 -1
  24. package/Gauge/GaugeReferenceArc.js +12 -3
  25. package/Gauge/GaugeValueArc.d.ts +4 -1
  26. package/Gauge/GaugeValueArc.js +16 -8
  27. package/Gauge/GaugeValueText.js +3 -1
  28. package/LineChart/LineChart.js +8 -0
  29. package/LineChart/LineChart.plugins.d.ts +2 -1
  30. package/LineChart/LineChart.plugins.js +2 -1
  31. package/LineChart/useLineChartProps.js +4 -2
  32. package/ScatterChart/ScatterChart.js +8 -0
  33. package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  34. package/ScatterChart/ScatterChart.plugins.js +2 -1
  35. package/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
  36. package/ScatterChart/useScatterChartProps.js +5 -3
  37. package/SparkLineChart/SparkLineChart.js +8 -0
  38. package/esm/BarChart/BarChart.js +8 -0
  39. package/esm/BarChart/BarChart.plugins.d.ts +2 -1
  40. package/esm/BarChart/BarChart.plugins.js +2 -1
  41. package/esm/BarChart/useBarChartProps.js +4 -2
  42. package/esm/BarChart/useBarPlotData.js +20 -33
  43. package/esm/ChartContainer/ChartContainer.js +8 -0
  44. package/esm/ChartContainer/useChartContainerProps.js +4 -2
  45. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
  46. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +2 -0
  47. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
  48. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +95 -0
  49. package/esm/ChartsBrushOverlay/index.d.ts +4 -0
  50. package/esm/ChartsBrushOverlay/index.js +2 -0
  51. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  52. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +14 -9
  53. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +14 -9
  54. package/esm/ChartsReferenceLine/common.d.ts +3 -1
  55. package/esm/ChartsReferenceLine/common.js +2 -0
  56. package/esm/ChartsTooltip/ChartsTooltipContainer.js +20 -2
  57. package/esm/ChartsXAxis/getVisibleLabels.js +45 -25
  58. package/esm/Gauge/Gauge.js +2 -9
  59. package/esm/Gauge/GaugeReferenceArc.d.ts +4 -1
  60. package/esm/Gauge/GaugeReferenceArc.js +11 -2
  61. package/esm/Gauge/GaugeValueArc.d.ts +4 -1
  62. package/esm/Gauge/GaugeValueArc.js +16 -8
  63. package/esm/Gauge/GaugeValueText.js +3 -1
  64. package/esm/LineChart/LineChart.js +8 -0
  65. package/esm/LineChart/LineChart.plugins.d.ts +2 -1
  66. package/esm/LineChart/LineChart.plugins.js +2 -1
  67. package/esm/LineChart/useLineChartProps.js +4 -2
  68. package/esm/ScatterChart/ScatterChart.js +8 -0
  69. package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  70. package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
  71. package/esm/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
  72. package/esm/ScatterChart/useScatterChartProps.js +5 -3
  73. package/esm/SparkLineChart/SparkLineChart.js +8 -0
  74. package/esm/hooks/index.d.ts +2 -1
  75. package/esm/hooks/index.js +2 -1
  76. package/esm/hooks/useBrush.d.ts +18 -0
  77. package/esm/hooks/useBrush.js +16 -0
  78. package/esm/index.d.ts +2 -1
  79. package/esm/index.js +2 -1
  80. package/esm/internals/Flatbush.d.ts +63 -0
  81. package/esm/internals/Flatbush.js +468 -0
  82. package/esm/internals/domUtils.d.ts +9 -4
  83. package/esm/internals/domUtils.js +115 -52
  84. package/esm/internals/index.d.ts +1 -0
  85. package/esm/internals/index.js +1 -0
  86. package/esm/internals/plugins/allPlugins.d.ts +4 -3
  87. package/esm/internals/plugins/allPlugins.js +2 -1
  88. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
  89. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
  90. package/esm/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
  91. package/esm/internals/plugins/featurePlugins/useChartBrush/index.js +3 -0
  92. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
  93. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +109 -0
  94. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
  95. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +75 -0
  96. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
  97. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +1 -0
  98. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  99. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  100. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
  101. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
  102. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
  103. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
  104. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
  105. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
  106. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +41 -0
  107. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  108. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
  109. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
  110. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
  111. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +33 -0
  112. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +40 -81
  113. package/esm/internals/plugins/utils/selectors.d.ts +1 -1
  114. package/esm/locales/elGR.js +97 -99
  115. package/esm/models/seriesType/scatter.d.ts +2 -0
  116. package/esm/tests/constants.js +1 -0
  117. package/esm/themeAugmentation/components.d.ts +3 -0
  118. package/esm/themeAugmentation/overrides.d.ts +2 -0
  119. package/hooks/index.d.ts +2 -1
  120. package/hooks/index.js +12 -0
  121. package/hooks/useBrush.d.ts +18 -0
  122. package/hooks/useBrush.js +21 -0
  123. package/index.d.ts +2 -1
  124. package/index.js +13 -1
  125. package/internals/Flatbush.d.ts +63 -0
  126. package/internals/Flatbush.js +477 -0
  127. package/internals/domUtils.d.ts +9 -4
  128. package/internals/domUtils.js +119 -54
  129. package/internals/index.d.ts +1 -0
  130. package/internals/index.js +12 -0
  131. package/internals/plugins/allPlugins.d.ts +4 -3
  132. package/internals/plugins/allPlugins.js +2 -1
  133. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
  134. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
  135. package/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
  136. package/internals/plugins/featurePlugins/useChartBrush/index.js +38 -0
  137. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
  138. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +117 -0
  139. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
  140. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +82 -0
  141. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
  142. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +5 -0
  143. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  144. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  145. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
  146. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
  147. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
  148. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
  149. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
  150. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
  151. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +43 -1
  152. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  153. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
  154. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
  155. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
  156. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +39 -0
  157. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +39 -80
  158. package/internals/plugins/utils/selectors.d.ts +1 -1
  159. package/locales/elGR.js +97 -99
  160. package/models/seriesType/scatter.d.ts +2 -0
  161. package/package.json +5 -4
  162. package/tests/constants.js +7 -0
  163. package/themeAugmentation/components.d.ts +3 -0
  164. package/themeAugmentation/overrides.d.ts +2 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorIsBrushSelectionActive = exports.selectorIsBrushEnabled = exports.selectorBrushState = exports.selectorBrushStartY = exports.selectorBrushStartX = exports.selectorBrushStart = exports.selectorBrushShouldPreventTooltip = exports.selectorBrushShouldPreventAxisHighlight = exports.selectorBrushCurrentY = exports.selectorBrushCurrentX = exports.selectorBrushCurrent = exports.selectorBrushConfigZoom = exports.selectorBrushConfigNoZoom = exports.selectorBrushConfig = exports.selectorBrush = void 0;
7
+ var _selectors = require("../../utils/selectors");
8
+ var _useChartCartesianAxis = require("../useChartCartesianAxis");
9
+ var _useChartSeries = require("../../corePlugins/useChartSeries");
10
+ const selectorBrush = state => state.brush;
11
+ exports.selectorBrush = selectorBrush;
12
+ const selectorBrushStart = exports.selectorBrushStart = (0, _selectors.createSelector)([selectorBrush], brush => brush?.start);
13
+ const selectorBrushCurrent = exports.selectorBrushCurrent = (0, _selectors.createSelector)([selectorBrush], brush => brush?.current);
14
+ const selectorBrushStartX = exports.selectorBrushStartX = (0, _selectors.createSelector)([selectorBrush], brush => brush?.start?.x ?? null);
15
+ const selectorBrushStartY = exports.selectorBrushStartY = (0, _selectors.createSelector)([selectorBrush], brush => brush?.start?.y ?? null);
16
+ const selectorBrushCurrentX = exports.selectorBrushCurrentX = (0, _selectors.createSelector)([selectorBrush], brush => brush?.current?.x ?? null);
17
+ const selectorBrushCurrentY = exports.selectorBrushCurrentY = (0, _selectors.createSelector)([selectorBrush], brush => brush?.current?.y ?? null);
18
+ const selectorBrushState = exports.selectorBrushState = (0, _selectors.createSelector)([selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY], (startX, startY, currentX, currentY) => {
19
+ if (startX === null || startY === null || currentX === null || currentY === null) {
20
+ return null;
21
+ }
22
+ return {
23
+ start: {
24
+ x: startX,
25
+ y: startY
26
+ },
27
+ current: {
28
+ x: currentX,
29
+ y: currentY
30
+ }
31
+ };
32
+ });
33
+ const selectorBrushConfigNoZoom = exports.selectorBrushConfigNoZoom = (0, _selectors.createSelector)([_useChartSeries.selectorChartSeriesProcessed], series => {
34
+ let hasHorizontal = false;
35
+ let isBothDirections = false;
36
+ if (series) {
37
+ Object.entries(series).forEach(([seriesType, seriesData]) => {
38
+ if (Object.values(seriesData.series).some(s => s.layout === 'horizontal')) {
39
+ hasHorizontal = true;
40
+ }
41
+ if (seriesType === 'scatter' && seriesData.seriesOrder.length > 0) {
42
+ isBothDirections = true;
43
+ }
44
+ });
45
+ }
46
+ if (isBothDirections) {
47
+ return 'xy';
48
+ }
49
+ if (hasHorizontal) {
50
+ return 'y';
51
+ }
52
+ return 'x';
53
+ });
54
+ const selectorBrushConfigZoom = exports.selectorBrushConfigZoom = (0, _selectors.createSelector)([_useChartCartesianAxis.selectorChartZoomOptionsLookup], optionsLookup => {
55
+ let hasX = false;
56
+ let hasY = false;
57
+ Object.values(optionsLookup).forEach(options => {
58
+ if (options.axisDirection === 'y') {
59
+ hasY = true;
60
+ }
61
+ if (options.axisDirection === 'x') {
62
+ hasX = true;
63
+ }
64
+ });
65
+ if (hasX && hasY) {
66
+ return 'xy';
67
+ }
68
+ if (hasY) {
69
+ return 'y';
70
+ }
71
+ if (hasX) {
72
+ return 'x';
73
+ }
74
+ return null;
75
+ });
76
+ const selectorBrushConfig = exports.selectorBrushConfig = (0, _selectors.createSelector)([selectorBrushConfigNoZoom, selectorBrushConfigZoom], (configNoZoom, configZoom) => configZoom ?? configNoZoom);
77
+ const selectorIsBrushEnabled = exports.selectorIsBrushEnabled = (0, _selectors.createSelector)([selectorBrush], brush => brush?.enabled);
78
+ const selectorIsBrushSelectionActive = exports.selectorIsBrushSelectionActive = (0, _selectors.createSelector)([selectorBrush], brush => {
79
+ return brush?.enabled && brush?.start !== null && brush?.current !== null;
80
+ });
81
+ const selectorBrushShouldPreventAxisHighlight = exports.selectorBrushShouldPreventAxisHighlight = (0, _selectors.createSelector)([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
82
+ const selectorBrushShouldPreventTooltip = exports.selectorBrushShouldPreventTooltip = (0, _selectors.createSelector)([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
@@ -0,0 +1,72 @@
1
+ import { ChartPluginSignature } from "../../models/index.js";
2
+ export type Point = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export interface UseChartBrushState {
7
+ brush: {
8
+ /**
9
+ * Whether the brush interaction is enabled.
10
+ */
11
+ enabled: boolean;
12
+ /**
13
+ * Whether to prevent tooltip from showing during brush interaction.
14
+ */
15
+ preventTooltip: boolean;
16
+ /**
17
+ * Whether to prevent highlighting during brush interaction.
18
+ */
19
+ preventHighlight: boolean;
20
+ /**
21
+ * The starting coordinate of the brush interaction.
22
+ */
23
+ start: Point | null;
24
+ /**
25
+ * The current coordinate of the brush interaction.
26
+ */
27
+ current: Point | null;
28
+ };
29
+ }
30
+ export interface UseChartBrushInstance {
31
+ /**
32
+ * Set the brush coordinates.
33
+ * @param {Point | null} point The point coordinate, if start value is null, it will set both start and current to this value.
34
+ */
35
+ setBrushCoordinates: (point: Point | null) => void;
36
+ /**
37
+ * Clear the brush coordinates.
38
+ */
39
+ clearBrush: () => void;
40
+ }
41
+ export interface BrushConfig {
42
+ /**
43
+ * Whether the brush interaction is enabled.
44
+ * @default false
45
+ */
46
+ enabled?: boolean;
47
+ /**
48
+ * Whether to prevent tooltip from showing during brush interaction.
49
+ * @default false
50
+ */
51
+ preventTooltip?: boolean;
52
+ /**
53
+ * Whether to prevent highlighting during brush interaction.
54
+ * @default false
55
+ */
56
+ preventHighlight?: boolean;
57
+ }
58
+ export interface UseChartBrushParameters {
59
+ /**
60
+ * Configuration for the brush interaction.
61
+ */
62
+ brushConfig?: BrushConfig;
63
+ }
64
+ export type UseChartBrushDefaultizedParameters = {
65
+ brushConfig: Required<BrushConfig>;
66
+ };
67
+ export type UseChartBrushSignature = ChartPluginSignature<{
68
+ params: UseChartBrushParameters;
69
+ defaultizedParams: UseChartBrushDefaultizedParameters;
70
+ state: UseChartBrushState;
71
+ instance: UseChartBrushInstance;
72
+ }>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -9,9 +9,10 @@ const createZoomLookup = axisDirection => (axes = []) => axes.reduce((acc, v) =>
9
9
  // @ts-ignore
10
10
  const {
11
11
  zoom,
12
- id: axisId
12
+ id: axisId,
13
+ reverse
13
14
  } = v;
14
- const defaultizedZoom = (0, _defaultizeZoom.defaultizeZoom)(zoom, axisId, axisDirection);
15
+ const defaultizedZoom = (0, _defaultizeZoom.defaultizeZoom)(zoom, axisId, axisDirection, reverse);
15
16
  if (defaultizedZoom) {
16
17
  acc[axisId] = defaultizedZoom;
17
18
  }
@@ -33,7 +33,7 @@ function defaultizeXAxis(inAxes, dataset) {
33
33
  id,
34
34
  position,
35
35
  height: axisConfig.height ?? defaultHeight,
36
- zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x')
36
+ zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x', axisConfig.reverse)
37
37
  });
38
38
 
39
39
  // Increment the offset for the next axis
@@ -83,7 +83,7 @@ function defaultizeYAxis(inAxes, dataset) {
83
83
  id,
84
84
  position,
85
85
  width: axisConfig.width ?? defaultWidth,
86
- zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y')
86
+ zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y', axisConfig.reverse)
87
87
  });
88
88
 
89
89
  // Increment the offset for the next axis
@@ -9,6 +9,7 @@ export declare const defaultZoomOptions: {
9
9
  maxSpan: number;
10
10
  panning: true;
11
11
  filterMode: "keep";
12
+ reverse: false;
12
13
  slider: {
13
14
  enabled: false;
14
15
  preview: false;
@@ -16,4 +17,4 @@ export declare const defaultZoomOptions: {
16
17
  showTooltip: import("./zoom.types.js").ZoomSliderShowTooltip;
17
18
  };
18
19
  };
19
- export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y") => DefaultizedZoomOptions | undefined;
20
+ export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y", reverse?: boolean) => DefaultizedZoomOptions | undefined;
@@ -15,6 +15,7 @@ const defaultZoomOptions = exports.defaultZoomOptions = {
15
15
  maxSpan: 100,
16
16
  panning: true,
17
17
  filterMode: 'keep',
18
+ reverse: false,
18
19
  slider: {
19
20
  enabled: false,
20
21
  preview: false,
@@ -22,7 +23,7 @@ const defaultZoomOptions = exports.defaultZoomOptions = {
22
23
  showTooltip: _constants.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP
23
24
  }
24
25
  };
25
- const defaultizeZoom = (zoom, axisId, axisDirection) => {
26
+ const defaultizeZoom = (zoom, axisId, axisDirection, reverse) => {
26
27
  if (!zoom) {
27
28
  return undefined;
28
29
  }
@@ -30,12 +31,16 @@ const defaultizeZoom = (zoom, axisId, axisDirection) => {
30
31
  return (0, _extends2.default)({
31
32
  axisId,
32
33
  axisDirection
33
- }, defaultZoomOptions);
34
+ }, defaultZoomOptions, {
35
+ reverse: reverse ?? false
36
+ });
34
37
  }
35
38
  return (0, _extends2.default)({
36
39
  axisId,
37
40
  axisDirection
38
- }, defaultZoomOptions, zoom, {
41
+ }, defaultZoomOptions, {
42
+ reverse: reverse ?? false
43
+ }, zoom, {
39
44
  slider: (0, _extends2.default)({}, defaultZoomOptions.slider, {
40
45
  size: zoom.slider?.preview ?? defaultZoomOptions.slider.preview ? _constants.DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE : _constants.DEFAULT_ZOOM_SLIDER_SIZE
41
46
  }, zoom.slider)
@@ -1,4 +1,4 @@
1
- import { ComputedAxis } from "../../../../models/axis.js";
1
+ import { ComputedAxis, D3Scale } from "../../../../models/axis.js";
2
2
  /**
3
3
  * For a pointer coordinate, this function returns the dataIndex associated.
4
4
  * Returns `-1` if no dataIndex matches.
@@ -8,4 +8,8 @@ export declare function getAxisIndex(axisConfig: ComputedAxis, pointerValue: num
8
8
  * For a pointer coordinate, this function returns the value associated.
9
9
  * Returns `null` if the coordinate has no value associated.
10
10
  */
11
- export declare function getAxisValue(axisConfig: ComputedAxis, pointerValue: number, dataIndex: number | null): number | Date | null;
11
+ export declare function getAxisValue<Domain extends {
12
+ toString(): string;
13
+ } = {
14
+ toString(): string;
15
+ }, Range = number, Output = number>(scale: D3Scale<Domain, Range, Output>, axisData: readonly any[] | undefined, pointerValue: number, dataIndex: number | null): number | Date | null;
@@ -53,14 +53,11 @@ function getAxisIndex(axisConfig, pointerValue) {
53
53
  * For a pointer coordinate, this function returns the value associated.
54
54
  * Returns `null` if the coordinate has no value associated.
55
55
  */
56
- function getAxisValue(axisConfig, pointerValue, dataIndex) {
57
- const {
58
- scale,
59
- data: axisData
60
- } = axisConfig;
56
+ function getAxisValue(scale, axisData, pointerValue, dataIndex) {
61
57
  if (!(0, _scaleGuards.isOrdinalScale)(scale)) {
62
58
  if (dataIndex === null) {
63
- return scale.invert(pointerValue);
59
+ const invertedValue = scale.invert(pointerValue);
60
+ return Number.isNaN(invertedValue) ? null : invertedValue;
64
61
  }
65
62
  return axisData[dataIndex];
66
63
  }
@@ -5,6 +5,7 @@ import type { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/i
5
5
  import type { ZoomData, ZoomOptions, ZoomSliderShowTooltip } from "./zoom.types.js";
6
6
  import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
7
7
  import type { ChartsAxisProps } from "../../../../ChartsAxis/index.js";
8
+ import type { UseChartBrushSignature } from "../useChartBrush/index.js";
8
9
  /**
9
10
  * The axes' configuration after computing.
10
11
  * An axis in this state already contains a scale function and all the necessary properties to be rendered.
@@ -67,6 +68,7 @@ export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slid
67
68
  axisId: AxisId;
68
69
  axisDirection: 'x' | 'y';
69
70
  slider: DefaultedZoomSliderOptions;
71
+ reverse: boolean;
70
72
  }
71
73
  export interface UseChartCartesianAxisState {
72
74
  /**
@@ -94,5 +96,5 @@ export type UseChartCartesianAxisSignature<SeriesType extends ChartSeriesType =
94
96
  defaultizedParams: UseChartCartesianAxisDefaultizedParameters;
95
97
  state: UseChartCartesianAxisState;
96
98
  dependencies: [UseChartSeriesSignature<SeriesType>];
97
- optionalDependencies: [UseChartInteractionSignature];
99
+ optionalDependencies: [UseChartInteractionSignature, UseChartBrushSignature];
98
100
  }>;
@@ -1,6 +1,8 @@
1
1
  import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
2
2
  import { ZoomData } from "./zoom.types.js";
3
3
  import { AxisId, D3Scale } from "../../../../models/axis.js";
4
+ import { SeriesId } from "../../../../models/seriesType/common.js";
5
+ import { Flatbush } from "../../../Flatbush.js";
4
6
  export declare const createZoomMap: (zoom: readonly ZoomData[]) => Map<AxisId, ZoomData>;
5
7
  /**
6
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.
@@ -15,6 +17,7 @@ export declare const selectorChartZoomMap: import("reselect").Selector<import(".
15
17
  } & {
16
18
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
17
19
  }, Map<AxisId, ZoomData> | undefined, []>;
20
+ export declare const selectorChartAxisZoomData: import("reselect").Selector<any, ZoomData | undefined, [axisId: AxisId]>;
18
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> & {
19
22
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
20
23
  } & {
@@ -222,4 +225,20 @@ export declare const selectorChartRawAxis: import("reselect").Selector<any, ({
222
225
  } & import("../../../../hooks/useTicks.js").TickParams & import("../../../index.js").AxisConfigExtension & {
223
226
  zoom: import("./useChartCartesianAxis.types.js").DefaultizedZoomOptions | undefined;
224
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[]>;
225
244
  export {};
@@ -4,8 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.selectorDefaultYAxisTickNumber = exports.selectorDefaultXAxisTickNumber = exports.selectorChartZoomOptionsLookup = exports.selectorChartZoomMap = exports.selectorChartZoomIsInteracting = exports.selectorChartZoomAxisFilters = exports.selectorChartYScales = exports.selectorChartYDomains = exports.selectorChartYAxis = exports.selectorChartXScales = exports.selectorChartXDomains = exports.selectorChartXAxis = exports.selectorChartRawAxis = exports.selectorChartNormalizedYScales = exports.selectorChartNormalizedXScales = exports.selectorChartFilteredYDomains = exports.selectorChartFilteredXDomains = exports.selectorChartAxisZoomOptionsLookup = exports.selectorChartAxis = exports.createZoomMap = void 0;
7
+ exports.selectorDefaultYAxisTickNumber = exports.selectorDefaultXAxisTickNumber = exports.selectorChartZoomOptionsLookup = exports.selectorChartZoomMap = exports.selectorChartZoomIsInteracting = exports.selectorChartZoomAxisFilters = exports.selectorChartYScales = exports.selectorChartYDomains = exports.selectorChartYAxis = exports.selectorChartXScales = exports.selectorChartXDomains = exports.selectorChartXAxis = exports.selectorChartSeriesFlatbushMap = exports.selectorChartSeriesEmptyFlatbushMap = exports.selectorChartRawAxis = exports.selectorChartNormalizedYScales = exports.selectorChartNormalizedXScales = exports.selectorChartFilteredYDomains = exports.selectorChartFilteredXDomains = exports.selectorChartDefaultYAxisId = exports.selectorChartDefaultXAxisId = exports.selectorChartAxisZoomOptionsLookup = exports.selectorChartAxisZoomData = exports.selectorChartAxis = exports.createZoomMap = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
9
10
  var _useChartDimensions = require("../../corePlugins/useChartDimensions");
10
11
  var _useChartSeries = require("../../corePlugins/useChartSeries");
11
12
  var _selectors = require("../../utils/selectors");
@@ -21,6 +22,7 @@ var _scaleGuards = require("../../../scaleGuards");
21
22
  var _zoom = require("./zoom");
22
23
  var _getAxisExtrema = require("./getAxisExtrema");
23
24
  var _domain = require("./domain");
25
+ var _Flatbush = require("../../../Flatbush");
24
26
  const createZoomMap = zoom => {
25
27
  const zoomItemMap = new Map();
26
28
  zoom.forEach(zoomItem => {
@@ -37,6 +39,7 @@ const selectorChartZoomState = state => state.zoom;
37
39
 
38
40
  const selectorChartZoomIsInteracting = exports.selectorChartZoomIsInteracting = (0, _selectors.createSelector)([selectorChartZoomState], zoom => zoom?.isInteracting);
39
41
  const selectorChartZoomMap = exports.selectorChartZoomMap = (0, _selectors.createSelector)([selectorChartZoomState], zoom => zoom?.zoomData && createZoomMap(zoom?.zoomData));
42
+ const selectorChartAxisZoomData = exports.selectorChartAxisZoomData = (0, _selectors.createSelector)([selectorChartZoomMap, (_, axisId) => axisId], (zoomMap, axisId) => zoomMap?.get(axisId));
40
43
  const selectorChartZoomOptionsLookup = exports.selectorChartZoomOptionsLookup = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartCartesianAxisLayout.selectorChartRawYAxis], (xAxis, yAxis) => (0, _extends2.default)({}, (0, _createZoomLookup.createZoomLookup)('x')(xAxis), (0, _createZoomLookup.createZoomLookup)('y')(yAxis)));
41
44
  const selectorChartAxisZoomOptionsLookup = exports.selectorChartAxisZoomOptionsLookup = (0, _selectors.createSelector)([selectorChartZoomOptionsLookup, (_, axisId) => axisId], (axisLookup, axisId) => axisLookup[axisId]);
42
45
  const selectorDefaultXAxisTickNumber = exports.selectorDefaultXAxisTickNumber = (0, _selectors.createSelector)([_useChartDimensions.selectorChartDrawingArea], function selectorDefaultXAxisTickNumber(drawingArea) {
@@ -133,6 +136,10 @@ const selectorChartFilteredXDomains = exports.selectorChartFilteredXDomains = (0
133
136
  filteredDomains[axis.id] = (0, _domain.calculateFinalDomain)(axis, 'x', axisIndex, formattedSeries, axisExtrema, rawTickNumber, preferStrictDomainInLineCharts);
134
137
  });
135
138
  return filteredDomains;
139
+ }, {
140
+ memoizeOptions: {
141
+ resultEqualityCheck: (a, b) => (0, _isDeepEqual.isDeepEqual)(a, b)
142
+ }
136
143
  });
137
144
  const selectorChartFilteredYDomains = exports.selectorChartFilteredYDomains = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, _useChartExperimentalFeature.selectorPreferStrictDomainInLineCharts, selectorChartYDomains], (axes, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, domains) => {
138
145
  const filteredDomains = {};
@@ -155,6 +162,10 @@ const selectorChartFilteredYDomains = exports.selectorChartFilteredYDomains = (0
155
162
  filteredDomains[axis.id] = (0, _domain.calculateFinalDomain)(axis, 'y', axisIndex, formattedSeries, axisExtrema, rawTickNumber, preferStrictDomainInLineCharts);
156
163
  });
157
164
  return filteredDomains;
165
+ }, {
166
+ memoizeOptions: {
167
+ resultEqualityCheck: (a, b) => (0, _isDeepEqual.isDeepEqual)(a, b)
168
+ }
158
169
  });
159
170
  const selectorChartNormalizedXScales = exports.selectorChartNormalizedXScales = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis, selectorChartFilteredXDomains], function selectorChartNormalizedXScales(axes, filteredDomains) {
160
171
  const scales = {};
@@ -235,4 +246,35 @@ const selectorChartRawAxis = exports.selectorChartRawAxis = (0, _selectors.creat
235
246
  return undefined;
236
247
  }
237
248
  return axis;
249
+ });
250
+ const selectorChartDefaultXAxisId = exports.selectorChartDefaultXAxisId = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis], xAxes => xAxes[0].id);
251
+ const selectorChartDefaultYAxisId = exports.selectorChartDefaultYAxisId = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis], yAxes => yAxes[0].id);
252
+ const EMPTY_MAP = new Map();
253
+ const selectorChartSeriesEmptyFlatbushMap = () => EMPTY_MAP;
254
+ exports.selectorChartSeriesEmptyFlatbushMap = selectorChartSeriesEmptyFlatbushMap;
255
+ const selectorChartSeriesFlatbushMap = exports.selectorChartSeriesFlatbushMap = (0, _selectors.createSelector)([_useChartSeries.selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId], function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId) {
256
+ // FIXME: Do we want to support non-scatter series here?
257
+ const validSeries = allSeries.scatter;
258
+ const flatbushMap = new Map();
259
+ if (!validSeries) {
260
+ return flatbushMap;
261
+ }
262
+ validSeries.seriesOrder.forEach(seriesId => {
263
+ const {
264
+ data,
265
+ xAxisId = defaultXAxisId,
266
+ yAxisId = defaultYAxisId
267
+ } = validSeries.series[seriesId];
268
+ const flatbush = new _Flatbush.Flatbush(data.length);
269
+ const originalXScale = xAxesScaleMap[xAxisId];
270
+ const originalYScale = yAxesScaleMap[yAxisId];
271
+ for (const datum of data) {
272
+ // Add the points using a [0, 1] range so that we don't need to recreate the Flatbush structure when zooming.
273
+ // This doesn't happen in practice, though, because currently the scales depend on the drawing area.
274
+ flatbush.add(originalXScale(datum.x), originalYScale(datum.y));
275
+ }
276
+ flatbush.finish();
277
+ flatbushMap.set(seriesId, flatbush);
278
+ });
279
+ return flatbushMap;
238
280
  });
@@ -3,17 +3,17 @@ export declare const selectorChartsHighlightXAxisIndex: import("reselect").Selec
3
3
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
4
4
  } & {
5
5
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
6
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
6
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
7
7
  export declare const selectorChartsHighlightYAxisIndex: 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("../useChartInteraction/useChartInteraction.types.js").UseChartInteractionState> & {
8
8
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
9
  } & {
10
10
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
11
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
11
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
12
12
  export declare const selectorChartsHighlightXAxisValue: 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("../useChartInteraction/useChartInteraction.types.js").UseChartInteractionState> & {
13
13
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
14
14
  } & {
15
15
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
16
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
16
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, {
17
17
  value: any;
18
18
  axisId: import("../../../index.js").AxisId;
19
19
  dataIndex: number;
@@ -26,7 +26,7 @@ export declare const selectorChartsHighlightYAxisValue: import("reselect").Selec
26
26
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
27
27
  } & {
28
28
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
29
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
29
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, {
30
30
  value: any;
31
31
  axisId: import("../../../index.js").AxisId;
32
32
  dataIndex: number;
@@ -11,8 +11,12 @@ var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.
11
11
  var _useChartCartesianInteraction = require("./useChartCartesianInteraction.selectors");
12
12
  var _useChartKeyboardNavigation = require("../useChartKeyboardNavigation/useChartKeyboardNavigation.selectors");
13
13
  var _useChartInteraction = require("../useChartInteraction/useChartInteraction.selectors");
14
+ var _useChartBrush = require("../useChartBrush");
14
15
  const selectorChartControlledCartesianAxisHighlight = state => state.controlledCartesianAxisHighlight;
15
- const selectAxisHighlight = (computedIndex, axis, axisItems) => {
16
+ const selectAxisHighlight = (computedIndex, axis, axisItems, isBrushSelectionActive) => {
17
+ if (isBrushSelectionActive) {
18
+ return [];
19
+ }
16
20
  if (axisItems !== undefined) {
17
21
  return axisItems.filter(item => axis.axis[item.axisId] !== undefined).map(item => item);
18
22
  }
@@ -21,9 +25,12 @@ const selectAxisHighlight = (computedIndex, axis, axisItems) => {
21
25
  dataIndex: computedIndex
22
26
  }];
23
27
  };
24
- const selectorChartsHighlightXAxisIndex = exports.selectorChartsHighlightXAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlight);
25
- const selectorChartsHighlightYAxisIndex = exports.selectorChartsHighlightYAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlight);
26
- const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, controlledAxisItems, keyboardAxisItem, lastInteractionUpdate) => {
28
+ const selectorChartsHighlightXAxisIndex = exports.selectorChartsHighlightXAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlight);
29
+ const selectorChartsHighlightYAxisIndex = exports.selectorChartsHighlightYAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlight);
30
+ const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, controlledAxisItems, keyboardAxisItem, lastInteractionUpdate, isBrushSelectionActive) => {
31
+ if (isBrushSelectionActive) {
32
+ return [];
33
+ }
27
34
  if (controlledAxisItems !== undefined) {
28
35
  return controlledAxisItems.map(item => (0, _extends2.default)({}, item, {
29
36
  value: axis.axis[item.axisId]?.data?.[item.dataIndex]
@@ -58,8 +65,8 @@ const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, contro
58
65
  }
59
66
  return [];
60
67
  };
61
- const selectorChartsHighlightXAxisValue = exports.selectorChartsHighlightXAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionXAxisValue, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardXAxisIndex, _useChartInteraction.selectorChartsLastInteraction], selectAxisHighlightWithValue);
62
- const selectorChartsHighlightYAxisValue = exports.selectorChartsHighlightYAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionYAxisValue, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardYAxisIndex, _useChartInteraction.selectorChartsLastInteraction], selectAxisHighlightWithValue);
68
+ const selectorChartsHighlightXAxisValue = exports.selectorChartsHighlightXAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionXAxisValue, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardXAxisIndex, _useChartInteraction.selectorChartsLastInteraction, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlightWithValue);
69
+ const selectorChartsHighlightYAxisValue = exports.selectorChartsHighlightYAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionYAxisValue, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardYAxisIndex, _useChartInteraction.selectorChartsLastInteraction, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlightWithValue);
63
70
 
64
71
  /**
65
72
  * Get the scale of the axis with highlight if controlled. The default axis otherwise.
@@ -41,7 +41,10 @@ const selectorChartAxisInteraction = exports.selectorChartAxisInteraction = (0,
41
41
  */
42
42
 
43
43
  function valueGetter(value, axes, indexes, ids = axes.axisIds[0]) {
44
- return Array.isArray(ids) ? ids.map((id, axisIndex) => (0, _getAxisValue.getAxisValue)(axes.axis[id], value, indexes[axisIndex])) : (0, _getAxisValue.getAxisValue)(axes.axis[ids], value, indexes);
44
+ return Array.isArray(ids) ? ids.map((id, axisIndex) => {
45
+ const axis = axes.axis[id];
46
+ return (0, _getAxisValue.getAxisValue)(axis.scale, axis.data, value, indexes[axisIndex]);
47
+ }) : (0, _getAxisValue.getAxisValue)(axes.axis[ids].scale, axes.axis[ids].data, value, indexes);
45
48
  }
46
49
  const selectorChartsInteractionXAxisValue = exports.selectorChartsInteractionXAxisValue = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartsInteractionXAxisIndex, optionalGetAxisId], (x, xAxes, xIndex, id) => {
47
50
  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,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findClosestPoints = findClosestPoints;
7
+ var _scaleGuards = require("../../../scaleGuards");
8
+ function findClosestPoints(flatbush, drawingArea, seriesData, xScale, yScale, xZoomStart, xZoomEnd, yZoomStart, yZoomEnd, svgPointX, svgPointY, maxRadius = Infinity, maxResults = 1) {
9
+ const originalXScale = xScale.copy();
10
+ const originalYScale = yScale.copy();
11
+ originalXScale.range([0, 1]);
12
+ originalYScale.range([0, 1]);
13
+ const excludeIfOutsideDrawingArea = function excludeIfOutsideDrawingArea(index) {
14
+ const x = originalXScale(seriesData[index].x);
15
+ const y = originalYScale(seriesData[index].y);
16
+ return x >= xZoomStart && x <= xZoomEnd && y >= yZoomStart && y <= yZoomEnd;
17
+ };
18
+
19
+ // We need to convert the distance from the original range [0, 1] to the current drawing area
20
+ // so the comparison is done on pixels instead of normalized values.
21
+ // fx and fy are the factors to convert the distance from [0, 1] to the current drawing area.
22
+ const fx = xScale.range()[1] - xScale.range()[0];
23
+ const fy = yScale.range()[1] - yScale.range()[0];
24
+ const fxSq = fx * fx;
25
+ const fySq = fy * fy;
26
+ function sqDistFn(dx, dy) {
27
+ return fxSq * dx * dx + fySq * dy * dy;
28
+ }
29
+ const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex].x));
30
+ const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex].y));
31
+ return flatbush.neighbors(pointX, pointY, maxResults, maxRadius != null ? maxRadius * maxRadius : Infinity, excludeIfOutsideDrawingArea, sqDistFn);
32
+ }
33
+ function invertScale(scale, value, getDataPoint) {
34
+ if ((0, _scaleGuards.isOrdinalScale)(scale)) {
35
+ 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());
36
+ return getDataPoint(dataIndex);
37
+ }
38
+ return scale.invert(value);
39
+ }