@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,27 @@
|
|
|
1
|
+
import { Sector } from 'recharts';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export var renderInactiveShape = function renderInactiveShape(props) {
|
|
4
|
+
var cx = props.cx,
|
|
5
|
+
cy = props.cy,
|
|
6
|
+
innerRadius = props.innerRadius,
|
|
7
|
+
outerRadius = props.outerRadius,
|
|
8
|
+
startAngle = props.startAngle,
|
|
9
|
+
endAngle = props.endAngle,
|
|
10
|
+
className = props.className;
|
|
11
|
+
return /*#__PURE__*/_jsx("g", {
|
|
12
|
+
children: /*#__PURE__*/_jsx(Sector, {
|
|
13
|
+
className: className,
|
|
14
|
+
cx: cx,
|
|
15
|
+
cy: cy,
|
|
16
|
+
endAngle: endAngle,
|
|
17
|
+
fill: "",
|
|
18
|
+
innerRadius: innerRadius,
|
|
19
|
+
opacity: 0.3,
|
|
20
|
+
outerRadius: outerRadius,
|
|
21
|
+
startAngle: startAngle,
|
|
22
|
+
style: {
|
|
23
|
+
outline: 'none'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -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: 16px;\n font-weight: 500;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextSecondary)
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import BaseChartProps from "../common/BaseChartProps";
|
|
3
|
+
import { CurveType } from "../types";
|
|
4
|
+
export interface LineChartProps extends BaseChartProps {
|
|
5
|
+
connectNulls?: boolean;
|
|
6
|
+
curveType?: CurveType;
|
|
7
|
+
}
|
|
8
|
+
declare const LineChart: import("react").ForwardRefExoticComponent<LineChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export default LineChart;
|
|
@@ -0,0 +1,347 @@
|
|
|
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, _templateObject3;
|
|
8
|
+
var _excluded = ["data", "categories", "index", "colors", "valueFormatter", "startEndOnly", "showXAxis", "showYAxis", "yAxisWidth", "intervalType", "animationDuration", "showAnimation", "showTooltip", "showLegend", "showGridLines", "autoMinValue", "curveType", "minValue", "maxValue", "connectNulls", "allowDecimals", "noDataText", "className", "onValueChange", "enableLegendSlider", "customTooltip", "rotateLabelX", "tickGap", "xAxisLabel", "yAxisLabel", "width", "height"];
|
|
9
|
+
import { css } from 'antd-style';
|
|
10
|
+
import { Fragment, forwardRef, useState } from 'react';
|
|
11
|
+
import { Flexbox } from 'react-layout-kit';
|
|
12
|
+
import { CartesianGrid, Dot, Label, Legend, Line, LineChart as ReChartsLineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
|
13
|
+
import ChartLegend from "../common/ChartLegend";
|
|
14
|
+
import ChartTooltip from "../common/ChartTooltip";
|
|
15
|
+
import NoData from "../common/NoData";
|
|
16
|
+
import { constructCategoryColors, getYAxisDomain, hasOnlyOneValueForThisKey } from "../common/utils";
|
|
17
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange";
|
|
18
|
+
import { defaultValueFormatter } from "../utils";
|
|
19
|
+
import { useStyles } from "./styles";
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
|
+
var _useStyles = useStyles(),
|
|
24
|
+
cx = _useStyles.cx,
|
|
25
|
+
theme = _useStyles.theme,
|
|
26
|
+
styles = _useStyles.styles;
|
|
27
|
+
var themeColorRange = useThemeColorRange();
|
|
28
|
+
var _props$data = props.data,
|
|
29
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
30
|
+
_props$categories = props.categories,
|
|
31
|
+
categories = _props$categories === void 0 ? [] : _props$categories,
|
|
32
|
+
index = props.index,
|
|
33
|
+
_props$colors = props.colors,
|
|
34
|
+
colors = _props$colors === void 0 ? themeColorRange : _props$colors,
|
|
35
|
+
_props$valueFormatter = props.valueFormatter,
|
|
36
|
+
valueFormatter = _props$valueFormatter === void 0 ? defaultValueFormatter : _props$valueFormatter,
|
|
37
|
+
_props$startEndOnly = props.startEndOnly,
|
|
38
|
+
startEndOnly = _props$startEndOnly === void 0 ? false : _props$startEndOnly,
|
|
39
|
+
_props$showXAxis = props.showXAxis,
|
|
40
|
+
showXAxis = _props$showXAxis === void 0 ? true : _props$showXAxis,
|
|
41
|
+
_props$showYAxis = props.showYAxis,
|
|
42
|
+
showYAxis = _props$showYAxis === void 0 ? true : _props$showYAxis,
|
|
43
|
+
_props$yAxisWidth = props.yAxisWidth,
|
|
44
|
+
yAxisWidth = _props$yAxisWidth === void 0 ? 56 : _props$yAxisWidth,
|
|
45
|
+
_props$intervalType = props.intervalType,
|
|
46
|
+
intervalType = _props$intervalType === void 0 ? 'equidistantPreserveStart' : _props$intervalType,
|
|
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
|
+
_props$curveType = props.curveType,
|
|
60
|
+
curveType = _props$curveType === void 0 ? 'linear' : _props$curveType,
|
|
61
|
+
minValue = props.minValue,
|
|
62
|
+
maxValue = props.maxValue,
|
|
63
|
+
_props$connectNulls = props.connectNulls,
|
|
64
|
+
connectNulls = _props$connectNulls === void 0 ? false : _props$connectNulls,
|
|
65
|
+
_props$allowDecimals = props.allowDecimals,
|
|
66
|
+
allowDecimals = _props$allowDecimals === void 0 ? true : _props$allowDecimals,
|
|
67
|
+
noDataText = props.noDataText,
|
|
68
|
+
className = props.className,
|
|
69
|
+
onValueChange = props.onValueChange,
|
|
70
|
+
_props$enableLegendSl = props.enableLegendSlider,
|
|
71
|
+
enableLegendSlider = _props$enableLegendSl === void 0 ? false : _props$enableLegendSl,
|
|
72
|
+
customTooltip = props.customTooltip,
|
|
73
|
+
rotateLabelX = props.rotateLabelX,
|
|
74
|
+
_props$tickGap = props.tickGap,
|
|
75
|
+
tickGap = _props$tickGap === void 0 ? 5 : _props$tickGap,
|
|
76
|
+
xAxisLabel = props.xAxisLabel,
|
|
77
|
+
yAxisLabel = props.yAxisLabel,
|
|
78
|
+
_props$width = props.width,
|
|
79
|
+
width = _props$width === void 0 ? '100%' : _props$width,
|
|
80
|
+
_props$height = props.height,
|
|
81
|
+
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
82
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
83
|
+
var CustomTooltip = customTooltip;
|
|
84
|
+
var paddingValue = !showXAxis && !showYAxis ? 0 : 20;
|
|
85
|
+
var _useState = useState(60),
|
|
86
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
+
legendHeight = _useState2[0],
|
|
88
|
+
setLegendHeight = _useState2[1];
|
|
89
|
+
var _useState3 = useState(),
|
|
90
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
91
|
+
activeDot = _useState4[0],
|
|
92
|
+
setActiveDot = _useState4[1];
|
|
93
|
+
var _useState5 = useState(),
|
|
94
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
95
|
+
activeLegend = _useState6[0],
|
|
96
|
+
setActiveLegend = _useState6[1];
|
|
97
|
+
var categoryColors = constructCategoryColors(categories, colors);
|
|
98
|
+
var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
99
|
+
var hasOnValueChange = !!onValueChange;
|
|
100
|
+
function onDotClick(itemData, event) {
|
|
101
|
+
event.stopPropagation();
|
|
102
|
+
if (!hasOnValueChange) return;
|
|
103
|
+
if (itemData.index === (activeDot === null || activeDot === void 0 ? void 0 : activeDot.index) && itemData.dataKey === (activeDot === null || activeDot === void 0 ? void 0 : activeDot.dataKey) || hasOnlyOneValueForThisKey(data, itemData.dataKey) && activeLegend && activeLegend === itemData.dataKey) {
|
|
104
|
+
setActiveLegend(undefined);
|
|
105
|
+
setActiveDot(undefined);
|
|
106
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
107
|
+
} else {
|
|
108
|
+
setActiveLegend(itemData.dataKey);
|
|
109
|
+
setActiveDot({
|
|
110
|
+
dataKey: itemData.dataKey,
|
|
111
|
+
index: itemData.index
|
|
112
|
+
});
|
|
113
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(_objectSpread({
|
|
114
|
+
categoryClicked: itemData.dataKey,
|
|
115
|
+
eventType: 'dot'
|
|
116
|
+
}, itemData.payload));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function onCategoryClick(dataKey) {
|
|
120
|
+
if (!hasOnValueChange) return;
|
|
121
|
+
if (dataKey === activeLegend && !activeDot || hasOnlyOneValueForThisKey(data, dataKey) && activeDot && activeDot.dataKey === dataKey) {
|
|
122
|
+
setActiveLegend(undefined);
|
|
123
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
124
|
+
} else {
|
|
125
|
+
setActiveLegend(dataKey);
|
|
126
|
+
onValueChange === null || onValueChange === void 0 || onValueChange({
|
|
127
|
+
categoryClicked: dataKey,
|
|
128
|
+
eventType: 'category'
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
setActiveDot(undefined);
|
|
132
|
+
}
|
|
133
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
134
|
+
className: className,
|
|
135
|
+
height: height,
|
|
136
|
+
ref: ref,
|
|
137
|
+
width: width
|
|
138
|
+
}, rest), {}, {
|
|
139
|
+
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
140
|
+
children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsLineChart, {
|
|
141
|
+
data: data,
|
|
142
|
+
margin: {
|
|
143
|
+
bottom: xAxisLabel ? 30 : undefined,
|
|
144
|
+
left: yAxisLabel ? 20 : undefined,
|
|
145
|
+
right: yAxisLabel ? 5 : undefined,
|
|
146
|
+
top: 5
|
|
147
|
+
},
|
|
148
|
+
onClick: hasOnValueChange && (activeLegend || activeDot) ? function () {
|
|
149
|
+
setActiveDot(undefined);
|
|
150
|
+
setActiveLegend(undefined);
|
|
151
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(null);
|
|
152
|
+
} : undefined,
|
|
153
|
+
children: [showGridLines ? /*#__PURE__*/_jsx(CartesianGrid, {
|
|
154
|
+
className: styles.gridLines,
|
|
155
|
+
horizontal: true,
|
|
156
|
+
vertical: false
|
|
157
|
+
}) : undefined, /*#__PURE__*/_jsx(XAxis, {
|
|
158
|
+
angle: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.angle,
|
|
159
|
+
axisLine: false,
|
|
160
|
+
className: styles.label,
|
|
161
|
+
dataKey: index,
|
|
162
|
+
dy: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.verticalShift,
|
|
163
|
+
fill: "",
|
|
164
|
+
height: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.xAxisHeight,
|
|
165
|
+
hide: !showXAxis,
|
|
166
|
+
interval: startEndOnly ? 'preserveStartEnd' : intervalType,
|
|
167
|
+
minTickGap: tickGap,
|
|
168
|
+
padding: {
|
|
169
|
+
left: paddingValue,
|
|
170
|
+
right: paddingValue
|
|
171
|
+
},
|
|
172
|
+
stroke: "",
|
|
173
|
+
tick: {
|
|
174
|
+
transform: 'translate(0, 6)'
|
|
175
|
+
},
|
|
176
|
+
tickLine: false,
|
|
177
|
+
ticks: startEndOnly ? [data[0][index], data.at(-1)[index]] : undefined,
|
|
178
|
+
children: xAxisLabel && /*#__PURE__*/_jsx(Label, {
|
|
179
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
180
|
+
offset: -20,
|
|
181
|
+
position: "insideBottom",
|
|
182
|
+
children: xAxisLabel
|
|
183
|
+
})
|
|
184
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
185
|
+
allowDecimals: allowDecimals,
|
|
186
|
+
axisLine: false,
|
|
187
|
+
className: styles.label,
|
|
188
|
+
domain: yAxisDomain,
|
|
189
|
+
fill: "",
|
|
190
|
+
hide: !showYAxis,
|
|
191
|
+
stroke: "",
|
|
192
|
+
tick: {
|
|
193
|
+
transform: 'translate(-3, 0)'
|
|
194
|
+
},
|
|
195
|
+
tickFormatter: valueFormatter,
|
|
196
|
+
tickLine: false,
|
|
197
|
+
type: "number",
|
|
198
|
+
width: yAxisWidth,
|
|
199
|
+
children: yAxisLabel && /*#__PURE__*/_jsx(Label, {
|
|
200
|
+
angle: -90,
|
|
201
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
202
|
+
offset: -15,
|
|
203
|
+
position: "insideLeft",
|
|
204
|
+
style: {
|
|
205
|
+
textAnchor: 'middle'
|
|
206
|
+
},
|
|
207
|
+
children: yAxisLabel
|
|
208
|
+
})
|
|
209
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
210
|
+
content: showTooltip ? function (_ref) {
|
|
211
|
+
var active = _ref.active,
|
|
212
|
+
payload = _ref.payload,
|
|
213
|
+
label = _ref.label;
|
|
214
|
+
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
215
|
+
active: active,
|
|
216
|
+
label: label,
|
|
217
|
+
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
218
|
+
var _categoryColors$get;
|
|
219
|
+
return _objectSpread(_objectSpread({}, payloadItem), {}, {
|
|
220
|
+
color: (_categoryColors$get = categoryColors.get(payloadItem.dataKey)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary
|
|
221
|
+
});
|
|
222
|
+
})
|
|
223
|
+
}) : /*#__PURE__*/_jsx(ChartTooltip, {
|
|
224
|
+
active: active,
|
|
225
|
+
categoryColors: categoryColors,
|
|
226
|
+
label: label,
|
|
227
|
+
payload: payload,
|
|
228
|
+
valueFormatter: valueFormatter
|
|
229
|
+
});
|
|
230
|
+
} : undefined,
|
|
231
|
+
cursor: {
|
|
232
|
+
stroke: '#d1d5db',
|
|
233
|
+
strokeWidth: 1
|
|
234
|
+
},
|
|
235
|
+
isAnimationActive: false,
|
|
236
|
+
position: {
|
|
237
|
+
y: 0
|
|
238
|
+
},
|
|
239
|
+
wrapperStyle: {
|
|
240
|
+
outline: 'none'
|
|
241
|
+
}
|
|
242
|
+
}), showLegend ? /*#__PURE__*/_jsx(Legend, {
|
|
243
|
+
content: function content(_ref2) {
|
|
244
|
+
var payload = _ref2.payload;
|
|
245
|
+
return ChartLegend({
|
|
246
|
+
payload: payload
|
|
247
|
+
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
248
|
+
return onCategoryClick(clickedLegendItem);
|
|
249
|
+
} : undefined, enableLegendSlider);
|
|
250
|
+
},
|
|
251
|
+
height: legendHeight,
|
|
252
|
+
verticalAlign: "top"
|
|
253
|
+
}) : undefined, categories.map(function (category) {
|
|
254
|
+
var _categoryColors$get3;
|
|
255
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
256
|
+
activeDot: function activeDot(props) {
|
|
257
|
+
var _categoryColors$get2;
|
|
258
|
+
var dotCx = props.dotCx,
|
|
259
|
+
dotCy = props.dotCy,
|
|
260
|
+
stroke = props.stroke,
|
|
261
|
+
strokeLinecap = props.strokeLinecap,
|
|
262
|
+
strokeLinejoin = props.strokeLinejoin,
|
|
263
|
+
strokeWidth = props.strokeWidth,
|
|
264
|
+
dataKey = props.dataKey;
|
|
265
|
+
return /*#__PURE__*/_jsx(Dot, {
|
|
266
|
+
className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n fill: ", ";\n "])), (_categoryColors$get2 = categoryColors.get(dataKey)) !== null && _categoryColors$get2 !== void 0 ? _categoryColors$get2 : theme.colorPrimary)),
|
|
267
|
+
cx: dotCx,
|
|
268
|
+
cy: dotCy,
|
|
269
|
+
fill: "",
|
|
270
|
+
onClick: function onClick(dotProps, event) {
|
|
271
|
+
return onDotClick(props, event);
|
|
272
|
+
},
|
|
273
|
+
r: 5,
|
|
274
|
+
stroke: stroke,
|
|
275
|
+
strokeLinecap: strokeLinecap,
|
|
276
|
+
strokeLinejoin: strokeLinejoin,
|
|
277
|
+
strokeWidth: strokeWidth
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
animationDuration: animationDuration,
|
|
281
|
+
className: cx(css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n stroke: ", ";\n "])), (_categoryColors$get3 = categoryColors.get(category)) !== null && _categoryColors$get3 !== void 0 ? _categoryColors$get3 : theme.colorPrimary)),
|
|
282
|
+
connectNulls: connectNulls,
|
|
283
|
+
dataKey: category,
|
|
284
|
+
dot: function dot(props) {
|
|
285
|
+
var stroke = props.stroke,
|
|
286
|
+
strokeLinecap = props.strokeLinecap,
|
|
287
|
+
strokeLinejoin = props.strokeLinejoin,
|
|
288
|
+
strokeWidth = props.strokeWidth,
|
|
289
|
+
dotCx = props.cx,
|
|
290
|
+
dotCy = props.cy,
|
|
291
|
+
dataKey = props.dataKey,
|
|
292
|
+
index = props.index;
|
|
293
|
+
if (hasOnlyOneValueForThisKey(data, category) && !(activeDot || activeLegend && activeLegend !== category) || (activeDot === null || activeDot === void 0 ? void 0 : activeDot.index) === index && (activeDot === null || activeDot === void 0 ? void 0 : activeDot.dataKey) === category) {
|
|
294
|
+
var _categoryColors$get4;
|
|
295
|
+
return /*#__PURE__*/_jsx(Dot, {
|
|
296
|
+
className: cx(css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n fill: ", ";\n "])), (_categoryColors$get4 = categoryColors.get(dataKey)) !== null && _categoryColors$get4 !== void 0 ? _categoryColors$get4 : theme.colorPrimary)),
|
|
297
|
+
cx: dotCx,
|
|
298
|
+
cy: dotCy,
|
|
299
|
+
fill: "",
|
|
300
|
+
r: 5,
|
|
301
|
+
stroke: stroke,
|
|
302
|
+
strokeLinecap: strokeLinecap,
|
|
303
|
+
strokeLinejoin: strokeLinejoin,
|
|
304
|
+
strokeWidth: strokeWidth
|
|
305
|
+
}, index);
|
|
306
|
+
}
|
|
307
|
+
return /*#__PURE__*/_jsx(Fragment, {}, index);
|
|
308
|
+
},
|
|
309
|
+
isAnimationActive: showAnimation,
|
|
310
|
+
name: category,
|
|
311
|
+
stroke: "",
|
|
312
|
+
strokeLinecap: "round",
|
|
313
|
+
strokeLinejoin: "round",
|
|
314
|
+
strokeOpacity: activeDot || activeLegend && activeLegend !== category ? 0.3 : 1,
|
|
315
|
+
strokeWidth: 2,
|
|
316
|
+
type: curveType
|
|
317
|
+
}, category);
|
|
318
|
+
}), onValueChange ? categories.map(function (category) {
|
|
319
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
320
|
+
connectNulls: connectNulls,
|
|
321
|
+
dataKey: category,
|
|
322
|
+
fill: "transparent",
|
|
323
|
+
legendType: "none",
|
|
324
|
+
name: category,
|
|
325
|
+
onClick: function onClick(props, event) {
|
|
326
|
+
event.stopPropagation();
|
|
327
|
+
var name = props.name;
|
|
328
|
+
onCategoryClick(name);
|
|
329
|
+
},
|
|
330
|
+
stroke: "transparent",
|
|
331
|
+
strokeOpacity: 0,
|
|
332
|
+
strokeWidth: 12,
|
|
333
|
+
style: {
|
|
334
|
+
cursor: 'pointer'
|
|
335
|
+
},
|
|
336
|
+
tooltipType: "none",
|
|
337
|
+
type: curveType
|
|
338
|
+
}, category);
|
|
339
|
+
}) : undefined]
|
|
340
|
+
}) : /*#__PURE__*/_jsx(NoData, {
|
|
341
|
+
noDataText: noDataText
|
|
342
|
+
})
|
|
343
|
+
})
|
|
344
|
+
}));
|
|
345
|
+
});
|
|
346
|
+
LineChart.displayName = 'LineChart';
|
|
347
|
+
export default LineChart;
|
|
@@ -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,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScatterChartValueFormatter } from "../types";
|
|
3
|
+
export interface ScatterChartTooltipProps {
|
|
4
|
+
active: boolean | undefined;
|
|
5
|
+
axis: any;
|
|
6
|
+
category?: string;
|
|
7
|
+
categoryColors: Map<string, string>;
|
|
8
|
+
label: string;
|
|
9
|
+
payload: any;
|
|
10
|
+
valueFormatter: ScatterChartValueFormatter;
|
|
11
|
+
}
|
|
12
|
+
declare const ScatterChartTooltip: React.NamedExoticComponent<ScatterChartTooltipProps>;
|
|
13
|
+
export default ScatterChartTooltip;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
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 React, { memo } from 'react';
|
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
|
9
|
+
import { ChartTooltipFrame } from "../common/ChartTooltip/ChartTooltipFrame";
|
|
10
|
+
import { defaultValueFormatter } from "../utils";
|
|
11
|
+
import ScatterChartTooltipRow from "./ScatterChartTooltipRow";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
var useStyles = createStyles(function (_ref) {
|
|
15
|
+
var css = _ref.css,
|
|
16
|
+
token = _ref.token;
|
|
17
|
+
return {
|
|
18
|
+
header: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-weight: 500;\n border-bottom: 1px solid ", ";\n "])), token.colorBorderSecondary)
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
var ScatterChartTooltip = /*#__PURE__*/memo(function (_ref2) {
|
|
22
|
+
var _categoryColors$get, _payload$;
|
|
23
|
+
var label = _ref2.label,
|
|
24
|
+
active = _ref2.active,
|
|
25
|
+
payload = _ref2.payload,
|
|
26
|
+
valueFormatter = _ref2.valueFormatter,
|
|
27
|
+
axis = _ref2.axis,
|
|
28
|
+
category = _ref2.category,
|
|
29
|
+
categoryColors = _ref2.categoryColors;
|
|
30
|
+
var _useStyles = useStyles(),
|
|
31
|
+
cx = _useStyles.cx,
|
|
32
|
+
theme = _useStyles.theme,
|
|
33
|
+
styles = _useStyles.styles;
|
|
34
|
+
var color = category ? (_categoryColors$get = categoryColors.get(payload === null || payload === void 0 || (_payload$ = payload[0]) === null || _payload$ === void 0 ? void 0 : _payload$.payload[category])) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary : theme.colorPrimary;
|
|
35
|
+
if (active && payload) {
|
|
36
|
+
return /*#__PURE__*/_jsxs(ChartTooltipFrame, {
|
|
37
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
38
|
+
align: 'center',
|
|
39
|
+
className: cx(styles.header),
|
|
40
|
+
gap: 8,
|
|
41
|
+
horizontal: true,
|
|
42
|
+
paddingBlock: 8,
|
|
43
|
+
paddingInline: 16,
|
|
44
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
45
|
+
color: color,
|
|
46
|
+
fill: color,
|
|
47
|
+
icon: Circle,
|
|
48
|
+
size: {
|
|
49
|
+
fontSize: 10
|
|
50
|
+
}
|
|
51
|
+
}), /*#__PURE__*/_jsx(Typography.Paragraph, {
|
|
52
|
+
ellipsis: true,
|
|
53
|
+
style: {
|
|
54
|
+
margin: 0
|
|
55
|
+
},
|
|
56
|
+
children: label
|
|
57
|
+
})]
|
|
58
|
+
}), /*#__PURE__*/_jsx(Flexbox, {
|
|
59
|
+
gap: 4,
|
|
60
|
+
paddingBlock: 8,
|
|
61
|
+
paddingInline: 16,
|
|
62
|
+
style: {
|
|
63
|
+
marginTop: 4
|
|
64
|
+
},
|
|
65
|
+
children: payload.map(function (_ref3, idx) {
|
|
66
|
+
var _Object$keys$find, _valueFormatter;
|
|
67
|
+
var value = _ref3.value,
|
|
68
|
+
name = _ref3.name;
|
|
69
|
+
var valueFormatterKey = (_Object$keys$find = Object.keys(axis).find(function (key) {
|
|
70
|
+
return axis[key] === name;
|
|
71
|
+
})) !== null && _Object$keys$find !== void 0 ? _Object$keys$find : '';
|
|
72
|
+
var valueFormatterFn = (_valueFormatter = valueFormatter[valueFormatterKey]) !== null && _valueFormatter !== void 0 ? _valueFormatter : defaultValueFormatter;
|
|
73
|
+
return /*#__PURE__*/_jsx(ScatterChartTooltipRow, {
|
|
74
|
+
name: name,
|
|
75
|
+
value: valueFormatter && valueFormatterFn ? valueFormatterFn(value) : "".concat(value)
|
|
76
|
+
}, "id-".concat(idx));
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
});
|
|
83
|
+
export default ScatterChartTooltip;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
|
+
import { Typography } from 'antd';
|
|
4
|
+
import { createStyles } from 'antd-style';
|
|
5
|
+
import React, { memo } from 'react';
|
|
6
|
+
import { Flexbox } from 'react-layout-kit';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
var useStyles = createStyles(function (_ref) {
|
|
10
|
+
var css = _ref.css,
|
|
11
|
+
token = _ref.token;
|
|
12
|
+
return {
|
|
13
|
+
number: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-weight: 500;\n "]))),
|
|
14
|
+
title: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextSecondary)
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
var ChartTooltipRow = /*#__PURE__*/memo(function (_ref2) {
|
|
18
|
+
var value = _ref2.value,
|
|
19
|
+
name = _ref2.name;
|
|
20
|
+
var _useStyles = useStyles(),
|
|
21
|
+
styles = _useStyles.styles;
|
|
22
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
23
|
+
align: 'center',
|
|
24
|
+
gap: 32,
|
|
25
|
+
horizontal: true,
|
|
26
|
+
justify: 'space-between',
|
|
27
|
+
children: [/*#__PURE__*/_jsx(Typography.Paragraph, {
|
|
28
|
+
className: styles.title,
|
|
29
|
+
ellipsis: true,
|
|
30
|
+
style: {
|
|
31
|
+
margin: 0
|
|
32
|
+
},
|
|
33
|
+
children: name
|
|
34
|
+
}), /*#__PURE__*/_jsx(Typography.Paragraph, {
|
|
35
|
+
className: styles.number,
|
|
36
|
+
style: {
|
|
37
|
+
margin: 0
|
|
38
|
+
},
|
|
39
|
+
children: value
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
export default ChartTooltipRow;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ComponentType, HTMLAttributes } from 'react';
|
|
2
|
+
import { CustomTooltipProps } from "../common/CustomTooltipProps";
|
|
3
|
+
import type { EventProps } from "../types";
|
|
4
|
+
import { IntervalType, ValueFormatter } from "../types";
|
|
5
|
+
import BaseAnimationTimingProps from '../common/BaseAnimationTimingProps';
|
|
6
|
+
import { type NoDataProps } from '../common/NoData';
|
|
7
|
+
export type ScatterChartValueFormatter = {
|
|
8
|
+
size?: ValueFormatter;
|
|
9
|
+
x?: ValueFormatter;
|
|
10
|
+
y?: ValueFormatter;
|
|
11
|
+
};
|
|
12
|
+
export interface ScatterChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
allowDecimals?: boolean;
|
|
14
|
+
autoMinXValue?: boolean;
|
|
15
|
+
autoMinYValue?: boolean;
|
|
16
|
+
category: string;
|
|
17
|
+
colors?: string[];
|
|
18
|
+
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
19
|
+
data: any[];
|
|
20
|
+
enableLegendSlider?: boolean;
|
|
21
|
+
intervalType?: IntervalType;
|
|
22
|
+
maxXValue?: number;
|
|
23
|
+
maxYValue?: number;
|
|
24
|
+
minXValue?: number;
|
|
25
|
+
minYValue?: number;
|
|
26
|
+
noDataText?: NoDataProps['noDataText'];
|
|
27
|
+
onValueChange?: (value: EventProps) => void;
|
|
28
|
+
rotateLabelX?: {
|
|
29
|
+
angle: number;
|
|
30
|
+
verticalShift: number;
|
|
31
|
+
xAxisHeight: number;
|
|
32
|
+
};
|
|
33
|
+
showGridLines?: boolean;
|
|
34
|
+
showLegend?: boolean;
|
|
35
|
+
showOpacity?: boolean;
|
|
36
|
+
showTooltip?: boolean;
|
|
37
|
+
showXAxis?: boolean;
|
|
38
|
+
showYAxis?: boolean;
|
|
39
|
+
size?: string;
|
|
40
|
+
sizeRange?: number[];
|
|
41
|
+
startEndOnly?: boolean;
|
|
42
|
+
tickGap?: number;
|
|
43
|
+
valueFormatter?: ScatterChartValueFormatter;
|
|
44
|
+
x: string;
|
|
45
|
+
xAxisLabel?: string;
|
|
46
|
+
y: string;
|
|
47
|
+
yAxisLabel?: string;
|
|
48
|
+
yAxisWidth?: number;
|
|
49
|
+
}
|
|
50
|
+
declare const ScatterChart: import("react").ForwardRefExoticComponent<ScatterChartProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
|
+
export default ScatterChart;
|