@lobehub/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 +218 -0
- package/es/AreaChart/index.d.ts +11 -0
- package/es/AreaChart/index.js +388 -0
- package/es/AreaChart/styles.d.ts +6 -0
- package/es/AreaChart/styles.js +13 -0
- package/es/BarChart/index.d.ts +10 -0
- package/es/BarChart/index.js +354 -0
- package/es/BarChart/renderShape.d.ts +1 -0
- package/es/BarChart/renderShape.js +29 -0
- package/es/BarChart/styles.d.ts +6 -0
- package/es/BarChart/styles.js +13 -0
- package/es/DonutChart/DonutChartTooltip.d.ts +7 -0
- package/es/DonutChart/DonutChartTooltip.js +25 -0
- package/es/DonutChart/index.d.ts +25 -0
- package/es/DonutChart/index.js +186 -0
- package/es/DonutChart/inputParser.d.ts +2 -0
- package/es/DonutChart/inputParser.js +9 -0
- package/es/DonutChart/renderInactiveShape.d.ts +1 -0
- package/es/DonutChart/renderInactiveShape.js +27 -0
- package/es/DonutChart/styles.d.ts +6 -0
- package/es/DonutChart/styles.js +13 -0
- package/es/LineChart/index.d.ts +9 -0
- package/es/LineChart/index.js +347 -0
- package/es/LineChart/styles.d.ts +6 -0
- package/es/LineChart/styles.js +13 -0
- package/es/ScatterChart/ScatterChartTooltip.d.ts +13 -0
- package/es/ScatterChart/ScatterChartTooltip.js +83 -0
- package/es/ScatterChart/ScatterChartTooltipRow.d.ts +7 -0
- package/es/ScatterChart/ScatterChartTooltipRow.js +43 -0
- package/es/ScatterChart/index.d.ts +51 -0
- package/es/ScatterChart/index.js +304 -0
- package/es/ScatterChart/renderShape.d.ts +1 -0
- package/es/ScatterChart/renderShape.js +18 -0
- package/es/ScatterChart/styles.d.ts +6 -0
- package/es/ScatterChart/styles.js +13 -0
- package/es/common/BaseAnimationTimingProps.d.ts +7 -0
- package/es/common/BaseAnimationTimingProps.js +1 -0
- package/es/common/BaseChartProps.d.ts +47 -0
- package/es/common/BaseChartProps.js +1 -0
- package/es/common/ChartLegend.d.ts +3 -0
- package/es/common/ChartLegend.js +39 -0
- package/es/common/ChartTooltip/ChartTooltipFrame.d.ts +7 -0
- package/es/common/ChartTooltip/ChartTooltipFrame.js +28 -0
- package/es/common/ChartTooltip/ChartTooltipRow.d.ts +8 -0
- package/es/common/ChartTooltip/ChartTooltipRow.js +58 -0
- package/es/common/ChartTooltip/index.d.ts +10 -0
- package/es/common/ChartTooltip/index.js +65 -0
- package/es/common/CustomTooltipProps.d.ts +6 -0
- package/es/common/CustomTooltipProps.js +1 -0
- package/es/common/NoData.d.ts +10 -0
- package/es/common/NoData.js +43 -0
- package/es/common/utils.d.ts +5 -0
- package/es/common/utils.js +77 -0
- package/es/components/Legend/LegendItem.d.ts +9 -0
- package/es/components/Legend/LegendItem.js +65 -0
- package/es/components/Legend/ScrollButton.d.ts +9 -0
- package/es/components/Legend/ScrollButton.js +58 -0
- package/es/components/Legend/index.d.ts +11 -0
- package/es/components/Legend/index.js +173 -0
- package/es/hooks/useOnWindowResize.d.ts +3 -0
- package/es/hooks/useOnWindowResize.js +14 -0
- package/es/hooks/useThemeColorRange.d.ts +1 -0
- package/es/hooks/useThemeColorRange.js +5 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +7 -0
- package/es/types.d.ts +20 -0
- package/es/types.js +1 -0
- package/es/utils/index.d.ts +3 -0
- package/es/utils/index.js +8 -0
- package/package.json +119 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
|
+
var _templateObject, _templateObject2;
|
|
8
|
+
var _excluded = ["data", "x", "y", "size", "category", "colors", "showOpacity", "sizeRange", "valueFormatter", "startEndOnly", "showXAxis", "showYAxis", "yAxisWidth", "intervalType", "animationDuration", "showAnimation", "showTooltip", "showLegend", "showGridLines", "autoMinXValue", "minXValue", "maxXValue", "autoMinYValue", "minYValue", "maxYValue", "allowDecimals", "noDataText", "onValueChange", "customTooltip", "rotateLabelX", "className", "enableLegendSlider", "tickGap", "xAxisLabel", "yAxisLabel", "width", "height"];
|
|
9
|
+
import { css } from 'antd-style';
|
|
10
|
+
import { forwardRef, useState } from 'react';
|
|
11
|
+
import { Flexbox } from 'react-layout-kit';
|
|
12
|
+
import { CartesianGrid, Label, Legend, ScatterChart as ReChartsScatterChart, ResponsiveContainer, Scatter, Tooltip, XAxis, YAxis, ZAxis } from 'recharts';
|
|
13
|
+
import { renderShape } from "./renderShape";
|
|
14
|
+
import ChartLegend from "../common/ChartLegend";
|
|
15
|
+
import { constructCategories, constructCategoryColors, deepEqual, getYAxisDomain } from "../common/utils";
|
|
16
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange";
|
|
17
|
+
import { defaultValueFormatter } from "../utils";
|
|
18
|
+
import NoData from "../common/NoData";
|
|
19
|
+
import ScatterChartTooltip from "./ScatterChartTooltip";
|
|
20
|
+
import { useStyles } from "./styles";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
+
var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
24
|
+
var _useStyles = useStyles(),
|
|
25
|
+
cx = _useStyles.cx,
|
|
26
|
+
theme = _useStyles.theme,
|
|
27
|
+
styles = _useStyles.styles;
|
|
28
|
+
var themeColorRange = useThemeColorRange();
|
|
29
|
+
var _props$data = props.data,
|
|
30
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
31
|
+
x = props.x,
|
|
32
|
+
y = props.y,
|
|
33
|
+
size = props.size,
|
|
34
|
+
category = props.category,
|
|
35
|
+
_props$colors = props.colors,
|
|
36
|
+
colors = _props$colors === void 0 ? themeColorRange : _props$colors,
|
|
37
|
+
_props$showOpacity = props.showOpacity,
|
|
38
|
+
showOpacity = _props$showOpacity === void 0 ? false : _props$showOpacity,
|
|
39
|
+
_props$sizeRange = props.sizeRange,
|
|
40
|
+
sizeRange = _props$sizeRange === void 0 ? [1, 1000] : _props$sizeRange,
|
|
41
|
+
_props$valueFormatter = props.valueFormatter,
|
|
42
|
+
valueFormatter = _props$valueFormatter === void 0 ? {
|
|
43
|
+
size: defaultValueFormatter,
|
|
44
|
+
x: defaultValueFormatter,
|
|
45
|
+
y: defaultValueFormatter
|
|
46
|
+
} : _props$valueFormatter,
|
|
47
|
+
_props$startEndOnly = props.startEndOnly,
|
|
48
|
+
startEndOnly = _props$startEndOnly === void 0 ? false : _props$startEndOnly,
|
|
49
|
+
_props$showXAxis = props.showXAxis,
|
|
50
|
+
showXAxis = _props$showXAxis === void 0 ? true : _props$showXAxis,
|
|
51
|
+
_props$showYAxis = props.showYAxis,
|
|
52
|
+
showYAxis = _props$showYAxis === void 0 ? true : _props$showYAxis,
|
|
53
|
+
_props$yAxisWidth = props.yAxisWidth,
|
|
54
|
+
yAxisWidth = _props$yAxisWidth === void 0 ? 56 : _props$yAxisWidth,
|
|
55
|
+
_props$intervalType = props.intervalType,
|
|
56
|
+
intervalType = _props$intervalType === void 0 ? 'equidistantPreserveStart' : _props$intervalType,
|
|
57
|
+
_props$animationDurat = props.animationDuration,
|
|
58
|
+
animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
|
|
59
|
+
_props$showAnimation = props.showAnimation,
|
|
60
|
+
showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
|
|
61
|
+
_props$showTooltip = props.showTooltip,
|
|
62
|
+
showTooltip = _props$showTooltip === void 0 ? true : _props$showTooltip,
|
|
63
|
+
_props$showLegend = props.showLegend,
|
|
64
|
+
showLegend = _props$showLegend === void 0 ? true : _props$showLegend,
|
|
65
|
+
_props$showGridLines = props.showGridLines,
|
|
66
|
+
showGridLines = _props$showGridLines === void 0 ? true : _props$showGridLines,
|
|
67
|
+
_props$autoMinXValue = props.autoMinXValue,
|
|
68
|
+
autoMinXValue = _props$autoMinXValue === void 0 ? false : _props$autoMinXValue,
|
|
69
|
+
minXValue = props.minXValue,
|
|
70
|
+
maxXValue = props.maxXValue,
|
|
71
|
+
_props$autoMinYValue = props.autoMinYValue,
|
|
72
|
+
autoMinYValue = _props$autoMinYValue === void 0 ? false : _props$autoMinYValue,
|
|
73
|
+
minYValue = props.minYValue,
|
|
74
|
+
maxYValue = props.maxYValue,
|
|
75
|
+
_props$allowDecimals = props.allowDecimals,
|
|
76
|
+
allowDecimals = _props$allowDecimals === void 0 ? true : _props$allowDecimals,
|
|
77
|
+
noDataText = props.noDataText,
|
|
78
|
+
onValueChange = props.onValueChange,
|
|
79
|
+
customTooltip = props.customTooltip,
|
|
80
|
+
rotateLabelX = props.rotateLabelX,
|
|
81
|
+
className = props.className,
|
|
82
|
+
_props$enableLegendSl = props.enableLegendSlider,
|
|
83
|
+
enableLegendSlider = _props$enableLegendSl === void 0 ? false : _props$enableLegendSl,
|
|
84
|
+
_props$tickGap = props.tickGap,
|
|
85
|
+
tickGap = _props$tickGap === void 0 ? 5 : _props$tickGap,
|
|
86
|
+
xAxisLabel = props.xAxisLabel,
|
|
87
|
+
yAxisLabel = props.yAxisLabel,
|
|
88
|
+
_props$width = props.width,
|
|
89
|
+
width = _props$width === void 0 ? '100%' : _props$width,
|
|
90
|
+
_props$height = props.height,
|
|
91
|
+
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
92
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
93
|
+
var CustomTooltip = customTooltip;
|
|
94
|
+
var _useState = useState(60),
|
|
95
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
96
|
+
legendHeight = _useState2[0],
|
|
97
|
+
setLegendHeight = _useState2[1];
|
|
98
|
+
var _useState3 = useState(),
|
|
99
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
100
|
+
activeNode = _useState4[0],
|
|
101
|
+
setActiveNode = _useState4[1];
|
|
102
|
+
var _useState5 = useState(),
|
|
103
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
104
|
+
activeLegend = _useState6[0],
|
|
105
|
+
setActiveLegend = _useState6[1];
|
|
106
|
+
var hasOnValueChange = !!onValueChange;
|
|
107
|
+
function onNodeClick(data, index, event) {
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
if (!hasOnValueChange) return;
|
|
110
|
+
if (deepEqual(activeNode, data.node)) {
|
|
111
|
+
setActiveLegend(undefined);
|
|
112
|
+
setActiveNode(undefined);
|
|
113
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
114
|
+
} else {
|
|
115
|
+
setActiveNode(data.node);
|
|
116
|
+
setActiveLegend(data.payload[category]);
|
|
117
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(_objectSpread({
|
|
118
|
+
categoryClicked: data.payload[category],
|
|
119
|
+
eventType: 'bubble'
|
|
120
|
+
}, data.payload));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function onCategoryClick(dataKey) {
|
|
124
|
+
if (!hasOnValueChange) return;
|
|
125
|
+
if (dataKey === activeLegend && !activeNode) {
|
|
126
|
+
setActiveLegend(undefined);
|
|
127
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
128
|
+
} else {
|
|
129
|
+
setActiveLegend(dataKey);
|
|
130
|
+
onValueChange === null || onValueChange === void 0 || onValueChange({
|
|
131
|
+
categoryClicked: dataKey,
|
|
132
|
+
eventType: 'category'
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
setActiveNode(undefined);
|
|
136
|
+
}
|
|
137
|
+
var categories = constructCategories(data, category);
|
|
138
|
+
var categoryColors = constructCategoryColors(categories, colors);
|
|
139
|
+
|
|
140
|
+
//maybe rename getYAxisDomain to getAxisDomain
|
|
141
|
+
var xAxisDomain = getYAxisDomain(autoMinXValue, minXValue, maxXValue);
|
|
142
|
+
var yAxisDomain = getYAxisDomain(autoMinYValue, minYValue, maxYValue);
|
|
143
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
144
|
+
className: className,
|
|
145
|
+
height: height,
|
|
146
|
+
ref: ref,
|
|
147
|
+
width: width
|
|
148
|
+
}, rest), {}, {
|
|
149
|
+
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
150
|
+
children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsScatterChart, {
|
|
151
|
+
margin: {
|
|
152
|
+
bottom: xAxisLabel ? 20 : undefined,
|
|
153
|
+
left: 20,
|
|
154
|
+
right: 20,
|
|
155
|
+
top: 5
|
|
156
|
+
},
|
|
157
|
+
onClick: hasOnValueChange && (activeLegend || activeNode) ? function () {
|
|
158
|
+
setActiveNode(undefined);
|
|
159
|
+
setActiveLegend(undefined);
|
|
160
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
161
|
+
} : undefined,
|
|
162
|
+
children: [showGridLines ? /*#__PURE__*/_jsx(CartesianGrid, {
|
|
163
|
+
className: styles.gridLines,
|
|
164
|
+
horizontal: true,
|
|
165
|
+
vertical: true
|
|
166
|
+
}) : null, x ? /*#__PURE__*/_jsx(XAxis, {
|
|
167
|
+
allowDataOverflow: true,
|
|
168
|
+
angle: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.angle,
|
|
169
|
+
axisLine: false,
|
|
170
|
+
className: styles.label,
|
|
171
|
+
dataKey: x,
|
|
172
|
+
domain: xAxisDomain,
|
|
173
|
+
dy: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.verticalShift,
|
|
174
|
+
fill: "",
|
|
175
|
+
height: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.xAxisHeight,
|
|
176
|
+
hide: !showXAxis,
|
|
177
|
+
interval: startEndOnly ? 'preserveStartEnd' : intervalType,
|
|
178
|
+
minTickGap: tickGap,
|
|
179
|
+
name: x,
|
|
180
|
+
stroke: "",
|
|
181
|
+
tick: {
|
|
182
|
+
transform: 'translate(0, 6)'
|
|
183
|
+
},
|
|
184
|
+
tickFormatter: valueFormatter.x,
|
|
185
|
+
tickLine: false,
|
|
186
|
+
ticks: startEndOnly ? [data[0][x], data.at(-1)[x]] : undefined,
|
|
187
|
+
type: "number",
|
|
188
|
+
children: xAxisLabel && /*#__PURE__*/_jsx(Label, {
|
|
189
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
190
|
+
offset: -20,
|
|
191
|
+
position: "insideBottom",
|
|
192
|
+
children: xAxisLabel
|
|
193
|
+
})
|
|
194
|
+
}) : null, y ? /*#__PURE__*/_jsx(YAxis, {
|
|
195
|
+
allowDataOverflow: true,
|
|
196
|
+
allowDecimals: allowDecimals,
|
|
197
|
+
axisLine: false,
|
|
198
|
+
className: styles.label,
|
|
199
|
+
dataKey: y,
|
|
200
|
+
domain: yAxisDomain,
|
|
201
|
+
fill: "",
|
|
202
|
+
hide: !showYAxis,
|
|
203
|
+
name: y,
|
|
204
|
+
stroke: "",
|
|
205
|
+
tick: {
|
|
206
|
+
transform: 'translate(-3, 0)'
|
|
207
|
+
},
|
|
208
|
+
tickFormatter: valueFormatter.y,
|
|
209
|
+
tickLine: false,
|
|
210
|
+
type: "number",
|
|
211
|
+
width: yAxisWidth,
|
|
212
|
+
children: yAxisLabel && /*#__PURE__*/_jsx(Label, {
|
|
213
|
+
angle: -90,
|
|
214
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
215
|
+
offset: -15,
|
|
216
|
+
position: "insideLeft",
|
|
217
|
+
style: {
|
|
218
|
+
textAnchor: 'middle'
|
|
219
|
+
},
|
|
220
|
+
children: yAxisLabel
|
|
221
|
+
})
|
|
222
|
+
}) : null, /*#__PURE__*/_jsx(Tooltip, {
|
|
223
|
+
content: showTooltip ? function (_ref) {
|
|
224
|
+
var _payload$;
|
|
225
|
+
var active = _ref.active,
|
|
226
|
+
payload = _ref.payload,
|
|
227
|
+
label = _ref.label;
|
|
228
|
+
var color = category ? payload === null || payload === void 0 || (_payload$ = payload[0]) === null || _payload$ === void 0 || (_payload$ = _payload$.payload) === null || _payload$ === void 0 ? void 0 : _payload$[category] : label;
|
|
229
|
+
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
230
|
+
active: active,
|
|
231
|
+
label: color,
|
|
232
|
+
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
233
|
+
var _categoryColors$get;
|
|
234
|
+
return _objectSpread(_objectSpread({}, payloadItem), {}, {
|
|
235
|
+
color: (_categoryColors$get = categoryColors.get(color)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary
|
|
236
|
+
});
|
|
237
|
+
})
|
|
238
|
+
}) : /*#__PURE__*/_jsx(ScatterChartTooltip, {
|
|
239
|
+
active: active,
|
|
240
|
+
axis: {
|
|
241
|
+
size: size,
|
|
242
|
+
x: x,
|
|
243
|
+
y: y
|
|
244
|
+
},
|
|
245
|
+
category: category,
|
|
246
|
+
categoryColors: categoryColors,
|
|
247
|
+
label: color,
|
|
248
|
+
payload: payload,
|
|
249
|
+
valueFormatter: valueFormatter
|
|
250
|
+
});
|
|
251
|
+
} : undefined,
|
|
252
|
+
cursor: {
|
|
253
|
+
stroke: '#d1d5db',
|
|
254
|
+
strokeWidth: 1
|
|
255
|
+
},
|
|
256
|
+
isAnimationActive: false,
|
|
257
|
+
wrapperStyle: {
|
|
258
|
+
outline: 'none'
|
|
259
|
+
}
|
|
260
|
+
}), size ? /*#__PURE__*/_jsx(ZAxis, {
|
|
261
|
+
dataKey: size,
|
|
262
|
+
name: size,
|
|
263
|
+
range: sizeRange,
|
|
264
|
+
type: "number"
|
|
265
|
+
}) : null, categories.map(function (cat) {
|
|
266
|
+
var _categoryColors$get2, _categoryColors$get3;
|
|
267
|
+
return /*#__PURE__*/_jsx(Scatter, {
|
|
268
|
+
animationDuration: animationDuration,
|
|
269
|
+
className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n fill: ", ";\n "])), (_categoryColors$get2 = categoryColors.get(cat)) !== null && _categoryColors$get2 !== void 0 ? _categoryColors$get2 : theme.colorPrimary), showOpacity && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n stroke: ", ";\n "])), (_categoryColors$get3 = categoryColors.get(cat)) !== null && _categoryColors$get3 !== void 0 ? _categoryColors$get3 : theme.colorPrimary)),
|
|
270
|
+
data: category ? data.filter(function (d) {
|
|
271
|
+
return d[category] === cat;
|
|
272
|
+
}) : data,
|
|
273
|
+
fill: "url(#".concat(categoryColors.get(cat), ")"),
|
|
274
|
+
fillOpacity: showOpacity ? 0.7 : 1,
|
|
275
|
+
isAnimationActive: showAnimation,
|
|
276
|
+
name: cat,
|
|
277
|
+
onClick: onNodeClick,
|
|
278
|
+
shape: function shape(props) {
|
|
279
|
+
return renderShape(props, activeNode, activeLegend);
|
|
280
|
+
},
|
|
281
|
+
style: {
|
|
282
|
+
cursor: onValueChange ? 'pointer' : undefined
|
|
283
|
+
}
|
|
284
|
+
}, cat);
|
|
285
|
+
}), showLegend ? /*#__PURE__*/_jsx(Legend, {
|
|
286
|
+
content: function content(_ref2) {
|
|
287
|
+
var payload = _ref2.payload;
|
|
288
|
+
return ChartLegend({
|
|
289
|
+
payload: payload
|
|
290
|
+
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
291
|
+
return onCategoryClick(clickedLegendItem);
|
|
292
|
+
} : undefined, enableLegendSlider);
|
|
293
|
+
},
|
|
294
|
+
height: legendHeight,
|
|
295
|
+
verticalAlign: "top"
|
|
296
|
+
}) : undefined]
|
|
297
|
+
}) : /*#__PURE__*/_jsx(NoData, {
|
|
298
|
+
noDataText: noDataText
|
|
299
|
+
})
|
|
300
|
+
})
|
|
301
|
+
}));
|
|
302
|
+
});
|
|
303
|
+
ScatterChart.displayName = 'ScatterChart';
|
|
304
|
+
export default ScatterChart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderShape: (props: any, activeNode: any | undefined, activeLegend: string | undefined) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dot } from 'recharts';
|
|
3
|
+
import { deepEqual } from "../common/utils";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export var renderShape = function renderShape(props, activeNode, activeLegend) {
|
|
6
|
+
var cx = props.cx,
|
|
7
|
+
cy = props.cy,
|
|
8
|
+
width = props.width,
|
|
9
|
+
node = props.node,
|
|
10
|
+
fillOpacity = props.fillOpacity,
|
|
11
|
+
name = props.name;
|
|
12
|
+
return /*#__PURE__*/_jsx(Dot, {
|
|
13
|
+
cx: cx,
|
|
14
|
+
cy: cy,
|
|
15
|
+
opacity: activeNode || activeLegend && activeLegend !== name ? deepEqual(activeNode, node) ? fillOpacity : 0.3 : fillOpacity,
|
|
16
|
+
r: width / 2
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
2
|
+
emphasis: import("antd-style").SerializedStyles;
|
|
3
|
+
gridLines: import("antd-style").SerializedStyles;
|
|
4
|
+
label: import("antd-style").SerializedStyles;
|
|
5
|
+
strongLabel: import("antd-style").SerializedStyles;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token;
|
|
7
|
+
return {
|
|
8
|
+
emphasis: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n "]))),
|
|
9
|
+
gridLines: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n stroke: ", ";\n stroke-width: 1;\n "])), token.colorBorderSecondary),
|
|
10
|
+
label: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextDescription),
|
|
11
|
+
strongLabel: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: 14px;\n font-weight: 500;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextSecondary)
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ComponentType, HTMLAttributes } from 'react';
|
|
2
|
+
import type { NoDataProps } from "./NoData";
|
|
3
|
+
import { IntervalType, ValueFormatter } from "../types";
|
|
4
|
+
import type BaseAnimationTimingProps from './BaseAnimationTimingProps';
|
|
5
|
+
import { CustomTooltipProps } from './CustomTooltipProps';
|
|
6
|
+
type FixedProps = {
|
|
7
|
+
categoryClicked: string;
|
|
8
|
+
eventType: 'dot' | 'category' | 'bar' | 'slice' | 'bubble';
|
|
9
|
+
};
|
|
10
|
+
type BaseEventProps = FixedProps & {
|
|
11
|
+
[key: string]: number | string;
|
|
12
|
+
};
|
|
13
|
+
export type EventProps = BaseEventProps | null | undefined;
|
|
14
|
+
interface BaseChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
|
|
15
|
+
allowDecimals?: boolean;
|
|
16
|
+
autoMinValue?: boolean;
|
|
17
|
+
categories: string[];
|
|
18
|
+
colors?: string[];
|
|
19
|
+
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
20
|
+
data: any[];
|
|
21
|
+
enableLegendSlider?: boolean;
|
|
22
|
+
height?: string | number;
|
|
23
|
+
index: string;
|
|
24
|
+
intervalType?: IntervalType;
|
|
25
|
+
maxValue?: number;
|
|
26
|
+
minValue?: number;
|
|
27
|
+
noDataText?: NoDataProps['noDataText'];
|
|
28
|
+
onValueChange?: (value: EventProps) => void;
|
|
29
|
+
rotateLabelX?: {
|
|
30
|
+
angle: number;
|
|
31
|
+
verticalShift?: number;
|
|
32
|
+
xAxisHeight?: number;
|
|
33
|
+
};
|
|
34
|
+
showGridLines?: boolean;
|
|
35
|
+
showLegend?: boolean;
|
|
36
|
+
showTooltip?: boolean;
|
|
37
|
+
showXAxis?: boolean;
|
|
38
|
+
showYAxis?: boolean;
|
|
39
|
+
startEndOnly?: boolean;
|
|
40
|
+
tickGap?: number;
|
|
41
|
+
valueFormatter?: ValueFormatter;
|
|
42
|
+
width?: string | number;
|
|
43
|
+
xAxisLabel?: string;
|
|
44
|
+
yAxisLabel?: string;
|
|
45
|
+
yAxisWidth?: number;
|
|
46
|
+
}
|
|
47
|
+
export default BaseChartProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
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) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default ChartLegend;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { Flexbox } from 'react-layout-kit';
|
|
3
|
+
import Legend from "../components/Legend";
|
|
4
|
+
import { useOnWindowResize } from "../hooks/useOnWindowResize";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
var calculateHeight = function calculateHeight(height) {
|
|
7
|
+
return height ? Number(height) + 20 // 20px extra padding
|
|
8
|
+
: 60;
|
|
9
|
+
}; // default height
|
|
10
|
+
|
|
11
|
+
var ChartLegend = function ChartLegend(_ref, categoryColors, setLegendHeight, activeLegend, onClick, enableLegendSlider) {
|
|
12
|
+
var payload = _ref.payload;
|
|
13
|
+
var legendRef = useRef(null);
|
|
14
|
+
useOnWindowResize(function () {
|
|
15
|
+
var _legendRef$current;
|
|
16
|
+
setLegendHeight(calculateHeight((_legendRef$current = legendRef.current) === null || _legendRef$current === void 0 ? void 0 : _legendRef$current.clientHeight));
|
|
17
|
+
});
|
|
18
|
+
var filteredPayload = payload.filter(function (item) {
|
|
19
|
+
return item.type !== 'none';
|
|
20
|
+
});
|
|
21
|
+
return /*#__PURE__*/_jsx(Flexbox, {
|
|
22
|
+
align: 'center',
|
|
23
|
+
horizontal: true,
|
|
24
|
+
justify: 'flex-end',
|
|
25
|
+
ref: legendRef,
|
|
26
|
+
children: /*#__PURE__*/_jsx(Legend, {
|
|
27
|
+
activeLegend: activeLegend,
|
|
28
|
+
categories: filteredPayload.map(function (entry) {
|
|
29
|
+
return entry.value;
|
|
30
|
+
}),
|
|
31
|
+
colors: filteredPayload.map(function (entry) {
|
|
32
|
+
return categoryColors.get(entry.value);
|
|
33
|
+
}),
|
|
34
|
+
enableLegendSlider: enableLegendSlider,
|
|
35
|
+
onClickLegendItem: onClick
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export default ChartLegend;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FlexboxProps } from 'react-layout-kit';
|
|
3
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
4
|
+
container: import("antd-style").SerializedStyles;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const ChartTooltipFrame: import("react").NamedExoticComponent<FlexboxProps>;
|
|
7
|
+
export default ChartTooltipFrame;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
|
+
var _excluded = ["children"];
|
|
5
|
+
var _templateObject;
|
|
6
|
+
import { createStyles } from 'antd-style';
|
|
7
|
+
import { memo } from 'react';
|
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export var useStyles = createStyles(function (_ref) {
|
|
11
|
+
var css = _ref.css,
|
|
12
|
+
token = _ref.token;
|
|
13
|
+
return {
|
|
14
|
+
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n "])), token.colorBgElevated, token.colorBorderSecondary, token.borderRadiusLG, token.boxShadow)
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
export var ChartTooltipFrame = /*#__PURE__*/memo(function (_ref2) {
|
|
18
|
+
var children = _ref2.children,
|
|
19
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
20
|
+
var _useStyles = useStyles(),
|
|
21
|
+
styles = _useStyles.styles;
|
|
22
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
23
|
+
className: styles.container
|
|
24
|
+
}, rest), {}, {
|
|
25
|
+
children: children
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
export default ChartTooltipFrame;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
|
+
import { Icon } from '@lobehub/ui';
|
|
4
|
+
import { Typography } from 'antd';
|
|
5
|
+
import { createStyles } from 'antd-style';
|
|
6
|
+
import { Circle } from 'lucide-react';
|
|
7
|
+
import { memo } from 'react';
|
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var useStyles = createStyles(function (_ref) {
|
|
12
|
+
var css = _ref.css,
|
|
13
|
+
token = _ref.token;
|
|
14
|
+
return {
|
|
15
|
+
number: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-weight: 500;\n "]))),
|
|
16
|
+
title: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextSecondary)
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
var ChartTooltipRow = /*#__PURE__*/memo(function (_ref2) {
|
|
20
|
+
var value = _ref2.value,
|
|
21
|
+
name = _ref2.name,
|
|
22
|
+
color = _ref2.color;
|
|
23
|
+
var _useStyles = useStyles(),
|
|
24
|
+
styles = _useStyles.styles;
|
|
25
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
26
|
+
align: 'center',
|
|
27
|
+
gap: 32,
|
|
28
|
+
horizontal: true,
|
|
29
|
+
justify: 'space-between',
|
|
30
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
31
|
+
align: 'center',
|
|
32
|
+
gap: 8,
|
|
33
|
+
horizontal: true,
|
|
34
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
35
|
+
color: color,
|
|
36
|
+
fill: color,
|
|
37
|
+
icon: Circle,
|
|
38
|
+
size: {
|
|
39
|
+
fontSize: 10
|
|
40
|
+
}
|
|
41
|
+
}), /*#__PURE__*/_jsx(Typography.Paragraph, {
|
|
42
|
+
className: styles.title,
|
|
43
|
+
ellipsis: true,
|
|
44
|
+
style: {
|
|
45
|
+
margin: 0
|
|
46
|
+
},
|
|
47
|
+
children: name
|
|
48
|
+
})]
|
|
49
|
+
}), /*#__PURE__*/_jsx(Typography.Paragraph, {
|
|
50
|
+
className: styles.number,
|
|
51
|
+
style: {
|
|
52
|
+
margin: 0
|
|
53
|
+
},
|
|
54
|
+
children: value
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
export default ChartTooltipRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValueFormatter } from "../../types";
|
|
2
|
+
export interface ChartTooltipProps {
|
|
3
|
+
active: boolean | undefined;
|
|
4
|
+
categoryColors: Map<string, string>;
|
|
5
|
+
label: string;
|
|
6
|
+
payload: any;
|
|
7
|
+
valueFormatter: ValueFormatter;
|
|
8
|
+
}
|
|
9
|
+
declare const ChartTooltip: ({ active, payload, label, categoryColors, valueFormatter, }: ChartTooltipProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export default ChartTooltip;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { Typography } from 'antd';
|
|
4
|
+
import { createStyles } from 'antd-style';
|
|
5
|
+
import { Flexbox } from 'react-layout-kit';
|
|
6
|
+
import ChartTooltipFrame from "./ChartTooltipFrame";
|
|
7
|
+
import ChartTooltipRow from "./ChartTooltipRow";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
var useStyles = createStyles(function (_ref) {
|
|
11
|
+
var css = _ref.css,
|
|
12
|
+
token = _ref.token;
|
|
13
|
+
return {
|
|
14
|
+
header: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-weight: 500;\n border-bottom: 1px solid ", ";\n "])), token.colorBorderSecondary)
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
var ChartTooltip = function ChartTooltip(_ref2) {
|
|
18
|
+
var active = _ref2.active,
|
|
19
|
+
payload = _ref2.payload,
|
|
20
|
+
label = _ref2.label,
|
|
21
|
+
categoryColors = _ref2.categoryColors,
|
|
22
|
+
valueFormatter = _ref2.valueFormatter;
|
|
23
|
+
var _useStyles = useStyles(),
|
|
24
|
+
cx = _useStyles.cx,
|
|
25
|
+
theme = _useStyles.theme,
|
|
26
|
+
styles = _useStyles.styles;
|
|
27
|
+
if (active && payload) {
|
|
28
|
+
var filteredPayload = payload.filter(function (item) {
|
|
29
|
+
return item.type !== 'none';
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/_jsxs(ChartTooltipFrame, {
|
|
32
|
+
children: [/*#__PURE__*/_jsx(Flexbox, {
|
|
33
|
+
className: cx(styles.header),
|
|
34
|
+
paddingBlock: 8,
|
|
35
|
+
paddingInline: 16,
|
|
36
|
+
children: /*#__PURE__*/_jsx(Typography.Paragraph, {
|
|
37
|
+
ellipsis: true,
|
|
38
|
+
style: {
|
|
39
|
+
margin: 0
|
|
40
|
+
},
|
|
41
|
+
children: label
|
|
42
|
+
})
|
|
43
|
+
}), /*#__PURE__*/_jsx(Flexbox, {
|
|
44
|
+
gap: 4,
|
|
45
|
+
paddingBlock: 8,
|
|
46
|
+
paddingInline: 16,
|
|
47
|
+
style: {
|
|
48
|
+
marginTop: 4
|
|
49
|
+
},
|
|
50
|
+
children: filteredPayload.map(function (_ref3, idx) {
|
|
51
|
+
var _categoryColors$get;
|
|
52
|
+
var value = _ref3.value,
|
|
53
|
+
name = _ref3.name;
|
|
54
|
+
return /*#__PURE__*/_jsx(ChartTooltipRow, {
|
|
55
|
+
color: (_categoryColors$get = categoryColors.get(name)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary,
|
|
56
|
+
name: name,
|
|
57
|
+
value: valueFormatter(value)
|
|
58
|
+
}, "id-".concat(idx));
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
export default ChartTooltip;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NameType, Payload } from 'recharts/types/component/DefaultTooltipContent';
|
|
2
|
+
export type CustomTooltipProps = {
|
|
3
|
+
active: boolean | undefined;
|
|
4
|
+
label: NameType | undefined;
|
|
5
|
+
payload: Payload<string | number | (string | number)[], string | number>[] | undefined;
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface NoDataProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
noDataText?: ReactNode | {
|
|
5
|
+
desc: ReactNode;
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
declare const NoData: import("react").NamedExoticComponent<NoDataProps>;
|
|
10
|
+
export default NoData;
|