@lobehub/charts 1.0.0 → 1.2.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/README.md +1 -0
- package/es/AreaChart/index.js +9 -5
- package/es/BarChart/index.js +5 -1
- package/es/BarList/index.d.ts +24 -0
- package/es/BarList/index.js +149 -0
- package/es/BarList/styles.d.ts +10 -0
- package/es/BarList/styles.js +17 -0
- package/es/DonutChart/index.d.ts +2 -1
- package/es/DonutChart/index.js +7 -3
- package/es/Heatmaps/Calendar.d.ts +18 -0
- package/es/Heatmaps/Calendar.js +67 -0
- package/es/Heatmaps/ChartLabels.d.ts +15 -0
- package/es/Heatmaps/ChartLabels.js +50 -0
- package/es/Heatmaps/Footer.d.ts +22 -0
- package/es/Heatmaps/Footer.js +60 -0
- package/es/Heatmaps/index.d.ts +28 -0
- package/es/Heatmaps/index.js +181 -0
- package/es/Heatmaps/styles.d.ts +7 -0
- package/es/Heatmaps/styles.js +14 -0
- package/es/LineChart/index.js +10 -6
- package/es/ScatterChart/index.js +10 -6
- package/es/SparkChart/SparkAreaChart.d.ts +11 -0
- package/es/SparkChart/SparkAreaChart.js +140 -0
- package/es/SparkChart/SparkBarChart.d.ts +8 -0
- package/es/SparkChart/SparkBarChart.js +98 -0
- package/es/SparkChart/SparkLineChart.d.ts +9 -0
- package/es/SparkChart/SparkLineChart.js +102 -0
- package/es/SparkChart/index.d.ts +3 -0
- package/es/SparkChart/index.js +3 -0
- package/es/Tracker/TrackerBlock.d.ts +8 -0
- package/es/Tracker/TrackerBlock.js +62 -0
- package/es/Tracker/index.d.ts +18 -0
- package/es/Tracker/index.js +98 -0
- package/es/Tracker/styles.d.ts +5 -0
- package/es/Tracker/styles.js +12 -0
- package/es/common/BaseSparkChartProps.d.ts +13 -0
- package/es/common/BaseSparkChartProps.js +1 -0
- package/es/common/utils.d.ts +2 -2
- package/es/common/utils.js +4 -4
- package/es/hooks/useOnWindowResize.js +2 -1
- package/es/hooks/usePrefersReducedMotion.d.ts +1 -0
- package/es/hooks/usePrefersReducedMotion.js +23 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +5 -1
- package/es/types.d.ts +25 -0
- package/es/utils/calendar.d.ts +29 -0
- package/es/utils/calendar.js +194 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/theme.d.ts +2 -0
- package/es/utils/theme.js +49 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -156,6 +156,7 @@ Every bit counts and your one-time donation sparkles in our galaxy of support! Y
|
|
|
156
156
|
|
|
157
157
|
- **recharts** - <https://github.com/recharts/recharts>
|
|
158
158
|
- **tremor** - <https://github.com/tremorlabs/tremor>
|
|
159
|
+
- **react-activity-calendar** - <https://github.com/grubersjoe/react-activity-calendar>
|
|
159
160
|
|
|
160
161
|
<div align="right">
|
|
161
162
|
|
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"];
|
|
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"];
|
|
9
9
|
import { css } from 'antd-style';
|
|
10
10
|
import { Fragment, forwardRef, useState } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -83,6 +83,7 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
83
83
|
width = _props$width === void 0 ? '100%' : _props$width,
|
|
84
84
|
_props$height = props.height,
|
|
85
85
|
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
86
|
+
style = props.style,
|
|
86
87
|
rest = _objectWithoutProperties(props, _excluded);
|
|
87
88
|
var CustomTooltip = customTooltip;
|
|
88
89
|
var paddingValue = !showXAxis && !showYAxis || startEndOnly && !showYAxis ? 0 : 20;
|
|
@@ -101,7 +102,7 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
101
102
|
var categoryColors = constructCategoryColors(categories, colors);
|
|
102
103
|
var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
|
|
103
104
|
var hasOnValueChange = !!onValueChange;
|
|
104
|
-
function onDotClick(itemData, event) {
|
|
105
|
+
var onDotClick = function onDotClick(itemData, event) {
|
|
105
106
|
event.stopPropagation();
|
|
106
107
|
if (!hasOnValueChange) return;
|
|
107
108
|
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) {
|
|
@@ -119,8 +120,8 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
119
120
|
eventType: 'dot'
|
|
120
121
|
}, itemData.payload));
|
|
121
122
|
}
|
|
122
|
-
}
|
|
123
|
-
function onCategoryClick(dataKey) {
|
|
123
|
+
};
|
|
124
|
+
var onCategoryClick = function onCategoryClick(dataKey) {
|
|
124
125
|
if (!hasOnValueChange) return;
|
|
125
126
|
if (dataKey === activeLegend && !activeDot || hasOnlyOneValueForThisKey(data, dataKey) && activeDot && activeDot.dataKey === dataKey) {
|
|
126
127
|
setActiveLegend(undefined);
|
|
@@ -133,11 +134,14 @@ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
setActiveDot(undefined);
|
|
136
|
-
}
|
|
137
|
+
};
|
|
137
138
|
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
138
139
|
className: className,
|
|
139
140
|
height: height,
|
|
140
141
|
ref: ref,
|
|
142
|
+
style: _objectSpread({
|
|
143
|
+
position: 'relative'
|
|
144
|
+
}, style),
|
|
141
145
|
width: width
|
|
142
146
|
}, rest), {}, {
|
|
143
147
|
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
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"];
|
|
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"];
|
|
9
9
|
import { css } from 'antd-style';
|
|
10
10
|
import { forwardRef, useState } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -83,6 +83,7 @@ var BarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
83
83
|
width = _props$width === void 0 ? '100%' : _props$width,
|
|
84
84
|
_props$height = props.height,
|
|
85
85
|
height = _props$height === void 0 ? '20rem' : _props$height,
|
|
86
|
+
style = props.style,
|
|
86
87
|
rest = _objectWithoutProperties(props, _excluded);
|
|
87
88
|
var CustomTooltip = customTooltip;
|
|
88
89
|
var paddingValue = !showXAxis && !showYAxis ? 0 : 20;
|
|
@@ -140,6 +141,9 @@ var BarChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
140
141
|
className: className,
|
|
141
142
|
height: height,
|
|
142
143
|
ref: ref,
|
|
144
|
+
style: _objectSpread({
|
|
145
|
+
position: 'relative'
|
|
146
|
+
}, style),
|
|
143
147
|
width: width
|
|
144
148
|
}, rest), {}, {
|
|
145
149
|
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ValueFormatter } from "../types";
|
|
3
|
+
export interface Bar {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
color?: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
key?: string;
|
|
9
|
+
name: ReactNode;
|
|
10
|
+
target?: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}
|
|
13
|
+
export interface BarListProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
color?: string;
|
|
15
|
+
data: Bar[];
|
|
16
|
+
leftLabel?: ReactNode;
|
|
17
|
+
onValueChange?: (payload: Bar) => void;
|
|
18
|
+
rightLabel?: ReactNode;
|
|
19
|
+
showAnimation?: boolean;
|
|
20
|
+
sortOrder?: 'ascending' | 'descending' | 'none';
|
|
21
|
+
valueFormatter?: ValueFormatter;
|
|
22
|
+
}
|
|
23
|
+
declare const BarList: React.ForwardRefExoticComponent<BarListProps & React.RefAttributes<HTMLDivElement>>;
|
|
24
|
+
export default BarList;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
var _excluded = ["data", "color", "valueFormatter", "showAnimation", "onValueChange", "sortOrder", "className", "leftLabel", "rightLabel", "style"];
|
|
7
|
+
import A from '@lobehub/ui/es/A';
|
|
8
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
9
|
+
import { Flexbox } from 'react-layout-kit';
|
|
10
|
+
import { useThemeColorRange } from "../hooks/useThemeColorRange";
|
|
11
|
+
import { defaultValueFormatter } from "../utils";
|
|
12
|
+
import { useStyles } from "./styles";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
var BarList = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
16
|
+
var _useStyles = useStyles(),
|
|
17
|
+
cx = _useStyles.cx,
|
|
18
|
+
styles = _useStyles.styles;
|
|
19
|
+
var themeColorRange = useThemeColorRange();
|
|
20
|
+
var _props$data = props.data,
|
|
21
|
+
data = _props$data === void 0 ? [] : _props$data,
|
|
22
|
+
_props$color = props.color,
|
|
23
|
+
color = _props$color === void 0 ? themeColorRange[0] : _props$color,
|
|
24
|
+
_props$valueFormatter = props.valueFormatter,
|
|
25
|
+
valueFormatter = _props$valueFormatter === void 0 ? defaultValueFormatter : _props$valueFormatter,
|
|
26
|
+
_props$showAnimation = props.showAnimation,
|
|
27
|
+
showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
|
|
28
|
+
onValueChange = props.onValueChange,
|
|
29
|
+
_props$sortOrder = props.sortOrder,
|
|
30
|
+
sortOrder = _props$sortOrder === void 0 ? 'descending' : _props$sortOrder,
|
|
31
|
+
className = props.className,
|
|
32
|
+
leftLabel = props.leftLabel,
|
|
33
|
+
rightLabel = props.rightLabel,
|
|
34
|
+
style = props.style,
|
|
35
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
36
|
+
var sortedData = useMemo(function () {
|
|
37
|
+
if (sortOrder === 'none') {
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
return _toConsumableArray(data).sort(function (a, b) {
|
|
41
|
+
return sortOrder === 'ascending' ? a.value - b.value : b.value - a.value;
|
|
42
|
+
});
|
|
43
|
+
}, [data, sortOrder]);
|
|
44
|
+
var widths = useMemo(function () {
|
|
45
|
+
var maxValue = Math.max.apply(Math, _toConsumableArray(sortedData.map(function (item) {
|
|
46
|
+
return item.value;
|
|
47
|
+
})).concat([0]));
|
|
48
|
+
return sortedData.map(function (item) {
|
|
49
|
+
return item.value === 0 ? 0 : Math.max(item.value / maxValue * 100, 2);
|
|
50
|
+
});
|
|
51
|
+
}, [sortedData]);
|
|
52
|
+
var rowHeight = 32;
|
|
53
|
+
var labelHeight = 20;
|
|
54
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
55
|
+
"aria-sort": sortOrder,
|
|
56
|
+
className: className,
|
|
57
|
+
gap: 24,
|
|
58
|
+
horizontal: true,
|
|
59
|
+
justify: 'space-between',
|
|
60
|
+
ref: ref,
|
|
61
|
+
style: _objectSpread({
|
|
62
|
+
position: 'relative'
|
|
63
|
+
}, style)
|
|
64
|
+
}, rest), {}, {
|
|
65
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
66
|
+
flex: 1,
|
|
67
|
+
gap: 8,
|
|
68
|
+
style: {
|
|
69
|
+
position: 'relative'
|
|
70
|
+
},
|
|
71
|
+
children: [(leftLabel || rightLabel) && /*#__PURE__*/_jsx(Flexbox, {
|
|
72
|
+
className: cx(styles.label, styles.emphasis),
|
|
73
|
+
height: labelHeight,
|
|
74
|
+
width: "100%",
|
|
75
|
+
children: leftLabel
|
|
76
|
+
}), sortedData.map(function (item, index) {
|
|
77
|
+
var _item$key, _item$color;
|
|
78
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
79
|
+
align: 'center',
|
|
80
|
+
className: styles.barContainer,
|
|
81
|
+
height: rowHeight,
|
|
82
|
+
horizontal: true,
|
|
83
|
+
onClick: function onClick() {
|
|
84
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(item);
|
|
85
|
+
},
|
|
86
|
+
style: {
|
|
87
|
+
cursor: onValueChange ? 'pointer' : 'default',
|
|
88
|
+
width: "".concat(widths[index], "%")
|
|
89
|
+
},
|
|
90
|
+
width: '100%',
|
|
91
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
92
|
+
className: cx(styles.bar, onValueChange && styles.barHover),
|
|
93
|
+
style: {
|
|
94
|
+
background: (_item$color = item.color) !== null && _item$color !== void 0 ? _item$color : color,
|
|
95
|
+
transition: showAnimation ? undefined : 'none',
|
|
96
|
+
width: "".concat(widths[index], "%"),
|
|
97
|
+
zIndex: 0
|
|
98
|
+
}
|
|
99
|
+
}), /*#__PURE__*/_jsxs(Flexbox, {
|
|
100
|
+
align: 'center',
|
|
101
|
+
gap: 8,
|
|
102
|
+
horizontal: true,
|
|
103
|
+
paddingInline: 8,
|
|
104
|
+
style: {
|
|
105
|
+
zIndex: 1
|
|
106
|
+
},
|
|
107
|
+
children: [item.icon, item.href ? /*#__PURE__*/_jsx(A, {
|
|
108
|
+
className: cx(styles.sourceALabel, styles.emphasis),
|
|
109
|
+
href: item.href,
|
|
110
|
+
onClick: function onClick(event) {
|
|
111
|
+
return event.stopPropagation();
|
|
112
|
+
},
|
|
113
|
+
target: item.target,
|
|
114
|
+
children: item.name
|
|
115
|
+
}) : /*#__PURE__*/_jsx("div", {
|
|
116
|
+
className: cx(styles.sourceLabel, styles.emphasis),
|
|
117
|
+
children: item.name
|
|
118
|
+
})]
|
|
119
|
+
})]
|
|
120
|
+
}, (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : index);
|
|
121
|
+
})]
|
|
122
|
+
}), /*#__PURE__*/_jsxs(Flexbox, {
|
|
123
|
+
gap: 8,
|
|
124
|
+
children: [(leftLabel || rightLabel) && /*#__PURE__*/_jsx(Flexbox, {
|
|
125
|
+
className: cx(styles.label, styles.emphasis),
|
|
126
|
+
height: labelHeight,
|
|
127
|
+
style: {
|
|
128
|
+
textAlign: 'right'
|
|
129
|
+
},
|
|
130
|
+
width: "100%",
|
|
131
|
+
children: rightLabel
|
|
132
|
+
}), sortedData.map(function (item, index) {
|
|
133
|
+
var _item$key2;
|
|
134
|
+
return /*#__PURE__*/_jsx(Flexbox, {
|
|
135
|
+
align: 'center',
|
|
136
|
+
height: rowHeight,
|
|
137
|
+
horizontal: true,
|
|
138
|
+
justify: 'flex-end',
|
|
139
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
140
|
+
className: cx(styles.strongLabel, styles.emphasis),
|
|
141
|
+
children: valueFormatter(item.value)
|
|
142
|
+
})
|
|
143
|
+
}, (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : index);
|
|
144
|
+
})]
|
|
145
|
+
})]
|
|
146
|
+
}));
|
|
147
|
+
});
|
|
148
|
+
BarList.displayName = 'BarList';
|
|
149
|
+
export default BarList;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
2
|
+
bar: import("antd-style").SerializedStyles;
|
|
3
|
+
barContainer: import("antd-style").SerializedStyles;
|
|
4
|
+
barHover: import("antd-style").SerializedStyles;
|
|
5
|
+
emphasis: import("antd-style").SerializedStyles;
|
|
6
|
+
label: import("antd-style").SerializedStyles;
|
|
7
|
+
sourceALabel: import("antd-style").SerializedStyles;
|
|
8
|
+
sourceLabel: import("antd-style").SerializedStyles;
|
|
9
|
+
strongLabel: import("antd-style").SerializedStyles;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
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
|
+
bar: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n\n max-width: 100%;\n height: 100%;\n\n opacity: 0.25;\n border-radius: ", "px;\n\n transition: all 0.25s ", ";\n "])), token.borderRadius, token.motionEaseInOut),
|
|
9
|
+
barContainer: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n "]))),
|
|
10
|
+
barHover: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &:hover {\n opacity: 0.4;\n }\n "]))),
|
|
11
|
+
emphasis: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n "]))),
|
|
12
|
+
label: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n color: ", ";\n "])), token.colorTextDescription),
|
|
13
|
+
sourceALabel: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n color: ", " !important;\n\n &:hover {\n color: ", " !important;\n }\n "])), token.colorText, token.colorLinkHover),
|
|
14
|
+
sourceLabel: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n color: ", ";\n "])), token.colorText),
|
|
15
|
+
strongLabel: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n font-size: 14px;\n font-weight: 500;\n line-height: 16px;\n color: ", ";\n "])), token.colorText)
|
|
16
|
+
};
|
|
17
|
+
});
|
package/es/DonutChart/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import { CSSProperties, ComponentType } from 'react';
|
|
2
2
|
import type BaseAnimationTimingProps from "../common/BaseAnimationTimingProps";
|
|
3
3
|
import { CustomTooltipProps } from "../common/CustomTooltipProps";
|
|
4
4
|
import { type NoDataProps } from "../common/NoData";
|
|
@@ -18,6 +18,7 @@ export interface DonutChartProps extends BaseAnimationTimingProps {
|
|
|
18
18
|
showAnimation?: boolean;
|
|
19
19
|
showLabel?: boolean;
|
|
20
20
|
showTooltip?: boolean;
|
|
21
|
+
style?: CSSProperties;
|
|
21
22
|
valueFormatter?: ValueFormatter;
|
|
22
23
|
variant?: DonutChartVariant;
|
|
23
24
|
}
|
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"];
|
|
9
|
+
var _excluded = ["data", "category", "index", "colors", "variant", "valueFormatter", "label", "showLabel", "animationDuration", "showAnimation", "showTooltip", "noDataText", "onValueChange", "customTooltip", "className", "width", "height", "style"];
|
|
10
10
|
import { css } from 'antd-style';
|
|
11
11
|
import { forwardRef, useEffect, useState } from 'react';
|
|
12
12
|
import { Flexbox } from 'react-layout-kit';
|
|
@@ -55,6 +55,7 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
55
55
|
width = _props$width === void 0 ? '100%' : _props$width,
|
|
56
56
|
_props$height = props.height,
|
|
57
57
|
height = _props$height === void 0 ? '10rem' : _props$height,
|
|
58
|
+
style = props.style,
|
|
58
59
|
rest = _objectWithoutProperties(props, _excluded);
|
|
59
60
|
var CustomTooltip = customTooltip;
|
|
60
61
|
var isDonut = variant === 'donut';
|
|
@@ -64,7 +65,7 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
64
65
|
activeIndex = _useState2[0],
|
|
65
66
|
setActiveIndex = _useState2[1];
|
|
66
67
|
var hasOnValueChange = !!onValueChange;
|
|
67
|
-
function onShapeClick(data, index, event) {
|
|
68
|
+
var onShapeClick = function onShapeClick(data, index, event) {
|
|
68
69
|
event.stopPropagation();
|
|
69
70
|
if (!hasOnValueChange) return;
|
|
70
71
|
if (activeIndex === index) {
|
|
@@ -76,7 +77,7 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
76
77
|
eventType: 'slice'
|
|
77
78
|
}, data.payload.payload));
|
|
78
79
|
}
|
|
79
|
-
}
|
|
80
|
+
};
|
|
80
81
|
useEffect(function () {
|
|
81
82
|
var pieSectors = document.querySelectorAll('.recharts-pie-sector');
|
|
82
83
|
if (pieSectors) {
|
|
@@ -108,6 +109,9 @@ var DonutChart = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
108
109
|
className: className,
|
|
109
110
|
height: height,
|
|
110
111
|
ref: ref,
|
|
112
|
+
style: _objectSpread({
|
|
113
|
+
position: 'relative'
|
|
114
|
+
}, style),
|
|
111
115
|
width: width
|
|
112
116
|
}, rest), {}, {
|
|
113
117
|
children: /*#__PURE__*/_jsx(ResponsiveContainer, {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { Activity, Labels, Week } from "../types";
|
|
3
|
+
interface CalendarProps {
|
|
4
|
+
blockMargin: number;
|
|
5
|
+
blockRadius: number;
|
|
6
|
+
blockSize: number;
|
|
7
|
+
colorScale: string[];
|
|
8
|
+
customTooltip?: (activity: Activity) => ReactNode;
|
|
9
|
+
enableAnimation: boolean;
|
|
10
|
+
labelHeight: number;
|
|
11
|
+
labels: Labels;
|
|
12
|
+
maxLevel: number;
|
|
13
|
+
onValueChange?: (value: Activity) => void;
|
|
14
|
+
showTooltip: boolean;
|
|
15
|
+
weeks: Week[];
|
|
16
|
+
}
|
|
17
|
+
declare const Calendar: import("react").NamedExoticComponent<CalendarProps>;
|
|
18
|
+
export default Calendar;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
3
|
+
var _templateObject;
|
|
4
|
+
import { Tooltip } from '@lobehub/ui';
|
|
5
|
+
import { keyframes } from 'antd-style';
|
|
6
|
+
import { Fragment, memo } from 'react';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
var Calendar = /*#__PURE__*/memo(function (_ref) {
|
|
10
|
+
var weeks = _ref.weeks,
|
|
11
|
+
maxLevel = _ref.maxLevel,
|
|
12
|
+
enableAnimation = _ref.enableAnimation,
|
|
13
|
+
colorScale = _ref.colorScale,
|
|
14
|
+
blockSize = _ref.blockSize,
|
|
15
|
+
blockRadius = _ref.blockRadius,
|
|
16
|
+
blockMargin = _ref.blockMargin,
|
|
17
|
+
labelHeight = _ref.labelHeight,
|
|
18
|
+
showTooltip = _ref.showTooltip,
|
|
19
|
+
customTooltip = _ref.customTooltip,
|
|
20
|
+
labels = _ref.labels,
|
|
21
|
+
onValueChange = _ref.onValueChange;
|
|
22
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
23
|
+
children: weeks.map(function (week, weekIndex) {
|
|
24
|
+
return week.map(function (activity, dayIndex) {
|
|
25
|
+
if (!activity) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (activity.level < 0 || activity.level > maxLevel) {
|
|
29
|
+
throw new RangeError("Provided activity level ".concat(activity.level, " for ").concat(activity.date, " is out of range. It must be between 0 and ").concat(maxLevel, "."));
|
|
30
|
+
}
|
|
31
|
+
var style = enableAnimation ? {
|
|
32
|
+
animation: "".concat(keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n fill: var(--lobe-heatmaps-loading);\n }\n 50% {\n fill: var(--lobe-heatmaps-loading-active);\n }\n 100% {\n fill: var(--lobe-heatmaps-loading);\n }\n "]))), " 1.75s ease-in-out infinite"),
|
|
33
|
+
animationDelay: "".concat(weekIndex * 20 + dayIndex * 20, "ms")
|
|
34
|
+
} : undefined;
|
|
35
|
+
var block = /*#__PURE__*/_jsx("rect", {
|
|
36
|
+
"data-date": activity.date,
|
|
37
|
+
"data-level": activity.level,
|
|
38
|
+
fill: colorScale[activity.level],
|
|
39
|
+
height: blockSize,
|
|
40
|
+
onClick: function onClick() {
|
|
41
|
+
return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(activity);
|
|
42
|
+
},
|
|
43
|
+
rx: blockRadius,
|
|
44
|
+
ry: blockRadius,
|
|
45
|
+
style: _objectSpread({
|
|
46
|
+
cursor: onValueChange ? 'pointer' : undefined
|
|
47
|
+
}, style),
|
|
48
|
+
width: blockSize,
|
|
49
|
+
x: 0,
|
|
50
|
+
y: labelHeight + (blockSize + blockMargin) * dayIndex
|
|
51
|
+
});
|
|
52
|
+
return /*#__PURE__*/_jsx(Fragment, {
|
|
53
|
+
children: showTooltip ? /*#__PURE__*/_jsx(Tooltip, {
|
|
54
|
+
title: customTooltip ? customTooltip(activity) : labels.tooltip ? labels.tooltip.replace('{{count}}', String(activity.count)).replace('{{date}}', String(activity.date)) : "".concat(activity.count, " activities on ").concat(activity.date),
|
|
55
|
+
children: block
|
|
56
|
+
}) : block
|
|
57
|
+
}, activity.date);
|
|
58
|
+
});
|
|
59
|
+
}).map(function (week, x) {
|
|
60
|
+
return /*#__PURE__*/_jsx("g", {
|
|
61
|
+
transform: "translate(".concat((blockSize + blockMargin) * x, ", 0)"),
|
|
62
|
+
children: week
|
|
63
|
+
}, x);
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
export default Calendar;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Labels, Week } from "../types";
|
|
3
|
+
interface ChartLabelsProps {
|
|
4
|
+
blockMargin: number;
|
|
5
|
+
blockSize: number;
|
|
6
|
+
hideMonthLabels: boolean;
|
|
7
|
+
labelHeight: number;
|
|
8
|
+
labelMargin: number;
|
|
9
|
+
labels: Labels;
|
|
10
|
+
showWeekdayLabels: boolean;
|
|
11
|
+
weekStart: number;
|
|
12
|
+
weeks: Week[];
|
|
13
|
+
}
|
|
14
|
+
declare const ChartLabels: import("react").NamedExoticComponent<ChartLabelsProps>;
|
|
15
|
+
export default ChartLabels;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { getMonthLabels } from "../utils/calendar";
|
|
3
|
+
import { useStyles } from "./styles";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
var ChartLabels = /*#__PURE__*/memo(function (_ref) {
|
|
8
|
+
var labels = _ref.labels,
|
|
9
|
+
blockSize = _ref.blockSize,
|
|
10
|
+
labelHeight = _ref.labelHeight,
|
|
11
|
+
blockMargin = _ref.blockMargin,
|
|
12
|
+
labelMargin = _ref.labelMargin,
|
|
13
|
+
showWeekdayLabels = _ref.showWeekdayLabels,
|
|
14
|
+
hideMonthLabels = _ref.hideMonthLabels,
|
|
15
|
+
weeks = _ref.weeks,
|
|
16
|
+
weekStart = _ref.weekStart;
|
|
17
|
+
var _useStyles = useStyles(),
|
|
18
|
+
cx = _useStyles.cx;
|
|
19
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
20
|
+
children: [showWeekdayLabels && weeks[0] && /*#__PURE__*/_jsx("g", {
|
|
21
|
+
className: cx('legend-weekday'),
|
|
22
|
+
children: weeks[0].map(function (_, index) {
|
|
23
|
+
var _labels$weekdays;
|
|
24
|
+
if (index % 2 === 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var dayIndex = (index + weekStart) % 7;
|
|
28
|
+
return /*#__PURE__*/_jsx("text", {
|
|
29
|
+
dominantBaseline: "middle",
|
|
30
|
+
textAnchor: "end",
|
|
31
|
+
x: -labelMargin,
|
|
32
|
+
y: labelHeight + (blockSize + blockMargin) * index + blockSize / 2,
|
|
33
|
+
children: labels === null || labels === void 0 || (_labels$weekdays = labels.weekdays) === null || _labels$weekdays === void 0 ? void 0 : _labels$weekdays[dayIndex]
|
|
34
|
+
}, index);
|
|
35
|
+
})
|
|
36
|
+
}), !hideMonthLabels && /*#__PURE__*/_jsx("g", {
|
|
37
|
+
className: cx('legend-month'),
|
|
38
|
+
children: getMonthLabels(weeks, labels.months).map(function (_ref2) {
|
|
39
|
+
var label = _ref2.label,
|
|
40
|
+
weekIndex = _ref2.weekIndex;
|
|
41
|
+
return /*#__PURE__*/_jsx("text", {
|
|
42
|
+
dominantBaseline: "hanging",
|
|
43
|
+
x: (blockSize + blockMargin) * weekIndex,
|
|
44
|
+
children: label
|
|
45
|
+
}, weekIndex);
|
|
46
|
+
})
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export default ChartLabels;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface FooterProps {
|
|
3
|
+
blockRadius: number;
|
|
4
|
+
blockSize: number;
|
|
5
|
+
colorScale: string[];
|
|
6
|
+
hideColorLegend?: boolean;
|
|
7
|
+
hideTotalCount?: boolean;
|
|
8
|
+
labels: {
|
|
9
|
+
legend: {
|
|
10
|
+
less: string;
|
|
11
|
+
more: string;
|
|
12
|
+
};
|
|
13
|
+
totalCount?: string;
|
|
14
|
+
};
|
|
15
|
+
loading: boolean;
|
|
16
|
+
maxLevel: number;
|
|
17
|
+
totalCount: number;
|
|
18
|
+
weekdayLabelOffset?: number;
|
|
19
|
+
year: number;
|
|
20
|
+
}
|
|
21
|
+
declare const Footer: import("react").NamedExoticComponent<FooterProps>;
|
|
22
|
+
export default Footer;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { useStyles } from "./styles";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
var Footer = /*#__PURE__*/memo(function (_ref) {
|
|
6
|
+
var hideTotalCount = _ref.hideTotalCount,
|
|
7
|
+
hideColorLegend = _ref.hideColorLegend,
|
|
8
|
+
weekdayLabelOffset = _ref.weekdayLabelOffset,
|
|
9
|
+
loading = _ref.loading,
|
|
10
|
+
labels = _ref.labels,
|
|
11
|
+
year = _ref.year,
|
|
12
|
+
maxLevel = _ref.maxLevel,
|
|
13
|
+
blockSize = _ref.blockSize,
|
|
14
|
+
colorScale = _ref.colorScale,
|
|
15
|
+
blockRadius = _ref.blockRadius,
|
|
16
|
+
totalCount = _ref.totalCount;
|
|
17
|
+
var _useStyles = useStyles(),
|
|
18
|
+
cx = _useStyles.cx,
|
|
19
|
+
styles = _useStyles.styles;
|
|
20
|
+
return /*#__PURE__*/_jsxs("footer", {
|
|
21
|
+
className: cx('footer', styles.footer),
|
|
22
|
+
style: {
|
|
23
|
+
marginLeft: weekdayLabelOffset
|
|
24
|
+
},
|
|
25
|
+
children: [loading && /*#__PURE__*/_jsx("div", {
|
|
26
|
+
children: "\xA0"
|
|
27
|
+
}), !loading && !hideTotalCount && /*#__PURE__*/_jsx("div", {
|
|
28
|
+
className: cx('count'),
|
|
29
|
+
children: labels.totalCount ? labels.totalCount.replace('{{count}}', String(totalCount)).replace('{{year}}', String(year)) : "".concat(totalCount, " activities in ").concat(year)
|
|
30
|
+
}), !loading && !hideColorLegend && /*#__PURE__*/_jsxs("div", {
|
|
31
|
+
className: cx('legend-colors', styles.legendColors),
|
|
32
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
33
|
+
style: {
|
|
34
|
+
marginRight: '0.4em'
|
|
35
|
+
},
|
|
36
|
+
children: labels.legend.less
|
|
37
|
+
}), Array.from({
|
|
38
|
+
length: maxLevel + 1
|
|
39
|
+
}).fill(null).map(function (_, level) {
|
|
40
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
41
|
+
height: blockSize,
|
|
42
|
+
width: blockSize,
|
|
43
|
+
children: /*#__PURE__*/_jsx("rect", {
|
|
44
|
+
fill: colorScale[level],
|
|
45
|
+
height: blockSize,
|
|
46
|
+
rx: blockRadius,
|
|
47
|
+
ry: blockRadius,
|
|
48
|
+
width: blockSize
|
|
49
|
+
})
|
|
50
|
+
}, level);
|
|
51
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
52
|
+
style: {
|
|
53
|
+
marginLeft: '0.4em'
|
|
54
|
+
},
|
|
55
|
+
children: labels.legend.more
|
|
56
|
+
})]
|
|
57
|
+
})]
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
export default Footer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Day as WeekDay } from 'date-fns';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { FlexboxProps } from 'react-layout-kit';
|
|
4
|
+
import { NoDataProps } from "../common/NoData";
|
|
5
|
+
import type { Activity, Labels } from "../types";
|
|
6
|
+
export interface HeatmapsProps extends FlexboxProps {
|
|
7
|
+
blockMargin?: number;
|
|
8
|
+
blockRadius?: number;
|
|
9
|
+
blockSize?: number;
|
|
10
|
+
colors?: string[];
|
|
11
|
+
customTooltip?: (activity: Activity) => ReactNode;
|
|
12
|
+
data: Array<Activity>;
|
|
13
|
+
fontSize?: number;
|
|
14
|
+
hideColorLegend?: boolean;
|
|
15
|
+
hideMonthLabels?: boolean;
|
|
16
|
+
hideTotalCount?: boolean;
|
|
17
|
+
labels?: Labels;
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
maxLevel?: number;
|
|
20
|
+
noDataText?: NoDataProps['noDataText'];
|
|
21
|
+
onValueChange?: (value: Activity) => void;
|
|
22
|
+
showTooltip?: boolean;
|
|
23
|
+
showWeekdayLabels?: boolean;
|
|
24
|
+
totalCount?: number;
|
|
25
|
+
weekStart?: WeekDay;
|
|
26
|
+
}
|
|
27
|
+
declare const Heatmaps: import("react").ForwardRefExoticComponent<HeatmapsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
28
|
+
export default Heatmaps;
|