@mui/x-charts-pro 8.0.0-beta.3 → 8.0.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/BarChartPro/BarChartPro.js +786 -9
- package/CHANGELOG.md +282 -96
- package/ChartDataProviderPro/ChartDataProviderPro.d.ts +1 -1
- package/ChartDataProviderPro/ChartDataProviderPro.js +27 -22
- package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -2
- package/ChartDataProviderPro/useChartDataProviderProProps.js +0 -2
- package/FunnelChart/FunnelChart.js +73 -4
- package/FunnelChart/categoryAxis.types.d.ts +3 -2
- package/FunnelChart/funnelSectionClasses.d.ts +5 -0
- package/FunnelChart/funnelSectionClasses.js +1 -1
- package/FunnelChart/index.d.ts +1 -0
- package/FunnelChart/index.js +12 -0
- package/FunnelChart/useFunnelChartProps.js +3 -3
- package/Heatmap/Heatmap.js +1 -2
- package/Heatmap/heatmapClasses.d.ts +5 -0
- package/Heatmap/heatmapClasses.js +1 -1
- package/LineChartPro/LineChartPro.js +786 -9
- package/ScatterChartPro/ScatterChartPro.js +786 -9
- package/esm/BarChartPro/BarChartPro.js +786 -9
- package/esm/ChartDataProviderPro/ChartDataProviderPro.d.ts +1 -1
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +28 -23
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -2
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.js +0 -2
- package/esm/FunnelChart/FunnelChart.js +73 -4
- package/esm/FunnelChart/categoryAxis.types.d.ts +3 -2
- package/esm/FunnelChart/funnelSectionClasses.d.ts +5 -0
- package/esm/FunnelChart/funnelSectionClasses.js +1 -1
- package/esm/FunnelChart/index.d.ts +1 -0
- package/esm/FunnelChart/index.js +1 -0
- package/esm/FunnelChart/useFunnelChartProps.js +3 -3
- package/esm/Heatmap/Heatmap.js +1 -2
- package/esm/Heatmap/heatmapClasses.d.ts +5 -0
- package/esm/Heatmap/heatmapClasses.js +1 -1
- package/esm/LineChartPro/LineChartPro.js +786 -9
- package/esm/ScatterChartPro/ScatterChartPro.js +786 -9
- package/esm/index.js +1 -1
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +28 -35
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +7 -7
- package/index.js +1 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.js +28 -34
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +7 -7
- package/package.json +6 -14
- package/esm/internals/utils/releaseInfo.d.ts +0 -1
- package/esm/internals/utils/releaseInfo.js +0 -13
- package/internals/utils/releaseInfo.d.ts +0 -1
- package/internals/utils/releaseInfo.js +0 -21
- package/modern/BarChartPro/BarChartPro.d.ts +0 -18
- package/modern/BarChartPro/BarChartPro.js +0 -406
- package/modern/BarChartPro/BarChartPro.plugins.d.ts +0 -4
- package/modern/BarChartPro/BarChartPro.plugins.js +0 -3
- package/modern/BarChartPro/index.d.ts +0 -1
- package/modern/BarChartPro/index.js +0 -1
- package/modern/ChartContainerPro/ChartContainerPro.d.ts +0 -35
- package/modern/ChartContainerPro/ChartContainerPro.js +0 -290
- package/modern/ChartContainerPro/index.d.ts +0 -2
- package/modern/ChartContainerPro/index.js +0 -2
- package/modern/ChartContainerPro/useChartContainerProProps.d.ts +0 -9
- package/modern/ChartContainerPro/useChartContainerProProps.js +0 -35
- package/modern/ChartDataProviderPro/ChartDataProviderPro.d.ts +0 -37
- package/modern/ChartDataProviderPro/ChartDataProviderPro.js +0 -106
- package/modern/ChartDataProviderPro/index.d.ts +0 -2
- package/modern/ChartDataProviderPro/index.js +0 -2
- package/modern/ChartDataProviderPro/useChartDataProviderProProps.d.ts +0 -8
- package/modern/ChartDataProviderPro/useChartDataProviderProProps.js +0 -15
- package/modern/FunnelChart/FunnelChart.d.ts +0 -37
- package/modern/FunnelChart/FunnelChart.js +0 -212
- package/modern/FunnelChart/FunnelPlot.d.ts +0 -16
- package/modern/FunnelChart/FunnelPlot.js +0 -184
- package/modern/FunnelChart/FunnelSection.d.ts +0 -15
- package/modern/FunnelChart/FunnelSection.js +0 -56
- package/modern/FunnelChart/categoryAxis.types.d.ts +0 -24
- package/modern/FunnelChart/categoryAxis.types.js +0 -1
- package/modern/FunnelChart/funnel.types.d.ts +0 -124
- package/modern/FunnelChart/funnel.types.js +0 -1
- package/modern/FunnelChart/funnelPlotSlots.types.d.ts +0 -20
- package/modern/FunnelChart/funnelPlotSlots.types.js +0 -1
- package/modern/FunnelChart/funnelSectionClasses.d.ts +0 -13
- package/modern/FunnelChart/funnelSectionClasses.js +0 -20
- package/modern/FunnelChart/funnelSlots.types.d.ts +0 -19
- package/modern/FunnelChart/funnelSlots.types.js +0 -1
- package/modern/FunnelChart/funnelStepCurve.d.ts +0 -4
- package/modern/FunnelChart/funnelStepCurve.js +0 -67
- package/modern/FunnelChart/index.d.ts +0 -7
- package/modern/FunnelChart/index.js +0 -5
- package/modern/FunnelChart/labelUtils.d.ts +0 -42
- package/modern/FunnelChart/labelUtils.js +0 -166
- package/modern/FunnelChart/seriesConfig/extremums.d.ts +0 -3
- package/modern/FunnelChart/seriesConfig/extremums.js +0 -42
- package/modern/FunnelChart/seriesConfig/getColor.d.ts +0 -3
- package/modern/FunnelChart/seriesConfig/getColor.js +0 -4
- package/modern/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +0 -3
- package/modern/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +0 -11
- package/modern/FunnelChart/seriesConfig/index.d.ts +0 -2
- package/modern/FunnelChart/seriesConfig/index.js +0 -15
- package/modern/FunnelChart/seriesConfig/legend.d.ts +0 -3
- package/modern/FunnelChart/seriesConfig/legend.js +0 -25
- package/modern/FunnelChart/seriesConfig/seriesProcessor.d.ts +0 -3
- package/modern/FunnelChart/seriesConfig/seriesProcessor.js +0 -89
- package/modern/FunnelChart/seriesConfig/tooltip.d.ts +0 -3
- package/modern/FunnelChart/seriesConfig/tooltip.js +0 -29
- package/modern/FunnelChart/useFunnelChartProps.d.ts +0 -30
- package/modern/FunnelChart/useFunnelChartProps.js +0 -161
- package/modern/Heatmap/Heatmap.d.ts +0 -57
- package/modern/Heatmap/Heatmap.js +0 -389
- package/modern/Heatmap/Heatmap.plugins.d.ts +0 -3
- package/modern/Heatmap/Heatmap.plugins.js +0 -2
- package/modern/Heatmap/HeatmapItem.d.ts +0 -49
- package/modern/Heatmap/HeatmapItem.js +0 -106
- package/modern/Heatmap/HeatmapPlot.d.ts +0 -8
- package/modern/Heatmap/HeatmapPlot.js +0 -59
- package/modern/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +0 -16
- package/modern/Heatmap/HeatmapTooltip/HeatmapTooltip.js +0 -284
- package/modern/Heatmap/HeatmapTooltip/HeatmapTooltipAxesValue.d.ts +0 -4
- package/modern/Heatmap/HeatmapTooltip/HeatmapTooltipAxesValue.js +0 -22
- package/modern/Heatmap/HeatmapTooltip/index.d.ts +0 -1
- package/modern/Heatmap/HeatmapTooltip/index.js +0 -1
- package/modern/Heatmap/heatmapClasses.d.ts +0 -11
- package/modern/Heatmap/heatmapClasses.js +0 -14
- package/modern/Heatmap/index.d.ts +0 -4
- package/modern/Heatmap/index.js +0 -4
- package/modern/Heatmap/seriesConfig/extremums.d.ts +0 -2
- package/modern/Heatmap/seriesConfig/extremums.js +0 -8
- package/modern/Heatmap/seriesConfig/getColor.d.ts +0 -3
- package/modern/Heatmap/seriesConfig/getColor.js +0 -15
- package/modern/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +0 -3
- package/modern/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +0 -8
- package/modern/Heatmap/seriesConfig/index.d.ts +0 -2
- package/modern/Heatmap/seriesConfig/index.js +0 -14
- package/modern/Heatmap/seriesConfig/seriesProcessor.d.ts +0 -3
- package/modern/Heatmap/seriesConfig/seriesProcessor.js +0 -21
- package/modern/Heatmap/seriesConfig/tooltip.d.ts +0 -3
- package/modern/Heatmap/seriesConfig/tooltip.js +0 -25
- package/modern/LineChartPro/LineChartPro.d.ts +0 -17
- package/modern/LineChartPro/LineChartPro.js +0 -403
- package/modern/LineChartPro/LineChartPro.plugins.d.ts +0 -4
- package/modern/LineChartPro/LineChartPro.plugins.js +0 -3
- package/modern/LineChartPro/index.d.ts +0 -1
- package/modern/LineChartPro/index.js +0 -1
- package/modern/ScatterChartPro/ScatterChartPro.d.ts +0 -17
- package/modern/ScatterChartPro/ScatterChartPro.js +0 -397
- package/modern/ScatterChartPro/ScatterChartPro.plugins.d.ts +0 -4
- package/modern/ScatterChartPro/ScatterChartPro.plugins.js +0 -3
- package/modern/ScatterChartPro/index.d.ts +0 -1
- package/modern/ScatterChartPro/index.js +0 -1
- package/modern/hooks/index.d.ts +0 -2
- package/modern/hooks/index.js +0 -2
- package/modern/hooks/useFunnelSeries.d.ts +0 -33
- package/modern/hooks/useFunnelSeries.js +0 -42
- package/modern/hooks/useHeatmapSeries.d.ts +0 -33
- package/modern/hooks/useHeatmapSeries.js +0 -42
- package/modern/hooks/zoom/index.d.ts +0 -1
- package/modern/hooks/zoom/index.js +0 -1
- package/modern/hooks/zoom/useIsZoomInteracting.d.ts +0 -6
- package/modern/hooks/zoom/useIsZoomInteracting.js +0 -14
- package/modern/index.d.ts +0 -34
- package/modern/index.js +0 -45
- package/modern/internals/plugins/allPlugins.d.ts +0 -8
- package/modern/internals/plugins/allPlugins.js +0 -6
- package/modern/internals/plugins/useChartProZoom/index.d.ts +0 -3
- package/modern/internals/plugins/useChartProZoom/index.js +0 -3
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.d.ts +0 -3
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.js +0 -350
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +0 -203
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +0 -4
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +0 -53
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.types.js +0 -1
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.utils.d.ts +0 -45
- package/modern/internals/plugins/useChartProZoom/useChartProZoom.utils.js +0 -126
- package/modern/internals/utils/releaseInfo.d.ts +0 -1
- package/modern/internals/utils/releaseInfo.js +0 -13
- package/modern/models/index.d.ts +0 -2
- package/modern/models/index.js +0 -2
- package/modern/models/seriesType/heatmap.d.ts +0 -28
- package/modern/models/seriesType/heatmap.js +0 -1
- package/modern/models/seriesType/index.d.ts +0 -1
- package/modern/models/seriesType/index.js +0 -1
- package/modern/package.json +0 -1
- package/modern/themeAugmentation/components.d.ts +0 -23
- package/modern/themeAugmentation/index.d.ts +0 -4
- package/modern/themeAugmentation/index.js +0 -0
- package/modern/themeAugmentation/overrides.d.ts +0 -11
- package/modern/themeAugmentation/props.d.ts +0 -20
- package/modern/typeOverloads/index.d.ts +0 -1
- package/modern/typeOverloads/index.js +0 -1
- package/modern/typeOverloads/modules.d.ts +0 -33
- package/modern/typeOverloads/modules.js +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
-
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
-
function getFunnelSectionUtilityClass(slot) {
|
|
5
|
-
return generateUtilityClass('MuiFunnelSection', slot);
|
|
6
|
-
}
|
|
7
|
-
export const useUtilityClasses = props => {
|
|
8
|
-
const {
|
|
9
|
-
classes,
|
|
10
|
-
seriesId
|
|
11
|
-
} = props;
|
|
12
|
-
const slots = {
|
|
13
|
-
root: ['root', `series-${seriesId}`],
|
|
14
|
-
highlighted: ['highlighted'],
|
|
15
|
-
faded: ['faded'],
|
|
16
|
-
label: ['label']
|
|
17
|
-
};
|
|
18
|
-
return composeClasses(slots, getFunnelSectionUtilityClass, classes);
|
|
19
|
-
};
|
|
20
|
-
export const funnelSectionClasses = generateUtilityClasses('MuiFunnelSection', ['root', 'highlighted', 'faded', 'label']);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
|
|
2
|
-
import { ChartsTooltipSlotProps, ChartsTooltipSlots } from '@mui/x-charts/ChartsTooltip';
|
|
3
|
-
import { ChartsAxisSlotProps, ChartsAxisSlots } from '@mui/x-charts/internals';
|
|
4
|
-
import { ChartsLegendSlotProps, ChartsLegendSlots } from '@mui/x-charts/ChartsLegend';
|
|
5
|
-
import { FunnelPlotSlotProps, FunnelPlotSlots } from "./funnelPlotSlots.types.js";
|
|
6
|
-
export interface FunnelChartSlots extends ChartsAxisSlots, FunnelPlotSlots, ChartsLegendSlots, ChartsTooltipSlots, ChartsOverlaySlots, ChartsAxisSlots {}
|
|
7
|
-
export interface FunnelChartSlotProps extends ChartsAxisSlotProps, FunnelPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps, ChartsOverlaySlotProps, ChartsAxisSlotProps {}
|
|
8
|
-
export interface FunnelChartSlotExtension {
|
|
9
|
-
/**
|
|
10
|
-
* Overridable component slots.
|
|
11
|
-
* @default {}
|
|
12
|
-
*/
|
|
13
|
-
slots?: FunnelChartSlots;
|
|
14
|
-
/**
|
|
15
|
-
* The props used for each component slot.
|
|
16
|
-
* @default {}
|
|
17
|
-
*/
|
|
18
|
-
slotProps?: FunnelChartSlotProps;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a custom "step" curve generator for the funnel chart.
|
|
3
|
-
* It is used to draw the funnel using "rectangles" without having to rework the rendering logic.
|
|
4
|
-
*
|
|
5
|
-
* It is based on the d3-shape step curve generator.
|
|
6
|
-
* https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/step.js
|
|
7
|
-
*/
|
|
8
|
-
class FunnelStep {
|
|
9
|
-
constructor(context, isHorizontal) {
|
|
10
|
-
this.context = void 0;
|
|
11
|
-
this.line = NaN;
|
|
12
|
-
this.x = NaN;
|
|
13
|
-
this.y = NaN;
|
|
14
|
-
this.currentPoint = 0;
|
|
15
|
-
this.isHorizontal = false;
|
|
16
|
-
this.context = context;
|
|
17
|
-
this.isHorizontal = isHorizontal;
|
|
18
|
-
}
|
|
19
|
-
areaStart() {
|
|
20
|
-
this.line = 0;
|
|
21
|
-
}
|
|
22
|
-
areaEnd() {
|
|
23
|
-
this.line = NaN;
|
|
24
|
-
}
|
|
25
|
-
lineStart() {
|
|
26
|
-
this.x = NaN;
|
|
27
|
-
this.y = NaN;
|
|
28
|
-
this.currentPoint = 0;
|
|
29
|
-
}
|
|
30
|
-
lineEnd() {
|
|
31
|
-
if (this.currentPoint === 2) {
|
|
32
|
-
this.context.lineTo(this.x, this.y);
|
|
33
|
-
}
|
|
34
|
-
if (this.line || this.line !== 0 && this.currentPoint === 1) {
|
|
35
|
-
this.context.closePath();
|
|
36
|
-
}
|
|
37
|
-
if (this.line >= 0) {
|
|
38
|
-
this.line = 1 - this.line;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
point(x, y) {
|
|
42
|
-
x = +x;
|
|
43
|
-
y = +y;
|
|
44
|
-
if (this.currentPoint === 0) {
|
|
45
|
-
this.context.moveTo(x, y);
|
|
46
|
-
} else if (this.isHorizontal && (this.currentPoint === 2 || this.currentPoint === 1)) {
|
|
47
|
-
this.context.lineTo(x, this.y);
|
|
48
|
-
this.context.lineTo(x, y);
|
|
49
|
-
} else if (this.currentPoint === 3 && !this.isHorizontal) {
|
|
50
|
-
this.context.lineTo(x, this.y);
|
|
51
|
-
this.context.lineTo(x, y);
|
|
52
|
-
} else {
|
|
53
|
-
this.context.lineTo(this.x, y);
|
|
54
|
-
this.context.lineTo(x, y);
|
|
55
|
-
}
|
|
56
|
-
this.currentPoint += 1;
|
|
57
|
-
this.x = x;
|
|
58
|
-
this.y = y;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const funnelHorizontalStepCurve = context => {
|
|
62
|
-
return new FunnelStep(context, true);
|
|
63
|
-
};
|
|
64
|
-
const funnelVerticalStepCurve = context => {
|
|
65
|
-
return new FunnelStep(context, false);
|
|
66
|
-
};
|
|
67
|
-
export { funnelHorizontalStepCurve, funnelVerticalStepCurve };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { FunnelChart as Unstable_FunnelChart } from "./FunnelChart.js";
|
|
2
|
-
export type { FunnelChartProps } from './FunnelChart';
|
|
3
|
-
export * from "./FunnelPlot.js";
|
|
4
|
-
export * from "./funnel.types.js";
|
|
5
|
-
export * from "./funnelSlots.types.js";
|
|
6
|
-
export { funnelSectionClasses } from "./funnelSectionClasses.js";
|
|
7
|
-
export type { FunnelSectionClasses } from './funnelSectionClasses';
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FunnelDataPoints, FunnelLabelOptions } from "./funnel.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* It tries to keep the label inside the bounds of the section based on the position.
|
|
4
|
-
*
|
|
5
|
-
* @returns The text anchor and dominant baseline of the label.
|
|
6
|
-
*/
|
|
7
|
-
export declare const alignLabel: ({
|
|
8
|
-
position,
|
|
9
|
-
textAnchor,
|
|
10
|
-
dominantBaseline
|
|
11
|
-
}: Omit<FunnelLabelOptions, "margin">) => {
|
|
12
|
-
textAnchor: string;
|
|
13
|
-
dominantBaseline: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* This function calculates the position of the label based on the position and margin.
|
|
17
|
-
*
|
|
18
|
-
* It is quite complex, because it needs to calculate the position based on the position of the points of a rectangle.
|
|
19
|
-
* And we are manually calculating each possible position of the label.
|
|
20
|
-
*
|
|
21
|
-
* @returns The x and y position of the label.
|
|
22
|
-
*/
|
|
23
|
-
export declare const positionLabel: ({
|
|
24
|
-
position,
|
|
25
|
-
offset,
|
|
26
|
-
xPosition,
|
|
27
|
-
yPosition,
|
|
28
|
-
isHorizontal,
|
|
29
|
-
values,
|
|
30
|
-
dataIndex,
|
|
31
|
-
baseScaleData
|
|
32
|
-
}: Omit<FunnelLabelOptions, "textAnchor" | "dominantBaseline"> & {
|
|
33
|
-
xPosition: (value: number, bandIndex: number, stackOffset?: number, useBand?: boolean) => number | undefined;
|
|
34
|
-
yPosition: (value: number, bandIndex: number, stackOffset?: number, useBand?: boolean) => number | undefined;
|
|
35
|
-
isHorizontal: boolean;
|
|
36
|
-
values: readonly FunnelDataPoints[];
|
|
37
|
-
dataIndex: number;
|
|
38
|
-
baseScaleData: readonly number[];
|
|
39
|
-
}) => {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* It tries to keep the label inside the bounds of the section based on the position.
|
|
3
|
-
*
|
|
4
|
-
* @returns The text anchor and dominant baseline of the label.
|
|
5
|
-
*/
|
|
6
|
-
export const alignLabel = ({
|
|
7
|
-
position,
|
|
8
|
-
textAnchor,
|
|
9
|
-
dominantBaseline
|
|
10
|
-
}) => {
|
|
11
|
-
const vertical = position?.vertical ?? 'middle';
|
|
12
|
-
const horizontal = position?.horizontal ?? 'center';
|
|
13
|
-
let anchor = 'middle';
|
|
14
|
-
let baseline = 'central';
|
|
15
|
-
if (vertical === 'top') {
|
|
16
|
-
baseline = 'hanging';
|
|
17
|
-
} else if (vertical === 'bottom') {
|
|
18
|
-
baseline = 'baseline';
|
|
19
|
-
}
|
|
20
|
-
if (horizontal === 'start') {
|
|
21
|
-
anchor = 'start';
|
|
22
|
-
} else if (horizontal === 'end') {
|
|
23
|
-
anchor = 'end';
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
textAnchor: textAnchor ?? anchor,
|
|
27
|
-
dominantBaseline: dominantBaseline ?? baseline
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* This function calculates the position of the label based on the position and margin.
|
|
33
|
-
*
|
|
34
|
-
* It is quite complex, because it needs to calculate the position based on the position of the points of a rectangle.
|
|
35
|
-
* And we are manually calculating each possible position of the label.
|
|
36
|
-
*
|
|
37
|
-
* @returns The x and y position of the label.
|
|
38
|
-
*/
|
|
39
|
-
export const positionLabel = ({
|
|
40
|
-
position,
|
|
41
|
-
offset,
|
|
42
|
-
xPosition,
|
|
43
|
-
yPosition,
|
|
44
|
-
isHorizontal,
|
|
45
|
-
values,
|
|
46
|
-
dataIndex,
|
|
47
|
-
baseScaleData
|
|
48
|
-
}) => {
|
|
49
|
-
const vertical = position?.vertical ?? 'middle';
|
|
50
|
-
const horizontal = position?.horizontal ?? 'center';
|
|
51
|
-
let x = 0;
|
|
52
|
-
let y = 0;
|
|
53
|
-
let minTop = 0;
|
|
54
|
-
let maxTop = 0;
|
|
55
|
-
let minBottom = 0;
|
|
56
|
-
let maxBottom = 0;
|
|
57
|
-
let minLeft = 0;
|
|
58
|
-
let maxLeft = 0;
|
|
59
|
-
let minRight = 0;
|
|
60
|
-
let maxRight = 0;
|
|
61
|
-
let center = 0;
|
|
62
|
-
let leftCenter = 0;
|
|
63
|
-
let rightCenter = 0;
|
|
64
|
-
let middle = 0;
|
|
65
|
-
let topMiddle = 0;
|
|
66
|
-
let bottomMiddle = 0;
|
|
67
|
-
const mv = typeof offset === 'number' ? offset : offset?.y ?? 0;
|
|
68
|
-
const mh = typeof offset === 'number' ? offset : offset?.x ?? 0;
|
|
69
|
-
const stackOffset = values[0].stackOffset;
|
|
70
|
-
if (isHorizontal) {
|
|
71
|
-
maxTop = yPosition(values[0].y, baseScaleData[dataIndex], stackOffset) - mv;
|
|
72
|
-
minTop = yPosition(values[1].y, baseScaleData[dataIndex], stackOffset) - mv;
|
|
73
|
-
minBottom = yPosition(values[2].y, baseScaleData[dataIndex], stackOffset) + mv;
|
|
74
|
-
maxBottom = yPosition(values[3].y, baseScaleData[dataIndex], stackOffset) + mv;
|
|
75
|
-
minRight = 0;
|
|
76
|
-
maxRight = xPosition(Math.min(...values.map(v => v.x)), baseScaleData[dataIndex], stackOffset, true) + mh;
|
|
77
|
-
minLeft = 0;
|
|
78
|
-
maxLeft = xPosition(Math.max(...values.map(v => v.x)), baseScaleData[dataIndex], stackOffset) + mh;
|
|
79
|
-
center = maxRight - (maxRight - maxLeft) / 2;
|
|
80
|
-
leftCenter = 0;
|
|
81
|
-
rightCenter = 0;
|
|
82
|
-
middle = yPosition(0, baseScaleData[dataIndex], stackOffset) - mv;
|
|
83
|
-
topMiddle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, baseScaleData[dataIndex], stackOffset) - mv;
|
|
84
|
-
bottomMiddle = yPosition(values[3].y - (values[3].y - values[2].y) / 2, baseScaleData[dataIndex], stackOffset) + mv;
|
|
85
|
-
} else {
|
|
86
|
-
minTop = 0;
|
|
87
|
-
maxTop = yPosition(Math.max(...values.map(v => v.y)), baseScaleData[dataIndex], stackOffset) - mv;
|
|
88
|
-
minBottom = 0;
|
|
89
|
-
maxBottom = yPosition(Math.min(...values.map(v => v.y)), baseScaleData[dataIndex], stackOffset, true) - mv;
|
|
90
|
-
maxRight = xPosition(values[0].x, baseScaleData[dataIndex], stackOffset) + mh;
|
|
91
|
-
minRight = xPosition(values[1].x, baseScaleData[dataIndex], stackOffset) + mh;
|
|
92
|
-
minLeft = xPosition(values[2].x, baseScaleData[dataIndex], stackOffset) - mh;
|
|
93
|
-
maxLeft = xPosition(values[3].x, baseScaleData[dataIndex], stackOffset) - mh;
|
|
94
|
-
center = xPosition(0, baseScaleData[dataIndex], stackOffset) - mh;
|
|
95
|
-
rightCenter = xPosition(values[0].x - (values[0].x - values[1].x) / 2, baseScaleData[dataIndex], stackOffset) + mh;
|
|
96
|
-
leftCenter = xPosition(values[3].x - (values[3].x - values[2].x) / 2, baseScaleData[dataIndex], stackOffset) - mh;
|
|
97
|
-
middle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, baseScaleData[dataIndex], stackOffset);
|
|
98
|
-
middle = maxTop - (maxTop - maxBottom) / 2;
|
|
99
|
-
topMiddle = 0;
|
|
100
|
-
bottomMiddle = 0;
|
|
101
|
-
}
|
|
102
|
-
if (isHorizontal) {
|
|
103
|
-
if (horizontal === 'center') {
|
|
104
|
-
x = center;
|
|
105
|
-
if (vertical === 'top') {
|
|
106
|
-
y = topMiddle;
|
|
107
|
-
} else if (vertical === 'middle') {
|
|
108
|
-
y = middle;
|
|
109
|
-
} else if (vertical === 'bottom') {
|
|
110
|
-
y = bottomMiddle;
|
|
111
|
-
}
|
|
112
|
-
} else if (horizontal === 'start') {
|
|
113
|
-
x = maxLeft;
|
|
114
|
-
if (vertical === 'top') {
|
|
115
|
-
y = maxTop;
|
|
116
|
-
} else if (vertical === 'middle') {
|
|
117
|
-
y = middle;
|
|
118
|
-
} else if (vertical === 'bottom') {
|
|
119
|
-
y = maxBottom;
|
|
120
|
-
}
|
|
121
|
-
} else if (horizontal === 'end') {
|
|
122
|
-
x = maxRight;
|
|
123
|
-
if (vertical === 'top') {
|
|
124
|
-
y = minTop;
|
|
125
|
-
} else if (vertical === 'middle') {
|
|
126
|
-
y = middle;
|
|
127
|
-
} else if (vertical === 'bottom') {
|
|
128
|
-
y = minBottom;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (!isHorizontal) {
|
|
133
|
-
if (vertical === 'middle') {
|
|
134
|
-
y = middle;
|
|
135
|
-
if (horizontal === 'start') {
|
|
136
|
-
x = leftCenter;
|
|
137
|
-
} else if (horizontal === 'center') {
|
|
138
|
-
x = center;
|
|
139
|
-
} else if (horizontal === 'end') {
|
|
140
|
-
x = rightCenter;
|
|
141
|
-
}
|
|
142
|
-
} else if (vertical === 'top') {
|
|
143
|
-
y = maxTop;
|
|
144
|
-
if (horizontal === 'start') {
|
|
145
|
-
x = maxLeft;
|
|
146
|
-
} else if (horizontal === 'center') {
|
|
147
|
-
x = center;
|
|
148
|
-
} else if (horizontal === 'end') {
|
|
149
|
-
x = maxRight;
|
|
150
|
-
}
|
|
151
|
-
} else if (vertical === 'bottom') {
|
|
152
|
-
y = maxBottom;
|
|
153
|
-
if (horizontal === 'start') {
|
|
154
|
-
x = minLeft;
|
|
155
|
-
} else if (horizontal === 'center') {
|
|
156
|
-
x = center;
|
|
157
|
-
} else if (horizontal === 'end') {
|
|
158
|
-
x = minRight;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
x,
|
|
164
|
-
y
|
|
165
|
-
};
|
|
166
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const getValueExtremum = (direction, isHorizontal, params) => {
|
|
2
|
-
const {
|
|
3
|
-
series,
|
|
4
|
-
axis,
|
|
5
|
-
isDefaultAxis
|
|
6
|
-
} = params;
|
|
7
|
-
return Object.keys(series)
|
|
8
|
-
// Keep only series that are associated with the current axis
|
|
9
|
-
.reduce((acc, seriesId) => {
|
|
10
|
-
const yAxisId = series[seriesId].yAxisId;
|
|
11
|
-
const xAxisId = series[seriesId].xAxisId;
|
|
12
|
-
const {
|
|
13
|
-
dataPoints
|
|
14
|
-
} = series[seriesId];
|
|
15
|
-
if (
|
|
16
|
-
// We skip except if the axis id is not defined for the direction and we are on the default one.
|
|
17
|
-
!(isDefaultAxis && yAxisId === undefined && direction === 'y') && !(isDefaultAxis && xAxisId === undefined && direction === 'x')) {
|
|
18
|
-
return acc;
|
|
19
|
-
}
|
|
20
|
-
if (axis.scaleType === 'band' || !isHorizontal && direction === 'x' || isHorizontal && direction === 'y') {
|
|
21
|
-
const [seriesMin, seriesMax] = dataPoints.map(v => v.map(t => t[direction]))?.reduce((seriesAcc, values) => {
|
|
22
|
-
return [Math.min(...values, seriesAcc[0]), Math.max(...values, seriesAcc[1])];
|
|
23
|
-
}, [Infinity, -Infinity]) ?? [Infinity, -Infinity];
|
|
24
|
-
return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
|
|
25
|
-
}
|
|
26
|
-
const seriesMin = dataPoints.flatMap(v => v.map(t => t[direction]).reduce((min, value) => Math.min(value, min), Infinity)).reduce((sumAcc, value) => sumAcc + value, 0);
|
|
27
|
-
const seriesMax = dataPoints.flatMap(v => v.map(t => t[direction]).reduce((max, value) => Math.max(value, max), -Infinity)).reduce((sumAcc, value) => sumAcc + value, 0);
|
|
28
|
-
return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
|
|
29
|
-
}, [Infinity, -Infinity]);
|
|
30
|
-
};
|
|
31
|
-
export const getExtremumX = params => {
|
|
32
|
-
const isHorizontal = Object.keys(params.series).some(seriesId => params.series[seriesId].layout === 'horizontal');
|
|
33
|
-
if (isHorizontal) {
|
|
34
|
-
const [min, max] = getValueExtremum('x', isHorizontal, params);
|
|
35
|
-
return [max, min];
|
|
36
|
-
}
|
|
37
|
-
return getValueExtremum('x', isHorizontal, params);
|
|
38
|
-
};
|
|
39
|
-
export const getExtremumY = params => {
|
|
40
|
-
const isHorizontal = Object.keys(params.series).some(seriesId => params.series[seriesId].layout === 'horizontal');
|
|
41
|
-
return getValueExtremum('y', isHorizontal, params);
|
|
42
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
|
|
3
|
-
return _extends({
|
|
4
|
-
id: seriesData.id ?? `auto-generated-id-${seriesIndex}`
|
|
5
|
-
}, seriesData, {
|
|
6
|
-
data: seriesData.data.map((d, index) => _extends({
|
|
7
|
-
color: colors[index % colors.length]
|
|
8
|
-
}, d))
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
export default getSeriesWithDefaultValues;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getExtremumX, getExtremumY } from "./extremums.js";
|
|
2
|
-
import seriesProcessor from "./seriesProcessor.js";
|
|
3
|
-
import getColor from "./getColor.js";
|
|
4
|
-
import legendGetter from "./legend.js";
|
|
5
|
-
import tooltipGetter from "./tooltip.js";
|
|
6
|
-
import getSeriesWithDefaultValues from "./getSeriesWithDefaultValues.js";
|
|
7
|
-
export const seriesConfig = {
|
|
8
|
-
seriesProcessor,
|
|
9
|
-
colorProcessor: getColor,
|
|
10
|
-
legendGetter,
|
|
11
|
-
tooltipGetter,
|
|
12
|
-
xExtremumGetter: getExtremumX,
|
|
13
|
-
yExtremumGetter: getExtremumY,
|
|
14
|
-
getSeriesWithDefaultValues
|
|
15
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getLabel } from '@mui/x-charts/internals';
|
|
2
|
-
const legendGetter = params => {
|
|
3
|
-
const {
|
|
4
|
-
seriesOrder,
|
|
5
|
-
series
|
|
6
|
-
} = params;
|
|
7
|
-
return seriesOrder.reduce((acc, seriesId) => {
|
|
8
|
-
series[seriesId].data.forEach(item => {
|
|
9
|
-
const formattedLabel = getLabel(item.label, 'legend');
|
|
10
|
-
if (formattedLabel === undefined) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
acc.push({
|
|
14
|
-
markType: item.labelMarkType ?? series[seriesId].labelMarkType,
|
|
15
|
-
seriesId,
|
|
16
|
-
id: item.id,
|
|
17
|
-
itemId: item.id,
|
|
18
|
-
color: item.color,
|
|
19
|
-
label: formattedLabel
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
return acc;
|
|
23
|
-
}, []);
|
|
24
|
-
};
|
|
25
|
-
export default legendGetter;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
const createPoint = ({
|
|
3
|
-
main,
|
|
4
|
-
other,
|
|
5
|
-
inverse,
|
|
6
|
-
useBandWidth,
|
|
7
|
-
stackOffset
|
|
8
|
-
}) => inverse ? {
|
|
9
|
-
x: other,
|
|
10
|
-
y: main,
|
|
11
|
-
useBandWidth,
|
|
12
|
-
stackOffset
|
|
13
|
-
} : {
|
|
14
|
-
x: main,
|
|
15
|
-
y: other,
|
|
16
|
-
useBandWidth,
|
|
17
|
-
stackOffset
|
|
18
|
-
};
|
|
19
|
-
const seriesProcessor = params => {
|
|
20
|
-
const {
|
|
21
|
-
seriesOrder,
|
|
22
|
-
series
|
|
23
|
-
} = params;
|
|
24
|
-
const completedSeries = {};
|
|
25
|
-
const isHorizontal = seriesOrder.some(seriesId => series[seriesId].layout === 'horizontal');
|
|
26
|
-
seriesOrder.forEach(seriesId => {
|
|
27
|
-
const currentSeries = series[seriesId];
|
|
28
|
-
completedSeries[seriesId] = _extends({
|
|
29
|
-
labelMarkType: 'square',
|
|
30
|
-
layout: isHorizontal ? 'horizontal' : 'vertical',
|
|
31
|
-
valueFormatter: item => item == null ? '' : item.value.toLocaleString()
|
|
32
|
-
}, currentSeries, {
|
|
33
|
-
data: currentSeries.data.map((v, i) => _extends({
|
|
34
|
-
id: `${seriesId}-funnel-item-${v.id ?? i}`
|
|
35
|
-
}, v)),
|
|
36
|
-
dataPoints: []
|
|
37
|
-
});
|
|
38
|
-
const stackOffsets = completedSeries[seriesId].data.toReversed().map((_, i, array) => array.slice(0, i).reduce((acc, item) => acc + item.value, 0)).toReversed();
|
|
39
|
-
completedSeries[seriesId].dataPoints = completedSeries[seriesId].data.map((item, dataIndex, array) => {
|
|
40
|
-
// Main = main axis, Other = other axis
|
|
41
|
-
// For horizontal layout, main is y, other is x
|
|
42
|
-
// For vertical layout, main is x, other is y
|
|
43
|
-
const currentMaxMain = item.value;
|
|
44
|
-
const nextDataIndex = dataIndex === array.length - 1 ? dataIndex : dataIndex + 1;
|
|
45
|
-
const nextMaxMain = array[nextDataIndex].value ?? 0;
|
|
46
|
-
const nextMaxOther = 0;
|
|
47
|
-
const currentMaxOther = completedSeries[seriesId].data[dataIndex].value;
|
|
48
|
-
const stackOffset = stackOffsets[dataIndex];
|
|
49
|
-
return [
|
|
50
|
-
// Top right (vertical) or Top left (horizontal)
|
|
51
|
-
createPoint({
|
|
52
|
-
main: currentMaxMain,
|
|
53
|
-
other: currentMaxOther,
|
|
54
|
-
inverse: isHorizontal,
|
|
55
|
-
useBandWidth: false,
|
|
56
|
-
stackOffset
|
|
57
|
-
}),
|
|
58
|
-
// Bottom right (vertical) or Top right (horizontal)
|
|
59
|
-
createPoint({
|
|
60
|
-
main: nextMaxMain,
|
|
61
|
-
other: nextMaxOther,
|
|
62
|
-
inverse: isHorizontal,
|
|
63
|
-
useBandWidth: true,
|
|
64
|
-
stackOffset
|
|
65
|
-
}),
|
|
66
|
-
// Bottom left (vertical) or Bottom right (horizontal)
|
|
67
|
-
createPoint({
|
|
68
|
-
main: -nextMaxMain,
|
|
69
|
-
other: nextMaxOther,
|
|
70
|
-
inverse: isHorizontal,
|
|
71
|
-
useBandWidth: true,
|
|
72
|
-
stackOffset
|
|
73
|
-
}),
|
|
74
|
-
// Top left (vertical) or Bottom left (horizontal)
|
|
75
|
-
createPoint({
|
|
76
|
-
main: -currentMaxMain,
|
|
77
|
-
other: currentMaxOther,
|
|
78
|
-
inverse: isHorizontal,
|
|
79
|
-
useBandWidth: false,
|
|
80
|
-
stackOffset
|
|
81
|
-
})];
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
seriesOrder,
|
|
86
|
-
series: completedSeries
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
export default seriesProcessor;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { getLabel } from '@mui/x-charts/internals';
|
|
3
|
-
const tooltipGetter = params => {
|
|
4
|
-
const {
|
|
5
|
-
series,
|
|
6
|
-
getColor,
|
|
7
|
-
identifier
|
|
8
|
-
} = params;
|
|
9
|
-
if (!identifier || identifier.dataIndex === undefined) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
const point = series.data[identifier.dataIndex];
|
|
13
|
-
const label = getLabel(point.label, 'tooltip');
|
|
14
|
-
const value = _extends({}, point, {
|
|
15
|
-
label
|
|
16
|
-
});
|
|
17
|
-
const formattedValue = series.valueFormatter(value, {
|
|
18
|
-
dataIndex: identifier.dataIndex
|
|
19
|
-
});
|
|
20
|
-
return {
|
|
21
|
-
identifier,
|
|
22
|
-
color: getColor(identifier.dataIndex),
|
|
23
|
-
label,
|
|
24
|
-
value,
|
|
25
|
-
formattedValue,
|
|
26
|
-
markType: point.labelMarkType ?? series.labelMarkType
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export default tooltipGetter;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ChartsOverlayProps } from '@mui/x-charts/ChartsOverlay';
|
|
2
|
-
import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
|
|
3
|
-
import { ChartsLegendSlotExtension } from '@mui/x-charts/ChartsLegend';
|
|
4
|
-
import { ChartsClipPathProps } from '@mui/x-charts/ChartsClipPath';
|
|
5
|
-
import { ChartsWrapperProps } from '@mui/x-charts/internals';
|
|
6
|
-
import { ChartsAxisHighlightProps } from '@mui/x-charts/ChartsAxisHighlight';
|
|
7
|
-
import { FunnelPlotProps } from "./FunnelPlot.js";
|
|
8
|
-
import type { FunnelChartProps } from './FunnelChart';
|
|
9
|
-
import { ChartContainerProProps } from "../ChartContainerPro/index.js";
|
|
10
|
-
/**
|
|
11
|
-
* A helper function that extracts FunnelChartProps from the input props
|
|
12
|
-
* and returns an object with props for the children components of FunnelChart.
|
|
13
|
-
*
|
|
14
|
-
* @param props The input props for FunnelChart
|
|
15
|
-
* @returns An object with props for the children components of FunnelChart
|
|
16
|
-
*/
|
|
17
|
-
export declare const useFunnelChartProps: (props: FunnelChartProps) => {
|
|
18
|
-
chartContainerProps: ChartContainerProProps<"funnel">;
|
|
19
|
-
funnelPlotProps: FunnelPlotProps;
|
|
20
|
-
overlayProps: ChartsOverlayProps;
|
|
21
|
-
chartsAxisProps: ChartsAxisProps;
|
|
22
|
-
legendProps: ChartsLegendSlotExtension;
|
|
23
|
-
clipPathGroupProps: {
|
|
24
|
-
clipPath: string;
|
|
25
|
-
};
|
|
26
|
-
clipPathProps: ChartsClipPathProps;
|
|
27
|
-
chartsWrapperProps: Omit<ChartsWrapperProps, "children">;
|
|
28
|
-
axisHighlightProps: ChartsAxisHighlightProps;
|
|
29
|
-
children: import("react").ReactNode;
|
|
30
|
-
};
|