@mantine/charts 7.8.1 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/AreaChart/AreaChart.cjs +171 -165
- package/cjs/AreaChart/AreaChart.cjs.map +1 -1
- package/cjs/AreaChart/AreaGradient.cjs +5 -6
- package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
- package/cjs/AreaChart/AreaSplit.cjs +19 -20
- package/cjs/AreaChart/AreaSplit.cjs.map +1 -1
- package/cjs/BarChart/BarChart.cjs +144 -126
- package/cjs/BarChart/BarChart.cjs.map +1 -1
- package/cjs/ChartLegend/ChartLegend.cjs +17 -19
- package/cjs/ChartLegend/ChartLegend.cjs.map +1 -1
- package/cjs/ChartTooltip/ChartTooltip.cjs +23 -15
- package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -1
- package/cjs/DonutChart/DonutChart.cjs +61 -60
- package/cjs/DonutChart/DonutChart.cjs.map +1 -1
- package/cjs/LineChart/LineChart.cjs +127 -124
- package/cjs/LineChart/LineChart.cjs.map +1 -1
- package/cjs/PieChart/PieChart.cjs +67 -67
- package/cjs/PieChart/PieChart.cjs.map +1 -1
- package/cjs/RadarChart/RadarChart.cjs +11 -9
- package/cjs/RadarChart/RadarChart.cjs.map +1 -1
- package/cjs/ScatterChart/ScatterChart.cjs +140 -137
- package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
- package/cjs/Sparkline/Sparkline.cjs +29 -29
- package/cjs/Sparkline/Sparkline.cjs.map +1 -1
- package/esm/AreaChart/AreaChart.mjs +169 -159
- package/esm/AreaChart/AreaChart.mjs.map +1 -1
- package/esm/AreaChart/AreaGradient.mjs +5 -2
- package/esm/AreaChart/AreaGradient.mjs.map +1 -1
- package/esm/AreaChart/AreaSplit.mjs +19 -16
- package/esm/AreaChart/AreaSplit.mjs.map +1 -1
- package/esm/BarChart/BarChart.mjs +143 -121
- package/esm/BarChart/BarChart.mjs.map +1 -1
- package/esm/ChartLegend/ChartLegend.mjs +17 -15
- package/esm/ChartLegend/ChartLegend.mjs.map +1 -1
- package/esm/ChartTooltip/ChartTooltip.mjs +23 -11
- package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -1
- package/esm/DonutChart/DonutChart.mjs +61 -56
- package/esm/DonutChart/DonutChart.mjs.map +1 -1
- package/esm/LineChart/LineChart.mjs +126 -119
- package/esm/LineChart/LineChart.mjs.map +1 -1
- package/esm/PieChart/PieChart.mjs +67 -63
- package/esm/PieChart/PieChart.mjs.map +1 -1
- package/esm/RadarChart/RadarChart.mjs +11 -5
- package/esm/RadarChart/RadarChart.mjs.map +1 -1
- package/esm/ScatterChart/ScatterChart.mjs +139 -132
- package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
- package/esm/Sparkline/Sparkline.mjs +27 -23
- package/esm/Sparkline/Sparkline.mjs.map +1 -1
- package/lib/AreaChart/AreaChart.d.ts +0 -1
- package/lib/AreaChart/AreaGradient.d.ts +1 -2
- package/lib/AreaChart/AreaSplit.d.ts +1 -2
- package/lib/BarChart/BarChart.d.ts +2 -1
- package/lib/ChartTooltip/ChartTooltip.d.ts +0 -1
- package/lib/DonutChart/DonutChart.d.ts +0 -1
- package/lib/LineChart/LineChart.d.ts +0 -1
- package/lib/PieChart/PieChart.d.ts +0 -1
- package/lib/RadarChart/RadarChart.d.ts +0 -1
- package/lib/ScatterChart/ScatterChart.d.ts +0 -1
- package/package.json +5 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
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 =
|
|
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] =
|
|
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__ */
|
|
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__ */
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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__ */
|
|
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__ */
|
|
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
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
-
|
|
331
|
-
withDots && dotsAreas,
|
|
332
|
-
children
|
|
333
|
-
))
|
|
338
|
+
) })
|
|
339
|
+
}
|
|
334
340
|
);
|
|
335
341
|
});
|
|
336
342
|
AreaChart.classes = gridChart_module;
|