@mui/x-charts-pro 8.1.0 → 8.2.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 +2 -1
- package/CHANGELOG.md +126 -7
- package/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -2
- package/FunnelChart/FunnelChart.js +7 -1
- package/FunnelChart/FunnelPlot.d.ts +5 -0
- package/FunnelChart/FunnelPlot.js +13 -16
- package/FunnelChart/curves/bump.d.ts +24 -0
- package/FunnelChart/curves/bump.js +82 -0
- package/FunnelChart/curves/curve.types.d.ts +8 -0
- package/FunnelChart/curves/curve.types.js +5 -0
- package/FunnelChart/curves/funnelStep.d.ts +25 -0
- package/FunnelChart/{funnelStepCurve.js → curves/funnelStep.js} +32 -19
- package/FunnelChart/curves/getFunnelCurve.d.ts +3 -0
- package/FunnelChart/curves/getFunnelCurve.js +22 -0
- package/FunnelChart/curves/index.d.ts +2 -0
- package/FunnelChart/curves/index.js +27 -0
- package/FunnelChart/curves/linear.d.ts +24 -0
- package/FunnelChart/curves/linear.js +113 -0
- package/FunnelChart/funnel.types.d.ts +2 -2
- package/FunnelChart/funnelPlotSlots.types.d.ts +1 -1
- package/FunnelChart/funnelSectionClasses.d.ts +1 -1
- package/FunnelChart/index.d.ts +3 -2
- package/FunnelChart/useFunnelChartProps.d.ts +1 -1
- package/FunnelChart/useFunnelChartProps.js +7 -4
- package/Heatmap/Heatmap.js +1 -1
- package/LineChartPro/LineChartPro.js +2 -1
- package/ScatterChartPro/ScatterChartPro.js +2 -1
- package/esm/BarChartPro/BarChartPro.js +2 -1
- package/esm/ChartContainerPro/useChartContainerProProps.d.ts +1 -1
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -2
- package/esm/FunnelChart/FunnelChart.js +7 -1
- package/esm/FunnelChart/FunnelPlot.d.ts +5 -0
- package/esm/FunnelChart/FunnelPlot.js +14 -17
- package/esm/FunnelChart/curves/bump.d.ts +24 -0
- package/esm/FunnelChart/curves/bump.js +75 -0
- package/esm/FunnelChart/curves/curve.types.d.ts +8 -0
- package/esm/FunnelChart/curves/curve.types.js +1 -0
- package/esm/FunnelChart/curves/funnelStep.d.ts +25 -0
- package/esm/FunnelChart/{funnelStepCurve.js → curves/funnelStep.js} +32 -19
- package/esm/FunnelChart/curves/getFunnelCurve.d.ts +3 -0
- package/esm/FunnelChart/curves/getFunnelCurve.js +15 -0
- package/esm/FunnelChart/curves/index.d.ts +2 -0
- package/esm/FunnelChart/curves/index.js +2 -0
- package/esm/FunnelChart/curves/linear.d.ts +24 -0
- package/esm/FunnelChart/curves/linear.js +106 -0
- package/esm/FunnelChart/funnel.types.d.ts +2 -2
- package/esm/FunnelChart/funnelPlotSlots.types.d.ts +1 -1
- package/esm/FunnelChart/funnelSectionClasses.d.ts +1 -1
- package/esm/FunnelChart/index.d.ts +3 -2
- package/esm/FunnelChart/useFunnelChartProps.d.ts +1 -1
- package/esm/FunnelChart/useFunnelChartProps.js +7 -4
- package/esm/Heatmap/Heatmap.js +1 -1
- package/esm/LineChartPro/LineChartPro.js +2 -1
- package/esm/ScatterChartPro/ScatterChartPro.js +2 -1
- package/esm/index.js +1 -1
- package/esm/internals/plugins/useChartProExport/common.d.ts +1 -0
- package/esm/internals/plugins/useChartProExport/common.js +8 -0
- package/esm/internals/plugins/useChartProExport/exportImage.d.ts +3 -0
- package/esm/internals/plugins/useChartProExport/exportImage.js +85 -0
- package/esm/internals/plugins/useChartProExport/print.js +6 -50
- package/esm/internals/plugins/useChartProExport/useChartProExport.js +22 -2
- package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +32 -0
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +1 -1
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +25 -25
- package/esm/themeAugmentation/components.d.ts +0 -4
- package/esm/themeAugmentation/components.js +1 -0
- package/esm/themeAugmentation/index.d.ts +3 -3
- package/esm/themeAugmentation/overrides.d.ts +0 -3
- package/esm/themeAugmentation/overrides.js +2 -0
- package/esm/themeAugmentation/props.d.ts +0 -6
- package/esm/themeAugmentation/props.js +2 -0
- package/index.js +1 -1
- package/internals/plugins/useChartProExport/common.d.ts +1 -0
- package/internals/plugins/useChartProExport/common.js +14 -0
- package/internals/plugins/useChartProExport/exportImage.d.ts +3 -0
- package/internals/plugins/useChartProExport/exportImage.js +95 -0
- package/internals/plugins/useChartProExport/print.js +6 -50
- package/internals/plugins/useChartProExport/useChartProExport.js +22 -2
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +32 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.js +1 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +25 -25
- package/package.json +7 -4
- package/themeAugmentation/components.d.ts +0 -4
- package/themeAugmentation/components.js +5 -0
- package/themeAugmentation/index.d.ts +3 -3
- package/themeAugmentation/overrides.d.ts +0 -3
- package/themeAugmentation/overrides.js +5 -0
- package/themeAugmentation/props.d.ts +0 -6
- package/themeAugmentation/props.js +5 -0
- package/FunnelChart/funnelStepCurve.d.ts +0 -4
- package/esm/FunnelChart/funnelStepCurve.d.ts +0 -4
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
/**
|
|
3
|
+
* This is a custom "linear" curve generator.
|
|
4
|
+
*
|
|
5
|
+
* It takes into account the gap between the points and draws a smooth curve between them.
|
|
6
|
+
*
|
|
7
|
+
* It is based on the d3-shape linear curve generator.
|
|
8
|
+
* https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/linear.js
|
|
9
|
+
*/
|
|
10
|
+
export declare class Linear implements CurveGenerator {
|
|
11
|
+
private context;
|
|
12
|
+
private line;
|
|
13
|
+
private x;
|
|
14
|
+
private y;
|
|
15
|
+
private currentPoint;
|
|
16
|
+
private isHorizontal;
|
|
17
|
+
private gap;
|
|
18
|
+
constructor(context: CanvasRenderingContext2D, isHorizontal: boolean, gap?: number);
|
|
19
|
+
areaStart(): void;
|
|
20
|
+
areaEnd(): void;
|
|
21
|
+
lineStart(): void;
|
|
22
|
+
lineEnd(): void;
|
|
23
|
+
point(x: number, y: number): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Linear = void 0;
|
|
7
|
+
// From point1 to point2, get the x value from y
|
|
8
|
+
const xFromY = (x1, y1, x2, y2) => y => {
|
|
9
|
+
if (y1 === y2) {
|
|
10
|
+
return x1;
|
|
11
|
+
}
|
|
12
|
+
const result = (x2 - x1) * (y - y1) / (y2 - y1) + x1;
|
|
13
|
+
return Number.isNaN(result) ? 0 : result;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// From point1 to point2, get the y value from x
|
|
17
|
+
const yFromX = (x1, y1, x2, y2) => x => {
|
|
18
|
+
if (x1 === x2) {
|
|
19
|
+
return y1;
|
|
20
|
+
}
|
|
21
|
+
const result = (y2 - y1) * (x - x1) / (x2 - x1) + y1;
|
|
22
|
+
return Number.isNaN(result) ? 0 : result;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This is a custom "linear" curve generator.
|
|
27
|
+
*
|
|
28
|
+
* It takes into account the gap between the points and draws a smooth curve between them.
|
|
29
|
+
*
|
|
30
|
+
* It is based on the d3-shape linear curve generator.
|
|
31
|
+
* https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/linear.js
|
|
32
|
+
*/
|
|
33
|
+
class Linear {
|
|
34
|
+
constructor(context, isHorizontal, gap = 0) {
|
|
35
|
+
this.context = void 0;
|
|
36
|
+
this.line = NaN;
|
|
37
|
+
this.x = NaN;
|
|
38
|
+
this.y = NaN;
|
|
39
|
+
this.currentPoint = 0;
|
|
40
|
+
this.isHorizontal = false;
|
|
41
|
+
this.gap = 0;
|
|
42
|
+
this.context = context;
|
|
43
|
+
this.isHorizontal = isHorizontal;
|
|
44
|
+
this.gap = gap / 2;
|
|
45
|
+
}
|
|
46
|
+
areaStart() {
|
|
47
|
+
this.line = 0;
|
|
48
|
+
}
|
|
49
|
+
areaEnd() {
|
|
50
|
+
this.line = NaN;
|
|
51
|
+
}
|
|
52
|
+
lineStart() {
|
|
53
|
+
this.currentPoint = 0;
|
|
54
|
+
}
|
|
55
|
+
lineEnd() {
|
|
56
|
+
if (this.line || this.line !== 0 && this.currentPoint === 1) {
|
|
57
|
+
this.context.closePath();
|
|
58
|
+
}
|
|
59
|
+
this.line = 1 - this.line;
|
|
60
|
+
}
|
|
61
|
+
point(x, y) {
|
|
62
|
+
x = +x;
|
|
63
|
+
y = +y;
|
|
64
|
+
|
|
65
|
+
// We draw the lines only at currentPoint 1 & 3 because we need
|
|
66
|
+
// The data of a pair of points to draw the lines.
|
|
67
|
+
// Hence currentPoint 1 draws a line from point 0 to point 1 and point 1 to point 2.
|
|
68
|
+
// currentPoint 3 draws a line from point 2 to point 3 and point 3 to point 0.
|
|
69
|
+
|
|
70
|
+
if (this.isHorizontal) {
|
|
71
|
+
const yGetter = yFromX(this.x, this.y, x, y);
|
|
72
|
+
let xGap = 0;
|
|
73
|
+
|
|
74
|
+
// 0 is the top-left corner.
|
|
75
|
+
if (this.currentPoint === 1) {
|
|
76
|
+
xGap = this.x + this.gap;
|
|
77
|
+
this.context.moveTo(xGap, yGetter(xGap));
|
|
78
|
+
this.context.lineTo(xGap, yGetter(xGap));
|
|
79
|
+
xGap = x - this.gap;
|
|
80
|
+
this.context.lineTo(xGap, yGetter(xGap));
|
|
81
|
+
} else if (this.currentPoint === 3) {
|
|
82
|
+
xGap = this.x - this.gap;
|
|
83
|
+
this.context.lineTo(xGap, yGetter(xGap));
|
|
84
|
+
xGap = x + this.gap;
|
|
85
|
+
this.context.lineTo(xGap, yGetter(xGap));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!this.isHorizontal) {
|
|
89
|
+
const xGetter = xFromY(this.x, this.y, x, y);
|
|
90
|
+
let yGap = 0;
|
|
91
|
+
|
|
92
|
+
// 0 is the top-right corner.
|
|
93
|
+
if (this.currentPoint === 1) {
|
|
94
|
+
yGap = this.y + this.gap;
|
|
95
|
+
this.context.moveTo(xGetter(yGap), yGap);
|
|
96
|
+
this.context.lineTo(xGetter(yGap), yGap);
|
|
97
|
+
yGap = y - this.gap;
|
|
98
|
+
this.context.lineTo(xGetter(yGap), yGap);
|
|
99
|
+
} else if (this.currentPoint === 3) {
|
|
100
|
+
yGap = this.y - this.gap;
|
|
101
|
+
this.context.lineTo(xGetter(yGap), yGap);
|
|
102
|
+
yGap = y + this.gap;
|
|
103
|
+
this.context.lineTo(xGetter(yGap), yGap);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Increment the values
|
|
108
|
+
this.currentPoint += 1;
|
|
109
|
+
this.x = x;
|
|
110
|
+
this.y = y;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.Linear = Linear;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ChartsLabelMarkProps } from '@mui/x-charts/ChartsLabel';
|
|
2
2
|
import { CommonSeriesType, CartesianSeriesType, CommonDefaultizedProps, SeriesId } from '@mui/x-charts/internals';
|
|
3
|
-
import {
|
|
3
|
+
import { Position } from '@mui/x-charts/models';
|
|
4
4
|
import { DefaultizedProps, MakeRequired } from '@mui/x-internals/types';
|
|
5
|
+
import { FunnelCurveType } from "./curves/index.js";
|
|
5
6
|
export type FunnelItemId = string | number;
|
|
6
|
-
export type FunnelCurveType = Extract<CurveType, 'linear' | 'step'> | 'bump';
|
|
7
7
|
export type FunnelValueType = {
|
|
8
8
|
/**
|
|
9
9
|
* A unique identifier of the funnel section.
|
package/FunnelChart/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { FunnelChart as Unstable_FunnelChart } from "./FunnelChart.js";
|
|
2
|
-
export type { FunnelChartProps } from
|
|
2
|
+
export type { FunnelChartProps } from "./FunnelChart.js";
|
|
3
3
|
export * from "./FunnelPlot.js";
|
|
4
4
|
export * from "./funnel.types.js";
|
|
5
5
|
export * from "./categoryAxis.types.js";
|
|
6
6
|
export * from "./funnelSlots.types.js";
|
|
7
|
+
export type { FunnelCurveType } from "./curves/index.js";
|
|
7
8
|
export { funnelSectionClasses } from "./funnelSectionClasses.js";
|
|
8
|
-
export type { FunnelSectionClasses } from
|
|
9
|
+
export type { FunnelSectionClasses } from "./funnelSectionClasses.js";
|
|
@@ -5,7 +5,7 @@ import { ChartsClipPathProps } from '@mui/x-charts/ChartsClipPath';
|
|
|
5
5
|
import { ChartsWrapperProps } from '@mui/x-charts/internals';
|
|
6
6
|
import { ChartsAxisHighlightProps } from '@mui/x-charts/ChartsAxisHighlight';
|
|
7
7
|
import { FunnelPlotProps } from "./FunnelPlot.js";
|
|
8
|
-
import type { FunnelChartProps } from
|
|
8
|
+
import type { FunnelChartProps } from "./FunnelChart.js";
|
|
9
9
|
import { ChartContainerProProps } from "../ChartContainerPro/index.js";
|
|
10
10
|
/**
|
|
11
11
|
* A helper function that extracts FunnelChartProps from the input props
|
|
@@ -12,7 +12,8 @@ var _constants = require("@mui/x-charts/constants");
|
|
|
12
12
|
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
13
13
|
var _internals = require("@mui/x-charts/internals");
|
|
14
14
|
var _warning = require("@mui/x-internals/warning");
|
|
15
|
-
|
|
15
|
+
var _colorPalettes = require("@mui/x-charts/colorPalettes");
|
|
16
|
+
const _excluded = ["categoryAxis", "series", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "skipAnimation", "loading", "onItemClick", "highlightedItem", "onHighlightChange", "className", "hideLegend", "axisHighlight", "apiRef", "gap"];
|
|
16
17
|
function getCategoryAxisConfig(categoryAxis, series, isHorizontal, direction) {
|
|
17
18
|
const maxSeriesLength = Math.max(...series.map(s => (s.data ?? []).length), 0);
|
|
18
19
|
const maxSeriesValue = Array.from({
|
|
@@ -20,7 +21,7 @@ function getCategoryAxisConfig(categoryAxis, series, isHorizontal, direction) {
|
|
|
20
21
|
}, (_, index) => series.reduce((a, s) => a + (s.data?.[index]?.value ?? 0), 0));
|
|
21
22
|
if (process.env.NODE_ENV !== 'production') {
|
|
22
23
|
if ((categoryAxis?.position === 'left' || categoryAxis?.position === 'right') && isHorizontal || (categoryAxis?.position === 'top' || categoryAxis?.position === 'bottom') && !isHorizontal) {
|
|
23
|
-
(0, _warning.warnOnce)([`MUI X: the categoryAxis position is set to '${categoryAxis.position}' but the series layout is ${isHorizontal ? 'horizontal' : 'vertical'}.`, `Ensure that the categoryAxis position is set to '${isHorizontal ? 'top' : 'left'}' or '${isHorizontal ? 'bottom' : 'right'}' for ${isHorizontal ? 'horizontal' : 'vertical'} layout.\n`], 'warning');
|
|
24
|
+
(0, _warning.warnOnce)([`MUI X Charts: the categoryAxis position is set to '${categoryAxis.position}' but the series layout is ${isHorizontal ? 'horizontal' : 'vertical'}.`, `Ensure that the categoryAxis position is set to '${isHorizontal ? 'top' : 'left'}' or '${isHorizontal ? 'bottom' : 'right'}' for ${isHorizontal ? 'horizontal' : 'vertical'} layout.\n`], 'warning');
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
const side = isHorizontal ? 'bottom' : 'left';
|
|
@@ -90,7 +91,8 @@ const useFunnelChartProps = props => {
|
|
|
90
91
|
onHighlightChange,
|
|
91
92
|
className,
|
|
92
93
|
axisHighlight,
|
|
93
|
-
apiRef
|
|
94
|
+
apiRef,
|
|
95
|
+
gap
|
|
94
96
|
} = props,
|
|
95
97
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
96
98
|
const margin = (0, _internals.defaultizeMargin)(marginProps, _constants.DEFAULT_MARGINS);
|
|
@@ -113,7 +115,7 @@ const useFunnelChartProps = props => {
|
|
|
113
115
|
width,
|
|
114
116
|
height,
|
|
115
117
|
margin,
|
|
116
|
-
colors,
|
|
118
|
+
colors: colors ?? _colorPalettes.strawberrySkyPalette,
|
|
117
119
|
xAxis: [xAxis],
|
|
118
120
|
yAxis: [yAxis],
|
|
119
121
|
sx,
|
|
@@ -123,6 +125,7 @@ const useFunnelChartProps = props => {
|
|
|
123
125
|
apiRef
|
|
124
126
|
});
|
|
125
127
|
const funnelPlotProps = {
|
|
128
|
+
gap,
|
|
126
129
|
onItemClick,
|
|
127
130
|
slots,
|
|
128
131
|
slotProps
|
package/Heatmap/Heatmap.js
CHANGED
|
@@ -194,7 +194,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
194
194
|
* The function called for onClick events.
|
|
195
195
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
196
196
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
197
|
-
* @param {null |
|
|
197
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
198
198
|
*/
|
|
199
199
|
onAxisClick: _propTypes.default.func,
|
|
200
200
|
/**
|
|
@@ -96,6 +96,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
|
|
|
96
96
|
// ----------------------------------------------------------------------
|
|
97
97
|
apiRef: _propTypes.default.shape({
|
|
98
98
|
current: _propTypes.default.shape({
|
|
99
|
+
exportAsImage: _propTypes.default.func.isRequired,
|
|
99
100
|
exportAsPrint: _propTypes.default.func.isRequired,
|
|
100
101
|
setZoomData: _propTypes.default.func.isRequired
|
|
101
102
|
})
|
|
@@ -197,7 +198,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
|
|
|
197
198
|
* The function called for onClick events.
|
|
198
199
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
199
200
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
200
|
-
* @param {null |
|
|
201
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
201
202
|
*/
|
|
202
203
|
onAxisClick: _propTypes.default.func,
|
|
203
204
|
/**
|
|
@@ -90,6 +90,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
90
90
|
// ----------------------------------------------------------------------
|
|
91
91
|
apiRef: _propTypes.default.shape({
|
|
92
92
|
current: _propTypes.default.shape({
|
|
93
|
+
exportAsImage: _propTypes.default.func.isRequired,
|
|
93
94
|
exportAsPrint: _propTypes.default.func.isRequired,
|
|
94
95
|
setZoomData: _propTypes.default.func.isRequired
|
|
95
96
|
})
|
|
@@ -188,7 +189,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
188
189
|
* The function called for onClick events.
|
|
189
190
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
190
191
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
191
|
-
* @param {null |
|
|
192
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
192
193
|
*/
|
|
193
194
|
onAxisClick: _propTypes.default.func,
|
|
194
195
|
/**
|
|
@@ -84,6 +84,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
84
84
|
// ----------------------------------------------------------------------
|
|
85
85
|
apiRef: PropTypes.shape({
|
|
86
86
|
current: PropTypes.shape({
|
|
87
|
+
exportAsImage: PropTypes.func.isRequired,
|
|
87
88
|
exportAsPrint: PropTypes.func.isRequired,
|
|
88
89
|
setZoomData: PropTypes.func.isRequired
|
|
89
90
|
})
|
|
@@ -195,7 +196,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
|
|
|
195
196
|
* The function called for onClick events.
|
|
196
197
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
197
198
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
198
|
-
* @param {null |
|
|
199
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
199
200
|
*/
|
|
200
201
|
onAxisClick: PropTypes.func,
|
|
201
202
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChartAnyPluginSignature, ChartSeriesType, UseChartContainerPropsReturnValue } from '@mui/x-charts/internals';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ChartDataProviderProps } from '@mui/x-charts/ChartDataProvider';
|
|
4
|
-
import type { ChartContainerProProps } from
|
|
4
|
+
import type { ChartContainerProProps } from "./ChartContainerPro.js";
|
|
5
5
|
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
6
6
|
export type UseChartContainerProPropsReturnValue<TSeries extends ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[]> = Pick<UseChartContainerPropsReturnValue<TSeries, TSignatures>, 'chartsSurfaceProps' | 'children'> & {
|
|
7
7
|
chartDataProviderProProps: ChartDataProviderProps<TSeries, TSignatures>;
|
|
@@ -10,7 +10,7 @@ import { useLicenseVerifier } from '@mui/x-license/useLicenseVerifier';
|
|
|
10
10
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
11
11
|
import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
const releaseInfo = "
|
|
13
|
+
const releaseInfo = "MTc0NjA0NjgwMDAwMA==";
|
|
14
14
|
const packageIdentifier = 'x-charts-pro';
|
|
15
15
|
/**
|
|
16
16
|
* Orchestrates the data providers for the chart components and hooks.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartAnyPluginSignature, ChartSeriesType } from '@mui/x-charts/internals';
|
|
2
|
-
import type { ChartDataProviderProProps } from
|
|
3
|
-
import type { AllPluginSignatures } from
|
|
2
|
+
import type { ChartDataProviderProProps } from "./ChartDataProviderPro.js";
|
|
3
|
+
import type { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
4
4
|
export declare const useChartDataProviderProProps: <TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>>(props: ChartDataProviderProProps<TSeries, TSignatures>) => {
|
|
5
5
|
children: import("react").ReactNode;
|
|
6
6
|
localeText: Partial<import("@mui/x-charts/locales").ChartsLocaleText> | undefined;
|
|
@@ -63,6 +63,7 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
|
|
|
63
63
|
// ----------------------------------------------------------------------
|
|
64
64
|
apiRef: PropTypes.shape({
|
|
65
65
|
current: PropTypes.shape({
|
|
66
|
+
exportAsImage: PropTypes.func.isRequired,
|
|
66
67
|
exportAsPrint: PropTypes.func.isRequired,
|
|
67
68
|
setZoomData: PropTypes.func.isRequired
|
|
68
69
|
})
|
|
@@ -176,6 +177,11 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
|
|
|
176
177
|
* @default false
|
|
177
178
|
*/
|
|
178
179
|
disableAxisListener: PropTypes.bool,
|
|
180
|
+
/**
|
|
181
|
+
* The gap, in pixels, between funnel sections.
|
|
182
|
+
* @default 0
|
|
183
|
+
*/
|
|
184
|
+
gap: PropTypes.number,
|
|
179
185
|
/**
|
|
180
186
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
181
187
|
*/
|
|
@@ -232,7 +238,7 @@ process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
|
|
|
232
238
|
* The function called for onClick events.
|
|
233
239
|
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
234
240
|
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
235
|
-
* @param {null |
|
|
241
|
+
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
236
242
|
*/
|
|
237
243
|
onAxisClick: PropTypes.func,
|
|
238
244
|
/**
|
|
@@ -2,6 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import { FunnelItemIdentifier } from "./funnel.types.js";
|
|
3
3
|
import { FunnelPlotSlotExtension } from "./funnelPlotSlots.types.js";
|
|
4
4
|
export interface FunnelPlotProps extends FunnelPlotSlotExtension {
|
|
5
|
+
/**
|
|
6
|
+
* The gap, in pixels, between funnel sections.
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
gap?: number;
|
|
5
10
|
/**
|
|
6
11
|
* Callback fired when a funnel item is clicked.
|
|
7
12
|
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["onItemClick"];
|
|
3
|
+
const _excluded = ["onItemClick", "gap"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
|
|
7
|
-
import {
|
|
7
|
+
import { cartesianSeriesTypes } from '@mui/x-charts/internals';
|
|
8
8
|
import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
|
|
9
9
|
import { useTheme } from '@mui/material/styles';
|
|
10
10
|
import { FunnelSection } from "./FunnelSection.js";
|
|
11
11
|
import { alignLabel, positionLabel } from "./labelUtils.js";
|
|
12
|
-
import { funnelHorizontalStepCurve, funnelVerticalStepCurve } from "./funnelStepCurve.js";
|
|
13
12
|
import { useFunnelSeriesContext } from "../hooks/useFunnelSeries.js";
|
|
13
|
+
import { getFunnelCurve } from "./curves/index.js";
|
|
14
14
|
import { createElement as _createElement } from "react";
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
cartesianSeriesTypes.addType('funnel');
|
|
17
|
-
const
|
|
18
|
-
if (curve === 'step') {
|
|
19
|
-
return isHorizontal ? funnelHorizontalStepCurve : funnelVerticalStepCurve;
|
|
20
|
-
}
|
|
21
|
-
if (curve === 'bump') {
|
|
22
|
-
return isHorizontal ? getCurveFactory('bumpX') : getCurveFactory('bumpY');
|
|
23
|
-
}
|
|
24
|
-
return getCurveFactory(curve ?? 'linear');
|
|
25
|
-
};
|
|
26
|
-
const useAggregatedData = () => {
|
|
17
|
+
const useAggregatedData = gap => {
|
|
27
18
|
const seriesData = useFunnelSeriesContext();
|
|
28
19
|
const {
|
|
29
20
|
xAxis,
|
|
@@ -55,7 +46,7 @@ const useAggregatedData = () => {
|
|
|
55
46
|
const bandWidth = (isXAxisBand || isYAxisBand) && baseScaleConfig.scale?.bandwidth() || 0;
|
|
56
47
|
const xScale = xAxis[xAxisId].scale;
|
|
57
48
|
const yScale = yAxis[yAxisId].scale;
|
|
58
|
-
const curve = getFunnelCurve(currentSeries.curve, isHorizontal);
|
|
49
|
+
const curve = getFunnelCurve(currentSeries.curve, isHorizontal, gap);
|
|
59
50
|
const xPosition = (value, bandIndex, stackOffset, useBand) => {
|
|
60
51
|
if (isXAxisBand) {
|
|
61
52
|
const position = xScale(bandIndex);
|
|
@@ -101,16 +92,17 @@ const useAggregatedData = () => {
|
|
|
101
92
|
});
|
|
102
93
|
});
|
|
103
94
|
return result.flat();
|
|
104
|
-
}, [seriesData, xAxis, xAxisIds, yAxis, yAxisIds]);
|
|
95
|
+
}, [seriesData, xAxis, xAxisIds, yAxis, yAxisIds, gap]);
|
|
105
96
|
return allData;
|
|
106
97
|
};
|
|
107
98
|
function FunnelPlot(props) {
|
|
108
99
|
const {
|
|
109
|
-
onItemClick
|
|
100
|
+
onItemClick,
|
|
101
|
+
gap
|
|
110
102
|
} = props,
|
|
111
103
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
112
104
|
const theme = useTheme();
|
|
113
|
-
const data = useAggregatedData();
|
|
105
|
+
const data = useAggregatedData(gap);
|
|
114
106
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
115
107
|
children: [data.map(({
|
|
116
108
|
d,
|
|
@@ -164,6 +156,11 @@ process.env.NODE_ENV !== "production" ? FunnelPlot.propTypes = {
|
|
|
164
156
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
165
157
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
166
158
|
// ----------------------------------------------------------------------
|
|
159
|
+
/**
|
|
160
|
+
* The gap, in pixels, between funnel sections.
|
|
161
|
+
* @default 0
|
|
162
|
+
*/
|
|
163
|
+
gap: PropTypes.number,
|
|
167
164
|
/**
|
|
168
165
|
* Callback fired when a funnel item is clicked.
|
|
169
166
|
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
/**
|
|
3
|
+
* This is a custom "bump" curve generator.
|
|
4
|
+
*
|
|
5
|
+
* It takes into account the gap between the points and draws a smooth curve between them.
|
|
6
|
+
*
|
|
7
|
+
* It is based on the d3-shape bump curve generator.
|
|
8
|
+
* https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/bump.js
|
|
9
|
+
*/
|
|
10
|
+
export declare class Bump implements CurveGenerator {
|
|
11
|
+
private context;
|
|
12
|
+
private line;
|
|
13
|
+
private x;
|
|
14
|
+
private y;
|
|
15
|
+
private currentPoint;
|
|
16
|
+
private isHorizontal;
|
|
17
|
+
private gap;
|
|
18
|
+
constructor(context: CanvasRenderingContext2D, isHorizontal: boolean, gap?: number);
|
|
19
|
+
areaStart(): void;
|
|
20
|
+
areaEnd(): void;
|
|
21
|
+
lineStart(): void;
|
|
22
|
+
lineEnd(): void;
|
|
23
|
+
point(x: number, y: number): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a custom "bump" curve generator.
|
|
3
|
+
*
|
|
4
|
+
* It takes into account the gap between the points and draws a smooth curve between them.
|
|
5
|
+
*
|
|
6
|
+
* It is based on the d3-shape bump curve generator.
|
|
7
|
+
* https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/bump.js
|
|
8
|
+
*/
|
|
9
|
+
export class Bump {
|
|
10
|
+
constructor(context, isHorizontal, gap = 0) {
|
|
11
|
+
this.context = void 0;
|
|
12
|
+
this.line = NaN;
|
|
13
|
+
this.x = NaN;
|
|
14
|
+
this.y = NaN;
|
|
15
|
+
this.currentPoint = 0;
|
|
16
|
+
this.isHorizontal = false;
|
|
17
|
+
this.gap = 0;
|
|
18
|
+
this.context = context;
|
|
19
|
+
this.isHorizontal = isHorizontal;
|
|
20
|
+
this.gap = gap / 2;
|
|
21
|
+
}
|
|
22
|
+
areaStart() {
|
|
23
|
+
this.line = 0;
|
|
24
|
+
}
|
|
25
|
+
areaEnd() {
|
|
26
|
+
this.line = NaN;
|
|
27
|
+
}
|
|
28
|
+
lineStart() {
|
|
29
|
+
this.currentPoint = 0;
|
|
30
|
+
}
|
|
31
|
+
lineEnd() {
|
|
32
|
+
if (this.line || this.line !== 0 && this.currentPoint === 1) {
|
|
33
|
+
this.context.closePath();
|
|
34
|
+
}
|
|
35
|
+
this.line = 1 - this.line;
|
|
36
|
+
}
|
|
37
|
+
point(x, y) {
|
|
38
|
+
x = +x;
|
|
39
|
+
y = +y;
|
|
40
|
+
|
|
41
|
+
// 0 is the top-left corner.
|
|
42
|
+
if (this.isHorizontal) {
|
|
43
|
+
if (this.currentPoint === 0) {
|
|
44
|
+
this.context.moveTo(x + this.gap, y);
|
|
45
|
+
this.context.lineTo(x + this.gap, y);
|
|
46
|
+
} else if (this.currentPoint === 1) {
|
|
47
|
+
this.context.bezierCurveTo((this.x + x) / 2, this.y, (this.x + x) / 2, y, x - this.gap, y);
|
|
48
|
+
} else if (this.currentPoint === 2) {
|
|
49
|
+
this.context.lineTo(x - this.gap, y);
|
|
50
|
+
} else {
|
|
51
|
+
this.context.bezierCurveTo((this.x + x) / 2, this.y, (this.x + x) / 2, y, x + this.gap, y);
|
|
52
|
+
}
|
|
53
|
+
this.currentPoint += 1;
|
|
54
|
+
this.x = x;
|
|
55
|
+
this.y = y;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 0 is the top-right corner.
|
|
60
|
+
if (this.currentPoint === 0) {
|
|
61
|
+
// X from Y
|
|
62
|
+
this.context.moveTo(x, y + this.gap);
|
|
63
|
+
this.context.lineTo(x, y + this.gap);
|
|
64
|
+
} else if (this.currentPoint === 1) {
|
|
65
|
+
this.context.bezierCurveTo(this.x, (this.y + y) / 2, x, (this.y + y) / 2, x, y - this.gap);
|
|
66
|
+
} else if (this.currentPoint === 2) {
|
|
67
|
+
this.context.lineTo(x, y - this.gap);
|
|
68
|
+
} else {
|
|
69
|
+
this.context.bezierCurveTo(this.x, (this.y + y) / 2, x, (this.y + y) / 2, x, y + this.gap);
|
|
70
|
+
}
|
|
71
|
+
this.currentPoint += 1;
|
|
72
|
+
this.x = x;
|
|
73
|
+
this.y = y;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
/**
|
|
3
|
+
* This is a custom "step" curve generator for the funnel chart.
|
|
4
|
+
* It is used to draw the funnel using "rectangles" without having to rework the rendering logic.
|
|
5
|
+
*
|
|
6
|
+
* It takes into account the gap between the points and draws a smooth curve between them.
|
|
7
|
+
*
|
|
8
|
+
* It is based on the d3-shape step curve generator.
|
|
9
|
+
* https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/step.js
|
|
10
|
+
*/
|
|
11
|
+
export declare class FunnelStep implements CurveGenerator {
|
|
12
|
+
private context;
|
|
13
|
+
private line;
|
|
14
|
+
private x;
|
|
15
|
+
private y;
|
|
16
|
+
private currentPoint;
|
|
17
|
+
private isHorizontal;
|
|
18
|
+
private gap;
|
|
19
|
+
constructor(context: CanvasRenderingContext2D, isHorizontal: boolean, gap?: number);
|
|
20
|
+
areaStart(): void;
|
|
21
|
+
areaEnd(): void;
|
|
22
|
+
lineStart(): void;
|
|
23
|
+
lineEnd(): void;
|
|
24
|
+
point(x: number, y: number): void;
|
|
25
|
+
}
|