@mui/x-charts-pro 7.0.0-alpha.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 (190) hide show
  1. package/BarChartPro/BarChartPro.d.ts +18 -0
  2. package/BarChartPro/BarChartPro.js +417 -0
  3. package/BarChartPro/index.d.ts +1 -0
  4. package/BarChartPro/index.js +1 -0
  5. package/BarChartPro/package.json +6 -0
  6. package/CHANGELOG.md +4404 -0
  7. package/ChartContainerPro/ChartContainerPro.d.ts +7 -0
  8. package/ChartContainerPro/ChartContainerPro.js +282 -0
  9. package/ChartContainerPro/index.d.ts +1 -0
  10. package/ChartContainerPro/index.js +1 -0
  11. package/ChartContainerPro/package.json +6 -0
  12. package/ChartContainerPro/useChartContainerProProps.d.ts +15 -0
  13. package/ChartContainerPro/useChartContainerProProps.js +39 -0
  14. package/Heatmap/DefaultHeatmapTooltip.d.ts +7 -0
  15. package/Heatmap/DefaultHeatmapTooltip.js +97 -0
  16. package/Heatmap/Heatmap.d.ts +49 -0
  17. package/Heatmap/Heatmap.js +387 -0
  18. package/Heatmap/HeatmapItem.d.ts +49 -0
  19. package/Heatmap/HeatmapItem.js +106 -0
  20. package/Heatmap/HeatmapPlot.d.ts +9 -0
  21. package/Heatmap/HeatmapPlot.js +57 -0
  22. package/Heatmap/extremums.d.ts +2 -0
  23. package/Heatmap/extremums.js +8 -0
  24. package/Heatmap/formatter.d.ts +3 -0
  25. package/Heatmap/formatter.js +20 -0
  26. package/Heatmap/getColor.d.ts +3 -0
  27. package/Heatmap/getColor.js +15 -0
  28. package/Heatmap/heatmapClasses.d.ts +11 -0
  29. package/Heatmap/heatmapClasses.js +13 -0
  30. package/Heatmap/index.d.ts +4 -0
  31. package/Heatmap/index.js +4 -0
  32. package/Heatmap/package.json +6 -0
  33. package/Heatmap/plugin.d.ts +2 -0
  34. package/Heatmap/plugin.js +10 -0
  35. package/LICENSE +11 -0
  36. package/LineChartPro/LineChartPro.d.ts +17 -0
  37. package/LineChartPro/LineChartPro.js +473 -0
  38. package/LineChartPro/index.d.ts +1 -0
  39. package/LineChartPro/index.js +1 -0
  40. package/LineChartPro/package.json +6 -0
  41. package/README.md +26 -0
  42. package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.d.ts +7 -0
  43. package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +259 -0
  44. package/ResponsiveChartContainerPro/index.d.ts +1 -0
  45. package/ResponsiveChartContainerPro/index.js +1 -0
  46. package/ResponsiveChartContainerPro/package.json +6 -0
  47. package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.d.ts +41 -0
  48. package/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +25 -0
  49. package/ScatterChartPro/ScatterChartPro.d.ts +17 -0
  50. package/ScatterChartPro/ScatterChartPro.js +388 -0
  51. package/ScatterChartPro/index.d.ts +1 -0
  52. package/ScatterChartPro/index.js +1 -0
  53. package/ScatterChartPro/package.json +6 -0
  54. package/context/CartesianProviderPro/CartesianProviderPro.d.ts +6 -0
  55. package/context/CartesianProviderPro/CartesianProviderPro.js +54 -0
  56. package/context/CartesianProviderPro/index.d.ts +1 -0
  57. package/context/CartesianProviderPro/index.js +1 -0
  58. package/context/ZoomProvider/Zoom.types.d.ts +134 -0
  59. package/context/ZoomProvider/Zoom.types.js +1 -0
  60. package/context/ZoomProvider/ZoomContext.d.ts +4 -0
  61. package/context/ZoomProvider/ZoomContext.js +16 -0
  62. package/context/ZoomProvider/ZoomProvider.d.ts +3 -0
  63. package/context/ZoomProvider/ZoomProvider.js +53 -0
  64. package/context/ZoomProvider/ZoomSetup.d.ts +9 -0
  65. package/context/ZoomProvider/ZoomSetup.js +16 -0
  66. package/context/ZoomProvider/defaultizeZoom.d.ts +2 -0
  67. package/context/ZoomProvider/defaultizeZoom.js +31 -0
  68. package/context/ZoomProvider/index.d.ts +3 -0
  69. package/context/ZoomProvider/index.js +3 -0
  70. package/context/ZoomProvider/initializeZoomData.d.ts +6 -0
  71. package/context/ZoomProvider/initializeZoomData.js +13 -0
  72. package/context/ZoomProvider/useSetupPan.d.ts +1 -0
  73. package/context/ZoomProvider/useSetupPan.js +104 -0
  74. package/context/ZoomProvider/useSetupZoom.d.ts +1 -0
  75. package/context/ZoomProvider/useSetupZoom.js +272 -0
  76. package/context/ZoomProvider/useZoom.d.ts +7 -0
  77. package/context/ZoomProvider/useZoom.js +17 -0
  78. package/context/index.d.ts +3 -0
  79. package/context/index.js +5 -0
  80. package/context/package.json +6 -0
  81. package/hooks/index.d.ts +1 -0
  82. package/hooks/index.js +1 -0
  83. package/hooks/package.json +6 -0
  84. package/hooks/useSeries.d.ts +11 -0
  85. package/hooks/useSeries.js +14 -0
  86. package/index.d.ts +31 -0
  87. package/index.js +45 -0
  88. package/internals/utils/releaseInfo.d.ts +1 -0
  89. package/internals/utils/releaseInfo.js +13 -0
  90. package/models/index.d.ts +1 -0
  91. package/models/index.js +1 -0
  92. package/models/package.json +6 -0
  93. package/models/seriesType/heatmap.d.ts +28 -0
  94. package/models/seriesType/heatmap.js +1 -0
  95. package/models/seriesType/index.d.ts +1 -0
  96. package/models/seriesType/index.js +1 -0
  97. package/modern/BarChartPro/BarChartPro.js +417 -0
  98. package/modern/BarChartPro/index.js +1 -0
  99. package/modern/ChartContainerPro/ChartContainerPro.js +282 -0
  100. package/modern/ChartContainerPro/index.js +1 -0
  101. package/modern/ChartContainerPro/useChartContainerProProps.js +39 -0
  102. package/modern/Heatmap/DefaultHeatmapTooltip.js +97 -0
  103. package/modern/Heatmap/Heatmap.js +387 -0
  104. package/modern/Heatmap/HeatmapItem.js +106 -0
  105. package/modern/Heatmap/HeatmapPlot.js +57 -0
  106. package/modern/Heatmap/extremums.js +8 -0
  107. package/modern/Heatmap/formatter.js +20 -0
  108. package/modern/Heatmap/getColor.js +15 -0
  109. package/modern/Heatmap/heatmapClasses.js +13 -0
  110. package/modern/Heatmap/index.js +4 -0
  111. package/modern/Heatmap/plugin.js +10 -0
  112. package/modern/LineChartPro/LineChartPro.js +473 -0
  113. package/modern/LineChartPro/index.js +1 -0
  114. package/modern/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +259 -0
  115. package/modern/ResponsiveChartContainerPro/index.js +1 -0
  116. package/modern/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +25 -0
  117. package/modern/ScatterChartPro/ScatterChartPro.js +388 -0
  118. package/modern/ScatterChartPro/index.js +1 -0
  119. package/modern/context/CartesianProviderPro/CartesianProviderPro.js +54 -0
  120. package/modern/context/CartesianProviderPro/index.js +1 -0
  121. package/modern/context/ZoomProvider/Zoom.types.js +1 -0
  122. package/modern/context/ZoomProvider/ZoomContext.js +16 -0
  123. package/modern/context/ZoomProvider/ZoomProvider.js +53 -0
  124. package/modern/context/ZoomProvider/ZoomSetup.js +16 -0
  125. package/modern/context/ZoomProvider/defaultizeZoom.js +31 -0
  126. package/modern/context/ZoomProvider/index.js +3 -0
  127. package/modern/context/ZoomProvider/initializeZoomData.js +13 -0
  128. package/modern/context/ZoomProvider/useSetupPan.js +104 -0
  129. package/modern/context/ZoomProvider/useSetupZoom.js +272 -0
  130. package/modern/context/ZoomProvider/useZoom.js +17 -0
  131. package/modern/context/index.js +5 -0
  132. package/modern/hooks/index.js +1 -0
  133. package/modern/hooks/useSeries.js +14 -0
  134. package/modern/index.js +45 -0
  135. package/modern/internals/utils/releaseInfo.js +13 -0
  136. package/modern/models/index.js +1 -0
  137. package/modern/models/seriesType/heatmap.js +1 -0
  138. package/modern/models/seriesType/index.js +1 -0
  139. package/modern/typeOverloads/index.js +1 -0
  140. package/modern/typeOverloads/modules.js +1 -0
  141. package/node/BarChartPro/BarChartPro.js +425 -0
  142. package/node/BarChartPro/index.js +16 -0
  143. package/node/ChartContainerPro/ChartContainerPro.js +290 -0
  144. package/node/ChartContainerPro/index.js +16 -0
  145. package/node/ChartContainerPro/useChartContainerProProps.js +47 -0
  146. package/node/Heatmap/DefaultHeatmapTooltip.js +105 -0
  147. package/node/Heatmap/Heatmap.js +395 -0
  148. package/node/Heatmap/HeatmapItem.js +114 -0
  149. package/node/Heatmap/HeatmapPlot.js +65 -0
  150. package/node/Heatmap/extremums.js +15 -0
  151. package/node/Heatmap/formatter.js +27 -0
  152. package/node/Heatmap/getColor.js +21 -0
  153. package/node/Heatmap/heatmapClasses.js +21 -0
  154. package/node/Heatmap/index.js +47 -0
  155. package/node/Heatmap/plugin.js +17 -0
  156. package/node/LineChartPro/LineChartPro.js +481 -0
  157. package/node/LineChartPro/index.js +16 -0
  158. package/node/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +267 -0
  159. package/node/ResponsiveChartContainerPro/index.js +16 -0
  160. package/node/ResponsiveChartContainerPro/useResponsiveChartContainerProProps.js +33 -0
  161. package/node/ScatterChartPro/ScatterChartPro.js +396 -0
  162. package/node/ScatterChartPro/index.js +16 -0
  163. package/node/context/CartesianProviderPro/CartesianProviderPro.js +61 -0
  164. package/node/context/CartesianProviderPro/index.js +16 -0
  165. package/node/context/ZoomProvider/Zoom.types.js +5 -0
  166. package/node/context/ZoomProvider/ZoomContext.js +24 -0
  167. package/node/context/ZoomProvider/ZoomProvider.js +62 -0
  168. package/node/context/ZoomProvider/ZoomSetup.js +20 -0
  169. package/node/context/ZoomProvider/defaultizeZoom.js +39 -0
  170. package/node/context/ZoomProvider/index.js +38 -0
  171. package/node/context/ZoomProvider/initializeZoomData.js +20 -0
  172. package/node/context/ZoomProvider/useSetupPan.js +114 -0
  173. package/node/context/ZoomProvider/useSetupZoom.js +281 -0
  174. package/node/context/ZoomProvider/useZoom.js +25 -0
  175. package/node/context/index.js +27 -0
  176. package/node/hooks/index.js +12 -0
  177. package/node/hooks/useSeries.js +21 -0
  178. package/node/index.js +354 -0
  179. package/node/internals/utils/releaseInfo.js +20 -0
  180. package/node/models/index.js +16 -0
  181. package/node/models/seriesType/heatmap.js +5 -0
  182. package/node/models/seriesType/index.js +16 -0
  183. package/node/typeOverloads/index.js +6 -0
  184. package/node/typeOverloads/modules.js +5 -0
  185. package/package.json +64 -0
  186. package/typeOverloads/index.d.ts +1 -0
  187. package/typeOverloads/index.js +1 -0
  188. package/typeOverloads/modules.d.ts +17 -0
  189. package/typeOverloads/modules.js +1 -0
  190. package/typeOverloads/package.json +6 -0
@@ -0,0 +1,387 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
5
+ import useId from '@mui/utils/useId';
6
+ import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
7
+ import { ChartsTooltip } from '@mui/x-charts/ChartsTooltip';
8
+ import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
9
+ import { ChartsOnAxisClickHandler } from '@mui/x-charts/ChartsOnAxisClickHandler';
10
+ import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
11
+ import { ResponsiveChartContainerPro } from '../ResponsiveChartContainerPro';
12
+ import { HeatmapPlot } from './HeatmapPlot';
13
+ import { plugin as heatmapPlugin } from './plugin';
14
+ import { DefaultHeatmapTooltip } from './DefaultHeatmapTooltip';
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ // The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
17
+ const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
18
+ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(props, ref) {
19
+ const {
20
+ xAxis,
21
+ yAxis,
22
+ zAxis,
23
+ series,
24
+ width,
25
+ height,
26
+ margin,
27
+ colors,
28
+ dataset,
29
+ sx,
30
+ tooltip,
31
+ topAxis,
32
+ leftAxis,
33
+ rightAxis,
34
+ bottomAxis,
35
+ onAxisClick,
36
+ children,
37
+ slots,
38
+ slotProps,
39
+ loading,
40
+ highlightedItem,
41
+ onHighlightChange
42
+ } = props;
43
+ const id = useId();
44
+ const clipPathId = `${id}-clip-path`;
45
+ const defaultizedXAxis = React.useMemo(() => xAxis.map(axis => _extends({
46
+ scaleType: 'band',
47
+ categoryGapRatio: 0
48
+ }, axis)), [xAxis]);
49
+ const defaultizedYAxis = React.useMemo(() => yAxis.map(axis => _extends({
50
+ scaleType: 'band',
51
+ categoryGapRatio: 0
52
+ }, axis)), [yAxis]);
53
+ const defaultizedZAxis = React.useMemo(() => zAxis ?? [{
54
+ colorMap: {
55
+ type: 'continuous',
56
+ min: 0,
57
+ max: 100,
58
+ color: defaultColorMap
59
+ }
60
+ }], [zAxis]);
61
+ return /*#__PURE__*/_jsxs(ResponsiveChartContainerPro, {
62
+ ref: ref,
63
+ plugins: [heatmapPlugin],
64
+ series: series.map(s => _extends({
65
+ type: 'heatmap'
66
+ }, s)),
67
+ width: width,
68
+ height: height,
69
+ margin: margin,
70
+ xAxis: defaultizedXAxis,
71
+ yAxis: defaultizedYAxis,
72
+ zAxis: defaultizedZAxis,
73
+ colors: colors,
74
+ dataset: dataset,
75
+ sx: sx,
76
+ disableAxisListener: true,
77
+ highlightedItem: highlightedItem,
78
+ onHighlightChange: onHighlightChange,
79
+ children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
80
+ onAxisClick: onAxisClick
81
+ }), /*#__PURE__*/_jsxs("g", {
82
+ clipPath: `url(#${clipPathId})`,
83
+ children: [/*#__PURE__*/_jsx(HeatmapPlot, {
84
+ slots: slots,
85
+ slotProps: slotProps
86
+ }), /*#__PURE__*/_jsx(ChartsOverlay, {
87
+ loading: loading,
88
+ slots: slots,
89
+ slotProps: slotProps
90
+ })]
91
+ }), /*#__PURE__*/_jsx(ChartsAxis, {
92
+ topAxis: topAxis,
93
+ leftAxis: leftAxis,
94
+ rightAxis: rightAxis,
95
+ bottomAxis: bottomAxis,
96
+ slots: slots,
97
+ slotProps: slotProps
98
+ }), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({
99
+ trigger: "item"
100
+ }, tooltip, {
101
+ slots: _extends({
102
+ itemContent: DefaultHeatmapTooltip
103
+ }, slots),
104
+ slotProps: slotProps
105
+ })), /*#__PURE__*/_jsx(ChartsClipPath, {
106
+ id: clipPathId
107
+ }), children]
108
+ });
109
+ });
110
+ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
111
+ // ----------------------------- Warning --------------------------------
112
+ // | These PropTypes are generated from the TypeScript type definitions |
113
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
114
+ // ----------------------------------------------------------------------
115
+ /**
116
+ * Indicate which axis to display the bottom of the charts.
117
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
118
+ * @default xAxisIds[0] The id of the first provided axis
119
+ */
120
+ bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
121
+ children: PropTypes.node,
122
+ className: PropTypes.string,
123
+ /**
124
+ * Color palette used to colorize multiple series.
125
+ * @default blueberryTwilightPalette
126
+ */
127
+ colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
128
+ /**
129
+ * An array of objects that can be used to populate series and axes data using their `dataKey` property.
130
+ */
131
+ dataset: PropTypes.arrayOf(PropTypes.object),
132
+ desc: PropTypes.string,
133
+ /**
134
+ * If `true`, the charts will not listen to the mouse move event.
135
+ * It might break interactive features, but will improve performance.
136
+ * @default false
137
+ */
138
+ disableAxisListener: PropTypes.bool,
139
+ /**
140
+ * The height of the chart in px. If not defined, it takes the height of the parent element.
141
+ */
142
+ height: PropTypes.number,
143
+ /**
144
+ * The item currently highlighted. Turns highlighting into a controlled prop.
145
+ */
146
+ highlightedItem: PropTypes.shape({
147
+ dataIndex: PropTypes.number,
148
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
149
+ }),
150
+ /**
151
+ * Indicate which axis to display the left of the charts.
152
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
153
+ * @default yAxisIds[0] The id of the first provided axis
154
+ */
155
+ leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
156
+ /**
157
+ * If `true`, a loading overlay is displayed.
158
+ * @default false
159
+ */
160
+ loading: PropTypes.bool,
161
+ /**
162
+ * The margin between the SVG and the drawing area.
163
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
164
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
165
+ * @default object Depends on the charts type.
166
+ */
167
+ margin: PropTypes.shape({
168
+ bottom: PropTypes.number,
169
+ left: PropTypes.number,
170
+ right: PropTypes.number,
171
+ top: PropTypes.number
172
+ }),
173
+ /**
174
+ * The function called for onClick events.
175
+ * The second argument contains information about all line/bar elements at the current mouse position.
176
+ * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
177
+ * @param {null | AxisData} data The data about the clicked axis and items associated with it.
178
+ */
179
+ onAxisClick: PropTypes.func,
180
+ /**
181
+ * The callback fired when the highlighted item changes.
182
+ *
183
+ * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
184
+ */
185
+ onHighlightChange: PropTypes.func,
186
+ /**
187
+ * Indicate which axis to display the right of the charts.
188
+ * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
189
+ * @default null
190
+ */
191
+ rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
192
+ /**
193
+ * The series to display in the bar chart.
194
+ * An array of [[HeatmapSeriesType]] objects.
195
+ */
196
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
197
+ /**
198
+ * The props used for each component slot.
199
+ * @default {}
200
+ */
201
+ slotProps: PropTypes.object,
202
+ /**
203
+ * Overridable component slots.
204
+ * @default {}
205
+ */
206
+ slots: PropTypes.object,
207
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
208
+ title: PropTypes.string,
209
+ /**
210
+ * The configuration of the tooltip.
211
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
212
+ */
213
+ tooltip: PropTypes.shape({
214
+ axisContent: PropTypes.elementType,
215
+ classes: PropTypes.object,
216
+ itemContent: PropTypes.elementType,
217
+ slotProps: PropTypes.object,
218
+ slots: PropTypes.object,
219
+ trigger: PropTypes.oneOf(['axis', 'item', 'none'])
220
+ }),
221
+ /**
222
+ * Indicate which axis to display the top of the charts.
223
+ * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
224
+ * @default null
225
+ */
226
+ topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
227
+ viewBox: PropTypes.shape({
228
+ height: PropTypes.number,
229
+ width: PropTypes.number,
230
+ x: PropTypes.number,
231
+ y: PropTypes.number
232
+ }),
233
+ /**
234
+ * The width of the chart in px. If not defined, it takes the width of the parent element.
235
+ */
236
+ width: PropTypes.number,
237
+ /**
238
+ * The configuration of the x-axes.
239
+ * If not provided, a default axis config is used.
240
+ * An array of [[AxisConfig]] objects.
241
+ */
242
+ xAxis: PropTypes.arrayOf(PropTypes.shape({
243
+ barGapRatio: PropTypes.number,
244
+ categoryGapRatio: PropTypes.number,
245
+ classes: PropTypes.object,
246
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
247
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
248
+ type: PropTypes.oneOf(['ordinal']).isRequired,
249
+ unknownColor: PropTypes.string,
250
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
251
+ }), PropTypes.shape({
252
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
253
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
254
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
255
+ type: PropTypes.oneOf(['continuous']).isRequired
256
+ }), PropTypes.shape({
257
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
258
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
259
+ type: PropTypes.oneOf(['piecewise']).isRequired
260
+ })]),
261
+ data: PropTypes.array,
262
+ dataKey: PropTypes.string,
263
+ disableLine: PropTypes.bool,
264
+ disableTicks: PropTypes.bool,
265
+ fill: PropTypes.string,
266
+ hideTooltip: PropTypes.bool,
267
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
268
+ label: PropTypes.string,
269
+ labelFontSize: PropTypes.number,
270
+ labelStyle: PropTypes.object,
271
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
272
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
273
+ position: PropTypes.oneOf(['bottom', 'top']),
274
+ reverse: PropTypes.bool,
275
+ scaleType: PropTypes.oneOf(['band']),
276
+ slotProps: PropTypes.object,
277
+ slots: PropTypes.object,
278
+ stroke: PropTypes.string,
279
+ tickFontSize: PropTypes.number,
280
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
281
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
282
+ tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
283
+ tickLabelStyle: PropTypes.object,
284
+ tickMaxStep: PropTypes.number,
285
+ tickMinStep: PropTypes.number,
286
+ tickNumber: PropTypes.number,
287
+ tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
288
+ tickSize: PropTypes.number,
289
+ valueFormatter: PropTypes.func,
290
+ zoom: PropTypes.oneOfType([PropTypes.shape({
291
+ maxEnd: PropTypes.number,
292
+ maxSpan: PropTypes.number,
293
+ minSpan: PropTypes.number,
294
+ minStart: PropTypes.number,
295
+ panning: PropTypes.bool,
296
+ step: PropTypes.number
297
+ }), PropTypes.bool])
298
+ })).isRequired,
299
+ /**
300
+ * The configuration of the y-axes.
301
+ * If not provided, a default axis config is used.
302
+ * An array of [[AxisConfig]] objects.
303
+ */
304
+ yAxis: PropTypes.arrayOf(PropTypes.shape({
305
+ barGapRatio: PropTypes.number,
306
+ categoryGapRatio: PropTypes.number,
307
+ classes: PropTypes.object,
308
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
309
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
310
+ type: PropTypes.oneOf(['ordinal']).isRequired,
311
+ unknownColor: PropTypes.string,
312
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
313
+ }), PropTypes.shape({
314
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
315
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
316
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
317
+ type: PropTypes.oneOf(['continuous']).isRequired
318
+ }), PropTypes.shape({
319
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
320
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
321
+ type: PropTypes.oneOf(['piecewise']).isRequired
322
+ })]),
323
+ data: PropTypes.array,
324
+ dataKey: PropTypes.string,
325
+ disableLine: PropTypes.bool,
326
+ disableTicks: PropTypes.bool,
327
+ fill: PropTypes.string,
328
+ hideTooltip: PropTypes.bool,
329
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
330
+ label: PropTypes.string,
331
+ labelFontSize: PropTypes.number,
332
+ labelStyle: PropTypes.object,
333
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
334
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
335
+ position: PropTypes.oneOf(['left', 'right']),
336
+ reverse: PropTypes.bool,
337
+ scaleType: PropTypes.oneOf(['band']),
338
+ slotProps: PropTypes.object,
339
+ slots: PropTypes.object,
340
+ stroke: PropTypes.string,
341
+ tickFontSize: PropTypes.number,
342
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
343
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
344
+ tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
345
+ tickLabelStyle: PropTypes.object,
346
+ tickMaxStep: PropTypes.number,
347
+ tickMinStep: PropTypes.number,
348
+ tickNumber: PropTypes.number,
349
+ tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
350
+ tickSize: PropTypes.number,
351
+ valueFormatter: PropTypes.func,
352
+ zoom: PropTypes.oneOfType([PropTypes.shape({
353
+ maxEnd: PropTypes.number,
354
+ maxSpan: PropTypes.number,
355
+ minSpan: PropTypes.number,
356
+ minStart: PropTypes.number,
357
+ panning: PropTypes.bool,
358
+ step: PropTypes.number
359
+ }), PropTypes.bool])
360
+ })).isRequired,
361
+ /**
362
+ * The configuration of the z-axes.
363
+ */
364
+ zAxis: PropTypes.arrayOf(PropTypes.shape({
365
+ colorMap: PropTypes.oneOfType([PropTypes.shape({
366
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
367
+ type: PropTypes.oneOf(['ordinal']).isRequired,
368
+ unknownColor: PropTypes.string,
369
+ values: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired)
370
+ }), PropTypes.shape({
371
+ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
372
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
373
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
374
+ type: PropTypes.oneOf(['continuous']).isRequired
375
+ }), PropTypes.shape({
376
+ colors: PropTypes.arrayOf(PropTypes.string).isRequired,
377
+ thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
378
+ type: PropTypes.oneOf(['piecewise']).isRequired
379
+ })]),
380
+ data: PropTypes.array,
381
+ dataKey: PropTypes.string,
382
+ id: PropTypes.string,
383
+ max: PropTypes.number,
384
+ min: PropTypes.number
385
+ }))
386
+ } : void 0;
387
+ export { Heatmap };
@@ -0,0 +1,49 @@
1
+ import * as React from 'react';
2
+ import { SeriesId } from '@mui/x-charts/internals';
3
+ import { HeatmapClasses } from './heatmapClasses';
4
+ export interface HeatmapItemSlots {
5
+ /**
6
+ * The component that renders the heatmap cell.
7
+ * @default HeatmapCell
8
+ */
9
+ cell?: React.ElementType;
10
+ }
11
+ export interface HeatmapItemSlotProps {
12
+ cell?: Partial<React.ComponentPropsWithRef<'rect'>>;
13
+ }
14
+ export interface HeatmapItemProps {
15
+ dataIndex: number;
16
+ seriesId: SeriesId;
17
+ value: number;
18
+ width: number;
19
+ height: number;
20
+ x: number;
21
+ y: number;
22
+ color: string;
23
+ /**
24
+ * The props used for each component slot.
25
+ * @default {}
26
+ */
27
+ slotProps?: HeatmapItemSlotProps;
28
+ /**
29
+ * Overridable component slots.
30
+ * @default {}
31
+ */
32
+ slots?: HeatmapItemSlots;
33
+ }
34
+ export interface HeatmapItemOwnerState {
35
+ seriesId: SeriesId;
36
+ dataIndex: number;
37
+ color: string;
38
+ isFaded: boolean;
39
+ isHighlighted: boolean;
40
+ classes?: Partial<HeatmapClasses>;
41
+ }
42
+ /**
43
+ * @ignore - internal component.
44
+ */
45
+ declare function HeatmapItem(props: HeatmapItemProps): React.JSX.Element;
46
+ declare namespace HeatmapItem {
47
+ var propTypes: any;
48
+ }
49
+ export { HeatmapItem };
@@ -0,0 +1,106 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["seriesId", "dataIndex", "color", "value", "slotProps", "slots"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { styled } from '@mui/material/styles';
7
+ import useSlotProps from '@mui/utils/useSlotProps';
8
+ import composeClasses from '@mui/utils/composeClasses';
9
+ import { useItemHighlighted } from '@mui/x-charts/context';
10
+ import { useInteractionItemProps } from '@mui/x-charts/internals';
11
+ import { getHeatmapUtilityClass } from './heatmapClasses';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const HeatmapCell = styled('rect', {
14
+ name: 'MuiHeatmap',
15
+ slot: 'Cell',
16
+ overridesResolver: (_, styles) => styles.arc
17
+ })(({
18
+ ownerState
19
+ }) => ({
20
+ filter: ownerState.isHighlighted && 'saturate(120%)' || ownerState.isFaded && 'saturate(80%)' || undefined,
21
+ fill: ownerState.color,
22
+ shapeRendering: 'crispEdges'
23
+ }));
24
+ const useUtilityClasses = ownerState => {
25
+ const {
26
+ classes,
27
+ seriesId,
28
+ isFaded,
29
+ isHighlighted
30
+ } = ownerState;
31
+ const slots = {
32
+ cell: ['cell', `series-${seriesId}`, isFaded && 'faded', isHighlighted && 'highlighted']
33
+ };
34
+ return composeClasses(slots, getHeatmapUtilityClass, classes);
35
+ };
36
+
37
+ /**
38
+ * @ignore - internal component.
39
+ */
40
+ function HeatmapItem(props) {
41
+ const {
42
+ seriesId,
43
+ dataIndex,
44
+ color,
45
+ value,
46
+ slotProps = {},
47
+ slots = {}
48
+ } = props,
49
+ other = _objectWithoutPropertiesLoose(props, _excluded);
50
+ const getInteractionItemProps = useInteractionItemProps();
51
+ const {
52
+ isFaded,
53
+ isHighlighted
54
+ } = useItemHighlighted({
55
+ seriesId,
56
+ dataIndex
57
+ });
58
+ const ownerState = {
59
+ seriesId,
60
+ dataIndex,
61
+ color,
62
+ value,
63
+ isFaded,
64
+ isHighlighted
65
+ };
66
+ const classes = useUtilityClasses(ownerState);
67
+ const Cell = slots?.cell ?? HeatmapCell;
68
+ const cellProps = useSlotProps({
69
+ elementType: Cell,
70
+ additionalProps: _extends({}, getInteractionItemProps({
71
+ type: 'heatmap',
72
+ seriesId,
73
+ dataIndex
74
+ })),
75
+ externalForwardedProps: _extends({}, other),
76
+ externalSlotProps: slotProps.cell,
77
+ ownerState,
78
+ className: classes.cell
79
+ });
80
+ return /*#__PURE__*/_jsx(Cell, _extends({}, cellProps));
81
+ }
82
+ process.env.NODE_ENV !== "production" ? HeatmapItem.propTypes = {
83
+ // ----------------------------- Warning --------------------------------
84
+ // | These PropTypes are generated from the TypeScript type definitions |
85
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
86
+ // ----------------------------------------------------------------------
87
+ color: PropTypes.string.isRequired,
88
+ dataIndex: PropTypes.number.isRequired,
89
+ height: PropTypes.number.isRequired,
90
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
91
+ /**
92
+ * The props used for each component slot.
93
+ * @default {}
94
+ */
95
+ slotProps: PropTypes.object,
96
+ /**
97
+ * Overridable component slots.
98
+ * @default {}
99
+ */
100
+ slots: PropTypes.object,
101
+ value: PropTypes.number.isRequired,
102
+ width: PropTypes.number.isRequired,
103
+ x: PropTypes.number.isRequired,
104
+ y: PropTypes.number.isRequired
105
+ } : void 0;
106
+ export { HeatmapItem };
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { HeatmapItemProps } from './HeatmapItem';
3
+ export interface HeatmapPlotProps extends Pick<HeatmapItemProps, 'slots' | 'slotProps'> {
4
+ }
5
+ declare function HeatmapPlot(props: HeatmapPlotProps): React.JSX.Element | null;
6
+ declare namespace HeatmapPlot {
7
+ var propTypes: any;
8
+ }
9
+ export { HeatmapPlot };
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useXScale, useYScale, useZColorScale } from '@mui/x-charts/hooks';
4
+ import { useHeatmapSeries } from '../hooks/useSeries';
5
+ import { HeatmapItem } from './HeatmapItem';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ function HeatmapPlot(props) {
8
+ const xScale = useXScale();
9
+ const yScale = useYScale();
10
+ const colorScale = useZColorScale();
11
+ const series = useHeatmapSeries();
12
+ const xDomain = xScale.domain();
13
+ const yDomain = yScale.domain();
14
+ if (!series || series.seriesOrder.length === 0) {
15
+ return null;
16
+ }
17
+ const seriesToDisplay = series.series[series.seriesOrder[0]];
18
+ return /*#__PURE__*/_jsx("g", {
19
+ children: seriesToDisplay.data.map(([xIndex, yIndex, value], dataIndex) => {
20
+ const x = xScale(xDomain[xIndex]);
21
+ const y = yScale(yDomain[yIndex]);
22
+ const color = colorScale?.(value);
23
+ if (x === undefined || y === undefined || !color) {
24
+ return null;
25
+ }
26
+ return /*#__PURE__*/_jsx(HeatmapItem, {
27
+ width: xScale.bandwidth(),
28
+ height: yScale.bandwidth(),
29
+ x: x,
30
+ y: y,
31
+ color: color,
32
+ dataIndex: dataIndex,
33
+ seriesId: series.seriesOrder[0],
34
+ value: value,
35
+ slots: props.slots,
36
+ slotProps: props.slotProps
37
+ }, `${xIndex}_${yIndex}`);
38
+ })
39
+ });
40
+ }
41
+ process.env.NODE_ENV !== "production" ? HeatmapPlot.propTypes = {
42
+ // ----------------------------- Warning --------------------------------
43
+ // | These PropTypes are generated from the TypeScript type definitions |
44
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
45
+ // ----------------------------------------------------------------------
46
+ /**
47
+ * The props used for each component slot.
48
+ * @default {}
49
+ */
50
+ slotProps: PropTypes.object,
51
+ /**
52
+ * Overridable component slots.
53
+ * @default {}
54
+ */
55
+ slots: PropTypes.object
56
+ } : void 0;
57
+ export { HeatmapPlot };
@@ -0,0 +1,2 @@
1
+ import { ExtremumGetter } from '@mui/x-charts/internals';
2
+ export declare const getBaseExtremum: ExtremumGetter<'heatmap'>;
@@ -0,0 +1,8 @@
1
+ export const getBaseExtremum = params => {
2
+ const {
3
+ axis
4
+ } = params;
5
+ const minX = Math.min(...(axis.data ?? []));
6
+ const maxX = Math.max(...(axis.data ?? []));
7
+ return [minX, maxX];
8
+ };
@@ -0,0 +1,3 @@
1
+ import { SeriesFormatter } from '@mui/x-charts/internals';
2
+ declare const formatter: SeriesFormatter<'heatmap'>;
3
+ export default formatter;
@@ -0,0 +1,20 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ const formatter = params => {
3
+ const {
4
+ series,
5
+ seriesOrder
6
+ } = params;
7
+ const defaultizedSeries = {};
8
+ Object.keys(series).forEach(seriesId => {
9
+ defaultizedSeries[seriesId] = _extends({
10
+ // Defaultize the data and the value formatter.
11
+ valueFormatter: v => v[2].toString(),
12
+ data: []
13
+ }, series[seriesId]);
14
+ });
15
+ return {
16
+ series: defaultizedSeries,
17
+ seriesOrder
18
+ };
19
+ };
20
+ export default formatter;
@@ -0,0 +1,3 @@
1
+ import { ColorProcessor } from '@mui/x-charts/internals';
2
+ declare const getColor: ColorProcessor<'heatmap'>;
3
+ export default getColor;
@@ -0,0 +1,15 @@
1
+ const getColor = (series, xAxis, yAxis, zAxis) => {
2
+ const zColorScale = zAxis?.colorScale;
3
+ if (zColorScale) {
4
+ return dataIndex => {
5
+ const value = series.data[dataIndex];
6
+ const color = zColorScale(value[2]);
7
+ if (color === null) {
8
+ return '';
9
+ }
10
+ return color;
11
+ };
12
+ }
13
+ return () => '';
14
+ };
15
+ export default getColor;
@@ -0,0 +1,11 @@
1
+ export interface HeatmapClasses {
2
+ /** Styles applied to the heatmap cells. */
3
+ cell: string;
4
+ /** Styles applied to the cell element if highlighted. */
5
+ highlighted: string;
6
+ /** Styles applied to the cell element if faded. */
7
+ faded: string;
8
+ }
9
+ export type HeatmapClassKey = keyof HeatmapClasses;
10
+ export declare function getHeatmapUtilityClass(slot: string): string;
11
+ export declare const heatmapClasses: HeatmapClasses;