@yamada-ui/charts 1.0.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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/area-chart-gradient.d.mts +11 -0
- package/dist/area-chart-gradient.d.ts +11 -0
- package/dist/area-chart-gradient.js +47 -0
- package/dist/area-chart-gradient.js.map +1 -0
- package/dist/area-chart-gradient.mjs +8 -0
- package/dist/area-chart-gradient.mjs.map +1 -0
- package/dist/area-chart-split.d.mts +10 -0
- package/dist/area-chart-split.d.ts +10 -0
- package/dist/area-chart-split.js +52 -0
- package/dist/area-chart-split.js.map +1 -0
- package/dist/area-chart-split.mjs +8 -0
- package/dist/area-chart-split.mjs.map +1 -0
- package/dist/area-chart.d.mts +36 -0
- package/dist/area-chart.d.ts +36 -0
- package/dist/area-chart.js +1249 -0
- package/dist/area-chart.js.map +1 -0
- package/dist/area-chart.mjs +21 -0
- package/dist/area-chart.mjs.map +1 -0
- package/dist/bar-chart.d.mts +33 -0
- package/dist/bar-chart.d.ts +33 -0
- package/dist/bar-chart.js +1053 -0
- package/dist/bar-chart.js.map +1 -0
- package/dist/bar-chart.mjs +19 -0
- package/dist/bar-chart.mjs.map +1 -0
- package/dist/chart-legend.d.mts +12 -0
- package/dist/chart-legend.d.ts +12 -0
- package/dist/chart-legend.js +87 -0
- package/dist/chart-legend.js.map +1 -0
- package/dist/chart-legend.mjs +11 -0
- package/dist/chart-legend.mjs.map +1 -0
- package/dist/chart-tooltip.d.mts +12 -0
- package/dist/chart-tooltip.d.ts +12 -0
- package/dist/chart-tooltip.js +120 -0
- package/dist/chart-tooltip.js.map +1 -0
- package/dist/chart-tooltip.mjs +11 -0
- package/dist/chart-tooltip.mjs.map +1 -0
- package/dist/chart-utils.d.mts +9 -0
- package/dist/chart-utils.d.ts +9 -0
- package/dist/chart-utils.js +45 -0
- package/dist/chart-utils.js.map +1 -0
- package/dist/chart-utils.mjs +10 -0
- package/dist/chart-utils.mjs.map +1 -0
- package/dist/chart.types.d.mts +65 -0
- package/dist/chart.types.d.ts +65 -0
- package/dist/chart.types.js +20 -0
- package/dist/chart.types.js.map +1 -0
- package/dist/chart.types.mjs +2 -0
- package/dist/chart.types.mjs.map +1 -0
- package/dist/chunk-32BO2QEP.mjs +83 -0
- package/dist/chunk-32BO2QEP.mjs.map +1 -0
- package/dist/chunk-3CY3IFRN.mjs +42 -0
- package/dist/chunk-3CY3IFRN.mjs.map +1 -0
- package/dist/chunk-3IBGJT6F.mjs +341 -0
- package/dist/chunk-3IBGJT6F.mjs.map +1 -0
- package/dist/chunk-5QCKM3B3.mjs +438 -0
- package/dist/chunk-5QCKM3B3.mjs.map +1 -0
- package/dist/chunk-AURFFNDQ.mjs +114 -0
- package/dist/chunk-AURFFNDQ.mjs.map +1 -0
- package/dist/chunk-FGDWJUA3.mjs +56 -0
- package/dist/chunk-FGDWJUA3.mjs.map +1 -0
- package/dist/chunk-GZLE5XDS.mjs +227 -0
- package/dist/chunk-GZLE5XDS.mjs.map +1 -0
- package/dist/chunk-HE6SM47L.mjs +234 -0
- package/dist/chunk-HE6SM47L.mjs.map +1 -0
- package/dist/chunk-LXZCGIND.mjs +33 -0
- package/dist/chunk-LXZCGIND.mjs.map +1 -0
- package/dist/chunk-MSIOYYWR.mjs +24 -0
- package/dist/chunk-MSIOYYWR.mjs.map +1 -0
- package/dist/chunk-PNE3JG54.mjs +29 -0
- package/dist/chunk-PNE3JG54.mjs.map +1 -0
- package/dist/chunk-QL3DB7OJ.mjs +21 -0
- package/dist/chunk-QL3DB7OJ.mjs.map +1 -0
- package/dist/chunk-RG5JQJXE.mjs +249 -0
- package/dist/chunk-RG5JQJXE.mjs.map +1 -0
- package/dist/chunk-RTTZPOUT.mjs +50 -0
- package/dist/chunk-RTTZPOUT.mjs.map +1 -0
- package/dist/chunk-RXWD2EJ2.mjs +56 -0
- package/dist/chunk-RXWD2EJ2.mjs.map +1 -0
- package/dist/chunk-TKLHZBVY.mjs +206 -0
- package/dist/chunk-TKLHZBVY.mjs.map +1 -0
- package/dist/chunk-WDSR6B47.mjs +324 -0
- package/dist/chunk-WDSR6B47.mjs.map +1 -0
- package/dist/chunk-WF3BD34Y.mjs +74 -0
- package/dist/chunk-WF3BD34Y.mjs.map +1 -0
- package/dist/chunk-YBAGOHS5.mjs +204 -0
- package/dist/chunk-YBAGOHS5.mjs.map +1 -0
- package/dist/chunk-YRY7MUCR.mjs +258 -0
- package/dist/chunk-YRY7MUCR.mjs.map +1 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +2725 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36 -0
- package/dist/index.mjs.map +1 -0
- package/dist/line-chart.d.mts +33 -0
- package/dist/line-chart.d.ts +33 -0
- package/dist/line-chart.js +1114 -0
- package/dist/line-chart.js.map +1 -0
- package/dist/line-chart.mjs +19 -0
- package/dist/line-chart.mjs.map +1 -0
- package/dist/radar-chart.d.mts +52 -0
- package/dist/radar-chart.d.ts +52 -0
- package/dist/radar-chart.js +940 -0
- package/dist/radar-chart.js.map +1 -0
- package/dist/radar-chart.mjs +16 -0
- package/dist/radar-chart.mjs.map +1 -0
- package/dist/rechart-properties.d.mts +24 -0
- package/dist/rechart-properties.d.ts +24 -0
- package/dist/rechart-properties.js +479 -0
- package/dist/rechart-properties.js.map +1 -0
- package/dist/rechart-properties.mjs +44 -0
- package/dist/rechart-properties.mjs.map +1 -0
- package/dist/use-area-chart.d.mts +118 -0
- package/dist/use-area-chart.d.ts +118 -0
- package/dist/use-area-chart.js +418 -0
- package/dist/use-area-chart.js.map +1 -0
- package/dist/use-area-chart.mjs +10 -0
- package/dist/use-area-chart.mjs.map +1 -0
- package/dist/use-bar-chart.d.mts +68 -0
- package/dist/use-bar-chart.d.ts +68 -0
- package/dist/use-bar-chart.js +288 -0
- package/dist/use-bar-chart.js.map +1 -0
- package/dist/use-bar-chart.mjs +10 -0
- package/dist/use-bar-chart.mjs.map +1 -0
- package/dist/use-chart-axis.d.mts +73 -0
- package/dist/use-chart-axis.d.ts +73 -0
- package/dist/use-chart-axis.js +227 -0
- package/dist/use-chart-axis.js.map +1 -0
- package/dist/use-chart-axis.mjs +10 -0
- package/dist/use-chart-axis.mjs.map +1 -0
- package/dist/use-chart-grid.d.mts +32 -0
- package/dist/use-chart-grid.d.ts +32 -0
- package/dist/use-chart-grid.js +92 -0
- package/dist/use-chart-grid.js.map +1 -0
- package/dist/use-chart-grid.mjs +10 -0
- package/dist/use-chart-grid.mjs.map +1 -0
- package/dist/use-chart-legend.d.mts +18 -0
- package/dist/use-chart-legend.d.ts +18 -0
- package/dist/use-chart-legend.js +81 -0
- package/dist/use-chart-legend.js.map +1 -0
- package/dist/use-chart-legend.mjs +9 -0
- package/dist/use-chart-legend.mjs.map +1 -0
- package/dist/use-chart-reference-line.d.mts +22 -0
- package/dist/use-chart-reference-line.d.ts +22 -0
- package/dist/use-chart-reference-line.js +105 -0
- package/dist/use-chart-reference-line.js.map +1 -0
- package/dist/use-chart-reference-line.mjs +10 -0
- package/dist/use-chart-reference-line.mjs.map +1 -0
- package/dist/use-chart-tooltip.d.mts +35 -0
- package/dist/use-chart-tooltip.d.ts +35 -0
- package/dist/use-chart-tooltip.js +121 -0
- package/dist/use-chart-tooltip.js.map +1 -0
- package/dist/use-chart-tooltip.mjs +9 -0
- package/dist/use-chart-tooltip.mjs.map +1 -0
- package/dist/use-chart.d.mts +33 -0
- package/dist/use-chart.d.ts +33 -0
- package/dist/use-chart.js +104 -0
- package/dist/use-chart.js.map +1 -0
- package/dist/use-chart.mjs +18 -0
- package/dist/use-chart.mjs.map +1 -0
- package/dist/use-line-chart.d.mts +92 -0
- package/dist/use-line-chart.d.ts +92 -0
- package/dist/use-line-chart.js +342 -0
- package/dist/use-line-chart.js.map +1 -0
- package/dist/use-line-chart.mjs +10 -0
- package/dist/use-line-chart.mjs.map +1 -0
- package/dist/use-radar-chart.d.mts +93 -0
- package/dist/use-radar-chart.d.ts +93 -0
- package/dist/use-radar-chart.js +471 -0
- package/dist/use-radar-chart.js.map +1 -0
- package/dist/use-radar-chart.mjs +10 -0
- package/dist/use-radar-chart.mjs.map +1 -0
- package/package.json +84 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
|
3
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
4
|
+
import { CSSUIObject } from '@yamada-ui/core';
|
5
|
+
import * as _yamada_ui_utils from '@yamada-ui/utils';
|
6
|
+
import { Dict } from '@yamada-ui/utils';
|
7
|
+
import * as Recharts from 'recharts';
|
8
|
+
import { RadarProps, RadarChartProps, PolarGridProps, PolarAngleAxisProps, PolarRadiusAxisProps, ChartPropGetter, RequiredChartPropGetter } from './chart.types.mjs';
|
9
|
+
|
10
|
+
type UseRadarChartOptions = {
|
11
|
+
/**
|
12
|
+
* Chart data.
|
13
|
+
*/
|
14
|
+
data: Dict[];
|
15
|
+
/**
|
16
|
+
* An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.
|
17
|
+
*/
|
18
|
+
series: RadarProps[];
|
19
|
+
/**
|
20
|
+
* The key of a group of data which should be unique in an chart.
|
21
|
+
*/
|
22
|
+
dataKey: string;
|
23
|
+
/**
|
24
|
+
* Props for the radar.
|
25
|
+
*/
|
26
|
+
radarProps?: Partial<RadarProps>;
|
27
|
+
/**
|
28
|
+
* Props passed down to recharts `RadarChart` component.
|
29
|
+
*/
|
30
|
+
radarChartProps?: RadarChartProps;
|
31
|
+
/**
|
32
|
+
* Props passed down to recharts `PolarGrid` component.
|
33
|
+
*/
|
34
|
+
polarGridProps?: PolarGridProps;
|
35
|
+
/**
|
36
|
+
* Props passed down to recharts `PolarAngleAxis` component.
|
37
|
+
*/
|
38
|
+
polarAngleAxisProps?: PolarAngleAxisProps;
|
39
|
+
/**
|
40
|
+
* Props passed down to recharts `PolarRadiusAxis` component.
|
41
|
+
*/
|
42
|
+
polarRadiusAxisProps?: PolarRadiusAxisProps;
|
43
|
+
/**
|
44
|
+
* Determines whether dots should be displayed.
|
45
|
+
*
|
46
|
+
* @default false
|
47
|
+
*/
|
48
|
+
withDots?: boolean;
|
49
|
+
/**
|
50
|
+
* Determines whether activeDots should be displayed.
|
51
|
+
*
|
52
|
+
* @default true
|
53
|
+
*/
|
54
|
+
withActiveDots?: boolean;
|
55
|
+
/**
|
56
|
+
* Stroke width for the chart radars.
|
57
|
+
*
|
58
|
+
* @default 2
|
59
|
+
*/
|
60
|
+
strokeWidth?: number;
|
61
|
+
/**
|
62
|
+
* Controls fill opacity of all radars.
|
63
|
+
*
|
64
|
+
* @default 1
|
65
|
+
*/
|
66
|
+
fillOpacity?: number | [number, number];
|
67
|
+
/**
|
68
|
+
* A function to format values on Y axis and inside the tooltip.
|
69
|
+
*/
|
70
|
+
valueFormatter?: (value: number) => string;
|
71
|
+
};
|
72
|
+
type UseRadarChartProps = UseRadarChartOptions & {
|
73
|
+
styles: Dict<CSSUIObject>;
|
74
|
+
};
|
75
|
+
declare const useRadarChart: ({ data, series, dataKey, withDots, withActiveDots, strokeWidth, fillOpacity, valueFormatter, styles, ...rest }: UseRadarChartProps) => {
|
76
|
+
radarVars: {
|
77
|
+
__prefix?: string | undefined;
|
78
|
+
name: string;
|
79
|
+
token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
|
80
|
+
value?: (number | _yamada_ui_utils.StringLiteral | _yamada_ui_core.ResponsiveObject<number | _yamada_ui_utils.StringLiteral> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
|
81
|
+
}[];
|
82
|
+
getRadarChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
|
83
|
+
getRadarProps: RequiredChartPropGetter<"div", {
|
84
|
+
index: number;
|
85
|
+
}, Omit<Recharts.RadarProps, "ref">>;
|
86
|
+
getPolarGridProps: ChartPropGetter<"div", Recharts.PolarGridProps, Recharts.PolarGridProps>;
|
87
|
+
getPolarAngleAxisProps: ChartPropGetter<"div", Recharts.PolarAngleAxisProps, Omit<Recharts.PolarAngleAxisProps, "ref">>;
|
88
|
+
getPolarRadiusAxisProps: ChartPropGetter<"div", Recharts.PolarRadiusAxisProps, Omit<Recharts.PolarRadiusAxisProps, "ref">>;
|
89
|
+
setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
|
90
|
+
};
|
91
|
+
type UseRadarChartReturn = ReturnType<typeof useRadarChart>;
|
92
|
+
|
93
|
+
export { type UseRadarChartOptions, type UseRadarChartReturn, useRadarChart };
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import * as recharts_types_chart_generateCategoricalChart from 'recharts/types/chart/generateCategoricalChart';
|
3
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
4
|
+
import { CSSUIObject } from '@yamada-ui/core';
|
5
|
+
import * as _yamada_ui_utils from '@yamada-ui/utils';
|
6
|
+
import { Dict } from '@yamada-ui/utils';
|
7
|
+
import * as Recharts from 'recharts';
|
8
|
+
import { RadarProps, RadarChartProps, PolarGridProps, PolarAngleAxisProps, PolarRadiusAxisProps, ChartPropGetter, RequiredChartPropGetter } from './chart.types.js';
|
9
|
+
|
10
|
+
type UseRadarChartOptions = {
|
11
|
+
/**
|
12
|
+
* Chart data.
|
13
|
+
*/
|
14
|
+
data: Dict[];
|
15
|
+
/**
|
16
|
+
* An array of objects with `dataKey` and `color` keys. Determines which data should be consumed from the `data` array.
|
17
|
+
*/
|
18
|
+
series: RadarProps[];
|
19
|
+
/**
|
20
|
+
* The key of a group of data which should be unique in an chart.
|
21
|
+
*/
|
22
|
+
dataKey: string;
|
23
|
+
/**
|
24
|
+
* Props for the radar.
|
25
|
+
*/
|
26
|
+
radarProps?: Partial<RadarProps>;
|
27
|
+
/**
|
28
|
+
* Props passed down to recharts `RadarChart` component.
|
29
|
+
*/
|
30
|
+
radarChartProps?: RadarChartProps;
|
31
|
+
/**
|
32
|
+
* Props passed down to recharts `PolarGrid` component.
|
33
|
+
*/
|
34
|
+
polarGridProps?: PolarGridProps;
|
35
|
+
/**
|
36
|
+
* Props passed down to recharts `PolarAngleAxis` component.
|
37
|
+
*/
|
38
|
+
polarAngleAxisProps?: PolarAngleAxisProps;
|
39
|
+
/**
|
40
|
+
* Props passed down to recharts `PolarRadiusAxis` component.
|
41
|
+
*/
|
42
|
+
polarRadiusAxisProps?: PolarRadiusAxisProps;
|
43
|
+
/**
|
44
|
+
* Determines whether dots should be displayed.
|
45
|
+
*
|
46
|
+
* @default false
|
47
|
+
*/
|
48
|
+
withDots?: boolean;
|
49
|
+
/**
|
50
|
+
* Determines whether activeDots should be displayed.
|
51
|
+
*
|
52
|
+
* @default true
|
53
|
+
*/
|
54
|
+
withActiveDots?: boolean;
|
55
|
+
/**
|
56
|
+
* Stroke width for the chart radars.
|
57
|
+
*
|
58
|
+
* @default 2
|
59
|
+
*/
|
60
|
+
strokeWidth?: number;
|
61
|
+
/**
|
62
|
+
* Controls fill opacity of all radars.
|
63
|
+
*
|
64
|
+
* @default 1
|
65
|
+
*/
|
66
|
+
fillOpacity?: number | [number, number];
|
67
|
+
/**
|
68
|
+
* A function to format values on Y axis and inside the tooltip.
|
69
|
+
*/
|
70
|
+
valueFormatter?: (value: number) => string;
|
71
|
+
};
|
72
|
+
type UseRadarChartProps = UseRadarChartOptions & {
|
73
|
+
styles: Dict<CSSUIObject>;
|
74
|
+
};
|
75
|
+
declare const useRadarChart: ({ data, series, dataKey, withDots, withActiveDots, strokeWidth, fillOpacity, valueFormatter, styles, ...rest }: UseRadarChartProps) => {
|
76
|
+
radarVars: {
|
77
|
+
__prefix?: string | undefined;
|
78
|
+
name: string;
|
79
|
+
token?: "colors" | "transitionDuration" | "transitionProperty" | "animations" | "blurs" | "borders" | "breakpoints" | "fonts" | "fontSizes" | "fontWeights" | "gradients" | "layerStyles" | "letterSpacings" | "lineHeights" | "radii" | "shadows" | "sizes" | "spaces" | "textStyles" | "transitionEasing" | "zIndices" | undefined;
|
80
|
+
value?: (number | _yamada_ui_utils.StringLiteral | _yamada_ui_core.ResponsiveObject<number | _yamada_ui_utils.StringLiteral> | _yamada_ui_core.ColorModeArray<number | _yamada_ui_utils.StringLiteral>) | undefined;
|
81
|
+
}[];
|
82
|
+
getRadarChartProps: ChartPropGetter<"div", recharts_types_chart_generateCategoricalChart.CategoricalChartProps, recharts_types_chart_generateCategoricalChart.CategoricalChartProps>;
|
83
|
+
getRadarProps: RequiredChartPropGetter<"div", {
|
84
|
+
index: number;
|
85
|
+
}, Omit<Recharts.RadarProps, "ref">>;
|
86
|
+
getPolarGridProps: ChartPropGetter<"div", Recharts.PolarGridProps, Recharts.PolarGridProps>;
|
87
|
+
getPolarAngleAxisProps: ChartPropGetter<"div", Recharts.PolarAngleAxisProps, Omit<Recharts.PolarAngleAxisProps, "ref">>;
|
88
|
+
getPolarRadiusAxisProps: ChartPropGetter<"div", Recharts.PolarRadiusAxisProps, Omit<Recharts.PolarRadiusAxisProps, "ref">>;
|
89
|
+
setHighlightedArea: react.Dispatch<react.SetStateAction<string | null>>;
|
90
|
+
};
|
91
|
+
type UseRadarChartReturn = ReturnType<typeof useRadarChart>;
|
92
|
+
|
93
|
+
export { type UseRadarChartOptions, type UseRadarChartReturn, useRadarChart };
|
@@ -0,0 +1,471 @@
|
|
1
|
+
"use client"
|
2
|
+
"use strict";
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
|
+
|
21
|
+
// src/use-radar-chart.ts
|
22
|
+
var use_radar_chart_exports = {};
|
23
|
+
__export(use_radar_chart_exports, {
|
24
|
+
useRadarChart: () => useRadarChart
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(use_radar_chart_exports);
|
27
|
+
var import_core2 = require("@yamada-ui/core");
|
28
|
+
var import_utils2 = require("@yamada-ui/utils");
|
29
|
+
var import_react = require("react");
|
30
|
+
|
31
|
+
// src/chart-utils.ts
|
32
|
+
var import_core = require("@yamada-ui/core");
|
33
|
+
var import_utils = require("@yamada-ui/utils");
|
34
|
+
var getClassName = (...styles) => (theme) => (0, import_utils.cx)(
|
35
|
+
...styles.map(
|
36
|
+
(style) => (0, import_utils.isString)(style) ? style : (0, import_core.getCSS)(style)(theme)
|
37
|
+
)
|
38
|
+
);
|
39
|
+
var getComponentProps = ([obj, keys], ...props) => (theme, isContain) => {
|
40
|
+
const [pickedProps, omittedProps] = (0, import_utils.splitObject)(obj, keys);
|
41
|
+
const className = getClassName(...props, omittedProps)(theme);
|
42
|
+
return !isContain ? [pickedProps, className] : { ...pickedProps, className };
|
43
|
+
};
|
44
|
+
|
45
|
+
// src/rechart-properties.ts
|
46
|
+
var radarChartProperties = [
|
47
|
+
"width",
|
48
|
+
"height",
|
49
|
+
"data",
|
50
|
+
"cx",
|
51
|
+
"cy",
|
52
|
+
"startAngle",
|
53
|
+
"endAngle",
|
54
|
+
"innerRadius",
|
55
|
+
"outerRadius",
|
56
|
+
"margin",
|
57
|
+
"onMouseEnter",
|
58
|
+
"onClick"
|
59
|
+
];
|
60
|
+
var radarProperties = [
|
61
|
+
"dataKey",
|
62
|
+
"points",
|
63
|
+
"shape",
|
64
|
+
"dot",
|
65
|
+
"activeDot",
|
66
|
+
"legendType",
|
67
|
+
"label",
|
68
|
+
"isAnimationActive",
|
69
|
+
"animationBegin",
|
70
|
+
"animationDuration",
|
71
|
+
"animationEasing",
|
72
|
+
"onAnimationStart",
|
73
|
+
"onAnimationEnd"
|
74
|
+
];
|
75
|
+
var dotProperties = [
|
76
|
+
"cx",
|
77
|
+
"cy",
|
78
|
+
"r",
|
79
|
+
"onClick",
|
80
|
+
"onMouseDown",
|
81
|
+
"onMouseUp",
|
82
|
+
"onMouseMove",
|
83
|
+
"onMouseOver",
|
84
|
+
"onMouseOut",
|
85
|
+
"onMouseEnter",
|
86
|
+
"onMouseLeave"
|
87
|
+
];
|
88
|
+
var polarGridProperties = [
|
89
|
+
"cx",
|
90
|
+
"cy",
|
91
|
+
"innerRadius",
|
92
|
+
"outerRadius",
|
93
|
+
"polarAngles",
|
94
|
+
"polarRadius",
|
95
|
+
"gridType"
|
96
|
+
];
|
97
|
+
var polarAngleAxisProperties = [
|
98
|
+
"dataKey",
|
99
|
+
"cx",
|
100
|
+
"cy",
|
101
|
+
"radius",
|
102
|
+
"axisLine",
|
103
|
+
"axisLineType",
|
104
|
+
"tickLine",
|
105
|
+
"tickSize",
|
106
|
+
"tick",
|
107
|
+
"ticks",
|
108
|
+
"orient",
|
109
|
+
"tickFormatter",
|
110
|
+
"type",
|
111
|
+
"allowDuplicatedCategory",
|
112
|
+
"onClick",
|
113
|
+
"onMouseDown",
|
114
|
+
"onMouseUp",
|
115
|
+
"onMouseMove",
|
116
|
+
"onMouseOver",
|
117
|
+
"onMouseOut",
|
118
|
+
"onMouseEnter",
|
119
|
+
"onMouseLeave"
|
120
|
+
];
|
121
|
+
var polarRadiusAxisProperties = [
|
122
|
+
"angle",
|
123
|
+
"type",
|
124
|
+
"allowDuplicatedCategory",
|
125
|
+
"cx",
|
126
|
+
"cy",
|
127
|
+
"domain",
|
128
|
+
"reversed",
|
129
|
+
"label",
|
130
|
+
"orientation",
|
131
|
+
"axisLine",
|
132
|
+
"tick",
|
133
|
+
"tickSize",
|
134
|
+
"tickFormatter",
|
135
|
+
"tickCount",
|
136
|
+
"scale",
|
137
|
+
"onClick",
|
138
|
+
"onMouseDown",
|
139
|
+
"onMouseUp",
|
140
|
+
"onMouseMove",
|
141
|
+
"onMouseOver",
|
142
|
+
"onMouseOut",
|
143
|
+
"onMouseEnter",
|
144
|
+
"onMouseLeave"
|
145
|
+
];
|
146
|
+
|
147
|
+
// src/use-radar-chart.ts
|
148
|
+
var useRadarChart = ({
|
149
|
+
data,
|
150
|
+
series,
|
151
|
+
dataKey,
|
152
|
+
withDots = false,
|
153
|
+
withActiveDots = false,
|
154
|
+
strokeWidth = 2,
|
155
|
+
fillOpacity = 0.4,
|
156
|
+
valueFormatter,
|
157
|
+
styles,
|
158
|
+
...rest
|
159
|
+
}) => {
|
160
|
+
var _a;
|
161
|
+
const { theme } = (0, import_core2.useTheme)();
|
162
|
+
const [highlightedArea, setHighlightedArea] = (0, import_react.useState)(null);
|
163
|
+
const shouldHighlight = highlightedArea !== null;
|
164
|
+
const {
|
165
|
+
dot = {},
|
166
|
+
activeDot = {},
|
167
|
+
dimDot,
|
168
|
+
dimRadar,
|
169
|
+
...computedRadarProps
|
170
|
+
} = (_a = rest.radarProps) != null ? _a : {};
|
171
|
+
const radarColors = (0, import_react.useMemo)(
|
172
|
+
() => series.map(({ color }, index) => ({
|
173
|
+
__prefix: "ui",
|
174
|
+
name: `radar-${index}`,
|
175
|
+
token: "colors",
|
176
|
+
value: color != null ? color : "transparent"
|
177
|
+
})),
|
178
|
+
[series]
|
179
|
+
);
|
180
|
+
const radarVars = (0, import_react.useMemo)(
|
181
|
+
() => [
|
182
|
+
...radarColors,
|
183
|
+
{ __prefix: "ui", name: "fill-opacity", value: fillOpacity }
|
184
|
+
],
|
185
|
+
[fillOpacity, radarColors]
|
186
|
+
);
|
187
|
+
const [polarAngleAxisProps, polarAngleAxisStyles] = (0, import_react.useMemo)(
|
188
|
+
() => {
|
189
|
+
var _a2;
|
190
|
+
return (0, import_utils2.splitObject)(
|
191
|
+
(_a2 = rest.polarAngleAxisProps) != null ? _a2 : {},
|
192
|
+
polarAngleAxisProperties
|
193
|
+
);
|
194
|
+
},
|
195
|
+
[rest.polarAngleAxisProps]
|
196
|
+
);
|
197
|
+
const [polarRadiusAxisProps, polarRadiusAxisStyles] = (0, import_react.useMemo)(
|
198
|
+
() => {
|
199
|
+
var _a2;
|
200
|
+
return (0, import_utils2.splitObject)(
|
201
|
+
(_a2 = rest.polarRadiusAxisProps) != null ? _a2 : {},
|
202
|
+
polarRadiusAxisProperties
|
203
|
+
);
|
204
|
+
},
|
205
|
+
[rest.polarRadiusAxisProps]
|
206
|
+
);
|
207
|
+
const [radarChartProps, radarChartClassName] = (0, import_react.useMemo)(() => {
|
208
|
+
const resolvedRadarChartProps = {
|
209
|
+
"& .recharts-polar-grid-concentric-polygon": { ...styles.polarGrid },
|
210
|
+
"& .recharts-polar-grid-concentric-circle": { ...styles.polarGrid },
|
211
|
+
"& .recharts-polar-angle-axis": {
|
212
|
+
...styles.polarAngleAxis,
|
213
|
+
...polarAngleAxisStyles
|
214
|
+
},
|
215
|
+
"& .recharts-polar-angle-axis-tick": { ...styles.polarAngleAxisTick },
|
216
|
+
"& .recharts-polar-radius-axis": {
|
217
|
+
...styles.polarRadiusAxis,
|
218
|
+
...polarRadiusAxisStyles
|
219
|
+
},
|
220
|
+
"& .recharts-polar-radius-axis-tick": { ...styles.polarRadiusAxisTick },
|
221
|
+
...rest.radarChartProps
|
222
|
+
};
|
223
|
+
return getComponentProps(
|
224
|
+
[resolvedRadarChartProps, radarChartProperties],
|
225
|
+
styles.chart
|
226
|
+
)(theme);
|
227
|
+
}, [
|
228
|
+
polarAngleAxisStyles,
|
229
|
+
polarRadiusAxisStyles,
|
230
|
+
rest.radarChartProps,
|
231
|
+
styles.chart,
|
232
|
+
styles.polarAngleAxis,
|
233
|
+
styles.polarAngleAxisTick,
|
234
|
+
styles.polarGrid,
|
235
|
+
styles.polarRadiusAxis,
|
236
|
+
styles.polarRadiusAxisTick,
|
237
|
+
theme
|
238
|
+
]);
|
239
|
+
const [polarGridProps, polarGridClassName] = (0, import_react.useMemo)(
|
240
|
+
() => {
|
241
|
+
var _a2;
|
242
|
+
return getComponentProps(
|
243
|
+
[(_a2 = rest.polarGridProps) != null ? _a2 : {}, polarGridProperties],
|
244
|
+
styles.polarGrid
|
245
|
+
)(theme);
|
246
|
+
},
|
247
|
+
[rest.polarGridProps, styles.polarGrid, theme]
|
248
|
+
);
|
249
|
+
const [radarProps, radarClassName] = (0, import_react.useMemo)(() => {
|
250
|
+
const resolvedRadarProps = {
|
251
|
+
fillOpacity: "var(--ui-fill-opacity)",
|
252
|
+
...computedRadarProps
|
253
|
+
};
|
254
|
+
return getComponentProps(
|
255
|
+
[resolvedRadarProps, radarProperties],
|
256
|
+
styles.radar
|
257
|
+
)(theme);
|
258
|
+
}, [computedRadarProps, styles.radar, theme]);
|
259
|
+
const [dimRadarProps, dimRadarClassName] = (0, import_react.useMemo)(() => {
|
260
|
+
const resolvedDimRadar = {
|
261
|
+
fillOpacity: 0.3,
|
262
|
+
strokeOpacity: 0.3,
|
263
|
+
...dimRadar
|
264
|
+
};
|
265
|
+
return getComponentProps([resolvedDimRadar, radarProperties])(
|
266
|
+
theme
|
267
|
+
);
|
268
|
+
}, [dimRadar, theme]);
|
269
|
+
const [dotProps, dotClassName] = (0, import_react.useMemo)(() => {
|
270
|
+
const resolvedDot = { fillOpacity: 1, strokeWidth: 2, ...dot };
|
271
|
+
return getComponentProps(
|
272
|
+
[resolvedDot, dotProperties],
|
273
|
+
styles.dot
|
274
|
+
)(theme);
|
275
|
+
}, [dot, styles.dot, theme]);
|
276
|
+
const [activeDotProps, activeDotClassName] = (0, import_react.useMemo)(
|
277
|
+
() => getComponentProps(
|
278
|
+
[activeDot, dotProperties],
|
279
|
+
styles.activeDot
|
280
|
+
)(theme),
|
281
|
+
[activeDot, styles.activeDot, theme]
|
282
|
+
);
|
283
|
+
const [dimDotProps, dimDotClassName] = (0, import_react.useMemo)(() => {
|
284
|
+
const resolvedDimDot = { fillOpacity: 0, strokeOpacity: 0, ...dimDot };
|
285
|
+
return getComponentProps([resolvedDimDot, dotProperties])(
|
286
|
+
theme
|
287
|
+
);
|
288
|
+
}, [dimDot, theme]);
|
289
|
+
const radarPropList = (0, import_react.useMemo)(
|
290
|
+
() => series.map((props, index) => {
|
291
|
+
const {
|
292
|
+
dataKey: dataKey2,
|
293
|
+
dot: dot2 = {},
|
294
|
+
activeDot: activeDot2 = {},
|
295
|
+
dimDot: dimDot2 = {},
|
296
|
+
dimRadar: dimRadar2 = {},
|
297
|
+
...computedProps
|
298
|
+
} = props;
|
299
|
+
const color = `var(--ui-radar-${index})`;
|
300
|
+
const dimmed = shouldHighlight && highlightedArea !== dataKey2;
|
301
|
+
const computedDimRadar = { ...dimRadarProps, ...dimRadar2 };
|
302
|
+
const resolvedProps = {
|
303
|
+
...radarProps,
|
304
|
+
...computedProps,
|
305
|
+
...dimmed ? computedDimRadar : {}
|
306
|
+
};
|
307
|
+
const rest2 = getComponentProps(
|
308
|
+
[resolvedProps, radarProperties],
|
309
|
+
radarClassName,
|
310
|
+
dimmed ? dimRadarClassName : void 0
|
311
|
+
)(theme, true);
|
312
|
+
let resolvedActiveDot;
|
313
|
+
if (withActiveDots) {
|
314
|
+
const computedActiveDot = {
|
315
|
+
...activeDotProps,
|
316
|
+
...activeDot2
|
317
|
+
};
|
318
|
+
const [rest3, className] = getComponentProps(
|
319
|
+
[computedActiveDot, dotProperties],
|
320
|
+
activeDotClassName
|
321
|
+
)(theme);
|
322
|
+
resolvedActiveDot = {
|
323
|
+
className: (0, import_utils2.cx)("ui-radar-chart__active-dot", className),
|
324
|
+
fill: color,
|
325
|
+
stroke: color,
|
326
|
+
r: 4,
|
327
|
+
...rest3
|
328
|
+
};
|
329
|
+
} else {
|
330
|
+
resolvedActiveDot = false;
|
331
|
+
}
|
332
|
+
let resolvedDot;
|
333
|
+
if (withDots) {
|
334
|
+
const computedDimDot = { ...dimDotProps, ...dimDot2 };
|
335
|
+
const computedDot = {
|
336
|
+
...dotProps,
|
337
|
+
...dot2,
|
338
|
+
...dimmed ? computedDimDot : {}
|
339
|
+
};
|
340
|
+
const [rest3, className] = getComponentProps(
|
341
|
+
[computedDot, dotProperties],
|
342
|
+
dotClassName,
|
343
|
+
dimmed ? dimDotClassName : void 0
|
344
|
+
)(theme);
|
345
|
+
resolvedDot = {
|
346
|
+
// BUG: className is not applied.
|
347
|
+
className: (0, import_utils2.cx)("ui-radar-chart__dot", className),
|
348
|
+
fill: color,
|
349
|
+
r: 4,
|
350
|
+
...rest3
|
351
|
+
};
|
352
|
+
} else {
|
353
|
+
resolvedDot = false;
|
354
|
+
}
|
355
|
+
return {
|
356
|
+
...rest2,
|
357
|
+
color,
|
358
|
+
dataKey: dataKey2,
|
359
|
+
dot: resolvedDot,
|
360
|
+
activeDot: resolvedActiveDot
|
361
|
+
};
|
362
|
+
}),
|
363
|
+
[
|
364
|
+
activeDotClassName,
|
365
|
+
activeDotProps,
|
366
|
+
dimDotClassName,
|
367
|
+
dimDotProps,
|
368
|
+
dimRadarClassName,
|
369
|
+
dimRadarProps,
|
370
|
+
dotClassName,
|
371
|
+
dotProps,
|
372
|
+
highlightedArea,
|
373
|
+
radarClassName,
|
374
|
+
radarProps,
|
375
|
+
series,
|
376
|
+
shouldHighlight,
|
377
|
+
theme,
|
378
|
+
withActiveDots,
|
379
|
+
withDots
|
380
|
+
]
|
381
|
+
);
|
382
|
+
const getRadarChartProps = (0, import_react.useCallback)(
|
383
|
+
({ className, ...props } = {}, ref = null) => ({
|
384
|
+
ref,
|
385
|
+
className: (0, import_utils2.cx)(className, radarChartClassName),
|
386
|
+
data,
|
387
|
+
...props,
|
388
|
+
...radarChartProps
|
389
|
+
}),
|
390
|
+
[data, radarChartClassName, radarChartProps]
|
391
|
+
);
|
392
|
+
const getRadarProps = (0, import_react.useCallback)(
|
393
|
+
({ index, className: classNameProp, ...props }, ref = null) => {
|
394
|
+
const { color, className, dataKey: dataKey2, activeDot: activeDot2, dot: dot2, ...rest2 } = radarPropList[index];
|
395
|
+
return {
|
396
|
+
ref,
|
397
|
+
className: (0, import_utils2.cx)(classNameProp, className),
|
398
|
+
activeDot: activeDot2,
|
399
|
+
dot: dot2,
|
400
|
+
name: dataKey2,
|
401
|
+
dataKey: dataKey2,
|
402
|
+
fill: color,
|
403
|
+
strokeWidth,
|
404
|
+
stroke: color,
|
405
|
+
isAnimationActive: false,
|
406
|
+
...props,
|
407
|
+
...rest2
|
408
|
+
};
|
409
|
+
},
|
410
|
+
[radarPropList, strokeWidth]
|
411
|
+
);
|
412
|
+
const getPolarGridProps = (0, import_react.useCallback)(
|
413
|
+
({ className, ...props } = {}, ref = null) => ({
|
414
|
+
ref,
|
415
|
+
// BUG: `.recharts-polar-grid-concentric-xxx` is not applied className.
|
416
|
+
className: (0, import_utils2.cx)(className, polarGridClassName),
|
417
|
+
...props,
|
418
|
+
...polarGridProps
|
419
|
+
}),
|
420
|
+
[polarGridClassName, polarGridProps]
|
421
|
+
);
|
422
|
+
const getPolarAngleAxisProps = (0, import_react.useCallback)(
|
423
|
+
({ className, ...props } = {}, ref = null) => ({
|
424
|
+
ref,
|
425
|
+
// BUG: className is not applied.
|
426
|
+
// className: cx(className, polarAngleAxisClassName),
|
427
|
+
className,
|
428
|
+
dataKey,
|
429
|
+
tickFormatter: valueFormatter,
|
430
|
+
tickSize: 16,
|
431
|
+
...props,
|
432
|
+
...polarAngleAxisProps
|
433
|
+
}),
|
434
|
+
[
|
435
|
+
dataKey,
|
436
|
+
// polarAngleAxisClassName,
|
437
|
+
polarAngleAxisProps,
|
438
|
+
valueFormatter
|
439
|
+
]
|
440
|
+
);
|
441
|
+
const getPolarRadiusAxisProps = (0, import_react.useCallback)(
|
442
|
+
({ className, ...props } = {}, ref = null) => ({
|
443
|
+
ref,
|
444
|
+
// BUG: className is not applied.
|
445
|
+
// className: cx(className, polarRadiusAxisClassName),
|
446
|
+
className,
|
447
|
+
tickFormatter: valueFormatter,
|
448
|
+
...props,
|
449
|
+
...polarRadiusAxisProps
|
450
|
+
}),
|
451
|
+
[
|
452
|
+
// polarRadiusAxisClassName,
|
453
|
+
polarRadiusAxisProps,
|
454
|
+
valueFormatter
|
455
|
+
]
|
456
|
+
);
|
457
|
+
return {
|
458
|
+
radarVars,
|
459
|
+
getRadarChartProps,
|
460
|
+
getRadarProps,
|
461
|
+
getPolarGridProps,
|
462
|
+
getPolarAngleAxisProps,
|
463
|
+
getPolarRadiusAxisProps,
|
464
|
+
setHighlightedArea
|
465
|
+
};
|
466
|
+
};
|
467
|
+
// Annotate the CommonJS export names for ESM import in node:
|
468
|
+
0 && (module.exports = {
|
469
|
+
useRadarChart
|
470
|
+
});
|
471
|
+
//# sourceMappingURL=use-radar-chart.js.map
|