@mantine/charts 9.4.2 → 9.5.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 +12 -3
- package/cjs/AreaChart/AreaChart.cjs.map +1 -1
- package/cjs/BarChart/BarChart.cjs +12 -3
- package/cjs/BarChart/BarChart.cjs.map +1 -1
- package/cjs/BubbleChart/BubbleChart.cjs +70 -66
- package/cjs/BubbleChart/BubbleChart.cjs.map +1 -1
- package/cjs/BulletChart/BulletChart.cjs +137 -0
- package/cjs/BulletChart/BulletChart.cjs.map +1 -0
- package/cjs/BulletChart/BulletChart.module.cjs +18 -0
- package/cjs/BulletChart/BulletChart.module.cjs.map +1 -0
- package/cjs/ChartBrush/ChartBrush.cjs +35 -0
- package/cjs/ChartBrush/ChartBrush.cjs.map +1 -0
- package/cjs/ChartBrush/ChartBrush.module.cjs +7 -0
- package/cjs/ChartBrush/ChartBrush.module.cjs.map +1 -0
- package/cjs/CompositeChart/CompositeChart.cjs +12 -3
- package/cjs/CompositeChart/CompositeChart.cjs.map +1 -1
- package/cjs/DonutChart/DonutChart.cjs +5 -3
- package/cjs/DonutChart/DonutChart.cjs.map +1 -1
- package/cjs/DonutChart/DonutChart.module.cjs.map +1 -1
- package/cjs/FunnelChart/FunnelChart.cjs +5 -3
- package/cjs/FunnelChart/FunnelChart.cjs.map +1 -1
- package/cjs/FunnelChart/FunnelChart.module.cjs.map +1 -1
- package/cjs/Heatmap/Heatmap.cjs +12 -5
- package/cjs/Heatmap/Heatmap.cjs.map +1 -1
- package/cjs/LineChart/LineChart.cjs +12 -3
- package/cjs/LineChart/LineChart.cjs.map +1 -1
- package/cjs/PieChart/PieChart.cjs +5 -3
- package/cjs/PieChart/PieChart.cjs.map +1 -1
- package/cjs/PieChart/PieChart.module.cjs.map +1 -1
- package/cjs/RadarChart/RadarChart.cjs +5 -3
- package/cjs/RadarChart/RadarChart.cjs.map +1 -1
- package/cjs/RadarChart/RadarChart.module.cjs.map +1 -1
- package/cjs/RadialBarChart/RadialBarChart.cjs +5 -3
- package/cjs/RadialBarChart/RadialBarChart.cjs.map +1 -1
- package/cjs/RadialBarChart/RadialBarChart.module.cjs.map +1 -1
- package/cjs/SankeyChart/SankeyChart.cjs +1 -1
- package/cjs/ScatterChart/ScatterChart.cjs +5 -3
- package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
- package/cjs/Sparkline/Sparkline.cjs +1 -1
- package/cjs/SunburstChart/SunburstChart.cjs +129 -0
- package/cjs/SunburstChart/SunburstChart.cjs.map +1 -0
- package/cjs/SunburstChart/SunburstChart.module.cjs +7 -0
- package/cjs/SunburstChart/SunburstChart.module.cjs.map +1 -0
- package/cjs/Treemap/Treemap.cjs +1 -1
- package/cjs/grid-chart.module.cjs.map +1 -1
- package/cjs/index.cjs +6 -0
- package/esm/AreaChart/AreaChart.mjs +12 -3
- package/esm/AreaChart/AreaChart.mjs.map +1 -1
- package/esm/BarChart/BarChart.mjs +12 -3
- package/esm/BarChart/BarChart.mjs.map +1 -1
- package/esm/BubbleChart/BubbleChart.mjs +70 -66
- package/esm/BubbleChart/BubbleChart.mjs.map +1 -1
- package/esm/BulletChart/BulletChart.mjs +137 -0
- package/esm/BulletChart/BulletChart.mjs.map +1 -0
- package/esm/BulletChart/BulletChart.module.mjs +18 -0
- package/esm/BulletChart/BulletChart.module.mjs.map +1 -0
- package/esm/ChartBrush/ChartBrush.mjs +35 -0
- package/esm/ChartBrush/ChartBrush.mjs.map +1 -0
- package/esm/ChartBrush/ChartBrush.module.mjs +7 -0
- package/esm/ChartBrush/ChartBrush.module.mjs.map +1 -0
- package/esm/CompositeChart/CompositeChart.mjs +12 -3
- package/esm/CompositeChart/CompositeChart.mjs.map +1 -1
- package/esm/DonutChart/DonutChart.mjs +5 -3
- package/esm/DonutChart/DonutChart.mjs.map +1 -1
- package/esm/DonutChart/DonutChart.module.mjs.map +1 -1
- package/esm/FunnelChart/FunnelChart.mjs +5 -3
- package/esm/FunnelChart/FunnelChart.mjs.map +1 -1
- package/esm/FunnelChart/FunnelChart.module.mjs.map +1 -1
- package/esm/Heatmap/Heatmap.mjs +12 -5
- package/esm/Heatmap/Heatmap.mjs.map +1 -1
- package/esm/LineChart/LineChart.mjs +12 -3
- package/esm/LineChart/LineChart.mjs.map +1 -1
- package/esm/PieChart/PieChart.mjs +5 -3
- package/esm/PieChart/PieChart.mjs.map +1 -1
- package/esm/PieChart/PieChart.module.mjs.map +1 -1
- package/esm/RadarChart/RadarChart.mjs +5 -3
- package/esm/RadarChart/RadarChart.mjs.map +1 -1
- package/esm/RadarChart/RadarChart.module.mjs.map +1 -1
- package/esm/RadialBarChart/RadialBarChart.mjs +5 -3
- package/esm/RadialBarChart/RadialBarChart.mjs.map +1 -1
- package/esm/RadialBarChart/RadialBarChart.module.mjs.map +1 -1
- package/esm/SankeyChart/SankeyChart.mjs +1 -1
- package/esm/ScatterChart/ScatterChart.mjs +5 -3
- package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
- package/esm/Sparkline/Sparkline.mjs +1 -1
- package/esm/SunburstChart/SunburstChart.mjs +129 -0
- package/esm/SunburstChart/SunburstChart.mjs.map +1 -0
- package/esm/SunburstChart/SunburstChart.module.mjs +7 -0
- package/esm/SunburstChart/SunburstChart.module.mjs.map +1 -0
- package/esm/Treemap/Treemap.mjs +1 -1
- package/esm/grid-chart.module.mjs.map +1 -1
- package/esm/index.mjs +4 -1
- package/lib/BubbleChart/BubbleChart.d.ts +2 -0
- package/lib/BulletChart/BulletChart.d.ts +58 -0
- package/lib/BulletChart/index.d.ts +9 -0
- package/lib/ChartBrush/ChartBrush.d.ts +15 -0
- package/lib/ChartBrush/index.d.ts +2 -0
- package/lib/DonutChart/DonutChart.d.ts +2 -0
- package/lib/FunnelChart/FunnelChart.d.ts +2 -0
- package/lib/Heatmap/Heatmap.d.ts +2 -0
- package/lib/PieChart/PieChart.d.ts +2 -0
- package/lib/RadarChart/RadarChart.d.ts +2 -0
- package/lib/RadialBarChart/RadialBarChart.d.ts +2 -0
- package/lib/ScatterChart/ScatterChart.d.ts +2 -2
- package/lib/SunburstChart/SunburstChart.d.ts +58 -0
- package/lib/SunburstChart/index.d.ts +10 -0
- package/lib/index.d.mts +3 -0
- package/lib/index.d.ts +3 -0
- package/lib/types.d.ts +8 -2
- package/package.json +3 -3
- package/styles.css +218 -2
- package/styles.layer.css +218 -2
|
@@ -4,8 +4,8 @@ import { ChartLegend } from "../ChartLegend/ChartLegend.mjs";
|
|
|
4
4
|
import grid_chart_module_default from "../grid-chart.module.mjs";
|
|
5
5
|
import { Box, createVarsResolver, factory, getThemeColor, useMantineTheme, useProps, useResolvedStylesApi, useStyles } from "@mantine/core";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useState } from "react";
|
|
8
7
|
import { CartesianGrid, Label, LabelList, Legend, ReferenceLine, ResponsiveContainer, Scatter, ScatterChart, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
|
|
8
|
+
import { useState } from "react";
|
|
9
9
|
//#region packages/@mantine/charts/src/ScatterChart/ScatterChart.tsx
|
|
10
10
|
function getAxis(key, dataKey) {
|
|
11
11
|
return key === dataKey.x ? "x" : "y";
|
|
@@ -17,7 +17,8 @@ const defaultProps = {
|
|
|
17
17
|
tooltipAnimationDuration: 0,
|
|
18
18
|
tickLine: "y",
|
|
19
19
|
strokeDasharray: "5 5",
|
|
20
|
-
gridAxis: "x"
|
|
20
|
+
gridAxis: "x",
|
|
21
|
+
accessibilityLayer: true
|
|
21
22
|
};
|
|
22
23
|
const varsResolver = createVarsResolver((theme, { textColor, gridColor }) => ({ root: {
|
|
23
24
|
"--chart-text-color": textColor ? getThemeColor(textColor, theme) : void 0,
|
|
@@ -25,7 +26,7 @@ const varsResolver = createVarsResolver((theme, { textColor, gridColor }) => ({
|
|
|
25
26
|
} }));
|
|
26
27
|
const ScatterChart$1 = factory((_props) => {
|
|
27
28
|
const props = useProps("ScatterChart", defaultProps, _props);
|
|
28
|
-
const { classNames, className, style, styles, unstyled, vars, referenceLines, dir, withLegend, withTooltip, withXAxis, withYAxis, xAxisProps, yAxisProps, orientation, scatterChartProps, legendProps, data, gridAxis, tickLine, strokeDasharray, gridProps, tooltipAnimationDuration, tooltipProps, children, onMouseLeave, dataKey, textColor, gridColor, xAxisLabel, yAxisLabel, unit, labels, valueFormatter, scatterProps, pointLabels, attributes, ...others } = props;
|
|
29
|
+
const { classNames, className, style, styles, unstyled, vars, referenceLines, dir, withLegend, withTooltip, withXAxis, withYAxis, xAxisProps, yAxisProps, orientation, scatterChartProps, legendProps, data, gridAxis, tickLine, strokeDasharray, gridProps, tooltipAnimationDuration, tooltipProps, children, onMouseLeave, dataKey, textColor, gridColor, xAxisLabel, yAxisLabel, unit, labels, valueFormatter, scatterProps, pointLabels, attributes, accessibilityLayer, ...others } = props;
|
|
29
30
|
const getFormatter = (axis) => typeof valueFormatter === "function" ? valueFormatter : valueFormatter?.[axis];
|
|
30
31
|
const xFormatter = getFormatter("x");
|
|
31
32
|
const yFormatter = getFormatter("y");
|
|
@@ -106,6 +107,7 @@ const ScatterChart$1 = factory((_props) => {
|
|
|
106
107
|
left: yAxisLabel ? 10 : void 0,
|
|
107
108
|
right: yAxisLabel ? 5 : void 0
|
|
108
109
|
},
|
|
110
|
+
accessibilityLayer,
|
|
109
111
|
...scatterChartProps,
|
|
110
112
|
children: [
|
|
111
113
|
/* @__PURE__ */ jsx(CartesianGrid, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScatterChart.mjs","names":["ScatterChart","ReChartsScatterChart","Tooltip","classes"],"sources":["../../src/ScatterChart/ScatterChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n LabelList,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ReferenceLine,\n ResponsiveContainer,\n Scatter,\n ScatterProps,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';\nimport { BaseChartStylesNames, GridChartBaseProps } from '../types';\nimport classes from '../grid-chart.module.css';\n\nexport interface ScatterChartSeries {\n color: MantineColor;\n name: string;\n data: Record<string, number>[];\n}\n\nexport type ScatterChartStylesNames =\n | 'scatter'\n | BaseChartStylesNames\n | ChartLegendStylesNames\n | ChartTooltipStylesNames;\n\nexport type ScatterChartCssVariables = {\n root: '--chart-text-color' | '--chart-grid-color';\n};\n\nexport interface ScatterChartProps\n extends\n Omit<GridChartBaseProps, 'dataKey' | 'data' | 'unit' | 'valueFormatter'>,\n BoxProps,\n StylesApiProps<ScatterChartFactory>,\n ElementProps<'div'> {\n /** Keys that should be used to retrieve data from the data array on x and y axis */\n dataKey: { x: string; y: string };\n\n /** Data that is used to build the chart */\n data: ScatterChartSeries[];\n\n /** Units displayed after value on axis and inside the tooltip */\n unit?: { x?: string; y?: string };\n\n /** Labels that should be used instead of keys names in the tooltip */\n labels?: { x?: string; y?: string };\n\n /** A function to format values on x/y axis and in the tooltip */\n valueFormatter?:\n | GridChartBaseProps['valueFormatter']\n | { x?: GridChartBaseProps['valueFormatter']; y?: GridChartBaseProps['valueFormatter'] };\n\n /** Props passed down to recharts `ScatterChart` component */\n scatterChartProps?: React.ComponentProps<typeof ReChartsScatterChart>;\n\n /** Props passed down to recharts `Scatter` component */\n scatterProps?: Partial<Omit<ScatterProps, 'ref'>>;\n\n /** If set, displays labels next to points for the given axis */\n pointLabels?: 'x' | 'y';\n}\n\nfunction getAxis(key: string, dataKey: { x: string; y: string }) {\n return key === dataKey.x ? 'x' : 'y';\n}\n\nexport type ScatterChartFactory = Factory<{\n props: ScatterChartProps;\n ref: HTMLDivElement;\n stylesNames: ScatterChartStylesNames;\n vars: ScatterChartCssVariables;\n}>;\n\nconst defaultProps = {\n withXAxis: true,\n withYAxis: true,\n withTooltip: true,\n tooltipAnimationDuration: 0,\n tickLine: 'y',\n strokeDasharray: '5 5',\n gridAxis: 'x',\n} satisfies Partial<ScatterChartProps>;\n\nconst varsResolver = createVarsResolver<ScatterChartFactory>((theme, { textColor, gridColor }) => ({\n root: {\n '--chart-text-color': textColor ? getThemeColor(textColor, theme) : undefined,\n '--chart-grid-color': gridColor ? getThemeColor(gridColor, theme) : undefined,\n },\n}));\n\nexport const ScatterChart = factory<ScatterChartFactory>((_props) => {\n const props = useProps('ScatterChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n referenceLines,\n dir,\n withLegend,\n withTooltip,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\n orientation,\n scatterChartProps,\n legendProps,\n data,\n gridAxis,\n tickLine,\n strokeDasharray,\n gridProps,\n tooltipAnimationDuration,\n tooltipProps,\n children,\n onMouseLeave,\n dataKey,\n textColor,\n gridColor,\n xAxisLabel,\n yAxisLabel,\n unit,\n labels,\n valueFormatter,\n scatterProps,\n pointLabels,\n attributes,\n ...others\n } = props;\n\n const getFormatter = (axis: 'x' | 'y') =>\n typeof valueFormatter === 'function' ? valueFormatter : valueFormatter?.[axis];\n const xFormatter = getFormatter('x');\n const yFormatter = getFormatter('y');\n\n const theme = useMantineTheme();\n\n const mappedData = data.map((item) => ({\n ...item,\n data: item.data.map((point) => ({ ...point, name: item.name })),\n }));\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ScatterChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const getStyles = useStyles<ScatterChartFactory>({\n name: 'ScatterChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const withXTickLine = gridAxis !== 'none' && (tickLine === 'x' || tickLine === 'xy');\n const withYTickLine = gridAxis !== 'none' && (tickLine === 'y' || tickLine === 'xy');\n const [highlightedArea, setHighlightedArea] = useState<string | number | null>(null);\n const shouldHighlight = highlightedArea !== null;\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n setHighlightedArea(null);\n onMouseLeave?.(event);\n };\n\n const referenceLinesItems = referenceLines?.map((line, index) => {\n const color = getThemeColor(line.color, theme);\n return (\n <ReferenceLine\n key={index}\n stroke={line.color ? color : 'var(--chart-grid-color)'}\n strokeWidth={1}\n {...line}\n label={{\n fill: line.color ? color : 'currentColor',\n fontSize: 12,\n position: line.labelPosition ?? 'insideBottomLeft',\n ...(typeof line.label === 'object' ? line.label : { value: line.label }),\n }}\n {...getStyles('referenceLine')}\n />\n );\n });\n\n const scatters = mappedData.map((item, index) => {\n const dimmed = shouldHighlight && highlightedArea !== item.name;\n return (\n <Scatter\n data={item.data}\n fill={getThemeColor(item.color, theme)}\n key={index}\n isAnimationActive={false}\n fillOpacity={dimmed ? 0.1 : 1}\n {...scatterProps}\n >\n {pointLabels && <LabelList dataKey={dataKey[pointLabels]} fontSize={8} dy={10} />}\n {scatterProps?.children}\n </Scatter>\n );\n });\n\n return (\n <Box {...getStyles('root')} onMouseLeave={handleMouseLeave} dir={dir || 'ltr'} {...others}>\n <ResponsiveContainer {...getStyles('container')}>\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel ? 5 : undefined,\n }}\n {...scatterChartProps}\n >\n <CartesianGrid\n strokeDasharray={strokeDasharray as string}\n vertical={gridAxis === 'y' || gridAxis === 'xy'}\n horizontal={gridAxis === 'x' || gridAxis === 'xy'}\n {...getStyles('grid')}\n {...gridProps}\n />\n <XAxis\n type=\"number\"\n hide={!withXAxis}\n dataKey={dataKey.x}\n tick={{ transform: 'translate(0, 10)', fontSize: 12, fill: 'currentColor' }}\n stroke=\"\"\n interval=\"preserveStartEnd\"\n tickLine={withXTickLine ? { stroke: 'currentColor' } : false}\n minTickGap={5}\n unit={unit?.x}\n tickFormatter={xFormatter}\n {...getStyles('axis')}\n {...xAxisProps}\n >\n {xAxisLabel && (\n <Label position=\"insideBottom\" offset={-20} fontSize={12} {...getStyles('axisLabel')}>\n {xAxisLabel}\n </Label>\n )}\n {xAxisProps?.children}\n </XAxis>\n <YAxis\n type=\"number\"\n hide={!withYAxis}\n axisLine={false}\n dataKey={dataKey.y}\n tickLine={withYTickLine ? { stroke: 'currentColor' } : false}\n tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}\n allowDecimals\n unit={unit?.y}\n tickFormatter={yFormatter}\n {...getStyles('axis')}\n {...yAxisProps}\n >\n {yAxisLabel && (\n <Label\n position=\"insideLeft\"\n angle={-90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {yAxisLabel}\n </Label>\n )}\n {yAxisProps?.children}\n </YAxis>\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={tooltipAnimationDuration !== 0}\n position={{ y: 0 }}\n cursor={{\n stroke: 'var(--chart-grid-color)',\n strokeWidth: 1,\n strokeDasharray,\n }}\n content={({ label, payload, labelFormatter }) => (\n <ChartTooltip\n type=\"scatter\"\n label={labelFormatter && payload ? labelFormatter(label, payload) : label}\n payload={\n labels\n ? payload?.map((item) => ({\n ...item,\n name: labels[getAxis(item.name as string, dataKey)] || item.name,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n : payload?.map((item) => ({\n ...item,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {withLegend && (\n <Legend\n verticalAlign=\"top\"\n content={(payload) => (\n <ChartLegend\n payload={payload.payload?.map((item, index) => ({\n ...item,\n dataKey: data[index].name,\n }))}\n onHighlight={setHighlightedArea}\n legendPosition={legendProps?.verticalAlign || 'top'}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n height={44}\n {...legendProps}\n />\n )}\n\n {referenceLinesItems}\n {scatters}\n </ReChartsScatterChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nScatterChart.displayName = '@mantine/charts/ScatterChart';\nScatterChart.classes = classes;\nScatterChart.varsResolver = varsResolver;\n\nexport namespace ScatterChart {\n export type Props = ScatterChartProps;\n export type StylesNames = ScatterChartStylesNames;\n export type CssVariables = ScatterChartCssVariables;\n export type Factory = ScatterChartFactory;\n export type Series = ScatterChartSeries;\n}\n"],"mappings":";;;;;;;;;AAoFA,SAAS,QAAQ,KAAa,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,IAAI,MAAM;AACnC;AASA,MAAM,eAAe;CACnB,WAAW;CACX,WAAW;CACX,aAAa;CACb,0BAA0B;CAC1B,UAAU;CACV,iBAAiB;CACjB,UAAU;AACZ;AAEA,MAAM,eAAe,oBAAyC,OAAO,EAAE,WAAW,iBAAiB,EACjG,MAAM;CACJ,sBAAsB,YAAY,cAAc,WAAW,KAAK,IAAI,KAAA;CACpE,sBAAsB,YAAY,cAAc,WAAW,KAAK,IAAI,KAAA;AACtE,EACF,EAAE;AAEF,MAAaA,iBAAe,SAA8B,WAAW;CACnE,MAAM,QAAQ,SAAS,gBAAgB,cAAc,MAAM;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,gBACA,KACA,YACA,aACA,WACA,WACA,YACA,YACA,aACA,mBACA,aACA,MACA,UACA,UACA,iBACA,WACA,0BACA,cACA,UACA,cACA,SACA,WACA,WACA,YACA,YACA,MACA,QACA,gBACA,cACA,aACA,YACA,GAAG,WACD;CAEJ,MAAM,gBAAgB,SACpB,OAAO,mBAAmB,aAAa,iBAAiB,iBAAiB;CAC3E,MAAM,aAAa,aAA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OACT,OAAO;OACP,YAAW;OACX,UAAU;OACV,QAAQ;OACR,GAAI,UAAU,WAAW;iBAExB;MACI,CAAA,GAER,YAAY,QACR;;KAEN,eACC,oBAACC,WAAD;MACE,mBAAmB;MACnB,mBAAmB,6BAA6B;MAChD,UAAU,EAAE,GAAG,EAAE;MACjB,QAAQ;OACN,QAAQ;OACR,aAAa;OACb;MACF;MACA,UAAU,EAAE,OAAO,SAAS,qBAC1B,oBAAC,cAAD;OACE,MAAK;OACL,OAAO,kBAAkB,UAAU,eAAe,OAAO,OAAO,IAAI;OACpE,SACE,SACI,SAAS,KAAK,UAAU;QACtB,GAAG;QACH,MAAM,OAAO,QAAQ,KAAK,MAAgB,OAAO,MAAM,KAAK;QAC5D,OACE,aAAa,QAAQ,KAAK,MAAgB,OAAO,CAAC,CAAC,GACjD,KAAK,KACP,KAAK,KAAK;OACd,EAAE,IACF,SAAS,KAAK,UAAU;QACtB,GAAG;QACH,OACE,aAAa,QAAQ,KAAK,MAAgB,OAAO,CAAC,CAAC,GACjD,KAAK,KACP,KAAK,KAAK;OACd,EAAE;OAER,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,GAAI;KACL,CAAA;KAGF,cACC,oBAAC,QAAD;MACE,eAAc;MACd,UAAU,YACR,oBAAC,aAAD;OACE,SAAS,QAAQ,SAAS,KAAK,MAAM,WAAW;QAC9C,GAAG;QACH,SAAS,KAAK,MAAM,CAAC;OACvB,EAAE;OACF,aAAa;OACb,gBAAgB,aAAa,iBAAiB;OAC9C,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,QAAQ;MACR,GAAI;KACL,CAAA;KAGF;KACA;IACmB;;EACH,CAAA;CAClB,CAAA;AAET,CAAC;AAED,eAAa,cAAc;AAC3B,eAAa,UAAUC;AACvB,eAAa,eAAe"}
|
|
1
|
+
{"version":3,"file":"ScatterChart.mjs","names":["ScatterChart","ReChartsScatterChart","Tooltip","classes"],"sources":["../../src/ScatterChart/ScatterChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n LabelList,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ReferenceLine,\n ResponsiveContainer,\n Scatter,\n ScatterProps,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';\nimport { BaseChartStylesNames, GridChartBaseProps } from '../types';\nimport classes from '../grid-chart.module.css';\n\nexport interface ScatterChartSeries {\n color: MantineColor;\n name: string;\n data: Record<string, number>[];\n}\n\nexport type ScatterChartStylesNames =\n | 'scatter'\n | Exclude<BaseChartStylesNames, 'brush'>\n | ChartLegendStylesNames\n | ChartTooltipStylesNames;\n\nexport type ScatterChartCssVariables = {\n root: '--chart-text-color' | '--chart-grid-color';\n};\n\nexport interface ScatterChartProps\n extends\n Omit<\n GridChartBaseProps,\n 'dataKey' | 'data' | 'unit' | 'valueFormatter' | 'withBrush' | 'brushProps'\n >,\n BoxProps,\n StylesApiProps<ScatterChartFactory>,\n ElementProps<'div'> {\n /** Keys that should be used to retrieve data from the data array on x and y axis */\n dataKey: { x: string; y: string };\n\n /** Data that is used to build the chart */\n data: ScatterChartSeries[];\n\n /** Units displayed after value on axis and inside the tooltip */\n unit?: { x?: string; y?: string };\n\n /** Labels that should be used instead of keys names in the tooltip */\n labels?: { x?: string; y?: string };\n\n /** A function to format values on x/y axis and in the tooltip */\n valueFormatter?:\n | GridChartBaseProps['valueFormatter']\n | { x?: GridChartBaseProps['valueFormatter']; y?: GridChartBaseProps['valueFormatter'] };\n\n /** Props passed down to recharts `ScatterChart` component */\n scatterChartProps?: React.ComponentProps<typeof ReChartsScatterChart>;\n\n /** Props passed down to recharts `Scatter` component */\n scatterProps?: Partial<Omit<ScatterProps, 'ref'>>;\n\n /** If set, displays labels next to points for the given axis */\n pointLabels?: 'x' | 'y';\n}\n\nfunction getAxis(key: string, dataKey: { x: string; y: string }) {\n return key === dataKey.x ? 'x' : 'y';\n}\n\nexport type ScatterChartFactory = Factory<{\n props: ScatterChartProps;\n ref: HTMLDivElement;\n stylesNames: ScatterChartStylesNames;\n vars: ScatterChartCssVariables;\n}>;\n\nconst defaultProps = {\n withXAxis: true,\n withYAxis: true,\n withTooltip: true,\n tooltipAnimationDuration: 0,\n tickLine: 'y',\n strokeDasharray: '5 5',\n gridAxis: 'x',\n accessibilityLayer: true,\n} satisfies Partial<ScatterChartProps>;\n\nconst varsResolver = createVarsResolver<ScatterChartFactory>((theme, { textColor, gridColor }) => ({\n root: {\n '--chart-text-color': textColor ? getThemeColor(textColor, theme) : undefined,\n '--chart-grid-color': gridColor ? getThemeColor(gridColor, theme) : undefined,\n },\n}));\n\nexport const ScatterChart = factory<ScatterChartFactory>((_props) => {\n const props = useProps('ScatterChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n referenceLines,\n dir,\n withLegend,\n withTooltip,\n withXAxis,\n withYAxis,\n xAxisProps,\n yAxisProps,\n orientation,\n scatterChartProps,\n legendProps,\n data,\n gridAxis,\n tickLine,\n strokeDasharray,\n gridProps,\n tooltipAnimationDuration,\n tooltipProps,\n children,\n onMouseLeave,\n dataKey,\n textColor,\n gridColor,\n xAxisLabel,\n yAxisLabel,\n unit,\n labels,\n valueFormatter,\n scatterProps,\n pointLabels,\n attributes,\n accessibilityLayer,\n ...others\n } = props;\n\n const getFormatter = (axis: 'x' | 'y') =>\n typeof valueFormatter === 'function' ? valueFormatter : valueFormatter?.[axis];\n const xFormatter = getFormatter('x');\n const yFormatter = getFormatter('y');\n\n const theme = useMantineTheme();\n\n const mappedData = data.map((item) => ({\n ...item,\n data: item.data.map((point) => ({ ...point, name: item.name })),\n }));\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ScatterChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const getStyles = useStyles<ScatterChartFactory>({\n name: 'ScatterChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const withXTickLine = gridAxis !== 'none' && (tickLine === 'x' || tickLine === 'xy');\n const withYTickLine = gridAxis !== 'none' && (tickLine === 'y' || tickLine === 'xy');\n const [highlightedArea, setHighlightedArea] = useState<string | number | null>(null);\n const shouldHighlight = highlightedArea !== null;\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n setHighlightedArea(null);\n onMouseLeave?.(event);\n };\n\n const referenceLinesItems = referenceLines?.map((line, index) => {\n const color = getThemeColor(line.color, theme);\n return (\n <ReferenceLine\n key={index}\n stroke={line.color ? color : 'var(--chart-grid-color)'}\n strokeWidth={1}\n {...line}\n label={{\n fill: line.color ? color : 'currentColor',\n fontSize: 12,\n position: line.labelPosition ?? 'insideBottomLeft',\n ...(typeof line.label === 'object' ? line.label : { value: line.label }),\n }}\n {...getStyles('referenceLine')}\n />\n );\n });\n\n const scatters = mappedData.map((item, index) => {\n const dimmed = shouldHighlight && highlightedArea !== item.name;\n return (\n <Scatter\n data={item.data}\n fill={getThemeColor(item.color, theme)}\n key={index}\n isAnimationActive={false}\n fillOpacity={dimmed ? 0.1 : 1}\n {...scatterProps}\n >\n {pointLabels && <LabelList dataKey={dataKey[pointLabels]} fontSize={8} dy={10} />}\n {scatterProps?.children}\n </Scatter>\n );\n });\n\n return (\n <Box {...getStyles('root')} onMouseLeave={handleMouseLeave} dir={dir || 'ltr'} {...others}>\n <ResponsiveContainer {...getStyles('container')}>\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel ? 5 : undefined,\n }}\n accessibilityLayer={accessibilityLayer}\n {...scatterChartProps}\n >\n <CartesianGrid\n strokeDasharray={strokeDasharray as string}\n vertical={gridAxis === 'y' || gridAxis === 'xy'}\n horizontal={gridAxis === 'x' || gridAxis === 'xy'}\n {...getStyles('grid')}\n {...gridProps}\n />\n <XAxis\n type=\"number\"\n hide={!withXAxis}\n dataKey={dataKey.x}\n tick={{ transform: 'translate(0, 10)', fontSize: 12, fill: 'currentColor' }}\n stroke=\"\"\n interval=\"preserveStartEnd\"\n tickLine={withXTickLine ? { stroke: 'currentColor' } : false}\n minTickGap={5}\n unit={unit?.x}\n tickFormatter={xFormatter}\n {...getStyles('axis')}\n {...xAxisProps}\n >\n {xAxisLabel && (\n <Label position=\"insideBottom\" offset={-20} fontSize={12} {...getStyles('axisLabel')}>\n {xAxisLabel}\n </Label>\n )}\n {xAxisProps?.children}\n </XAxis>\n <YAxis\n type=\"number\"\n hide={!withYAxis}\n axisLine={false}\n dataKey={dataKey.y}\n tickLine={withYTickLine ? { stroke: 'currentColor' } : false}\n tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}\n allowDecimals\n unit={unit?.y}\n tickFormatter={yFormatter}\n {...getStyles('axis')}\n {...yAxisProps}\n >\n {yAxisLabel && (\n <Label\n position=\"insideLeft\"\n angle={-90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {yAxisLabel}\n </Label>\n )}\n {yAxisProps?.children}\n </YAxis>\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={tooltipAnimationDuration !== 0}\n position={{ y: 0 }}\n cursor={{\n stroke: 'var(--chart-grid-color)',\n strokeWidth: 1,\n strokeDasharray,\n }}\n content={({ label, payload, labelFormatter }) => (\n <ChartTooltip\n type=\"scatter\"\n label={labelFormatter && payload ? labelFormatter(label, payload) : label}\n payload={\n labels\n ? payload?.map((item) => ({\n ...item,\n name: labels[getAxis(item.name as string, dataKey)] || item.name,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n : payload?.map((item) => ({\n ...item,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {withLegend && (\n <Legend\n verticalAlign=\"top\"\n content={(payload) => (\n <ChartLegend\n payload={payload.payload?.map((item, index) => ({\n ...item,\n dataKey: data[index].name,\n }))}\n onHighlight={setHighlightedArea}\n legendPosition={legendProps?.verticalAlign || 'top'}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n height={44}\n {...legendProps}\n />\n )}\n\n {referenceLinesItems}\n {scatters}\n </ReChartsScatterChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nScatterChart.displayName = '@mantine/charts/ScatterChart';\nScatterChart.classes = classes;\nScatterChart.varsResolver = varsResolver;\n\nexport namespace ScatterChart {\n export type Props = ScatterChartProps;\n export type StylesNames = ScatterChartStylesNames;\n export type CssVariables = ScatterChartCssVariables;\n export type Factory = ScatterChartFactory;\n export type Series = ScatterChartSeries;\n}\n"],"mappings":";;;;;;;;;AAuFA,SAAS,QAAQ,KAAa,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,IAAI,MAAM;AACnC;AASA,MAAM,eAAe;CACnB,WAAW;CACX,WAAW;CACX,aAAa;CACb,0BAA0B;CAC1B,UAAU;CACV,iBAAiB;CACjB,UAAU;CACV,oBAAoB;AACtB;AAEA,MAAM,eAAe,oBAAyC,OAAO,EAAE,WAAW,iBAAiB,EACjG,MAAM;CACJ,sBAAsB,YAAY,cAAc,WAAW,KAAK,IAAI,KAAA;CACpE,sBAAsB,YAAY,cAAc,WAAW,KAAK,IAAI,KAAA;AACtE,EACF,EAAE;AAEF,MAAaA,iBAAe,SAA8B,WAAW;CACnE,MAAM,QAAQ,SAAS,gBAAgB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EAAE;OACF,aAAa;OACb,gBAAgB,aAAa,iBAAiB;OAC9C,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,QAAQ;MACR,GAAI;KACL,CAAA;KAGF;KACA;IACmB;;EACH,CAAA;CAClB,CAAA;AAET,CAAC;AAED,eAAa,cAAc;AAC3B,eAAa,UAAUC;AACvB,eAAa,eAAe"}
|
|
@@ -3,8 +3,8 @@ import { AreaGradient } from "../AreaChart/AreaGradient.mjs";
|
|
|
3
3
|
import Sparkline_module_default from "./Sparkline.module.mjs";
|
|
4
4
|
import { Box, createVarsResolver, factory, getThemeColor, useProps, useStyles } from "@mantine/core";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useId, useMemo } from "react";
|
|
7
6
|
import { Area, AreaChart, ResponsiveContainer } from "recharts";
|
|
7
|
+
import { useId, useMemo } from "react";
|
|
8
8
|
//#region packages/@mantine/charts/src/Sparkline/Sparkline.tsx
|
|
9
9
|
const defaultProps = {
|
|
10
10
|
withGradient: true,
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ChartTooltip } from "../ChartTooltip/ChartTooltip.mjs";
|
|
3
|
+
import SunburstChart_module_default from "./SunburstChart.module.mjs";
|
|
4
|
+
import { Box, createVarsResolver, factory, getThemeColor, parseThemeColor, rem, useMantineTheme, useProps, useResolvedStylesApi, useStyles } from "@mantine/core";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { ResponsiveContainer, SunburstChart, Tooltip as Tooltip$1 } from "recharts";
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
//#region packages/@mantine/charts/src/SunburstChart/SunburstChart.tsx
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
dataKey: "value",
|
|
11
|
+
withTooltip: true,
|
|
12
|
+
tooltipAnimationDuration: 0,
|
|
13
|
+
size: 300,
|
|
14
|
+
innerRadius: 50,
|
|
15
|
+
gap: 1,
|
|
16
|
+
startAngle: 0,
|
|
17
|
+
endAngle: 360
|
|
18
|
+
};
|
|
19
|
+
const varsResolver = createVarsResolver((theme, { strokeColor, size }) => ({ root: {
|
|
20
|
+
"--chart-stroke-color": strokeColor ? getThemeColor(strokeColor, theme) : void 0,
|
|
21
|
+
"--chart-size": rem(size)
|
|
22
|
+
} }));
|
|
23
|
+
function resolveData(data, theme, dataKey, parentFill) {
|
|
24
|
+
let total = 0;
|
|
25
|
+
return {
|
|
26
|
+
resolved: data.map((item) => {
|
|
27
|
+
const fill = (item.color ? parseThemeColor({
|
|
28
|
+
color: item.color,
|
|
29
|
+
theme
|
|
30
|
+
}).value : parentFill) || void 0;
|
|
31
|
+
const result = {
|
|
32
|
+
...item,
|
|
33
|
+
fill
|
|
34
|
+
};
|
|
35
|
+
if (item.children) {
|
|
36
|
+
const child = resolveData(item.children, theme, dataKey, fill);
|
|
37
|
+
result.children = child.resolved;
|
|
38
|
+
if (result[dataKey] == null) result[dataKey] = child.total;
|
|
39
|
+
total += child.total;
|
|
40
|
+
} else total += Number(item[dataKey]) || 0;
|
|
41
|
+
return result;
|
|
42
|
+
}),
|
|
43
|
+
total
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const SunburstChart$1 = factory((_props) => {
|
|
47
|
+
const props = useProps("SunburstChart", defaultProps, _props);
|
|
48
|
+
const { classNames, className, style, styles, unstyled, vars, data, dataKey, withTooltip, tooltipAnimationDuration, tooltipProps, sunburstChartProps, strokeColor, size, innerRadius, gap, startAngle, endAngle, withLabels, valueFormatter, children, attributes, ...others } = props;
|
|
49
|
+
const theme = useMantineTheme();
|
|
50
|
+
const getStyles = useStyles({
|
|
51
|
+
name: "SunburstChart",
|
|
52
|
+
classes: SunburstChart_module_default,
|
|
53
|
+
props,
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
classNames,
|
|
57
|
+
styles,
|
|
58
|
+
unstyled,
|
|
59
|
+
attributes,
|
|
60
|
+
vars,
|
|
61
|
+
varsResolver
|
|
62
|
+
});
|
|
63
|
+
const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
|
|
64
|
+
classNames,
|
|
65
|
+
styles,
|
|
66
|
+
props
|
|
67
|
+
});
|
|
68
|
+
const rootData = useMemo(() => {
|
|
69
|
+
const { resolved, total } = resolveData(data, theme, dataKey);
|
|
70
|
+
return {
|
|
71
|
+
name: "root",
|
|
72
|
+
[dataKey]: total,
|
|
73
|
+
children: resolved
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
data,
|
|
77
|
+
theme,
|
|
78
|
+
dataKey
|
|
79
|
+
]);
|
|
80
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
81
|
+
size,
|
|
82
|
+
...getStyles("root"),
|
|
83
|
+
...others,
|
|
84
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(SunburstChart, {
|
|
85
|
+
data: rootData,
|
|
86
|
+
dataKey,
|
|
87
|
+
innerRadius,
|
|
88
|
+
padding: gap,
|
|
89
|
+
ringPadding: 0,
|
|
90
|
+
startAngle,
|
|
91
|
+
endAngle,
|
|
92
|
+
stroke: "var(--chart-stroke-color, var(--mantine-color-body))",
|
|
93
|
+
textOptions: withLabels ? {
|
|
94
|
+
fontWeight: "bold",
|
|
95
|
+
fontSize: ".65rem",
|
|
96
|
+
paintOrder: "stroke fill",
|
|
97
|
+
stroke: "var(--chart-stroke-color, var(--mantine-color-body))",
|
|
98
|
+
strokeWidth: 1,
|
|
99
|
+
fill: "var(--mantine-color-bright)",
|
|
100
|
+
pointerEvents: "none"
|
|
101
|
+
} : { display: "none" },
|
|
102
|
+
...sunburstChartProps,
|
|
103
|
+
children: [withTooltip && /* @__PURE__ */ jsx(Tooltip$1, {
|
|
104
|
+
animationDuration: tooltipAnimationDuration,
|
|
105
|
+
isAnimationActive: false,
|
|
106
|
+
content: ({ payload }) => /* @__PURE__ */ jsx(ChartTooltip, {
|
|
107
|
+
payload: payload?.map((item) => ({
|
|
108
|
+
name: item.name,
|
|
109
|
+
value: item.value,
|
|
110
|
+
color: item.payload?.fill || "var(--mantine-color-blue-6)"
|
|
111
|
+
})) || [],
|
|
112
|
+
classNames: resolvedClassNames,
|
|
113
|
+
styles: resolvedStyles,
|
|
114
|
+
type: "radial",
|
|
115
|
+
valueFormatter,
|
|
116
|
+
attributes
|
|
117
|
+
}),
|
|
118
|
+
...tooltipProps
|
|
119
|
+
}), children]
|
|
120
|
+
}) })
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
SunburstChart$1.displayName = "@mantine/charts/SunburstChart";
|
|
124
|
+
SunburstChart$1.classes = SunburstChart_module_default;
|
|
125
|
+
SunburstChart$1.varsResolver = varsResolver;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { SunburstChart$1 as SunburstChart };
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=SunburstChart.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SunburstChart.mjs","names":["SunburstChart","RechartsSunburstChart","Tooltip","classes"],"sources":["../../src/SunburstChart/SunburstChart.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n ResponsiveContainer,\n SunburstChart as RechartsSunburstChart,\n SunburstChartProps as RechartsSunburstChartProps,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n MantineTheme,\n parseThemeColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './SunburstChart.module.css';\n\nexport interface SunburstChartData {\n name: string;\n value?: number;\n color?: MantineColor;\n children?: SunburstChartData[];\n [key: string]: unknown;\n}\n\nexport type SunburstChartStylesNames = 'root' | ChartTooltipStylesNames;\nexport type SunburstChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-size';\n};\n\nexport interface SunburstChartProps\n extends BoxProps, StylesApiProps<SunburstChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: SunburstChartData[];\n\n /** Key in data object for the value @default 'value' */\n dataKey?: string;\n\n /** Determines whether the tooltip should be displayed when a node is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `SunburstChart` component */\n sunburstChartProps?: Partial<Omit<RechartsSunburstChartProps, 'ref' | 'data' | 'dataKey'>>;\n\n /** Controls color of the sectors stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls chart width and height @default 300 */\n size?: number;\n\n /** Controls the radius of the inner circle at the center of the chart @default 50 */\n innerRadius?: number;\n\n /** Gap between sectors and rings in px @default 1 */\n gap?: number;\n\n /** Angle in degrees from which the chart should start @default 0 */\n startAngle?: number;\n\n /** Angle in degrees at which the chart should end @default 360 */\n endAngle?: number;\n\n /** Determines whether value labels are displayed inside each sector @default false */\n withLabels?: boolean;\n\n /** A function to format values inside the tooltip and labels */\n valueFormatter?: (value: number) => string;\n\n /** Additional elements rendered inside `SunburstChart` component */\n children?: React.ReactNode;\n}\n\nexport type SunburstChartFactory = Factory<{\n props: SunburstChartProps;\n ref: HTMLDivElement;\n stylesNames: SunburstChartStylesNames;\n vars: SunburstChartCssVariables;\n}>;\n\nconst defaultProps = {\n dataKey: 'value',\n withTooltip: true,\n tooltipAnimationDuration: 0,\n size: 300,\n innerRadius: 50,\n gap: 1,\n startAngle: 0,\n endAngle: 360,\n} satisfies Partial<SunburstChartProps>;\n\nconst varsResolver = createVarsResolver<SunburstChartFactory>((theme, { strokeColor, size }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-size': rem(size),\n },\n}));\n\nfunction resolveData(\n data: SunburstChartData[],\n theme: MantineTheme,\n dataKey: string,\n parentFill?: string\n): { resolved: any[]; total: number } {\n let total = 0;\n\n const resolved = data.map((item) => {\n const resolvedColor = item.color\n ? parseThemeColor({ color: item.color, theme }).value\n : parentFill;\n const fill = resolvedColor || undefined;\n\n const result: any = {\n ...item,\n fill,\n };\n\n if (item.children) {\n const child = resolveData(item.children, theme, dataKey, fill);\n result.children = child.resolved;\n if (result[dataKey] == null) {\n result[dataKey] = child.total;\n }\n total += child.total;\n } else {\n total += Number(item[dataKey]) || 0;\n }\n\n return result;\n });\n\n return { resolved, total };\n}\n\nexport const SunburstChart = factory<SunburstChartFactory>((_props) => {\n const props = useProps('SunburstChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n dataKey,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n sunburstChartProps,\n strokeColor,\n size,\n innerRadius,\n gap,\n startAngle,\n endAngle,\n withLabels,\n valueFormatter,\n children,\n attributes,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<SunburstChartFactory>({\n name: 'SunburstChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<SunburstChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const rootData = useMemo(() => {\n const { resolved, total } = resolveData(data, theme, dataKey!);\n return {\n name: 'root',\n [dataKey!]: total,\n children: resolved,\n };\n }, [data, theme, dataKey]);\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <RechartsSunburstChart\n data={rootData as any}\n dataKey={dataKey as any}\n innerRadius={innerRadius}\n padding={gap}\n ringPadding={0}\n startAngle={startAngle}\n endAngle={endAngle}\n stroke=\"var(--chart-stroke-color, var(--mantine-color-body))\"\n textOptions={\n withLabels\n ? {\n fontWeight: 'bold',\n fontSize: '.65rem',\n paintOrder: 'stroke fill',\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth: 1,\n fill: 'var(--mantine-color-bright)',\n pointerEvents: 'none',\n }\n : { display: 'none' }\n }\n {...sunburstChartProps}\n >\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={\n payload?.map((item) => ({\n name: item.name as string,\n value: item.value as number,\n color: (item.payload as any)?.fill || 'var(--mantine-color-blue-6)',\n })) || []\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </RechartsSunburstChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSunburstChart.displayName = '@mantine/charts/SunburstChart';\nSunburstChart.classes = classes;\nSunburstChart.varsResolver = varsResolver;\n"],"mappings":";;;;;;;;AAiGA,MAAM,eAAe;CACnB,SAAS;CACT,aAAa;CACb,0BAA0B;CAC1B,MAAM;CACN,aAAa;CACb,KAAK;CACL,YAAY;CACZ,UAAU;AACZ;AAEA,MAAM,eAAe,oBAA0C,OAAO,EAAE,aAAa,YAAY,EAC/F,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,gBAAgB,IAAI,IAAI;AAC1B,EACF,EAAE;AAEF,SAAS,YACP,MACA,OACA,SACA,YACoC;CACpC,IAAI,QAAQ;CA2BZ,OAAO;EAAE,UAzBQ,KAAK,KAAK,SAAS;GAIlC,MAAM,QAHgB,KAAK,QACvB,gBAAgB;IAAE,OAAO,KAAK;IAAO;GAAM,CAAC,CAAC,CAAC,QAC9C,eAC0B,KAAA;GAE9B,MAAM,SAAc;IAClB,GAAG;IACH;GACF;GAEA,IAAI,KAAK,UAAU;IACjB,MAAM,QAAQ,YAAY,KAAK,UAAU,OAAO,SAAS,IAAI;IAC7D,OAAO,W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,OAAQ,KAAK,SAAiB,QAAQ;KACxC,EAAE,KAAK,CAAC;KAEV,YAAY;KACZ,QAAQ;KACR,MAAK;KACW;KACJ;IACb,CAAA;IAEH,GAAI;GACL,CAAA,GAGF,QACoB;KACJ,CAAA;CAClB,CAAA;AAET,CAAC;AAED,gBAAc,cAAc;AAC5B,gBAAc,UAAUC;AACxB,gBAAc,eAAe"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/charts/src/SunburstChart/SunburstChart.module.css
|
|
3
|
+
var SunburstChart_module_default = { "root": "m_a73eff05" };
|
|
4
|
+
//#endregion
|
|
5
|
+
export { SunburstChart_module_default as default };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=SunburstChart.module.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SunburstChart.module.mjs","names":[],"sources":["../../src/SunburstChart/SunburstChart.module.css"],"sourcesContent":[".root {\n min-height: var(--chart-size, auto);\n height: var(--chart-size, auto);\n width: var(--chart-size, auto);\n min-width: var(--chart-size, auto);\n\n & :where(*) {\n outline: 0;\n }\n}\n"],"mappings":""}
|
package/esm/Treemap/Treemap.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { ChartTooltip } from "../ChartTooltip/ChartTooltip.mjs";
|
|
|
3
3
|
import Treemap_module_default from "./Treemap.module.mjs";
|
|
4
4
|
import { Box, createVarsResolver, factory, getAutoContrastValue, getThemeColor, isLightColor, parseThemeColor, rem, useMantineTheme, useProps, useResolvedStylesApi, useStyles } from "@mantine/core";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import "react";
|
|
7
6
|
import { ResponsiveContainer, Tooltip as Tooltip$1, Treemap } from "recharts";
|
|
7
|
+
import "react";
|
|
8
8
|
//#region packages/@mantine/charts/src/Treemap/Treemap.tsx
|
|
9
9
|
const defaultProps = {
|
|
10
10
|
dataKey: "value",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-chart.module.mjs","names":[],"sources":["../src/grid-chart.module.css"],"sourcesContent":[".root {\n display: block;\n width: 100%;\n\n --chart-bar-label-color: var(--mantine-color-dimmed);\n\n svg {\n overflow: visible;\n outline: 0;\n }\n\n @mixin where-light {\n --chart-grid-color: rgba(173, 181, 189, 0.6);\n --chart-cursor-fill: rgba(173, 181, 189, 0.15);\n }\n\n @mixin where-dark {\n --chart-cursor-fill: rgba(105, 105, 105, 0.15);\n --chart-grid-color: rgba(105, 105, 105, 0.6);\n }\n\n & :where(text) {\n font-family: var(--mantine-font-family);\n color: var(--chart-text-color, var(--mantine-color-dimmed));\n }\n}\n\n.container {\n height: 100%;\n width: 100%;\n}\n\n.grid {\n stroke: var(--chart-grid-color);\n}\n\n.axis {\n color: var(--chart-grid-color);\n}\n\n.axisLabel {\n color: var(--chart-text-color, var(--mantine-color-dimmed));\n}\n\n.tooltip {\n min-width: 200px;\n background-color: var(--mantine-color-body);\n box-shadow: var(--mantine-shadow-md);\n border-radius: var(--mantine-radius-default);\n padding: var(--mantine-spacing-sm);\n\n @mixin where-light {\n border: 1px solid var(--mantine-color-gray-3);\n }\n\n @mixin where-dark {\n border: 1px solid var(--mantine-color-dark-4);\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"grid-chart.module.mjs","names":[],"sources":["../src/grid-chart.module.css"],"sourcesContent":[".root {\n display: block;\n width: 100%;\n\n --chart-bar-label-color: var(--mantine-color-dimmed);\n\n svg {\n overflow: visible;\n outline: 0;\n }\n\n :where(svg *) {\n outline: 0;\n }\n\n svg:focus-visible {\n outline: 2px solid var(--mantine-primary-color-filled);\n outline-offset: 2px;\n }\n\n @mixin where-light {\n --chart-grid-color: rgba(173, 181, 189, 0.6);\n --chart-cursor-fill: rgba(173, 181, 189, 0.15);\n }\n\n @mixin where-dark {\n --chart-cursor-fill: rgba(105, 105, 105, 0.15);\n --chart-grid-color: rgba(105, 105, 105, 0.6);\n }\n\n & :where(text) {\n font-family: var(--mantine-font-family);\n color: var(--chart-text-color, var(--mantine-color-dimmed));\n }\n}\n\n.container {\n height: 100%;\n width: 100%;\n}\n\n.grid {\n stroke: var(--chart-grid-color);\n}\n\n.axis {\n color: var(--chart-grid-color);\n}\n\n.axisLabel {\n color: var(--chart-text-color, var(--mantine-color-dimmed));\n}\n\n.tooltip {\n min-width: 200px;\n background-color: var(--mantine-color-body);\n box-shadow: var(--mantine-shadow-md);\n border-radius: var(--mantine-radius-default);\n padding: var(--mantine-spacing-sm);\n\n @mixin where-light {\n border: 1px solid var(--mantine-color-gray-3);\n }\n\n @mixin where-dark {\n border: 1px solid var(--mantine-color-dark-4);\n }\n}\n"],"mappings":""}
|
package/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChartTooltip, getFilteredChartTooltipPayload } from "./ChartTooltip/ChartTooltip.mjs";
|
|
2
2
|
import { ChartLegend, getFilteredChartLegendPayload } from "./ChartLegend/ChartLegend.mjs";
|
|
3
|
+
import { ChartBrush } from "./ChartBrush/ChartBrush.mjs";
|
|
3
4
|
import { AreaGradient } from "./AreaChart/AreaGradient.mjs";
|
|
4
5
|
import { getSplitOffset } from "./AreaChart/get-split-offset.mjs";
|
|
5
6
|
import { AreaChart } from "./AreaChart/AreaChart.mjs";
|
|
@@ -18,4 +19,6 @@ import { Heatmap } from "./Heatmap/Heatmap.mjs";
|
|
|
18
19
|
import { BarsList } from "./BarsList/BarsList.mjs";
|
|
19
20
|
import { Treemap } from "./Treemap/Treemap.mjs";
|
|
20
21
|
import { SankeyChart } from "./SankeyChart/SankeyChart.mjs";
|
|
21
|
-
|
|
22
|
+
import { SunburstChart } from "./SunburstChart/SunburstChart.mjs";
|
|
23
|
+
import { BulletChart } from "./BulletChart/BulletChart.mjs";
|
|
24
|
+
export { AreaChart, AreaGradient, BarChart, BarsList, BubbleChart, BulletChart, ChartBrush, ChartLegend, ChartTooltip, CompositeChart, DonutChart, FunnelChart, Heatmap, LineChart, PieChart, RadarChart, RadialBarChart, SankeyChart, ScatterChart, Sparkline, SunburstChart, Treemap, getFilteredChartLegendPayload, getFilteredChartTooltipPayload, getSplitOffset };
|
|
@@ -38,6 +38,8 @@ export interface BubbleChartProps extends BoxProps, StylesApiProps<BubbleChartFa
|
|
|
38
38
|
withTooltip?: boolean;
|
|
39
39
|
/** Function to format z axis values */
|
|
40
40
|
valueFormatter?: (value: number) => string;
|
|
41
|
+
/** Determines whether the chart should be keyboard-navigable with the recharts accessibility layer, `true` by default */
|
|
42
|
+
accessibilityLayer?: boolean;
|
|
41
43
|
}
|
|
42
44
|
export type BubbleChartFactory = Factory<{
|
|
43
45
|
props: BubbleChartProps;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BoxProps, ElementProps, Factory, MantineColor, StylesApiProps } from '@mantine/core';
|
|
2
|
+
export interface BulletChartRange {
|
|
3
|
+
/** Upper bound value for this range */
|
|
4
|
+
value: number;
|
|
5
|
+
/** Background color of the range band */
|
|
6
|
+
color: MantineColor;
|
|
7
|
+
/** Optional label for the range */
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
export type BulletChartStylesNames = 'root' | 'label' | 'trackWrapper' | 'track' | 'range' | 'bar' | 'target' | 'rangeLabel' | 'barLabel' | 'targetLabel';
|
|
11
|
+
export type BulletChartCssVariables = {
|
|
12
|
+
root: '--bullet-size' | '--bullet-bar-size';
|
|
13
|
+
};
|
|
14
|
+
export interface BulletChartProps extends BoxProps, StylesApiProps<BulletChartFactory>, ElementProps<'div'> {
|
|
15
|
+
/** Current actual value */
|
|
16
|
+
value: number;
|
|
17
|
+
/** Target value, displayed as a marker line */
|
|
18
|
+
target?: number;
|
|
19
|
+
/** Qualitative ranges displayed as background bands */
|
|
20
|
+
ranges: BulletChartRange[];
|
|
21
|
+
/** Orientation, @default 'horizontal' */
|
|
22
|
+
orientation?: 'horizontal' | 'vertical';
|
|
23
|
+
/** Label displayed next to the chart */
|
|
24
|
+
label?: React.ReactNode;
|
|
25
|
+
/** Value formatter for tooltip/display and labels */
|
|
26
|
+
valueFormatter?: (value: number) => string;
|
|
27
|
+
/** Color of the actual value bar, @default 'white' */
|
|
28
|
+
barColor?: MantineColor;
|
|
29
|
+
/** Color of the target marker, @default 'dark' for light, 'white' for dark */
|
|
30
|
+
targetColor?: MantineColor;
|
|
31
|
+
/** Height of the chart track area (ranges), @default 32 */
|
|
32
|
+
size?: number | string;
|
|
33
|
+
/** Height of the actual value bar, @default 16 */
|
|
34
|
+
barSize?: number | string;
|
|
35
|
+
/** Target marker size relative to chart size, @default 0.7 */
|
|
36
|
+
targetRatio?: number;
|
|
37
|
+
/** Target marker thickness, @default 2 */
|
|
38
|
+
targetSize?: number | string;
|
|
39
|
+
/** Whether to show tooltip on hover, @default false */
|
|
40
|
+
withTooltip?: boolean;
|
|
41
|
+
/** Custom tooltip content */
|
|
42
|
+
getTooltipLabel?: (data: {
|
|
43
|
+
value: number;
|
|
44
|
+
target?: number;
|
|
45
|
+
}) => React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
export type BulletChartFactory = Factory<{
|
|
48
|
+
props: BulletChartProps;
|
|
49
|
+
ref: HTMLDivElement;
|
|
50
|
+
stylesNames: BulletChartStylesNames;
|
|
51
|
+
vars: BulletChartCssVariables;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const BulletChart: import("@mantine/core").MantineComponent<{
|
|
54
|
+
props: BulletChartProps;
|
|
55
|
+
ref: HTMLDivElement;
|
|
56
|
+
stylesNames: BulletChartStylesNames;
|
|
57
|
+
vars: BulletChartCssVariables;
|
|
58
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BulletChartFactory, BulletChartProps, BulletChartRange, BulletChartStylesNames } from './BulletChart';
|
|
2
|
+
export { BulletChart } from './BulletChart';
|
|
3
|
+
export type { BulletChartProps, BulletChartStylesNames, BulletChartFactory, BulletChartRange };
|
|
4
|
+
export declare namespace BulletChart {
|
|
5
|
+
type Props = BulletChartProps;
|
|
6
|
+
type StylesNames = BulletChartStylesNames;
|
|
7
|
+
type Factory = BulletChartFactory;
|
|
8
|
+
type Range = BulletChartRange;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BrushProps } from 'recharts';
|
|
2
|
+
import { Factory, StylesApiProps } from '@mantine/core';
|
|
3
|
+
export type ChartBrushStylesNames = 'brush';
|
|
4
|
+
export interface ChartBrushProps extends Omit<BrushProps, 'ref'>, StylesApiProps<ChartBrushFactory> {
|
|
5
|
+
}
|
|
6
|
+
export type ChartBrushFactory = Factory<{
|
|
7
|
+
props: ChartBrushProps;
|
|
8
|
+
ref: SVGElement;
|
|
9
|
+
stylesNames: ChartBrushStylesNames;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const ChartBrush: import("@mantine/core").MantineComponent<{
|
|
12
|
+
props: ChartBrushProps;
|
|
13
|
+
ref: SVGElement;
|
|
14
|
+
stylesNames: ChartBrushStylesNames;
|
|
15
|
+
}>;
|
|
@@ -60,6 +60,8 @@ export interface DonutChartProps extends BoxProps, StylesApiProps<DonutChartFact
|
|
|
60
60
|
valueFormatter?: (value: number) => string;
|
|
61
61
|
/** Props passed down to each segment of the chart */
|
|
62
62
|
cellProps?: ((series: DonutChartCell) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>) | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>;
|
|
63
|
+
/** Determines whether the chart should be keyboard-navigable with the recharts accessibility layer, `true` by default */
|
|
64
|
+
accessibilityLayer?: boolean;
|
|
63
65
|
}
|
|
64
66
|
export type DonutChartFactory = Factory<{
|
|
65
67
|
props: DonutChartProps;
|
|
@@ -47,6 +47,8 @@ export interface FunnelChartProps extends BoxProps, StylesApiProps<FunnelChartFa
|
|
|
47
47
|
children?: React.ReactNode;
|
|
48
48
|
/** Props passed down to recharts `FunnelChart` component */
|
|
49
49
|
funnelChartProps?: React.ComponentProps<typeof RechartsFunnelChart>;
|
|
50
|
+
/** Determines whether the chart should be keyboard-navigable with the recharts accessibility layer, `true` by default */
|
|
51
|
+
accessibilityLayer?: boolean;
|
|
50
52
|
}
|
|
51
53
|
export type FunnelChartFactory = Factory<{
|
|
52
54
|
props: FunnelChartProps;
|
package/lib/Heatmap/Heatmap.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface HeatmapProps extends BoxProps, StylesApiProps<HeatmapFactory>,
|
|
|
15
15
|
endDate?: Date | string;
|
|
16
16
|
/** If set, month labels are displayed @default false */
|
|
17
17
|
withMonthLabels?: boolean;
|
|
18
|
+
/** Month labels position relative to the heatmap @default 'top' */
|
|
19
|
+
monthLabelsPosition?: 'top' | 'bottom';
|
|
18
20
|
/** Month labels, array of 12 elements, can be used for localization */
|
|
19
21
|
monthLabels?: string[];
|
|
20
22
|
/** If set, weekday labels are displayed @default false */
|
|
@@ -59,6 +59,8 @@ export interface PieChartProps extends BoxProps, StylesApiProps<PieChartFactory>
|
|
|
59
59
|
valueFormatter?: (value: number) => string;
|
|
60
60
|
/** Props passed down to each segment of the chart */
|
|
61
61
|
cellProps?: ((series: PieChartCell) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>) | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>;
|
|
62
|
+
/** Determines whether the chart should be keyboard-navigable with the recharts accessibility layer, `true` by default */
|
|
63
|
+
accessibilityLayer?: boolean;
|
|
62
64
|
}
|
|
63
65
|
export type PieChartFactory = Factory<{
|
|
64
66
|
props: PieChartProps;
|
|
@@ -59,6 +59,8 @@ export interface RadarChartProps extends BoxProps, StylesApiProps<RadarChartFact
|
|
|
59
59
|
activeDotProps?: MantineChartDotProps;
|
|
60
60
|
/** Additional components that are rendered inside recharts `RadarChart` component */
|
|
61
61
|
children?: React.ReactNode;
|
|
62
|
+
/** Determines whether the chart should be keyboard-navigable with the recharts accessibility layer, `true` by default */
|
|
63
|
+
accessibilityLayer?: boolean;
|
|
62
64
|
}
|
|
63
65
|
export type RadarChartFactory = Factory<{
|
|
64
66
|
props: RadarChartProps;
|
|
@@ -34,6 +34,8 @@ export interface RadialBarChartProps extends BoxProps, StylesApiProps<RadialBarC
|
|
|
34
34
|
legendProps?: Omit<LegendProps, 'ref'>;
|
|
35
35
|
/** Props passed down to `Tooltip` recharts component */
|
|
36
36
|
tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;
|
|
37
|
+
/** Determines whether the chart should be keyboard-navigable with the recharts accessibility layer, `true` by default */
|
|
38
|
+
accessibilityLayer?: boolean;
|
|
37
39
|
}
|
|
38
40
|
export type RadialBarChartFactory = Factory<{
|
|
39
41
|
props: RadialBarChartProps;
|
|
@@ -8,11 +8,11 @@ export interface ScatterChartSeries {
|
|
|
8
8
|
name: string;
|
|
9
9
|
data: Record<string, number>[];
|
|
10
10
|
}
|
|
11
|
-
export type ScatterChartStylesNames = 'scatter' | BaseChartStylesNames | ChartLegendStylesNames | ChartTooltipStylesNames;
|
|
11
|
+
export type ScatterChartStylesNames = 'scatter' | Exclude<BaseChartStylesNames, 'brush'> | ChartLegendStylesNames | ChartTooltipStylesNames;
|
|
12
12
|
export type ScatterChartCssVariables = {
|
|
13
13
|
root: '--chart-text-color' | '--chart-grid-color';
|
|
14
14
|
};
|
|
15
|
-
export interface ScatterChartProps extends Omit<GridChartBaseProps, 'dataKey' | 'data' | 'unit' | 'valueFormatter'>, BoxProps, StylesApiProps<ScatterChartFactory>, ElementProps<'div'> {
|
|
15
|
+
export interface ScatterChartProps extends Omit<GridChartBaseProps, 'dataKey' | 'data' | 'unit' | 'valueFormatter' | 'withBrush' | 'brushProps'>, BoxProps, StylesApiProps<ScatterChartFactory>, ElementProps<'div'> {
|
|
16
16
|
/** Keys that should be used to retrieve data from the data array on x and y axis */
|
|
17
17
|
dataKey: {
|
|
18
18
|
x: string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SunburstChartProps as RechartsSunburstChartProps, TooltipProps } from 'recharts';
|
|
2
|
+
import { BoxProps, ElementProps, Factory, MantineColor, StylesApiProps } from '@mantine/core';
|
|
3
|
+
import { ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';
|
|
4
|
+
export interface SunburstChartData {
|
|
5
|
+
name: string;
|
|
6
|
+
value?: number;
|
|
7
|
+
color?: MantineColor;
|
|
8
|
+
children?: SunburstChartData[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export type SunburstChartStylesNames = 'root' | ChartTooltipStylesNames;
|
|
12
|
+
export type SunburstChartCssVariables = {
|
|
13
|
+
root: '--chart-stroke-color' | '--chart-size';
|
|
14
|
+
};
|
|
15
|
+
export interface SunburstChartProps extends BoxProps, StylesApiProps<SunburstChartFactory>, ElementProps<'div'> {
|
|
16
|
+
/** Data used to render chart */
|
|
17
|
+
data: SunburstChartData[];
|
|
18
|
+
/** Key in data object for the value @default 'value' */
|
|
19
|
+
dataKey?: string;
|
|
20
|
+
/** Determines whether the tooltip should be displayed when a node is hovered @default true */
|
|
21
|
+
withTooltip?: boolean;
|
|
22
|
+
/** Tooltip animation duration in ms @default 0 */
|
|
23
|
+
tooltipAnimationDuration?: number;
|
|
24
|
+
/** Props passed down to `Tooltip` recharts component */
|
|
25
|
+
tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;
|
|
26
|
+
/** Props passed down to recharts `SunburstChart` component */
|
|
27
|
+
sunburstChartProps?: Partial<Omit<RechartsSunburstChartProps, 'ref' | 'data' | 'dataKey'>>;
|
|
28
|
+
/** Controls color of the sectors stroke, by default depends on color scheme */
|
|
29
|
+
strokeColor?: MantineColor;
|
|
30
|
+
/** Controls chart width and height @default 300 */
|
|
31
|
+
size?: number;
|
|
32
|
+
/** Controls the radius of the inner circle at the center of the chart @default 50 */
|
|
33
|
+
innerRadius?: number;
|
|
34
|
+
/** Gap between sectors and rings in px @default 1 */
|
|
35
|
+
gap?: number;
|
|
36
|
+
/** Angle in degrees from which the chart should start @default 0 */
|
|
37
|
+
startAngle?: number;
|
|
38
|
+
/** Angle in degrees at which the chart should end @default 360 */
|
|
39
|
+
endAngle?: number;
|
|
40
|
+
/** Determines whether value labels are displayed inside each sector @default false */
|
|
41
|
+
withLabels?: boolean;
|
|
42
|
+
/** A function to format values inside the tooltip and labels */
|
|
43
|
+
valueFormatter?: (value: number) => string;
|
|
44
|
+
/** Additional elements rendered inside `SunburstChart` component */
|
|
45
|
+
children?: React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
export type SunburstChartFactory = Factory<{
|
|
48
|
+
props: SunburstChartProps;
|
|
49
|
+
ref: HTMLDivElement;
|
|
50
|
+
stylesNames: SunburstChartStylesNames;
|
|
51
|
+
vars: SunburstChartCssVariables;
|
|
52
|
+
}>;
|
|
53
|
+
export declare const SunburstChart: import("@mantine/core").MantineComponent<{
|
|
54
|
+
props: SunburstChartProps;
|
|
55
|
+
ref: HTMLDivElement;
|
|
56
|
+
stylesNames: SunburstChartStylesNames;
|
|
57
|
+
vars: SunburstChartCssVariables;
|
|
58
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SunburstChartCssVariables, SunburstChartData, SunburstChartFactory, SunburstChartProps, SunburstChartStylesNames } from './SunburstChart';
|
|
2
|
+
export { SunburstChart } from './SunburstChart';
|
|
3
|
+
export type { SunburstChartProps, SunburstChartStylesNames, SunburstChartCssVariables, SunburstChartFactory, SunburstChartData, };
|
|
4
|
+
export declare namespace SunburstChart {
|
|
5
|
+
type Props = SunburstChartProps;
|
|
6
|
+
type StylesNames = SunburstChartStylesNames;
|
|
7
|
+
type CssVariables = SunburstChartCssVariables;
|
|
8
|
+
type Factory = SunburstChartFactory;
|
|
9
|
+
type Data = SunburstChartData;
|
|
10
|
+
}
|
package/lib/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './ChartTooltip/index.js';
|
|
2
2
|
export * from './ChartLegend/index.js';
|
|
3
|
+
export * from './ChartBrush/index.js';
|
|
3
4
|
export * from './AreaChart/index.js';
|
|
4
5
|
export * from './BarChart/index.js';
|
|
5
6
|
export * from './LineChart/index.js';
|
|
@@ -16,4 +17,6 @@ export * from './Heatmap/index.js';
|
|
|
16
17
|
export * from './BarsList/index.js';
|
|
17
18
|
export * from './Treemap/index.js';
|
|
18
19
|
export * from './SankeyChart/index.js';
|
|
20
|
+
export * from './SunburstChart/index.js';
|
|
21
|
+
export * from './BulletChart/index.js';
|
|
19
22
|
export * from './types';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './ChartTooltip/index.js';
|
|
2
2
|
export * from './ChartLegend/index.js';
|
|
3
|
+
export * from './ChartBrush/index.js';
|
|
3
4
|
export * from './AreaChart/index.js';
|
|
4
5
|
export * from './BarChart/index.js';
|
|
5
6
|
export * from './LineChart/index.js';
|
|
@@ -16,4 +17,6 @@ export * from './Heatmap/index.js';
|
|
|
16
17
|
export * from './BarsList/index.js';
|
|
17
18
|
export * from './Treemap/index.js';
|
|
18
19
|
export * from './SankeyChart/index.js';
|
|
20
|
+
export * from './SunburstChart/index.js';
|
|
21
|
+
export * from './BulletChart/index.js';
|
|
19
22
|
export * from './types';
|