@mui/x-charts-pro 8.11.3 → 8.13.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.
Files changed (144) hide show
  1. package/BarChartPro/BarChartPro.d.ts +2 -2
  2. package/BarChartPro/BarChartPro.js +25 -1
  3. package/BarChartPro/BarChartPro.plugins.d.ts +3 -3
  4. package/BarChartPro/BarChartPro.plugins.js +1 -1
  5. package/BarChartPro/index.d.ts +2 -1
  6. package/BarChartPro/index.js +11 -0
  7. package/CHANGELOG.md +296 -6
  8. package/ChartContainerPro/useChartContainerProProps.js +3 -1
  9. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  10. package/FunnelChart/FunnelChart.d.ts +2 -2
  11. package/FunnelChart/FunnelChart.plugins.d.ts +2 -2
  12. package/FunnelChart/funnelAxisPlugin/computeAxisValue.js +2 -5
  13. package/FunnelChart/index.d.ts +1 -0
  14. package/FunnelChart/index.js +12 -0
  15. package/FunnelChart/useFunnelChartProps.d.ts +2 -2
  16. package/Heatmap/Heatmap.d.ts +2 -2
  17. package/Heatmap/Heatmap.plugins.d.ts +2 -2
  18. package/Heatmap/index.d.ts +1 -0
  19. package/Heatmap/index.js +12 -0
  20. package/LineChartPro/LineChartPro.d.ts +2 -2
  21. package/LineChartPro/LineChartPro.js +25 -1
  22. package/LineChartPro/LineChartPro.plugins.d.ts +3 -3
  23. package/LineChartPro/LineChartPro.plugins.js +1 -1
  24. package/LineChartPro/index.d.ts +2 -1
  25. package/LineChartPro/index.js +11 -0
  26. package/PieChartPro/PieChartPro.js +1 -0
  27. package/PieChartPro/PieChartPro.plugins.d.ts +2 -2
  28. package/PieChartPro/index.d.ts +2 -1
  29. package/PieChartPro/index.js +11 -0
  30. package/RadarChartPro/RadarChartPro.d.ts +2 -2
  31. package/RadarChartPro/RadarChartPro.plugins.d.ts +2 -2
  32. package/RadarChartPro/index.d.ts +2 -1
  33. package/RadarChartPro/index.js +11 -0
  34. package/SankeyChart/SankeyChart.d.ts +2 -2
  35. package/SankeyChart/SankeyChart.js +4 -1
  36. package/SankeyChart/SankeyChart.plugins.d.ts +3 -2
  37. package/SankeyChart/SankeyChart.plugins.js +2 -4
  38. package/SankeyChart/SankeyLinkLabel.js +12 -1
  39. package/SankeyChart/calculateSankeyLayout.js +8 -2
  40. package/SankeyChart/sankey.types.d.ts +55 -5
  41. package/SankeyChart/seriesConfig/getSeriesWithDefaultValues.js +2 -0
  42. package/SankeyChart/seriesConfig/tooltipGetter.js +13 -3
  43. package/SankeyChart/useSankeyChartProps.d.ts +2 -2
  44. package/ScatterChartPro/ScatterChartPro.d.ts +2 -2
  45. package/ScatterChartPro/ScatterChartPro.js +37 -3
  46. package/ScatterChartPro/ScatterChartPro.plugins.d.ts +3 -3
  47. package/ScatterChartPro/ScatterChartPro.plugins.js +1 -1
  48. package/ScatterChartPro/index.d.ts +2 -1
  49. package/ScatterChartPro/index.js +11 -0
  50. package/context/ChartProApi.d.ts +14 -12
  51. package/esm/BarChartPro/BarChartPro.d.ts +2 -2
  52. package/esm/BarChartPro/BarChartPro.js +25 -1
  53. package/esm/BarChartPro/BarChartPro.plugins.d.ts +3 -3
  54. package/esm/BarChartPro/BarChartPro.plugins.js +2 -2
  55. package/esm/BarChartPro/index.d.ts +2 -1
  56. package/esm/BarChartPro/index.js +2 -1
  57. package/esm/ChartContainerPro/useChartContainerProProps.js +3 -1
  58. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  59. package/esm/FunnelChart/FunnelChart.d.ts +2 -2
  60. package/esm/FunnelChart/FunnelChart.plugins.d.ts +2 -2
  61. package/esm/FunnelChart/funnelAxisPlugin/computeAxisValue.js +3 -6
  62. package/esm/FunnelChart/index.d.ts +1 -0
  63. package/esm/FunnelChart/index.js +1 -0
  64. package/esm/FunnelChart/useFunnelChartProps.d.ts +2 -2
  65. package/esm/Heatmap/Heatmap.d.ts +2 -2
  66. package/esm/Heatmap/Heatmap.plugins.d.ts +2 -2
  67. package/esm/Heatmap/index.d.ts +1 -0
  68. package/esm/Heatmap/index.js +1 -0
  69. package/esm/LineChartPro/LineChartPro.d.ts +2 -2
  70. package/esm/LineChartPro/LineChartPro.js +25 -1
  71. package/esm/LineChartPro/LineChartPro.plugins.d.ts +3 -3
  72. package/esm/LineChartPro/LineChartPro.plugins.js +2 -2
  73. package/esm/LineChartPro/index.d.ts +2 -1
  74. package/esm/LineChartPro/index.js +2 -1
  75. package/esm/PieChartPro/PieChartPro.js +1 -0
  76. package/esm/PieChartPro/PieChartPro.plugins.d.ts +2 -2
  77. package/esm/PieChartPro/index.d.ts +2 -1
  78. package/esm/PieChartPro/index.js +2 -1
  79. package/esm/RadarChartPro/RadarChartPro.d.ts +2 -2
  80. package/esm/RadarChartPro/RadarChartPro.plugins.d.ts +2 -2
  81. package/esm/RadarChartPro/index.d.ts +2 -1
  82. package/esm/RadarChartPro/index.js +2 -1
  83. package/esm/SankeyChart/SankeyChart.d.ts +2 -2
  84. package/esm/SankeyChart/SankeyChart.js +4 -1
  85. package/esm/SankeyChart/SankeyChart.plugins.d.ts +3 -2
  86. package/esm/SankeyChart/SankeyChart.plugins.js +2 -6
  87. package/esm/SankeyChart/SankeyLinkLabel.js +12 -1
  88. package/esm/SankeyChart/calculateSankeyLayout.js +8 -2
  89. package/esm/SankeyChart/sankey.types.d.ts +55 -5
  90. package/esm/SankeyChart/seriesConfig/getSeriesWithDefaultValues.js +2 -0
  91. package/esm/SankeyChart/seriesConfig/tooltipGetter.js +13 -3
  92. package/esm/SankeyChart/useSankeyChartProps.d.ts +2 -2
  93. package/esm/ScatterChartPro/ScatterChartPro.d.ts +2 -2
  94. package/esm/ScatterChartPro/ScatterChartPro.js +37 -3
  95. package/esm/ScatterChartPro/ScatterChartPro.plugins.d.ts +3 -3
  96. package/esm/ScatterChartPro/ScatterChartPro.plugins.js +2 -2
  97. package/esm/ScatterChartPro/index.d.ts +2 -1
  98. package/esm/ScatterChartPro/index.js +2 -1
  99. package/esm/context/ChartProApi.d.ts +14 -12
  100. package/esm/index.d.ts +1 -0
  101. package/esm/index.js +2 -1
  102. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +1 -2
  103. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +22 -0
  104. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +4 -0
  105. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +92 -0
  106. package/esm/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.js +1 -0
  107. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +21 -6
  108. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +1 -1
  109. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +18 -9
  110. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.d.ts +8 -0
  111. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +73 -0
  112. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +14 -4
  113. package/esm/internals/plugins/useChartProZoom/initializeZoomData.d.ts +2 -0
  114. package/esm/internals/plugins/useChartProZoom/initializeZoomData.js +26 -0
  115. package/esm/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.d.ts +2 -0
  116. package/esm/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.js +86 -0
  117. package/esm/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -2
  118. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +25 -44
  119. package/esm/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +9 -0
  120. package/esm/plugins/index.d.ts +3 -0
  121. package/esm/plugins/index.js +3 -0
  122. package/index.d.ts +1 -0
  123. package/index.js +13 -1
  124. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +1 -2
  125. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +22 -0
  126. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +10 -0
  127. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +92 -0
  128. package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.js +5 -0
  129. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +21 -6
  130. package/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +1 -1
  131. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +18 -9
  132. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.d.ts +8 -0
  133. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +80 -0
  134. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +14 -4
  135. package/internals/plugins/useChartProZoom/initializeZoomData.d.ts +2 -0
  136. package/internals/plugins/useChartProZoom/initializeZoomData.js +31 -0
  137. package/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.d.ts +2 -0
  138. package/internals/plugins/useChartProZoom/initializeZoomInteractionConfig.js +92 -0
  139. package/internals/plugins/useChartProZoom/useChartProZoom.d.ts +1 -2
  140. package/internals/plugins/useChartProZoom/useChartProZoom.js +26 -45
  141. package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +9 -0
  142. package/package.json +7 -7
  143. package/plugins/index.d.ts +3 -0
  144. package/plugins/index.js +35 -0
@@ -136,6 +136,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
136
136
  * @default false
137
137
  */
138
138
  disableAxisListener: PropTypes.bool,
139
+ enableKeyboardNavigation: PropTypes.bool,
139
140
  /**
140
141
  * Option to display a cartesian grid in the background.
141
142
  */
@@ -1415,6 +1416,29 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
1415
1416
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1416
1417
  end: PropTypes.number.isRequired,
1417
1418
  start: PropTypes.number.isRequired
1418
- }))
1419
+ })),
1420
+ /**
1421
+ * Configuration for zoom interactions.
1422
+ */
1423
+ zoomInteractionConfig: PropTypes.shape({
1424
+ pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag']), PropTypes.shape({
1425
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1426
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1427
+ type: PropTypes.oneOf(['drag']).isRequired
1428
+ })]).isRequired),
1429
+ zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
1430
+ pointerMode: PropTypes.any,
1431
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1432
+ type: PropTypes.oneOf(['wheel']).isRequired
1433
+ }), PropTypes.shape({
1434
+ pointerMode: PropTypes.any,
1435
+ requiredKeys: PropTypes.array,
1436
+ type: PropTypes.oneOf(['pinch']).isRequired
1437
+ }), PropTypes.shape({
1438
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1439
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1440
+ type: PropTypes.oneOf(['tapAndDrag']).isRequired
1441
+ })]).isRequired)
1442
+ })
1419
1443
  } : void 0;
1420
1444
  export { BarChartPro };
@@ -1,5 +1,5 @@
1
- import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
1
+ import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "../internals/plugins/useChartProZoom/index.js";
4
- export type BarChartProPluginsSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'bar'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
- export declare const BAR_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<BarChartProPluginsSignatures>;
4
+ export type BarChartProPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'bar'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
+ export declare const BAR_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<BarChartProPluginSignatures>;
@@ -1,4 +1,4 @@
1
- import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight } from '@mui/x-charts/internals';
1
+ import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation } from '@mui/x-charts/internals';
2
2
  import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { useChartProZoom } from "../internals/plugins/useChartProZoom/index.js";
4
- export const BAR_CHART_PRO_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartProZoom, useChartProExport];
4
+ export const BAR_CHART_PRO_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartProZoom, useChartProExport];
@@ -1 +1,2 @@
1
- export * from "./BarChartPro.js";
1
+ export * from "./BarChartPro.js";
2
+ export * from "./BarChartPro.plugins.js";
@@ -1 +1,2 @@
1
- export * from "./BarChartPro.js";
1
+ export * from "./BarChartPro.js";
2
+ export * from "./BarChartPro.plugins.js";
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["initialZoom", "zoomData", "onZoomChange", "plugins", "apiRef"];
5
+ const _excluded = ["initialZoom", "zoomData", "onZoomChange", "zoomInteractionConfig", "plugins", "apiRef"];
6
6
  import { useChartContainerProps } from '@mui/x-charts/internals';
7
7
  import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
8
8
  export const useChartContainerProProps = (props, ref) => {
@@ -11,6 +11,7 @@ export const useChartContainerProProps = (props, ref) => {
11
11
  initialZoom,
12
12
  zoomData,
13
13
  onZoomChange,
14
+ zoomInteractionConfig,
14
15
  plugins,
15
16
  apiRef
16
17
  } = _ref,
@@ -24,6 +25,7 @@ export const useChartContainerProProps = (props, ref) => {
24
25
  initialZoom,
25
26
  zoomData,
26
27
  onZoomChange,
28
+ zoomInteractionConfig,
27
29
  apiRef,
28
30
  plugins: plugins ?? DEFAULT_PLUGINS
29
31
  });
@@ -11,7 +11,7 @@ import { defaultSlotsMaterial } from "../internals/material/index.js";
11
11
  import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
12
12
  import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const releaseInfo = "MTc1ODA2NzIwMDAwMA==";
14
+ const releaseInfo = "MTc1OTI3NjgwMDAwMA==";
15
15
  const packageIdentifier = 'x-charts-pro';
16
16
  /**
17
17
  * Orchestrates the data providers for the chart components and hooks.
@@ -7,9 +7,9 @@ import { FunnelSeriesType } from "./funnel.types.js";
7
7
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
8
8
  import { FunnelChartSlotExtension } from "./funnelSlots.types.js";
9
9
  import { CategoryAxis } from "./categoryAxis.types.js";
10
- import { FunnelChartPluginsSignatures } from "./FunnelChart.plugins.js";
10
+ import { FunnelChartPluginSignatures } from "./FunnelChart.plugins.js";
11
11
  export type FunnelSeries = MakeOptional<FunnelSeriesType, 'type'>;
12
- export interface FunnelChartProps extends Omit<ChartContainerProProps<'funnel', FunnelChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis' | 'zoom' | 'onZoomChange' | 'dataset' | 'yAxis' | 'xAxis' | 'rotationAxis' | 'radiusAxis' | 'slots' | 'slotProps' | 'experimentalFeatures'>, Omit<FunnelPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, FunnelChartSlotExtension {
12
+ export interface FunnelChartProps extends Omit<ChartContainerProProps<'funnel', FunnelChartPluginSignatures>, 'series' | 'plugins' | 'zAxis' | 'zoom' | 'onZoomChange' | 'dataset' | 'yAxis' | 'xAxis' | 'rotationAxis' | 'radiusAxis' | 'slots' | 'slotProps' | 'experimentalFeatures'>, Omit<FunnelPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, FunnelChartSlotExtension {
13
13
  /**
14
14
  * The series to display in the funnel chart.
15
15
  * An array of [[FunnelSeries]] objects.
@@ -1,5 +1,5 @@
1
1
  import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { UseChartFunnelAxisSignature } from "./funnelAxisPlugin/useChartFunnelAxis.types.js";
4
- export type FunnelChartPluginsSignatures = [UseChartFunnelAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
5
- export declare const FUNNEL_CHART_PLUGINS: ConvertSignaturesIntoPlugins<FunnelChartPluginsSignatures>;
4
+ export type FunnelChartPluginSignatures = [UseChartFunnelAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
5
+ export declare const FUNNEL_CHART_PLUGINS: ConvertSignaturesIntoPlugins<FunnelChartPluginSignatures>;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { scaleBand } from '@mui/x-charts-vendor/d3-scale';
3
- import { getAxisExtremum, isBandScaleConfig, getScale, getColorScale, getOrdinalColorScale, getTickNumber, scaleTickNumberByRange, getCartesianAxisTriggerTooltip, isDateData, createDateFormatter } from '@mui/x-charts/internals';
3
+ import { getAxisExtrema, isBandScaleConfig, getScale, getColorScale, getOrdinalColorScale, getTickNumber, scaleTickNumberByRange, getCartesianAxisTriggerTooltip, isDateData, createDateFormatter, getDefaultTickNumber } from '@mui/x-charts/internals';
4
4
  export const xRangeGetter = (drawingArea, reverse, removedSpace = 0) => {
5
5
  const range = [drawingArea.left, drawingArea.left + drawingArea.width - removedSpace];
6
6
  return reverse ? [range[1], range[0]] : [range[0], range[1]];
@@ -31,7 +31,7 @@ export function computeAxisValue({
31
31
  allAxis.forEach((eachAxis, axisIndex) => {
32
32
  const axis = eachAxis;
33
33
  let range = getRange(drawingArea, axisDirection, axis);
34
- const [minData, maxData] = getAxisExtremum(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
34
+ const [minData, maxData] = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
35
35
  const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
36
36
  const data = axis.data ?? [];
37
37
  if (isBandScaleConfig(axis)) {
@@ -84,10 +84,7 @@ export function computeAxisValue({
84
84
  axisExtremums[0] = min;
85
85
  axisExtremums[1] = max;
86
86
  }
87
- const rawTickNumber = getTickNumber(_extends({}, axis, {
88
- range,
89
- domain: axisExtremums
90
- }));
87
+ const rawTickNumber = getTickNumber(axis, axisExtremums, getDefaultTickNumber(Math.abs(range[1] - range[0])));
91
88
  const tickNumber = scaleTickNumberByRange(rawTickNumber, range);
92
89
  const scale = getScale(scaleType, axisExtremums, range);
93
90
  const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
@@ -8,6 +8,7 @@ export * from "./FunnelPlot.js";
8
8
  export * from "./funnel.types.js";
9
9
  export * from "./categoryAxis.types.js";
10
10
  export * from "./funnelSlots.types.js";
11
+ export * from "./FunnelChart.plugins.js";
11
12
  export type { FunnelCurveType } from "./curves/index.js";
12
13
  export { funnelSectionClasses } from "./funnelSectionClasses.js";
13
14
  export type { FunnelSectionClasses } from "./funnelSectionClasses.js";
@@ -9,6 +9,7 @@ export * from "./FunnelPlot.js";
9
9
  export * from "./funnel.types.js";
10
10
  export * from "./categoryAxis.types.js";
11
11
  export * from "./funnelSlots.types.js";
12
+ export * from "./FunnelChart.plugins.js";
12
13
  export { funnelSectionClasses } from "./funnelSectionClasses.js";
13
14
  export { FunnelSection } from "./FunnelSection.js";
14
15
  export { FunnelSectionLabel } from "./FunnelSectionLabel.js";
@@ -3,7 +3,7 @@ import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
3
3
  import { ChartsLegendSlotExtension } from '@mui/x-charts/ChartsLegend';
4
4
  import { ChartsAxisHighlightProps } from '@mui/x-charts/ChartsAxisHighlight';
5
5
  import type { ChartsWrapperProps } from '@mui/x-charts/ChartsWrapper';
6
- import { FunnelChartPluginsSignatures } from "./FunnelChart.plugins.js";
6
+ import { FunnelChartPluginSignatures } from "./FunnelChart.plugins.js";
7
7
  import { FunnelPlotProps } from "./FunnelPlot.js";
8
8
  import type { FunnelChartProps } from "./FunnelChart.js";
9
9
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
@@ -15,7 +15,7 @@ import { ChartContainerProProps } from "../ChartContainerPro/index.js";
15
15
  * @returns An object with props for the children components of FunnelChart
16
16
  */
17
17
  export declare const useFunnelChartProps: (props: FunnelChartProps) => {
18
- chartContainerProps: ChartContainerProProps<"funnel", FunnelChartPluginsSignatures>;
18
+ chartContainerProps: ChartContainerProProps<"funnel", FunnelChartPluginSignatures>;
19
19
  funnelPlotProps: FunnelPlotProps;
20
20
  overlayProps: ChartsOverlayProps;
21
21
  chartsAxisProps: ChartsAxisProps;
@@ -10,7 +10,7 @@ import { ChartContainerProProps } from "../ChartContainerPro/index.js";
10
10
  import { HeatmapSeriesType } from "../models/seriesType/heatmap.js";
11
11
  import { HeatmapTooltipProps } from "./HeatmapTooltip/index.js";
12
12
  import { HeatmapItemSlotProps, HeatmapItemSlots } from "./HeatmapItem.js";
13
- import { HeatmapPluginsSignatures } from "./Heatmap.plugins.js";
13
+ import { HeatmapPluginSignatures } from "./Heatmap.plugins.js";
14
14
  import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
15
15
  export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {
16
16
  /**
@@ -28,7 +28,7 @@ export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlot
28
28
  tooltip?: Partial<HeatmapTooltipProps>;
29
29
  }
30
30
  export type HeatmapSeries = MakeOptional<HeatmapSeriesType, 'type'>;
31
- export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginsSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation' | 'slots' | 'slotProps' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
31
+ export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation' | 'slots' | 'slotProps' | 'experimentalFeatures' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
32
32
  /**
33
33
  * The configuration of the x-axes.
34
34
  * If not provided, a default axis config is used.
@@ -1,4 +1,4 @@
1
1
  import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
- export type HeatmapPluginsSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'heatmap'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
4
- export declare const HEATMAP_PLUGINS: ConvertSignaturesIntoPlugins<HeatmapPluginsSignatures>;
3
+ export type HeatmapPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'heatmap'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
4
+ export declare const HEATMAP_PLUGINS: ConvertSignaturesIntoPlugins<HeatmapPluginSignatures>;
@@ -2,4 +2,5 @@ export { Heatmap } from "./Heatmap.js";
2
2
  export type { HeatmapSeries, HeatmapProps } from "./Heatmap.js";
3
3
  export { HeatmapPlot } from "./HeatmapPlot.js";
4
4
  export * from "./HeatmapTooltip/index.js";
5
+ export * from "./Heatmap.plugins.js";
5
6
  export * from "./heatmapClasses.js";
@@ -1,4 +1,5 @@
1
1
  export { Heatmap } from "./Heatmap.js";
2
2
  export { HeatmapPlot } from "./HeatmapPlot.js";
3
3
  export * from "./HeatmapTooltip/index.js";
4
+ export * from "./Heatmap.plugins.js";
4
5
  export * from "./heatmapClasses.js";
@@ -3,10 +3,10 @@ import { LineChartProps, LineChartSlots, LineChartSlotProps } from '@mui/x-chart
3
3
  import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
4
4
  import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
5
5
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
6
- import { LineChartProPluginsSignatures } from "./LineChartPro.plugins.js";
6
+ import { LineChartProPluginSignatures } from "./LineChartPro.plugins.js";
7
7
  export interface LineChartProSlots extends Omit<LineChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
8
8
  export interface LineChartProSlotProps extends Omit<LineChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
9
- export interface LineChartProProps extends Omit<LineChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<ChartContainerProProps<'line', LineChartProPluginsSignatures>, 'series' | 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {
9
+ export interface LineChartProProps extends Omit<LineChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<ChartContainerProProps<'line', LineChartProPluginSignatures>, 'series' | 'plugins' | 'seriesConfig' | 'slots' | 'slotProps'> {
10
10
  /**
11
11
  * Overridable component slots.
12
12
  * @default {}
@@ -132,6 +132,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
132
132
  * If `true`, render the line highlight item.
133
133
  */
134
134
  disableLineItemHighlight: PropTypes.bool,
135
+ enableKeyboardNavigation: PropTypes.bool,
135
136
  /**
136
137
  * Options to enable features planned for the next major.
137
138
  */
@@ -1418,6 +1419,29 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
1418
1419
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
1419
1420
  end: PropTypes.number.isRequired,
1420
1421
  start: PropTypes.number.isRequired
1421
- }))
1422
+ })),
1423
+ /**
1424
+ * Configuration for zoom interactions.
1425
+ */
1426
+ zoomInteractionConfig: PropTypes.shape({
1427
+ pan: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['drag']), PropTypes.shape({
1428
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1429
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1430
+ type: PropTypes.oneOf(['drag']).isRequired
1431
+ })]).isRequired),
1432
+ zoom: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(['pinch', 'tapAndDrag', 'wheel']), PropTypes.shape({
1433
+ pointerMode: PropTypes.any,
1434
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1435
+ type: PropTypes.oneOf(['wheel']).isRequired
1436
+ }), PropTypes.shape({
1437
+ pointerMode: PropTypes.any,
1438
+ requiredKeys: PropTypes.array,
1439
+ type: PropTypes.oneOf(['pinch']).isRequired
1440
+ }), PropTypes.shape({
1441
+ pointerMode: PropTypes.oneOf(['mouse', 'touch']),
1442
+ requiredKeys: PropTypes.arrayOf(PropTypes.string),
1443
+ type: PropTypes.oneOf(['tapAndDrag']).isRequired
1444
+ })]).isRequired)
1445
+ })
1422
1446
  } : void 0;
1423
1447
  export { LineChartPro };
@@ -1,5 +1,5 @@
1
- import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
1
+ import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "../internals/plugins/useChartProZoom/index.js";
4
- export type LineChartProPluginsSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'line'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
- export declare const LINE_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<LineChartProPluginsSignatures>;
4
+ export type LineChartProPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'line'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
+ export declare const LINE_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<LineChartProPluginSignatures>;
@@ -1,4 +1,4 @@
1
- import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight } from '@mui/x-charts/internals';
1
+ import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation } from '@mui/x-charts/internals';
2
2
  import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { useChartProZoom } from "../internals/plugins/useChartProZoom/index.js";
4
- export const LINE_CHART_PRO_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartProZoom, useChartProExport];
4
+ export const LINE_CHART_PRO_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartProZoom, useChartProExport];
@@ -1 +1,2 @@
1
- export * from "./LineChartPro.js";
1
+ export * from "./LineChartPro.js";
2
+ export * from "./LineChartPro.plugins.js";
@@ -1 +1,2 @@
1
- export * from "./LineChartPro.js";
1
+ export * from "./LineChartPro.js";
2
+ export * from "./LineChartPro.plugins.js";
@@ -111,6 +111,7 @@ process.env.NODE_ENV !== "production" ? PieChartPro.propTypes = {
111
111
  */
112
112
  dataset: PropTypes.arrayOf(PropTypes.object),
113
113
  desc: PropTypes.string,
114
+ enableKeyboardNavigation: PropTypes.bool,
114
115
  /**
115
116
  * The height of the chart in px. If not defined, it takes the height of the parent element.
116
117
  */
@@ -1,4 +1,4 @@
1
- import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature } from '@mui/x-charts/internals';
1
+ import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature, UseChartKeyboardNavigationSignature } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
- export type PieChartProPluginSignatures = [UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
3
+ export type PieChartProPluginSignatures = [UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProExportSignature];
4
4
  export declare const PIE_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<PieChartProPluginSignatures>;
@@ -1 +1,2 @@
1
- export * from "./PieChartPro.js";
1
+ export * from "./PieChartPro.js";
2
+ export * from "./PieChartPro.plugins.js";
@@ -1 +1,2 @@
1
- export * from "./PieChartPro.js";
1
+ export * from "./PieChartPro.js";
2
+ export * from "./PieChartPro.plugins.js";
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { RadarChartProps, RadarDataProviderProps, RadarChartSlotProps, RadarChartSlots } from '@mui/x-charts/RadarChart';
3
- import { RadarChartProPluginsSignatures } from "./RadarChartPro.plugins.js";
3
+ import { RadarChartProPluginSignatures } from "./RadarChartPro.plugins.js";
4
4
  import { ChartsToolbarProSlotProps, ChartsToolbarProSlots } from "../ChartsToolbarPro/Toolbar.types.js";
5
5
  import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
6
6
  export interface RadarChartProSlots extends Omit<RadarChartSlots, 'toolbar'>, ChartsToolbarProSlots, Partial<ChartsSlotsPro> {}
7
7
  export interface RadarChartProSlotProps extends Omit<RadarChartSlotProps, 'toolbar'>, ChartsToolbarProSlotProps, Partial<ChartsSlotPropsPro> {}
8
- export interface RadarChartProProps extends Omit<RadarChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<RadarDataProviderProps<RadarChartProPluginsSignatures>, 'plugins' | 'seriesConfig' | 'slots' | 'slotProps' | 'experimentalFeatures'> {
8
+ export interface RadarChartProProps extends Omit<RadarChartProps, 'apiRef' | 'slots' | 'slotProps'>, Omit<RadarDataProviderProps<RadarChartProPluginSignatures>, 'plugins' | 'seriesConfig' | 'slots' | 'slotProps' | 'experimentalFeatures'> {
9
9
  /**
10
10
  * Overridable component slots.
11
11
  * @default {}
@@ -1,4 +1,4 @@
1
1
  import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature, UseChartPolarAxisSignature } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
- export type RadarChartProPluginsSignatures = [UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
4
- export declare const RADAR_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<RadarChartProPluginsSignatures>;
3
+ export type RadarChartProPluginSignatures = [UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
4
+ export declare const RADAR_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<RadarChartProPluginSignatures>;
@@ -1 +1,2 @@
1
- export * from "./RadarChartPro.js";
1
+ export * from "./RadarChartPro.js";
2
+ export * from "./RadarChartPro.plugins.js";
@@ -1 +1,2 @@
1
- export * from "./RadarChartPro.js";
1
+ export * from "./RadarChartPro.js";
2
+ export * from "./RadarChartPro.plugins.js";
@@ -3,11 +3,11 @@ import { type ChartsOverlayProps } from '@mui/x-charts/ChartsOverlay';
3
3
  import type { MakeOptional } from '@mui/x-internals/types';
4
4
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
5
5
  import { type SankeyPlotProps } from "./SankeyPlot.js";
6
- import { type SankeyChartPluginsSignatures } from "./SankeyChart.plugins.js";
6
+ import { type SankeyChartPluginSignatures } from "./SankeyChart.plugins.js";
7
7
  import type { SankeySeriesType } from "./sankey.types.js";
8
8
  import type { SankeyChartSlotExtension } from "./sankeySlots.types.js";
9
9
  export type SankeySeries = MakeOptional<SankeySeriesType, 'type'>;
10
- export interface SankeyChartProps extends Omit<ChartContainerProProps<'sankey', SankeyChartPluginsSignatures>, 'plugins' | 'series' | 'slotProps' | 'slots' | 'dataset' | 'hideLegend' | 'skipAnimation' | 'highlightedItem' | 'onHighlightChange'>, Omit<SankeyPlotProps, 'data'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, SankeyChartSlotExtension {
10
+ export interface SankeyChartProps extends Omit<ChartContainerProProps<'sankey', SankeyChartPluginSignatures>, 'plugins' | 'series' | 'slotProps' | 'slots' | 'dataset' | 'hideLegend' | 'skipAnimation' | 'highlightedItem' | 'onHighlightChange'>, Omit<SankeyPlotProps, 'data'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, SankeyChartSlotExtension {
11
11
  /**
12
12
  * The series to display in the Sankey chart.
13
13
  * A single object is expected.
@@ -68,7 +68,10 @@ process.env.NODE_ENV !== "production" ? SankeyChart.propTypes = {
68
68
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
69
69
  // ----------------------------------------------------------------------
70
70
  apiRef: PropTypes.shape({
71
- current: PropTypes.object
71
+ current: PropTypes.shape({
72
+ exportAsImage: PropTypes.func.isRequired,
73
+ exportAsPrint: PropTypes.func.isRequired
74
+ })
72
75
  }),
73
76
  /**
74
77
  * Classes applied to the various elements.
@@ -1,3 +1,4 @@
1
1
  import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature } from '@mui/x-charts/internals';
2
- export type SankeyChartPluginsSignatures = [UseChartInteractionSignature, UseChartHighlightSignature];
3
- export declare const SANKEY_CHART_PLUGINS: ConvertSignaturesIntoPlugins<SankeyChartPluginsSignatures>;
2
+ import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
+ export type SankeyChartPluginSignatures = [UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
4
+ export declare const SANKEY_CHART_PLUGINS: ConvertSignaturesIntoPlugins<SankeyChartPluginSignatures>;
@@ -1,9 +1,5 @@
1
1
  import { useChartHighlight
2
2
  // useChartHighlight,
3
3
  , useChartInteraction } from '@mui/x-charts/internals';
4
- import // useChartProExport,
5
- // UseChartProExportSignature,
6
- "../internals/plugins/useChartProExport/index.js";
7
- export const SANKEY_CHART_PLUGINS = [useChartInteraction, useChartHighlight
8
- // useChartProExport,
9
- ];
4
+ import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
5
+ export const SANKEY_CHART_PLUGINS = [useChartInteraction, useChartHighlight, useChartProExport];
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import { useTheme } from '@mui/material/styles';
5
+ import { useSankeySeriesContext } from "../hooks/useSankeySeries.js";
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
6
7
  const getLinkMidpoint = link => {
7
8
  if (link.y0 === undefined || link.y1 === undefined) {
@@ -30,10 +31,20 @@ export const SankeyLinkLabel = /*#__PURE__*/React.forwardRef(function SankeyLink
30
31
  link
31
32
  } = props;
32
33
  const theme = useTheme();
34
+ const seriesContext = useSankeySeriesContext();
33
35
  if (!link.path || link.y0 === undefined || link.y1 === undefined) {
34
36
  return null; // No path defined or invalid coordinates, nothing to render
35
37
  }
36
38
  const midpoint = getLinkMidpoint(link);
39
+
40
+ // Get the series data and valueFormatter
41
+ const series = seriesContext?.series[seriesContext.seriesOrder?.[0]];
42
+ const formattedValue = series?.valueFormatter ? series.valueFormatter(link.value, {
43
+ type: 'link',
44
+ sourceId: link.source.id,
45
+ targetId: link.target.id,
46
+ location: 'label'
47
+ }) : link.value;
37
48
  return /*#__PURE__*/_jsx("text", {
38
49
  ref: ref,
39
50
  x: midpoint.x,
@@ -46,7 +57,7 @@ export const SankeyLinkLabel = /*#__PURE__*/React.forwardRef(function SankeyLink
46
57
  "data-link-target": link.target.id,
47
58
  fontFamily: theme.typography.fontFamily,
48
59
  pointerEvents: "none",
49
- children: link.value
60
+ children: formattedValue
50
61
  });
51
62
  });
52
63
  if (process.env.NODE_ENV !== "production") SankeyLinkLabel.displayName = "SankeyLinkLabel";
@@ -27,7 +27,7 @@ export function calculateSankeyLayout(data, drawingArea, theme, series = {}) {
27
27
  sort: nodeSort = null
28
28
  } = nodeOptions ?? {};
29
29
  const {
30
- color: linkColor = (theme.vars || theme).palette.text.primary,
30
+ color: linkColor = 'source',
31
31
  sort: linkSort = null,
32
32
  curveCorrection = 10
33
33
  } = linkOptions ?? {};
@@ -86,8 +86,14 @@ export function calculateSankeyLayout(data, drawingArea, theme, series = {}) {
86
86
  const originalLink = data.links.find(l => {
87
87
  return l.source === link.source.id && l.target === link.target.id;
88
88
  });
89
+ let resolvedColor = originalLink?.color ?? linkColor;
90
+ if (resolvedColor === 'source') {
91
+ resolvedColor = link.source.color ?? linkColor;
92
+ } else if (resolvedColor === 'target') {
93
+ resolvedColor = link.target.color ?? linkColor;
94
+ }
89
95
  return _extends({}, originalLink, link, {
90
- color: originalLink?.color ?? linkColor,
96
+ color: resolvedColor,
91
97
  path: improvedNaiveSankeyLinkPathHorizontal(link, curveCorrection)
92
98
  });
93
99
  });
@@ -38,9 +38,13 @@ export interface SankeyLink {
38
38
  */
39
39
  data?: any;
40
40
  /**
41
- * Optional color override for the link
41
+ * Optional color override for the link.
42
+ * Can be a color string, or a keyword:
43
+ * - 'source': Use the color of the source node
44
+ * - 'target': Use the color of the target node
45
+ * @default 'source'
42
46
  */
43
- color?: string;
47
+ color?: string | 'source' | 'target';
44
48
  }
45
49
  export type SankeyNodeOptions = {
46
50
  /**
@@ -78,9 +82,13 @@ export type SankeyNodeOptions = {
78
82
  };
79
83
  export type SankeyLinkOptions = {
80
84
  /**
81
- * Default color for links without specified colors
85
+ * Default color for links without specified colors.
86
+ * Can be a color string, or a keyword:
87
+ * - 'source': Use the color of the source node
88
+ * - 'target': Use the color of the target node
89
+ * @default 'source'
82
90
  */
83
- color?: string;
91
+ color?: string | 'source' | 'target';
84
92
  /**
85
93
  * Opacity of the links (0-1)
86
94
  */
@@ -146,6 +154,17 @@ export interface SankeySeriesType {
146
154
  * @default 6
147
155
  */
148
156
  iterations?: number;
157
+ /**
158
+ * Formatter used to render values in tooltip or other data display.
159
+ * @param {number} value The value to render.
160
+ * @param {SankeyValueFormatterContext} context The rendering context of the value.
161
+ * @param {'node' | 'link'} context.type The type of element being formatted.
162
+ * @param {SankeyNodeId} [context.nodeId] For nodes: the node ID. For links: undefined.
163
+ * @param {SankeyNodeId} [context.sourceId] For links: the source node ID. For nodes: undefined.
164
+ * @param {SankeyNodeId} [context.targetId] For links: the target node ID. For nodes: undefined.
165
+ * @returns {string | null} The formatted value to display.
166
+ */
167
+ valueFormatter?: (value: number, context: SankeyValueFormatterContext) => string | null;
149
168
  }
150
169
  /**
151
170
  * Represents the calculated positions and dimensions for a node in the Sankey diagram
@@ -170,7 +189,7 @@ export interface SankeyLayout {
170
189
  nodes: readonly SankeyLayoutNode[];
171
190
  links: readonly SankeyLayoutLink[];
172
191
  }
173
- export interface DefaultizedSankeySeriesType extends DefaultizedProps<Omit<SankeySeriesType, 'data'>, 'id'> {
192
+ export interface DefaultizedSankeySeriesType extends DefaultizedProps<Omit<SankeySeriesType, 'data'>, 'id' | 'valueFormatter'> {
174
193
  data: {
175
194
  nodes: Map<SankeyNodeId, SankeyNode>;
176
195
  links: readonly SankeyLink[];
@@ -222,4 +241,35 @@ export type SankeyLinkIdentifierWithData = SankeyLinkIdentifier & {
222
241
  };
223
242
  export type SankeyItemIdentifier = SankeyNodeIdentifier | SankeyLinkIdentifier;
224
243
  export type SankeyItemIdentifierWithData = SankeyNodeIdentifierWithData | SankeyLinkIdentifierWithData;
244
+ export type SankeyValueFormatterContext = {
245
+ /**
246
+ * Where the value will be displayed
247
+ */
248
+ location: 'tooltip' | 'label';
249
+ /**
250
+ * Can be 'node' or 'link'
251
+ */
252
+ type: 'node';
253
+ /**
254
+ * The id of the node
255
+ */
256
+ nodeId: SankeyNodeId;
257
+ } | {
258
+ /**
259
+ * Where the value will be displayed
260
+ */
261
+ location: 'tooltip' | 'label';
262
+ /**
263
+ * Can be 'node' or 'link'
264
+ */
265
+ type: 'link';
266
+ /**
267
+ * The id of the source node
268
+ */
269
+ sourceId: SankeyNodeId;
270
+ /**
271
+ * The id of the target node
272
+ */
273
+ targetId: SankeyNodeId;
274
+ };
225
275
  export {};
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ const defaultSankeyValueFormatter = v => v == null ? '' : v.toLocaleString();
2
3
  export const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
3
4
  const nodeMap = new Map();
4
5
  const nodeColor = seriesData.nodeOptions?.color;
@@ -39,6 +40,7 @@ export const getSeriesWithDefaultValues = (seriesData, seriesIndex, colors) => {
39
40
  return _extends({
40
41
  id: seriesData.id ?? `auto-generated-id-${seriesIndex}`
41
42
  }, seriesData, {
43
+ valueFormatter: seriesData.valueFormatter ?? defaultSankeyValueFormatter,
42
44
  data: {
43
45
  links: data.links,
44
46
  nodes: nodeMap