@mui/x-charts 8.13.1 → 8.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +44 -36
- package/CHANGELOG.md +109 -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/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/SparkLineChart/SparkLineChart.js +44 -36
- package/esm/BarChart/BarChart.js +44 -36
- 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/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/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/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/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 +166 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +158 -47
- 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/hooks/animation/useAnimate.js +4 -3
- package/hooks/useScale.d.ts +5 -1
- package/index.js +1 -1
- 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/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 +166 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +158 -47
- 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/package.json +6 -6
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
+
import { ContinuousScaleName, DefaultedAxis } from "../../../../models/axis.js";
|
|
3
|
+
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
import { TickParams } from "../../../../hooks/useTicks.js";
|
|
5
|
+
/**
|
|
6
|
+
* Calculates the initial domain and tick number for a given axis.
|
|
7
|
+
* The domain should still run through the zoom filterMode after this step.
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculateInitialDomainAndTickNumber(axis: DefaultedAxis<ContinuousScaleName>, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], defaultTickNumber: number, preferStrictDomainInLineCharts: boolean | undefined): {
|
|
10
|
+
domain: [NumberValue, NumberValue];
|
|
11
|
+
tickNumber: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the final domain for an axis.
|
|
15
|
+
* After this step, the domain can be used to create the axis scale.
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateFinalDomain(axis: Pick<DefaultedAxis<ContinuousScaleName>, 'id' | 'domainLimit' | 'scaleType'> & TickParams & {
|
|
18
|
+
min?: NumberValue;
|
|
19
|
+
max?: NumberValue;
|
|
20
|
+
}, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, [minData, maxData]: [number | Date, number | Date], tickNumber: number, preferStrictDomainInLineCharts: boolean | undefined): NumberValue[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.calculateFinalDomain = calculateFinalDomain;
|
|
7
|
+
exports.calculateInitialDomainAndTickNumber = calculateInitialDomainAndTickNumber;
|
|
8
|
+
var _getScale = require("../../../getScale");
|
|
9
|
+
var _getAxisDomainLimit = require("./getAxisDomainLimit");
|
|
10
|
+
var _ticks = require("../../../ticks");
|
|
11
|
+
function niceDomain(scaleType, domain, tickNumber) {
|
|
12
|
+
return (0, _getScale.getScale)(scaleType ?? 'linear', domain, [0, 1]).nice(tickNumber).domain();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Calculates the initial domain and tick number for a given axis.
|
|
17
|
+
* The domain should still run through the zoom filterMode after this step.
|
|
18
|
+
*/
|
|
19
|
+
function calculateInitialDomainAndTickNumber(axis, axisDirection, axisIndex, formattedSeries, [minData, maxData], defaultTickNumber, preferStrictDomainInLineCharts) {
|
|
20
|
+
const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
21
|
+
let axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
22
|
+
if (typeof domainLimit === 'function') {
|
|
23
|
+
const {
|
|
24
|
+
min,
|
|
25
|
+
max
|
|
26
|
+
} = domainLimit(minData.valueOf(), maxData.valueOf());
|
|
27
|
+
axisExtrema[0] = min;
|
|
28
|
+
axisExtrema[1] = max;
|
|
29
|
+
}
|
|
30
|
+
const tickNumber = (0, _ticks.getTickNumber)(axis, axisExtrema, defaultTickNumber);
|
|
31
|
+
if (domainLimit === 'nice') {
|
|
32
|
+
axisExtrema = niceDomain(axis.scaleType, axisExtrema, tickNumber);
|
|
33
|
+
}
|
|
34
|
+
axisExtrema = ['min' in axis ? axis.min ?? axisExtrema[0] : axisExtrema[0], 'max' in axis ? axis.max ?? axisExtrema[1] : axisExtrema[1]];
|
|
35
|
+
return {
|
|
36
|
+
domain: axisExtrema,
|
|
37
|
+
tickNumber
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Calculates the final domain for an axis.
|
|
43
|
+
* After this step, the domain can be used to create the axis scale.
|
|
44
|
+
*/
|
|
45
|
+
function calculateFinalDomain(axis, axisDirection, axisIndex, formattedSeries, [minData, maxData], tickNumber, preferStrictDomainInLineCharts) {
|
|
46
|
+
const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
47
|
+
let axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
48
|
+
if (typeof domainLimit === 'function') {
|
|
49
|
+
const {
|
|
50
|
+
min,
|
|
51
|
+
max
|
|
52
|
+
} = domainLimit(minData.valueOf(), maxData.valueOf());
|
|
53
|
+
axisExtrema[0] = min;
|
|
54
|
+
axisExtrema[1] = max;
|
|
55
|
+
}
|
|
56
|
+
if (domainLimit === 'nice') {
|
|
57
|
+
axisExtrema = niceDomain(axis.scaleType, axisExtrema, tickNumber);
|
|
58
|
+
}
|
|
59
|
+
return [axis.min ?? axisExtrema[0], axis.max ?? axisExtrema[1]];
|
|
60
|
+
}
|
|
61
|
+
function getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts) {
|
|
62
|
+
return preferStrictDomainInLineCharts ? (0, _getAxisDomainLimit.getAxisDomainLimit)(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
67
|
+
* @param axisExtrema User defined axis extrema.
|
|
68
|
+
* @param minData Minimum value from the data.
|
|
69
|
+
* @param maxData Maximum value from the data.
|
|
70
|
+
*/
|
|
71
|
+
function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
72
|
+
let min = minData;
|
|
73
|
+
let max = maxData;
|
|
74
|
+
if ('max' in axisExtrema && axisExtrema.max != null && axisExtrema.max < minData) {
|
|
75
|
+
min = axisExtrema.max;
|
|
76
|
+
}
|
|
77
|
+
if ('min' in axisExtrema && axisExtrema.min != null && axisExtrema.min > minData) {
|
|
78
|
+
max = axisExtrema.min;
|
|
79
|
+
}
|
|
80
|
+
if (!('min' in axisExtrema) && !('max' in axisExtrema)) {
|
|
81
|
+
return [min, max];
|
|
82
|
+
}
|
|
83
|
+
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
84
|
+
}
|
|
@@ -1,66 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
-
import { ChartSeriesConfig } from "../../models/index.js";
|
|
5
|
-
import { ZoomData } from "./zoom.types.js";
|
|
1
|
+
import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
+
import { AxisConfig, ChartsAxisProps, D3Scale, DefaultedAxis, ScaleName } from "../../../../models/axis.js";
|
|
6
3
|
import { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
formattedSeries: ProcessedSeries<T>;
|
|
10
|
-
seriesConfig: ChartSeriesConfig<T>;
|
|
11
|
-
zoomMap?: Map<AxisId, ZoomData>;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
14
|
-
*/
|
|
15
|
-
preferStrictDomainInLineCharts?: boolean;
|
|
16
|
-
defaultTickNumber: number;
|
|
17
|
-
};
|
|
18
|
-
export declare function getXAxesScales<T extends ChartSeriesType>({
|
|
19
|
-
drawingArea,
|
|
20
|
-
formattedSeries,
|
|
21
|
-
axis: axes,
|
|
22
|
-
seriesConfig,
|
|
23
|
-
zoomMap,
|
|
24
|
-
preferStrictDomainInLineCharts,
|
|
25
|
-
defaultTickNumber
|
|
26
|
-
}: GetAxesScalesParams<T> & {
|
|
27
|
-
axis?: DefaultedAxis[];
|
|
28
|
-
}): Record<AxisId, ScaleDefinition>;
|
|
29
|
-
export declare function getYAxesScales<T extends ChartSeriesType>({
|
|
30
|
-
drawingArea,
|
|
31
|
-
formattedSeries,
|
|
32
|
-
axis: axes,
|
|
33
|
-
seriesConfig,
|
|
34
|
-
zoomMap,
|
|
35
|
-
preferStrictDomainInLineCharts,
|
|
36
|
-
defaultTickNumber
|
|
37
|
-
}: GetAxesScalesParams<T> & {
|
|
38
|
-
axis?: DefaultedAxis[];
|
|
39
|
-
}): Record<AxisId, ScaleDefinition>;
|
|
40
|
-
export type ScaleDefinition = {
|
|
41
|
-
scale: D3ContinuousScale;
|
|
42
|
-
tickNumber: number;
|
|
43
|
-
} | {
|
|
44
|
-
scale: D3OrdinalScale;
|
|
45
|
-
tickNumber?: never;
|
|
46
|
-
};
|
|
47
|
-
type DomainLimit = 'nice' | 'strict' | ((min: number, max: number) => {
|
|
48
|
-
min: number;
|
|
49
|
-
max: number;
|
|
50
|
-
});
|
|
51
|
-
export declare function getDomainLimit(axis: Pick<DefaultedAxis, 'id' | 'domainLimit'>, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, preferStrictDomainInLineCharts: boolean | undefined): "nice" | "strict" | ((min: number, max: number) => {
|
|
52
|
-
min: number;
|
|
53
|
-
max: number;
|
|
54
|
-
});
|
|
55
|
-
export declare function applyDomainLimit(scale: D3ContinuousScale, axis: {
|
|
56
|
-
min?: number | Date;
|
|
57
|
-
max?: number | Date;
|
|
58
|
-
}, domainLimit: DomainLimit, rawTickNumber: number): void;
|
|
59
|
-
/**
|
|
60
|
-
* Get the actual axis extrema considering the user defined min and max values.
|
|
61
|
-
* @param axisExtrema User defined axis extrema.
|
|
62
|
-
* @param minData Minimum value from the data.
|
|
63
|
-
* @param maxData Maximum value from the data.
|
|
64
|
-
*/
|
|
65
|
-
export declare function getActualAxisExtrema(axisExtrema: Pick<AxisConfig, 'min' | 'max'>, minData: number, maxData: number): [number | Date, number | Date];
|
|
66
|
-
export {};
|
|
4
|
+
export declare function getRange(drawingArea: ChartDrawingArea, axisDirection: 'x' | 'y', axis: AxisConfig<ScaleName, any, ChartsAxisProps>): [number, number];
|
|
5
|
+
export declare function getNormalizedAxisScale(axis: Readonly<DefaultedAxis<ScaleName, any, Readonly<ChartsAxisProps>>>, domain: ReadonlyArray<NumberValue | string>): D3Scale;
|
|
@@ -3,129 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.getDomainLimit = getDomainLimit;
|
|
9
|
-
exports.getXAxesScales = getXAxesScales;
|
|
10
|
-
exports.getYAxesScales = getYAxesScales;
|
|
6
|
+
exports.getNormalizedAxisScale = getNormalizedAxisScale;
|
|
7
|
+
exports.getRange = getRange;
|
|
11
8
|
var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
|
|
12
9
|
var _axis = require("../../../../models/axis");
|
|
13
|
-
var _zoom = require("./zoom");
|
|
14
|
-
var _getAxisDomainLimit = require("./getAxisDomainLimit");
|
|
15
|
-
var _ticks = require("../../../ticks");
|
|
16
10
|
var _getScale = require("../../../getScale");
|
|
17
|
-
var _getAxisExtrema = require("./getAxisExtrema");
|
|
18
11
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
19
12
|
function getRange(drawingArea, axisDirection, axis) {
|
|
20
13
|
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
21
14
|
return axis.reverse ? [range[1], range[0]] : range;
|
|
22
15
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
formattedSeries,
|
|
26
|
-
axis: axes = [],
|
|
27
|
-
seriesConfig,
|
|
28
|
-
zoomMap,
|
|
29
|
-
preferStrictDomainInLineCharts,
|
|
30
|
-
defaultTickNumber
|
|
31
|
-
}) {
|
|
32
|
-
const scales = {};
|
|
33
|
-
axes.forEach((eachAxis, axisIndex) => {
|
|
34
|
-
const axis = eachAxis;
|
|
35
|
-
const zoom = zoomMap?.get(axis.id);
|
|
36
|
-
scales[axis.id] = getAxisScale(axis, 'x', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts, defaultTickNumber);
|
|
37
|
-
});
|
|
38
|
-
return scales;
|
|
39
|
-
}
|
|
40
|
-
function getYAxesScales({
|
|
41
|
-
drawingArea,
|
|
42
|
-
formattedSeries,
|
|
43
|
-
axis: axes = [],
|
|
44
|
-
seriesConfig,
|
|
45
|
-
zoomMap,
|
|
46
|
-
preferStrictDomainInLineCharts,
|
|
47
|
-
defaultTickNumber
|
|
48
|
-
}) {
|
|
49
|
-
const scales = {};
|
|
50
|
-
axes.forEach((eachAxis, axisIndex) => {
|
|
51
|
-
const axis = eachAxis;
|
|
52
|
-
const zoom = zoomMap?.get(axis.id);
|
|
53
|
-
scales[axis.id] = getAxisScale(axis, 'y', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts, defaultTickNumber);
|
|
54
|
-
});
|
|
55
|
-
return scales;
|
|
56
|
-
}
|
|
57
|
-
function getAxisScale(axis, axisDirection, zoom, drawingArea, seriesConfig, axisIndex, formattedSeries,
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
60
|
-
*/
|
|
61
|
-
preferStrictDomainInLineCharts, defaultTickNumber) {
|
|
62
|
-
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
63
|
-
const range = getRange(drawingArea, axisDirection, axis);
|
|
16
|
+
function getNormalizedAxisScale(axis, domain) {
|
|
17
|
+
const range = [0, 1];
|
|
64
18
|
if ((0, _axis.isBandScaleConfig)(axis)) {
|
|
65
19
|
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
66
|
-
|
|
67
|
-
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
68
|
-
const zoomedRange = (0, _zoom.zoomScaleRange)(scaleRange, zoomRange);
|
|
69
|
-
return {
|
|
70
|
-
scale: (0, _d3Scale.scaleBand)(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2)
|
|
71
|
-
};
|
|
20
|
+
return (0, _d3Scale.scaleBand)(domain, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2);
|
|
72
21
|
}
|
|
73
22
|
if ((0, _axis.isPointScaleConfig)(axis)) {
|
|
74
|
-
|
|
75
|
-
const zoomedRange = (0, _zoom.zoomScaleRange)(scaleRange, zoomRange);
|
|
76
|
-
return {
|
|
77
|
-
scale: (0, _d3Scale.scalePoint)(axis.data, zoomedRange)
|
|
78
|
-
};
|
|
23
|
+
return (0, _d3Scale.scalePoint)(domain, range);
|
|
79
24
|
}
|
|
80
25
|
const scaleType = axis.scaleType ?? 'linear';
|
|
81
|
-
const
|
|
82
|
-
const [minData, maxData] = (0, _getAxisExtrema.getAxisExtrema)(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
|
|
83
|
-
const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
84
|
-
if (typeof domainLimit === 'function') {
|
|
85
|
-
const {
|
|
86
|
-
min,
|
|
87
|
-
max
|
|
88
|
-
} = domainLimit(minData, maxData);
|
|
89
|
-
axisExtrema[0] = min;
|
|
90
|
-
axisExtrema[1] = max;
|
|
91
|
-
}
|
|
92
|
-
const rawTickNumber = (0, _ticks.getTickNumber)(axis, axisExtrema, defaultTickNumber);
|
|
93
|
-
const zoomedRange = (0, _zoom.zoomScaleRange)(range, zoomRange);
|
|
94
|
-
const scale = (0, _getScale.getScale)(scaleType, axisExtrema, zoomedRange);
|
|
26
|
+
const scale = (0, _getScale.getScale)(scaleType, domain, range);
|
|
95
27
|
if ((0, _axis.isSymlogScaleConfig)(axis) && axis.constant != null) {
|
|
96
28
|
scale.constant(axis.constant);
|
|
97
29
|
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
scale,
|
|
101
|
-
tickNumber: rawTickNumber
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts) {
|
|
105
|
-
return preferStrictDomainInLineCharts ? (0, _getAxisDomainLimit.getAxisDomainLimit)(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
|
|
106
|
-
}
|
|
107
|
-
function applyDomainLimit(scale, axis, domainLimit, rawTickNumber) {
|
|
108
|
-
if (domainLimit === 'nice') {
|
|
109
|
-
scale.nice(rawTickNumber);
|
|
110
|
-
}
|
|
111
|
-
const [minDomain, maxDomain] = scale.domain();
|
|
112
|
-
scale.domain([axis.min ?? minDomain, axis.max ?? maxDomain]);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Get the actual axis extrema considering the user defined min and max values.
|
|
117
|
-
* @param axisExtrema User defined axis extrema.
|
|
118
|
-
* @param minData Minimum value from the data.
|
|
119
|
-
* @param maxData Maximum value from the data.
|
|
120
|
-
*/
|
|
121
|
-
function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
122
|
-
let min = minData;
|
|
123
|
-
let max = maxData;
|
|
124
|
-
if (axisExtrema.max != null && axisExtrema.max.valueOf() < minData) {
|
|
125
|
-
min = axisExtrema.max;
|
|
126
|
-
}
|
|
127
|
-
if (axisExtrema.min != null && axisExtrema.min.valueOf() > minData) {
|
|
128
|
-
max = axisExtrema.min;
|
|
129
|
-
}
|
|
130
|
-
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
30
|
+
return scale;
|
|
131
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AxisId } from "../../../../models/axis.js";
|
|
2
|
-
export declare const selectorChartPreviewXScales: import("reselect").Selector<any, Record<AxisId,
|
|
1
|
+
import { AxisId, D3Scale } from "../../../../models/axis.js";
|
|
2
|
+
export declare const selectorChartPreviewXScales: import("reselect").Selector<any, Record<AxisId, D3Scale>, [axisId: AxisId]>;
|
|
3
3
|
export declare const selectorChartPreviewComputedXAxis: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").ComputedAxisConfig<import("../../../index.js").ChartsXAxisProps>, [axisId: AxisId]>;
|
|
4
|
-
export declare const selectorChartPreviewYScales: import("reselect").Selector<any, Record<AxisId,
|
|
4
|
+
export declare const selectorChartPreviewYScales: import("reselect").Selector<any, Record<AxisId, D3Scale>, [axisId: AxisId]>;
|
|
5
5
|
export declare const selectorChartPreviewComputedYAxis: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").ComputedAxisConfig<import("../../../index.js").ChartsYAxisProps>, [axisId: AxisId]>;
|
|
@@ -11,8 +11,9 @@ var _computeAxisValue = require("./computeAxisValue");
|
|
|
11
11
|
var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.selectors");
|
|
12
12
|
var _useChartDimensions = require("../../corePlugins/useChartDimensions");
|
|
13
13
|
var _constants = require("../../../constants");
|
|
14
|
-
var _useChartExperimentalFeature = require("../../corePlugins/useChartExperimentalFeature");
|
|
15
14
|
var _getAxisScale = require("./getAxisScale");
|
|
15
|
+
var _zoom = require("./zoom");
|
|
16
|
+
var _scaleGuards = require("../../../scaleGuards");
|
|
16
17
|
function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
17
18
|
return axisDirection === 'x' ? {
|
|
18
19
|
left: 0,
|
|
@@ -30,26 +31,22 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
|
30
31
|
bottom: mainChartDrawingArea.height
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
|
-
const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartDimensions.selectorChartDrawingArea,
|
|
34
|
+
const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartNormalizedXScales, (_, axisId) => axisId], function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
|
|
34
35
|
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
35
36
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
36
37
|
const options = zoomOptions[axisId];
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
axis: xAxes,
|
|
46
|
-
seriesConfig,
|
|
47
|
-
zoomMap,
|
|
48
|
-
preferStrictDomainInLineCharts,
|
|
49
|
-
defaultTickNumber
|
|
38
|
+
const scales = {};
|
|
39
|
+
xAxes?.forEach(eachAxis => {
|
|
40
|
+
const axis = eachAxis;
|
|
41
|
+
const scale = normalizedXScales[axis.id].copy();
|
|
42
|
+
const range = (0, _getAxisScale.getRange)(drawingArea, 'x', axis);
|
|
43
|
+
const zoomedRange = (0, _zoom.zoomScaleRange)(range, [options.minStart, options.maxEnd]);
|
|
44
|
+
scale.range(zoomedRange);
|
|
45
|
+
scales[axis.id] = scale;
|
|
50
46
|
});
|
|
47
|
+
return scales;
|
|
51
48
|
});
|
|
52
|
-
const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXAxis = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup,
|
|
49
|
+
const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXAxis = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartDimensions.selectorChartDrawingArea, selectorChartPreviewXScales, _useChartCartesianAxisRendering.selectorChartXDomains, (_, axisId) => axisId], (xAxes, formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, domains, axisId) => {
|
|
53
50
|
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
54
51
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
55
52
|
const options = zoomOptions[axisId];
|
|
@@ -66,9 +63,7 @@ const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXA
|
|
|
66
63
|
seriesConfig,
|
|
67
64
|
axisDirection: 'x',
|
|
68
65
|
zoomMap,
|
|
69
|
-
|
|
70
|
-
getFilters,
|
|
71
|
-
preferStrictDomainInLineCharts
|
|
66
|
+
domains
|
|
72
67
|
});
|
|
73
68
|
if (computedAxes.axis[axisId]) {
|
|
74
69
|
return {
|
|
@@ -77,26 +72,25 @@ const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXA
|
|
|
77
72
|
}
|
|
78
73
|
return computedAxes.axis;
|
|
79
74
|
});
|
|
80
|
-
const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartDimensions.selectorChartDrawingArea,
|
|
75
|
+
const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartNormalizedYScales, (_, axisId) => axisId], function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
|
|
81
76
|
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
82
77
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
83
78
|
const options = zoomOptions[axisId];
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
preferStrictDomainInLineCharts,
|
|
96
|
-
defaultTickNumber
|
|
79
|
+
const scales = {};
|
|
80
|
+
yAxes?.forEach(eachAxis => {
|
|
81
|
+
const axis = eachAxis;
|
|
82
|
+
const scale = normalizedYScales[axis.id].copy();
|
|
83
|
+
let range = (0, _getAxisScale.getRange)(drawingArea, 'y', axis);
|
|
84
|
+
if ((0, _scaleGuards.isOrdinalScale)(scale)) {
|
|
85
|
+
range = range.reverse();
|
|
86
|
+
}
|
|
87
|
+
const zoomedRange = (0, _zoom.zoomScaleRange)(range, [options.minStart, options.maxEnd]);
|
|
88
|
+
scale.range(zoomedRange);
|
|
89
|
+
scales[axis.id] = scale;
|
|
97
90
|
});
|
|
91
|
+
return scales;
|
|
98
92
|
});
|
|
99
|
-
const selectorChartPreviewComputedYAxis = exports.selectorChartPreviewComputedYAxis = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup,
|
|
93
|
+
const selectorChartPreviewComputedYAxis = exports.selectorChartPreviewComputedYAxis = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartDimensions.selectorChartDrawingArea, selectorChartPreviewYScales, _useChartCartesianAxisRendering.selectorChartYDomains, (_, axisId) => axisId], (yAxes, formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, domains, axisId) => {
|
|
100
94
|
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
101
95
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
102
96
|
const options = zoomOptions[axisId];
|
|
@@ -113,9 +107,7 @@ const selectorChartPreviewComputedYAxis = exports.selectorChartPreviewComputedYA
|
|
|
113
107
|
seriesConfig,
|
|
114
108
|
axisDirection: 'y',
|
|
115
109
|
zoomMap,
|
|
116
|
-
|
|
117
|
-
getFilters,
|
|
118
|
-
preferStrictDomainInLineCharts
|
|
110
|
+
domains
|
|
119
111
|
});
|
|
120
112
|
if (computedAxes.axis[axisId]) {
|
|
121
113
|
return {
|