@mui/x-charts 8.13.1 → 8.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +44 -36
- package/BarChart/useBarPlotData.js +20 -33
- package/CHANGELOG.md +204 -1
- package/ChartContainer/ChartContainer.js +68 -56
- package/ChartsTooltip/ChartsTooltipContainer.js +2 -0
- package/ChartsXAxis/useAxisTicksProps.d.ts +197 -355
- package/ChartsYAxis/useAxisTicksProps.d.ts +197 -355
- 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/LineChart/LineChart.js +44 -36
- package/PieChart/PieArc.d.ts +18 -4
- package/PieChart/PieArc.js +11 -5
- package/PieChart/PieArcPlot.js +3 -1
- package/ScatterChart/ScatterChart.js +44 -36
- package/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
- package/SparkLineChart/SparkLineChart.js +44 -36
- package/esm/BarChart/BarChart.js +44 -36
- package/esm/BarChart/useBarPlotData.js +20 -33
- package/esm/ChartContainer/ChartContainer.js +68 -56
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +2 -0
- package/esm/ChartsXAxis/useAxisTicksProps.d.ts +197 -355
- package/esm/ChartsYAxis/useAxisTicksProps.d.ts +197 -355
- 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/LineChart/LineChart.js +44 -36
- package/esm/PieChart/PieArc.d.ts +18 -4
- package/esm/PieChart/PieArc.js +11 -5
- package/esm/PieChart/PieArcPlot.js +3 -1
- package/esm/ScatterChart/ScatterChart.js +44 -36
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +44 -36
- package/esm/hooks/animation/useAnimate.js +5 -3
- package/esm/hooks/useScale.d.ts +5 -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/animation/useAnimateInternal.d.ts +1 -1
- package/esm/internals/animation/useAnimateInternal.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +8 -8
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +4 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +9 -11
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -28
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +4 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +3 -24
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +20 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +77 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +4 -65
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +7 -104
- 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/useChartCartesianAxisPreview.selectors.d.ts +3 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +31 -39
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +185 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +199 -47
- 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/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +10 -3
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -2
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +6 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +5 -1
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +9 -1
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -1
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
- package/esm/internals/scaleGuards.d.ts +12 -6
- package/esm/internals/symlogScale.js +5 -0
- package/esm/locales/enUS.js +4 -4
- package/esm/locales/ptBR.js +97 -99
- package/esm/models/axis.d.ts +39 -17
- package/esm/models/axis.js +3 -0
- 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/hooks/animation/useAnimate.js +4 -3
- package/hooks/useScale.d.ts +5 -1
- 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/animation/useAnimateInternal.d.ts +1 -1
- package/internals/animation/useAnimateInternal.js +1 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +7 -7
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +4 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +9 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -28
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +4 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +3 -25
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +20 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +84 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +4 -65
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -108
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +29 -37
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +185 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +200 -47
- 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/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +10 -3
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -2
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +5 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +9 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -1
- package/internals/scaleGuards.d.ts +12 -6
- package/internals/symlogScale.js +5 -0
- package/locales/enUS.js +4 -4
- package/locales/ptBR.js +97 -99
- package/models/axis.d.ts +39 -17
- package/models/axis.js +4 -0
- package/models/seriesType/scatter.d.ts +2 -0
- package/package.json +7 -6
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/overrides.d.ts +2 -0
package/esm/models/axis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleOrdinal, ScalePoint, ScalePower, ScaleSequential, ScaleThreshold, ScaleTime, ScaleSymLog } from '@mui/x-charts-vendor/d3-scale';
|
|
1
|
+
import type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleOrdinal, ScalePoint, ScalePower, ScaleSequential, ScaleThreshold, ScaleTime, ScaleSymLog, NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
2
2
|
import { SxProps } from '@mui/system/styleFunctionSx';
|
|
3
3
|
import { type MakeOptional, MakeRequired } from '@mui/x-internals/types';
|
|
4
4
|
import type { DefaultizedZoomOptions } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
@@ -9,11 +9,15 @@ import { ContinuousColorConfig, OrdinalColorConfig, PiecewiseColorConfig } from
|
|
|
9
9
|
export type AxisId = string | number;
|
|
10
10
|
export type D3Scale<Domain extends {
|
|
11
11
|
toString(): string;
|
|
12
|
-
} =
|
|
12
|
+
} = {
|
|
13
|
+
toString(): string;
|
|
14
|
+
}, Range = number, Output = number> = ScaleBand<Domain> | ScaleSymLog<Range, Output> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
|
|
13
15
|
export type D3ContinuousScale<Range = number, Output = number> = ScaleSymLog<Range, Output> | ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
|
|
14
16
|
export type D3OrdinalScale<Domain extends {
|
|
15
17
|
toString(): string;
|
|
16
|
-
} =
|
|
18
|
+
} = {
|
|
19
|
+
toString(): string;
|
|
20
|
+
}> = ScaleBand<Domain> | ScalePoint<Domain>;
|
|
17
21
|
export interface ChartsAxisSlots {
|
|
18
22
|
/**
|
|
19
23
|
* Custom component for the axis main line.
|
|
@@ -220,7 +224,9 @@ export type AxisGroups = {
|
|
|
220
224
|
export interface AxisScaleConfig {
|
|
221
225
|
band: {
|
|
222
226
|
scaleType: 'band';
|
|
223
|
-
scale: ScaleBand<
|
|
227
|
+
scale: ScaleBand<{
|
|
228
|
+
toString(): string;
|
|
229
|
+
}>;
|
|
224
230
|
/**
|
|
225
231
|
* The ratio between the space allocated for padding between two categories and the category width.
|
|
226
232
|
* 0 means no gap, and 1 no data.
|
|
@@ -237,7 +243,9 @@ export interface AxisScaleConfig {
|
|
|
237
243
|
} & AxisGroups & Pick<TickParams, 'tickPlacement' | 'tickLabelPlacement'>;
|
|
238
244
|
point: {
|
|
239
245
|
scaleType: 'point';
|
|
240
|
-
scale: ScalePoint<
|
|
246
|
+
scale: ScalePoint<{
|
|
247
|
+
toString(): string;
|
|
248
|
+
}>;
|
|
241
249
|
colorMap?: OrdinalColorConfig | ContinuousColorConfig | PiecewiseColorConfig;
|
|
242
250
|
} & AxisGroups;
|
|
243
251
|
log: {
|
|
@@ -363,26 +371,39 @@ export type AxisValueFormatterContext<S extends ScaleName = ScaleName> = {
|
|
|
363
371
|
*/
|
|
364
372
|
tickNumber?: number;
|
|
365
373
|
};
|
|
366
|
-
|
|
367
|
-
* Config that is shared between cartesian and polar axes.
|
|
368
|
-
*/
|
|
369
|
-
type CommonAxisConfig<S extends ScaleName = ScaleName, V = any> = {
|
|
374
|
+
type MinMaxConfig<S extends ScaleName = ScaleName> = S extends ContinuousScaleName ? S extends 'utc' | 'time' ? {
|
|
370
375
|
/**
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* The ID must be unique across all axes in this chart.
|
|
376
|
+
* The minimal value of the domain.
|
|
377
|
+
* If not provided, it gets computed to display the entire chart data.
|
|
374
378
|
*/
|
|
375
|
-
|
|
379
|
+
min?: NumberValue;
|
|
380
|
+
/**
|
|
381
|
+
* The maximal value of the domain.
|
|
382
|
+
* If not provided, it gets computed to display the entire chart data.
|
|
383
|
+
*/
|
|
384
|
+
max?: NumberValue;
|
|
385
|
+
} : {
|
|
376
386
|
/**
|
|
377
387
|
* The minimal value of the domain.
|
|
378
388
|
* If not provided, it gets computed to display the entire chart data.
|
|
379
389
|
*/
|
|
380
|
-
min?: number
|
|
390
|
+
min?: number;
|
|
381
391
|
/**
|
|
382
392
|
* The maximal value of the domain.
|
|
383
393
|
* If not provided, it gets computed to display the entire chart data.
|
|
384
394
|
*/
|
|
385
|
-
max?: number
|
|
395
|
+
max?: number;
|
|
396
|
+
} : {};
|
|
397
|
+
/**
|
|
398
|
+
* Config that is shared between cartesian and polar axes.
|
|
399
|
+
*/
|
|
400
|
+
type CommonAxisConfig<S extends ScaleName = ScaleName, V = any> = {
|
|
401
|
+
/**
|
|
402
|
+
* ID used to identify the axis.
|
|
403
|
+
*
|
|
404
|
+
* The ID must be unique across all axes in this chart.
|
|
405
|
+
*/
|
|
406
|
+
id: AxisId;
|
|
386
407
|
/**
|
|
387
408
|
* The data used by `'band'` and `'point'` scales.
|
|
388
409
|
*/
|
|
@@ -429,7 +450,7 @@ export type PolarAxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps
|
|
|
429
450
|
* @default 0
|
|
430
451
|
*/
|
|
431
452
|
offset?: number;
|
|
432
|
-
} & CommonAxisConfig<S, V> & Omit<Partial<AxisProps>, 'axisId'> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & AxisConfigExtension;
|
|
453
|
+
} & CommonAxisConfig<S, V> & MinMaxConfig<S> & Omit<Partial<AxisProps>, 'axisId'> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & AxisConfigExtension;
|
|
433
454
|
/**
|
|
434
455
|
* Use this type for advanced typing. For basic usage, use `XAxis`, `YAxis`, `RotationAxis` or `RadiusAxis`.
|
|
435
456
|
*/
|
|
@@ -441,7 +462,7 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps exten
|
|
|
441
462
|
* @default 0
|
|
442
463
|
*/
|
|
443
464
|
offset?: number;
|
|
444
|
-
} & CommonAxisConfig<S, V> & Omit<Partial<AxisProps>, 'axisId'> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & AxisSideConfig<AxisProps> & TickParams & AxisConfigExtension;
|
|
465
|
+
} & CommonAxisConfig<S, V> & MinMaxConfig<S> & Omit<Partial<AxisProps>, 'axisId'> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & AxisSideConfig<AxisProps> & TickParams & AxisConfigExtension;
|
|
445
466
|
export interface AxisConfigExtension {}
|
|
446
467
|
export type PolarAxisDefaultized<S extends ScaleName = ScaleName, V = any, AxisProps extends ChartsAxisProps = ChartsRotationAxisProps | ChartsRadiusAxisProps> = Omit<PolarAxisConfig<S, V, AxisProps>, 'scaleType'> & AxisScaleConfig[S] & AxisScaleComputedConfig[S] & {
|
|
447
468
|
/**
|
|
@@ -467,6 +488,7 @@ export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): s
|
|
|
467
488
|
export declare function isPointScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'point'> & {
|
|
468
489
|
scaleType: 'point';
|
|
469
490
|
};
|
|
491
|
+
export declare function isContinuousScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<ContinuousScaleName>;
|
|
470
492
|
export declare function isSymlogScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'symlog'> & {
|
|
471
493
|
scaleType: 'symlog';
|
|
472
494
|
};
|
package/esm/models/axis.js
CHANGED
|
@@ -17,6 +17,9 @@ export function isBandScaleConfig(scaleConfig) {
|
|
|
17
17
|
export function isPointScaleConfig(scaleConfig) {
|
|
18
18
|
return scaleConfig.scaleType === 'point';
|
|
19
19
|
}
|
|
20
|
+
export function isContinuousScaleConfig(scaleConfig) {
|
|
21
|
+
return scaleConfig.scaleType !== 'point' && scaleConfig.scaleType !== 'band';
|
|
22
|
+
}
|
|
20
23
|
export function isSymlogScaleConfig(scaleConfig) {
|
|
21
24
|
return scaleConfig.scaleType === 'symlog';
|
|
22
25
|
}
|
|
@@ -23,6 +23,8 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType | n
|
|
|
23
23
|
/**
|
|
24
24
|
* If true, the interaction will not use element hover for this series.
|
|
25
25
|
* @default false
|
|
26
|
+
* @deprecated This prop will be removed in a future version because it is ambiguous. You can select what to disable
|
|
27
|
+
* on hover by disabling the highlight or the tooltip separately.
|
|
26
28
|
*/
|
|
27
29
|
disableHover?: boolean;
|
|
28
30
|
/**
|
|
@@ -62,6 +62,9 @@ export interface ChartsComponents<Theme = unknown> {
|
|
|
62
62
|
defaultProps?: ComponentsProps['MuiScatterChart'];
|
|
63
63
|
};
|
|
64
64
|
MuiScatter?: {};
|
|
65
|
+
MuiGauge?: {
|
|
66
|
+
styleOverrides?: ComponentsOverrides<Theme>['MuiGauge'];
|
|
67
|
+
};
|
|
65
68
|
}
|
|
66
69
|
declare module '@mui/material/styles' {
|
|
67
70
|
interface Components<Theme = unknown> extends ChartsComponents<Theme> {}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GaugeClassKey } from "../Gauge/index.js";
|
|
1
2
|
import { BarLabelClassKey } from "../BarChart/index.js";
|
|
2
3
|
import { BarElementClassKey } from "../BarChart/barElementClasses.js";
|
|
3
4
|
import { ChartsAxisHighlightClassKey } from "../ChartsAxisHighlight/index.js";
|
|
@@ -18,6 +19,7 @@ export interface ChartsComponentNameToClassKey {
|
|
|
18
19
|
MuiAreaElement: AreaElementClassKey;
|
|
19
20
|
MuiLineElement: LineElementClassKey;
|
|
20
21
|
MuiMarkElement: MarkElementClassKey;
|
|
22
|
+
MuiGauge: GaugeClassKey;
|
|
21
23
|
}
|
|
22
24
|
declare module '@mui/material/styles' {
|
|
23
25
|
interface ComponentNameToClassKey extends ChartsComponentNameToClassKey {}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -41,14 +42,14 @@ function useAnimate(props, {
|
|
|
41
42
|
ref
|
|
42
43
|
}) {
|
|
43
44
|
const transform = transformProps ?? (p => p);
|
|
44
|
-
const animateRef = (0, _useAnimateInternal.useAnimateInternal)(props, {
|
|
45
|
+
const [animateRef, lastInterpolatedProps] = (0, _useAnimateInternal.useAnimateInternal)(props, {
|
|
45
46
|
initialProps,
|
|
46
47
|
createInterpolator,
|
|
47
48
|
applyProps: (element, animatedProps) => applyProps(element, transform(animatedProps)),
|
|
48
49
|
skip
|
|
49
50
|
});
|
|
50
|
-
const usedProps = skip ? props :
|
|
51
|
-
return (0, _extends2.default)({},
|
|
51
|
+
const usedProps = skip ? transformProps(props) : transformProps(lastInterpolatedProps);
|
|
52
|
+
return (0, _extends2.default)({}, usedProps, {
|
|
52
53
|
ref: (0, _useForkRef.default)(animateRef, ref)
|
|
53
54
|
});
|
|
54
55
|
}
|
package/hooks/useScale.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ import { AxisId, AxisScaleConfig, D3Scale, ScaleName } from "../models/axis.js";
|
|
|
5
5
|
* @param {D3Scale} scale The scale to use
|
|
6
6
|
* @returns {(value: any) => number} A function that map value to their position
|
|
7
7
|
*/
|
|
8
|
-
export declare function getValueToPositionMapper
|
|
8
|
+
export declare function getValueToPositionMapper<Domain extends {
|
|
9
|
+
toString(): string;
|
|
10
|
+
} = {
|
|
11
|
+
toString(): string;
|
|
12
|
+
}, Range = number>(scale: D3Scale<Domain, Range>): (value: any) => number;
|
|
9
13
|
/**
|
|
10
14
|
* Get the X scale.
|
|
11
15
|
*
|
package/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _Flatbush = require("./Flatbush");
|
|
5
|
+
const data = [],
|
|
6
|
+
n = 1_000_000;
|
|
7
|
+
|
|
8
|
+
// Generate and position the datapoints in a tangent wave pattern
|
|
9
|
+
for (let i = 0; i < n; i += 1) {
|
|
10
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
11
|
+
const radius = Math.pow(Math.random(), 2) * 100;
|
|
12
|
+
const waveDeviation = (Math.random() - 0.5) * 70;
|
|
13
|
+
const waveValue = Math.tan(theta) * waveDeviation;
|
|
14
|
+
data.push({
|
|
15
|
+
x: 50 + (radius + waveValue) * Math.cos(theta),
|
|
16
|
+
y: 50 + (radius + waveValue) * Math.sin(theta)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const flatbush1M = new _Flatbush.Flatbush(data.length);
|
|
20
|
+
for (let i = 0; i < data.length; i += 1) {
|
|
21
|
+
flatbush1M.add(data[i].x, data[i].y);
|
|
22
|
+
}
|
|
23
|
+
flatbush1M.finish();
|
|
24
|
+
(0, _vitest.describe)('Flatbush benchmarks', () => {
|
|
25
|
+
(0, _vitest.describe)('add + finish', () => {
|
|
26
|
+
(0, _vitest.bench)('add 1M points + finish', () => {
|
|
27
|
+
const flatbush = new _Flatbush.Flatbush(data.length);
|
|
28
|
+
for (let i = 0; i < data.length; i += 1) {
|
|
29
|
+
flatbush.add(data[i].x, data[i].y);
|
|
30
|
+
}
|
|
31
|
+
flatbush.finish();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
(0, _vitest.describe)('search 1M points', () => {
|
|
35
|
+
(0, _vitest.bench)('search 1M points', () => {
|
|
36
|
+
flatbush1M.search(0.4, 0.4, 0.6, 0.6);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
(0, _vitest.describe)('neighbors 1M points', () => {
|
|
40
|
+
(0, _vitest.bench)('neighbors 1M points', () => {
|
|
41
|
+
flatbush1M.neighbors(0.5, 0.5, 1, 0.04, undefined);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -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 {};
|