@mui/x-charts-pro 8.17.0 → 8.19.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 +6 -1
- package/CHANGELOG.md +213 -0
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +11 -5
- package/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +8 -5
- package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +6 -3
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +1 -0
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +1 -0
- package/ChartsToolbarPro/ChartsToolbarPro.js +1 -0
- package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.js +1 -1
- package/LineChartPro/LineChartPro.js +6 -1
- package/SankeyChart/calculateSankeyLayout.js +16 -7
- package/SankeyChart/plugins/useSankeyHighlight.selectors.js +10 -10
- package/SankeyChart/sankey.types.d.ts +17 -4
- package/ScatterChartPro/ScatterChartPro.js +6 -1
- package/esm/BarChartPro/BarChartPro.js +6 -1
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +11 -5
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderThumb.js +8 -5
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +6 -3
- package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +1 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +1 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPro.js +1 -0
- package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.js +3 -3
- package/esm/LineChartPro/LineChartPro.js +6 -1
- package/esm/SankeyChart/calculateSankeyLayout.js +16 -7
- package/esm/SankeyChart/plugins/useSankeyHighlight.selectors.js +10 -10
- package/esm/SankeyChart/sankey.types.d.ts +17 -4
- package/esm/ScatterChartPro/ScatterChartPro.js +6 -1
- package/esm/hooks/useFunnelSeries.js +3 -5
- package/esm/hooks/useHeatmapSeries.js +3 -5
- package/esm/hooks/useSankeySeries.js +3 -5
- package/esm/index.js +1 -1
- package/esm/internals/plugins/useChartProExport/exportImage.js +5 -3
- package/esm/internals/plugins/useChartProExport/print.d.ts +2 -1
- package/esm/internals/plugins/useChartProExport/print.js +3 -2
- package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +5 -0
- package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +4 -12
- package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +5 -4
- package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +17 -2
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.d.ts +8 -0
- package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.js +98 -0
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.d.ts +1 -1
- package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +2 -2
- package/esm/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.d.ts +2 -1
- package/esm/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.js +38 -5
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +9 -3
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +7 -6
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +2 -0
- package/hooks/useFunnelSeries.js +2 -5
- package/hooks/useHeatmapSeries.js +2 -5
- package/hooks/useSankeySeries.js +2 -5
- package/index.js +1 -1
- package/internals/plugins/useChartProExport/exportImage.js +5 -3
- package/internals/plugins/useChartProExport/print.d.ts +2 -1
- package/internals/plugins/useChartProExport/print.js +3 -2
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +5 -0
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +4 -12
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +4 -3
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +17 -2
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.d.ts +8 -0
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.js +105 -0
- package/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.d.ts +1 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +2 -2
- package/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.d.ts +2 -1
- package/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.js +38 -5
- package/internals/plugins/useChartProZoom/useChartProZoom.js +9 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +6 -5
- package/package.json +8 -8
- package/utils/index.d.ts +1 -0
- package/utils/index.js +16 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
const _excluded = ["className", "onMove", "orientation", "placement", "rx", "ry"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
@@ -14,10 +14,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
const Rect = styled('rect')(({
|
|
15
15
|
theme
|
|
16
16
|
}) => ({
|
|
17
|
-
[`&.${chartAxisZoomSliderThumbClasses.root}`]: {
|
|
18
|
-
fill:
|
|
19
|
-
stroke:
|
|
20
|
-
},
|
|
17
|
+
[`&.${chartAxisZoomSliderThumbClasses.root}`]: _extends({
|
|
18
|
+
fill: (theme.vars || theme).palette.common.white,
|
|
19
|
+
stroke: (theme.vars || theme).palette.grey[500]
|
|
20
|
+
}, theme.applyStyles('dark', {
|
|
21
|
+
fill: (theme.vars || theme).palette.grey[300],
|
|
22
|
+
stroke: (theme.vars || theme).palette.grey[600]
|
|
23
|
+
})),
|
|
21
24
|
[`&.${chartAxisZoomSliderThumbClasses.horizontal}`]: {
|
|
22
25
|
cursor: 'ew-resize'
|
|
23
26
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
const _excluded = ["axisId", "axisDirection", "reverse", "onSelectStart", "onSelectEnd"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { useChartContext, getSVGPoint, selectorChartAxisZoomOptionsLookup, useStore } from '@mui/x-charts/internals';
|
|
@@ -16,8 +16,11 @@ const ZoomSliderTrack = styled('rect', {
|
|
|
16
16
|
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'axisDirection' && prop !== 'isSelecting'
|
|
17
17
|
})(({
|
|
18
18
|
theme
|
|
19
|
-
}) => ({
|
|
20
|
-
fill:
|
|
19
|
+
}) => _extends({
|
|
20
|
+
fill: (theme.vars || theme).palette.grey[300]
|
|
21
|
+
}, theme.applyStyles('dark', {
|
|
22
|
+
fill: (theme.vars || theme).palette.grey[800]
|
|
23
|
+
}), {
|
|
21
24
|
cursor: 'pointer',
|
|
22
25
|
variants: [{
|
|
23
26
|
props: {
|
|
@@ -58,6 +58,7 @@ process.env.NODE_ENV !== "production" ? ChartsToolbarImageExportTrigger.propType
|
|
|
58
58
|
options: PropTypes.shape({
|
|
59
59
|
copyStyles: PropTypes.bool,
|
|
60
60
|
fileName: PropTypes.string,
|
|
61
|
+
nonce: PropTypes.string,
|
|
61
62
|
onBeforeExport: PropTypes.func,
|
|
62
63
|
quality: PropTypes.number,
|
|
63
64
|
type: PropTypes.string.isRequired
|
|
@@ -153,6 +153,7 @@ process.env.NODE_ENV !== "production" ? ChartsToolbarPro.propTypes = {
|
|
|
153
153
|
imageExportOptions: PropTypes.arrayOf(PropTypes.shape({
|
|
154
154
|
copyStyles: PropTypes.bool,
|
|
155
155
|
fileName: PropTypes.string,
|
|
156
|
+
nonce: PropTypes.string,
|
|
156
157
|
onBeforeExport: PropTypes.func,
|
|
157
158
|
quality: PropTypes.number,
|
|
158
159
|
type: PropTypes.string.isRequired
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
-
import {
|
|
1
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
+
import { selectorChartSeriesConfig, selectorChartSeriesProcessed, selectorChartDrawingArea, selectorChartRawXAxis, selectorChartRawYAxis } from '@mui/x-charts/internals';
|
|
3
3
|
import { computeAxisValue } from "./computeAxisValue.js";
|
|
4
4
|
export const selectorFunnel = state => state.funnel;
|
|
5
|
-
export const selectorFunnelGap = createSelector(
|
|
5
|
+
export const selectorFunnelGap = createSelector(selectorFunnel, funnel => funnel?.gap ?? 0);
|
|
6
6
|
export const selectorChartXAxis = createSelectorMemoized(selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorFunnelGap, (axis, drawingArea, formattedSeries, seriesConfig, gap) => computeAxisValue({
|
|
7
7
|
drawingArea,
|
|
8
8
|
formattedSeries,
|
|
@@ -1441,7 +1441,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
|
|
|
1441
1441
|
* Configuration for zoom interactions.
|
|
1442
1442
|
*/
|
|
1443
1443
|
zoomInteractionConfig: PropTypes.shape({
|
|
1444
|
-
pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag', 'pressAndDrag']), PropTypes.shape({
|
|
1444
|
+
pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag', 'pressAndDrag', 'wheel']), PropTypes.shape({
|
|
1445
1445
|
pointerMode: PropTypes.oneOf(['mouse', 'touch']),
|
|
1446
1446
|
requiredKeys: PropTypes.arrayOf(PropTypes.string),
|
|
1447
1447
|
type: PropTypes.oneOf(['drag']).isRequired
|
|
@@ -1449,6 +1449,11 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
|
|
|
1449
1449
|
pointerMode: PropTypes.oneOf(['mouse', 'touch']),
|
|
1450
1450
|
requiredKeys: PropTypes.arrayOf(PropTypes.string),
|
|
1451
1451
|
type: PropTypes.oneOf(['pressAndDrag']).isRequired
|
|
1452
|
+
}), PropTypes.shape({
|
|
1453
|
+
allowedDirection: PropTypes.oneOf(['x', 'xy', 'y']),
|
|
1454
|
+
pointerMode: PropTypes.any,
|
|
1455
|
+
requiredKeys: PropTypes.arrayOf(PropTypes.string),
|
|
1456
|
+
type: PropTypes.oneOf(['wheel']).isRequired
|
|
1452
1457
|
})]).isRequired),
|
|
1453
1458
|
zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['brush', 'doubleTapReset', 'pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
|
|
1454
1459
|
pointerMode: PropTypes.any,
|
|
@@ -24,11 +24,11 @@ export function calculateSankeyLayout(data, drawingArea, theme, series = {}) {
|
|
|
24
24
|
width: nodeWidth = 15,
|
|
25
25
|
padding: nodePadding = 10,
|
|
26
26
|
align: nodeAlign = 'justify',
|
|
27
|
-
sort: nodeSort
|
|
27
|
+
sort: nodeSort
|
|
28
28
|
} = nodeOptions ?? {};
|
|
29
29
|
const {
|
|
30
30
|
color: linkColor = 'source',
|
|
31
|
-
sort: linkSort
|
|
31
|
+
sort: linkSort,
|
|
32
32
|
curveCorrection = 10
|
|
33
33
|
} = linkOptions ?? {};
|
|
34
34
|
const {
|
|
@@ -53,12 +53,21 @@ export function calculateSankeyLayout(data, drawingArea, theme, series = {}) {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
// Create the sankey layout generator
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const sankeyGenerator = sankey().nodeWidth(nodeWidth).nodePadding(nodePadding).nodeAlign(getNodeAlignFunction(nodeAlign)).extent([[left, top], [width + right, height + bottom]]).nodeId(d => d.id).iterations(iterations);
|
|
57
|
+
|
|
58
|
+
// For 'auto' or undefined, don't set anything (use d3-sankey default behavior)
|
|
59
|
+
if (typeof nodeSort === 'function') {
|
|
60
|
+
sankeyGenerator.nodeSort(nodeSort);
|
|
61
|
+
} else if (nodeSort === 'fixed') {
|
|
62
|
+
// Null is not accepted by the types.
|
|
63
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/73953
|
|
64
|
+
sankeyGenerator.nodeSort(null);
|
|
59
65
|
}
|
|
60
|
-
if (linkSort) {
|
|
61
|
-
sankeyGenerator
|
|
66
|
+
if (typeof linkSort === 'function') {
|
|
67
|
+
sankeyGenerator.linkSort(linkSort);
|
|
68
|
+
} else if (linkSort === 'fixed') {
|
|
69
|
+
// Null is not accepted by the types.
|
|
70
|
+
sankeyGenerator.linkSort(null);
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
// Generate the layout
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createSelector } from '@mui/x-
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
const selectorSankeyHighlight = state => state.highlight;
|
|
3
3
|
const selectSeries = state => state.series;
|
|
4
|
-
const selectorSankeySeries = createSelector(
|
|
4
|
+
const selectorSankeySeries = createSelector(selectSeries, series => series.processedSeries.sankey?.series[series.processedSeries.sankey?.seriesOrder[0]] || null);
|
|
5
5
|
const DEFAULT_NODE_HIGHLIGHT = 'links';
|
|
6
6
|
const DEFAULT_LINK_HIGHLIGHT = 'links';
|
|
7
7
|
const DEFAULT_FADE = 'none';
|
|
@@ -10,32 +10,32 @@ const DEFAULT_FADE = 'none';
|
|
|
10
10
|
* Get the node highlight configuration from the Sankey series.
|
|
11
11
|
* Defaults to 'nodes' if not specified.
|
|
12
12
|
*/
|
|
13
|
-
export const selectorNodeHighlightConfig = createSelector(
|
|
13
|
+
export const selectorNodeHighlightConfig = createSelector(selectorSankeySeries, series => series?.nodeOptions?.highlight ?? DEFAULT_NODE_HIGHLIGHT);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Get the node fade configuration from the Sankey series.
|
|
17
17
|
* Defaults to 'none' if not specified.
|
|
18
18
|
*/
|
|
19
|
-
export const selectorNodeFadeConfig = createSelector(
|
|
19
|
+
export const selectorNodeFadeConfig = createSelector(selectorSankeySeries, series => series?.nodeOptions?.fade ?? DEFAULT_FADE);
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Get the link highlight configuration from the Sankey series.
|
|
23
23
|
* Defaults to 'links' if not specified.
|
|
24
24
|
*/
|
|
25
|
-
export const selectorLinkHighlightConfig = createSelector(
|
|
25
|
+
export const selectorLinkHighlightConfig = createSelector(selectorSankeySeries, series => series?.linkOptions?.highlight ?? DEFAULT_LINK_HIGHLIGHT);
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Get the link fade configuration from the Sankey series.
|
|
29
29
|
* Defaults to 'none' if not specified.
|
|
30
30
|
*/
|
|
31
|
-
export const selectorLinkFadeConfig = createSelector(
|
|
31
|
+
export const selectorLinkFadeConfig = createSelector(selectorSankeySeries, series => series?.linkOptions?.fade ?? DEFAULT_FADE);
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Get the currently highlighted item in the Sankey chart.
|
|
35
35
|
* @param {UseSankeyHighlightSignature['state']} state The state of the chart.
|
|
36
36
|
* @returns {SankeyItemIdentifier | null} The highlighted item identifier or null.
|
|
37
37
|
*/
|
|
38
|
-
export const selectorSankeyHighlightedItem = createSelector(
|
|
38
|
+
export const selectorSankeyHighlightedItem = createSelector(selectorSankeyHighlight, highlight => highlight.item);
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Determines if a specific node should be highlighted.
|
|
@@ -43,7 +43,7 @@ export const selectorSankeyHighlightedItem = createSelector([selectorSankeyHighl
|
|
|
43
43
|
* - It's the highlighted node (unless highlight mode is 'none')
|
|
44
44
|
* - It's connected to a highlighted link (based on linkOptions.highlight)
|
|
45
45
|
*/
|
|
46
|
-
export const selectorIsNodeHighlighted = createSelector(
|
|
46
|
+
export const selectorIsNodeHighlighted = createSelector(selectorSankeyHighlightedItem, selectorNodeHighlightConfig, selectorLinkHighlightConfig, (highlightedItem, nodeHighlight, linkHighlight, nodeId) => {
|
|
47
47
|
if (!highlightedItem) {
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
@@ -78,7 +78,7 @@ export const selectorIsNodeHighlighted = createSelector([selectorSankeyHighlight
|
|
|
78
78
|
* - It's the highlighted link (unless highlight mode is 'none')
|
|
79
79
|
* - It's connected to a highlighted node (based on nodeOptions.highlight)
|
|
80
80
|
*/
|
|
81
|
-
export const selectorIsLinkHighlighted = createSelector(
|
|
81
|
+
export const selectorIsLinkHighlighted = createSelector(selectorSankeyHighlightedItem, selectorNodeHighlightConfig, selectorLinkHighlightConfig, (highlightedItem, nodeHighlight, linkHighlight, link) => {
|
|
82
82
|
if (!highlightedItem) {
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
@@ -111,7 +111,7 @@ export const selectorIsLinkHighlighted = createSelector([selectorSankeyHighlight
|
|
|
111
111
|
* - This item is not highlighted
|
|
112
112
|
* - The fade mode is 'global' for the highlighted element type
|
|
113
113
|
*/
|
|
114
|
-
export const selectorIsSankeyItemFaded = createSelector(
|
|
114
|
+
export const selectorIsSankeyItemFaded = createSelector(selectorSankeyHighlightedItem, selectorNodeFadeConfig, selectorLinkFadeConfig, (highlightedItem, nodeFade, linkFade, isHighlighted) => {
|
|
115
115
|
if (!highlightedItem || isHighlighted) {
|
|
116
116
|
return false;
|
|
117
117
|
}
|
|
@@ -74,12 +74,19 @@ export type SankeyNodeOptions = {
|
|
|
74
74
|
*/
|
|
75
75
|
showLabels?: boolean;
|
|
76
76
|
/**
|
|
77
|
-
* Custom sort
|
|
77
|
+
* Custom sort mode for nodes
|
|
78
|
+
*
|
|
79
|
+
* - 'auto': Automatic sorting behavior (default)
|
|
80
|
+
* - 'fixed': Preserve the order from the nodes array (disables automatic sorting)
|
|
81
|
+
* - or a custom function
|
|
82
|
+
*
|
|
78
83
|
* @param {SankeyLayoutNode} a - First node to compare
|
|
79
84
|
* @param {SankeyLayoutNode} b - Second node to compare
|
|
80
85
|
* @returns {number} Comparison result
|
|
86
|
+
*
|
|
87
|
+
* @default 'auto'
|
|
81
88
|
*/
|
|
82
|
-
sort?: (a: SankeyLayoutNode, b: SankeyLayoutNode) => number
|
|
89
|
+
sort?: 'auto' | 'fixed' | ((a: SankeyLayoutNode, b: SankeyLayoutNode) => number);
|
|
83
90
|
} & SankeyNodeHighlightScope;
|
|
84
91
|
export type SankeyLinkOptions = {
|
|
85
92
|
/**
|
|
@@ -99,12 +106,18 @@ export type SankeyLinkOptions = {
|
|
|
99
106
|
*/
|
|
100
107
|
showValues?: boolean;
|
|
101
108
|
/**
|
|
102
|
-
* Custom sort
|
|
109
|
+
* Custom sort mode for links
|
|
110
|
+
*
|
|
111
|
+
* - 'auto': Automatic sorting behavior (default)
|
|
112
|
+
* - 'fixed': Preserve the order from the links array (disables automatic sorting)
|
|
113
|
+
* - or a custom function
|
|
114
|
+
*
|
|
103
115
|
* @param {SankeyLayoutLink} a - First link to compare
|
|
104
116
|
* @param {SankeyLayoutLink} b - Second link to compare
|
|
105
117
|
* @returns {number} Comparison result
|
|
118
|
+
* @default 'auto'
|
|
106
119
|
*/
|
|
107
|
-
sort?: (a: SankeyLayoutLink, b: SankeyLayoutLink) => number
|
|
120
|
+
sort?: 'auto' | 'fixed' | ((a: SankeyLayoutLink, b: SankeyLayoutLink) => number);
|
|
108
121
|
/**
|
|
109
122
|
* Applies the given number to the X dimension of the control points of the link's curve function.
|
|
110
123
|
* This can create better looking links between nodes, but is dependent on the graph layout.
|
|
@@ -1423,7 +1423,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
1423
1423
|
* Configuration for zoom interactions.
|
|
1424
1424
|
*/
|
|
1425
1425
|
zoomInteractionConfig: PropTypes.shape({
|
|
1426
|
-
pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag', 'pressAndDrag']), PropTypes.shape({
|
|
1426
|
+
pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag', 'pressAndDrag', 'wheel']), PropTypes.shape({
|
|
1427
1427
|
pointerMode: PropTypes.oneOf(['mouse', 'touch']),
|
|
1428
1428
|
requiredKeys: PropTypes.arrayOf(PropTypes.string),
|
|
1429
1429
|
type: PropTypes.oneOf(['drag']).isRequired
|
|
@@ -1431,6 +1431,11 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
1431
1431
|
pointerMode: PropTypes.oneOf(['mouse', 'touch']),
|
|
1432
1432
|
requiredKeys: PropTypes.arrayOf(PropTypes.string),
|
|
1433
1433
|
type: PropTypes.oneOf(['pressAndDrag']).isRequired
|
|
1434
|
+
}), PropTypes.shape({
|
|
1435
|
+
allowedDirection: PropTypes.oneOf(['x', 'xy', 'y']),
|
|
1436
|
+
pointerMode: PropTypes.any,
|
|
1437
|
+
requiredKeys: PropTypes.arrayOf(PropTypes.string),
|
|
1438
|
+
type: PropTypes.oneOf(['wheel']).isRequired
|
|
1434
1439
|
})]).isRequired),
|
|
1435
1440
|
zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['brush', 'doubleTapReset', 'pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
|
|
1436
1441
|
pointerMode: PropTypes.any,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
const useSelectorSeries = createSeriesSelectorsOfType('funnel');
|
|
5
|
-
const useSelectorSeriesContext = createAllSeriesSelectorOfType('funnel');
|
|
3
|
+
import { useSeriesOfType, useAllSeriesOfType } from '@mui/x-charts/internals';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Get access to the internal state of funnel series.
|
|
@@ -27,7 +25,7 @@ const useSelectorSeriesContext = createAllSeriesSelectorOfType('funnel');
|
|
|
27
25
|
*/
|
|
28
26
|
|
|
29
27
|
export function useFunnelSeries(seriesIds) {
|
|
30
|
-
return
|
|
28
|
+
return useSeriesOfType('funnel', seriesIds);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -38,5 +36,5 @@ export function useFunnelSeries(seriesIds) {
|
|
|
38
36
|
* @returns the funnel series
|
|
39
37
|
*/
|
|
40
38
|
export function useFunnelSeriesContext() {
|
|
41
|
-
return
|
|
39
|
+
return useAllSeriesOfType('funnel');
|
|
42
40
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
const useSelectorSeries = createSeriesSelectorsOfType('heatmap');
|
|
5
|
-
const useSelectorSeriesContext = createAllSeriesSelectorOfType('heatmap');
|
|
3
|
+
import { useSeriesOfType, useAllSeriesOfType } from '@mui/x-charts/internals';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Get access to the internal state of heatmap series.
|
|
@@ -27,7 +25,7 @@ const useSelectorSeriesContext = createAllSeriesSelectorOfType('heatmap');
|
|
|
27
25
|
*/
|
|
28
26
|
|
|
29
27
|
export function useHeatmapSeries(seriesIds) {
|
|
30
|
-
return
|
|
28
|
+
return useSeriesOfType('heatmap', seriesIds);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -38,5 +36,5 @@ export function useHeatmapSeries(seriesIds) {
|
|
|
38
36
|
* @returns the heatmap series
|
|
39
37
|
*/
|
|
40
38
|
export function useHeatmapSeriesContext() {
|
|
41
|
-
return
|
|
39
|
+
return useAllSeriesOfType('heatmap');
|
|
42
40
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
const useSelectorSeries = createSeriesSelectorsOfType('sankey');
|
|
5
|
-
const useSelectorSeriesContext = createAllSeriesSelectorOfType('sankey');
|
|
3
|
+
import { useSeriesOfType, useAllSeriesOfType } from '@mui/x-charts/internals';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Get access to the internal state of sankey series.
|
|
@@ -27,7 +25,7 @@ const useSelectorSeriesContext = createAllSeriesSelectorOfType('sankey');
|
|
|
27
25
|
*/
|
|
28
26
|
|
|
29
27
|
export function useSankeySeries(seriesIds) {
|
|
30
|
-
return
|
|
28
|
+
return useSeriesOfType('sankey', seriesIds);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -38,5 +36,5 @@ export function useSankeySeries(seriesIds) {
|
|
|
38
36
|
* @returns the sankey series
|
|
39
37
|
*/
|
|
40
38
|
export function useSankeySeriesContext() {
|
|
41
|
-
return
|
|
39
|
+
return useAllSeriesOfType('sankey');
|
|
42
40
|
}
|
package/esm/index.js
CHANGED
|
@@ -18,7 +18,8 @@ export async function exportImage(element, svg, params) {
|
|
|
18
18
|
type = 'image/png',
|
|
19
19
|
quality = 0.9,
|
|
20
20
|
onBeforeExport = defaultOnBeforeExport,
|
|
21
|
-
copyStyles = true
|
|
21
|
+
copyStyles = true,
|
|
22
|
+
nonce
|
|
22
23
|
} = params ?? {};
|
|
23
24
|
const drawDocumentPromise = getDrawDocument();
|
|
24
25
|
const doc = ownerDocument(element);
|
|
@@ -45,7 +46,7 @@ export async function exportImage(element, svg, params) {
|
|
|
45
46
|
const rootCandidate = element.getRootNode();
|
|
46
47
|
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
|
|
47
48
|
if (copyStyles) {
|
|
48
|
-
await Promise.all(loadStyleSheets(exportDoc, root));
|
|
49
|
+
await Promise.all(loadStyleSheets(exportDoc, root, nonce));
|
|
49
50
|
}
|
|
50
51
|
resolve();
|
|
51
52
|
};
|
|
@@ -65,7 +66,8 @@ export async function exportImage(element, svg, params) {
|
|
|
65
66
|
try {
|
|
66
67
|
await drawDocument(iframe.contentDocument, canvas, {
|
|
67
68
|
// Handle retina displays: https://github.com/cburgmer/rasterizeHTML.js/blob/262b3404d1c469ce4a7750a2976dec09b8ae2d6c/examples/retina.html#L71
|
|
68
|
-
zoom: ratio
|
|
69
|
+
zoom: ratio,
|
|
70
|
+
nonce
|
|
69
71
|
});
|
|
70
72
|
} finally {
|
|
71
73
|
doc.body.removeChild(iframe);
|
|
@@ -5,7 +5,8 @@ import { defaultOnBeforeExport } from "./defaults.js";
|
|
|
5
5
|
export function printChart(element, {
|
|
6
6
|
fileName,
|
|
7
7
|
onBeforeExport = defaultOnBeforeExport,
|
|
8
|
-
copyStyles = true
|
|
8
|
+
copyStyles = true,
|
|
9
|
+
nonce
|
|
9
10
|
} = {}) {
|
|
10
11
|
const printWindow = createExportIframe(fileName);
|
|
11
12
|
const doc = ownerDocument(element);
|
|
@@ -17,7 +18,7 @@ export function printChart(element, {
|
|
|
17
18
|
const rootCandidate = element.getRootNode();
|
|
18
19
|
const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
|
|
19
20
|
if (copyStyles) {
|
|
20
|
-
await Promise.all(loadStyleSheets(printDoc, root));
|
|
21
|
+
await Promise.all(loadStyleSheets(printDoc, root, nonce));
|
|
21
22
|
}
|
|
22
23
|
const mediaQueryList = printWindow.contentWindow.matchMedia('print');
|
|
23
24
|
mediaQueryList.addEventListener('change', mql => {
|
|
@@ -24,6 +24,11 @@ export interface ChartExportOptions {
|
|
|
24
24
|
* @default true
|
|
25
25
|
*/
|
|
26
26
|
copyStyles?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* A nonce to be used for Content Security Policy (CSP) compliance.
|
|
29
|
+
* If provided, this nonce will be added to any style elements created during the export process.
|
|
30
|
+
*/
|
|
31
|
+
nonce?: string;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* The options to apply on the Print export.
|
|
@@ -8,10 +8,11 @@ export declare const selectorZoomInteractionConfig: (args_0: import("@mui/x-char
|
|
|
8
8
|
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
9
9
|
};
|
|
10
10
|
pointerMode?: import("@mui/x-internal-gestures/core").PointerMode[];
|
|
11
|
+
allowedDirection?: "x" | "y" | "xy";
|
|
11
12
|
}) | null;
|
|
12
13
|
export declare const selectorPanInteractionConfig: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.js").UseChartProZoomState & Partial<{}> & {
|
|
13
14
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
14
|
-
}, interactionName: "drag" | "pressAndDrag") => (Omit<import("./ZoomInteractionConfig.types.js").PanInteraction, "pointerMode"> & {
|
|
15
|
+
}, interactionName: "wheel" | "drag" | "pressAndDrag") => (Omit<import("./ZoomInteractionConfig.types.js").PanInteraction, "pointerMode"> & {
|
|
15
16
|
mouse: {
|
|
16
17
|
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
17
18
|
};
|
|
@@ -19,15 +20,6 @@ export declare const selectorPanInteractionConfig: (args_0: import("@mui/x-chart
|
|
|
19
20
|
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
20
21
|
};
|
|
21
22
|
pointerMode?: import("@mui/x-internal-gestures/core").PointerMode[];
|
|
23
|
+
allowedDirection?: "x" | "y" | "xy";
|
|
22
24
|
}) | null;
|
|
23
|
-
export declare const selectorIsZoomBrushEnabled: (args_0:
|
|
24
|
-
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
25
|
-
}) => false | (Omit<import("./ZoomInteractionConfig.types.js").ZoomInteraction, "pointerMode"> & {
|
|
26
|
-
mouse: {
|
|
27
|
-
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
28
|
-
};
|
|
29
|
-
touch: {
|
|
30
|
-
requiredKeys?: import("@mui/x-internal-gestures/core").KeyboardKey[];
|
|
31
|
-
};
|
|
32
|
-
pointerMode?: import("@mui/x-internal-gestures/core").PointerMode[];
|
|
33
|
-
});
|
|
25
|
+
export declare const selectorIsZoomBrushEnabled: (args_0: {}, zoomInteractionConfig: any) => any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createSelector
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
|
+
import { selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
2
3
|
import { selectorChartZoomState } from "./useChartProZoom.selectors.js";
|
|
3
|
-
export const selectorZoomInteractionConfig = createSelector(
|
|
4
|
-
export const selectorPanInteractionConfig = createSelector(
|
|
5
|
-
export const selectorIsZoomBrushEnabled = createSelector(
|
|
4
|
+
export const selectorZoomInteractionConfig = createSelector(selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.zoom[interactionName] ?? null);
|
|
5
|
+
export const selectorPanInteractionConfig = createSelector(selectorChartZoomState, (zoomState, interactionName) => zoomState.zoomInteractionConfig.pan[interactionName] ?? null);
|
|
6
|
+
export const selectorIsZoomBrushEnabled = createSelector(selectorChartZoomOptionsLookup, state => selectorZoomInteractionConfig(state, 'brush'), (zoomOptions, zoomInteractionConfig) => Object.keys(zoomOptions).length > 0 && zoomInteractionConfig || false);
|
|
@@ -15,8 +15,9 @@ export type ZoomInteractionConfig = {
|
|
|
15
15
|
* Defines the interactions that trigger panning.
|
|
16
16
|
* - `drag`: Pans the chart when dragged with the mouse.
|
|
17
17
|
* - `pressAndDrag`: Pans the chart by pressing and holding, then dragging. Useful for avoiding conflicts with selection gestures.
|
|
18
|
+
* - `wheel`: Pans the chart when the mouse wheel is scrolled (horizontal by default).
|
|
18
19
|
*
|
|
19
|
-
* @default ['drag']
|
|
20
|
+
* @default ['drag', 'wheel']
|
|
20
21
|
*/
|
|
21
22
|
pan?: readonly (PanInteraction | PanInteraction['type'])[];
|
|
22
23
|
};
|
|
@@ -28,13 +29,14 @@ type Entry<T extends AnyInteraction> = { [K in T['type']]?: Omit<T, 'pointerMode
|
|
|
28
29
|
requiredKeys?: KeyboardKey[];
|
|
29
30
|
};
|
|
30
31
|
pointerMode?: PointerMode[];
|
|
32
|
+
allowedDirection?: 'x' | 'y' | 'xy';
|
|
31
33
|
} };
|
|
32
34
|
export type DefaultizedZoomInteractionConfig = {
|
|
33
35
|
zoom: Entry<ZoomInteraction>;
|
|
34
36
|
pan: Entry<PanInteraction>;
|
|
35
37
|
};
|
|
36
38
|
export type ZoomInteraction = WheelInteraction | PinchInteraction | TapAndDragInteraction | DoubleTapResetInteraction | BrushInteraction;
|
|
37
|
-
export type PanInteraction = DragInteraction | PressAndDragInteraction;
|
|
39
|
+
export type PanInteraction = DragInteraction | PressAndDragInteraction | WheelPanInteraction;
|
|
38
40
|
export type ZoomInteractionName = ZoomInteraction['type'];
|
|
39
41
|
export type PanInteractionName = PanInteraction['type'];
|
|
40
42
|
export type InteractionMode = Exclude<PointerMode, 'pen'>;
|
|
@@ -81,6 +83,17 @@ export type TapAndDragInteraction = Unpack<{
|
|
|
81
83
|
export type PressAndDragInteraction = Unpack<{
|
|
82
84
|
type: 'pressAndDrag';
|
|
83
85
|
} & AllModeProp & AllKeysProp>;
|
|
86
|
+
export type WheelPanInteraction = Unpack<{
|
|
87
|
+
type: 'wheel';
|
|
88
|
+
/**
|
|
89
|
+
* Defines which axes are affected by pan on wheel.
|
|
90
|
+
* - `'x'`: Only pan horizontally
|
|
91
|
+
* - `'y'`: Only pan vertically
|
|
92
|
+
* - `'xy'`: Pan both axes
|
|
93
|
+
* @default 'x'
|
|
94
|
+
*/
|
|
95
|
+
allowedDirection?: 'x' | 'y' | 'xy';
|
|
96
|
+
} & NoModeProp & AllKeysProp>;
|
|
84
97
|
export type DoubleTapResetInteraction = Unpack<{
|
|
85
98
|
type: 'doubleTapReset';
|
|
86
99
|
} & AllModeProp & AllKeysProp>;
|
|
@@ -91,6 +104,7 @@ export type AnyInteraction = {
|
|
|
91
104
|
type: string;
|
|
92
105
|
pointerMode?: InteractionMode;
|
|
93
106
|
requiredKeys?: KeyboardKey[];
|
|
107
|
+
allowedDirection?: 'x' | 'y' | 'xy';
|
|
94
108
|
};
|
|
95
109
|
export type AnyEntry = Omit<AnyInteraction, 'pointerMode'> & {
|
|
96
110
|
mouse: {
|
|
@@ -100,5 +114,6 @@ export type AnyEntry = Omit<AnyInteraction, 'pointerMode'> & {
|
|
|
100
114
|
requiredKeys?: KeyboardKey[];
|
|
101
115
|
};
|
|
102
116
|
pointerMode?: PointerMode[];
|
|
117
|
+
allowedDirection?: 'x' | 'y' | 'xy';
|
|
103
118
|
};
|
|
104
119
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartPlugin, ZoomData } from '@mui/x-charts/internals';
|
|
3
|
+
import { UseChartProZoomSignature } from "../useChartProZoom.types.js";
|
|
4
|
+
export declare const usePanOnWheel: ({
|
|
5
|
+
store,
|
|
6
|
+
instance,
|
|
7
|
+
svgRef
|
|
8
|
+
}: Pick<Parameters<ChartPlugin<UseChartProZoomSignature>>[0], "store" | "instance" | "svgRef">, setZoomDataCallback: React.Dispatch<ZoomData[] | ((prev: ZoomData[]) => ZoomData[])>) => void;
|