@mui/x-charts 7.7.1 → 7.9.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.d.ts +3 -3
- package/BarChart/BarElement.d.ts +225 -228
- package/BarChart/BarLabel/BarLabel.d.ts +225 -228
- package/BarChart/BarLabel/getBarLabel.d.ts +1 -1
- package/BarChart/useBarChartProps.d.ts +20 -88
- package/CHANGELOG.md +166 -1
- package/ChartContainer/ChartContainer.d.ts +1 -1
- package/ChartContainer/ChartContainer.js +3 -1
- package/ChartContainer/useChartContainerHooks.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +19 -4
- package/ChartsReferenceLine/common.d.ts +0 -1
- package/ChartsSurface.js +5 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +3 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -39
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +7 -6
- package/ChartsTooltip/ChartsItemTooltipContent.js +4 -27
- package/ChartsTooltip/ChartsTooltip.d.ts +10 -9
- package/ChartsTooltip/ChartsTooltip.js +8 -2
- package/ChartsTooltip/ChartsTooltipTable.d.ts +15 -1
- package/ChartsTooltip/ChartsTooltipTable.js +19 -0
- package/ChartsTooltip/index.d.ts +1 -0
- package/ChartsTooltip/index.js +11 -0
- package/ChartsTooltip/utils.d.ts +7 -6
- package/ChartsTooltip/utils.js +24 -30
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/ChartsXAxis/ChartsXAxis.js +7 -5
- package/ChartsYAxis/ChartsYAxis.js +3 -1
- package/Gauge/GaugeProvider.d.ts +1 -1
- package/LineChart/AnimatedArea.d.ts +225 -228
- package/LineChart/AnimatedLine.d.ts +225 -228
- package/LineChart/LineChart.d.ts +3 -3
- package/LineChart/MarkPlot.js +6 -2
- package/LineChart/useLineChartProps.d.ts +26 -103
- package/LineChart/useLineChartProps.js +3 -3
- package/PieChart/PieArc.d.ts +0 -1
- package/PieChart/PieArcLabel.d.ts +0 -1
- package/PieChart/PieChart.d.ts +3 -3
- package/PieChart/dataTransform/transition.d.ts +0 -1
- package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -2
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/ScatterChart/Scatter.js +7 -5
- package/ScatterChart/ScatterChart.d.ts +3 -3
- package/ScatterChart/ScatterChart.js +3 -1
- package/ScatterChart/useScatterChartProps.d.ts +20 -75
- package/SparkLineChart/SparkLineChart.d.ts +3 -3
- package/context/CartesianProvider/computeValue.d.ts +2 -2
- package/context/CartesianProvider/computeValue.js +36 -5
- package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
- package/context/ZAxisContextProvider.js +7 -2
- package/esm/BarChart/useBarChartProps.js +0 -1
- package/esm/ChartContainer/ChartContainer.js +3 -1
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +19 -4
- package/esm/ChartsSurface.js +5 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +3 -38
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +3 -26
- package/esm/ChartsTooltip/ChartsTooltip.js +8 -2
- package/esm/ChartsTooltip/ChartsTooltipTable.js +20 -0
- package/esm/ChartsTooltip/index.js +2 -1
- package/esm/ChartsTooltip/utils.js +23 -30
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -5
- package/esm/ChartsYAxis/ChartsYAxis.js +3 -1
- package/esm/LineChart/MarkPlot.js +6 -2
- package/esm/LineChart/useLineChartProps.js +3 -3
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/esm/ScatterChart/Scatter.js +7 -5
- package/esm/ScatterChart/ScatterChart.js +3 -1
- package/esm/context/CartesianProvider/computeValue.js +37 -6
- package/esm/context/ZAxisContextProvider.js +7 -2
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useAxis.js +17 -0
- package/esm/hooks/useAxisEvents.js +25 -17
- package/esm/hooks/useInteractionItemProps.js +11 -4
- package/esm/hooks/useScale.js +7 -14
- package/esm/hooks/useTicks.js +2 -1
- package/esm/internals/getSVGPoint.js +11 -0
- package/esm/internals/index.js +4 -0
- package/esm/internals/utils.js +0 -12
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +12 -0
- package/hooks/useAxis.d.ts +2 -0
- package/hooks/useAxis.js +24 -0
- package/hooks/useAxisEvents.js +25 -17
- package/hooks/useChartDimensions.d.ts +1 -1
- package/hooks/useColor.d.ts +1 -1
- package/hooks/useInteractionItemProps.d.ts +4 -2
- package/hooks/useInteractionItemProps.js +11 -4
- package/hooks/useScale.js +6 -14
- package/hooks/useTicks.js +2 -1
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
- package/internals/defaultizeColor.d.ts +68 -68
- package/internals/getSVGPoint.d.ts +6 -0
- package/internals/getSVGPoint.js +17 -0
- package/internals/getWordsByLines.d.ts +0 -1
- package/internals/index.d.ts +4 -0
- package/internals/index.js +40 -0
- package/internals/useAnimatedPath.d.ts +0 -1
- package/internals/utils.d.ts +0 -6
- package/internals/utils.js +0 -13
- package/models/axis.d.ts +1 -2
- package/models/colorMapping.d.ts +1 -1
- package/models/z-axis.d.ts +8 -0
- package/modern/BarChart/useBarChartProps.js +0 -1
- package/modern/ChartContainer/ChartContainer.js +3 -1
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +19 -4
- package/modern/ChartsSurface.js +5 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -38
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +3 -26
- package/modern/ChartsTooltip/ChartsTooltip.js +8 -2
- package/modern/ChartsTooltip/ChartsTooltipTable.js +20 -0
- package/modern/ChartsTooltip/index.js +2 -1
- package/modern/ChartsTooltip/utils.js +23 -30
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +7 -5
- package/modern/ChartsYAxis/ChartsYAxis.js +3 -1
- package/modern/LineChart/MarkPlot.js +6 -2
- package/modern/LineChart/useLineChartProps.js +3 -3
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/modern/ScatterChart/Scatter.js +7 -5
- package/modern/ScatterChart/ScatterChart.js +3 -1
- package/modern/context/CartesianProvider/computeValue.js +37 -6
- package/modern/context/ZAxisContextProvider.js +7 -2
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/useAxis.js +17 -0
- package/modern/hooks/useAxisEvents.js +25 -17
- package/modern/hooks/useInteractionItemProps.js +11 -4
- package/modern/hooks/useScale.js +7 -14
- package/modern/hooks/useTicks.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/getSVGPoint.js +11 -0
- package/modern/internals/index.js +4 -0
- package/modern/internals/utils.js +0 -12
- package/package.json +3 -3
- package/themeAugmentation/props.d.ts +2 -1
package/LineChart/LineChart.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ import { LineHighlightPlotSlots, LineHighlightPlotSlotProps } from './LineHighli
|
|
|
14
14
|
import { ChartsGridProps } from '../ChartsGrid';
|
|
15
15
|
import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
|
|
16
16
|
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '../ChartsOverlay';
|
|
17
|
-
export interface LineChartSlots extends ChartsAxisSlots, AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, ChartsLegendSlots, ChartsTooltipSlots
|
|
17
|
+
export interface LineChartSlots extends ChartsAxisSlots, AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, ChartsLegendSlots, ChartsTooltipSlots<'line'>, ChartsOverlaySlots {
|
|
18
18
|
}
|
|
19
|
-
export interface LineChartSlotProps extends ChartsAxisSlotProps, AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps
|
|
19
|
+
export interface LineChartSlotProps extends ChartsAxisSlotProps, AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps<'line'>, ChartsOverlaySlotProps {
|
|
20
20
|
}
|
|
21
21
|
export interface LineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'plugins' | 'zAxis'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, ChartsOnAxisClickHandlerProps {
|
|
22
22
|
/**
|
|
@@ -29,7 +29,7 @@ export interface LineChartProps extends Omit<ResponsiveChartContainerProps, 'ser
|
|
|
29
29
|
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
30
30
|
* @default { trigger: 'item' }
|
|
31
31
|
*/
|
|
32
|
-
tooltip?: ChartsTooltipProps
|
|
32
|
+
tooltip?: ChartsTooltipProps<'line'>;
|
|
33
33
|
/**
|
|
34
34
|
* Option to display a cartesian grid in the background.
|
|
35
35
|
*/
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -17,6 +17,7 @@ var _constants = require("../constants");
|
|
|
17
17
|
var _utils = require("../internals/utils");
|
|
18
18
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
19
19
|
var _useSeries = require("../hooks/useSeries");
|
|
20
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
20
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
22
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
22
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -42,6 +43,10 @@ function MarkPlot(props) {
|
|
|
42
43
|
const seriesData = (0, _useSeries.useLineSeries)();
|
|
43
44
|
const axisData = (0, _CartesianProvider.useCartesianContext)();
|
|
44
45
|
const chartId = (0, _useChartId.useChartId)();
|
|
46
|
+
const {
|
|
47
|
+
left,
|
|
48
|
+
width
|
|
49
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
45
50
|
const Mark = slots?.mark ?? _MarkElement.MarkElement;
|
|
46
51
|
if (seriesData === undefined) {
|
|
47
52
|
return null;
|
|
@@ -76,13 +81,12 @@ function MarkPlot(props) {
|
|
|
76
81
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
77
82
|
const yScale = yAxis[yAxisKey].scale;
|
|
78
83
|
const xData = xAxis[xAxisKey].data;
|
|
79
|
-
const xRange = xAxis[xAxisKey].scale.range();
|
|
80
84
|
const yRange = yScale.range();
|
|
81
85
|
const isInRange = ({
|
|
82
86
|
x,
|
|
83
87
|
y
|
|
84
88
|
}) => {
|
|
85
|
-
if (x <
|
|
89
|
+
if (x < left || x > left + width) {
|
|
86
90
|
return false;
|
|
87
91
|
}
|
|
88
92
|
if (y < Math.min(...yRange) || y > Math.max(...yRange)) {
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { LineChartProps } from './LineChart';
|
|
2
|
+
import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
|
|
3
|
+
import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
|
|
4
|
+
import { ChartsGridProps } from '../ChartsGrid';
|
|
5
|
+
import { ChartsClipPathProps } from '../ChartsClipPath';
|
|
6
|
+
import { AreaPlotProps } from './AreaPlot';
|
|
7
|
+
import { LinePlotProps } from './LinePlot';
|
|
8
|
+
import { MarkPlotProps } from './MarkPlot';
|
|
9
|
+
import { ChartsOverlayProps } from '../ChartsOverlay';
|
|
10
|
+
import { ChartsAxisProps } from '../ChartsAxis';
|
|
11
|
+
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
12
|
+
import { LineHighlightPlotProps } from './LineHighlightPlot';
|
|
13
|
+
import { ChartsLegendProps } from '../ChartsLegend';
|
|
14
|
+
import { ChartsTooltipProps } from '../ChartsTooltip';
|
|
3
15
|
/**
|
|
4
16
|
* A helper function that extracts LineChartProps from the input props
|
|
5
17
|
* and returns an object with props for the children components of LineChart.
|
|
@@ -8,110 +20,21 @@ import type { LineChartProps } from './LineChart';
|
|
|
8
20
|
* @returns An object with props for the children components of LineChart
|
|
9
21
|
*/
|
|
10
22
|
export declare const useLineChartProps: (props: LineChartProps) => {
|
|
11
|
-
chartContainerProps:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
data?: (number | null)[] | undefined;
|
|
16
|
-
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
17
|
-
id?: import("../internals").SeriesId | undefined;
|
|
18
|
-
dataKey?: string | undefined;
|
|
19
|
-
stackOffset?: import("..").StackOffsetType | undefined;
|
|
20
|
-
valueFormatter?: import("../internals").SeriesValueFormatter<number | null> | undefined;
|
|
21
|
-
highlightScope?: Partial<import("..").HighlightScope> | undefined;
|
|
22
|
-
xAxisKey?: string | undefined;
|
|
23
|
-
yAxisKey?: string | undefined;
|
|
24
|
-
stack?: string | undefined;
|
|
25
|
-
stackOrder?: import("..").StackOrderType | undefined;
|
|
26
|
-
curve?: import("..").CurveType | undefined;
|
|
27
|
-
showMark?: boolean | ((params: import("..").ShowMarkParams<number | Date>) => boolean) | undefined;
|
|
28
|
-
disableHighlight: boolean;
|
|
29
|
-
connectNulls?: boolean | undefined;
|
|
30
|
-
type: "line";
|
|
31
|
-
}[];
|
|
32
|
-
width: number | undefined;
|
|
33
|
-
height: number | undefined;
|
|
34
|
-
margin: Partial<import("..").CardinalDirections<number>> | undefined;
|
|
35
|
-
colors: import("..").ChartsColorPalette | undefined;
|
|
36
|
-
dataset: import("../internals").DatasetType | undefined;
|
|
37
|
-
xAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsXAxisProps>, "id">[];
|
|
38
|
-
yAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsYAxisProps>, "id">[] | undefined;
|
|
39
|
-
sx: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
40
|
-
highlightedItem: import("..").HighlightItemData | null | undefined;
|
|
41
|
-
onHighlightChange: ((highlightedItem: import("..").HighlightItemData | null) => void) | undefined;
|
|
42
|
-
disableAxisListener: boolean;
|
|
43
|
-
};
|
|
44
|
-
axisClickHandlerProps: {
|
|
45
|
-
onAxisClick: ((event: MouseEvent, data: {
|
|
46
|
-
dataIndex: number;
|
|
47
|
-
axisValue?: string | number | Date | undefined;
|
|
48
|
-
seriesValues: Record<string, number | null | undefined>;
|
|
49
|
-
} | null) => void) | undefined;
|
|
50
|
-
};
|
|
51
|
-
gridProps: {
|
|
52
|
-
vertical: boolean | undefined;
|
|
53
|
-
horizontal: boolean | undefined;
|
|
54
|
-
};
|
|
55
|
-
clipPathProps: {
|
|
56
|
-
id: string;
|
|
57
|
-
};
|
|
23
|
+
chartContainerProps: ResponsiveChartContainerProps;
|
|
24
|
+
axisClickHandlerProps: ChartsOnAxisClickHandlerProps;
|
|
25
|
+
gridProps: ChartsGridProps;
|
|
26
|
+
clipPathProps: ChartsClipPathProps;
|
|
58
27
|
clipPathGroupProps: {
|
|
59
28
|
clipPath: string;
|
|
60
29
|
};
|
|
61
|
-
areaPlotProps:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
onLineClick: ((event: import("react").MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: import("..").LineItemIdentifier) => void) | undefined;
|
|
71
|
-
skipAnimation: boolean | undefined;
|
|
72
|
-
};
|
|
73
|
-
markPlotProps: {
|
|
74
|
-
slots: import("./LineChart").LineChartSlots | undefined;
|
|
75
|
-
slotProps: import("./LineChart").LineChartSlotProps | undefined;
|
|
76
|
-
onMarkClick: ((event: import("react").MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: import("..").LineItemIdentifier) => void) | undefined;
|
|
77
|
-
skipAnimation: boolean | undefined;
|
|
78
|
-
};
|
|
79
|
-
overlayProps: {
|
|
80
|
-
slots: import("./LineChart").LineChartSlots | undefined;
|
|
81
|
-
slotProps: import("./LineChart").LineChartSlotProps | undefined;
|
|
82
|
-
loading: boolean | undefined;
|
|
83
|
-
};
|
|
84
|
-
chartsAxisProps: {
|
|
85
|
-
topAxis: string | import("..").ChartsXAxisProps | null | undefined;
|
|
86
|
-
leftAxis: string | import("..").ChartsYAxisProps | null | undefined;
|
|
87
|
-
rightAxis: string | import("..").ChartsYAxisProps | null | undefined;
|
|
88
|
-
bottomAxis: string | import("..").ChartsXAxisProps | null | undefined;
|
|
89
|
-
slots: import("./LineChart").LineChartSlots | undefined;
|
|
90
|
-
slotProps: import("./LineChart").LineChartSlotProps | undefined;
|
|
91
|
-
};
|
|
92
|
-
axisHighlightProps: {
|
|
93
|
-
x: "none" | "line" | "band";
|
|
94
|
-
y?: ("none" | "line" | "band") | undefined;
|
|
95
|
-
};
|
|
96
|
-
lineHighlightPlotProps: {
|
|
97
|
-
slots: import("./LineChart").LineChartSlots | undefined;
|
|
98
|
-
slotProps: import("./LineChart").LineChartSlotProps | undefined;
|
|
99
|
-
};
|
|
100
|
-
legendProps: {
|
|
101
|
-
slots: import("./LineChart").LineChartSlots | undefined;
|
|
102
|
-
slotProps: import("./LineChart").LineChartSlotProps | undefined;
|
|
103
|
-
position?: import("..").AnchorPosition | undefined;
|
|
104
|
-
classes?: Partial<import("..").ChartsLegendClasses> | undefined;
|
|
105
|
-
hidden?: boolean | undefined;
|
|
106
|
-
direction?: import("..").Direction | undefined;
|
|
107
|
-
};
|
|
108
|
-
tooltipProps: {
|
|
109
|
-
slots: import("./LineChart").LineChartSlots | undefined;
|
|
110
|
-
slotProps: import("./LineChart").LineChartSlotProps | undefined;
|
|
111
|
-
trigger?: import("../ChartsTooltip/utils").TriggerOptions | undefined;
|
|
112
|
-
itemContent?: import("react").ElementType<import("..").ChartsItemContentProps<any>, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
113
|
-
axisContent?: import("react").ElementType<import("..").ChartsAxisContentProps, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
114
|
-
classes?: Partial<import("..").ChartsTooltipClasses> | undefined;
|
|
115
|
-
};
|
|
30
|
+
areaPlotProps: AreaPlotProps;
|
|
31
|
+
linePlotProps: LinePlotProps;
|
|
32
|
+
markPlotProps: MarkPlotProps;
|
|
33
|
+
overlayProps: ChartsOverlayProps;
|
|
34
|
+
chartsAxisProps: ChartsAxisProps;
|
|
35
|
+
axisHighlightProps: ChartsAxisHighlightProps;
|
|
36
|
+
lineHighlightPlotProps: LineHighlightPlotProps;
|
|
37
|
+
legendProps: ChartsLegendProps;
|
|
38
|
+
tooltipProps: ChartsTooltipProps<"line">;
|
|
116
39
|
children: import("react").ReactNode;
|
|
117
40
|
};
|
|
@@ -88,19 +88,19 @@ const useLineChartProps = props => {
|
|
|
88
88
|
const areaPlotProps = {
|
|
89
89
|
slots,
|
|
90
90
|
slotProps,
|
|
91
|
-
onAreaClick,
|
|
91
|
+
onItemClick: onAreaClick,
|
|
92
92
|
skipAnimation
|
|
93
93
|
};
|
|
94
94
|
const linePlotProps = {
|
|
95
95
|
slots,
|
|
96
96
|
slotProps,
|
|
97
|
-
onLineClick,
|
|
97
|
+
onItemClick: onLineClick,
|
|
98
98
|
skipAnimation
|
|
99
99
|
};
|
|
100
100
|
const markPlotProps = {
|
|
101
101
|
slots,
|
|
102
102
|
slotProps,
|
|
103
|
-
onMarkClick,
|
|
103
|
+
onItemClick: onMarkClick,
|
|
104
104
|
skipAnimation
|
|
105
105
|
};
|
|
106
106
|
const overlayProps = {
|
package/PieChart/PieArc.d.ts
CHANGED
package/PieChart/PieChart.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { PiePlotProps, PiePlotSlotProps, PiePlotSlots } from './PiePlot';
|
|
|
10
10
|
import { PieValueType } from '../models/seriesType/pie';
|
|
11
11
|
import { ChartsAxisSlots, ChartsAxisSlotProps, ChartsXAxisProps, ChartsYAxisProps } from '../models/axis';
|
|
12
12
|
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '../ChartsOverlay';
|
|
13
|
-
export interface PieChartSlots extends ChartsAxisSlots, PiePlotSlots, ChartsLegendSlots, ChartsTooltipSlots
|
|
13
|
+
export interface PieChartSlots extends ChartsAxisSlots, PiePlotSlots, ChartsLegendSlots, ChartsTooltipSlots<'pie'>, ChartsOverlaySlots {
|
|
14
14
|
}
|
|
15
|
-
export interface PieChartSlotProps extends ChartsAxisSlotProps, PiePlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps
|
|
15
|
+
export interface PieChartSlotProps extends ChartsAxisSlotProps, PiePlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps<'pie'>, ChartsOverlaySlotProps {
|
|
16
16
|
}
|
|
17
17
|
export interface PieChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'leftAxis' | 'bottomAxis' | 'plugins' | 'zAxis'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<PiePlotProps, 'skipAnimation'> {
|
|
18
18
|
/**
|
|
@@ -37,7 +37,7 @@ export interface PieChartProps extends Omit<ResponsiveChartContainerProps, 'seri
|
|
|
37
37
|
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
38
38
|
* @default { trigger: 'item' }
|
|
39
39
|
*/
|
|
40
|
-
tooltip?: ChartsTooltipProps
|
|
40
|
+
tooltip?: ChartsTooltipProps<'pie'>;
|
|
41
41
|
/**
|
|
42
42
|
* The configuration of axes highlight.
|
|
43
43
|
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { ResponsiveChartContainerProps } from './ResponsiveChartContainer';
|
|
3
2
|
/**
|
|
4
3
|
* Wrapping div that take the shape of its parent.
|
|
@@ -6,5 +5,5 @@ import type { ResponsiveChartContainerProps } from './ResponsiveChartContainer';
|
|
|
6
5
|
* @ignore - do not document.
|
|
7
6
|
*/
|
|
8
7
|
export declare const ResizableContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
9
|
-
ownerState: Pick<ResponsiveChartContainerProps,
|
|
8
|
+
ownerState: Pick<ResponsiveChartContainerProps, "width" | "height">;
|
|
10
9
|
}, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -238,6 +238,8 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
238
238
|
})]),
|
|
239
239
|
data: _propTypes.default.array,
|
|
240
240
|
dataKey: _propTypes.default.string,
|
|
241
|
-
id: _propTypes.default.string
|
|
241
|
+
id: _propTypes.default.string,
|
|
242
|
+
max: _propTypes.default.number,
|
|
243
|
+
min: _propTypes.default.number
|
|
242
244
|
}))
|
|
243
245
|
} : void 0;
|
package/ScatterChart/Scatter.js
CHANGED
|
@@ -12,6 +12,7 @@ var _useScale = require("../hooks/useScale");
|
|
|
12
12
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
13
13
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
14
14
|
var _context = require("../context");
|
|
15
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -35,6 +36,10 @@ function Scatter(props) {
|
|
|
35
36
|
markerSize,
|
|
36
37
|
onItemClick
|
|
37
38
|
} = props;
|
|
39
|
+
const {
|
|
40
|
+
left,
|
|
41
|
+
width
|
|
42
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
38
43
|
const {
|
|
39
44
|
useVoronoiInteraction
|
|
40
45
|
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
@@ -47,10 +52,7 @@ function Scatter(props) {
|
|
|
47
52
|
const cleanData = React.useMemo(() => {
|
|
48
53
|
const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
49
54
|
const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
|
|
50
|
-
const xRange = xScale.range();
|
|
51
55
|
const yRange = yScale.range();
|
|
52
|
-
const minXRange = Math.min(...xRange);
|
|
53
|
-
const maxXRange = Math.max(...xRange);
|
|
54
56
|
const minYRange = Math.min(...yRange);
|
|
55
57
|
const maxYRange = Math.max(...yRange);
|
|
56
58
|
const temp = [];
|
|
@@ -58,7 +60,7 @@ function Scatter(props) {
|
|
|
58
60
|
const scatterPoint = series.data[i];
|
|
59
61
|
const x = getXPosition(scatterPoint.x);
|
|
60
62
|
const y = getYPosition(scatterPoint.y);
|
|
61
|
-
const isInRange = x >=
|
|
63
|
+
const isInRange = x >= left && x <= left + width && y >= minYRange && y <= maxYRange;
|
|
62
64
|
const pointCtx = {
|
|
63
65
|
type: 'scatter',
|
|
64
66
|
seriesId: series.id,
|
|
@@ -83,7 +85,7 @@ function Scatter(props) {
|
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
return temp;
|
|
86
|
-
}, [xScale, yScale, series.data, series.id,
|
|
88
|
+
}, [xScale, yScale, left, width, series.data, series.id, isHighlighted, isFaded, getInteractionItemProps, colorGetter, color]);
|
|
87
89
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
88
90
|
children: cleanData.map(dataPoint => /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({
|
|
89
91
|
cx: 0,
|
|
@@ -12,9 +12,9 @@ import { ChartsAxisSlots, ChartsAxisSlotProps } from '../models/axis';
|
|
|
12
12
|
import { ChartsVoronoiHandlerProps } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
13
13
|
import { ChartsGridProps } from '../ChartsGrid';
|
|
14
14
|
import { ZAxisContextProviderProps } from '../context/ZAxisContextProvider';
|
|
15
|
-
export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsTooltipSlots
|
|
15
|
+
export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsTooltipSlots<'scatter'>, ChartsOverlaySlots {
|
|
16
16
|
}
|
|
17
|
-
export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps
|
|
17
|
+
export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps<'scatter'>, ChartsOverlaySlotProps {
|
|
18
18
|
}
|
|
19
19
|
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'plugins'>, Omit<ZAxisContextProviderProps, 'children' | 'dataset'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Omit<ChartsVoronoiHandlerProps, 'onItemClick'> {
|
|
20
20
|
/**
|
|
@@ -27,7 +27,7 @@ export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, '
|
|
|
27
27
|
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
28
28
|
* @default { trigger: 'item' }
|
|
29
29
|
*/
|
|
30
|
-
tooltip?: ChartsTooltipProps
|
|
30
|
+
tooltip?: ChartsTooltipProps<'scatter'>;
|
|
31
31
|
/**
|
|
32
32
|
* The configuration of axes highlight.
|
|
33
33
|
* @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
|
|
@@ -348,6 +348,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
348
348
|
})]),
|
|
349
349
|
data: _propTypes.default.array,
|
|
350
350
|
dataKey: _propTypes.default.string,
|
|
351
|
-
id: _propTypes.default.string
|
|
351
|
+
id: _propTypes.default.string,
|
|
352
|
+
max: _propTypes.default.number,
|
|
353
|
+
min: _propTypes.default.number
|
|
352
354
|
}))
|
|
353
355
|
} : void 0;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { ChartsAxisProps } from '../ChartsAxis';
|
|
2
|
+
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
3
|
+
import { ChartsGridProps } from '../ChartsGrid';
|
|
4
|
+
import { ChartsLegendProps } from '../ChartsLegend';
|
|
5
|
+
import { ChartsOverlayProps } from '../ChartsOverlay';
|
|
6
|
+
import { ChartsTooltipProps } from '../ChartsTooltip';
|
|
7
|
+
import type { ChartsVoronoiHandlerProps } from '../ChartsVoronoiHandler';
|
|
8
|
+
import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
|
|
9
|
+
import { ZAxisContextProviderProps } from '../context';
|
|
2
10
|
import type { ScatterChartProps } from './ScatterChart';
|
|
11
|
+
import type { ScatterPlotProps } from './ScatterPlot';
|
|
3
12
|
/**
|
|
4
13
|
* A helper function that extracts ScatterChartProps from the input props
|
|
5
14
|
* and returns an object with props for the children components of ScatterChart.
|
|
@@ -8,79 +17,15 @@ import type { ScatterChartProps } from './ScatterChart';
|
|
|
8
17
|
* @returns An object with props for the children components of ScatterChart
|
|
9
18
|
*/
|
|
10
19
|
export declare const useScatterChartProps: (props: ScatterChartProps) => {
|
|
11
|
-
chartContainerProps:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
markerSize?: number | undefined;
|
|
22
|
-
disableHover?: boolean | undefined;
|
|
23
|
-
zAxisKey?: string | undefined;
|
|
24
|
-
type: "scatter";
|
|
25
|
-
}[];
|
|
26
|
-
width: number | undefined;
|
|
27
|
-
height: number | undefined;
|
|
28
|
-
margin: Partial<import("..").CardinalDirections<number>> | undefined;
|
|
29
|
-
colors: import("..").ChartsColorPalette | undefined;
|
|
30
|
-
xAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsXAxisProps>, "id">[] | undefined;
|
|
31
|
-
yAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsYAxisProps>, "id">[] | undefined;
|
|
32
|
-
sx: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
33
|
-
highlightedItem: import("..").HighlightItemData | null | undefined;
|
|
34
|
-
onHighlightChange: ((highlightedItem: import("..").HighlightItemData | null) => void) | undefined;
|
|
35
|
-
};
|
|
36
|
-
zAxisProps: {
|
|
37
|
-
zAxis: import("../internals").MakeOptional<import("../internals").ZAxisConfig<any>, "id">[] | undefined;
|
|
38
|
-
};
|
|
39
|
-
voronoiHandlerProps: {
|
|
40
|
-
voronoiMaxRadius: number | undefined;
|
|
41
|
-
onItemClick: ((event: MouseEvent, scatterItemIdentifier: import("..").ScatterItemIdentifier) => void) | undefined;
|
|
42
|
-
};
|
|
43
|
-
chartsAxisProps: {
|
|
44
|
-
topAxis: string | import("..").ChartsXAxisProps | null | undefined;
|
|
45
|
-
leftAxis: string | import("..").ChartsYAxisProps | null | undefined;
|
|
46
|
-
rightAxis: string | import("..").ChartsYAxisProps | null | undefined;
|
|
47
|
-
bottomAxis: string | import("..").ChartsXAxisProps | null | undefined;
|
|
48
|
-
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
49
|
-
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
50
|
-
};
|
|
51
|
-
gridProps: {
|
|
52
|
-
vertical: boolean | undefined;
|
|
53
|
-
horizontal: boolean | undefined;
|
|
54
|
-
};
|
|
55
|
-
scatterPlotProps: {
|
|
56
|
-
onItemClick: ((event: import("react").MouseEvent<SVGElement, MouseEvent>, scatterItemIdentifier: import("..").ScatterItemIdentifier) => void) | undefined;
|
|
57
|
-
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
58
|
-
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
59
|
-
};
|
|
60
|
-
overlayProps: {
|
|
61
|
-
loading: boolean | undefined;
|
|
62
|
-
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
63
|
-
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
64
|
-
};
|
|
65
|
-
legendProps: {
|
|
66
|
-
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
67
|
-
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
68
|
-
position?: import("..").AnchorPosition | undefined;
|
|
69
|
-
classes?: Partial<import("..").ChartsLegendClasses> | undefined;
|
|
70
|
-
hidden?: boolean | undefined;
|
|
71
|
-
direction?: import("..").Direction | undefined;
|
|
72
|
-
};
|
|
73
|
-
axisHighlightProps: {
|
|
74
|
-
x: "none" | "line" | "band";
|
|
75
|
-
y: "none" | "line" | "band";
|
|
76
|
-
};
|
|
77
|
-
tooltipProps: {
|
|
78
|
-
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
79
|
-
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
80
|
-
trigger: import("../ChartsTooltip/utils").TriggerOptions;
|
|
81
|
-
itemContent?: import("react").ElementType<import("..").ChartsItemContentProps<any>, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
82
|
-
axisContent?: import("react").ElementType<import("..").ChartsAxisContentProps, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
83
|
-
classes?: Partial<import("..").ChartsTooltipClasses> | undefined;
|
|
84
|
-
};
|
|
20
|
+
chartContainerProps: ResponsiveChartContainerProps;
|
|
21
|
+
zAxisProps: Omit<ZAxisContextProviderProps, "children">;
|
|
22
|
+
voronoiHandlerProps: ChartsVoronoiHandlerProps;
|
|
23
|
+
chartsAxisProps: ChartsAxisProps;
|
|
24
|
+
gridProps: ChartsGridProps;
|
|
25
|
+
scatterPlotProps: ScatterPlotProps;
|
|
26
|
+
overlayProps: ChartsOverlayProps;
|
|
27
|
+
legendProps: ChartsLegendProps;
|
|
28
|
+
axisHighlightProps: ChartsAxisHighlightProps;
|
|
29
|
+
tooltipProps: ChartsTooltipProps<"scatter">;
|
|
85
30
|
children: import("react").ReactNode;
|
|
86
31
|
};
|
|
@@ -11,9 +11,9 @@ import { LinePlotSlots, LinePlotSlotProps } from '../LineChart/LinePlot';
|
|
|
11
11
|
import { MarkPlotSlots, MarkPlotSlotProps } from '../LineChart/MarkPlot';
|
|
12
12
|
import { LineHighlightPlotSlots, LineHighlightPlotSlotProps } from '../LineChart/LineHighlightPlot';
|
|
13
13
|
import { BarPlotSlots, BarPlotSlotProps } from '../BarChart/BarPlot';
|
|
14
|
-
export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, Omit<BarPlotSlots, 'barLabel'>, ChartsTooltipSlots {
|
|
14
|
+
export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, Omit<BarPlotSlots, 'barLabel'>, ChartsTooltipSlots<'line' | 'bar'> {
|
|
15
15
|
}
|
|
16
|
-
export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps {
|
|
16
|
+
export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps<'line' | 'bar'> {
|
|
17
17
|
}
|
|
18
18
|
export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'margin' | 'plugins'> {
|
|
19
19
|
/**
|
|
@@ -26,7 +26,7 @@ export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps,
|
|
|
26
26
|
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
27
27
|
*/
|
|
28
28
|
yAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>;
|
|
29
|
-
tooltip?: ChartsTooltipProps
|
|
29
|
+
tooltip?: ChartsTooltipProps<'line' | 'bar'>;
|
|
30
30
|
axisHighlight?: ChartsAxisHighlightProps;
|
|
31
31
|
/**
|
|
32
32
|
* Type of plot used.
|
|
@@ -7,13 +7,13 @@ import { FormattedSeries } from '../SeriesContextProvider';
|
|
|
7
7
|
import { MakeOptional } from '../../models/helpers';
|
|
8
8
|
export declare function computeValue(drawingArea: DrawingArea, formattedSeries: FormattedSeries, axis: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>[] | undefined, extremumGetters: {
|
|
9
9
|
[K in CartesianChartSeriesType]?: ExtremumGetter<K>;
|
|
10
|
-
}, axisName: 'y'): {
|
|
10
|
+
}, axisName: 'y', zoomRange?: [number, number]): {
|
|
11
11
|
axis: DefaultizedAxisConfig<ChartsYAxisProps>;
|
|
12
12
|
axisIds: string[];
|
|
13
13
|
};
|
|
14
14
|
export declare function computeValue(drawingArea: DrawingArea, formattedSeries: FormattedSeries, inAxis: MakeOptional<AxisConfig<ScaleName, any, ChartsXAxisProps>, 'id'>[] | undefined, extremumGetters: {
|
|
15
15
|
[K in CartesianChartSeriesType]?: ExtremumGetter<K>;
|
|
16
|
-
}, axisName: 'x'): {
|
|
16
|
+
}, axisName: 'x', zoomRange?: [number, number]): {
|
|
17
17
|
axis: DefaultizedAxisConfig<ChartsAxisProps>;
|
|
18
18
|
axisIds: string[];
|
|
19
19
|
};
|
|
@@ -17,9 +17,26 @@ const getRange = (drawingArea, axisName, isReverse) => {
|
|
|
17
17
|
const range = axisName === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
18
18
|
return isReverse ? range.reverse() : range;
|
|
19
19
|
};
|
|
20
|
+
const zoomedScaleRange = (scaleRange, zoomRange) => {
|
|
21
|
+
const rangeGap = scaleRange[1] - scaleRange[0];
|
|
22
|
+
const zoomGap = zoomRange[1] - zoomRange[0];
|
|
23
|
+
|
|
24
|
+
// If current zoom show the scale between p1 and p2 percents
|
|
25
|
+
// The range should be extended by adding [0, p1] and [p2, 100] segments
|
|
26
|
+
const min = scaleRange[0] - zoomRange[0] * rangeGap / zoomGap;
|
|
27
|
+
const max = scaleRange[1] + (100 - zoomRange[1]) * rangeGap / zoomGap;
|
|
28
|
+
return [min, max];
|
|
29
|
+
};
|
|
30
|
+
const isDateData = data => data?.[0] instanceof Date;
|
|
31
|
+
function createDateFormatter(axis, range) {
|
|
32
|
+
const timeScale = (0, _d3Scale.scaleTime)(axis.data, range);
|
|
33
|
+
return (v, {
|
|
34
|
+
location
|
|
35
|
+
}) => location === 'tick' ? timeScale.tickFormat(axis.tickNumber)(v) : `${v.toLocaleString()}`;
|
|
36
|
+
}
|
|
20
37
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
21
38
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
22
|
-
function computeValue(drawingArea, formattedSeries, inAxis, extremumGetters, axisName) {
|
|
39
|
+
function computeValue(drawingArea, formattedSeries, inAxis, extremumGetters, axisName, zoomRange = [0, 100]) {
|
|
23
40
|
const DEFAULT_AXIS_KEY = axisName === 'x' ? _constants.DEFAULT_X_AXIS_KEY : _constants.DEFAULT_Y_AXIS_KEY;
|
|
24
41
|
const allAxis = [...(inAxis?.map((axis, index) => (0, _extends2.default)({
|
|
25
42
|
id: `defaultized-${axisName}-axis-${index}`
|
|
@@ -39,26 +56,36 @@ function computeValue(drawingArea, formattedSeries, inAxis, extremumGetters, axi
|
|
|
39
56
|
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
40
57
|
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
41
58
|
const scaleRange = axisName === 'x' ? range : [range[1], range[0]];
|
|
59
|
+
const zoomedRange = zoomedScaleRange(scaleRange, zoomRange);
|
|
42
60
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
43
61
|
categoryGapRatio,
|
|
44
62
|
barGapRatio
|
|
45
63
|
}, axis, {
|
|
46
|
-
scale: (0, _d3Scale.scaleBand)(axis.data,
|
|
64
|
+
scale: (0, _d3Scale.scaleBand)(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
47
65
|
tickNumber: axis.data.length,
|
|
48
66
|
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
49
67
|
values: axis.data
|
|
50
68
|
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap))
|
|
51
69
|
});
|
|
70
|
+
if (isDateData(axis.data)) {
|
|
71
|
+
const dateFormatter = createDateFormatter(axis, scaleRange);
|
|
72
|
+
completeAxis[axis.id].valueFormatter = axis.valueFormatter ?? dateFormatter;
|
|
73
|
+
}
|
|
52
74
|
}
|
|
53
75
|
if ((0, _axis.isPointScaleConfig)(axis)) {
|
|
54
76
|
const scaleRange = axisName === 'x' ? range : [...range].reverse();
|
|
77
|
+
const zoomedRange = zoomedScaleRange(scaleRange, zoomRange);
|
|
55
78
|
completeAxis[axis.id] = (0, _extends2.default)({}, axis, {
|
|
56
|
-
scale: (0, _d3Scale.scalePoint)(axis.data,
|
|
79
|
+
scale: (0, _d3Scale.scalePoint)(axis.data, zoomedRange),
|
|
57
80
|
tickNumber: axis.data.length,
|
|
58
81
|
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
59
82
|
values: axis.data
|
|
60
83
|
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap))
|
|
61
84
|
});
|
|
85
|
+
if (isDateData(axis.data)) {
|
|
86
|
+
const dateFormatter = createDateFormatter(axis, scaleRange);
|
|
87
|
+
completeAxis[axis.id].valueFormatter = axis.valueFormatter ?? dateFormatter;
|
|
88
|
+
}
|
|
62
89
|
}
|
|
63
90
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
64
91
|
// Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
|
|
@@ -66,11 +93,15 @@ function computeValue(drawingArea, formattedSeries, inAxis, extremumGetters, axi
|
|
|
66
93
|
}
|
|
67
94
|
const scaleType = axis.scaleType ?? 'linear';
|
|
68
95
|
const extremums = [axis.min ?? minData, axis.max ?? maxData];
|
|
69
|
-
const
|
|
96
|
+
const rawTickNumber = (0, _useTicks.getTickNumber)((0, _extends2.default)({}, axis, {
|
|
70
97
|
range,
|
|
71
98
|
domain: extremums
|
|
72
99
|
}));
|
|
73
|
-
const
|
|
100
|
+
const tickNumber = rawTickNumber / ((zoomRange[1] - zoomRange[0]) / 100);
|
|
101
|
+
const zoomedRange = zoomedScaleRange(range, zoomRange);
|
|
102
|
+
|
|
103
|
+
// TODO: move nice to prop? Disable when there is zoom?
|
|
104
|
+
const scale = (0, _getScale.getScale)(scaleType, extremums, zoomedRange).nice(rawTickNumber);
|
|
74
105
|
const [minDomain, maxDomain] = scale.domain();
|
|
75
106
|
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
76
107
|
completeAxis[axis.id] = (0, _extends2.default)({}, axis, {
|
|
@@ -2,4 +2,4 @@ import type { AxisConfig, ScaleName } from '../../models';
|
|
|
2
2
|
import { ChartsAxisProps } from '../../models/axis';
|
|
3
3
|
import { MakeOptional } from '../../models/helpers';
|
|
4
4
|
import { DatasetType } from '../../models/seriesType/config';
|
|
5
|
-
export declare const normalizeAxis: <T extends ChartsAxisProps, R extends MakeOptional<AxisConfig<ScaleName, any, T>, "id">>(axis: R[] | undefined, dataset: DatasetType | undefined, axisName:
|
|
5
|
+
export declare const normalizeAxis: <T extends ChartsAxisProps, R extends MakeOptional<AxisConfig<ScaleName, any, T>, "id">>(axis: R[] | undefined, dataset: DatasetType | undefined, axisName: "x" | "y") => R[] | undefined;
|
|
@@ -47,7 +47,10 @@ function ZAxisContextProvider(props) {
|
|
|
47
47
|
completedZAxis[axis.id] = (0, _extends2.default)({}, axis, {
|
|
48
48
|
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' && axis.data ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
49
49
|
values: axis.data
|
|
50
|
-
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap)
|
|
50
|
+
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap.type === 'continuous' ? (0, _extends2.default)({
|
|
51
|
+
min: axis.min,
|
|
52
|
+
max: axis.max
|
|
53
|
+
}, axis.colorMap) : axis.colorMap))
|
|
51
54
|
});
|
|
52
55
|
});
|
|
53
56
|
return {
|
|
@@ -93,6 +96,8 @@ process.env.NODE_ENV !== "production" ? ZAxisContextProvider.propTypes = {
|
|
|
93
96
|
})]),
|
|
94
97
|
data: _propTypes.default.array,
|
|
95
98
|
dataKey: _propTypes.default.string,
|
|
96
|
-
id: _propTypes.default.string
|
|
99
|
+
id: _propTypes.default.string,
|
|
100
|
+
max: _propTypes.default.number,
|
|
101
|
+
min: _propTypes.default.number
|
|
97
102
|
}))
|
|
98
103
|
} : void 0;
|