@mui/x-charts-pro 8.0.0-alpha.13 → 8.0.0-alpha.14

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.
Files changed (162) hide show
  1. package/BarChartPro/BarChartPro.d.ts +2 -1
  2. package/CHANGELOG.md +131 -0
  3. package/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  4. package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -1
  5. package/FunnelChart/FunnelChart.d.ts +37 -0
  6. package/FunnelChart/FunnelChart.js +218 -0
  7. package/FunnelChart/FunnelPlot.d.ts +16 -0
  8. package/FunnelChart/FunnelPlot.js +191 -0
  9. package/FunnelChart/FunnelSection.d.ts +15 -0
  10. package/FunnelChart/FunnelSection.js +62 -0
  11. package/FunnelChart/categoryAxis.types.d.ts +24 -0
  12. package/FunnelChart/categoryAxis.types.js +5 -0
  13. package/FunnelChart/funnel.types.d.ts +124 -0
  14. package/FunnelChart/funnel.types.js +5 -0
  15. package/FunnelChart/funnelPlotSlots.types.d.ts +20 -0
  16. package/FunnelChart/funnelPlotSlots.types.js +5 -0
  17. package/FunnelChart/funnelSectionClasses.d.ts +13 -0
  18. package/FunnelChart/funnelSectionClasses.js +28 -0
  19. package/FunnelChart/funnelSlots.types.d.ts +19 -0
  20. package/FunnelChart/funnelSlots.types.js +5 -0
  21. package/FunnelChart/funnelStepCurve.d.ts +4 -0
  22. package/FunnelChart/funnelStepCurve.js +74 -0
  23. package/FunnelChart/index.d.ts +7 -0
  24. package/FunnelChart/index.js +59 -0
  25. package/FunnelChart/labelUtils.d.ts +42 -0
  26. package/FunnelChart/labelUtils.js +174 -0
  27. package/FunnelChart/seriesConfig/extremums.d.ts +3 -0
  28. package/FunnelChart/seriesConfig/extremums.js +50 -0
  29. package/FunnelChart/seriesConfig/getColor.d.ts +3 -0
  30. package/FunnelChart/seriesConfig/getColor.js +10 -0
  31. package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  32. package/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +18 -0
  33. package/FunnelChart/seriesConfig/index.d.ts +2 -0
  34. package/FunnelChart/seriesConfig/index.js +22 -0
  35. package/FunnelChart/seriesConfig/legend.d.ts +3 -0
  36. package/FunnelChart/seriesConfig/legend.js +31 -0
  37. package/FunnelChart/seriesConfig/seriesProcessor.d.ts +3 -0
  38. package/FunnelChart/seriesConfig/seriesProcessor.js +96 -0
  39. package/FunnelChart/seriesConfig/tooltip.d.ts +3 -0
  40. package/FunnelChart/seriesConfig/tooltip.js +36 -0
  41. package/FunnelChart/useFunnelChartProps.d.ts +30 -0
  42. package/FunnelChart/useFunnelChartProps.js +168 -0
  43. package/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  44. package/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +15 -0
  45. package/Heatmap/seriesConfig/index.js +3 -1
  46. package/LineChartPro/LineChartPro.d.ts +2 -1
  47. package/esm/BarChartPro/BarChartPro.d.ts +2 -1
  48. package/esm/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  49. package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -1
  50. package/esm/FunnelChart/FunnelChart.d.ts +37 -0
  51. package/esm/FunnelChart/FunnelChart.js +212 -0
  52. package/esm/FunnelChart/FunnelPlot.d.ts +16 -0
  53. package/esm/FunnelChart/FunnelPlot.js +184 -0
  54. package/esm/FunnelChart/FunnelSection.d.ts +15 -0
  55. package/esm/FunnelChart/FunnelSection.js +56 -0
  56. package/esm/FunnelChart/categoryAxis.types.d.ts +24 -0
  57. package/esm/FunnelChart/categoryAxis.types.js +1 -0
  58. package/esm/FunnelChart/funnel.types.d.ts +124 -0
  59. package/esm/FunnelChart/funnel.types.js +1 -0
  60. package/esm/FunnelChart/funnelPlotSlots.types.d.ts +20 -0
  61. package/esm/FunnelChart/funnelPlotSlots.types.js +1 -0
  62. package/esm/FunnelChart/funnelSectionClasses.d.ts +13 -0
  63. package/esm/FunnelChart/funnelSectionClasses.js +20 -0
  64. package/esm/FunnelChart/funnelSlots.types.d.ts +19 -0
  65. package/esm/FunnelChart/funnelSlots.types.js +1 -0
  66. package/esm/FunnelChart/funnelStepCurve.d.ts +4 -0
  67. package/esm/FunnelChart/funnelStepCurve.js +67 -0
  68. package/esm/FunnelChart/index.d.ts +7 -0
  69. package/esm/FunnelChart/index.js +5 -0
  70. package/esm/FunnelChart/labelUtils.d.ts +42 -0
  71. package/esm/FunnelChart/labelUtils.js +166 -0
  72. package/esm/FunnelChart/seriesConfig/extremums.d.ts +3 -0
  73. package/esm/FunnelChart/seriesConfig/extremums.js +42 -0
  74. package/esm/FunnelChart/seriesConfig/getColor.d.ts +3 -0
  75. package/esm/FunnelChart/seriesConfig/getColor.js +4 -0
  76. package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  77. package/esm/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +11 -0
  78. package/esm/FunnelChart/seriesConfig/index.d.ts +2 -0
  79. package/esm/FunnelChart/seriesConfig/index.js +15 -0
  80. package/esm/FunnelChart/seriesConfig/legend.d.ts +3 -0
  81. package/esm/FunnelChart/seriesConfig/legend.js +25 -0
  82. package/esm/FunnelChart/seriesConfig/seriesProcessor.d.ts +3 -0
  83. package/esm/FunnelChart/seriesConfig/seriesProcessor.js +89 -0
  84. package/esm/FunnelChart/seriesConfig/tooltip.d.ts +3 -0
  85. package/esm/FunnelChart/seriesConfig/tooltip.js +29 -0
  86. package/esm/FunnelChart/useFunnelChartProps.d.ts +30 -0
  87. package/esm/FunnelChart/useFunnelChartProps.js +161 -0
  88. package/esm/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  89. package/esm/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +8 -0
  90. package/esm/Heatmap/seriesConfig/index.js +3 -1
  91. package/esm/LineChartPro/LineChartPro.d.ts +2 -1
  92. package/esm/hooks/useFunnelSeries.d.ts +33 -0
  93. package/esm/hooks/useFunnelSeries.js +42 -0
  94. package/esm/index.d.ts +3 -1
  95. package/esm/index.js +4 -2
  96. package/esm/internals/plugins/allPlugins.d.ts +3 -3
  97. package/esm/internals/plugins/allPlugins.js +2 -2
  98. package/esm/internals/utils/releaseInfo.js +1 -1
  99. package/esm/typeOverloads/modules.d.ts +13 -2
  100. package/hooks/useFunnelSeries.d.ts +33 -0
  101. package/hooks/useFunnelSeries.js +48 -0
  102. package/index.d.ts +3 -1
  103. package/index.js +23 -1
  104. package/internals/plugins/allPlugins.d.ts +3 -3
  105. package/internals/plugins/allPlugins.js +1 -1
  106. package/internals/utils/releaseInfo.js +1 -1
  107. package/modern/BarChartPro/BarChartPro.d.ts +2 -1
  108. package/modern/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
  109. package/modern/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -1
  110. package/modern/FunnelChart/FunnelChart.d.ts +37 -0
  111. package/modern/FunnelChart/FunnelChart.js +212 -0
  112. package/modern/FunnelChart/FunnelPlot.d.ts +16 -0
  113. package/modern/FunnelChart/FunnelPlot.js +184 -0
  114. package/modern/FunnelChart/FunnelSection.d.ts +15 -0
  115. package/modern/FunnelChart/FunnelSection.js +56 -0
  116. package/modern/FunnelChart/categoryAxis.types.d.ts +24 -0
  117. package/modern/FunnelChart/categoryAxis.types.js +1 -0
  118. package/modern/FunnelChart/funnel.types.d.ts +124 -0
  119. package/modern/FunnelChart/funnel.types.js +1 -0
  120. package/modern/FunnelChart/funnelPlotSlots.types.d.ts +20 -0
  121. package/modern/FunnelChart/funnelPlotSlots.types.js +1 -0
  122. package/modern/FunnelChart/funnelSectionClasses.d.ts +13 -0
  123. package/modern/FunnelChart/funnelSectionClasses.js +20 -0
  124. package/modern/FunnelChart/funnelSlots.types.d.ts +19 -0
  125. package/modern/FunnelChart/funnelSlots.types.js +1 -0
  126. package/modern/FunnelChart/funnelStepCurve.d.ts +4 -0
  127. package/modern/FunnelChart/funnelStepCurve.js +67 -0
  128. package/modern/FunnelChart/index.d.ts +7 -0
  129. package/modern/FunnelChart/index.js +5 -0
  130. package/modern/FunnelChart/labelUtils.d.ts +42 -0
  131. package/modern/FunnelChart/labelUtils.js +166 -0
  132. package/modern/FunnelChart/seriesConfig/extremums.d.ts +3 -0
  133. package/modern/FunnelChart/seriesConfig/extremums.js +42 -0
  134. package/modern/FunnelChart/seriesConfig/getColor.d.ts +3 -0
  135. package/modern/FunnelChart/seriesConfig/getColor.js +4 -0
  136. package/modern/FunnelChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  137. package/modern/FunnelChart/seriesConfig/getSeriesWithDefaultValues.js +11 -0
  138. package/modern/FunnelChart/seriesConfig/index.d.ts +2 -0
  139. package/modern/FunnelChart/seriesConfig/index.js +15 -0
  140. package/modern/FunnelChart/seriesConfig/legend.d.ts +3 -0
  141. package/modern/FunnelChart/seriesConfig/legend.js +25 -0
  142. package/modern/FunnelChart/seriesConfig/seriesProcessor.d.ts +3 -0
  143. package/modern/FunnelChart/seriesConfig/seriesProcessor.js +89 -0
  144. package/modern/FunnelChart/seriesConfig/tooltip.d.ts +3 -0
  145. package/modern/FunnelChart/seriesConfig/tooltip.js +29 -0
  146. package/modern/FunnelChart/useFunnelChartProps.d.ts +30 -0
  147. package/modern/FunnelChart/useFunnelChartProps.js +161 -0
  148. package/modern/Heatmap/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
  149. package/modern/Heatmap/seriesConfig/getSeriesWithDefaultValues.js +8 -0
  150. package/modern/Heatmap/seriesConfig/index.js +3 -1
  151. package/modern/LineChartPro/LineChartPro.d.ts +2 -1
  152. package/modern/hooks/useFunnelSeries.d.ts +33 -0
  153. package/modern/hooks/useFunnelSeries.js +42 -0
  154. package/modern/index.d.ts +3 -1
  155. package/modern/index.js +4 -2
  156. package/modern/internals/plugins/allPlugins.d.ts +3 -3
  157. package/modern/internals/plugins/allPlugins.js +2 -2
  158. package/modern/internals/utils/releaseInfo.js +1 -1
  159. package/modern/typeOverloads/modules.d.ts +13 -2
  160. package/package.json +4 -4
  161. package/tsconfig.build.tsbuildinfo +1 -1
  162. package/typeOverloads/modules.d.ts +13 -2
@@ -0,0 +1,124 @@
1
+ import { ChartsLabelMarkProps } from '@mui/x-charts/ChartsLabel';
2
+ import { CommonSeriesType, CartesianSeriesType, CommonDefaultizedProps, SeriesId } from '@mui/x-charts/internals';
3
+ import { CurveType, Position } from '@mui/x-charts/models';
4
+ import { DefaultizedProps, MakeRequired } from '@mui/x-internals/types';
5
+ export type FunnelItemId = string | number;
6
+ export type FunnelCurveType = Extract<CurveType, 'linear' | 'step'> | 'bump';
7
+ export type FunnelValueType = {
8
+ /**
9
+ * A unique identifier of the funnel section.
10
+ */
11
+ id?: FunnelItemId;
12
+ /**
13
+ * The value of the funnel section.
14
+ */
15
+ value: number;
16
+ /**
17
+ * The label to display on the tooltip, funnel section, or the legend. It can be a string or a function.
18
+ */
19
+ label?: string | ((location: 'tooltip' | 'legend' | 'section') => string);
20
+ /**
21
+ * The color of the funnel section
22
+ */
23
+ color?: string;
24
+ /**
25
+ * Defines the mark type for the funnel item.
26
+ * @default 'square'
27
+ */
28
+ labelMarkType?: ChartsLabelMarkProps['type'];
29
+ };
30
+ export interface FunnelSeriesType extends Omit<CommonSeriesType<FunnelValueType>, 'color'>, CartesianSeriesType {
31
+ type: 'funnel';
32
+ /**
33
+ * Data associated to the funnel section.
34
+ */
35
+ data: Readonly<FunnelValueType[]>;
36
+ /**
37
+ * The label to display on the tooltip or the legend. It can be a string or a function.
38
+ */
39
+ label?: string | ((location: 'tooltip' | 'legend') => string);
40
+ /**
41
+ * Layout of the funnel.
42
+ * @default 'vertical'
43
+ */
44
+ layout?: 'horizontal' | 'vertical';
45
+ /**
46
+ * The type of curve to use for the line. Read more about curves at
47
+ * [line interpolation](https://mui.com/x/react-charts/lines/#interpolation).
48
+ * @default 'linear'
49
+ */
50
+ curve?: FunnelCurveType;
51
+ /**
52
+ * The label configuration for the funnel plot.
53
+ * Allows to customize the position and margin of the label that is displayed on the funnel sections.
54
+ *
55
+ * If set to `false`, the label will not be displayed.
56
+ * @default { vertical: 'middle', horizontal: 'center' }
57
+ */
58
+ sectionLabel?: FunnelLabelOptions | ((item: FunnelItem) => FunnelLabelOptions | false) | false;
59
+ }
60
+ /**
61
+ * An object that allows to identify a funnel item.
62
+ * Used for item interaction
63
+ */
64
+ export type FunnelItemIdentifier = {
65
+ type: 'funnel';
66
+ /**
67
+ * The series id of the funnel.
68
+ */
69
+ seriesId: SeriesId;
70
+ /**
71
+ * The index of the data point in the series.
72
+ */
73
+ dataIndex: number;
74
+ };
75
+ export type FunnelItem = {
76
+ /**
77
+ * The series id of the funnel.
78
+ */
79
+ seriesId: SeriesId;
80
+ /**
81
+ * The index of the data point in the series.
82
+ */
83
+ dataIndex: number;
84
+ /**
85
+ * The value of the data point.
86
+ */
87
+ value: number;
88
+ };
89
+ export interface DefaultizedFunnelSeriesType extends DefaultizedProps<FunnelSeriesType, CommonDefaultizedProps | 'layout'> {
90
+ dataPoints: FunnelDataPoints[][];
91
+ data: Readonly<MakeRequired<FunnelValueType, 'id' | 'color'>[]>;
92
+ }
93
+ export type FunnelDataPoints = Record<'x' | 'y', number> & {
94
+ useBandWidth: boolean;
95
+ stackOffset: number;
96
+ };
97
+ export type FunnelLabelOptions = {
98
+ /**
99
+ * The position of the label.
100
+ * @default { vertical: 'middle', horizontal: 'center' }
101
+ */
102
+ position?: Position;
103
+ /**
104
+ * The text anchor of the label. Affects the horizontal alignment of the text.
105
+ *
106
+ * Default value depends on the position.
107
+ */
108
+ textAnchor?: 'start' | 'middle' | 'end';
109
+ /**
110
+ * The dominant baseline of the label. Affects the vertical alignment of the text.
111
+ *
112
+ * Default value depends on the position.
113
+ */
114
+ dominantBaseline?: 'auto' | 'baseline' | 'hanging' | 'middle' | 'central' | 'text-after-edge' | 'text-before-edge';
115
+ /**
116
+ * The offset of the label from the anchor point.
117
+ * If a single number is provided, the offset will be applied in both directions.
118
+ * @default 0
119
+ */
120
+ offset?: number | {
121
+ x?: number;
122
+ y?: number;
123
+ };
124
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import type { FunnelSectionProps } from './FunnelSection';
3
+ export interface FunnelPlotSlots {
4
+ funnelSection?: React.ElementType<FunnelSectionProps>;
5
+ }
6
+ export interface FunnelPlotSlotProps {
7
+ funnelSection?: FunnelSectionProps;
8
+ }
9
+ export interface FunnelPlotSlotExtension {
10
+ /**
11
+ * Overridable component slots.
12
+ * @default {}
13
+ */
14
+ slots?: FunnelPlotSlots;
15
+ /**
16
+ * The props used for each component slot.
17
+ * @default {}
18
+ */
19
+ slotProps?: FunnelPlotSlotProps;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { FunnelSectionProps } from './FunnelSection';
2
+ export interface FunnelSectionClasses {
3
+ /** Styles applied to the root element. */
4
+ root: string;
5
+ /** Styles applied to the root element if `highlighted={true}`. */
6
+ highlighted: string;
7
+ /** Styles applied to the root element if `faded={true}`. */
8
+ faded: string;
9
+ /** Styles applied to the label element. */
10
+ label: string;
11
+ }
12
+ export declare const useUtilityClasses: (props: FunnelSectionProps) => Record<"label" | "highlighted" | "faded" | "root", string>;
13
+ export declare const funnelSectionClasses: FunnelSectionClasses;
@@ -0,0 +1,20 @@
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']);
@@ -0,0 +1,19 @@
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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { CurveFactory } from '@mui/x-charts-vendor/d3-shape';
2
+ declare const funnelHorizontalStepCurve: CurveFactory;
3
+ declare const funnelVerticalStepCurve: CurveFactory;
4
+ export { funnelHorizontalStepCurve, funnelVerticalStepCurve };
@@ -0,0 +1,67 @@
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 };
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,5 @@
1
+ export { FunnelChart as Unstable_FunnelChart } from "./FunnelChart.js";
2
+ export * from "./FunnelPlot.js";
3
+ export * from "./funnel.types.js";
4
+ export * from "./funnelSlots.types.js";
5
+ export { funnelSectionClasses } from "./funnelSectionClasses.js";
@@ -0,0 +1,42 @@
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
+ };
@@ -0,0 +1,166 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ import { CartesianExtremumGetter } from '@mui/x-charts/internals';
2
+ export declare const getExtremumX: CartesianExtremumGetter<'funnel'>;
3
+ export declare const getExtremumY: CartesianExtremumGetter<'funnel'>;
@@ -0,0 +1,42 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ import { ColorProcessor } from '@mui/x-charts/internals';
2
+ declare const getColor: ColorProcessor<'funnel'>;
3
+ export default getColor;
@@ -0,0 +1,4 @@
1
+ const getColor = series => {
2
+ return dataIndex => series.data[dataIndex].color;
3
+ };
4
+ export default getColor;
@@ -0,0 +1,3 @@
1
+ import { GetSeriesWithDefaultValues } from '@mui/x-charts/internals';
2
+ declare const getSeriesWithDefaultValues: GetSeriesWithDefaultValues<'funnel'>;
3
+ export default getSeriesWithDefaultValues;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,2 @@
1
+ import type { ChartSeriesTypeConfig } from '@mui/x-charts/internals';
2
+ export declare const seriesConfig: ChartSeriesTypeConfig<'funnel'>;
@@ -0,0 +1,15 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ import { LegendGetter } from '@mui/x-charts/internals';
2
+ declare const legendGetter: LegendGetter<'funnel'>;
3
+ export default legendGetter;
@@ -0,0 +1,25 @@
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;
@@ -0,0 +1,3 @@
1
+ import { SeriesProcessor } from '@mui/x-charts/internals';
2
+ declare const seriesProcessor: SeriesProcessor<'funnel'>;
3
+ export default seriesProcessor;