@mui/x-charts-pro 8.3.0 → 8.4.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 +37 -20
- package/CHANGELOG.md +206 -10
- package/ChartContainerPro/ChartContainerPro.js +1 -0
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartZoomSlider/index.d.ts +1 -1
- package/ChartZoomSlider/index.js +4 -4
- package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +94 -60
- package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.d.ts +12 -0
- package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +92 -0
- package/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.d.ts +11 -0
- package/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.js +58 -0
- package/ChartZoomSlider/internals/chartAxisZoomSliderThumbClasses.d.ts +17 -0
- package/ChartZoomSlider/internals/{chartAxisZoomSliderHandleClasses.js → chartAxisZoomSliderThumbClasses.js} +6 -6
- package/FunnelChart/FunnelChart.js +4 -3
- package/FunnelChart/FunnelPlot.js +2 -0
- package/FunnelChart/FunnelSection.js +2 -1
- package/FunnelChart/curves/curve.types.d.ts +4 -0
- package/FunnelChart/curves/pyramid.d.ts +3 -1
- package/FunnelChart/curves/pyramid.js +37 -10
- package/FunnelChart/curves/step-pyramid.d.ts +10 -2
- package/FunnelChart/curves/step-pyramid.js +96 -20
- package/FunnelChart/curves/step.d.ts +5 -1
- package/FunnelChart/curves/step.js +20 -2
- package/FunnelChart/funnel.types.d.ts +7 -0
- package/FunnelChart/seriesConfig/seriesProcessor.js +47 -1
- package/Heatmap/Heatmap.d.ts +1 -1
- package/Heatmap/Heatmap.js +25 -21
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.d.ts +2 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.js +27 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +1 -10
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.js +4 -102
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +10 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.js +5 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.d.ts +7 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +96 -0
- package/Heatmap/HeatmapTooltip/index.d.ts +3 -1
- package/Heatmap/HeatmapTooltip/index.js +11 -0
- package/LineChartPro/LineChartPro.js +37 -20
- package/ScatterChartPro/ScatterChartPro.js +38 -21
- package/esm/BarChartPro/BarChartPro.js +35 -18
- package/esm/ChartContainerPro/ChartContainerPro.js +1 -0
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartZoomSlider/index.d.ts +1 -1
- package/esm/ChartZoomSlider/index.js +1 -1
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +94 -60
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.d.ts +12 -0
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +85 -0
- package/esm/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.d.ts +11 -0
- package/esm/ChartZoomSlider/internals/ChartsTooltipZoomSliderValue.js +52 -0
- package/esm/ChartZoomSlider/internals/chartAxisZoomSliderThumbClasses.d.ts +17 -0
- package/esm/ChartZoomSlider/internals/{chartAxisZoomSliderHandleClasses.js → chartAxisZoomSliderThumbClasses.js} +4 -4
- package/esm/FunnelChart/FunnelChart.js +4 -3
- package/esm/FunnelChart/FunnelPlot.js +2 -0
- package/esm/FunnelChart/FunnelSection.js +1 -0
- package/esm/FunnelChart/curves/curve.types.d.ts +4 -0
- package/esm/FunnelChart/curves/pyramid.d.ts +3 -1
- package/esm/FunnelChart/curves/pyramid.js +37 -10
- package/esm/FunnelChart/curves/step-pyramid.d.ts +10 -2
- package/esm/FunnelChart/curves/step-pyramid.js +96 -20
- package/esm/FunnelChart/curves/step.d.ts +5 -1
- package/esm/FunnelChart/curves/step.js +20 -2
- package/esm/FunnelChart/funnel.types.d.ts +7 -0
- package/esm/FunnelChart/seriesConfig/seriesProcessor.js +47 -1
- package/esm/Heatmap/Heatmap.d.ts +1 -1
- package/esm/Heatmap/Heatmap.js +23 -19
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.d.ts +2 -0
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.classes.js +19 -0
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.d.ts +1 -10
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.js +5 -103
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +10 -0
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltip.types.js +1 -0
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipContent.d.ts +7 -0
- package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipContent.js +89 -0
- package/esm/Heatmap/HeatmapTooltip/index.d.ts +3 -1
- package/esm/Heatmap/HeatmapTooltip/index.js +3 -1
- package/esm/LineChartPro/LineChartPro.js +35 -18
- package/esm/ScatterChartPro/ScatterChartPro.js +36 -19
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -3
- package/esm/internals/plugins/useChartProExport/exportImage.js +1 -1
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -68
- package/internals/plugins/useChartProExport/exportImage.js +1 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.js +2 -2
- package/package.json +5 -5
- package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +0 -12
- package/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +0 -92
- package/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +0 -17
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.d.ts +0 -12
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderHandle.js +0 -85
- package/esm/ChartZoomSlider/internals/chartAxisZoomSliderHandleClasses.d.ts +0 -17
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
2
|
import composeClasses from '@mui/utils/composeClasses';
|
|
3
3
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
4
|
-
export const
|
|
5
|
-
export function
|
|
6
|
-
return generateUtilityClass('
|
|
4
|
+
export const chartAxisZoomSliderThumbClasses = generateUtilityClasses('MuiChartAxisZoomSliderThumb', ['root', 'horizontal', 'vertical', 'start', 'end']);
|
|
5
|
+
export function getAxisZoomSliderThumbUtilityClass(slot) {
|
|
6
|
+
return generateUtilityClass('MuiChartAxisZoomSliderThumb', slot);
|
|
7
7
|
}
|
|
8
8
|
export const useUtilityClasses = ownerState => {
|
|
9
9
|
const {
|
|
@@ -13,5 +13,5 @@ export const useUtilityClasses = ownerState => {
|
|
|
13
13
|
const slots = {
|
|
14
14
|
root: ['root', orientation === 'horizontal' ? 'horizontal' : 'vertical', placement === 'start' ? 'start' : 'end']
|
|
15
15
|
};
|
|
16
|
-
return composeClasses(slots,
|
|
16
|
+
return composeClasses(slots, getAxisZoomSliderThumbUtilityClass);
|
|
17
17
|
};
|
|
@@ -44,13 +44,14 @@ const FunnelChart = /*#__PURE__*/React.forwardRef(function FunnelChart(props, re
|
|
|
44
44
|
seriesConfig: seriesConfig,
|
|
45
45
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
46
46
|
children: [!themedProps.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
47
|
-
children: [/*#__PURE__*/_jsx(FunnelPlot, _extends({}, funnelPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)),
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
children: [/*#__PURE__*/_jsx(FunnelPlot, _extends({}, funnelPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), children]
|
|
48
|
+
})), !themedProps.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, themedProps.slotProps?.tooltip, {
|
|
49
|
+
trigger: "item"
|
|
50
50
|
}))]
|
|
51
51
|
}))
|
|
52
52
|
}));
|
|
53
53
|
});
|
|
54
|
+
if (process.env.NODE_ENV !== "production") FunnelChart.displayName = "FunnelChart";
|
|
54
55
|
process.env.NODE_ENV !== "production" ? FunnelChart.propTypes = {
|
|
55
56
|
// ----------------------------- Warning --------------------------------
|
|
56
57
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -78,12 +78,14 @@ const useAggregatedData = gap => {
|
|
|
78
78
|
seriesId,
|
|
79
79
|
value: currentSeries.data[dataIndex].value
|
|
80
80
|
}) : currentSeries.sectionLabel;
|
|
81
|
+
const isIncreasing = currentSeries.dataDirection === 'increasing';
|
|
81
82
|
const curve = getFunnelCurve(currentSeries.curve, {
|
|
82
83
|
isHorizontal,
|
|
83
84
|
gap,
|
|
84
85
|
position: dataIndex,
|
|
85
86
|
sections: currentSeries.dataPoints.length,
|
|
86
87
|
borderRadius: currentSeries.borderRadius,
|
|
88
|
+
isIncreasing,
|
|
87
89
|
min: minPoint,
|
|
88
90
|
max: maxPoint
|
|
89
91
|
});
|
|
@@ -8,6 +8,10 @@ export type CurveOptions = {
|
|
|
8
8
|
* Indicates if the main axis of the visualization.
|
|
9
9
|
*/
|
|
10
10
|
isHorizontal?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Indicates if the segments values are increasing or decreasing.
|
|
13
|
+
*/
|
|
14
|
+
isIncreasing?: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* The order position of the segment.
|
|
13
17
|
*/
|
|
@@ -11,6 +11,7 @@ export declare class Pyramid implements CurveGenerator {
|
|
|
11
11
|
private position;
|
|
12
12
|
private sections;
|
|
13
13
|
private isHorizontal;
|
|
14
|
+
private isIncreasing;
|
|
14
15
|
private gap;
|
|
15
16
|
private borderRadius;
|
|
16
17
|
private min;
|
|
@@ -23,7 +24,8 @@ export declare class Pyramid implements CurveGenerator {
|
|
|
23
24
|
sections,
|
|
24
25
|
borderRadius,
|
|
25
26
|
min,
|
|
26
|
-
max
|
|
27
|
+
max,
|
|
28
|
+
isIncreasing
|
|
27
29
|
}: CurveOptions);
|
|
28
30
|
areaStart(): void;
|
|
29
31
|
areaEnd(): void;
|
|
@@ -17,12 +17,14 @@ export class Pyramid {
|
|
|
17
17
|
sections,
|
|
18
18
|
borderRadius,
|
|
19
19
|
min,
|
|
20
|
-
max
|
|
20
|
+
max,
|
|
21
|
+
isIncreasing
|
|
21
22
|
}) {
|
|
22
23
|
this.context = void 0;
|
|
23
24
|
this.position = 0;
|
|
24
25
|
this.sections = 0;
|
|
25
26
|
this.isHorizontal = false;
|
|
27
|
+
this.isIncreasing = false;
|
|
26
28
|
this.gap = 0;
|
|
27
29
|
this.borderRadius = 0;
|
|
28
30
|
this.min = {
|
|
@@ -40,6 +42,7 @@ export class Pyramid {
|
|
|
40
42
|
this.position = position ?? 0;
|
|
41
43
|
this.sections = sections ?? 1;
|
|
42
44
|
this.borderRadius = borderRadius ?? 0;
|
|
45
|
+
this.isIncreasing = isIncreasing ?? false;
|
|
43
46
|
this.min = min ?? {
|
|
44
47
|
x: 0,
|
|
45
48
|
y: 0
|
|
@@ -48,6 +51,12 @@ export class Pyramid {
|
|
|
48
51
|
x: 0,
|
|
49
52
|
y: 0
|
|
50
53
|
};
|
|
54
|
+
if (isIncreasing) {
|
|
55
|
+
const currentMin = this.min;
|
|
56
|
+
const currentMax = this.max;
|
|
57
|
+
this.min = currentMax;
|
|
58
|
+
this.max = currentMin;
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
61
|
areaStart() {}
|
|
53
62
|
areaEnd() {}
|
|
@@ -57,14 +66,25 @@ export class Pyramid {
|
|
|
57
66
|
if (this.gap > 0) {
|
|
58
67
|
return this.borderRadius;
|
|
59
68
|
}
|
|
60
|
-
if (this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
if (this.isIncreasing) {
|
|
70
|
+
// Is largest section
|
|
71
|
+
if (this.position === this.sections - 1) {
|
|
72
|
+
return [this.borderRadius, this.borderRadius];
|
|
73
|
+
}
|
|
74
|
+
// Is smallest section and shaped like a triangle
|
|
75
|
+
if (this.position === 0) {
|
|
76
|
+
return [0, 0, this.borderRadius];
|
|
77
|
+
}
|
|
65
78
|
}
|
|
66
|
-
if (this.
|
|
67
|
-
|
|
79
|
+
if (!this.isIncreasing) {
|
|
80
|
+
// Is largest section
|
|
81
|
+
if (this.position === 0) {
|
|
82
|
+
return [0, 0, this.borderRadius, this.borderRadius];
|
|
83
|
+
}
|
|
84
|
+
// Is smallest section and shaped like a triangle
|
|
85
|
+
if (this.position === this.sections - 1) {
|
|
86
|
+
return [this.borderRadius];
|
|
87
|
+
}
|
|
68
88
|
}
|
|
69
89
|
return 0;
|
|
70
90
|
}
|
|
@@ -113,8 +133,15 @@ export class Pyramid {
|
|
|
113
133
|
|
|
114
134
|
// In the last section, to form a triangle we need 3 points instead of 4
|
|
115
135
|
// Else the algorithm will break.
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
const isLastSection = this.position === this.sections - 1;
|
|
137
|
+
const isFirstSection = this.position === 0;
|
|
138
|
+
if (this.gap <= 0) {
|
|
139
|
+
if (isFirstSection && this.isIncreasing) {
|
|
140
|
+
this.points = [this.points[0], this.points[1], this.points[2]];
|
|
141
|
+
}
|
|
142
|
+
if (isLastSection && !this.isIncreasing) {
|
|
143
|
+
this.points = [this.points[0], this.points[1], this.points[3]];
|
|
144
|
+
}
|
|
118
145
|
}
|
|
119
146
|
borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
|
|
120
147
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
-
import { CurveOptions } from "./curve.types.js";
|
|
2
|
+
import { CurveOptions, Point } from "./curve.types.js";
|
|
3
3
|
/**
|
|
4
4
|
* This is a custom "step-pyramid" curve generator.
|
|
5
5
|
* It creates a step pyramid, which is a step-like shape with static lengths.
|
|
@@ -8,7 +8,9 @@ import { CurveOptions } from "./curve.types.js";
|
|
|
8
8
|
export declare class StepPyramid implements CurveGenerator {
|
|
9
9
|
private context;
|
|
10
10
|
private position;
|
|
11
|
+
private sections;
|
|
11
12
|
private isHorizontal;
|
|
13
|
+
private isIncreasing;
|
|
12
14
|
private gap;
|
|
13
15
|
private borderRadius;
|
|
14
16
|
private min;
|
|
@@ -18,14 +20,20 @@ export declare class StepPyramid implements CurveGenerator {
|
|
|
18
20
|
isHorizontal,
|
|
19
21
|
gap,
|
|
20
22
|
position,
|
|
23
|
+
sections,
|
|
21
24
|
borderRadius,
|
|
22
25
|
min,
|
|
23
|
-
max
|
|
26
|
+
max,
|
|
27
|
+
isIncreasing
|
|
24
28
|
}: CurveOptions);
|
|
25
29
|
areaStart(): void;
|
|
26
30
|
areaEnd(): void;
|
|
27
31
|
lineStart(): void;
|
|
28
32
|
lineEnd(): void;
|
|
29
33
|
protected getBorderRadius(): number | number[];
|
|
34
|
+
slopeStart(index: number): Point;
|
|
35
|
+
slopeEnd(index: number): Point;
|
|
36
|
+
initialX(index: number): number;
|
|
37
|
+
initialY(index: number): number;
|
|
30
38
|
point(xIn: number, yIn: number): void;
|
|
31
39
|
}
|
|
@@ -13,13 +13,17 @@ export class StepPyramid {
|
|
|
13
13
|
isHorizontal,
|
|
14
14
|
gap,
|
|
15
15
|
position,
|
|
16
|
+
sections,
|
|
16
17
|
borderRadius,
|
|
17
18
|
min,
|
|
18
|
-
max
|
|
19
|
+
max,
|
|
20
|
+
isIncreasing
|
|
19
21
|
}) {
|
|
20
22
|
this.context = void 0;
|
|
21
23
|
this.position = 0;
|
|
24
|
+
this.sections = 0;
|
|
22
25
|
this.isHorizontal = false;
|
|
26
|
+
this.isIncreasing = false;
|
|
23
27
|
this.gap = 0;
|
|
24
28
|
this.borderRadius = 0;
|
|
25
29
|
this.min = {
|
|
@@ -35,7 +39,9 @@ export class StepPyramid {
|
|
|
35
39
|
this.isHorizontal = isHorizontal ?? false;
|
|
36
40
|
this.gap = (gap ?? 0) / 2;
|
|
37
41
|
this.position = position ?? 0;
|
|
42
|
+
this.sections = sections ?? 1;
|
|
38
43
|
this.borderRadius = borderRadius ?? 0;
|
|
44
|
+
this.isIncreasing = isIncreasing ?? false;
|
|
39
45
|
this.min = min ?? {
|
|
40
46
|
x: 0,
|
|
41
47
|
y: 0
|
|
@@ -50,7 +56,91 @@ export class StepPyramid {
|
|
|
50
56
|
lineStart() {}
|
|
51
57
|
lineEnd() {}
|
|
52
58
|
getBorderRadius() {
|
|
53
|
-
|
|
59
|
+
if (this.gap > 0) {
|
|
60
|
+
return this.borderRadius;
|
|
61
|
+
}
|
|
62
|
+
if (this.isIncreasing) {
|
|
63
|
+
if (this.position === this.sections - 1) {
|
|
64
|
+
return this.borderRadius;
|
|
65
|
+
}
|
|
66
|
+
return [0, 0, this.borderRadius, this.borderRadius];
|
|
67
|
+
}
|
|
68
|
+
if (this.position === 0) {
|
|
69
|
+
return this.borderRadius;
|
|
70
|
+
}
|
|
71
|
+
return [this.borderRadius, this.borderRadius];
|
|
72
|
+
}
|
|
73
|
+
slopeStart(index) {
|
|
74
|
+
if (this.isIncreasing) {
|
|
75
|
+
if (this.isHorizontal) {
|
|
76
|
+
return {
|
|
77
|
+
x: this.min.x,
|
|
78
|
+
y: (this.min.y + this.max.y) / 2
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
x: (this.min.x + this.max.x) / 2,
|
|
83
|
+
y: this.min.y
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (this.isHorizontal) {
|
|
87
|
+
if (index <= 1) {
|
|
88
|
+
return this.min;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
x: this.min.x,
|
|
92
|
+
y: this.max.y
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (index <= 1) {
|
|
96
|
+
return {
|
|
97
|
+
x: this.max.x,
|
|
98
|
+
y: this.min.y
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return this.min;
|
|
102
|
+
}
|
|
103
|
+
slopeEnd(index) {
|
|
104
|
+
if (this.isIncreasing) {
|
|
105
|
+
if (this.isHorizontal) {
|
|
106
|
+
if (index <= 1) {
|
|
107
|
+
return {
|
|
108
|
+
x: this.max.x,
|
|
109
|
+
y: this.min.y
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return this.max;
|
|
113
|
+
}
|
|
114
|
+
if (index <= 1) {
|
|
115
|
+
return this.max;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
x: this.min.x,
|
|
119
|
+
y: this.max.y
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (this.isHorizontal) {
|
|
123
|
+
return {
|
|
124
|
+
x: this.max.x,
|
|
125
|
+
y: (this.max.y + this.min.y) / 2
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
x: (this.max.x + this.min.x) / 2,
|
|
130
|
+
y: this.max.y
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
initialX(index) {
|
|
134
|
+
if (this.isIncreasing) {
|
|
135
|
+
return index === 0 || index === 1 ? this.points.at(1).x : this.points.at(2).x;
|
|
136
|
+
}
|
|
137
|
+
return index === 0 || index === 1 ? this.points.at(0).x : this.points.at(3).x;
|
|
138
|
+
}
|
|
139
|
+
initialY(index) {
|
|
140
|
+
if (this.isIncreasing) {
|
|
141
|
+
return index === 0 || index === 1 ? this.points.at(1).y : this.points.at(2).y;
|
|
142
|
+
}
|
|
143
|
+
return index === 0 || index === 1 ? this.points.at(0).y : this.points.at(3).y;
|
|
54
144
|
}
|
|
55
145
|
point(xIn, yIn) {
|
|
56
146
|
this.points.push({
|
|
@@ -63,34 +153,20 @@ export class StepPyramid {
|
|
|
63
153
|
|
|
64
154
|
// Add gaps where they are needed.
|
|
65
155
|
this.points = this.points.map((point, index) => {
|
|
156
|
+
const slopeStart = this.slopeStart(index);
|
|
157
|
+
const slopeEnd = this.slopeEnd(index);
|
|
66
158
|
if (this.isHorizontal) {
|
|
67
|
-
const slopeEnd = {
|
|
68
|
-
x: this.max.x,
|
|
69
|
-
y: (this.max.y + this.min.y) / 2
|
|
70
|
-
};
|
|
71
|
-
const slopeStart = index <= 1 ? this.min : {
|
|
72
|
-
x: this.min.x,
|
|
73
|
-
y: this.max.y
|
|
74
|
-
};
|
|
75
159
|
const yGetter = lerpY(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
|
|
76
160
|
const xGap = point.x + (index === 0 || index === 3 ? this.gap : -this.gap);
|
|
77
|
-
const xInitial =
|
|
161
|
+
const xInitial = this.initialX(index);
|
|
78
162
|
return {
|
|
79
163
|
x: xGap,
|
|
80
164
|
y: yGetter(xInitial)
|
|
81
165
|
};
|
|
82
166
|
}
|
|
83
|
-
const slopeEnd = {
|
|
84
|
-
x: (this.max.x + this.min.x) / 2,
|
|
85
|
-
y: this.max.y
|
|
86
|
-
};
|
|
87
|
-
const slopeStart = index <= 1 ? {
|
|
88
|
-
x: this.max.x,
|
|
89
|
-
y: this.min.y
|
|
90
|
-
} : this.min;
|
|
91
167
|
const xGetter = lerpX(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
|
|
92
168
|
const yGap = point.y + (index === 0 || index === 3 ? this.gap : -this.gap);
|
|
93
|
-
const yInitial =
|
|
169
|
+
const yInitial = this.initialY(index);
|
|
94
170
|
return {
|
|
95
171
|
x: xGetter(yInitial),
|
|
96
172
|
y: yGap
|
|
@@ -13,15 +13,19 @@ import { CurveOptions } from "./curve.types.js";
|
|
|
13
13
|
export declare class Step implements CurveGenerator {
|
|
14
14
|
private context;
|
|
15
15
|
private isHorizontal;
|
|
16
|
+
private isIncreasing;
|
|
16
17
|
private gap;
|
|
17
18
|
private borderRadius;
|
|
18
19
|
private position;
|
|
20
|
+
private sections;
|
|
19
21
|
private points;
|
|
20
22
|
constructor(context: CanvasRenderingContext2D, {
|
|
21
23
|
isHorizontal,
|
|
22
24
|
gap,
|
|
23
25
|
position,
|
|
24
|
-
borderRadius
|
|
26
|
+
borderRadius,
|
|
27
|
+
isIncreasing,
|
|
28
|
+
sections
|
|
25
29
|
}: CurveOptions);
|
|
26
30
|
areaStart(): void;
|
|
27
31
|
areaEnd(): void;
|
|
@@ -18,26 +18,44 @@ export class Step {
|
|
|
18
18
|
isHorizontal,
|
|
19
19
|
gap,
|
|
20
20
|
position,
|
|
21
|
-
borderRadius
|
|
21
|
+
borderRadius,
|
|
22
|
+
isIncreasing,
|
|
23
|
+
sections
|
|
22
24
|
}) {
|
|
23
25
|
this.context = void 0;
|
|
24
26
|
this.isHorizontal = false;
|
|
27
|
+
this.isIncreasing = false;
|
|
25
28
|
this.gap = 0;
|
|
26
29
|
this.borderRadius = 0;
|
|
27
30
|
this.position = 0;
|
|
31
|
+
this.sections = 0;
|
|
28
32
|
this.points = [];
|
|
29
33
|
this.context = context;
|
|
30
34
|
this.isHorizontal = isHorizontal ?? false;
|
|
31
35
|
this.gap = (gap ?? 0) / 2;
|
|
32
36
|
this.position = position ?? 0;
|
|
37
|
+
this.sections = sections ?? 1;
|
|
33
38
|
this.borderRadius = borderRadius ?? 0;
|
|
39
|
+
this.isIncreasing = isIncreasing ?? false;
|
|
34
40
|
}
|
|
35
41
|
areaStart() {}
|
|
36
42
|
areaEnd() {}
|
|
37
43
|
lineStart() {}
|
|
38
44
|
lineEnd() {}
|
|
39
45
|
getBorderRadius() {
|
|
40
|
-
|
|
46
|
+
if (this.gap > 0) {
|
|
47
|
+
return this.borderRadius;
|
|
48
|
+
}
|
|
49
|
+
if (this.isIncreasing) {
|
|
50
|
+
if (this.position === this.sections - 1) {
|
|
51
|
+
return this.borderRadius;
|
|
52
|
+
}
|
|
53
|
+
return [0, 0, this.borderRadius, this.borderRadius];
|
|
54
|
+
}
|
|
55
|
+
if (this.position === 0) {
|
|
56
|
+
return this.borderRadius;
|
|
57
|
+
}
|
|
58
|
+
return [this.borderRadius, this.borderRadius];
|
|
41
59
|
}
|
|
42
60
|
point(xIn, yIn) {
|
|
43
61
|
this.points.push({
|
|
@@ -110,6 +110,13 @@ export type FunnelItem = {
|
|
|
110
110
|
export interface DefaultizedFunnelSeriesType extends DefaultizedProps<FunnelSeriesType, CommonDefaultizedProps | 'layout'> {
|
|
111
111
|
dataPoints: FunnelDataPoints[][];
|
|
112
112
|
data: Readonly<MakeRequired<FunnelValueType, 'id' | 'color'>[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Denotes if the data is increasing, first data point is less than the last data point.
|
|
115
|
+
* While the data is decreasing if the first data point is greater than the last data point.
|
|
116
|
+
*
|
|
117
|
+
* This is used to determine the direction of the funnel.
|
|
118
|
+
*/
|
|
119
|
+
dataDirection: 'increasing' | 'decreasing';
|
|
113
120
|
}
|
|
114
121
|
export type FunnelDataPoints = Record<'x' | 'y', number> & {
|
|
115
122
|
useBandWidth: boolean;
|
|
@@ -25,6 +25,9 @@ const seriesProcessor = params => {
|
|
|
25
25
|
const isHorizontal = seriesOrder.some(seriesId => series[seriesId].layout === 'horizontal');
|
|
26
26
|
seriesOrder.forEach(seriesId => {
|
|
27
27
|
const currentSeries = series[seriesId];
|
|
28
|
+
const firstDataPoint = currentSeries.data.at(0);
|
|
29
|
+
const lastDataPoint = currentSeries.data.at(-1);
|
|
30
|
+
const dataDirection = firstDataPoint !== undefined && lastDataPoint !== undefined && firstDataPoint.value < lastDataPoint.value ? 'increasing' : 'decreasing';
|
|
28
31
|
completedSeries[seriesId] = _extends({
|
|
29
32
|
labelMarkType: 'square',
|
|
30
33
|
layout: isHorizontal ? 'horizontal' : 'vertical',
|
|
@@ -33,6 +36,7 @@ const seriesProcessor = params => {
|
|
|
33
36
|
data: currentSeries.data.map((v, i) => _extends({
|
|
34
37
|
id: `${seriesId}-funnel-item-${v.id ?? i}`
|
|
35
38
|
}, v)),
|
|
39
|
+
dataDirection,
|
|
36
40
|
dataPoints: []
|
|
37
41
|
});
|
|
38
42
|
const stackOffsets = completedSeries[seriesId].data.toReversed().map((_, i, array) => array.slice(0, i).reduce((acc, item) => acc + item.value, 0)).toReversed();
|
|
@@ -40,12 +44,54 @@ const seriesProcessor = params => {
|
|
|
40
44
|
// Main = main axis, Other = other axis
|
|
41
45
|
// For horizontal layout, main is y, other is x
|
|
42
46
|
// For vertical layout, main is x, other is y
|
|
47
|
+
const isIncreasing = completedSeries[seriesId].dataDirection === 'increasing';
|
|
43
48
|
const currentMaxMain = item.value;
|
|
44
|
-
const
|
|
49
|
+
const getNextDataIndex = () => {
|
|
50
|
+
if (isIncreasing) {
|
|
51
|
+
return dataIndex === 0 ? dataIndex : dataIndex - 1;
|
|
52
|
+
}
|
|
53
|
+
return dataIndex === array.length - 1 ? dataIndex : dataIndex + 1;
|
|
54
|
+
};
|
|
55
|
+
const nextDataIndex = getNextDataIndex();
|
|
45
56
|
const nextMaxMain = array[nextDataIndex].value ?? 0;
|
|
46
57
|
const nextMaxOther = 0;
|
|
47
58
|
const currentMaxOther = completedSeries[seriesId].data[dataIndex].value;
|
|
48
59
|
const stackOffset = stackOffsets[dataIndex];
|
|
60
|
+
if (isIncreasing) {
|
|
61
|
+
return [
|
|
62
|
+
// Top right (vertical) or Top left (horizontal)
|
|
63
|
+
createPoint({
|
|
64
|
+
main: nextMaxMain,
|
|
65
|
+
other: nextMaxOther,
|
|
66
|
+
inverse: isHorizontal,
|
|
67
|
+
useBandWidth: false,
|
|
68
|
+
stackOffset
|
|
69
|
+
}),
|
|
70
|
+
// Bottom right (vertical) or Top right (horizontal)
|
|
71
|
+
createPoint({
|
|
72
|
+
main: currentMaxMain,
|
|
73
|
+
other: currentMaxOther,
|
|
74
|
+
inverse: isHorizontal,
|
|
75
|
+
useBandWidth: true,
|
|
76
|
+
stackOffset
|
|
77
|
+
}),
|
|
78
|
+
// Bottom left (vertical) or Bottom right (horizontal)
|
|
79
|
+
createPoint({
|
|
80
|
+
main: -currentMaxMain,
|
|
81
|
+
other: currentMaxOther,
|
|
82
|
+
inverse: isHorizontal,
|
|
83
|
+
useBandWidth: true,
|
|
84
|
+
stackOffset
|
|
85
|
+
}),
|
|
86
|
+
// Top left (vertical) or Bottom left (horizontal)
|
|
87
|
+
createPoint({
|
|
88
|
+
main: -nextMaxMain,
|
|
89
|
+
other: nextMaxOther,
|
|
90
|
+
inverse: isHorizontal,
|
|
91
|
+
useBandWidth: false,
|
|
92
|
+
stackOffset
|
|
93
|
+
})];
|
|
94
|
+
}
|
|
49
95
|
return [
|
|
50
96
|
// Top right (vertical) or Top left (horizontal)
|
|
51
97
|
createPoint({
|
package/esm/Heatmap/Heatmap.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ChartsAxisSlots, ChartsAxisSlotProps, XAxis, YAxis } from '@mui/x-chart
|
|
|
6
6
|
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
|
|
7
7
|
import { ChartContainerProProps } from "../ChartContainerPro/index.js";
|
|
8
8
|
import { HeatmapSeriesType } from "../models/seriesType/heatmap.js";
|
|
9
|
-
import { HeatmapTooltipProps } from "./HeatmapTooltip/
|
|
9
|
+
import { HeatmapTooltipProps } from "./HeatmapTooltip/index.js";
|
|
10
10
|
import { HeatmapItemSlotProps, HeatmapItemSlots } from "./HeatmapItem.js";
|
|
11
11
|
import { HeatmapPluginsSignatures } from "./Heatmap.plugins.js";
|
|
12
12
|
export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots {
|
package/esm/Heatmap/Heatmap.js
CHANGED
|
@@ -7,14 +7,15 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
7
7
|
import useId from '@mui/utils/useId';
|
|
8
8
|
import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
|
|
9
9
|
import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
|
|
10
|
+
import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
|
|
10
11
|
import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
|
|
11
12
|
import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
|
|
12
13
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '@mui/x-charts/constants';
|
|
13
|
-
import { ChartContainerPro } from "../ChartContainerPro/index.js";
|
|
14
14
|
import { HeatmapPlot } from "./HeatmapPlot.js";
|
|
15
15
|
import { seriesConfig as heatmapSeriesConfig } from "./seriesConfig/index.js";
|
|
16
|
-
import { HeatmapTooltip } from "./HeatmapTooltip/
|
|
16
|
+
import { HeatmapTooltip } from "./HeatmapTooltip/index.js";
|
|
17
17
|
import { HEATMAP_PLUGINS } from "./Heatmap.plugins.js";
|
|
18
|
+
import { ChartDataProviderPro } from "../ChartDataProviderPro/index.js";
|
|
18
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
// The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
|
|
20
21
|
const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
|
|
@@ -82,8 +83,7 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
|
|
|
82
83
|
}
|
|
83
84
|
}], [zAxis]);
|
|
84
85
|
const Tooltip = props.slots?.tooltip ?? HeatmapTooltip;
|
|
85
|
-
return /*#__PURE__*/_jsxs(
|
|
86
|
-
ref: ref,
|
|
86
|
+
return /*#__PURE__*/_jsxs(ChartDataProviderPro, {
|
|
87
87
|
seriesConfig: seriesConfig,
|
|
88
88
|
series: series.map(s => _extends({
|
|
89
89
|
type: 'heatmap'
|
|
@@ -96,30 +96,34 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
|
|
|
96
96
|
zAxis: zAxisWithDefault,
|
|
97
97
|
colors: colors,
|
|
98
98
|
dataset: dataset,
|
|
99
|
-
sx: sx,
|
|
100
99
|
disableAxisListener: true,
|
|
101
100
|
highlightedItem: highlightedItem,
|
|
102
101
|
onHighlightChange: onHighlightChange,
|
|
103
102
|
onAxisClick: onAxisClick,
|
|
104
103
|
plugins: HEATMAP_PLUGINS,
|
|
105
|
-
children: [/*#__PURE__*/_jsxs(
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
children: [/*#__PURE__*/_jsxs(ChartsSurface, {
|
|
105
|
+
ref: ref,
|
|
106
|
+
sx: sx,
|
|
107
|
+
children: [/*#__PURE__*/_jsxs("g", {
|
|
108
|
+
clipPath: `url(#${clipPathId})`,
|
|
109
|
+
children: [/*#__PURE__*/_jsx(HeatmapPlot, {
|
|
110
|
+
slots: slots,
|
|
111
|
+
slotProps: slotProps
|
|
112
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
113
|
+
loading: loading,
|
|
114
|
+
slots: slots,
|
|
115
|
+
slotProps: slotProps
|
|
116
|
+
})]
|
|
117
|
+
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
108
118
|
slots: slots,
|
|
109
119
|
slotProps: slotProps
|
|
110
|
-
}), /*#__PURE__*/_jsx(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
})]
|
|
115
|
-
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
116
|
-
slots: slots,
|
|
117
|
-
slotProps: slotProps
|
|
118
|
-
}), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
119
|
-
id: clipPathId
|
|
120
|
-
}), children]
|
|
120
|
+
}), /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
121
|
+
id: clipPathId
|
|
122
|
+
}), children]
|
|
123
|
+
}), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip))]
|
|
121
124
|
});
|
|
122
125
|
});
|
|
126
|
+
if (process.env.NODE_ENV !== "production") Heatmap.displayName = "Heatmap";
|
|
123
127
|
process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
124
128
|
// ----------------------------- Warning --------------------------------
|
|
125
129
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import { getChartsTooltipUtilityClass } from '@mui/x-charts/ChartsTooltip';
|
|
3
|
+
export const useUtilityClasses = props => {
|
|
4
|
+
const {
|
|
5
|
+
classes
|
|
6
|
+
} = props;
|
|
7
|
+
const slots = {
|
|
8
|
+
root: ['root'],
|
|
9
|
+
paper: ['paper'],
|
|
10
|
+
table: ['table'],
|
|
11
|
+
row: ['row'],
|
|
12
|
+
cell: ['cell'],
|
|
13
|
+
mark: ['mark'],
|
|
14
|
+
markContainer: ['markContainer'],
|
|
15
|
+
labelCell: ['labelCell'],
|
|
16
|
+
valueCell: ['valueCell']
|
|
17
|
+
};
|
|
18
|
+
return composeClasses(slots, getChartsTooltipUtilityClass, classes);
|
|
19
|
+
};
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface HeatmapTooltipProps extends Omit<ChartsTooltipContainerProps, 'trigger' | 'children'> {
|
|
4
|
-
/**
|
|
5
|
-
* Select the kind of tooltip to display
|
|
6
|
-
* - 'item': Shows data about the item below the mouse.
|
|
7
|
-
* - 'none': Does not display tooltip
|
|
8
|
-
* @default 'item'
|
|
9
|
-
*/
|
|
10
|
-
trigger?: 'item' | 'none';
|
|
11
|
-
}
|
|
2
|
+
import { HeatmapTooltipProps } from "./HeatmapTooltip.types.js";
|
|
12
3
|
declare function HeatmapTooltip(props: HeatmapTooltipProps): React.JSX.Element;
|
|
13
4
|
declare namespace HeatmapTooltip {
|
|
14
5
|
var propTypes: any;
|