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