@lobehub/charts 1.9.10 → 1.9.12

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.
@@ -1,4 +1,5 @@
1
1
  import React, { HTMLAttributes, ReactNode } from 'react';
2
+ import { NoDataProps } from "../common/NoData";
2
3
  import { ValueFormatter } from "../types/charts";
3
4
  export interface Bar {
4
5
  [key: string]: any;
@@ -16,6 +17,7 @@ export interface BarListProps extends HTMLAttributes<HTMLDivElement> {
16
17
  height?: string | number;
17
18
  leftLabel?: ReactNode;
18
19
  loading?: boolean;
20
+ noDataText?: NoDataProps['noDataText'];
19
21
  onValueChange?: (payload: Bar) => void;
20
22
  rightLabel?: ReactNode;
21
23
  showAnimation?: boolean;
@@ -3,11 +3,12 @@
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
- var _excluded = ["data", "color", "valueFormatter", "showAnimation", "onValueChange", "sortOrder", "className", "leftLabel", "rightLabel", "style", "loading", "width", "height"];
6
+ var _excluded = ["data", "color", "valueFormatter", "showAnimation", "onValueChange", "sortOrder", "className", "leftLabel", "rightLabel", "style", "loading", "width", "height", "noDataText"];
7
7
  import A from '@lobehub/ui/es/A';
8
8
  import { Skeleton } from 'antd';
9
9
  import React, { forwardRef, useMemo } from 'react';
10
10
  import { Flexbox } from 'react-layout-kit';
11
+ import NoData from "../common/NoData";
11
12
  import { useThemeColorRange } from "../hooks/useThemeColorRange";
12
13
  import { defaultValueFormatter } from "../utils";
13
14
  import { useStyles } from "./styles";
@@ -16,7 +17,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  var BarList = /*#__PURE__*/forwardRef(function (props, ref) {
17
18
  var _useStyles = useStyles(),
18
19
  cx = _useStyles.cx,
19
- styles = _useStyles.styles;
20
+ styles = _useStyles.styles,
21
+ prefixCls = _useStyles.prefixCls;
20
22
  var themeColorRange = useThemeColorRange();
21
23
  var _props$data = props.data,
22
24
  data = _props$data === void 0 ? [] : _props$data,
@@ -37,6 +39,7 @@ var BarList = /*#__PURE__*/forwardRef(function (props, ref) {
37
39
  _props$width = props.width,
38
40
  width = _props$width === void 0 ? '100%' : _props$width,
39
41
  height = props.height,
42
+ noDataText = props.noDataText,
40
43
  rest = _objectWithoutProperties(props, _excluded);
41
44
  var sortedData = useMemo(function () {
42
45
  if (sortOrder === 'none') {
@@ -93,7 +96,7 @@ var BarList = /*#__PURE__*/forwardRef(function (props, ref) {
93
96
  var _item$key, _item$color;
94
97
  return /*#__PURE__*/_jsxs(Flexbox, {
95
98
  align: 'center',
96
- className: styles.barContainer,
99
+ className: cx(styles.barContainer, onValueChange && styles.barHover),
97
100
  height: rowHeight,
98
101
  horizontal: true,
99
102
  onClick: function onClick() {
@@ -104,7 +107,7 @@ var BarList = /*#__PURE__*/forwardRef(function (props, ref) {
104
107
  },
105
108
  width: '100%',
106
109
  children: [/*#__PURE__*/_jsx("div", {
107
- className: cx(styles.bar, onValueChange && styles.barHover),
110
+ className: cx("".concat(prefixCls, "-chart-bar-item"), styles.bar),
108
111
  style: {
109
112
  background: (_item$color = item.color) !== null && _item$color !== void 0 ? _item$color : color,
110
113
  transition: showAnimation ? undefined : 'none',
@@ -136,6 +139,8 @@ var BarList = /*#__PURE__*/forwardRef(function (props, ref) {
136
139
  })]
137
140
  })]
138
141
  }, (_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : index);
142
+ }), !(data !== null && data !== void 0 && data.length) && /*#__PURE__*/_jsx(NoData, {
143
+ noDataText: noDataText
139
144
  })]
140
145
  }), /*#__PURE__*/_jsxs(Flexbox, {
141
146
  gap: 8,
@@ -2,12 +2,13 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLit
2
2
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref) {
5
- var css = _ref.css,
5
+ var prefixCls = _ref.prefixCls,
6
+ css = _ref.css,
6
7
  token = _ref.token;
7
8
  return {
8
9
  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
10
  barContainer: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n "]))),
10
- barHover: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &:hover {\n opacity: 0.4;\n }\n "]))),
11
+ barHover: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &:hover {\n .", "-chart-bar-item {\n opacity: 0.4;\n }\n }\n "])), prefixCls),
11
12
  emphasis: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n "]))),
12
13
  label: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 12px;\n line-height: 16px;\n color: ", ";\n "])), token.colorTextDescription),
13
14
  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),
@@ -1,4 +1,5 @@
1
1
  import { HTMLAttributes } from 'react';
2
+ import { NoDataProps } from "./NoData";
2
3
  import BaseAnimationTimingProps from './BaseAnimationTimingProps';
3
4
  interface BaseSparkChartProps extends BaseAnimationTimingProps, HTMLAttributes<HTMLDivElement> {
4
5
  autoMinValue?: boolean;
@@ -8,6 +9,6 @@ interface BaseSparkChartProps extends BaseAnimationTimingProps, HTMLAttributes<H
8
9
  index: string;
9
10
  maxValue?: number;
10
11
  minValue?: number;
11
- noDataText?: string;
12
+ noDataText?: NoDataProps['noDataText'];
12
13
  }
13
14
  export default BaseSparkChartProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/charts",
3
- "version": "1.9.10",
3
+ "version": "1.9.12",
4
4
  "description": "React modern charts components built on recharts",
5
5
  "keywords": [
6
6
  "lobehub",