@mantine/charts 7.8.1 → 7.9.1

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 (59) hide show
  1. package/cjs/AreaChart/AreaChart.cjs +171 -165
  2. package/cjs/AreaChart/AreaChart.cjs.map +1 -1
  3. package/cjs/AreaChart/AreaGradient.cjs +5 -6
  4. package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
  5. package/cjs/AreaChart/AreaSplit.cjs +19 -20
  6. package/cjs/AreaChart/AreaSplit.cjs.map +1 -1
  7. package/cjs/BarChart/BarChart.cjs +144 -126
  8. package/cjs/BarChart/BarChart.cjs.map +1 -1
  9. package/cjs/ChartLegend/ChartLegend.cjs +17 -19
  10. package/cjs/ChartLegend/ChartLegend.cjs.map +1 -1
  11. package/cjs/ChartTooltip/ChartTooltip.cjs +23 -15
  12. package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -1
  13. package/cjs/DonutChart/DonutChart.cjs +61 -60
  14. package/cjs/DonutChart/DonutChart.cjs.map +1 -1
  15. package/cjs/LineChart/LineChart.cjs +127 -124
  16. package/cjs/LineChart/LineChart.cjs.map +1 -1
  17. package/cjs/PieChart/PieChart.cjs +67 -67
  18. package/cjs/PieChart/PieChart.cjs.map +1 -1
  19. package/cjs/RadarChart/RadarChart.cjs +11 -9
  20. package/cjs/RadarChart/RadarChart.cjs.map +1 -1
  21. package/cjs/ScatterChart/ScatterChart.cjs +140 -137
  22. package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
  23. package/cjs/Sparkline/Sparkline.cjs +29 -29
  24. package/cjs/Sparkline/Sparkline.cjs.map +1 -1
  25. package/esm/AreaChart/AreaChart.mjs +169 -159
  26. package/esm/AreaChart/AreaChart.mjs.map +1 -1
  27. package/esm/AreaChart/AreaGradient.mjs +5 -2
  28. package/esm/AreaChart/AreaGradient.mjs.map +1 -1
  29. package/esm/AreaChart/AreaSplit.mjs +19 -16
  30. package/esm/AreaChart/AreaSplit.mjs.map +1 -1
  31. package/esm/BarChart/BarChart.mjs +143 -121
  32. package/esm/BarChart/BarChart.mjs.map +1 -1
  33. package/esm/ChartLegend/ChartLegend.mjs +17 -15
  34. package/esm/ChartLegend/ChartLegend.mjs.map +1 -1
  35. package/esm/ChartTooltip/ChartTooltip.mjs +23 -11
  36. package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -1
  37. package/esm/DonutChart/DonutChart.mjs +61 -56
  38. package/esm/DonutChart/DonutChart.mjs.map +1 -1
  39. package/esm/LineChart/LineChart.mjs +126 -119
  40. package/esm/LineChart/LineChart.mjs.map +1 -1
  41. package/esm/PieChart/PieChart.mjs +67 -63
  42. package/esm/PieChart/PieChart.mjs.map +1 -1
  43. package/esm/RadarChart/RadarChart.mjs +11 -5
  44. package/esm/RadarChart/RadarChart.mjs.map +1 -1
  45. package/esm/ScatterChart/ScatterChart.mjs +139 -132
  46. package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
  47. package/esm/Sparkline/Sparkline.mjs +27 -23
  48. package/esm/Sparkline/Sparkline.mjs.map +1 -1
  49. package/lib/AreaChart/AreaChart.d.ts +0 -1
  50. package/lib/AreaChart/AreaGradient.d.ts +1 -2
  51. package/lib/AreaChart/AreaSplit.d.ts +1 -2
  52. package/lib/BarChart/BarChart.d.ts +2 -1
  53. package/lib/ChartTooltip/ChartTooltip.d.ts +0 -1
  54. package/lib/DonutChart/DonutChart.d.ts +0 -1
  55. package/lib/LineChart/LineChart.d.ts +0 -1
  56. package/lib/PieChart/PieChart.d.ts +0 -1
  57. package/lib/RadarChart/RadarChart.d.ts +0 -1
  58. package/lib/ScatterChart/ScatterChart.d.ts +0 -1
  59. package/package.json +5 -5
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  'use strict';
3
3
 
4
- var React = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var react = require('react');
5
6
  var recharts = require('recharts');
6
7
  var core = require('@mantine/core');
7
8
  var ChartLegend = require('../ChartLegend/ChartLegend.cjs');
@@ -11,10 +12,6 @@ var AreaSplit = require('./AreaSplit.cjs');
11
12
  var getSplitOffset = require('./get-split-offset.cjs');
12
13
  var gridChart_module = require('../grid-chart.module.css.cjs');
13
14
 
14
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
-
16
- var React__default = /*#__PURE__*/_interopDefault(React);
17
-
18
15
  function valueToPercent(value) {
19
16
  return `${(value * 100).toFixed(0)}%`;
20
17
  }
@@ -91,14 +88,14 @@ const AreaChart = core.factory((_props, ref) => {
91
88
  ...others
92
89
  } = props;
93
90
  const theme = core.useMantineTheme();
94
- const baseId = React.useId();
91
+ const baseId = react.useId();
95
92
  const splitId = `${baseId}-split`;
96
93
  const withXTickLine = gridAxis !== "none" && (tickLine === "x" || tickLine === "xy");
97
94
  const withYTickLine = gridAxis !== "none" && (tickLine === "y" || tickLine === "xy");
98
95
  const isAnimationActive = (tooltipAnimationDuration || 0) > 0;
99
96
  const _withGradient = typeof withGradient === "boolean" ? withGradient : type === "default";
100
97
  const stacked = type === "stacked" || type === "percent";
101
- const [highlightedArea, setHighlightedArea] = React.useState(null);
98
+ const [highlightedArea, setHighlightedArea] = react.useState(null);
102
99
  const shouldHighlight = highlightedArea !== null;
103
100
  const handleMouseLeave = (event) => {
104
101
  setHighlightedArea(null);
@@ -124,7 +121,7 @@ const AreaChart = core.factory((_props, ref) => {
124
121
  const dotsAreas = series.map((item) => {
125
122
  const color = core.getThemeColor(item.color, theme);
126
123
  const dimmed = shouldHighlight && highlightedArea !== item.name;
127
- return /* @__PURE__ */ React__default.default.createElement(
124
+ return /* @__PURE__ */ react.createElement(
128
125
  recharts.Area,
129
126
  {
130
127
  ...getStyles("area"),
@@ -148,42 +145,44 @@ const AreaChart = core.factory((_props, ref) => {
148
145
  const id = `${baseId}-${item.color.replace(/[^a-zA-Z0-9]/g, "")}`;
149
146
  const color = core.getThemeColor(item.color, theme);
150
147
  const dimmed = shouldHighlight && highlightedArea !== item.name;
151
- return /* @__PURE__ */ React__default.default.createElement(React.Fragment, { key: item.name }, /* @__PURE__ */ React__default.default.createElement("defs", null, /* @__PURE__ */ React__default.default.createElement(
152
- AreaGradient.AreaGradient,
153
- {
154
- color,
155
- withGradient: _withGradient,
156
- id,
157
- fillOpacity
158
- }
159
- )), /* @__PURE__ */ React__default.default.createElement(
160
- recharts.Area,
161
- {
162
- ...getStyles("area"),
163
- activeDot: false,
164
- dot: false,
165
- name: item.name,
166
- type: curveType,
167
- dataKey: item.name,
168
- fill: type === "split" ? `url(#${splitId})` : `url(#${id})`,
169
- strokeWidth,
170
- stroke: color,
171
- isAnimationActive: false,
172
- connectNulls,
173
- stackId: stacked ? "stack" : void 0,
174
- fillOpacity: dimmed ? 0 : 1,
175
- strokeOpacity: dimmed ? 0.5 : 1,
176
- strokeDasharray: item.strokeDasharray,
177
- ...typeof areaProps === "function" ? areaProps(item) : areaProps
178
- }
179
- ));
148
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
149
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx(
150
+ AreaGradient.AreaGradient,
151
+ {
152
+ color,
153
+ withGradient: _withGradient,
154
+ id,
155
+ fillOpacity
156
+ }
157
+ ) }),
158
+ /* @__PURE__ */ jsxRuntime.jsx(
159
+ recharts.Area,
160
+ {
161
+ ...getStyles("area"),
162
+ activeDot: false,
163
+ dot: false,
164
+ name: item.name,
165
+ type: curveType,
166
+ dataKey: item.name,
167
+ fill: type === "split" ? `url(#${splitId})` : `url(#${id})`,
168
+ strokeWidth,
169
+ stroke: color,
170
+ isAnimationActive: false,
171
+ connectNulls,
172
+ stackId: stacked ? "stack" : void 0,
173
+ fillOpacity: dimmed ? 0 : 1,
174
+ strokeOpacity: dimmed ? 0.5 : 1,
175
+ strokeDasharray: item.strokeDasharray,
176
+ ...typeof areaProps === "function" ? areaProps(item) : areaProps
177
+ }
178
+ )
179
+ ] }, item.name);
180
180
  });
181
181
  const referenceLinesItems = referenceLines?.map((line, index) => {
182
182
  const color = core.getThemeColor(line.color, theme);
183
- return /* @__PURE__ */ React__default.default.createElement(
183
+ return /* @__PURE__ */ jsxRuntime.jsx(
184
184
  recharts.ReferenceLine,
185
185
  {
186
- key: index,
187
186
  stroke: line.color ? color : "var(--chart-grid-color)",
188
187
  strokeWidth: 1,
189
188
  ...line,
@@ -194,143 +193,150 @@ const AreaChart = core.factory((_props, ref) => {
194
193
  position: line.labelPosition ?? "insideBottomLeft"
195
194
  },
196
195
  ...getStyles("referenceLine")
197
- }
196
+ },
197
+ index
198
198
  );
199
199
  });
200
- return /* @__PURE__ */ React__default.default.createElement(
200
+ return /* @__PURE__ */ jsxRuntime.jsx(
201
201
  core.Box,
202
202
  {
203
203
  ref,
204
204
  ...getStyles("root"),
205
205
  onMouseLeave: handleMouseLeave,
206
206
  dir: dir || "ltr",
207
- ...others
208
- },
209
- /* @__PURE__ */ React__default.default.createElement(recharts.ResponsiveContainer, { ...getStyles("container") }, /* @__PURE__ */ React__default.default.createElement(
210
- recharts.AreaChart,
211
- {
212
- data,
213
- stackOffset: type === "percent" ? "expand" : void 0,
214
- layout: orientation,
215
- margin: {
216
- bottom: xAxisLabel ? 30 : void 0,
217
- left: yAxisLabel ? 10 : void 0,
218
- right: yAxisLabel ? 5 : void 0
219
- },
220
- ...areaChartProps
221
- },
222
- referenceLinesItems,
223
- withLegend && /* @__PURE__ */ React__default.default.createElement(
224
- recharts.Legend,
225
- {
226
- verticalAlign: "top",
227
- content: (payload) => /* @__PURE__ */ React__default.default.createElement(
228
- ChartLegend.ChartLegend,
229
- {
230
- payload: payload.payload,
231
- onHighlight: setHighlightedArea,
232
- legendPosition: legendProps?.verticalAlign || "top",
233
- classNames: resolvedClassNames,
234
- styles: resolvedStyles,
235
- series
236
- }
237
- ),
238
- ...legendProps
239
- }
240
- ),
241
- /* @__PURE__ */ React__default.default.createElement(
242
- recharts.CartesianGrid,
243
- {
244
- strokeDasharray,
245
- vertical: gridAxis === "y" || gridAxis === "xy",
246
- horizontal: gridAxis === "x" || gridAxis === "xy",
247
- ...getStyles("grid"),
248
- ...gridProps
249
- }
250
- ),
251
- /* @__PURE__ */ React__default.default.createElement(
252
- recharts.XAxis,
253
- {
254
- hide: !withXAxis,
255
- ...orientation === "vertical" ? { type: "number" } : { dataKey },
256
- tick: { transform: "translate(0, 10)", fontSize: 12, fill: "currentColor" },
257
- stroke: "",
258
- interval: "preserveStartEnd",
259
- tickLine: withXTickLine ? { stroke: "currentColor" } : false,
260
- minTickGap: 5,
261
- ...getStyles("axis"),
262
- ...xAxisProps
263
- },
264
- xAxisLabel && /* @__PURE__ */ React__default.default.createElement(recharts.Label, { position: "insideBottom", offset: -20, fontSize: 12, ...getStyles("axisLabel") }, xAxisLabel),
265
- xAxisProps?.children
266
- ),
267
- /* @__PURE__ */ React__default.default.createElement(
268
- recharts.YAxis,
207
+ ...others,
208
+ children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { ...getStyles("container"), children: /* @__PURE__ */ jsxRuntime.jsxs(
209
+ recharts.AreaChart,
269
210
  {
270
- hide: !withYAxis,
271
- axisLine: false,
272
- ...orientation === "vertical" ? { dataKey, type: "category" } : { type: "number" },
273
- tickLine: withYTickLine ? { stroke: "currentColor" } : false,
274
- tick: { transform: "translate(-10, 0)", fontSize: 12, fill: "currentColor" },
275
- allowDecimals: true,
276
- unit,
277
- tickFormatter: type === "percent" ? valueToPercent : valueFormatter,
278
- ...getStyles("axis"),
279
- ...yAxisProps
280
- },
281
- yAxisLabel && /* @__PURE__ */ React__default.default.createElement(
282
- recharts.Label,
283
- {
284
- position: "insideLeft",
285
- angle: -90,
286
- textAnchor: "middle",
287
- fontSize: 12,
288
- offset: -5,
289
- ...getStyles("axisLabel")
211
+ data,
212
+ stackOffset: type === "percent" ? "expand" : void 0,
213
+ layout: orientation,
214
+ margin: {
215
+ bottom: xAxisLabel ? 30 : void 0,
216
+ left: yAxisLabel ? 10 : void 0,
217
+ right: yAxisLabel ? 5 : void 0
290
218
  },
291
- yAxisLabel
292
- ),
293
- yAxisProps?.children
294
- ),
295
- withTooltip && /* @__PURE__ */ React__default.default.createElement(
296
- recharts.Tooltip,
297
- {
298
- animationDuration: tooltipAnimationDuration,
299
- isAnimationActive,
300
- position: { y: 0 },
301
- cursor: {
302
- stroke: "var(--chart-grid-color)",
303
- strokeWidth: 1,
304
- strokeDasharray
305
- },
306
- content: ({ label, payload }) => /* @__PURE__ */ React__default.default.createElement(
307
- ChartTooltip.ChartTooltip,
308
- {
309
- label,
310
- payload,
311
- unit,
312
- classNames: resolvedClassNames,
313
- styles: resolvedStyles,
314
- series,
315
- valueFormatter
316
- }
317
- ),
318
- ...tooltipProps
319
- }
320
- ),
321
- type === "split" && /* @__PURE__ */ React__default.default.createElement("defs", null, /* @__PURE__ */ React__default.default.createElement(
322
- AreaSplit.AreaSplit,
323
- {
324
- colors: splitColors,
325
- id: splitId,
326
- offset: splitOffset ?? getSplitOffset.getDefaultSplitOffset({ data, series }),
327
- fillOpacity
219
+ ...areaChartProps,
220
+ children: [
221
+ referenceLinesItems,
222
+ withLegend && /* @__PURE__ */ jsxRuntime.jsx(
223
+ recharts.Legend,
224
+ {
225
+ verticalAlign: "top",
226
+ content: (payload) => /* @__PURE__ */ jsxRuntime.jsx(
227
+ ChartLegend.ChartLegend,
228
+ {
229
+ payload: payload.payload,
230
+ onHighlight: setHighlightedArea,
231
+ legendPosition: legendProps?.verticalAlign || "top",
232
+ classNames: resolvedClassNames,
233
+ styles: resolvedStyles,
234
+ series
235
+ }
236
+ ),
237
+ ...legendProps
238
+ }
239
+ ),
240
+ /* @__PURE__ */ jsxRuntime.jsx(
241
+ recharts.CartesianGrid,
242
+ {
243
+ strokeDasharray,
244
+ vertical: gridAxis === "y" || gridAxis === "xy",
245
+ horizontal: gridAxis === "x" || gridAxis === "xy",
246
+ ...getStyles("grid"),
247
+ ...gridProps
248
+ }
249
+ ),
250
+ /* @__PURE__ */ jsxRuntime.jsxs(
251
+ recharts.XAxis,
252
+ {
253
+ hide: !withXAxis,
254
+ ...orientation === "vertical" ? { type: "number" } : { dataKey },
255
+ tick: { transform: "translate(0, 10)", fontSize: 12, fill: "currentColor" },
256
+ stroke: "",
257
+ interval: "preserveStartEnd",
258
+ tickLine: withXTickLine ? { stroke: "currentColor" } : false,
259
+ minTickGap: 5,
260
+ ...getStyles("axis"),
261
+ ...xAxisProps,
262
+ children: [
263
+ xAxisLabel && /* @__PURE__ */ jsxRuntime.jsx(recharts.Label, { position: "insideBottom", offset: -20, fontSize: 12, ...getStyles("axisLabel"), children: xAxisLabel }),
264
+ xAxisProps?.children
265
+ ]
266
+ }
267
+ ),
268
+ /* @__PURE__ */ jsxRuntime.jsxs(
269
+ recharts.YAxis,
270
+ {
271
+ hide: !withYAxis,
272
+ axisLine: false,
273
+ ...orientation === "vertical" ? { dataKey, type: "category" } : { type: "number" },
274
+ tickLine: withYTickLine ? { stroke: "currentColor" } : false,
275
+ tick: { transform: "translate(-10, 0)", fontSize: 12, fill: "currentColor" },
276
+ allowDecimals: true,
277
+ unit,
278
+ tickFormatter: type === "percent" ? valueToPercent : valueFormatter,
279
+ ...getStyles("axis"),
280
+ ...yAxisProps,
281
+ children: [
282
+ yAxisLabel && /* @__PURE__ */ jsxRuntime.jsx(
283
+ recharts.Label,
284
+ {
285
+ position: "insideLeft",
286
+ angle: -90,
287
+ textAnchor: "middle",
288
+ fontSize: 12,
289
+ offset: -5,
290
+ ...getStyles("axisLabel"),
291
+ children: yAxisLabel
292
+ }
293
+ ),
294
+ yAxisProps?.children
295
+ ]
296
+ }
297
+ ),
298
+ withTooltip && /* @__PURE__ */ jsxRuntime.jsx(
299
+ recharts.Tooltip,
300
+ {
301
+ animationDuration: tooltipAnimationDuration,
302
+ isAnimationActive,
303
+ position: { y: 0 },
304
+ cursor: {
305
+ stroke: "var(--chart-grid-color)",
306
+ strokeWidth: 1,
307
+ strokeDasharray
308
+ },
309
+ content: ({ label, payload }) => /* @__PURE__ */ jsxRuntime.jsx(
310
+ ChartTooltip.ChartTooltip,
311
+ {
312
+ label,
313
+ payload,
314
+ unit,
315
+ classNames: resolvedClassNames,
316
+ styles: resolvedStyles,
317
+ series,
318
+ valueFormatter
319
+ }
320
+ ),
321
+ ...tooltipProps
322
+ }
323
+ ),
324
+ type === "split" && /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx(
325
+ AreaSplit.AreaSplit,
326
+ {
327
+ colors: splitColors,
328
+ id: splitId,
329
+ offset: splitOffset ?? getSplitOffset.getDefaultSplitOffset({ data, series }),
330
+ fillOpacity
331
+ }
332
+ ) }),
333
+ areas,
334
+ withDots && dotsAreas,
335
+ children
336
+ ]
328
337
  }
329
- )),
330
- areas,
331
- withDots && dotsAreas,
332
- children
333
- ))
338
+ ) })
339
+ }
334
340
  );
335
341
  });
336
342
  AreaChart.classes = gridChart_module;