@mui/x-charts 8.14.0 → 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 (50) hide show
  1. package/BarChart/useBarPlotData.js +20 -33
  2. package/CHANGELOG.md +95 -0
  3. package/Gauge/Gauge.js +2 -9
  4. package/Gauge/GaugeReferenceArc.d.ts +4 -1
  5. package/Gauge/GaugeReferenceArc.js +12 -3
  6. package/Gauge/GaugeValueArc.d.ts +4 -1
  7. package/Gauge/GaugeValueArc.js +16 -8
  8. package/Gauge/GaugeValueText.js +3 -1
  9. package/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
  10. package/esm/BarChart/useBarPlotData.js +20 -33
  11. package/esm/Gauge/Gauge.js +2 -9
  12. package/esm/Gauge/GaugeReferenceArc.d.ts +4 -1
  13. package/esm/Gauge/GaugeReferenceArc.js +11 -2
  14. package/esm/Gauge/GaugeValueArc.d.ts +4 -1
  15. package/esm/Gauge/GaugeValueArc.js +16 -8
  16. package/esm/Gauge/GaugeValueText.js +3 -1
  17. package/esm/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
  18. package/esm/index.js +1 -1
  19. package/esm/internals/Flatbush.bench.d.ts +1 -0
  20. package/esm/internals/Flatbush.bench.js +42 -0
  21. package/esm/internals/Flatbush.d.ts +63 -0
  22. package/esm/internals/Flatbush.js +468 -0
  23. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
  24. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
  25. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
  26. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +41 -0
  27. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
  28. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
  29. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +33 -0
  30. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +40 -81
  31. package/esm/models/seriesType/scatter.d.ts +2 -0
  32. package/esm/themeAugmentation/components.d.ts +3 -0
  33. package/esm/themeAugmentation/overrides.d.ts +2 -0
  34. package/index.js +1 -1
  35. package/internals/Flatbush.bench.d.ts +1 -0
  36. package/internals/Flatbush.bench.js +44 -0
  37. package/internals/Flatbush.d.ts +63 -0
  38. package/internals/Flatbush.js +477 -0
  39. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
  40. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
  41. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
  42. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +43 -1
  43. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
  44. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
  45. package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +39 -0
  46. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +39 -80
  47. package/models/seriesType/scatter.d.ts +2 -0
  48. package/package.json +5 -4
  49. package/themeAugmentation/components.d.ts +3 -0
  50. package/themeAugmentation/overrides.d.ts +2 -0
@@ -5,7 +5,7 @@ const seriesProcessor = ({
5
5
  }, dataset) => {
6
6
  const completeSeries = Object.fromEntries(Object.entries(series).map(([seriesId, seriesData]) => {
7
7
  const datasetKeys = seriesData?.datasetKeys;
8
- const missingKeys = ['x', 'y', 'id'].filter(key => typeof datasetKeys?.[key] !== 'string');
8
+ const missingKeys = ['x', 'y'].filter(key => typeof datasetKeys?.[key] !== 'string');
9
9
  if (seriesData?.datasetKeys && missingKeys.length > 0) {
10
10
  throw new Error([`MUI X Charts: scatter series with id='${seriesId}' has incomplete datasetKeys.`, `Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.`].join('\n'));
11
11
  }
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.14.0
2
+ * @mui/x-charts v8.14.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import { describe, bench } from 'vitest';
2
+ import { Flatbush } from "./Flatbush.js";
3
+ const data = [],
4
+ n = 1_000_000;
5
+
6
+ // Generate and position the datapoints in a tangent wave pattern
7
+ for (let i = 0; i < n; i += 1) {
8
+ const theta = Math.random() * 2 * Math.PI;
9
+ const radius = Math.pow(Math.random(), 2) * 100;
10
+ const waveDeviation = (Math.random() - 0.5) * 70;
11
+ const waveValue = Math.tan(theta) * waveDeviation;
12
+ data.push({
13
+ x: 50 + (radius + waveValue) * Math.cos(theta),
14
+ y: 50 + (radius + waveValue) * Math.sin(theta)
15
+ });
16
+ }
17
+ const flatbush1M = new Flatbush(data.length);
18
+ for (let i = 0; i < data.length; i += 1) {
19
+ flatbush1M.add(data[i].x, data[i].y);
20
+ }
21
+ flatbush1M.finish();
22
+ describe('Flatbush benchmarks', () => {
23
+ describe('add + finish', () => {
24
+ bench('add 1M points + finish', () => {
25
+ const flatbush = new Flatbush(data.length);
26
+ for (let i = 0; i < data.length; i += 1) {
27
+ flatbush.add(data[i].x, data[i].y);
28
+ }
29
+ flatbush.finish();
30
+ });
31
+ });
32
+ describe('search 1M points', () => {
33
+ bench('search 1M points', () => {
34
+ flatbush1M.search(0.4, 0.4, 0.6, 0.6);
35
+ });
36
+ });
37
+ describe('neighbors 1M points', () => {
38
+ bench('neighbors 1M points', () => {
39
+ flatbush1M.neighbors(0.5, 0.5, 1, 0.04, undefined);
40
+ });
41
+ });
42
+ });
@@ -0,0 +1,63 @@
1
+ import FlatQueue from 'flatqueue';
2
+ type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
3
+ export declare class Flatbush {
4
+ _queue: FlatQueue<number>;
5
+ _boxes: TypedArrayConstructor;
6
+ _indices: Uint16Array | Uint32Array;
7
+ data: ArrayBufferLike;
8
+ numItems: number;
9
+ nodeSize: number;
10
+ _levelBounds: number[];
11
+ byteOffset: number;
12
+ /**
13
+ * Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
14
+ * @param {ArrayBufferLike} data
15
+ * @param {number} [byteOffset=0] byte offset to the start of the Flatbush buffer in the referenced ArrayBuffer.
16
+ * @returns {Flatbush} index
17
+ */
18
+ static from(data: any, byteOffset?: number): Flatbush;
19
+ /**
20
+ * Create a Flatbush index that will hold a given number of items.
21
+ * @param {number} numItems
22
+ * @param {number} [nodeSize=16] Size of the tree node (16 by default).
23
+ * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
24
+ * @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used to store data (`ArrayBuffer` by default).
25
+ * @param {ArrayBufferLike} [data] (Only used internally)
26
+ * @param {number} [byteOffset=0] (Only used internally)
27
+ */
28
+ constructor(numItems: number, nodeSize?: number, ArrayType?: TypedArrayConstructor, ArrayBufferType?: ArrayBufferConstructor | SharedArrayBufferConstructor, data?: ArrayBufferLike, byteOffset?: number);
29
+ /**
30
+ * Add a given rectangle to the index.
31
+ * @param {number} minX
32
+ * @param {number} minY
33
+ * @param {number} maxX
34
+ * @param {number} maxY
35
+ * @returns {number} A zero-based, incremental number that represents the newly added rectangle.
36
+ */
37
+ add(minX: any, minY: any, maxX?: any, maxY?: any): number;
38
+ /** Perform indexing of the added rectangles. */
39
+ finish(): void;
40
+ /**
41
+ * Search the index by a bounding box.
42
+ * @param {number} minX
43
+ * @param {number} minY
44
+ * @param {number} maxX
45
+ * @param {number} maxY
46
+ * @param {(index: number) => boolean} [filterFn] An optional function for filtering the results.
47
+ * @returns {number[]} An array containing the index, the x coordinate and the y coordinate of the points intersecting or touching the given bounding box.
48
+ */
49
+ search(minX: number, minY: number, maxX: number, maxY: number, filterFn?: (index: number) => boolean): number[];
50
+ /**
51
+ * Search items in order of distance from the given point.
52
+ * @param x
53
+ * @param y
54
+ * @param [maxResults=Infinity]
55
+ * @param maxDistSq
56
+ * @param [filterFn] An optional function for filtering the results.
57
+ * @param [sqDistFn] An optional function to calculate squared distance from the point to the item.
58
+ * @returns {number[]} An array of indices of items found.
59
+ */
60
+ neighbors(x: any, y: any, maxResults?: number, maxDistSq?: number, filterFn?: (index: number) => boolean, sqDistFn?: typeof sqDist): number[];
61
+ }
62
+ declare function sqDist(dx: number, dy: number): number;
63
+ export {};
@@ -0,0 +1,468 @@
1
+ // @ts-nocheck
2
+ /* eslint-disable */
3
+ import FlatQueue from 'flatqueue';
4
+ const ARRAY_TYPES = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];
5
+ const VERSION = 3; // serialized format version
6
+
7
+ export class Flatbush {
8
+ /**
9
+ * Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
10
+ * @param {ArrayBufferLike} data
11
+ * @param {number} [byteOffset=0] byte offset to the start of the Flatbush buffer in the referenced ArrayBuffer.
12
+ * @returns {Flatbush} index
13
+ */
14
+ static from(data, byteOffset = 0) {
15
+ if (byteOffset % 8 !== 0) {
16
+ throw new Error('byteOffset must be 8-byte aligned.');
17
+ }
18
+
19
+ // @ts-expect-error duck typing array buffers
20
+ if (!data || data.byteLength === undefined || data.buffer) {
21
+ throw new Error('Data must be an instance of ArrayBuffer or SharedArrayBuffer.');
22
+ }
23
+ const [magic, versionAndType] = new Uint8Array(data, byteOffset + 0, 2);
24
+ if (magic !== 0xfb) {
25
+ throw new Error('Data does not appear to be in a Flatbush format.');
26
+ }
27
+ const version = versionAndType >> 4;
28
+ if (version !== VERSION) {
29
+ throw new Error(`Got v${version} data when expected v${VERSION}.`);
30
+ }
31
+ const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];
32
+ if (!ArrayType) {
33
+ throw new Error('Unrecognized array type.');
34
+ }
35
+ const [nodeSize] = new Uint16Array(data, byteOffset + 2, 1);
36
+ const [numItems] = new Uint32Array(data, byteOffset + 4, 1);
37
+ return new Flatbush(numItems, nodeSize, ArrayType, undefined, data, byteOffset);
38
+ }
39
+
40
+ /**
41
+ * Create a Flatbush index that will hold a given number of items.
42
+ * @param {number} numItems
43
+ * @param {number} [nodeSize=16] Size of the tree node (16 by default).
44
+ * @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
45
+ * @param {ArrayBufferConstructor | SharedArrayBufferConstructor} [ArrayBufferType=ArrayBuffer] The array buffer type used to store data (`ArrayBuffer` by default).
46
+ * @param {ArrayBufferLike} [data] (Only used internally)
47
+ * @param {number} [byteOffset=0] (Only used internally)
48
+ */
49
+ constructor(numItems, nodeSize = 16, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data, byteOffset = 0) {
50
+ if (numItems === undefined) {
51
+ throw new Error('Missing required argument: numItems.');
52
+ }
53
+ if (isNaN(numItems) || numItems <= 0) {
54
+ throw new Error(`Unexpected numItems value: ${numItems}.`);
55
+ }
56
+ this.numItems = +numItems;
57
+ this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);
58
+ this.byteOffset = byteOffset;
59
+
60
+ // calculate the total number of nodes in the R-tree to allocate space for
61
+ // and the index of each tree level (used in search later)
62
+ let n = numItems;
63
+ let numNodes = n;
64
+ this._levelBounds = [n * 4];
65
+ do {
66
+ n = Math.ceil(n / this.nodeSize);
67
+ numNodes += n;
68
+ this._levelBounds.push(numNodes * 4);
69
+ } while (n !== 1);
70
+ this.ArrayType = ArrayType;
71
+ this.IndexArrayType = numNodes < 16384 ? Uint16Array : Uint32Array;
72
+ const arrayTypeIndex = ARRAY_TYPES.indexOf(ArrayType);
73
+ const nodesByteSize = numNodes * 4 * ArrayType.BYTES_PER_ELEMENT;
74
+ if (arrayTypeIndex < 0) {
75
+ throw new Error(`Unexpected typed array class: ${ArrayType}.`);
76
+ }
77
+ if (data) {
78
+ this.data = data;
79
+ this._boxes = new ArrayType(data, byteOffset + 8, numNodes * 4);
80
+ this._indices = new this.IndexArrayType(data, byteOffset + 8 + nodesByteSize, numNodes);
81
+ this._pos = numNodes * 4;
82
+ this.minX = this._boxes[this._pos - 4];
83
+ this.minY = this._boxes[this._pos - 3];
84
+ this.maxX = this._boxes[this._pos - 2];
85
+ this.maxY = this._boxes[this._pos - 1];
86
+ } else {
87
+ const data = this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
88
+ this._boxes = new ArrayType(data, 8, numNodes * 4);
89
+ this._indices = new this.IndexArrayType(data, 8 + nodesByteSize, numNodes);
90
+ this._pos = 0;
91
+ this.minX = Infinity;
92
+ this.minY = Infinity;
93
+ this.maxX = -Infinity;
94
+ this.maxY = -Infinity;
95
+ new Uint8Array(data, 0, 2).set([0xfb, (VERSION << 4) + arrayTypeIndex]);
96
+ new Uint16Array(data, 2, 1)[0] = nodeSize;
97
+ new Uint32Array(data, 4, 1)[0] = numItems;
98
+ }
99
+
100
+ // a priority queue for k-nearest-neighbors queries
101
+ /** @type FlatQueue<number> */
102
+ this._queue = new FlatQueue();
103
+ }
104
+
105
+ /**
106
+ * Add a given rectangle to the index.
107
+ * @param {number} minX
108
+ * @param {number} minY
109
+ * @param {number} maxX
110
+ * @param {number} maxY
111
+ * @returns {number} A zero-based, incremental number that represents the newly added rectangle.
112
+ */
113
+ add(minX, minY, maxX = minX, maxY = minY) {
114
+ const index = this._pos >> 2;
115
+ const boxes = this._boxes;
116
+ this._indices[index] = index;
117
+ boxes[this._pos++] = minX;
118
+ boxes[this._pos++] = minY;
119
+ boxes[this._pos++] = maxX;
120
+ boxes[this._pos++] = maxY;
121
+ if (minX < this.minX) {
122
+ this.minX = minX;
123
+ }
124
+ if (minY < this.minY) {
125
+ this.minY = minY;
126
+ }
127
+ if (maxX > this.maxX) {
128
+ this.maxX = maxX;
129
+ }
130
+ if (maxY > this.maxY) {
131
+ this.maxY = maxY;
132
+ }
133
+ return index;
134
+ }
135
+
136
+ /** Perform indexing of the added rectangles. */
137
+ finish() {
138
+ if (this._pos >> 2 !== this.numItems) {
139
+ throw new Error(`Added ${this._pos >> 2} items when expected ${this.numItems}.`);
140
+ }
141
+ const boxes = this._boxes;
142
+ if (this.numItems <= this.nodeSize) {
143
+ // only one node, skip sorting and just fill the root box
144
+ boxes[this._pos++] = this.minX;
145
+ boxes[this._pos++] = this.minY;
146
+ boxes[this._pos++] = this.maxX;
147
+ boxes[this._pos++] = this.maxY;
148
+ return;
149
+ }
150
+ const width = this.maxX - this.minX || 1;
151
+ const height = this.maxY - this.minY || 1;
152
+ const hilbertValues = new Uint32Array(this.numItems);
153
+ const hilbertMax = (1 << 16) - 1;
154
+
155
+ // map item centers into Hilbert coordinate space and calculate Hilbert values
156
+ for (let i = 0, pos = 0; i < this.numItems; i++) {
157
+ const minX = boxes[pos++];
158
+ const minY = boxes[pos++];
159
+ const maxX = boxes[pos++];
160
+ const maxY = boxes[pos++];
161
+ const x = Math.floor(hilbertMax * ((minX + maxX) / 2 - this.minX) / width);
162
+ const y = Math.floor(hilbertMax * ((minY + maxY) / 2 - this.minY) / height);
163
+ hilbertValues[i] = hilbert(x, y);
164
+ }
165
+
166
+ // sort items by their Hilbert value (for packing later)
167
+ sort(hilbertValues, boxes, this._indices, 0, this.numItems - 1, this.nodeSize);
168
+
169
+ // generate nodes at each tree level, bottom-up
170
+ for (let i = 0, pos = 0; i < this._levelBounds.length - 1; i++) {
171
+ const end = this._levelBounds[i];
172
+
173
+ // generate a parent node for each block of consecutive <nodeSize> nodes
174
+ while (pos < end) {
175
+ const nodeIndex = pos;
176
+
177
+ // calculate bbox for the new node
178
+ let nodeMinX = boxes[pos++];
179
+ let nodeMinY = boxes[pos++];
180
+ let nodeMaxX = boxes[pos++];
181
+ let nodeMaxY = boxes[pos++];
182
+ for (let j = 1; j < this.nodeSize && pos < end; j++) {
183
+ nodeMinX = Math.min(nodeMinX, boxes[pos++]);
184
+ nodeMinY = Math.min(nodeMinY, boxes[pos++]);
185
+ nodeMaxX = Math.max(nodeMaxX, boxes[pos++]);
186
+ nodeMaxY = Math.max(nodeMaxY, boxes[pos++]);
187
+ }
188
+
189
+ // add the new node to the tree data
190
+ this._indices[this._pos >> 2] = nodeIndex;
191
+ boxes[this._pos++] = nodeMinX;
192
+ boxes[this._pos++] = nodeMinY;
193
+ boxes[this._pos++] = nodeMaxX;
194
+ boxes[this._pos++] = nodeMaxY;
195
+ }
196
+ }
197
+ }
198
+
199
+ /**
200
+ * Search the index by a bounding box.
201
+ * @param {number} minX
202
+ * @param {number} minY
203
+ * @param {number} maxX
204
+ * @param {number} maxY
205
+ * @param {(index: number) => boolean} [filterFn] An optional function for filtering the results.
206
+ * @returns {number[]} An array containing the index, the x coordinate and the y coordinate of the points intersecting or touching the given bounding box.
207
+ */
208
+ search(minX, minY, maxX, maxY, filterFn) {
209
+ if (this._pos !== this._boxes.length) {
210
+ throw new Error('Data not yet indexed - call index.finish().');
211
+ }
212
+
213
+ /** @type number | undefined */
214
+ let nodeIndex = this._boxes.length - 4;
215
+ const queue = [];
216
+ const results = [];
217
+ while (nodeIndex !== undefined) {
218
+ // find the end index of the node
219
+ const end = Math.min(nodeIndex + this.nodeSize * 4, upperBound(nodeIndex, this._levelBounds));
220
+
221
+ // search through child nodes
222
+ for (let /** @type number */pos = nodeIndex; pos < end; pos += 4) {
223
+ // check if node bbox intersects with query bbox
224
+ if (maxX < this._boxes[pos]) {
225
+ continue;
226
+ } // maxX < nodeMinX
227
+ if (maxY < this._boxes[pos + 1]) {
228
+ continue;
229
+ } // maxY < nodeMinY
230
+ if (minX > this._boxes[pos + 2]) {
231
+ continue;
232
+ } // minX > nodeMaxX
233
+ if (minY > this._boxes[pos + 3]) {
234
+ continue;
235
+ } // minY > nodeMaxY
236
+
237
+ const index = this._indices[pos >> 2] | 0;
238
+ if (nodeIndex >= this.numItems * 4) {
239
+ queue.push(index); // node; add it to the search queue
240
+ } else if (filterFn === undefined || filterFn(index)) {
241
+ results.push(index);
242
+ results.push(this._boxes[pos]); // leaf item
243
+ results.push(this._boxes[pos + 1]);
244
+ }
245
+ }
246
+ nodeIndex = queue.pop();
247
+ }
248
+ return results;
249
+ }
250
+
251
+ /**
252
+ * Search items in order of distance from the given point.
253
+ * @param x
254
+ * @param y
255
+ * @param [maxResults=Infinity]
256
+ * @param maxDistSq
257
+ * @param [filterFn] An optional function for filtering the results.
258
+ * @param [sqDistFn] An optional function to calculate squared distance from the point to the item.
259
+ * @returns {number[]} An array of indices of items found.
260
+ */
261
+ neighbors(x, y, maxResults = Infinity, maxDistSq = Infinity, filterFn, sqDistFn = sqDist) {
262
+ if (this._pos !== this._boxes.length) {
263
+ throw new Error('Data not yet indexed - call index.finish().');
264
+ }
265
+
266
+ /** @type number | undefined */
267
+ let nodeIndex = this._boxes.length - 4;
268
+ const q = this._queue;
269
+ const results = [];
270
+
271
+ /* eslint-disable no-labels */
272
+ outer: while (nodeIndex !== undefined) {
273
+ // find the end index of the node
274
+ const end = Math.min(nodeIndex + this.nodeSize * 4, upperBound(nodeIndex, this._levelBounds));
275
+
276
+ // add child nodes to the queue
277
+ for (let pos = nodeIndex; pos < end; pos += 4) {
278
+ const index = this._indices[pos >> 2] | 0;
279
+ const minX = this._boxes[pos];
280
+ const minY = this._boxes[pos + 1];
281
+ const maxX = this._boxes[pos + 2];
282
+ const maxY = this._boxes[pos + 3];
283
+ const dx = x < minX ? minX - x : x > maxX ? x - maxX : 0;
284
+ const dy = y < minY ? minY - y : y > maxY ? y - maxY : 0;
285
+ const dist = sqDistFn(dx, dy);
286
+ if (dist > maxDistSq) {
287
+ continue;
288
+ }
289
+ if (nodeIndex >= this.numItems * 4) {
290
+ q.push(index << 1, dist); // node (use even id)
291
+ } else if (filterFn === undefined || filterFn(index)) {
292
+ q.push((index << 1) + 1, dist); // leaf item (use odd id)
293
+ }
294
+ }
295
+
296
+ // pop items from the queue
297
+ // @ts-expect-error q.length check eliminates undefined values
298
+ while (q.length && q.peek() & 1) {
299
+ const dist = q.peekValue();
300
+
301
+ // @ts-expect-error
302
+ if (dist > maxDistSq) {
303
+ break outer;
304
+ }
305
+ // @ts-expect-error
306
+ results.push(q.pop() >> 1);
307
+ if (results.length === maxResults) {
308
+ break outer;
309
+ }
310
+ }
311
+
312
+ // @ts-expect-error
313
+ nodeIndex = q.length ? q.pop() >> 1 : undefined;
314
+ }
315
+ q.clear();
316
+ return results;
317
+ }
318
+ }
319
+ function sqDist(dx, dy) {
320
+ return dx * dx + dy * dy;
321
+ }
322
+
323
+ /**
324
+ * Binary search for the first value in the array bigger than the given.
325
+ * @param {number} value
326
+ * @param {number[]} arr
327
+ */
328
+ function upperBound(value, arr) {
329
+ let i = 0;
330
+ let j = arr.length - 1;
331
+ while (i < j) {
332
+ const m = i + j >> 1;
333
+ if (arr[m] > value) {
334
+ j = m;
335
+ } else {
336
+ i = m + 1;
337
+ }
338
+ }
339
+ return arr[i];
340
+ }
341
+
342
+ /**
343
+ * Custom quicksort that partially sorts bbox data alongside the hilbert values.
344
+ * @param {Uint32Array} values
345
+ * @param {InstanceType<TypedArrayConstructor>} boxes
346
+ * @param {Uint16Array | Uint32Array} indices
347
+ * @param {number} left
348
+ * @param {number} right
349
+ * @param {number} nodeSize
350
+ */
351
+ function sort(values, boxes, indices, left, right, nodeSize) {
352
+ if (Math.floor(left / nodeSize) >= Math.floor(right / nodeSize)) {
353
+ return;
354
+ }
355
+
356
+ // apply median of three method
357
+ const start = values[left];
358
+ const mid = values[left + right >> 1];
359
+ const end = values[right];
360
+ let pivot = end;
361
+ const x = Math.max(start, mid);
362
+ if (end > x) {
363
+ pivot = x;
364
+ } else if (x === start) {
365
+ pivot = Math.max(mid, end);
366
+ } else if (x === mid) {
367
+ pivot = Math.max(start, end);
368
+ }
369
+ let i = left - 1;
370
+ let j = right + 1;
371
+ while (true) {
372
+ do {
373
+ i++;
374
+ } while (values[i] < pivot);
375
+ do {
376
+ j--;
377
+ } while (values[j] > pivot);
378
+ if (i >= j) {
379
+ break;
380
+ }
381
+ swap(values, boxes, indices, i, j);
382
+ }
383
+ sort(values, boxes, indices, left, j, nodeSize);
384
+ sort(values, boxes, indices, j + 1, right, nodeSize);
385
+ }
386
+
387
+ /**
388
+ * Swap two values and two corresponding boxes.
389
+ * @param {Uint32Array} values
390
+ * @param {InstanceType<TypedArrayConstructor>} boxes
391
+ * @param {Uint16Array | Uint32Array} indices
392
+ * @param {number} i
393
+ * @param {number} j
394
+ */
395
+ function swap(values, boxes, indices, i, j) {
396
+ const temp = values[i];
397
+ values[i] = values[j];
398
+ values[j] = temp;
399
+ const k = 4 * i;
400
+ const m = 4 * j;
401
+ const a = boxes[k];
402
+ const b = boxes[k + 1];
403
+ const c = boxes[k + 2];
404
+ const d = boxes[k + 3];
405
+ boxes[k] = boxes[m];
406
+ boxes[k + 1] = boxes[m + 1];
407
+ boxes[k + 2] = boxes[m + 2];
408
+ boxes[k + 3] = boxes[m + 3];
409
+ boxes[m] = a;
410
+ boxes[m + 1] = b;
411
+ boxes[m + 2] = c;
412
+ boxes[m + 3] = d;
413
+ const e = indices[i];
414
+ indices[i] = indices[j];
415
+ indices[j] = e;
416
+ }
417
+
418
+ /**
419
+ * Fast Hilbert curve algorithm by http://threadlocalmutex.com/
420
+ * Ported from C++ https://github.com/rawrunprotected/hilbert_curves (public domain)
421
+ * @param {number} x
422
+ * @param {number} y
423
+ */
424
+ function hilbert(x, y) {
425
+ let a = x ^ y;
426
+ let b = 0xffff ^ a;
427
+ let c = 0xffff ^ (x | y);
428
+ let d = x & (y ^ 0xffff);
429
+ let A = a | b >> 1;
430
+ let B = a >> 1 ^ a;
431
+ let C = c >> 1 ^ b & d >> 1 ^ c;
432
+ let D = a & c >> 1 ^ d >> 1 ^ d;
433
+ a = A;
434
+ b = B;
435
+ c = C;
436
+ d = D;
437
+ A = a & a >> 2 ^ b & b >> 2;
438
+ B = a & b >> 2 ^ b & (a ^ b) >> 2;
439
+ C ^= a & c >> 2 ^ b & d >> 2;
440
+ D ^= b & c >> 2 ^ (a ^ b) & d >> 2;
441
+ a = A;
442
+ b = B;
443
+ c = C;
444
+ d = D;
445
+ A = a & a >> 4 ^ b & b >> 4;
446
+ B = a & b >> 4 ^ b & (a ^ b) >> 4;
447
+ C ^= a & c >> 4 ^ b & d >> 4;
448
+ D ^= b & c >> 4 ^ (a ^ b) & d >> 4;
449
+ a = A;
450
+ b = B;
451
+ c = C;
452
+ d = D;
453
+ C ^= a & c >> 8 ^ b & d >> 8;
454
+ D ^= b & c >> 8 ^ (a ^ b) & d >> 8;
455
+ a = C ^ C >> 1;
456
+ b = D ^ D >> 1;
457
+ let i0 = x ^ y;
458
+ let i1 = b | 0xffff ^ (i0 | a);
459
+ i0 = (i0 | i0 << 8) & 0x00ff00ff;
460
+ i0 = (i0 | i0 << 4) & 0x0f0f0f0f;
461
+ i0 = (i0 | i0 << 2) & 0x33333333;
462
+ i0 = (i0 | i0 << 1) & 0x55555555;
463
+ i1 = (i1 | i1 << 8) & 0x00ff00ff;
464
+ i1 = (i1 | i1 << 4) & 0x0f0f0f0f;
465
+ i1 = (i1 | i1 << 2) & 0x33333333;
466
+ i1 = (i1 | i1 << 1) & 0x55555555;
467
+ return (i1 << 1 | i0) >>> 0;
468
+ }
@@ -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;
@@ -46,14 +46,11 @@ export function getAxisIndex(axisConfig, pointerValue) {
46
46
  * For a pointer coordinate, this function returns the value associated.
47
47
  * Returns `null` if the coordinate has no value associated.
48
48
  */
49
- export function getAxisValue(axisConfig, pointerValue, dataIndex) {
50
- const {
51
- scale,
52
- data: axisData
53
- } = axisConfig;
49
+ export function getAxisValue(scale, axisData, pointerValue, dataIndex) {
54
50
  if (!isOrdinalScale(scale)) {
55
51
  if (dataIndex === null) {
56
- return scale.invert(pointerValue);
52
+ const invertedValue = scale.invert(pointerValue);
53
+ return Number.isNaN(invertedValue) ? null : invertedValue;
57
54
  }
58
55
  return axisData[dataIndex];
59
56
  }
@@ -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 {};