@lobehub/charts 5.2.0 → 5.3.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/es/BarChart/renderShape.d.ts +2 -1
- package/es/ComposedChart/index.js +34 -33
- package/es/DonutChart/DonutChartTooltip.d.ts +2 -1
- package/es/DonutChart/renderInactiveShape.d.ts +2 -1
- package/es/FunnelChart/ArrowRightIcon.d.ts +2 -1
- package/es/RadarChart/index.d.ts +24 -0
- package/es/RadarChart/index.js +254 -0
- package/es/RadarChart/styles.d.ts +5 -0
- package/es/RadarChart/styles.js +12 -0
- package/es/ScatterChart/renderShape.d.ts +2 -1
- package/es/common/ChartLegend.d.ts +1 -1
- package/es/common/ChartTooltip/index.d.ts +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/package.json +4 -4
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const renderShape: (props: any, activeBar: any | undefined, activeLegend: string | undefined, layout: string) => import("react").JSX.Element;
|
|
@@ -253,40 +253,9 @@ var ComposedChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
253
253
|
},
|
|
254
254
|
children: yAxisRight.label
|
|
255
255
|
})
|
|
256
|
-
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
257
|
-
content: showTooltip ? function (_ref) {
|
|
258
|
-
var active = _ref.active,
|
|
259
|
-
payload = _ref.payload,
|
|
260
|
-
label = _ref.label;
|
|
261
|
-
return /*#__PURE__*/_jsx(ChartTooltip, {
|
|
262
|
-
active: active,
|
|
263
|
-
categoryColors: categoryColors,
|
|
264
|
-
customCategories: customCategories,
|
|
265
|
-
label: label,
|
|
266
|
-
payload: payload,
|
|
267
|
-
valueFormatter: function valueFormatter(value, name) {
|
|
268
|
-
var _ref2, _currentSeries$valueF;
|
|
269
|
-
var currentSeries = series.find(function (item) {
|
|
270
|
-
return item.key === name;
|
|
271
|
-
});
|
|
272
|
-
var formatter = (_ref2 = (_currentSeries$valueF = currentSeries === null || currentSeries === void 0 ? void 0 : currentSeries.valueFormatter) !== null && _currentSeries$valueF !== void 0 ? _currentSeries$valueF : (currentSeries === null || currentSeries === void 0 ? void 0 : currentSeries.axis) === 'right' ? yAxisRight === null || yAxisRight === void 0 ? void 0 : yAxisRight.valueFormatter : yAxisLeft === null || yAxisLeft === void 0 ? void 0 : yAxisLeft.valueFormatter) !== null && _ref2 !== void 0 ? _ref2 : defaultValueFormatter;
|
|
273
|
-
return formatter(value);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
} : undefined,
|
|
277
|
-
cursor: {
|
|
278
|
-
fill: cssVar.colorFillTertiary
|
|
279
|
-
},
|
|
280
|
-
isAnimationActive: false,
|
|
281
|
-
position: {
|
|
282
|
-
y: 0
|
|
283
|
-
},
|
|
284
|
-
wrapperStyle: {
|
|
285
|
-
outline: 'none'
|
|
286
|
-
}
|
|
287
256
|
}), showLegend && /*#__PURE__*/_jsx(Legend, {
|
|
288
|
-
content: function content(
|
|
289
|
-
var payload =
|
|
257
|
+
content: function content(_ref) {
|
|
258
|
+
var payload = _ref.payload;
|
|
290
259
|
return ChartLegend({
|
|
291
260
|
payload: payload
|
|
292
261
|
}, categoryColors, setLegendHeight, undefined, undefined, enableLegendSlider, customCategories);
|
|
@@ -323,6 +292,38 @@ var ComposedChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
323
292
|
}, s.key);
|
|
324
293
|
}
|
|
325
294
|
return null;
|
|
295
|
+
}), showTooltip && /*#__PURE__*/_jsx(Tooltip, {
|
|
296
|
+
content: function content(_ref2) {
|
|
297
|
+
var active = _ref2.active,
|
|
298
|
+
payload = _ref2.payload,
|
|
299
|
+
label = _ref2.label;
|
|
300
|
+
return /*#__PURE__*/_jsx(ChartTooltip, {
|
|
301
|
+
active: active,
|
|
302
|
+
categoryColors: categoryColors,
|
|
303
|
+
customCategories: customCategories,
|
|
304
|
+
label: label,
|
|
305
|
+
payload: payload,
|
|
306
|
+
valueFormatter: function valueFormatter(value, name) {
|
|
307
|
+
var _ref3, _currentSeries$valueF;
|
|
308
|
+
var currentSeries = series.find(function (item) {
|
|
309
|
+
return item.key === name;
|
|
310
|
+
});
|
|
311
|
+
var formatter = (_ref3 = (_currentSeries$valueF = currentSeries === null || currentSeries === void 0 ? void 0 : currentSeries.valueFormatter) !== null && _currentSeries$valueF !== void 0 ? _currentSeries$valueF : (currentSeries === null || currentSeries === void 0 ? void 0 : currentSeries.axis) === 'right' ? yAxisRight === null || yAxisRight === void 0 ? void 0 : yAxisRight.valueFormatter : yAxisLeft === null || yAxisLeft === void 0 ? void 0 : yAxisLeft.valueFormatter) !== null && _ref3 !== void 0 ? _ref3 : defaultValueFormatter;
|
|
312
|
+
return formatter(value);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
},
|
|
316
|
+
cursor: {
|
|
317
|
+
stroke: cssVar.colorTextSecondary,
|
|
318
|
+
strokeWidth: 1
|
|
319
|
+
},
|
|
320
|
+
isAnimationActive: false,
|
|
321
|
+
position: {
|
|
322
|
+
y: 0
|
|
323
|
+
},
|
|
324
|
+
wrapperStyle: {
|
|
325
|
+
outline: 'none'
|
|
326
|
+
}
|
|
326
327
|
})]
|
|
327
328
|
}) : /*#__PURE__*/_jsx(NoData, {
|
|
328
329
|
noDataText: noDataText
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ValueFormatter } from "../types/charts";
|
|
2
3
|
export interface DonutChartTooltipProps {
|
|
3
4
|
active: boolean | undefined;
|
|
@@ -7,4 +8,4 @@ export interface DonutChartTooltipProps {
|
|
|
7
8
|
payload: any;
|
|
8
9
|
valueFormatter: ValueFormatter;
|
|
9
10
|
}
|
|
10
|
-
export declare const DonutChartTooltip: ({ customCategories, active, payload, valueFormatter, }: DonutChartTooltipProps) =>
|
|
11
|
+
export declare const DonutChartTooltip: ({ customCategories, active, payload, valueFormatter, }: DonutChartTooltipProps) => React.JSX.Element | null;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const renderInactiveShape: (props: any) => import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import BaseChartProps from "../common/BaseChartProps";
|
|
3
|
+
export interface RadarChartProps extends BaseChartProps {
|
|
4
|
+
/**
|
|
5
|
+
* Format angle-axis labels. Receives the index value and the matching data row.
|
|
6
|
+
* Can return a string or ReactNode (e.g. colored `<tspan>`).
|
|
7
|
+
*/
|
|
8
|
+
angleAxisLabelFormatter?: (value: string | number, payload?: Record<string, any>) => ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* When true, series after the first are rendered at `secondaryOpacity`.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
dimSecondarySeries?: boolean;
|
|
14
|
+
fillOpacity?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Opacity applied to series after the first when `dimSecondarySeries` is enabled.
|
|
17
|
+
* @default 0.25
|
|
18
|
+
*/
|
|
19
|
+
secondaryOpacity?: number;
|
|
20
|
+
shape?: 'polygon' | 'circle';
|
|
21
|
+
showRadiusAxis?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const RadarChart: import("react").ForwardRefExoticComponent<RadarChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
24
|
+
export default RadarChart;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _excluded = ["data", "categories", "customCategories", "index", "colors", "valueFormatter", "animationDuration", "showAnimation", "showTooltip", "showLegend", "showGridLines", "autoMinValue", "minValue", "maxValue", "allowDecimals", "noDataText", "onValueChange", "enableLegendSlider", "customTooltip", "loading", "className", "width", "height", "style", "shape", "fillOpacity", "showRadiusAxis", "dimSecondarySeries", "secondaryOpacity", "angleAxisLabelFormatter", "xAxisLabelFormatter", "yAxisDomain"];
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
22
|
+
import { Flexbox, Skeleton } from '@lobehub/ui';
|
|
23
|
+
import { cssVar } from 'antd-style';
|
|
24
|
+
import { forwardRef, useState } from 'react';
|
|
25
|
+
import { Legend, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart as ReChartsRadarChart, ResponsiveContainer, Tooltip } from 'recharts';
|
|
26
|
+
import ChartLegend from "../common/ChartLegend";
|
|
27
|
+
import ChartTooltip from "../common/ChartTooltip";
|
|
28
|
+
import NoData from "../common/NoData";
|
|
29
|
+
import { constructCategoryColors, getYAxisDomain } from "../common/utils";
|
|
30
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange";
|
|
31
|
+
import { defaultValueFormatter } from "../utils";
|
|
32
|
+
import { styles } from "./styles";
|
|
33
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
|
+
var RadarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
36
|
+
var themeColorRange = useThemeColorRange();
|
|
37
|
+
var _props$data = props.data,
|
|
38
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
39
|
+
_props$categories = props.categories,
|
|
40
|
+
categories = _props$categories === void 0 ? [] : _props$categories,
|
|
41
|
+
customCategories = props.customCategories,
|
|
42
|
+
index = props.index,
|
|
43
|
+
_props$colors = props.colors,
|
|
44
|
+
colors = _props$colors === void 0 ? themeColorRange : _props$colors,
|
|
45
|
+
_props$valueFormatter = props.valueFormatter,
|
|
46
|
+
valueFormatter = _props$valueFormatter === void 0 ? defaultValueFormatter : _props$valueFormatter,
|
|
47
|
+
_props$animationDurat = props.animationDuration,
|
|
48
|
+
animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
|
|
49
|
+
_props$showAnimation = props.showAnimation,
|
|
50
|
+
showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
|
|
51
|
+
_props$showTooltip = props.showTooltip,
|
|
52
|
+
showTooltip = _props$showTooltip === void 0 ? true : _props$showTooltip,
|
|
53
|
+
_props$showLegend = props.showLegend,
|
|
54
|
+
showLegend = _props$showLegend === void 0 ? true : _props$showLegend,
|
|
55
|
+
_props$showGridLines = props.showGridLines,
|
|
56
|
+
showGridLines = _props$showGridLines === void 0 ? true : _props$showGridLines,
|
|
57
|
+
_props$autoMinValue = props.autoMinValue,
|
|
58
|
+
autoMinValue = _props$autoMinValue === void 0 ? false : _props$autoMinValue,
|
|
59
|
+
minValue = props.minValue,
|
|
60
|
+
maxValue = props.maxValue,
|
|
61
|
+
_props$allowDecimals = props.allowDecimals,
|
|
62
|
+
allowDecimals = _props$allowDecimals === void 0 ? true : _props$allowDecimals,
|
|
63
|
+
noDataText = props.noDataText,
|
|
64
|
+
onValueChange = props.onValueChange,
|
|
65
|
+
_props$enableLegendSl = props.enableLegendSlider,
|
|
66
|
+
enableLegendSlider = _props$enableLegendSl === void 0 ? false : _props$enableLegendSl,
|
|
67
|
+
customTooltip = props.customTooltip,
|
|
68
|
+
loading = props.loading,
|
|
69
|
+
className = props.className,
|
|
70
|
+
_props$width = props.width,
|
|
71
|
+
width = _props$width === void 0 ? '100%' : _props$width,
|
|
72
|
+
_props$height = props.height,
|
|
73
|
+
height = _props$height === void 0 ? 280 : _props$height,
|
|
74
|
+
style = props.style,
|
|
75
|
+
_props$shape = props.shape,
|
|
76
|
+
shape = _props$shape === void 0 ? 'polygon' : _props$shape,
|
|
77
|
+
_props$fillOpacity = props.fillOpacity,
|
|
78
|
+
fillOpacity = _props$fillOpacity === void 0 ? 0.33 : _props$fillOpacity,
|
|
79
|
+
_props$showRadiusAxis = props.showRadiusAxis,
|
|
80
|
+
showRadiusAxis = _props$showRadiusAxis === void 0 ? false : _props$showRadiusAxis,
|
|
81
|
+
_props$dimSecondarySe = props.dimSecondarySeries,
|
|
82
|
+
dimSecondarySeries = _props$dimSecondarySe === void 0 ? true : _props$dimSecondarySe,
|
|
83
|
+
_props$secondaryOpaci = props.secondaryOpacity,
|
|
84
|
+
secondaryOpacity = _props$secondaryOpaci === void 0 ? 0.25 : _props$secondaryOpaci,
|
|
85
|
+
angleAxisLabelFormatter = props.angleAxisLabelFormatter,
|
|
86
|
+
xAxisLabelFormatter = props.xAxisLabelFormatter,
|
|
87
|
+
yAxisDomainOverride = props.yAxisDomain,
|
|
88
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
89
|
+
var _useState = useState(),
|
|
90
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
91
|
+
activeLegend = _useState2[0],
|
|
92
|
+
setActiveLegend = _useState2[1];
|
|
93
|
+
var _useState3 = useState(60),
|
|
94
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
95
|
+
legendHeight = _useState4[0],
|
|
96
|
+
setLegendHeight = _useState4[1];
|
|
97
|
+
if (loading || !data) return /*#__PURE__*/_jsx(Skeleton.Block, {
|
|
98
|
+
active: true,
|
|
99
|
+
height: height,
|
|
100
|
+
width: width
|
|
101
|
+
});
|
|
102
|
+
var CustomTooltip = customTooltip;
|
|
103
|
+
var categoryColors = constructCategoryColors(categories, colors);
|
|
104
|
+
var hasOnValueChange = !!onValueChange;
|
|
105
|
+
var yAxisDomain = yAxisDomainOverride !== null && yAxisDomainOverride !== void 0 ? yAxisDomainOverride : getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
106
|
+
var onCategoryClick = function onCategoryClick(dataKey) {
|
|
107
|
+
if (!hasOnValueChange) return;
|
|
108
|
+
if (dataKey === activeLegend) {
|
|
109
|
+
setActiveLegend(undefined);
|
|
110
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
111
|
+
} else {
|
|
112
|
+
setActiveLegend(dataKey);
|
|
113
|
+
onValueChange === null || onValueChange === void 0 || onValueChange({
|
|
114
|
+
categoryClicked: dataKey,
|
|
115
|
+
eventType: 'category'
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
120
|
+
className: className,
|
|
121
|
+
height: height,
|
|
122
|
+
ref: ref,
|
|
123
|
+
style: _objectSpread({
|
|
124
|
+
position: 'relative'
|
|
125
|
+
}, style),
|
|
126
|
+
width: width
|
|
127
|
+
}, rest), {}, {
|
|
128
|
+
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
129
|
+
children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsRadarChart, {
|
|
130
|
+
data: data,
|
|
131
|
+
margin: {
|
|
132
|
+
bottom: 10,
|
|
133
|
+
left: 10,
|
|
134
|
+
right: 10,
|
|
135
|
+
top: 10
|
|
136
|
+
},
|
|
137
|
+
onClick: hasOnValueChange && activeLegend ? function () {
|
|
138
|
+
setActiveLegend(undefined);
|
|
139
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
140
|
+
} : undefined,
|
|
141
|
+
children: [showGridLines ? /*#__PURE__*/_jsx(PolarGrid, {
|
|
142
|
+
className: styles.gridLines,
|
|
143
|
+
fill: "none",
|
|
144
|
+
gridType: shape,
|
|
145
|
+
stroke: cssVar.colorBorderSecondary
|
|
146
|
+
}) : undefined, /*#__PURE__*/_jsx(PolarAngleAxis, {
|
|
147
|
+
axisLine: false,
|
|
148
|
+
className: styles.label,
|
|
149
|
+
dataKey: index,
|
|
150
|
+
tick: function tick(tickProps) {
|
|
151
|
+
var x = tickProps.x,
|
|
152
|
+
y = tickProps.y,
|
|
153
|
+
textAnchor = tickProps.textAnchor,
|
|
154
|
+
tickPayload = tickProps.payload;
|
|
155
|
+
var value = tickPayload === null || tickPayload === void 0 ? void 0 : tickPayload.value;
|
|
156
|
+
var row = data.find(function (item) {
|
|
157
|
+
return item[index] === value;
|
|
158
|
+
});
|
|
159
|
+
var content = value;
|
|
160
|
+
if (angleAxisLabelFormatter) {
|
|
161
|
+
content = angleAxisLabelFormatter(value, row);
|
|
162
|
+
} else if (xAxisLabelFormatter) {
|
|
163
|
+
content = xAxisLabelFormatter(value);
|
|
164
|
+
}
|
|
165
|
+
return /*#__PURE__*/_jsx("text", {
|
|
166
|
+
className: "recharts-polar-angle-axis-tick-value",
|
|
167
|
+
fill: cssVar.colorTextDescription,
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
textAnchor: textAnchor,
|
|
170
|
+
x: x,
|
|
171
|
+
y: y,
|
|
172
|
+
children: content
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
tickLine: false
|
|
176
|
+
}), /*#__PURE__*/_jsx(PolarRadiusAxis, {
|
|
177
|
+
allowDecimals: allowDecimals,
|
|
178
|
+
axisLine: false,
|
|
179
|
+
className: styles.radiusLabel,
|
|
180
|
+
domain: yAxisDomain,
|
|
181
|
+
stroke: cssVar.colorTextQuaternary,
|
|
182
|
+
tick: showRadiusAxis,
|
|
183
|
+
tickFormatter: valueFormatter,
|
|
184
|
+
tickLine: false
|
|
185
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
186
|
+
content: showTooltip ? function (_ref) {
|
|
187
|
+
var active = _ref.active,
|
|
188
|
+
payload = _ref.payload,
|
|
189
|
+
label = _ref.label;
|
|
190
|
+
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
191
|
+
active: active,
|
|
192
|
+
customCategories: customCategories,
|
|
193
|
+
label: label,
|
|
194
|
+
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
195
|
+
var _categoryColors$get;
|
|
196
|
+
return _objectSpread(_objectSpread({}, payloadItem), {}, {
|
|
197
|
+
color: (_categoryColors$get = categoryColors.get(payloadItem.dataKey)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : cssVar.colorPrimary
|
|
198
|
+
});
|
|
199
|
+
}),
|
|
200
|
+
valueFormatter: valueFormatter
|
|
201
|
+
}) : /*#__PURE__*/_jsx(ChartTooltip, {
|
|
202
|
+
active: active,
|
|
203
|
+
categoryColors: categoryColors,
|
|
204
|
+
customCategories: customCategories,
|
|
205
|
+
label: label,
|
|
206
|
+
payload: payload,
|
|
207
|
+
valueFormatter: valueFormatter
|
|
208
|
+
});
|
|
209
|
+
} : undefined,
|
|
210
|
+
isAnimationActive: false,
|
|
211
|
+
wrapperStyle: {
|
|
212
|
+
outline: 'none'
|
|
213
|
+
}
|
|
214
|
+
}), showLegend ? /*#__PURE__*/_jsx(Legend, {
|
|
215
|
+
content: function content(_ref2) {
|
|
216
|
+
var payload = _ref2.payload;
|
|
217
|
+
return ChartLegend({
|
|
218
|
+
payload: payload === null || payload === void 0 ? void 0 : payload.slice().reverse()
|
|
219
|
+
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
220
|
+
return onCategoryClick(clickedLegendItem);
|
|
221
|
+
} : undefined, enableLegendSlider, customCategories);
|
|
222
|
+
},
|
|
223
|
+
height: legendHeight,
|
|
224
|
+
verticalAlign: "top"
|
|
225
|
+
}) : undefined, _toConsumableArray(categories).reverse().map(function (category) {
|
|
226
|
+
var _categoryColors$get2;
|
|
227
|
+
var isInactive = Boolean(activeLegend && activeLegend !== category);
|
|
228
|
+
var isSecondary = dimSecondarySeries && category !== categories[0];
|
|
229
|
+
var seriesFillOpacity = isSecondary ? fillOpacity * secondaryOpacity : fillOpacity;
|
|
230
|
+
var seriesStrokeOpacity = isSecondary ? secondaryOpacity : 1;
|
|
231
|
+
var color = (_categoryColors$get2 = categoryColors.get(category)) !== null && _categoryColors$get2 !== void 0 ? _categoryColors$get2 : cssVar.colorPrimary;
|
|
232
|
+
return /*#__PURE__*/_jsx(Radar, {
|
|
233
|
+
animationDuration: animationDuration,
|
|
234
|
+
dataKey: category,
|
|
235
|
+
fill: color,
|
|
236
|
+
fillOpacity: isInactive ? seriesFillOpacity * 0.3 : seriesFillOpacity,
|
|
237
|
+
isAnimationActive: showAnimation,
|
|
238
|
+
name: category,
|
|
239
|
+
stroke: color,
|
|
240
|
+
strokeOpacity: isInactive ? seriesStrokeOpacity * 0.3 : seriesStrokeOpacity,
|
|
241
|
+
strokeWidth: 2,
|
|
242
|
+
style: {
|
|
243
|
+
cursor: onValueChange ? 'pointer' : undefined
|
|
244
|
+
}
|
|
245
|
+
}, category);
|
|
246
|
+
})]
|
|
247
|
+
}) : /*#__PURE__*/_jsx(NoData, {
|
|
248
|
+
noDataText: noDataText
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
}));
|
|
252
|
+
});
|
|
253
|
+
RadarChart.displayName = 'RadarChart';
|
|
254
|
+
export default RadarChart;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { createStaticStyles } from 'antd-style';
|
|
4
|
+
export var styles = createStaticStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
cssVar = _ref.cssVar;
|
|
7
|
+
return {
|
|
8
|
+
gridLines: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n fill: none;\n stroke: ", ";\n stroke-width: 1;\n "])), cssVar.colorBorderSecondary),
|
|
9
|
+
label: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 12px;\n line-height: 16px;\n fill: ", ";\n "])), cssVar.colorTextDescription),
|
|
10
|
+
radiusLabel: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 12px;\n line-height: 16px;\n fill: ", ";\n "])), cssVar.colorTextQuaternary)
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const renderShape: (props: any, activeNode: any | undefined, activeLegend: string | undefined) => React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
declare const ChartLegend: ({ payload }: any, categoryColors: Map<string, string>, setLegendHeight: Dispatch<SetStateAction<number>>, activeLegend: string | undefined, onClick?: ((category: string, color: string) => void) | undefined, enableLegendSlider?: boolean, customCategories?: {
|
|
3
3
|
[key: string]: string;
|
|
4
|
-
} | undefined) => import("react
|
|
4
|
+
} | undefined) => import("react").JSX.Element;
|
|
5
5
|
export default ChartLegend;
|
|
@@ -11,5 +11,5 @@ export interface ChartTooltipProps {
|
|
|
11
11
|
payload: any;
|
|
12
12
|
valueFormatter: ValueFormatter | ((value: number, name?: string) => string);
|
|
13
13
|
}
|
|
14
|
-
declare const ChartTooltip: ({ active, payload, label, categoryColors, valueFormatter, customCategories, footer, }: ChartTooltipProps) => import("react
|
|
14
|
+
declare const ChartTooltip: ({ active, payload, label, categoryColors, valueFormatter, customCategories, footer, }: ChartTooltipProps) => import("react").JSX.Element | null;
|
|
15
15
|
export default ChartTooltip;
|
package/es/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { default as FunnelChart, type FunnelChartProps } from './FunnelChart';
|
|
|
12
12
|
export { default as Heatmaps, type HeatmapsProps } from './Heatmaps';
|
|
13
13
|
export { default as Legend, type LegendProps } from './Legend';
|
|
14
14
|
export { default as LineChart, type LineChartProps } from './LineChart';
|
|
15
|
+
export { default as RadarChart, type RadarChartProps } from './RadarChart';
|
|
15
16
|
export { default as ScatterChart, type ScatterChartProps } from './ScatterChart';
|
|
16
17
|
export * from './SparkChart';
|
|
17
18
|
export { default as Tracker, type TrackerProps } from './Tracker';
|
package/es/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { default as FunnelChart } from "./FunnelChart";
|
|
|
12
12
|
export { default as Heatmaps } from "./Heatmaps";
|
|
13
13
|
export { default as Legend } from "./Legend";
|
|
14
14
|
export { default as LineChart } from "./LineChart";
|
|
15
|
+
export { default as RadarChart } from "./RadarChart";
|
|
15
16
|
export { default as ScatterChart } from "./ScatterChart";
|
|
16
17
|
export * from "./SparkChart";
|
|
17
18
|
export { default as Tracker } from "./Tracker";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/charts",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "React modern charts components built on recharts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"es"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"ahooks": "^3.9.
|
|
29
|
+
"ahooks": "^3.9.7",
|
|
30
30
|
"antd-style": "^4.1.0",
|
|
31
31
|
"chroma-js": "^3.2.0",
|
|
32
|
-
"date-fns": "^4.
|
|
33
|
-
"dayjs": "^1.11.
|
|
32
|
+
"date-fns": "^4.4.0",
|
|
33
|
+
"dayjs": "^1.11.21",
|
|
34
34
|
"fast-deep-equal": "^3.1.3",
|
|
35
35
|
"lucide-react": "^0.562.0",
|
|
36
36
|
"polished": "^4.3.1",
|