@lobehub/charts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +218 -0
  3. package/es/AreaChart/index.d.ts +11 -0
  4. package/es/AreaChart/index.js +388 -0
  5. package/es/AreaChart/styles.d.ts +6 -0
  6. package/es/AreaChart/styles.js +13 -0
  7. package/es/BarChart/index.d.ts +10 -0
  8. package/es/BarChart/index.js +354 -0
  9. package/es/BarChart/renderShape.d.ts +1 -0
  10. package/es/BarChart/renderShape.js +29 -0
  11. package/es/BarChart/styles.d.ts +6 -0
  12. package/es/BarChart/styles.js +13 -0
  13. package/es/DonutChart/DonutChartTooltip.d.ts +7 -0
  14. package/es/DonutChart/DonutChartTooltip.js +25 -0
  15. package/es/DonutChart/index.d.ts +25 -0
  16. package/es/DonutChart/index.js +186 -0
  17. package/es/DonutChart/inputParser.d.ts +2 -0
  18. package/es/DonutChart/inputParser.js +9 -0
  19. package/es/DonutChart/renderInactiveShape.d.ts +1 -0
  20. package/es/DonutChart/renderInactiveShape.js +27 -0
  21. package/es/DonutChart/styles.d.ts +6 -0
  22. package/es/DonutChart/styles.js +13 -0
  23. package/es/LineChart/index.d.ts +9 -0
  24. package/es/LineChart/index.js +347 -0
  25. package/es/LineChart/styles.d.ts +6 -0
  26. package/es/LineChart/styles.js +13 -0
  27. package/es/ScatterChart/ScatterChartTooltip.d.ts +13 -0
  28. package/es/ScatterChart/ScatterChartTooltip.js +83 -0
  29. package/es/ScatterChart/ScatterChartTooltipRow.d.ts +7 -0
  30. package/es/ScatterChart/ScatterChartTooltipRow.js +43 -0
  31. package/es/ScatterChart/index.d.ts +51 -0
  32. package/es/ScatterChart/index.js +304 -0
  33. package/es/ScatterChart/renderShape.d.ts +1 -0
  34. package/es/ScatterChart/renderShape.js +18 -0
  35. package/es/ScatterChart/styles.d.ts +6 -0
  36. package/es/ScatterChart/styles.js +13 -0
  37. package/es/common/BaseAnimationTimingProps.d.ts +7 -0
  38. package/es/common/BaseAnimationTimingProps.js +1 -0
  39. package/es/common/BaseChartProps.d.ts +47 -0
  40. package/es/common/BaseChartProps.js +1 -0
  41. package/es/common/ChartLegend.d.ts +3 -0
  42. package/es/common/ChartLegend.js +39 -0
  43. package/es/common/ChartTooltip/ChartTooltipFrame.d.ts +7 -0
  44. package/es/common/ChartTooltip/ChartTooltipFrame.js +28 -0
  45. package/es/common/ChartTooltip/ChartTooltipRow.d.ts +8 -0
  46. package/es/common/ChartTooltip/ChartTooltipRow.js +58 -0
  47. package/es/common/ChartTooltip/index.d.ts +10 -0
  48. package/es/common/ChartTooltip/index.js +65 -0
  49. package/es/common/CustomTooltipProps.d.ts +6 -0
  50. package/es/common/CustomTooltipProps.js +1 -0
  51. package/es/common/NoData.d.ts +10 -0
  52. package/es/common/NoData.js +43 -0
  53. package/es/common/utils.d.ts +5 -0
  54. package/es/common/utils.js +77 -0
  55. package/es/components/Legend/LegendItem.d.ts +9 -0
  56. package/es/components/Legend/LegendItem.js +65 -0
  57. package/es/components/Legend/ScrollButton.d.ts +9 -0
  58. package/es/components/Legend/ScrollButton.js +58 -0
  59. package/es/components/Legend/index.d.ts +11 -0
  60. package/es/components/Legend/index.js +173 -0
  61. package/es/hooks/useOnWindowResize.d.ts +3 -0
  62. package/es/hooks/useOnWindowResize.js +14 -0
  63. package/es/hooks/useThemeColorRange.d.ts +1 -0
  64. package/es/hooks/useThemeColorRange.js +5 -0
  65. package/es/index.d.ts +8 -0
  66. package/es/index.js +7 -0
  67. package/es/types.d.ts +20 -0
  68. package/es/types.js +1 -0
  69. package/es/utils/index.d.ts +3 -0
  70. package/es/utils/index.js +8 -0
  71. package/package.json +119 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 LobeHub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,218 @@
1
+ <a name="readme-top"></a>
2
+
3
+ <div align="center">
4
+
5
+ <img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
6
+ <img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
7
+ <img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/bar-chart.webp">
8
+
9
+ <h1>Lobe Charts</h1>
10
+
11
+ React modern charts components built on recharts
12
+
13
+ [Changelog](./CHANGELOG.md) · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
14
+
15
+ <!-- SHIELD GROUP -->
16
+
17
+ [![][npm-release-shield]][npm-release-link]
18
+ [![][vercel-shield]][vercel-link]
19
+ [![][discord-shield]][discord-link]
20
+ [![][npm-downloads-shield]][npm-downloads-link]<br/>
21
+ [![][github-releasedate-shield]][github-releasedate-link]
22
+ [![][github-action-test-shield]][github-action-test-link]
23
+ [![][github-action-release-shield]][github-action-release-link]<br/>
24
+ [![][github-contributors-shield]][github-contributors-link]
25
+ [![][github-forks-shield]][github-forks-link]
26
+ [![][github-stars-shield]][github-stars-link]
27
+ [![][github-issues-shield]][github-issues-link]
28
+ [![][github-license-shield]][github-license-link]
29
+
30
+ ![](https://github.com/user-attachments/assets/71f7ff66-7fc6-49b1-af12-02151c5b1026)
31
+
32
+ </div>
33
+
34
+ <details>
35
+ <summary><kbd>Table of contents</kbd></summary>
36
+
37
+ #### TOC
38
+
39
+ - [✨ Features](#-features)
40
+ - [📦 Installation](#-installation)
41
+ - [Compile with NextJS](#compile-with-nextjs)
42
+ - [⌨️ Local Development](#️-local-development)
43
+ - [🤝 Contributing](#-contributing)
44
+ - [🩷 Sponsor](#-sponsor)
45
+ - [🔗 Links](#-links)
46
+ - [More Products](#more-products)
47
+ - [Credits](#credits)
48
+
49
+ ####
50
+
51
+ </details>
52
+
53
+ ## ✨ Features
54
+
55
+ <div align="right">
56
+
57
+ [![][back-to-top]](#readme-top)
58
+
59
+ </div>
60
+
61
+ ## 📦 Installation
62
+
63
+ > \[!IMPORTANT]\
64
+ > This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
65
+
66
+ To install Lobe UI, run the following command:
67
+
68
+ [![][bun-shield]][bun-link]
69
+
70
+ ```bash
71
+ $ bun add @lobehub/charts
72
+ ```
73
+
74
+ ### Compile with NextJS
75
+
76
+ > \[!NOTE]\
77
+ > By work correct with nextjs ssr, add `transpilePackages: ['@lobehub/charts']` to `next.config.js`. For example:
78
+
79
+ ```js
80
+ // next.config.js
81
+ const nextConfig = {
82
+ // ...other config
83
+
84
+ transpilePackages: ['@lobehub/charts'],
85
+ };
86
+ ```
87
+
88
+ <div align="right">
89
+
90
+ [![][back-to-top]](#readme-top)
91
+
92
+ </div>
93
+
94
+ ## ⌨️ Local Development
95
+
96
+ You can use Github Codespaces for online development:
97
+
98
+ [![][codespaces-shield]][codespaces-link]
99
+
100
+ Or clone it for local development:
101
+
102
+ ```bash
103
+ $ git clone https://github.com/lobehub/lobe-charts.git
104
+ $ cd lobe-charts
105
+ $ bun install
106
+ $ bun start
107
+ ```
108
+
109
+ <div align="right">
110
+
111
+ [![][back-to-top]](#readme-top)
112
+
113
+ </div>
114
+
115
+ ## 🤝 Contributing
116
+
117
+ Contributions of all types are more than welcome, if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] to get stuck in to show us what you’re made of.
118
+
119
+ [![][pr-welcome-shield]][pr-welcome-link]
120
+
121
+ [![][contributors-contrib]][contributors-link]
122
+
123
+ <div align="right">
124
+
125
+ [![][back-to-top]](#readme-top)
126
+
127
+ </div>
128
+
129
+ ## 🩷 Sponsor
130
+
131
+ Every bit counts and your one-time donation sparkles in our galaxy of support! You're a shooting star, making a swift and bright impact on our journey. Thank you for believing in us – your generosity guides us toward our mission, one brilliant flash at a time.
132
+
133
+ <a href="https://opencollective.com/lobehub" target="_blank">
134
+ <picture>
135
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/lobehub/.github/blob/main/static/sponsor-dark.png?raw=true">
136
+ <img src="https://github.com/lobehub/.github/blob/main/static/sponsor-light.png?raw=true">
137
+ </picture>
138
+ </a>
139
+
140
+ <div align="right">
141
+
142
+ [![][back-to-top]](#readme-top)
143
+
144
+ </div>
145
+
146
+ ## 🔗 Links
147
+
148
+ ### More Products
149
+
150
+ - **[🤖 Lobe Chat][lobe-chat] :** An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application.
151
+ - **[🤯 Lobe Theme][lobe-theme] :** The modern theme for stable diffusion webui, exquisite interface design, highly customizable UI, and efficiency boosting features.
152
+ - **[🌏 Lobe i18n][lobe-i18n] :** Lobe i18n is an automation tool for the i18n (internationalization) translation process, powered by ChatGPT. It supports features such as automatic splitting of large files, incremental updates, and customization options for the OpenAI model, API proxy, and temperature.
153
+ - **[💌 Lobe Commit][lobe-commit] :** Lobe Commit is a CLI tool that leverages Langchain/ChatGPT to generate Gitmoji-based commit messages.
154
+
155
+ ### Credits
156
+
157
+ - **recharts** - <https://github.com/recharts/recharts>
158
+ - **tremor** - <https://github.com/tremorlabs/tremor>
159
+
160
+ <div align="right">
161
+
162
+ [![][back-to-top]](#readme-top)
163
+
164
+ </div>
165
+
166
+ ---
167
+
168
+ <details><summary><h4>📝 License</h4></summary>
169
+
170
+ [![][fossa-license-shield]][fossa-license-link]
171
+
172
+ </details>
173
+
174
+ Copyright © 2023 [LobeHub][profile-link]. <br />
175
+ This project is [MIT](./LICENSE) licensed.
176
+
177
+ <!-- LINK GROUP -->
178
+
179
+ [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
180
+ [bun-link]: https://bun.sh
181
+ [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
182
+ [codespaces-link]: https://codespaces.new/lobehub/lobe-charts
183
+ [codespaces-shield]: https://github.com/codespaces/badge.svg
184
+ [contributors-contrib]: https://contrib.rocks/image?repo=lobehub/lobe-charts
185
+ [contributors-link]: https://github.com/lobehub/lobe-charts/graphs/contributors
186
+ [discord-link]: https://discord.gg/AYFPHvv2jT
187
+ [discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
188
+ [fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-charts
189
+ [fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-charts.svg?type=large
190
+ [github-action-release-link]: https://github.com/actions/workflows/lobehub/lobe-charts/release.yml
191
+ [github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-charts/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
192
+ [github-action-test-link]: https://github.com/actions/workflows/lobehub/lobe-charts/test.yml
193
+ [github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-charts/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
194
+ [github-contributors-link]: https://github.com/lobehub/lobe-charts/graphs/contributors
195
+ [github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-charts?color=c4f042&labelColor=black&style=flat-square
196
+ [github-forks-link]: https://github.com/lobehub/lobe-charts/network/members
197
+ [github-forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-charts?color=8ae8ff&labelColor=black&style=flat-square
198
+ [github-issues-link]: https://github.com/lobehub/lobe-charts/issues
199
+ [github-issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-charts?color=ff80eb&labelColor=black&style=flat-square
200
+ [github-license-link]: https://github.com/lobehub/lobe-charts/blob/master/LICENSE
201
+ [github-license-shield]: https://img.shields.io/github/license/lobehub/lobe-charts?color=white&labelColor=black&style=flat-square
202
+ [github-releasedate-link]: https://github.com/lobehub/lobe-charts/releases
203
+ [github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-charts?labelColor=black&style=flat-square
204
+ [github-stars-link]: https://github.com/lobehub/lobe-charts/network/stargazers
205
+ [github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-charts?color=ffcb47&labelColor=black&style=flat-square
206
+ [lobe-chat]: https://github.com/lobehub/lobe-chat
207
+ [lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
208
+ [lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
209
+ [lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
210
+ [npm-downloads-link]: https://www.npmjs.com/package/@lobehub/charts
211
+ [npm-downloads-shield]: https://img.shields.io/npm/dt/@lobehub/charts?labelColor=black&style=flat-square
212
+ [npm-release-link]: https://www.npmjs.com/package/@lobehub/charts
213
+ [npm-release-shield]: https://img.shields.io/npm/v/@lobehub/charts?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
214
+ [pr-welcome-link]: https://github.com/lobehub/lobe-chat/pulls
215
+ [pr-welcome-shield]: https://img.shields.io/badge/🤯_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
216
+ [profile-link]: https://github.com/lobehub
217
+ [vercel-link]: https://charts.lobehub.com
218
+ [vercel-shield]: https://img.shields.io/website?down_message=offline&label=vercel&labelColor=black&logo=vercel&style=flat-square&up_message=online&url=https%3A%2F%2Fui.lobehub.com
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import BaseChartProps from "../common/BaseChartProps";
3
+ import { CurveType } from "../types";
4
+ export interface AreaChartProps extends BaseChartProps {
5
+ connectNulls?: boolean;
6
+ curveType?: CurveType;
7
+ showGradient?: boolean;
8
+ stack?: boolean;
9
+ }
10
+ declare const AreaChart: import("react").ForwardRefExoticComponent<AreaChartProps & import("react").RefAttributes<HTMLDivElement>>;
11
+ export default AreaChart;
@@ -0,0 +1,388 @@
1
+ 'use client';
2
+
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
7
+ var _templateObject, _templateObject2, _templateObject3, _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"];
9
+ import { css } from 'antd-style';
10
+ import { Fragment, forwardRef, useState } from 'react';
11
+ import { Flexbox } from 'react-layout-kit';
12
+ import { Area, CartesianGrid, Dot, Label, Legend, Line, AreaChart as ReChartsAreaChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
13
+ import ChartLegend from "../common/ChartLegend";
14
+ import ChartTooltip from "../common/ChartTooltip";
15
+ import NoData from "../common/NoData";
16
+ import { constructCategoryColors, getYAxisDomain, hasOnlyOneValueForThisKey } from "../common/utils";
17
+ import { useThemeColorRange } from "../hooks/useThemeColorRange";
18
+ import { defaultValueFormatter } from "../utils";
19
+ import { useStyles } from "./styles";
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ import { jsxs as _jsxs } from "react/jsx-runtime";
22
+ var AreaChart = /*#__PURE__*/forwardRef(function (props, ref) {
23
+ var _useStyles = useStyles(),
24
+ cx = _useStyles.cx,
25
+ theme = _useStyles.theme,
26
+ styles = _useStyles.styles;
27
+ var themeColorRange = useThemeColorRange();
28
+ var _props$data = props.data,
29
+ data = _props$data === void 0 ? [] : _props$data,
30
+ _props$categories = props.categories,
31
+ categories = _props$categories === void 0 ? [] : _props$categories,
32
+ index = props.index,
33
+ _props$stack = props.stack,
34
+ stack = _props$stack === void 0 ? false : _props$stack,
35
+ _props$colors = props.colors,
36
+ colors = _props$colors === void 0 ? themeColorRange : _props$colors,
37
+ _props$valueFormatter = props.valueFormatter,
38
+ valueFormatter = _props$valueFormatter === void 0 ? defaultValueFormatter : _props$valueFormatter,
39
+ _props$startEndOnly = props.startEndOnly,
40
+ startEndOnly = _props$startEndOnly === void 0 ? false : _props$startEndOnly,
41
+ _props$showXAxis = props.showXAxis,
42
+ showXAxis = _props$showXAxis === void 0 ? true : _props$showXAxis,
43
+ _props$showYAxis = props.showYAxis,
44
+ showYAxis = _props$showYAxis === void 0 ? true : _props$showYAxis,
45
+ _props$yAxisWidth = props.yAxisWidth,
46
+ yAxisWidth = _props$yAxisWidth === void 0 ? 56 : _props$yAxisWidth,
47
+ _props$intervalType = props.intervalType,
48
+ intervalType = _props$intervalType === void 0 ? 'equidistantPreserveStart' : _props$intervalType,
49
+ _props$showAnimation = props.showAnimation,
50
+ showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
51
+ _props$animationDurat = props.animationDuration,
52
+ animationDuration = _props$animationDurat === void 0 ? 900 : _props$animationDurat,
53
+ _props$showTooltip = props.showTooltip,
54
+ showTooltip = _props$showTooltip === void 0 ? true : _props$showTooltip,
55
+ _props$showLegend = props.showLegend,
56
+ showLegend = _props$showLegend === void 0 ? true : _props$showLegend,
57
+ _props$showGridLines = props.showGridLines,
58
+ showGridLines = _props$showGridLines === void 0 ? true : _props$showGridLines,
59
+ _props$showGradient = props.showGradient,
60
+ showGradient = _props$showGradient === void 0 ? true : _props$showGradient,
61
+ _props$autoMinValue = props.autoMinValue,
62
+ autoMinValue = _props$autoMinValue === void 0 ? false : _props$autoMinValue,
63
+ _props$curveType = props.curveType,
64
+ curveType = _props$curveType === void 0 ? 'linear' : _props$curveType,
65
+ minValue = props.minValue,
66
+ maxValue = props.maxValue,
67
+ _props$connectNulls = props.connectNulls,
68
+ connectNulls = _props$connectNulls === void 0 ? false : _props$connectNulls,
69
+ _props$allowDecimals = props.allowDecimals,
70
+ allowDecimals = _props$allowDecimals === void 0 ? true : _props$allowDecimals,
71
+ noDataText = props.noDataText,
72
+ className = props.className,
73
+ onValueChange = props.onValueChange,
74
+ _props$enableLegendSl = props.enableLegendSlider,
75
+ enableLegendSlider = _props$enableLegendSl === void 0 ? false : _props$enableLegendSl,
76
+ customTooltip = props.customTooltip,
77
+ rotateLabelX = props.rotateLabelX,
78
+ _props$tickGap = props.tickGap,
79
+ tickGap = _props$tickGap === void 0 ? 5 : _props$tickGap,
80
+ xAxisLabel = props.xAxisLabel,
81
+ yAxisLabel = props.yAxisLabel,
82
+ _props$width = props.width,
83
+ width = _props$width === void 0 ? '100%' : _props$width,
84
+ _props$height = props.height,
85
+ height = _props$height === void 0 ? '20rem' : _props$height,
86
+ rest = _objectWithoutProperties(props, _excluded);
87
+ var CustomTooltip = customTooltip;
88
+ var paddingValue = !showXAxis && !showYAxis || startEndOnly && !showYAxis ? 0 : 20;
89
+ var _useState = useState(60),
90
+ _useState2 = _slicedToArray(_useState, 2),
91
+ legendHeight = _useState2[0],
92
+ setLegendHeight = _useState2[1];
93
+ var _useState3 = useState(),
94
+ _useState4 = _slicedToArray(_useState3, 2),
95
+ activeDot = _useState4[0],
96
+ setActiveDot = _useState4[1];
97
+ var _useState5 = useState(),
98
+ _useState6 = _slicedToArray(_useState5, 2),
99
+ activeLegend = _useState6[0],
100
+ setActiveLegend = _useState6[1];
101
+ var categoryColors = constructCategoryColors(categories, colors);
102
+ var yAxisDomain = getYAxisDomain(autoMinValue, minValue, maxValue);
103
+ var hasOnValueChange = !!onValueChange;
104
+ function onDotClick(itemData, event) {
105
+ event.stopPropagation();
106
+ if (!hasOnValueChange) return;
107
+ 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) {
108
+ setActiveLegend(undefined);
109
+ setActiveDot(undefined);
110
+ onValueChange === null || onValueChange === void 0 || onValueChange(null);
111
+ } else {
112
+ setActiveLegend(itemData.dataKey);
113
+ setActiveDot({
114
+ dataKey: itemData.dataKey,
115
+ index: itemData.index
116
+ });
117
+ onValueChange === null || onValueChange === void 0 || onValueChange(_objectSpread({
118
+ categoryClicked: itemData.dataKey,
119
+ eventType: 'dot'
120
+ }, itemData.payload));
121
+ }
122
+ }
123
+ function onCategoryClick(dataKey) {
124
+ if (!hasOnValueChange) return;
125
+ if (dataKey === activeLegend && !activeDot || hasOnlyOneValueForThisKey(data, dataKey) && activeDot && activeDot.dataKey === dataKey) {
126
+ setActiveLegend(undefined);
127
+ onValueChange === null || onValueChange === void 0 || onValueChange(null);
128
+ } else {
129
+ setActiveLegend(dataKey);
130
+ onValueChange === null || onValueChange === void 0 || onValueChange({
131
+ categoryClicked: dataKey,
132
+ eventType: 'category'
133
+ });
134
+ }
135
+ setActiveDot(undefined);
136
+ }
137
+ return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
138
+ className: className,
139
+ height: height,
140
+ ref: ref,
141
+ width: width
142
+ }, rest), {}, {
143
+ children: /*#__PURE__*/_jsx(ResponsiveContainer, {
144
+ children: data !== null && data !== void 0 && data.length ? /*#__PURE__*/_jsxs(ReChartsAreaChart, {
145
+ data: data,
146
+ margin: {
147
+ bottom: xAxisLabel ? 30 : undefined,
148
+ left: yAxisLabel ? 20 : undefined,
149
+ right: yAxisLabel ? 5 : undefined,
150
+ top: 5
151
+ },
152
+ onClick: hasOnValueChange && (activeLegend || activeDot) ? function () {
153
+ setActiveDot(undefined);
154
+ setActiveLegend(undefined);
155
+ onValueChange === null || onValueChange === void 0 || onValueChange(null);
156
+ } : undefined,
157
+ children: [showGridLines ? /*#__PURE__*/_jsx(CartesianGrid, {
158
+ className: styles.gridLines,
159
+ horizontal: true,
160
+ vertical: false
161
+ }) : undefined, /*#__PURE__*/_jsx(XAxis, {
162
+ angle: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.angle,
163
+ axisLine: false,
164
+ className: styles.label,
165
+ dataKey: index,
166
+ dy: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.verticalShift,
167
+ fill: "",
168
+ height: rotateLabelX === null || rotateLabelX === void 0 ? void 0 : rotateLabelX.xAxisHeight,
169
+ hide: !showXAxis,
170
+ interval: startEndOnly ? 'preserveStartEnd' : intervalType,
171
+ minTickGap: tickGap,
172
+ padding: {
173
+ left: paddingValue,
174
+ right: paddingValue
175
+ },
176
+ stroke: "",
177
+ tick: {
178
+ transform: 'translate(0, 6)'
179
+ },
180
+ tickLine: false,
181
+ ticks: startEndOnly ? [data[0][index], data.at(-1)[index]] : undefined,
182
+ children: xAxisLabel && /*#__PURE__*/_jsx(Label, {
183
+ className: cx(styles.strongLabel, styles.emphasis),
184
+ offset: -20,
185
+ position: "insideBottom",
186
+ children: xAxisLabel
187
+ })
188
+ }), /*#__PURE__*/_jsx(YAxis, {
189
+ allowDecimals: allowDecimals,
190
+ axisLine: false,
191
+ className: styles.label,
192
+ domain: yAxisDomain,
193
+ fill: "",
194
+ hide: !showYAxis,
195
+ stroke: "",
196
+ tick: {
197
+ transform: 'translate(-3, 0)'
198
+ },
199
+ tickFormatter: valueFormatter,
200
+ tickLine: false,
201
+ type: "number",
202
+ width: yAxisWidth,
203
+ children: yAxisLabel && /*#__PURE__*/_jsx(Label, {
204
+ angle: -90,
205
+ className: cx(styles.strongLabel, styles.emphasis),
206
+ offset: -15,
207
+ position: "insideLeft",
208
+ style: {
209
+ textAnchor: 'middle'
210
+ },
211
+ children: yAxisLabel
212
+ })
213
+ }), /*#__PURE__*/_jsx(Tooltip, {
214
+ content: showTooltip ? function (_ref) {
215
+ var active = _ref.active,
216
+ payload = _ref.payload,
217
+ label = _ref.label;
218
+ return CustomTooltip ? /*#__PURE__*/_jsx(CustomTooltip, {
219
+ active: active,
220
+ label: label,
221
+ payload: payload === null || payload === void 0 ? void 0 : payload.map(function (payloadItem) {
222
+ var _categoryColors$get;
223
+ return _objectSpread(_objectSpread({}, payloadItem), {}, {
224
+ color: (_categoryColors$get = categoryColors.get(payloadItem.dataKey)) !== null && _categoryColors$get !== void 0 ? _categoryColors$get : theme.colorPrimary
225
+ });
226
+ })
227
+ }) : /*#__PURE__*/_jsx(ChartTooltip, {
228
+ active: active,
229
+ categoryColors: categoryColors,
230
+ label: label,
231
+ payload: payload,
232
+ valueFormatter: valueFormatter
233
+ });
234
+ } : undefined,
235
+ cursor: {
236
+ stroke: theme.colorTextSecondary,
237
+ strokeWidth: 1
238
+ },
239
+ isAnimationActive: false,
240
+ position: {
241
+ y: 0
242
+ },
243
+ wrapperStyle: {
244
+ outline: 'none'
245
+ }
246
+ }), showLegend ? /*#__PURE__*/_jsx(Legend, {
247
+ content: function content(_ref2) {
248
+ var payload = _ref2.payload;
249
+ return ChartLegend({
250
+ payload: payload
251
+ }, categoryColors, setLegendHeight, activeLegend, hasOnValueChange ? function (clickedLegendItem) {
252
+ return onCategoryClick(clickedLegendItem);
253
+ } : undefined, enableLegendSlider);
254
+ },
255
+ height: legendHeight,
256
+ verticalAlign: "top"
257
+ }) : undefined, categories.map(function (category) {
258
+ var _categoryColors$get2, _categoryColors$get3;
259
+ return /*#__PURE__*/_jsx("defs", {
260
+ children: showGradient ? /*#__PURE__*/_jsxs("linearGradient", {
261
+ className: cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n "])), (_categoryColors$get2 = categoryColors.get(category)) !== null && _categoryColors$get2 !== void 0 ? _categoryColors$get2 : theme.colorPrimary)),
262
+ id: categoryColors.get(category),
263
+ x1: "0",
264
+ x2: "0",
265
+ y1: "0",
266
+ y2: "1",
267
+ children: [/*#__PURE__*/_jsx("stop", {
268
+ offset: "5%",
269
+ stopColor: "currentColor",
270
+ stopOpacity: activeDot || activeLegend && activeLegend !== category ? 0.15 : 0.4
271
+ }), /*#__PURE__*/_jsx("stop", {
272
+ offset: "95%",
273
+ stopColor: "currentColor",
274
+ stopOpacity: 0
275
+ })]
276
+ }) : /*#__PURE__*/_jsx("linearGradient", {
277
+ className: cx(css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n "])), (_categoryColors$get3 = categoryColors.get(category)) !== null && _categoryColors$get3 !== void 0 ? _categoryColors$get3 : theme.colorPrimary)),
278
+ id: categoryColors.get(category),
279
+ x1: "0",
280
+ x2: "0",
281
+ y1: "0",
282
+ y2: "1",
283
+ children: /*#__PURE__*/_jsx("stop", {
284
+ stopColor: "currentColor",
285
+ stopOpacity: activeDot || activeLegend && activeLegend !== category ? 0.1 : 0.3
286
+ })
287
+ })
288
+ }, category);
289
+ }), categories.map(function (category) {
290
+ var _categoryColors$get5;
291
+ return /*#__PURE__*/_jsx(Area, {
292
+ activeDot: function activeDot(props) {
293
+ var _categoryColors$get4;
294
+ var dotCx = props.cx,
295
+ dotCy = props.cy,
296
+ stroke = props.stroke,
297
+ strokeLinecap = props.strokeLinecap,
298
+ strokeLinejoin = props.strokeLinejoin,
299
+ strokeWidth = props.strokeWidth,
300
+ dataKey = props.dataKey;
301
+ return /*#__PURE__*/_jsx(Dot, {
302
+ className: cx(css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n fill: ", ";\n "])), (_categoryColors$get4 = categoryColors.get(dataKey)) !== null && _categoryColors$get4 !== void 0 ? _categoryColors$get4 : theme.colorPrimary)),
303
+ cx: dotCx,
304
+ cy: dotCy,
305
+ fill: "",
306
+ onClick: function onClick(dotProps, event) {
307
+ return onDotClick(props, event);
308
+ },
309
+ r: 5,
310
+ stroke: stroke,
311
+ strokeLinecap: strokeLinecap,
312
+ strokeLinejoin: strokeLinejoin,
313
+ strokeWidth: strokeWidth
314
+ });
315
+ },
316
+ animationDuration: animationDuration,
317
+ className: cx(css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n stroke: ", ";\n "])), (_categoryColors$get5 = categoryColors.get(category)) !== null && _categoryColors$get5 !== void 0 ? _categoryColors$get5 : theme.colorPrimary)),
318
+ connectNulls: connectNulls,
319
+ dataKey: category,
320
+ dot: function dot(props) {
321
+ var stroke = props.stroke,
322
+ strokeLinecap = props.strokeLinecap,
323
+ strokeLinejoin = props.strokeLinejoin,
324
+ strokeWidth = props.strokeWidth,
325
+ dotCx = props.cx,
326
+ dotCy = props.cy,
327
+ dataKey = props.dataKey,
328
+ index = props.index;
329
+ if (hasOnlyOneValueForThisKey(data, category) && !(activeDot || activeLegend && activeLegend !== category) || (activeDot === null || activeDot === void 0 ? void 0 : activeDot.index) === index && (activeDot === null || activeDot === void 0 ? void 0 : activeDot.dataKey) === category) {
330
+ var _categoryColors$get6;
331
+ return /*#__PURE__*/_jsx(Dot, {
332
+ className: cx(css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n fill: ", ";\n "])), (_categoryColors$get6 = categoryColors.get(dataKey)) !== null && _categoryColors$get6 !== void 0 ? _categoryColors$get6 : theme.colorPrimary)),
333
+ cx: dotCx,
334
+ cy: dotCy,
335
+ fill: "",
336
+ r: 5,
337
+ stroke: stroke,
338
+ strokeLinecap: strokeLinecap,
339
+ strokeLinejoin: strokeLinejoin,
340
+ strokeWidth: strokeWidth,
341
+ style: {
342
+ cursor: onValueChange ? 'pointer' : undefined
343
+ }
344
+ }, index);
345
+ }
346
+ return /*#__PURE__*/_jsx(Fragment, {}, index);
347
+ },
348
+ fill: "url(#".concat(categoryColors.get(category), ")"),
349
+ isAnimationActive: showAnimation,
350
+ name: category,
351
+ stackId: stack ? 'a' : undefined,
352
+ stroke: "",
353
+ strokeLinecap: "round",
354
+ strokeLinejoin: "round",
355
+ strokeOpacity: activeDot || activeLegend && activeLegend !== category ? 0.3 : 1,
356
+ strokeWidth: 2,
357
+ type: curveType
358
+ }, category);
359
+ }), onValueChange ? categories.map(function (category) {
360
+ return /*#__PURE__*/_jsx(Line, {
361
+ connectNulls: connectNulls,
362
+ dataKey: category,
363
+ fill: "transparent",
364
+ legendType: "none",
365
+ name: category,
366
+ onClick: function onClick(props, event) {
367
+ event.stopPropagation();
368
+ var name = props.name;
369
+ onCategoryClick(name);
370
+ },
371
+ stroke: "transparent",
372
+ strokeOpacity: 0,
373
+ strokeWidth: 12,
374
+ style: {
375
+ cursor: 'pointer'
376
+ },
377
+ tooltipType: "none",
378
+ type: curveType
379
+ }, category);
380
+ }) : undefined]
381
+ }) : /*#__PURE__*/_jsx(NoData, {
382
+ noDataText: noDataText
383
+ })
384
+ })
385
+ }));
386
+ });
387
+ AreaChart.displayName = 'AreaChart';
388
+ export default AreaChart;
@@ -0,0 +1,6 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ emphasis: import("antd-style").SerializedStyles;
3
+ gridLines: import("antd-style").SerializedStyles;
4
+ label: import("antd-style").SerializedStyles;
5
+ strongLabel: import("antd-style").SerializedStyles;
6
+ }>;
@@ -0,0 +1,13 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css,
6
+ token = _ref.token;
7
+ return {
8
+ emphasis: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n "]))),
9
+ gridLines: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n stroke: ", ";\n stroke-width: 1;\n "])), token.colorBorderSecondary),
10
+ label: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextDescription),
11
+ strongLabel: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: 14px;\n font-weight: 500;\n line-height: 16px;\n fill: ", ";\n "])), token.colorTextSecondary)
12
+ };
13
+ });
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import BaseChartProps from "../common/BaseChartProps";
3
+ export interface BarChartProps extends BaseChartProps {
4
+ barCategoryGap?: string | number;
5
+ layout?: 'vertical' | 'horizontal';
6
+ relative?: boolean;
7
+ stack?: boolean;
8
+ }
9
+ declare const BarChart: import("react").ForwardRefExoticComponent<BarChartProps & import("react").RefAttributes<HTMLDivElement>>;
10
+ export default BarChart;