@lobehub/charts 1.4.0 → 1.4.1
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/AreaChart/index.js +5 -2
- package/es/BarChart/index.js +5 -2
- package/es/DonutChart/DonutChartTooltip.d.ts +4 -1
- package/es/DonutChart/DonutChartTooltip.js +3 -2
- package/es/DonutChart/index.d.ts +3 -0
- package/es/DonutChart/index.js +4 -1
- package/es/Legend/LegendItem.d.ts +1 -0
- package/es/Legend/LegendItem.js +3 -2
- package/es/Legend/index.d.ts +3 -0
- package/es/Legend/index.js +4 -2
- package/es/LineChart/index.js +5 -2
- package/es/ScatterChart/ScatterChartTooltip.d.ts +3 -0
- package/es/ScatterChart/ScatterChartTooltip.js +3 -2
- package/es/ScatterChart/index.d.ts +3 -0
- package/es/ScatterChart/index.js +5 -2
- package/es/common/BaseChartProps.d.ts +3 -0
- package/es/common/ChartLegend.d.ts +3 -1
- package/es/common/ChartLegend.js +2 -1
- package/es/common/ChartTooltip/index.d.ts +4 -1
- package/es/common/ChartTooltip/index.js +3 -2
- package/es/common/CustomTooltipProps.d.ts +3 -0
- package/package.json +3 -3
package/es/AreaChart/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
7
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
8
|
-
var _excluded = ["data", "categories", "index", "stack", "colors", "valueFormatter", "startEndOnly", "showXAxis", "showYAxis", "yAxisWidth", "intervalType", "showAnimation", "animationDuration", "showTooltip", "showLegend", "showGridLines", "showGradient", "autoMinValue", "curveType", "minValue", "maxValue", "connectNulls", "allowDecimals", "noDataText", "className", "onValueChange", "enableLegendSlider", "customTooltip", "rotateLabelX", "tickGap", "xAxisLabel", "yAxisLabel", "width", "height", "style"];
|
|
8
|
+
var _excluded = ["data", "categories", "index", "stack", "colors", "valueFormatter", "startEndOnly", "showXAxis", "showYAxis", "yAxisWidth", "intervalType", "showAnimation", "animationDuration", "showTooltip", "showLegend", "showGridLines", "showGradient", "autoMinValue", "curveType", "minValue", "maxValue", "connectNulls", "allowDecimals", "noDataText", "className", "onValueChange", "enableLegendSlider", "customTooltip", "rotateLabelX", "tickGap", "xAxisLabel", "yAxisLabel", "width", "height", "style", "customCategories"];
|
|
9
9
|
import { css } from 'antd-style';
|
|
10
10
|
import { Fragment, forwardRef, useState } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -84,6 +84,7 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
84
84
|
_props$height = props.height,
|
|
85
85
|
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
86
86
|
style = props.style,
|
|
87
|
+
customCategories = props.customCategories,
|
|
87
88
|
rest = _objectWithoutProperties(props, _excluded);
|
|
88
89
|
var CustomTooltip = customTooltip;
|
|
89
90
|
var paddingValue = !showXAxis && !showYAxis || startEndOnly && !showYAxis ? 0 : 20;
|
|
@@ -221,6 +222,7 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
221
222
|
label = _ref.label;
|
|
222
223
|
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
223
224
|
active: active,
|
|
225
|
+
customCategories: customCategories,
|
|
224
226
|
label: label,
|
|
225
227
|
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
226
228
|
var _categoryColors$get;
|
|
@@ -231,6 +233,7 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
231
233
|
}) : /*#__PURE__*/_jsx(ChartTooltip, {
|
|
232
234
|
active: active,
|
|
233
235
|
categoryColors: categoryColors,
|
|
236
|
+
customCategories: customCategories,
|
|
234
237
|
label: label,
|
|
235
238
|
payload: payload,
|
|
236
239
|
valueFormatter: valueFormatter
|
|
@@ -254,7 +257,7 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
254
257
|
payload: payload
|
|
255
258
|
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
256
259
|
return onCategoryClick(clickedLegendItem);
|
|
257
|
-
} : undefined, enableLegendSlider);
|
|
260
|
+
} : undefined, enableLegendSlider, customCategories);
|
|
258
261
|
},
|
|
259
262
|
height: legendHeight,
|
|
260
263
|
verticalAlign: "top"
|
package/es/BarChart/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
7
|
var _templateObject;
|
|
8
|
-
var _excluded = ["data", "categories", "index", "colors", "valueFormatter", "layout", "stack", "relative", "startEndOnly", "animationDuration", "showAnimation", "showXAxis", "showYAxis", "yAxisWidth", "intervalType", "showTooltip", "showLegend", "showGridLines", "autoMinValue", "minValue", "maxValue", "allowDecimals", "noDataText", "onValueChange", "enableLegendSlider", "customTooltip", "rotateLabelX", "barCategoryGap", "tickGap", "xAxisLabel", "yAxisLabel", "className", "width", "height", "style"];
|
|
8
|
+
var _excluded = ["data", "categories", "customCategories", "index", "colors", "valueFormatter", "layout", "stack", "relative", "startEndOnly", "animationDuration", "showAnimation", "showXAxis", "showYAxis", "yAxisWidth", "intervalType", "showTooltip", "showLegend", "showGridLines", "autoMinValue", "minValue", "maxValue", "allowDecimals", "noDataText", "onValueChange", "enableLegendSlider", "customTooltip", "rotateLabelX", "barCategoryGap", "tickGap", "xAxisLabel", "yAxisLabel", "className", "width", "height", "style"];
|
|
9
9
|
import { css } from 'antd-style';
|
|
10
10
|
import { forwardRef, useState } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -30,6 +30,7 @@ var BarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
30
30
|
data = _props$data === void 0 ? [] : _props$data,
|
|
31
31
|
_props$categories = props.categories,
|
|
32
32
|
categories = _props$categories === void 0 ? [] : _props$categories,
|
|
33
|
+
customCategories = props.customCategories,
|
|
33
34
|
index = props.index,
|
|
34
35
|
_props$colors = props.colors,
|
|
35
36
|
colors = _props$colors === void 0 ? themeColorRange : _props$colors,
|
|
@@ -291,6 +292,7 @@ var BarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
291
292
|
label = _ref.label;
|
|
292
293
|
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
293
294
|
active: active,
|
|
295
|
+
customCategories: customCategories,
|
|
294
296
|
label: label,
|
|
295
297
|
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
296
298
|
var _categoryColors$get;
|
|
@@ -301,6 +303,7 @@ var BarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
301
303
|
}) : /*#__PURE__*/_jsx(ChartTooltip, {
|
|
302
304
|
active: active,
|
|
303
305
|
categoryColors: categoryColors,
|
|
306
|
+
customCategories: customCategories,
|
|
304
307
|
label: label,
|
|
305
308
|
payload: payload,
|
|
306
309
|
valueFormatter: valueFormatter
|
|
@@ -323,7 +326,7 @@ var BarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
323
326
|
payload: payload
|
|
324
327
|
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
325
328
|
return onCategoryClick(clickedLegendItem);
|
|
326
|
-
} : undefined, enableLegendSlider);
|
|
329
|
+
} : undefined, enableLegendSlider, customCategories);
|
|
327
330
|
},
|
|
328
331
|
height: legendHeight,
|
|
329
332
|
verticalAlign: "top"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ValueFormatter } from "../types";
|
|
2
2
|
export interface DonutChartTooltipProps {
|
|
3
3
|
active: boolean | undefined;
|
|
4
|
+
customCategories?: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
4
7
|
payload: any;
|
|
5
8
|
valueFormatter: ValueFormatter;
|
|
6
9
|
}
|
|
7
|
-
export declare const DonutChartTooltip: ({ active, payload, valueFormatter }: DonutChartTooltipProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export declare const DonutChartTooltip: ({ customCategories, active, payload, valueFormatter, }: DonutChartTooltipProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -4,7 +4,8 @@ import ChartTooltipFrame from "../common/ChartTooltip/ChartTooltipFrame";
|
|
|
4
4
|
import ChartTooltipRow from "../common/ChartTooltip/ChartTooltipRow";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
export var DonutChartTooltip = function DonutChartTooltip(_ref) {
|
|
7
|
-
var
|
|
7
|
+
var customCategories = _ref.customCategories,
|
|
8
|
+
active = _ref.active,
|
|
8
9
|
payload = _ref.payload,
|
|
9
10
|
valueFormatter = _ref.valueFormatter;
|
|
10
11
|
if (active && payload !== null && payload !== void 0 && payload[0]) {
|
|
@@ -15,7 +16,7 @@ export var DonutChartTooltip = function DonutChartTooltip(_ref) {
|
|
|
15
16
|
paddingInline: 16,
|
|
16
17
|
children: /*#__PURE__*/_jsx(ChartTooltipRow, {
|
|
17
18
|
color: payloadRow.payload.color,
|
|
18
|
-
name: payloadRow.name,
|
|
19
|
+
name: (customCategories === null || customCategories === void 0 ? void 0 : customCategories[payloadRow.name]) || payloadRow.name,
|
|
19
20
|
value: valueFormatter(payloadRow.value)
|
|
20
21
|
})
|
|
21
22
|
})
|
package/es/DonutChart/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export interface DonutChartProps extends BaseAnimationTimingProps {
|
|
|
9
9
|
category?: string;
|
|
10
10
|
className?: string;
|
|
11
11
|
colors?: string[];
|
|
12
|
+
customCategories?: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
12
15
|
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
13
16
|
data: any[];
|
|
14
17
|
index?: string;
|
package/es/DonutChart/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
6
6
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
8
|
var _templateObject;
|
|
9
|
-
var _excluded = ["data", "category", "index", "colors", "variant", "valueFormatter", "label", "showLabel", "animationDuration", "showAnimation", "showTooltip", "noDataText", "onValueChange", "customTooltip", "className", "width", "height", "style"];
|
|
9
|
+
var _excluded = ["data", "category", "index", "colors", "variant", "valueFormatter", "label", "showLabel", "animationDuration", "showAnimation", "showTooltip", "noDataText", "onValueChange", "customTooltip", "className", "width", "height", "style", "customCategories"];
|
|
10
10
|
import { css } from 'antd-style';
|
|
11
11
|
import { forwardRef, useEffect, useState } from 'react';
|
|
12
12
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -56,6 +56,7 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
56
56
|
_props$height = props.height,
|
|
57
57
|
height = _props$height === void 0 ? '10rem' : _props$height,
|
|
58
58
|
style = props.style,
|
|
59
|
+
customCategories = props.customCategories,
|
|
59
60
|
rest = _objectWithoutProperties(props, _excluded);
|
|
60
61
|
var CustomTooltip = customTooltip;
|
|
61
62
|
var isDonut = variant === 'donut';
|
|
@@ -162,6 +163,7 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
162
163
|
payload = _ref.payload;
|
|
163
164
|
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
164
165
|
active: active,
|
|
166
|
+
customCategories: customCategories,
|
|
165
167
|
label: payload === null || payload === void 0 || (_payload$ = payload[0]) === null || _payload$ === void 0 ? void 0 : _payload$.name,
|
|
166
168
|
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
167
169
|
var _payload$0$payload$co, _payload$2;
|
|
@@ -171,6 +173,7 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
171
173
|
})
|
|
172
174
|
}) : /*#__PURE__*/_jsx(DonutChartTooltip, {
|
|
173
175
|
active: active,
|
|
176
|
+
customCategories: customCategories,
|
|
174
177
|
payload: payload,
|
|
175
178
|
valueFormatter: valueFormatter
|
|
176
179
|
});
|
package/es/Legend/LegendItem.js
CHANGED
|
@@ -18,7 +18,8 @@ var useStyles = createStyles(function (_ref) {
|
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
20
|
var LegendItem = /*#__PURE__*/memo(function (_ref2) {
|
|
21
|
-
var
|
|
21
|
+
var label = _ref2.label,
|
|
22
|
+
name = _ref2.name,
|
|
22
23
|
color = _ref2.color,
|
|
23
24
|
_onClick = _ref2.onClick,
|
|
24
25
|
activeLegend = _ref2.activeLegend;
|
|
@@ -58,7 +59,7 @@ var LegendItem = /*#__PURE__*/memo(function (_ref2) {
|
|
|
58
59
|
margin: 0,
|
|
59
60
|
opacity: activeLegend && activeLegend !== name ? 0.4 : 1
|
|
60
61
|
},
|
|
61
|
-
children:
|
|
62
|
+
children: label
|
|
62
63
|
})]
|
|
63
64
|
});
|
|
64
65
|
});
|
package/es/Legend/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export interface LegendProps extends FlexboxProps {
|
|
|
4
4
|
activeLegend?: string;
|
|
5
5
|
categories: string[];
|
|
6
6
|
colors?: string[];
|
|
7
|
+
customCategories?: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
7
10
|
enableLegendSlider?: boolean;
|
|
8
11
|
onClickLegendItem?: (category: string, color: string) => void;
|
|
9
12
|
}
|
package/es/Legend/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
5
|
-
var _excluded = ["categories", "colors", "className", "onClickLegendItem", "activeLegend", "enableLegendSlider"];
|
|
5
|
+
var _excluded = ["customCategories", "categories", "colors", "className", "onClickLegendItem", "activeLegend", "enableLegendSlider"];
|
|
6
6
|
var _templateObject, _templateObject2, _templateObject3;
|
|
7
7
|
import { createStyles } from 'antd-style';
|
|
8
8
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
@@ -26,7 +26,8 @@ var Legend = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
26
26
|
cx = _useStyles.cx,
|
|
27
27
|
styles = _useStyles.styles;
|
|
28
28
|
var themeColorRange = useThemeColorRange();
|
|
29
|
-
var
|
|
29
|
+
var customCategories = props.customCategories,
|
|
30
|
+
categories = props.categories,
|
|
30
31
|
_props$colors = props.colors,
|
|
31
32
|
colors = _props$colors === void 0 ? themeColorRange : _props$colors,
|
|
32
33
|
className = props.className,
|
|
@@ -139,6 +140,7 @@ var Legend = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
139
140
|
return /*#__PURE__*/_jsx(LegendItem, {
|
|
140
141
|
activeLegend: activeLegend,
|
|
141
142
|
color: colors[idx % colors.length],
|
|
143
|
+
label: (customCategories === null || customCategories === void 0 ? void 0 : customCategories[category]) || category,
|
|
142
144
|
name: category,
|
|
143
145
|
onClick: onClickLegendItem
|
|
144
146
|
}, "item-".concat(idx));
|
package/es/LineChart/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
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", "style"];
|
|
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", "style", "customCategories"];
|
|
9
9
|
import { css } from 'antd-style';
|
|
10
10
|
import { Fragment, forwardRef, useState } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -80,6 +80,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
80
80
|
_props$height = props.height,
|
|
81
81
|
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
82
82
|
style = props.style,
|
|
83
|
+
customCategories = props.customCategories,
|
|
83
84
|
rest = _objectWithoutProperties(props, _excluded);
|
|
84
85
|
var CustomTooltip = customTooltip;
|
|
85
86
|
var paddingValue = !showXAxis && !showYAxis ? 0 : 20;
|
|
@@ -217,6 +218,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
217
218
|
label = _ref.label;
|
|
218
219
|
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
219
220
|
active: active,
|
|
221
|
+
customCategories: customCategories,
|
|
220
222
|
label: label,
|
|
221
223
|
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
222
224
|
var _categoryColors$get;
|
|
@@ -227,6 +229,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
227
229
|
}) : /*#__PURE__*/_jsx(ChartTooltip, {
|
|
228
230
|
active: active,
|
|
229
231
|
categoryColors: categoryColors,
|
|
232
|
+
customCategories: customCategories,
|
|
230
233
|
label: label,
|
|
231
234
|
payload: payload,
|
|
232
235
|
valueFormatter: valueFormatter
|
|
@@ -250,7 +253,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
250
253
|
payload: payload
|
|
251
254
|
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
252
255
|
return onCategoryClick(clickedLegendItem);
|
|
253
|
-
} : undefined, enableLegendSlider);
|
|
256
|
+
} : undefined, enableLegendSlider, customCategories);
|
|
254
257
|
},
|
|
255
258
|
height: legendHeight,
|
|
256
259
|
verticalAlign: "top"
|
|
@@ -20,7 +20,8 @@ var useStyles = createStyles(function (_ref) {
|
|
|
20
20
|
});
|
|
21
21
|
var ScatterChartTooltip = /*#__PURE__*/memo(function (_ref2) {
|
|
22
22
|
var _categoryColors$get, _payload$;
|
|
23
|
-
var
|
|
23
|
+
var customCategories = _ref2.customCategories,
|
|
24
|
+
label = _ref2.label,
|
|
24
25
|
active = _ref2.active,
|
|
25
26
|
payload = _ref2.payload,
|
|
26
27
|
valueFormatter = _ref2.valueFormatter,
|
|
@@ -71,7 +72,7 @@ var ScatterChartTooltip = /*#__PURE__*/memo(function (_ref2) {
|
|
|
71
72
|
})) !== null && _Object$keys$find !== void 0 ? _Object$keys$find : '';
|
|
72
73
|
var valueFormatterFn = (_valueFormatter = valueFormatter[valueFormatterKey]) !== null && _valueFormatter !== void 0 ? _valueFormatter : defaultValueFormatter;
|
|
73
74
|
return /*#__PURE__*/_jsx(ScatterChartTooltipRow, {
|
|
74
|
-
name: name,
|
|
75
|
+
name: (customCategories === null || customCategories === void 0 ? void 0 : customCategories[name]) || name,
|
|
75
76
|
value: valueFormatter && valueFormatterFn ? valueFormatterFn(value) : "".concat(value)
|
|
76
77
|
}, "id-".concat(idx));
|
|
77
78
|
})
|
|
@@ -15,6 +15,9 @@ export interface ScatterChartProps extends BaseAnimationTimingProps, HTMLAttribu
|
|
|
15
15
|
autoMinYValue?: boolean;
|
|
16
16
|
category: string;
|
|
17
17
|
colors?: string[];
|
|
18
|
+
customCategories?: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
18
21
|
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
19
22
|
data: any[];
|
|
20
23
|
enableLegendSlider?: boolean;
|
package/es/ScatterChart/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
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", "style"];
|
|
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", "style", "customCategories"];
|
|
9
9
|
import { css } from 'antd-style';
|
|
10
10
|
import { forwardRef, useState } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -90,6 +90,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
90
90
|
_props$height = props.height,
|
|
91
91
|
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
92
92
|
style = props.style,
|
|
93
|
+
customCategories = props.customCategories,
|
|
93
94
|
rest = _objectWithoutProperties(props, _excluded);
|
|
94
95
|
var CustomTooltip = customTooltip;
|
|
95
96
|
var _useState = useState(60),
|
|
@@ -232,6 +233,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
232
233
|
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;
|
|
233
234
|
return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
|
|
234
235
|
active: active,
|
|
236
|
+
customCategories: customCategories,
|
|
235
237
|
label: color,
|
|
236
238
|
payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
|
|
237
239
|
var _categoryColors$get;
|
|
@@ -248,6 +250,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
248
250
|
},
|
|
249
251
|
category: category,
|
|
250
252
|
categoryColors: categoryColors,
|
|
253
|
+
customCategories: customCategories,
|
|
251
254
|
label: color,
|
|
252
255
|
payload: payload,
|
|
253
256
|
valueFormatter: valueFormatter
|
|
@@ -293,7 +296,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
293
296
|
payload: payload
|
|
294
297
|
}, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
|
|
295
298
|
return onCategoryClick(clickedLegendItem);
|
|
296
|
-
} : undefined, enableLegendSlider);
|
|
299
|
+
} : undefined, enableLegendSlider, customCategories);
|
|
297
300
|
},
|
|
298
301
|
height: legendHeight,
|
|
299
302
|
verticalAlign: "top"
|
|
@@ -16,6 +16,9 @@ interface BaseChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDi
|
|
|
16
16
|
autoMinValue?: boolean;
|
|
17
17
|
categories: string[];
|
|
18
18
|
colors?: string[];
|
|
19
|
+
customCategories?: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
19
22
|
customTooltip?: ComponentType<CustomTooltipProps>;
|
|
20
23
|
data: any[];
|
|
21
24
|
enableLegendSlider?: boolean;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
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
|
|
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
|
+
[key: string]: string;
|
|
4
|
+
} | undefined) => import("react/jsx-runtime").JSX.Element;
|
|
3
5
|
export default ChartLegend;
|
package/es/common/ChartLegend.js
CHANGED
|
@@ -8,7 +8,7 @@ var calculateHeight = function calculateHeight(height) {
|
|
|
8
8
|
: 60;
|
|
9
9
|
}; // default height
|
|
10
10
|
|
|
11
|
-
var ChartLegend = function ChartLegend(_ref, categoryColors, setLegendHeight, activeLegend, onClick, enableLegendSlider) {
|
|
11
|
+
var ChartLegend = function ChartLegend(_ref, categoryColors, setLegendHeight, activeLegend, onClick, enableLegendSlider, customCategories) {
|
|
12
12
|
var payload = _ref.payload;
|
|
13
13
|
var legendRef = useRef(null);
|
|
14
14
|
useOnWindowResize(function () {
|
|
@@ -31,6 +31,7 @@ var ChartLegend = function ChartLegend(_ref, categoryColors, setLegendHeight, ac
|
|
|
31
31
|
colors: filteredPayload.map(function (entry) {
|
|
32
32
|
return categoryColors.get(entry.value);
|
|
33
33
|
}),
|
|
34
|
+
customCategories: customCategories,
|
|
34
35
|
enableLegendSlider: enableLegendSlider,
|
|
35
36
|
onClickLegendItem: onClick
|
|
36
37
|
})
|
|
@@ -2,9 +2,12 @@ import { ValueFormatter } from "../../types";
|
|
|
2
2
|
export interface ChartTooltipProps {
|
|
3
3
|
active: boolean | undefined;
|
|
4
4
|
categoryColors: Map<string, string>;
|
|
5
|
+
customCategories?: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
5
8
|
label: string;
|
|
6
9
|
payload: any;
|
|
7
10
|
valueFormatter: ValueFormatter;
|
|
8
11
|
}
|
|
9
|
-
declare const ChartTooltip: ({ active, payload, label, categoryColors, valueFormatter, }: ChartTooltipProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
declare const ChartTooltip: ({ active, payload, label, categoryColors, valueFormatter, customCategories, }: ChartTooltipProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
13
|
export default ChartTooltip;
|
|
@@ -19,7 +19,8 @@ var ChartTooltip = function ChartTooltip(_ref2) {
|
|
|
19
19
|
payload = _ref2.payload,
|
|
20
20
|
label = _ref2.label,
|
|
21
21
|
categoryColors = _ref2.categoryColors,
|
|
22
|
-
valueFormatter = _ref2.valueFormatter
|
|
22
|
+
valueFormatter = _ref2.valueFormatter,
|
|
23
|
+
customCategories = _ref2.customCategories;
|
|
23
24
|
var _useStyles = useStyles(),
|
|
24
25
|
cx = _useStyles.cx,
|
|
25
26
|
theme = _useStyles.theme,
|
|
@@ -53,7 +54,7 @@ var ChartTooltip = function ChartTooltip(_ref2) {
|
|
|
53
54
|
name = _ref3.name;
|
|
54
55
|
return /*#__PURE__*/_jsx(ChartTooltipRow, {
|
|
55
56
|
color: (_categoryColors$get = categoryColors.get(name)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary,
|
|
56
|
-
name: name,
|
|
57
|
+
name: (customCategories === null || customCategories === void 0 ? void 0 : customCategories[name]) || name,
|
|
57
58
|
value: valueFormatter(value)
|
|
58
59
|
}, "id-".concat(idx));
|
|
59
60
|
})
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { NameType, Payload } from 'recharts/types/component/DefaultTooltipContent';
|
|
2
2
|
export type CustomTooltipProps = {
|
|
3
3
|
active: boolean | undefined;
|
|
4
|
+
customCategories?: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
4
7
|
label: NameType | undefined;
|
|
5
8
|
payload: Payload<string | number | (string | number)[], string | number>[] | undefined;
|
|
6
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "React modern charts components built on recharts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@types/query-string": "^6.3.0",
|
|
84
84
|
"@types/react": "18.2.40",
|
|
85
85
|
"@types/react-dom": "^18.3.0",
|
|
86
|
-
"@vitest/coverage-v8": "
|
|
87
|
-
"babel-plugin-antd-style": "
|
|
86
|
+
"@vitest/coverage-v8": "~1.2.2",
|
|
87
|
+
"babel-plugin-antd-style": "^1.0.4",
|
|
88
88
|
"commitlint": "^19.3.0",
|
|
89
89
|
"concurrently": "^8.2.2",
|
|
90
90
|
"cross-env": "^7.0.3",
|