@lobehub/charts 1.0.0 → 1.1.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.
@@ -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, {
@@ -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
+ });
@@ -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
  }
@@ -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, {
@@ -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"];
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"];
9
9
  import { css } from 'antd-style';
10
10
  import { Fragment, forwardRef, useState } from 'react';
11
11
  import { Flexbox } from 'react-layout-kit';
@@ -79,6 +79,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
79
79
  width = _props$width === void 0 ? '100%' : _props$width,
80
80
  _props$height = props.height,
81
81
  height = _props$height === void 0 ? '20rem' : _props$height,
82
+ style = props.style,
82
83
  rest = _objectWithoutProperties(props, _excluded);
83
84
  var CustomTooltip = customTooltip;
84
85
  var paddingValue = !showXAxis && !showYAxis ? 0 : 20;
@@ -97,7 +98,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
97
98
  var categoryColors = constructCategoryColors(categories, colors);
98
99
  var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
99
100
  var hasOnValueChange = !!onValueChange;
100
- function onDotClick(itemData, event) {
101
+ var onDotClick = function onDotClick(itemData, event) {
101
102
  event.stopPropagation();
102
103
  if (!hasOnValueChange) return;
103
104
  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) {
@@ -115,8 +116,8 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
115
116
  eventType: 'dot'
116
117
  }, itemData.payload));
117
118
  }
118
- }
119
- function onCategoryClick(dataKey) {
119
+ };
120
+ var onCategoryClick = function onCategoryClick(dataKey) {
120
121
  if (!hasOnValueChange) return;
121
122
  if (dataKey === activeLegend && !activeDot || hasOnlyOneValueForThisKey(data, dataKey) && activeDot && activeDot.dataKey === dataKey) {
122
123
  setActiveLegend(undefined);
@@ -129,11 +130,14 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
129
130
  });
130
131
  }
131
132
  setActiveDot(undefined);
132
- }
133
+ };
133
134
  return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
134
135
  className: className,
135
136
  height: height,
136
137
  ref: ref,
138
+ style: _objectSpread({
139
+ position: 'relative'
140
+ }, style),
137
141
  width: width
138
142
  }, rest), {}, {
139
143
  children: /*#__PURE__*/_jsx(ResponsiveContainer, {
@@ -229,7 +233,7 @@ var LineChart = /*#__PURE__*/forwardRef(function (props, ref) {
229
233
  });
230
234
  } : undefined,
231
235
  cursor: {
232
- stroke: '#d1d5db',
236
+ stroke: theme.colorTextSecondary,
233
237
  strokeWidth: 1
234
238
  },
235
239
  isAnimationActive: false,
@@ -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"];
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"];
9
9
  import { css } from 'antd-style';
10
10
  import { forwardRef, useState } from 'react';
11
11
  import { Flexbox } from 'react-layout-kit';
@@ -89,6 +89,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
89
89
  width = _props$width === void 0 ? '100%' : _props$width,
90
90
  _props$height = props.height,
91
91
  height = _props$height === void 0 ? '20rem' : _props$height,
92
+ style = props.style,
92
93
  rest = _objectWithoutProperties(props, _excluded);
93
94
  var CustomTooltip = customTooltip;
94
95
  var _useState = useState(60),
@@ -104,7 +105,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
104
105
  activeLegend = _useState6[0],
105
106
  setActiveLegend = _useState6[1];
106
107
  var hasOnValueChange = !!onValueChange;
107
- function onNodeClick(data, index, event) {
108
+ var onNodeClick = function onNodeClick(data, index, event) {
108
109
  event.stopPropagation();
109
110
  if (!hasOnValueChange) return;
110
111
  if (deepEqual(activeNode, data.node)) {
@@ -119,8 +120,8 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
119
120
  eventType: 'bubble'
120
121
  }, data.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 && !activeNode) {
126
127
  setActiveLegend(undefined);
@@ -133,7 +134,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
133
134
  });
134
135
  }
135
136
  setActiveNode(undefined);
136
- }
137
+ };
137
138
  var categories = constructCategories(data, category);
138
139
  var categoryColors = constructCategoryColors(categories, colors);
139
140
 
@@ -144,6 +145,9 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
144
145
  className: className,
145
146
  height: height,
146
147
  ref: ref,
148
+ style: _objectSpread({
149
+ position: 'relative'
150
+ }, style),
147
151
  width: width
148
152
  }, rest), {}, {
149
153
  children: /*#__PURE__*/_jsx(ResponsiveContainer, {
@@ -250,7 +254,7 @@ var ScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
250
254
  });
251
255
  } : undefined,
252
256
  cursor: {
253
- stroke: '#d1d5db',
257
+ stroke: theme.colorTextSecondary,
254
258
  strokeWidth: 1
255
259
  },
256
260
  isAnimationActive: false,
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import BaseSparkChartProps from "../common/BaseSparkChartProps";
3
+ import { CurveType } from "../types";
4
+ export interface SparkAreaChartProps extends BaseSparkChartProps {
5
+ connectNulls?: boolean;
6
+ curveType?: CurveType;
7
+ showGradient?: boolean;
8
+ stack?: boolean;
9
+ }
10
+ declare const SparkAreaChart: import("react").ForwardRefExoticComponent<SparkAreaChartProps & import("react").RefAttributes<HTMLDivElement>>;
11
+ export default SparkAreaChart;
@@ -0,0 +1,140 @@
1
+ 'use client';
2
+
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
+ var _templateObject, _templateObject2, _templateObject3;
7
+ var _excluded = ["data", "categories", "index", "stack", "colors", "showAnimation", "animationDuration", "showGradient", "curveType", "connectNulls", "noDataText", "autoMinValue", "minValue", "maxValue", "className", "width", "height", "style"];
8
+ import { css } from 'antd-style';
9
+ import { forwardRef } from 'react';
10
+ import { Flexbox } from 'react-layout-kit';
11
+ import { Area, AreaChart as ReChartsAreaChart, ResponsiveContainer, XAxis, YAxis } from 'recharts';
12
+ import { useStyles } from "../AreaChart/styles";
13
+ import NoData from "../common/NoData";
14
+ import { constructCategoryColors, getYAxisDomain } from "../common/utils";
15
+ import { useThemeColorRange } from "../hooks/useThemeColorRange";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ var SparkAreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
19
+ var _useStyles = useStyles(),
20
+ cx = _useStyles.cx,
21
+ theme = _useStyles.theme;
22
+ var themeColorRange = useThemeColorRange();
23
+ var _props$data = props.data,
24
+ data = _props$data === void 0 ? [] : _props$data,
25
+ _props$categories = props.categories,
26
+ categories = _props$categories === void 0 ? [] : _props$categories,
27
+ index = props.index,
28
+ _props$stack = props.stack,
29
+ stack = _props$stack === void 0 ? false : _props$stack,
30
+ _props$colors = props.colors,
31
+ colors = _props$colors === void 0 ? themeColorRange : _props$colors,
32
+ _props$showAnimation = props.showAnimation,
33
+ showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
34
+ _props$animationDurat = props.animationDuration,
35
+ animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
36
+ _props$showGradient = props.showGradient,
37
+ showGradient = _props$showGradient === void 0 ? true : _props$showGradient,
38
+ _props$curveType = props.curveType,
39
+ curveType = _props$curveType === void 0 ? 'linear' : _props$curveType,
40
+ _props$connectNulls = props.connectNulls,
41
+ connectNulls = _props$connectNulls === void 0 ? false : _props$connectNulls,
42
+ _props$noDataText = props.noDataText,
43
+ noDataText = _props$noDataText === void 0 ? /*#__PURE__*/_jsx("div", {}) : _props$noDataText,
44
+ _props$autoMinValue = props.autoMinValue,
45
+ autoMinValue = _props$autoMinValue === void 0 ? false : _props$autoMinValue,
46
+ minValue = props.minValue,
47
+ maxValue = props.maxValue,
48
+ className = props.className,
49
+ _props$width = props.width,
50
+ width = _props$width === void 0 ? 112 : _props$width,
51
+ _props$height = props.height,
52
+ height = _props$height === void 0 ? 48 : _props$height,
53
+ style = props.style,
54
+ rest = _objectWithoutProperties(props, _excluded);
55
+ var categoryColors = constructCategoryColors(categories, colors);
56
+ var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
57
+ return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
58
+ className: className,
59
+ height: height,
60
+ ref: ref,
61
+ style: _objectSpread({
62
+ position: 'relative'
63
+ }, style),
64
+ width: width
65
+ }, rest), {}, {
66
+ children: /*#__PURE__*/_jsx(ResponsiveContainer, {
67
+ children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsAreaChart, {
68
+ data: data,
69
+ margin: {
70
+ bottom: 1,
71
+ left: 1,
72
+ right: 1,
73
+ top: 1
74
+ },
75
+ children: [/*#__PURE__*/_jsx(YAxis, {
76
+ domain: yAxisDomain,
77
+ hide: true
78
+ }), /*#__PURE__*/_jsx(XAxis, {
79
+ dataKey: index,
80
+ hide: true
81
+ }), categories.map(function (category) {
82
+ var _categoryColors$get, _categoryColors$get2;
83
+ return /*#__PURE__*/_jsx("defs", {
84
+ children: showGradient ? /*#__PURE__*/_jsxs("linearGradient", {
85
+ className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n "])), (_categoryColors$get = categoryColors.get(category)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary)),
86
+ id: categoryColors.get(category),
87
+ x1: "0",
88
+ x2: "0",
89
+ y1: "0",
90
+ y2: "1",
91
+ children: [/*#__PURE__*/_jsx("stop", {
92
+ offset: "5%",
93
+ stopColor: "currentColor",
94
+ stopOpacity: 0.4
95
+ }), /*#__PURE__*/_jsx("stop", {
96
+ offset: "95%",
97
+ stopColor: "currentColor",
98
+ stopOpacity: 0
99
+ })]
100
+ }) : /*#__PURE__*/_jsx("linearGradient", {
101
+ className: cx(css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n "])), (_categoryColors$get2 = categoryColors.get(category)) !== null && _categoryColors$get2 !== void 0 ? _categoryColors$get2 : theme.colorPrimary)),
102
+ id: categoryColors.get(category),
103
+ x1: "0",
104
+ x2: "0",
105
+ y1: "0",
106
+ y2: "1",
107
+ children: /*#__PURE__*/_jsx("stop", {
108
+ stopColor: "currentColor",
109
+ stopOpacity: 0.3
110
+ })
111
+ })
112
+ }, category);
113
+ }), categories.map(function (category) {
114
+ var _categoryColors$get3;
115
+ return /*#__PURE__*/_jsx(Area, {
116
+ animationDuration: animationDuration,
117
+ className: cx(css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n stroke: ", ";\n "])), (_categoryColors$get3 = categoryColors.get(category)) !== null && _categoryColors$get3 !== void 0 ? _categoryColors$get3 : theme.colorPrimary)),
118
+ connectNulls: connectNulls,
119
+ dataKey: category,
120
+ dot: false,
121
+ fill: "url(#".concat(categoryColors.get(category), ")"),
122
+ isAnimationActive: showAnimation,
123
+ name: category,
124
+ stackId: stack ? 'a' : undefined,
125
+ stroke: "",
126
+ strokeLinecap: "round",
127
+ strokeLinejoin: "round",
128
+ strokeOpacity: 1,
129
+ strokeWidth: 2,
130
+ type: curveType
131
+ }, category);
132
+ })]
133
+ }) : /*#__PURE__*/_jsx(NoData, {
134
+ noDataText: noDataText
135
+ })
136
+ })
137
+ }));
138
+ });
139
+ SparkAreaChart.displayName = 'AreaChart';
140
+ export default SparkAreaChart;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import BaseSparkChartProps from "../common/BaseSparkChartProps";
3
+ export interface SparkBarChartProps extends BaseSparkChartProps {
4
+ relative?: boolean;
5
+ stack?: boolean;
6
+ }
7
+ declare const SparkBarChart: import("react").ForwardRefExoticComponent<SparkBarChartProps & import("react").RefAttributes<HTMLDivElement>>;
8
+ export default SparkBarChart;
@@ -0,0 +1,98 @@
1
+ 'use client';
2
+
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
+ var _templateObject;
7
+ var _excluded = ["data", "categories", "index", "colors", "stack", "relative", "animationDuration", "showAnimation", "noDataText", "autoMinValue", "minValue", "maxValue", "className", "width", "height", "style"];
8
+ import { css } from 'antd-style';
9
+ import { forwardRef } from 'react';
10
+ import { Flexbox } from 'react-layout-kit';
11
+ import { Bar, BarChart as ReChartsBarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts';
12
+ import { useStyles } from "../BarChart/styles";
13
+ import NoData from "../common/NoData";
14
+ import { constructCategoryColors, getYAxisDomain } from "../common/utils";
15
+ import { useThemeColorRange } from "../hooks/useThemeColorRange";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ var SparkBarChart = /*#__PURE__*/forwardRef(function (props, ref) {
19
+ var _useStyles = useStyles(),
20
+ cx = _useStyles.cx,
21
+ theme = _useStyles.theme;
22
+ var themeColorRange = useThemeColorRange();
23
+ var _props$data = props.data,
24
+ data = _props$data === void 0 ? [] : _props$data,
25
+ _props$categories = props.categories,
26
+ categories = _props$categories === void 0 ? [] : _props$categories,
27
+ index = props.index,
28
+ _props$colors = props.colors,
29
+ colors = _props$colors === void 0 ? themeColorRange : _props$colors,
30
+ _props$stack = props.stack,
31
+ stack = _props$stack === void 0 ? false : _props$stack,
32
+ _props$relative = props.relative,
33
+ relative = _props$relative === void 0 ? false : _props$relative,
34
+ _props$animationDurat = props.animationDuration,
35
+ animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
36
+ _props$showAnimation = props.showAnimation,
37
+ showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
38
+ _props$noDataText = props.noDataText,
39
+ noDataText = _props$noDataText === void 0 ? /*#__PURE__*/_jsx("div", {}) : _props$noDataText,
40
+ _props$autoMinValue = props.autoMinValue,
41
+ autoMinValue = _props$autoMinValue === void 0 ? false : _props$autoMinValue,
42
+ minValue = props.minValue,
43
+ maxValue = props.maxValue,
44
+ className = props.className,
45
+ _props$width = props.width,
46
+ width = _props$width === void 0 ? 112 : _props$width,
47
+ _props$height = props.height,
48
+ height = _props$height === void 0 ? 48 : _props$height,
49
+ style = props.style,
50
+ rest = _objectWithoutProperties(props, _excluded);
51
+ var categoryColors = constructCategoryColors(categories, colors);
52
+ var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
53
+ return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
54
+ className: className,
55
+ height: height,
56
+ ref: ref,
57
+ style: _objectSpread({
58
+ position: 'relative'
59
+ }, style),
60
+ width: width
61
+ }, rest), {}, {
62
+ children: /*#__PURE__*/_jsx(ResponsiveContainer, {
63
+ children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsBarChart, {
64
+ data: data,
65
+ margin: {
66
+ bottom: 0,
67
+ left: -1.5,
68
+ right: -1.5,
69
+ top: 0
70
+ },
71
+ stackOffset: relative ? 'expand' : 'none',
72
+ children: [/*#__PURE__*/_jsx(YAxis, {
73
+ domain: yAxisDomain,
74
+ hide: true
75
+ }), /*#__PURE__*/_jsx(XAxis, {
76
+ dataKey: index,
77
+ hide: true
78
+ }), categories.map(function (category) {
79
+ var _categoryColors$get;
80
+ return /*#__PURE__*/_jsx(Bar, {
81
+ animationDuration: animationDuration,
82
+ className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n fill: ", ";\n "])), (_categoryColors$get = categoryColors.get(category)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary)),
83
+ dataKey: category,
84
+ fill: "",
85
+ isAnimationActive: showAnimation,
86
+ name: category,
87
+ stackId: stack || relative ? 'a' : undefined,
88
+ type: "linear"
89
+ }, category);
90
+ })]
91
+ }) : /*#__PURE__*/_jsx(NoData, {
92
+ noDataText: noDataText
93
+ })
94
+ })
95
+ }));
96
+ });
97
+ SparkBarChart.displayName = 'SparkBarChart';
98
+ export default SparkBarChart;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import BaseSparkChartProps from "../common/BaseSparkChartProps";
3
+ import { CurveType } from "../types";
4
+ export interface SparkLineChartProps extends BaseSparkChartProps {
5
+ connectNulls?: boolean;
6
+ curveType?: CurveType;
7
+ }
8
+ declare const SparkLineChart: import("react").ForwardRefExoticComponent<SparkLineChartProps & import("react").RefAttributes<HTMLDivElement>>;
9
+ export default SparkLineChart;
@@ -0,0 +1,102 @@
1
+ 'use client';
2
+
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
+ var _templateObject;
7
+ var _excluded = ["data", "categories", "index", "colors", "animationDuration", "showAnimation", "curveType", "connectNulls", "noDataText", "autoMinValue", "minValue", "maxValue", "className", "width", "height", "style"];
8
+ import { css } from 'antd-style';
9
+ import { forwardRef } from 'react';
10
+ import { Flexbox } from 'react-layout-kit';
11
+ import { Line, LineChart as ReChartsLineChart, ResponsiveContainer, XAxis, YAxis } from 'recharts';
12
+ import { useStyles } from "../LineChart/styles";
13
+ import NoData from "../common/NoData";
14
+ import { constructCategoryColors, getYAxisDomain } from "../common/utils";
15
+ import { useThemeColorRange } from "../hooks/useThemeColorRange";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ var SparkLineChart = /*#__PURE__*/forwardRef(function (props, ref) {
19
+ var _useStyles = useStyles(),
20
+ cx = _useStyles.cx,
21
+ theme = _useStyles.theme;
22
+ var themeColorRange = useThemeColorRange();
23
+ var _props$data = props.data,
24
+ data = _props$data === void 0 ? [] : _props$data,
25
+ _props$categories = props.categories,
26
+ categories = _props$categories === void 0 ? [] : _props$categories,
27
+ index = props.index,
28
+ _props$colors = props.colors,
29
+ colors = _props$colors === void 0 ? themeColorRange : _props$colors,
30
+ _props$animationDurat = props.animationDuration,
31
+ animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
32
+ _props$showAnimation = props.showAnimation,
33
+ showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
34
+ _props$curveType = props.curveType,
35
+ curveType = _props$curveType === void 0 ? 'linear' : _props$curveType,
36
+ _props$connectNulls = props.connectNulls,
37
+ connectNulls = _props$connectNulls === void 0 ? false : _props$connectNulls,
38
+ _props$noDataText = props.noDataText,
39
+ noDataText = _props$noDataText === void 0 ? /*#__PURE__*/_jsx("div", {}) : _props$noDataText,
40
+ _props$autoMinValue = props.autoMinValue,
41
+ autoMinValue = _props$autoMinValue === void 0 ? false : _props$autoMinValue,
42
+ minValue = props.minValue,
43
+ maxValue = props.maxValue,
44
+ className = props.className,
45
+ _props$width = props.width,
46
+ width = _props$width === void 0 ? 112 : _props$width,
47
+ _props$height = props.height,
48
+ height = _props$height === void 0 ? 48 : _props$height,
49
+ style = props.style,
50
+ rest = _objectWithoutProperties(props, _excluded);
51
+ var categoryColors = constructCategoryColors(categories, colors);
52
+ var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
53
+ return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
54
+ className: className,
55
+ height: height,
56
+ ref: ref,
57
+ style: _objectSpread({
58
+ position: 'relative'
59
+ }, style),
60
+ width: width
61
+ }, rest), {}, {
62
+ children: /*#__PURE__*/_jsx(ResponsiveContainer, {
63
+ children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsLineChart, {
64
+ data: data,
65
+ margin: {
66
+ bottom: 1,
67
+ left: 1,
68
+ right: 1,
69
+ top: 1
70
+ },
71
+ children: [/*#__PURE__*/_jsx(YAxis, {
72
+ domain: yAxisDomain,
73
+ hide: true
74
+ }), /*#__PURE__*/_jsx(XAxis, {
75
+ dataKey: index,
76
+ hide: true
77
+ }), categories.map(function (category) {
78
+ var _categoryColors$get;
79
+ return /*#__PURE__*/_jsx(Line, {
80
+ animationDuration: animationDuration,
81
+ className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n stroke: ", ";\n "])), (_categoryColors$get = categoryColors.get(category)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary)),
82
+ connectNulls: connectNulls,
83
+ dataKey: category,
84
+ dot: false,
85
+ isAnimationActive: showAnimation,
86
+ name: category,
87
+ stroke: "",
88
+ strokeLinecap: "round",
89
+ strokeLinejoin: "round",
90
+ strokeOpacity: 1,
91
+ strokeWidth: 2,
92
+ type: curveType
93
+ }, category);
94
+ })]
95
+ }) : /*#__PURE__*/_jsx(NoData, {
96
+ noDataText: noDataText
97
+ })
98
+ })
99
+ }));
100
+ });
101
+ SparkLineChart.displayName = 'SparkLineChart';
102
+ export default SparkLineChart;
@@ -0,0 +1,3 @@
1
+ export { default as SparkAreaChart, type SparkAreaChartProps } from './SparkAreaChart';
2
+ export { default as SparkBarChart, type SparkBarChartProps } from './SparkBarChart';
3
+ export { default as SparkLineChart, type SparkLineChartProps } from './SparkLineChart';
@@ -0,0 +1,3 @@
1
+ export { default as SparkAreaChart } from "./SparkAreaChart";
2
+ export { default as SparkBarChart } from "./SparkBarChart";
3
+ export { default as SparkLineChart } from "./SparkLineChart";
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TrackerBlockProps {
3
+ color?: 'success' | 'warning' | 'error' | string;
4
+ key?: string | number;
5
+ tooltip?: ReactNode;
6
+ }
7
+ declare const TrackerBlock: import("react").ForwardRefExoticComponent<TrackerBlockProps & import("react-layout-kit/lib/FlexBasic").FlexBasicProps & import("react-layout-kit").CommonProps & import("react").RefAttributes<HTMLDivElement>>;
8
+ export default TrackerBlock;
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
6
+ var _excluded = ["color", "tooltip", "width", "style"];
7
+ var _templateObject;
8
+ import { Tooltip } from '@lobehub/ui';
9
+ import { createStyles } from 'antd-style';
10
+ import { forwardRef, useMemo } from 'react';
11
+ import { Flexbox } from 'react-layout-kit';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var useStyles = createStyles(function (_ref) {
14
+ var css = _ref.css,
15
+ token = _ref.token;
16
+ return {
17
+ block: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n\n &:hover {\n opacity: 0.5;\n }\n "])), token.colorFill, token.borderRadiusSM, token.borderRadiusSM, token.borderRadiusSM, token.borderRadiusSM)
18
+ };
19
+ });
20
+ var TrackerBlock = /*#__PURE__*/forwardRef(function (_ref2, ref) {
21
+ var color = _ref2.color,
22
+ tooltip = _ref2.tooltip,
23
+ width = _ref2.width,
24
+ style = _ref2.style,
25
+ rest = _objectWithoutProperties(_ref2, _excluded);
26
+ var _useStyles = useStyles(),
27
+ styles = _useStyles.styles,
28
+ theme = _useStyles.theme;
29
+ var blockColor = useMemo(function () {
30
+ switch (color) {
31
+ case 'success':
32
+ {
33
+ return theme.colorSuccess;
34
+ }
35
+ case 'warning':
36
+ {
37
+ return theme.colorWarning;
38
+ }
39
+ case 'error':
40
+ {
41
+ return theme.colorError;
42
+ }
43
+ default:
44
+ {
45
+ return color;
46
+ }
47
+ }
48
+ }, [color]);
49
+ return /*#__PURE__*/_jsx(Tooltip, {
50
+ title: tooltip,
51
+ children: /*#__PURE__*/_jsx(Flexbox, _objectSpread({
52
+ className: styles.block,
53
+ height: '100%',
54
+ ref: ref,
55
+ style: _objectSpread({
56
+ background: blockColor
57
+ }, style),
58
+ width: width || '100%'
59
+ }, rest))
60
+ });
61
+ });
62
+ export default TrackerBlock;
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+ import { FlexboxProps } from 'react-layout-kit';
3
+ import { TrackerBlockProps } from './TrackerBlock';
4
+ interface DataItem extends TrackerBlockProps {
5
+ [key: string]: any;
6
+ }
7
+ export interface TrackerProps extends FlexboxProps {
8
+ blockGap?: number | string;
9
+ blockHeight?: number | string;
10
+ blockWidth?: number | string;
11
+ customTooltip?: (payload: DataItem) => ReactNode;
12
+ data: DataItem[];
13
+ leftLabel?: ReactNode;
14
+ onValueChange?: (payload: DataItem) => void;
15
+ rightLabel?: ReactNode;
16
+ }
17
+ declare const Tracker: import("react").ForwardRefExoticComponent<TrackerProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ export default Tracker;
@@ -0,0 +1,98 @@
1
+ 'use client';
2
+
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["data", "className", "height", "width", "blockWidth", "blockHeight", "blockGap", "customTooltip", "onValueChange", "leftLabel", "rightLabel", "style"];
6
+ import { forwardRef } from 'react';
7
+ import { Flexbox } from 'react-layout-kit';
8
+ import TrackerBlock from "./TrackerBlock";
9
+ import { useStyles } from "./styles";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ var Tracker = /*#__PURE__*/forwardRef(function (props, ref) {
13
+ var _props$data = props.data,
14
+ data = _props$data === void 0 ? [] : _props$data,
15
+ className = props.className,
16
+ height = props.height,
17
+ _props$width = props.width,
18
+ width = _props$width === void 0 ? 'fit-content' : _props$width,
19
+ _props$blockWidth = props.blockWidth,
20
+ blockWidth = _props$blockWidth === void 0 ? 12 : _props$blockWidth,
21
+ _props$blockHeight = props.blockHeight,
22
+ blockHeight = _props$blockHeight === void 0 ? 40 : _props$blockHeight,
23
+ _props$blockGap = props.blockGap,
24
+ blockGap = _props$blockGap === void 0 ? 4 : _props$blockGap,
25
+ customTooltip = props.customTooltip,
26
+ onValueChange = props.onValueChange,
27
+ leftLabel = props.leftLabel,
28
+ rightLabel = props.rightLabel,
29
+ style = props.style,
30
+ rest = _objectWithoutProperties(props, _excluded);
31
+ var _useStyles = useStyles(),
32
+ styles = _useStyles.styles,
33
+ cx = _useStyles.cx;
34
+ var content = data.map(function (item, idx) {
35
+ var _item$key;
36
+ return /*#__PURE__*/_jsx(TrackerBlock, {
37
+ color: item.color,
38
+ height: blockHeight,
39
+ onClick: function onClick() {
40
+ return onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(item);
41
+ },
42
+ style: {
43
+ cursor: onValueChange ? 'pointer' : 'default'
44
+ },
45
+ tooltip: customTooltip ? customTooltip(item) : item.tooltip,
46
+ width: blockWidth
47
+ }, (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : idx);
48
+ });
49
+ if (leftLabel || rightLabel) {
50
+ return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
51
+ className: className,
52
+ gap: 8,
53
+ height: height,
54
+ ref: ref,
55
+ style: _objectSpread({
56
+ position: 'relative'
57
+ }, style),
58
+ width: width
59
+ }, rest), {}, {
60
+ children: [/*#__PURE__*/_jsxs(Flexbox, {
61
+ align: 'center',
62
+ horizontal: true,
63
+ justify: 'space-between',
64
+ width: '100%',
65
+ children: [/*#__PURE__*/_jsx("div", {
66
+ className: cx(styles.strongLabel, styles.emphasis),
67
+ children: leftLabel
68
+ }), /*#__PURE__*/_jsx("div", {
69
+ className: cx(styles.label, styles.emphasis),
70
+ style: {
71
+ textAlign: 'right'
72
+ },
73
+ children: rightLabel
74
+ })]
75
+ }), /*#__PURE__*/_jsx(Flexbox, {
76
+ align: 'center',
77
+ gap: blockGap,
78
+ height: blockHeight,
79
+ horizontal: true,
80
+ width: '100%',
81
+ children: content
82
+ })]
83
+ }));
84
+ }
85
+ return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
86
+ align: 'center',
87
+ className: className,
88
+ gap: blockGap,
89
+ height: height || blockHeight,
90
+ horizontal: true,
91
+ ref: ref,
92
+ width: width
93
+ }, rest), {}, {
94
+ children: content
95
+ }));
96
+ });
97
+ Tracker.displayName = 'Tracker';
98
+ export default Tracker;
@@ -0,0 +1,5 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ emphasis: import("antd-style").SerializedStyles;
3
+ label: import("antd-style").SerializedStyles;
4
+ strongLabel: import("antd-style").SerializedStyles;
5
+ }>;
@@ -0,0 +1,12 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
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
+ label: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n color: ", ";\n "])), token.colorTextDescription),
10
+ strongLabel: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 14px;\n font-weight: 500;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextSecondary)
11
+ };
12
+ });
@@ -0,0 +1,13 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import BaseAnimationTimingProps from './BaseAnimationTimingProps';
3
+ interface BaseSparkChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
4
+ autoMinValue?: boolean;
5
+ categories: string[];
6
+ colors?: string[];
7
+ data: any[];
8
+ index: string;
9
+ maxValue?: number;
10
+ minValue?: number;
11
+ noDataText?: string;
12
+ }
13
+ export default BaseSparkChartProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  export declare const constructCategoryColors: (categories: string[], colors: string[]) => Map<string, string>;
2
2
  export declare const getYAxisDomain: (autoMinValue: boolean, minValue: number | undefined, maxValue: number | undefined) => (string | number)[];
3
3
  export declare const constructCategories: (data: any[], color?: string) => string[];
4
- export declare function deepEqual(obj1: any, obj2: any): boolean;
5
- export declare function hasOnlyOneValueForThisKey(array: any[], keyToCheck: string): boolean;
4
+ export declare const deepEqual: (obj1: any, obj2: any) => boolean;
5
+ export declare const hasOnlyOneValueForThisKey: (array: any[], keyToCheck: string) => boolean;
@@ -42,7 +42,7 @@ export var constructCategories = function constructCategories(data, color) {
42
42
  }
43
43
  return _toConsumableArray(categories);
44
44
  };
45
- export function deepEqual(obj1, obj2) {
45
+ export var deepEqual = function deepEqual(obj1, obj2) {
46
46
  if (obj1 === obj2) return true;
47
47
  if (_typeof(obj1) !== 'object' || _typeof(obj2) !== 'object' || obj1 === null || obj2 === null) return false;
48
48
  var keys1 = Object.keys(obj1);
@@ -53,8 +53,8 @@ export function deepEqual(obj1, obj2) {
53
53
  if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) return false;
54
54
  }
55
55
  return true;
56
- }
57
- export function hasOnlyOneValueForThisKey(array, keyToCheck) {
56
+ };
57
+ export var hasOnlyOneValueForThisKey = function hasOnlyOneValueForThisKey(array, keyToCheck) {
58
58
  var val = [];
59
59
  var _iterator3 = _createForOfIteratorHelper(array),
60
60
  _step3;
@@ -74,4 +74,4 @@ export function hasOnlyOneValueForThisKey(array, keyToCheck) {
74
74
  _iterator3.f();
75
75
  }
76
76
  return true;
77
- }
77
+ };
package/es/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  export { default as AreaChart, type AreaChartProps } from './AreaChart';
2
2
  export { default as BarChart, type BarChartProps } from './BarChart';
3
+ export { type Bar, default as BarList, type BarListProps } from './BarList';
3
4
  export { default as ChartTooltipFrame } from './common/ChartTooltip/ChartTooltipFrame';
4
5
  export { default as Legend, type LegendProps } from './components/Legend';
5
6
  export { default as DonutChart, type DonutChartProps } from './DonutChart';
6
7
  export { default as LineChart, type LineChartProps } from './LineChart';
7
8
  export { default as ScatterChart, type ScatterChartProps } from './ScatterChart';
9
+ export * from './SparkChart';
10
+ export { default as Tracker, type TrackerProps } from './Tracker';
8
11
  export type * from './types';
package/es/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  export { default as AreaChart } from "./AreaChart";
2
2
  export { default as BarChart } from "./BarChart";
3
+ export { default as BarList } from "./BarList";
3
4
  export { default as ChartTooltipFrame } from "./common/ChartTooltip/ChartTooltipFrame";
4
5
  export { default as Legend } from "./components/Legend";
5
6
  export { default as DonutChart } from "./DonutChart";
6
7
  export { default as LineChart } from "./LineChart";
7
- export { default as ScatterChart } from "./ScatterChart";
8
+ export { default as ScatterChart } from "./ScatterChart";
9
+ export * from "./SparkChart";
10
+ export { default as Tracker } from "./Tracker";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/charts",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "React modern charts components built on recharts",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -74,6 +74,7 @@
74
74
  },
75
75
  "devDependencies": {
76
76
  "@commitlint/cli": "^19.3.0",
77
+ "@icons-pack/react-simple-icons": "^9.6.0",
77
78
  "@lobehub/lint": "^1.24.3",
78
79
  "@lobehub/ui": "^1.146.8",
79
80
  "@testing-library/react": "^14.3.1",