Initial commit - Dutchie dispensary scraper

This commit is contained in:
Kelly
2025-11-28 19:45:44 -07:00
commit 5757a8e9bd
23375 changed files with 3788799 additions and 0 deletions

28
frontend/node_modules/recharts/AGENTS.md generated vendored Normal file
View File

@@ -0,0 +1,28 @@
***CRITICAL*** **ALWAYS** unset `NODE_ENV` environment variable when working in this project. See https://github.com/github/copilot-cli/issues/151
This is Recharts repository. Recharts is a React-based charting library.
The goal is to provide a simple, declarative, and composable way to build charts.
We value consistency, usability, and performance. Accessibility is important.
We do not solve internationalization. Do not hardcode any strings or formatting choices in the library code,
we expect the users of Recharts to provide localized strings as desired.
Read ./DEVELOPING.md for instructions how to develop this project.
Read ./CONTRIBUTING.md for guidelines on contributing to this project.
When running unit tests, prefer to run a single test file:
```shell
npm run test -- path/to/TestFile.spec.tsx
```
If you run all tests at once using `npm test`, it may take a long time to complete.
Only do that when you want to verify that everything is working correctly.
This project has a long history. You may observe some inconsistencies in coding style.
When making changes, prefer current best practices as described in CONTRIBUTING.md,
and try to improve the code style where possible and where relevant to the current task.
Do not attempt to fix too much at once, or when it is not related to the current changes.
Do not focus too much on fitting the existing style, if it is not ideal.

1965
frontend/node_modules/recharts/CHANGELOG.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

90
frontend/node_modules/recharts/CONTRIBUTING.md generated vendored Normal file
View File

@@ -0,0 +1,90 @@
# Contributing to Recharts
We'd love for you to contribute to our source code and to make Recharts even better than it is today!
If you want to know how to develop then check out the [Development Guide](/DEVELOPING.md).
Here are the guidelines we'd like you to follow:
## Ongoing Initiatives
We use Github Discussion to organize our discussion along new initiatives and organize ourselves. Please do check the [announcements](https://github.com/recharts/recharts/discussions/categories/announcements) section for an overview of recent initiatives.
Also feel free to join us on Slack: https://recharts.slack.com/archives/C042Q5K5UDC
## <a name="issues"></a>Issues and Bugs
### Where to Find Known Issues
We will be using [GitHub Issues](https://github.com/recharts/recharts/issues) for our bugs and feature requests. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new task, try to make sure your problem doesn't already exist.
### Reporting New Issues
The best way to get your bug fixed is to provide a reduced test case. codesandbox provide a way to give live examples. You can fork our example in [recharts.github.io](https://recharts.github.io/) to show your case.
## <a name="testing"></a>Testing
We do cherish tests. They help us move swiftly, and release with confidence.
In our repo, you will find three types of tests: Unit tests, rendering tests with RTL, and user interaction tests in storybook.
Wherever possible we prefer the simplest tests - unit tests. Only where needed / useful we would use RTL or storybook tests.
### Unit tests
When writing new code, aim for 100% unit test code coverage.
When implementing a new feature we would prefer to extract pure helper function for data processing.
Such functions are found in a few utils files. An example is `test/util/ShallowEqual.spec.ts`.
Unit testing in recharts has some specialties, please see [Recharts unit tests README](test/README.md) for more information.
### React Testing Library
Some behaviour must be tested upon rendering, such as interactions between components (Line, Tooltip), see `test/component/Tooltip.visibility.spec.tsx` for an example.
### Storybook Test Runner
Storybook also has a great interface for adding tests. By default every story in storybook is a smoke test (rendering without error logs means the test passed). Additionally, it is possible to add actual tests as play functions with an assert to a story. This will often be easier than using React Testing Library, because the natural test debugging tool is Storybook itself. See for example `storybook/stories/Examples/cartesian/ReferenceLine/ReferenceLineIfOverflow.stories.tsx`
### Mutation tests
We have [stryker](https://stryker-mutator.io/docs/) installed and ready to use for mutation testing.
If you want to run mutation test be aware that these may take hours! A single file will take 15 minutes or more.
To run, update the list of checked files in `./stryker.config.mjs` and then run with `npm run test-mutation`.
You will find test output in your console, and also HTML report in the `./reports` folder.
## <a name="pr"></a>Pull Requests
**Working on your first Pull Request?** You can learn how from this _free_ series [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github)
_Before_ submitting a pull request, please make sure the following is done…
- Search [GitHub](https://github.com/recharts/recharts/pulls) for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort.
- Fork the repo and create your branch from `main`.
- If you have added functionality or changed existing functionality, be sure to add a test. Ideally a unit test for helper function, or a test that includes rendering with RTL.
- If you've changed APIs, make sure that the stories in Storybook are working as expected.
- Ensure the test suite passes (`npm run test`).
- Make sure your code lints (`npm run lint`) - we've done our best to make sure these rules match our internal linting guidelines.
## <a name="code"></a>Code Guide
Our linter will catch most styling issues that may exist in your code.
You can check the status of your code styling by running: `npm run lint`
However, there are still some styles that the linter cannot pick up. If you are unsure about something, looking at [Airbnb's Style Guide](https://github.com/airbnb/javascript) will guide you in the right direction.
## Types
We use TypeScript for type safety. Some rules to follow:
- Never use `any` type. Implicit or explicit.
- Prefer `unknown` over `any`. Refine the type.
- Type your function parameters and return values explicitly, do not rely on implicit any or inference. Exceptions are React components and trivial functions where the types are obvious.
- Do not use `as` type assertions, ever. The only exception is `as const`.
## <a name="license"></a>License
By contributing to Recharts, you agree that your contributions will be licensed under its MIT license.

214
frontend/node_modules/recharts/DEVELOPING.md generated vendored Normal file
View File

@@ -0,0 +1,214 @@
This is a development guide.
If you want to know the guidelines we follow then read [CONTRIBUTING.md](CONTRIBUTING.md).
# Setup development environment
```sh
git clone https://github.com/recharts/recharts.git
cd recharts
npm install
```
# Linting and types
You may also want to enable ESLint and Prettier configuration in your favourite IDE.
```sh
$ npm run lint
$ npm run check-types
```
# Automated testing
## Running unit tests
Most unit tests are in the `test` directory, some others are in `www/test`.
Run all tests:
```sh
$ npm run test
```
Run a specific test file:
```sh
$ npm run test -- path/to/TestFile.spec.tsx
```
## Running mutation tests
Mutation tests may take several hours to complete.
You may want to first open `./stryker.config.mjs` and set the `mutate` property to a specific file or directory
that you want to test. That may take 5-10 minutes to run.
Mutation tests do not run in CI.
```sh
$ npm run test-mutation
```
## Storybook
To run the Storybook UI:
```sh
$ npm run storybook
```
and then browse to http://localhost:6006.
While the storybook is running:
```sh
$ npm run test-storybook
```
## Run visual regression tests (using playwright)
### Prerequisites
Playwright tests are running inside Docker. You will need to have Docker installed and running.
See https://docs.docker.com/get-started/get-docker/. You do not need Docker account or login.
You only need to do this once.
### Build the Docker image
This takes two or three minutes to complete.
You will need to re-build every time you make a change to dependencies in `package.json`.
```sh
$ npm run test-vr:prepare
```
### Run the tests
Now, the usual loop. Write a new test, run it, fix it, repeat.
```sh
$ npm run test-vr
```
Alternatively, the UI playwright mode is available as well:
```sh
$ npm run test-vr:ui
```
If you want to record new snapshots or update the old ones, you can run:
```sh
$ npm run test-vr:update
```
You will see new files created in the `test-vr/__snapshots__` directory, please commit them to the repository!
### See VR test results
Open http://localhost:9323 in your browser to see the results of the tests.
The CLI will tell you to run a "show-report" which is not necessary because there is already a Docker container running
in the background and serving the report. Just open the URL in your browser.
# Manual testing
## recharts.github.io local run
To manually test Recharts in a real application environment, you can use the `www` directory which contains the source code
for the Recharts documentation website https://recharts.github.io.
You can add a new example and commit it too!
To run the website locally in dev mode with hot-reloading:
```sh
$ cd www
$ npm run start
```
When running locally, the website pulls the Recharts library from the local filesystem.
When you make changes to the Recharts source code, you need to re-build it for the changes to be reflected in the website:
```sh
$ cd ..
$ npm run build
$ cd www
```
In production build, the website pulls recharts from npm registry.
## Storybook
You can also use Storybook for manual testing of individual components.
```sh
$ npm run storybook
```
When adding new stories, mind that all stories here are also used for automated visual regression tests,
using Chromatic cloud infrastructure.
Chromatic are very generous and free for open source projects,
however we already have so many stories that we hit the limit for open source plan in some months.
For this reason, try to keep storybook for high fidelity examples, the ones you want to see published on the website
and in storybook UI. For low fidelity tests, use unit tests or VR tests instead.
## Playwright UI mode
You can also use Playwright in UI mode for manual testing. This opens a browser window where you can see the tests running,
and you can see before & after.
```sh
$ npm run test-vr:ui
```
# Releases
[Releases](https://github.com/recharts/recharts/releases) are automated via GH Actions - when a new release is created
in GH, CI will trigger that:
1. Runs a build
2. Runs tests
3. Runs `npm publish`
Version increments and tagging are not automated at this time.
## Release testing
Until we can automate more, it should be preferred to test as close to the results of `npm publish` as we possibly can.
This ensures we don't publish unintended breaking changes. One way to do that is using `yalc` - `npm i -g yalc`.
1. Make your changes in recharts
2. `yalc publish` in recharts
3. `yalc add recharts` in your test package (ex: in a vite or webpack reach app with recharts installed, imported, and
your recent changes used)
4. `npm install`
5. Test a local run, a build, etc.
# Folder structure
Source code:
- `src` - source code for Recharts library
- `test` - unit tests
- `test-vr` - visual regression tests (using Playwright)
- `www` - source code for Recharts documentation website recharts.github.io
- `storybook` - Storybook stories for Recharts components, and Storybook config+scaffolding
- `scripts` - helper scripts for development and releases
- `.husky` and `.github` - git hooks and GitHub Actions workflows for CI
Autogenerated code:
Running `npm run build` generates the following folders:
- `lib` - compiled output of Recharts library in CJS format - published to npm
- `es6` - compiled output of Recharts library in ESM format - published to npm
- `umd` - compiled output of Recharts library in UMD format - published to npm
- `types` - generated TypeScript declaration files - published to npm
- `build` - output of `tsc` build - we don't use this for anything at all I think
Running `npm run test-coverage` generates:
- `coverage` - code coverage report
Running `npm run test-mutation` generates:
- `reports` - mutation testing report

22
frontend/node_modules/recharts/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015-present recharts
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

92
frontend/node_modules/recharts/README.md generated vendored Normal file
View File

@@ -0,0 +1,92 @@
# Recharts
[![storybook](https://raw.githubusercontent.com/storybooks/brand/master/badge/badge-storybook.svg)](https://recharts.github.io/en-US/storybook)
[![Build Status](https://github.com/recharts/recharts/workflows/Node.js%20CI/badge.svg)](https://github.com/recharts/recharts/actions)
[![codecov](https://codecov.io/gh/recharts/recharts/graph/badge.svg?token=Bn6L2hrl8T)](https://codecov.io/gh/recharts/recharts)
[![npm version](https://badge.fury.io/js/recharts.svg)](http://badge.fury.io/js/recharts)
[![npm downloads](https://img.shields.io/npm/dm/recharts.svg?style=flat-square)](https://www.npmjs.com/package/recharts)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](/LICENSE)
## Introduction
Recharts is a **Redefined** chart library built with [React](https://facebook.github.io/react/) and [D3](http://d3js.org).
The main purpose of this library is to help you to write charts in React applications without any pain. Main principles of Recharts are:
1. **Simply** deploy with React components.
2. **Native** SVG support, lightweight with minimal dependencies.
3. **Declarative** components.
Documentation at [recharts.github.io](https://recharts.github.io) and our [storybook](https://recharts.github.io/en-US/storybook)
Also see [the wiki](https://github.com/recharts/recharts/wiki).
All development is done on the `main` branch. The current latest release and storybook documentation reflects what is on the `release` branch.
## Examples
```jsx
<LineChart width={400} height={400} data={data}>
<XAxis dataKey="name" />
<Tooltip />
<CartesianGrid stroke="#f5f5f5" />
<Line type="monotone" dataKey="uv" stroke="#ff7300" />
<Line type="monotone" dataKey="pv" stroke="#387908" />
</LineChart>
```
All the components of Recharts are clearly separated. The LineChart is composed of x axis, tooltip, grid, and line items, and each of them is an independent React Component. The clear separation and composition of components is one of the principle Recharts follows.
## Installation
### npm
NPM is the easiest and fastest way to get started using Recharts. It is also the recommended installation method when building single-page applications (SPAs). It pairs nicely with a CommonJS module bundler such as Webpack.
```sh
# latest stable
$ npm install recharts react-is
```
`react-is` needs to match the version of your installed `react` package.
### umd
The UMD build is also available on unpkg.com:
```html
<script src="https://unpkg.com/react/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/react-is/umd/react-is.production.min.js"></script>
<script src="https://unpkg.com/recharts/umd/Recharts.min.js"></script>
```
Then you can find the library on `window.Recharts`.
## Contributing
Recharts is open source. If you want to contribute to the project, please read the [CONTRIBUTING.md](/CONTRIBUTING.md)
to understand how to contribute to the project and [DEVELOPING.md](/DEVELOPING.md) to set up your development
environment.
## Thanks
<a href="https://www.chromatic.com/"><img src="https://user-images.githubusercontent.com/321738/84662277-e3db4f80-af1b-11ea-88f5-91d67a5e59f6.png" width="153" height="30" alt="Chromatic" /></a>
Thanks to [Chromatic](https://www.chromatic.com/) for providing the visual testing platform that helps us review UI changes and catch visual regressions.
[![JetBrains logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSourceSupport)
Thanks to JetBrains for providing OSS development license for their IDEs.
Browser testing via [<img src="https://www.lambdatest.com/blue-logo.png"
width="250"
height="45"
alt="LambdaTest"
/>](https://www.lambdatest.com/?utm_source=recharts&utm_medium=sponsor)
## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2015-2024 Recharts Group.

View File

@@ -0,0 +1,66 @@
/**
* Represents a single item in the ReactSmoothQueue.
* The item can be:
* - A number representing a delay in milliseconds.
* - An object representing a style change
* - A StartAnimationFunction that starts eased transition and calls different render
* because of course in Recharts we have to have three ways to do everything
* - An arbitrary function to be executed
*/
export function createAnimateManager(timeoutController) {
var currStyle;
var handleChange = () => null;
var shouldStop = false;
var cancelTimeout = null;
var setStyle = _style => {
if (shouldStop) {
return;
}
if (Array.isArray(_style)) {
if (!_style.length) {
return;
}
var styles = _style;
var [curr, ...restStyles] = styles;
if (typeof curr === 'number') {
cancelTimeout = timeoutController.setTimeout(setStyle.bind(null, restStyles), curr);
return;
}
setStyle(curr);
cancelTimeout = timeoutController.setTimeout(setStyle.bind(null, restStyles));
return;
}
if (typeof _style === 'string') {
currStyle = _style;
handleChange(currStyle);
}
if (typeof _style === 'object') {
currStyle = _style;
handleChange(currStyle);
}
if (typeof _style === 'function') {
_style();
}
};
return {
stop: () => {
shouldStop = true;
},
start: style => {
shouldStop = false;
if (cancelTimeout) {
cancelTimeout();
cancelTimeout = null;
}
setStyle(style);
},
subscribe: _handleChange => {
handleChange = _handleChange;
return () => {
handleChange = () => null;
};
},
getTimeoutController: () => timeoutController
};
}

View File

@@ -0,0 +1,83 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { noop } from '../util/DataUtils';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { useAnimationManager } from './useAnimationManager';
import { getTransitionVal } from './util';
var defaultProps = {
begin: 0,
duration: 1000,
easing: 'ease',
isActive: true,
canBegin: true,
onAnimationEnd: () => {},
onAnimationStart: () => {}
};
export function CSSTransitionAnimate(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultProps);
var {
animationId,
from,
to,
attributeName,
isActive,
canBegin,
duration,
easing,
begin,
onAnimationEnd,
onAnimationStart: onAnimationStartFromProps,
children
} = props;
var animationManager = useAnimationManager(animationId + attributeName, props.animationManager);
var [style, setStyle] = useState(() => {
if (!isActive) {
return to;
}
return from;
});
var initialized = useRef(false);
var onAnimationStart = useCallback(() => {
setStyle(from);
onAnimationStartFromProps();
}, [from, onAnimationStartFromProps]);
useEffect(() => {
if (!isActive || !canBegin) {
return noop;
}
initialized.current = true;
var unsubscribe = animationManager.subscribe(setStyle);
animationManager.start([onAnimationStart, begin, to, duration, onAnimationEnd]);
return () => {
animationManager.stop();
if (unsubscribe) {
unsubscribe();
}
onAnimationEnd();
};
}, [isActive, canBegin, duration, easing, begin, onAnimationStart, onAnimationEnd, animationManager, to, from]);
if (!isActive) {
/*
* With isActive=false, the component always renders with the final style, immediately,
* and ignores all other props.
* Also there is no transition applied.
*/
return children({
[attributeName]: to
});
}
if (!canBegin) {
return children({
[attributeName]: from
});
}
if (initialized.current) {
var transition = getTransitionVal([attributeName], duration, easing);
return children({
transition,
[attributeName]: style
});
}
return children({
[attributeName]: from
});
}

View File

@@ -0,0 +1,60 @@
import { useEffect, useRef, useState } from 'react';
import { noop } from '../util/DataUtils';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import configUpdate from './configUpdate';
import { configEasing } from './easing';
import { useAnimationManager } from './useAnimationManager';
var defaultJavascriptAnimateProps = {
begin: 0,
duration: 1000,
easing: 'ease',
isActive: true,
canBegin: true,
onAnimationEnd: () => {},
onAnimationStart: () => {}
};
var from = {
t: 0
};
var to = {
t: 1
};
export function JavascriptAnimate(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultJavascriptAnimateProps);
var {
isActive,
canBegin,
duration,
easing,
begin,
onAnimationEnd,
onAnimationStart,
children
} = props;
var animationManager = useAnimationManager(props.animationId, props.animationManager);
var [style, setStyle] = useState(isActive ? from : to);
var stopJSAnimation = useRef(null);
useEffect(() => {
if (!isActive) {
setStyle(to);
}
}, [isActive]);
useEffect(() => {
if (!isActive || !canBegin) {
return noop;
}
var startAnimation = configUpdate(from, to, configEasing(easing), duration, setStyle, animationManager.getTimeoutController());
var onAnimationActive = () => {
stopJSAnimation.current = startAnimation();
};
animationManager.start([onAnimationStart, begin, onAnimationActive, duration, onAnimationEnd]);
return () => {
animationManager.stop();
if (stopJSAnimation.current) {
stopJSAnimation.current();
}
onAnimationEnd();
};
}, [isActive, canBegin, duration, easing, begin, onAnimationStart, onAnimationEnd, animationManager]);
return children(style.t);
}

View File

@@ -0,0 +1,128 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { getIntersectionKeys, mapObject } from './util';
export var alpha = (begin, end, k) => begin + (end - begin) * k;
var needContinue = _ref => {
var {
from,
to
} = _ref;
return from !== to;
};
/*
* @description: cal new from value and velocity in each stepper
* @return: { [styleProperty]: { from, to, velocity } }
*/
var calStepperVals = (easing, preVals, steps) => {
var nextStepVals = mapObject((key, val) => {
if (needContinue(val)) {
var [newX, newV] = easing(val.from, val.to, val.velocity);
return _objectSpread(_objectSpread({}, val), {}, {
from: newX,
velocity: newV
});
}
return val;
}, preVals);
if (steps < 1) {
return mapObject((key, val) => {
if (needContinue(val)) {
return _objectSpread(_objectSpread({}, val), {}, {
velocity: alpha(val.velocity, nextStepVals[key].velocity, steps),
from: alpha(val.from, nextStepVals[key].from, steps)
});
}
return val;
}, preVals);
}
return calStepperVals(easing, nextStepVals, steps - 1);
};
function createStepperUpdate(from, to, easing, interKeys, render, timeoutController) {
var preTime;
var stepperStyle = interKeys.reduce((res, key) => _objectSpread(_objectSpread({}, res), {}, {
[key]: {
from: from[key],
velocity: 0,
to: to[key]
}
}), {});
var getCurrStyle = () => mapObject((key, val) => val.from, stepperStyle);
var shouldStopAnimation = () => !Object.values(stepperStyle).filter(needContinue).length;
var stopAnimation = null;
var stepperUpdate = now => {
if (!preTime) {
preTime = now;
}
var deltaTime = now - preTime;
var steps = deltaTime / easing.dt;
stepperStyle = calStepperVals(easing, stepperStyle, steps);
// get union set and add compatible prefix
render(_objectSpread(_objectSpread(_objectSpread({}, from), to), getCurrStyle()));
preTime = now;
if (!shouldStopAnimation()) {
stopAnimation = timeoutController.setTimeout(stepperUpdate);
}
};
// return start animation method
return () => {
stopAnimation = timeoutController.setTimeout(stepperUpdate);
// return stop animation method
return () => {
var _stopAnimation;
(_stopAnimation = stopAnimation) === null || _stopAnimation === void 0 || _stopAnimation();
};
};
}
function createTimingUpdate(from, to, easing, duration, interKeys, render, timeoutController) {
var stopAnimation = null;
var timingStyle = interKeys.reduce((res, key) => _objectSpread(_objectSpread({}, res), {}, {
[key]: [from[key], to[key]]
}), {});
var beginTime;
var timingUpdate = now => {
if (!beginTime) {
beginTime = now;
}
var t = (now - beginTime) / duration;
var currStyle = mapObject((key, val) => alpha(...val, easing(t)), timingStyle);
// get union set and add compatible prefix
render(_objectSpread(_objectSpread(_objectSpread({}, from), to), currStyle));
if (t < 1) {
stopAnimation = timeoutController.setTimeout(timingUpdate);
} else {
var finalStyle = mapObject((key, val) => alpha(...val, easing(1)), timingStyle);
render(_objectSpread(_objectSpread(_objectSpread({}, from), to), finalStyle));
}
};
// return start animation method
return () => {
stopAnimation = timeoutController.setTimeout(timingUpdate);
// return stop animation method
return () => {
var _stopAnimation2;
(_stopAnimation2 = stopAnimation) === null || _stopAnimation2 === void 0 || _stopAnimation2();
};
};
}
// configure update function
// eslint-disable-next-line import/no-default-export
export default (from, to, easing, duration, render, timeoutController) => {
var interKeys = getIntersectionKeys(from, to);
if (easing == null) {
// no animation, just set to final state
return () => {
render(_objectSpread(_objectSpread({}, from), to));
return () => {};
};
}
return easing.isStepper === true ? createStepperUpdate(from, to, easing, interKeys, render, timeoutController) : createTimingUpdate(from, to, easing, duration, interKeys, render, timeoutController);
};

View File

@@ -0,0 +1,5 @@
import { createAnimateManager } from './AnimationManager';
import { RequestAnimationFrameTimeoutController } from './timeoutController';
export function createDefaultAnimationManager() {
return createAnimateManager(new RequestAnimationFrameTimeoutController());
}

124
frontend/node_modules/recharts/es6/animation/easing.js generated vendored Normal file
View File

@@ -0,0 +1,124 @@
export var ACCURACY = 1e-4;
var cubicBezierFactor = (c1, c2) => [0, 3 * c1, 3 * c2 - 6 * c1, 3 * c1 - 3 * c2 + 1];
var evaluatePolynomial = (params, t) => params.map((param, i) => param * t ** i).reduce((pre, curr) => pre + curr);
var cubicBezier = (c1, c2) => t => {
var params = cubicBezierFactor(c1, c2);
return evaluatePolynomial(params, t);
};
var derivativeCubicBezier = (c1, c2) => t => {
var params = cubicBezierFactor(c1, c2);
var newParams = [...params.map((param, i) => param * i).slice(1), 0];
return evaluatePolynomial(newParams, t);
};
var getBezierCoordinates = function getBezierCoordinates() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args.length === 1) {
switch (args[0]) {
case 'linear':
return [0.0, 0.0, 1.0, 1.0];
case 'ease':
return [0.25, 0.1, 0.25, 1.0];
case 'ease-in':
return [0.42, 0.0, 1.0, 1.0];
case 'ease-out':
return [0.42, 0.0, 0.58, 1.0];
case 'ease-in-out':
return [0.0, 0.0, 0.58, 1.0];
default:
{
var _easing$;
var easing = args[0].split('(');
if (easing[0] === 'cubic-bezier' && ((_easing$ = easing[1]) === null || _easing$ === void 0 ? void 0 : _easing$.split(')')[0].split(',').length) === 4) {
var coords = easing[1].split(')')[0].split(',').map(x => parseFloat(x));
return [coords[0], coords[1], coords[2], coords[3]];
}
}
}
}
if (args.length === 4) {
return args;
}
// Fallback for invalid inputs. The previous implementation was buggy and would lead to NaN.
// Returning linear easing is a safe default.
return [0.0, 0.0, 1.0, 1.0];
};
var createBezierEasing = (x1, y1, x2, y2) => {
var curveX = cubicBezier(x1, x2);
var curveY = cubicBezier(y1, y2);
var derCurveX = derivativeCubicBezier(x1, x2);
var rangeValue = value => {
if (value > 1) {
return 1;
}
if (value < 0) {
return 0;
}
return value;
};
var bezier = _t => {
var t = _t > 1 ? 1 : _t;
var x = t;
for (var i = 0; i < 8; ++i) {
var evalT = curveX(x) - t;
var derVal = derCurveX(x);
if (Math.abs(evalT - t) < ACCURACY || derVal < ACCURACY) {
return curveY(x);
}
x = rangeValue(x - evalT / derVal);
}
return curveY(x);
};
bezier.isStepper = false;
return bezier;
};
// calculate cubic-bezier using Newton's method
export var configBezier = function configBezier() {
return createBezierEasing(...getBezierCoordinates(...arguments));
};
export var configSpring = function configSpring() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var {
stiff = 100,
damping = 8,
dt = 17
} = config;
var stepper = (currX, destX, currV) => {
var FSpring = -(currX - destX) * stiff;
var FDamping = currV * damping;
var newV = currV + (FSpring - FDamping) * dt / 1000;
var newX = currV * dt / 1000 + currX;
if (Math.abs(newX - destX) < ACCURACY && Math.abs(newV) < ACCURACY) {
return [destX, 0];
}
return [newX, newV];
};
stepper.isStepper = true;
stepper.dt = dt;
return stepper;
};
export var configEasing = easing => {
if (typeof easing === 'string') {
switch (easing) {
case 'ease':
case 'ease-in-out':
case 'ease-out':
case 'ease-in':
case 'linear':
return configBezier(easing);
case 'spring':
return configSpring();
default:
if (easing.split('(')[0] === 'cubic-bezier') {
return configBezier(easing);
}
}
}
if (typeof easing === 'function') {
return easing;
}
return null;
};

View File

@@ -0,0 +1,31 @@
/**
* Callback type for the timeout function.
* Receives current time in milliseconds as an argument.
*/
/**
* A function that, when called, cancels the timeout.
*/
export class RequestAnimationFrameTimeoutController {
setTimeout(callback) {
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var startTime = performance.now();
var requestId = null;
var executeCallback = now => {
if (now - startTime >= delay) {
callback(now);
// tests fail without the extra if, even when five lines below it's not needed
// TODO finish transition to the mocked timeout controller and then remove this condition
} else if (typeof requestAnimationFrame === 'function') {
requestId = requestAnimationFrame(executeCallback);
}
};
requestId = requestAnimationFrame(executeCallback);
return () => {
if (requestId != null) {
cancelAnimationFrame(requestId);
}
};
}
}

View File

@@ -0,0 +1,7 @@
import { createContext, useContext, useMemo } from 'react';
import { createDefaultAnimationManager } from './createDefaultAnimationManager';
export var AnimationManagerContext = /*#__PURE__*/createContext(createDefaultAnimationManager);
export function useAnimationManager(animationId, animationManagerFromProps) {
var contextAnimationManager = useContext(AnimationManagerContext);
return useMemo(() => animationManagerFromProps !== null && animationManagerFromProps !== void 0 ? animationManagerFromProps : contextAnimationManager(animationId), [animationId, animationManagerFromProps, contextAnimationManager]);
}

29
frontend/node_modules/recharts/es6/animation/util.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/*
* @description: convert camel case to dash case
* string => string
*/
export var getDashCase = name => name.replace(/([A-Z])/g, v => "-".concat(v.toLowerCase()));
export var getTransitionVal = (props, duration, easing) => props.map(prop => "".concat(getDashCase(prop), " ").concat(duration, "ms ").concat(easing)).join(',');
/**
* Finds the intersection of keys between two objects
* @param {object} preObj previous object
* @param {object} nextObj next object
* @returns an array of keys that exist in both objects
*/
export var getIntersectionKeys = (preObj, nextObj) => [Object.keys(preObj), Object.keys(nextObj)].reduce((a, b) => a.filter(c => b.includes(c)));
/**
* Maps an object to another object
* @param {function} fn function to map
* @param {object} obj object to map
* @returns mapped object
*/
export var mapObject = (fn, obj) => Object.keys(obj).reduce((res, key) => _objectSpread(_objectSpread({}, res), {}, {
[key]: fn(key, obj[key])
}), {});

754
frontend/node_modules/recharts/es6/cartesian/Area.js generated vendored Normal file
View File

@@ -0,0 +1,754 @@
var _excluded = ["id"],
_excluded2 = ["activeDot", "animationBegin", "animationDuration", "animationEasing", "connectNulls", "dot", "fill", "fillOpacity", "hide", "isAnimationActive", "legendType", "stroke", "xAxisId", "yAxisId"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { PureComponent, useCallback, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { Curve } from '../shape/Curve';
import { Layer } from '../container/Layer';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { Dots } from '../component/Dots';
import { Global } from '../util/Global';
import { interpolate, isNan, isNullish, isNumber } from '../util/DataUtils';
import { getCateCoordinateOfLine, getNormalizedStackId, getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
import { isClipDot } from '../util/ReactUtils';
import { ActivePoints } from '../component/ActivePoints';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { GraphicalItemClipPath, useNeedsClip } from './GraphicalItemClipPath';
import { selectArea } from '../state/selectors/areaSelectors';
import { useIsPanorama } from '../context/PanoramaContext';
import { useChartLayout } from '../context/chartLayoutContext';
import { useChartName } from '../state/selectors/selectors';
import { SetLegendPayload } from '../state/SetLegendPayload';
import { useAppSelector } from '../state/hooks';
import { useAnimationId } from '../util/useAnimationId';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { isWellBehavedNumber } from '../util/isWellBehavedNumber';
import { usePlotArea } from '../hooks';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetCartesianGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { getRadiusAndStrokeWidthFromDot } from '../util/getRadiusAndStrokeWidthFromDot';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
/**
* External props, intended for end users to fill in
*/
/**
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
*/
function getLegendItemColor(stroke, fill) {
return stroke && stroke !== 'none' ? stroke : fill;
}
var computeLegendPayloadFromAreaData = props => {
var {
dataKey,
name,
stroke,
fill,
legendType,
hide
} = props;
return [{
inactive: hide,
dataKey,
type: legendType,
color: getLegendItemColor(stroke, fill),
value: getTooltipNameProp(name, dataKey),
payload: props
}];
};
function getTooltipEntrySettings(props) {
var {
dataKey,
data,
stroke,
strokeWidth,
fill,
name,
hide,
unit
} = props;
return {
dataDefinedOnItem: data,
positions: undefined,
settings: {
stroke,
strokeWidth,
fill,
dataKey,
nameKey: undefined,
name: getTooltipNameProp(name, dataKey),
hide,
type: props.tooltipType,
color: getLegendItemColor(stroke, fill),
unit
}
};
}
function AreaDotsWrapper(_ref) {
var {
clipPathId,
points,
props
} = _ref;
var {
needClip,
dot,
dataKey
} = props;
var areaProps = svgPropertiesNoEvents(props);
return /*#__PURE__*/React.createElement(Dots, {
points: points,
dot: dot,
className: "recharts-area-dots",
dotClassName: "recharts-area-dot",
dataKey: dataKey,
baseProps: areaProps,
needClip: needClip,
clipPathId: clipPathId
});
}
function AreaLabelListProvider(_ref2) {
var {
showLabels,
children,
points
} = _ref2;
var labelListEntries = points.map(point => {
var _point$x, _point$y;
var viewBox = {
x: (_point$x = point.x) !== null && _point$x !== void 0 ? _point$x : 0,
y: (_point$y = point.y) !== null && _point$y !== void 0 ? _point$y : 0,
width: 0,
lowerWidth: 0,
upperWidth: 0,
height: 0
};
return _objectSpread(_objectSpread({}, viewBox), {}, {
value: point.value,
payload: point.payload,
parentViewBox: undefined,
viewBox,
fill: undefined
});
});
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function StaticArea(_ref3) {
var {
points,
baseLine,
needClip,
clipPathId,
props
} = _ref3;
var {
layout,
type,
stroke,
connectNulls,
isRange
} = props;
var {
id
} = props,
propsWithoutId = _objectWithoutProperties(props, _excluded);
var allOtherProps = svgPropertiesNoEvents(propsWithoutId);
var propsWithEvents = svgPropertiesAndEvents(propsWithoutId);
return /*#__PURE__*/React.createElement(React.Fragment, null, (points === null || points === void 0 ? void 0 : points.length) > 1 && /*#__PURE__*/React.createElement(Layer, {
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined
}, /*#__PURE__*/React.createElement(Curve, _extends({}, propsWithEvents, {
id: id,
points: points,
connectNulls: connectNulls,
type: type,
baseLine: baseLine,
layout: layout,
stroke: "none",
className: "recharts-area-area"
})), stroke !== 'none' && /*#__PURE__*/React.createElement(Curve, _extends({}, allOtherProps, {
className: "recharts-area-curve",
layout: layout,
type: type,
connectNulls: connectNulls,
fill: "none",
points: points
})), stroke !== 'none' && isRange && /*#__PURE__*/React.createElement(Curve, _extends({}, allOtherProps, {
className: "recharts-area-curve",
layout: layout,
type: type,
connectNulls: connectNulls,
fill: "none",
points: baseLine
}))), /*#__PURE__*/React.createElement(AreaDotsWrapper, {
points: points,
props: propsWithoutId,
clipPathId: clipPathId
}));
}
function VerticalRect(_ref4) {
var {
alpha,
baseLine,
points,
strokeWidth
} = _ref4;
var startY = points[0].y;
var endY = points[points.length - 1].y;
if (!isWellBehavedNumber(startY) || !isWellBehavedNumber(endY)) {
return null;
}
var height = alpha * Math.abs(startY - endY);
var maxX = Math.max(...points.map(entry => entry.x || 0));
if (isNumber(baseLine)) {
maxX = Math.max(baseLine, maxX);
} else if (baseLine && Array.isArray(baseLine) && baseLine.length) {
maxX = Math.max(...baseLine.map(entry => entry.x || 0), maxX);
}
if (isNumber(maxX)) {
return /*#__PURE__*/React.createElement("rect", {
x: 0,
y: startY < endY ? startY : startY - height,
width: maxX + (strokeWidth ? parseInt("".concat(strokeWidth), 10) : 1),
height: Math.floor(height)
});
}
return null;
}
function HorizontalRect(_ref5) {
var {
alpha,
baseLine,
points,
strokeWidth
} = _ref5;
var startX = points[0].x;
var endX = points[points.length - 1].x;
if (!isWellBehavedNumber(startX) || !isWellBehavedNumber(endX)) {
return null;
}
var width = alpha * Math.abs(startX - endX);
var maxY = Math.max(...points.map(entry => entry.y || 0));
if (isNumber(baseLine)) {
maxY = Math.max(baseLine, maxY);
} else if (baseLine && Array.isArray(baseLine) && baseLine.length) {
maxY = Math.max(...baseLine.map(entry => entry.y || 0), maxY);
}
if (isNumber(maxY)) {
return /*#__PURE__*/React.createElement("rect", {
x: startX < endX ? startX : startX - width,
y: 0,
width: width,
height: Math.floor(maxY + (strokeWidth ? parseInt("".concat(strokeWidth), 10) : 1))
});
}
return null;
}
function ClipRect(_ref6) {
var {
alpha,
layout,
points,
baseLine,
strokeWidth
} = _ref6;
if (layout === 'vertical') {
return /*#__PURE__*/React.createElement(VerticalRect, {
alpha: alpha,
points: points,
baseLine: baseLine,
strokeWidth: strokeWidth
});
}
return /*#__PURE__*/React.createElement(HorizontalRect, {
alpha: alpha,
points: points,
baseLine: baseLine,
strokeWidth: strokeWidth
});
}
function AreaWithAnimation(_ref7) {
var {
needClip,
clipPathId,
props,
previousPointsRef,
previousBaselineRef
} = _ref7;
var {
points,
baseLine,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
onAnimationStart,
onAnimationEnd
} = props;
var animationId = useAnimationId(props, 'recharts-area-');
var [isAnimating, setIsAnimating] = useState(false);
var showLabels = !isAnimating;
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
var prevPoints = previousPointsRef.current;
var prevBaseLine = previousBaselineRef.current;
return /*#__PURE__*/React.createElement(AreaLabelListProvider, {
showLabels: showLabels,
points: points
}, props.children, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
onAnimationEnd: handleAnimationEnd,
onAnimationStart: handleAnimationStart,
key: animationId
}, t => {
if (prevPoints) {
var prevPointsDiffFactor = prevPoints.length / points.length;
var stepPoints =
/*
* Here it is important that at the very end of the animation, on the last frame,
* we render the original points without any interpolation.
* This is needed because the code above is checking for reference equality to decide if the animation should run
* and if we create a new array instance (even if the numbers were the same)
* then we would break animations.
*/
t === 1 ? points : points.map((entry, index) => {
var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
if (prevPoints[prevPointIndex]) {
var prev = prevPoints[prevPointIndex];
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(prev.x, entry.x, t),
y: interpolate(prev.y, entry.y, t)
});
}
return entry;
});
var stepBaseLine;
if (isNumber(baseLine)) {
stepBaseLine = interpolate(prevBaseLine, baseLine, t);
} else if (isNullish(baseLine) || isNan(baseLine)) {
stepBaseLine = interpolate(prevBaseLine, 0, t);
} else {
stepBaseLine = baseLine.map((entry, index) => {
var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
if (Array.isArray(prevBaseLine) && prevBaseLine[prevPointIndex]) {
var prev = prevBaseLine[prevPointIndex];
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(prev.x, entry.x, t),
y: interpolate(prev.y, entry.y, t)
});
}
return entry;
});
}
if (t > 0) {
/*
* We need to keep the refs in the parent component because we need to remember the last shape of the animation
* even if AreaWithAnimation is unmounted as that happens when changing props.
*
* And we need to update the refs here because here is where the interpolation is computed.
* Eslint doesn't like changing function arguments, but we need it so here is an eslint-disable.
*/
// eslint-disable-next-line no-param-reassign
previousPointsRef.current = stepPoints;
// eslint-disable-next-line no-param-reassign
previousBaselineRef.current = stepBaseLine;
}
return /*#__PURE__*/React.createElement(StaticArea, {
points: stepPoints,
baseLine: stepBaseLine,
needClip: needClip,
clipPathId: clipPathId,
props: props
});
}
if (t > 0) {
// eslint-disable-next-line no-param-reassign
previousPointsRef.current = points;
// eslint-disable-next-line no-param-reassign
previousBaselineRef.current = baseLine;
}
return /*#__PURE__*/React.createElement(Layer, null, isAnimationActive && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
id: "animationClipPath-".concat(clipPathId)
}, /*#__PURE__*/React.createElement(ClipRect, {
alpha: t,
points: points,
baseLine: baseLine,
layout: props.layout,
strokeWidth: props.strokeWidth
}))), /*#__PURE__*/React.createElement(Layer, {
clipPath: "url(#animationClipPath-".concat(clipPathId, ")")
}, /*#__PURE__*/React.createElement(StaticArea, {
points: points,
baseLine: baseLine,
needClip: needClip,
clipPathId: clipPathId,
props: props
})));
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}));
}
/*
* This components decides if the area should be animated or not.
* It also holds the state of the animation.
*/
function RenderArea(_ref8) {
var {
needClip,
clipPathId,
props
} = _ref8;
/*
* These two must be refs, not state!
* Because we want to store the most recent shape of the animation in case we have to interrupt the animation;
* that happens when user initiates another animation before the current one finishes.
*
* If this was a useState, then every step in the animation would trigger a re-render.
* So, useRef it is.
*/
var previousPointsRef = useRef(null);
var previousBaselineRef = useRef();
return /*#__PURE__*/React.createElement(AreaWithAnimation, {
needClip: needClip,
clipPathId: clipPathId,
props: props,
previousPointsRef: previousPointsRef,
previousBaselineRef: previousBaselineRef
});
}
class AreaWithState extends PureComponent {
render() {
var {
hide,
dot,
points,
className,
top,
left,
needClip,
xAxisId,
yAxisId,
width,
height,
id,
baseLine,
zIndex
} = this.props;
if (hide) {
return null;
}
var layerClass = clsx('recharts-area', className);
var clipPathId = id;
var {
r,
strokeWidth
} = getRadiusAndStrokeWidthFromDot(dot);
var clipDot = isClipDot(dot);
var dotSize = r * 2 + strokeWidth;
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, needClip && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement(GraphicalItemClipPath, {
clipPathId: clipPathId,
xAxisId: xAxisId,
yAxisId: yAxisId
}), !clipDot && /*#__PURE__*/React.createElement("clipPath", {
id: "clipPath-dots-".concat(clipPathId)
}, /*#__PURE__*/React.createElement("rect", {
x: left - dotSize / 2,
y: top - dotSize / 2,
width: width + dotSize,
height: height + dotSize
}))), /*#__PURE__*/React.createElement(RenderArea, {
needClip: needClip,
clipPathId: clipPathId,
props: this.props
})), /*#__PURE__*/React.createElement(ActivePoints, {
points: points,
mainColor: getLegendItemColor(this.props.stroke, this.props.fill),
itemDataKey: this.props.dataKey,
activeDot: this.props.activeDot
}), this.props.isRange && Array.isArray(baseLine) && /*#__PURE__*/React.createElement(ActivePoints, {
points: baseLine,
mainColor: getLegendItemColor(this.props.stroke, this.props.fill),
itemDataKey: this.props.dataKey,
activeDot: this.props.activeDot
}));
}
}
var defaultAreaProps = {
activeDot: true,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease',
connectNulls: false,
dot: false,
fill: '#3182bd',
fillOpacity: 0.6,
hide: false,
isAnimationActive: !Global.isSsr,
legendType: 'line',
stroke: '#3182bd',
xAxisId: 0,
yAxisId: 0,
zIndex: DefaultZIndexes.area
};
function AreaImpl(props) {
var _useAppSelector;
var _resolveDefaultProps = resolveDefaultProps(props, defaultAreaProps),
{
activeDot,
animationBegin,
animationDuration,
animationEasing,
connectNulls,
dot,
fill,
fillOpacity,
hide,
isAnimationActive,
legendType,
stroke,
xAxisId,
yAxisId
} = _resolveDefaultProps,
everythingElse = _objectWithoutProperties(_resolveDefaultProps, _excluded2);
var layout = useChartLayout();
var chartName = useChartName();
var {
needClip
} = useNeedsClip(xAxisId, yAxisId);
var isPanorama = useIsPanorama();
var {
points,
isRange,
baseLine
} = (_useAppSelector = useAppSelector(state => selectArea(state, xAxisId, yAxisId, isPanorama, props.id))) !== null && _useAppSelector !== void 0 ? _useAppSelector : {};
var plotArea = usePlotArea();
if (layout !== 'horizontal' && layout !== 'vertical' || plotArea == null) {
// Can't render Area in an unsupported layout
return null;
}
if (chartName !== 'AreaChart' && chartName !== 'ComposedChart') {
// There is nothing stopping us from rendering Area in other charts, except for historical reasons. Do we want to allow that?
return null;
}
var {
height,
width,
x: left,
y: top
} = plotArea;
if (!points || !points.length) {
return null;
}
return /*#__PURE__*/React.createElement(AreaWithState, _extends({}, everythingElse, {
activeDot: activeDot,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
baseLine: baseLine,
connectNulls: connectNulls,
dot: dot,
fill: fill,
fillOpacity: fillOpacity,
height: height,
hide: hide,
layout: layout,
isAnimationActive: isAnimationActive,
isRange: isRange,
legendType: legendType,
needClip: needClip,
points: points,
stroke: stroke,
width: width,
left: left,
top: top,
xAxisId: xAxisId,
yAxisId: yAxisId
}));
}
export var getBaseValue = (layout, chartBaseValue, itemBaseValue, xAxis, yAxis) => {
// The baseValue can be defined both on the AreaChart, and on the Area.
// The value for the item takes precedence.
var baseValue = itemBaseValue !== null && itemBaseValue !== void 0 ? itemBaseValue : chartBaseValue;
if (isNumber(baseValue)) {
return baseValue;
}
var numericAxis = layout === 'horizontal' ? yAxis : xAxis;
// @ts-expect-error d3scale .domain() returns unknown, Math.max expects number
var domain = numericAxis.scale.domain();
if (numericAxis.type === 'number') {
var domainMax = Math.max(domain[0], domain[1]);
var domainMin = Math.min(domain[0], domain[1]);
if (baseValue === 'dataMin') {
return domainMin;
}
if (baseValue === 'dataMax') {
return domainMax;
}
return domainMax < 0 ? domainMax : Math.max(Math.min(domain[0], domain[1]), 0);
}
if (baseValue === 'dataMin') {
return domain[0];
}
if (baseValue === 'dataMax') {
return domain[1];
}
return domain[0];
};
export function computeArea(_ref9) {
var {
areaSettings: {
connectNulls,
baseValue: itemBaseValue,
dataKey
},
stackedData,
layout,
chartBaseValue,
xAxis,
yAxis,
displayedData,
dataStartIndex,
xAxisTicks,
yAxisTicks,
bandSize
} = _ref9;
var hasStack = stackedData && stackedData.length;
var baseValue = getBaseValue(layout, chartBaseValue, itemBaseValue, xAxis, yAxis);
var isHorizontalLayout = layout === 'horizontal';
var isRange = false;
var points = displayedData.map((entry, index) => {
var value;
if (hasStack) {
value = stackedData[dataStartIndex + index];
} else {
value = getValueByDataKey(entry, dataKey);
if (!Array.isArray(value)) {
value = [baseValue, value];
} else {
isRange = true;
}
}
var isBreakPoint = value[1] == null || hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null;
if (isHorizontalLayout) {
return {
x: getCateCoordinateOfLine({
axis: xAxis,
ticks: xAxisTicks,
bandSize,
entry,
index
}),
y: isBreakPoint ? null : yAxis.scale(value[1]),
value,
payload: entry
};
}
return {
x: isBreakPoint ? null : xAxis.scale(value[1]),
y: getCateCoordinateOfLine({
axis: yAxis,
ticks: yAxisTicks,
bandSize,
entry,
index
}),
value,
payload: entry
};
});
var baseLine;
if (hasStack || isRange) {
baseLine = points.map(entry => {
var x = Array.isArray(entry.value) ? entry.value[0] : null;
if (isHorizontalLayout) {
return {
x: entry.x,
y: x != null && entry.y != null ? yAxis.scale(x) : null,
payload: entry.payload
};
}
return {
x: x != null ? xAxis.scale(x) : null,
y: entry.y,
payload: entry.payload
};
});
} else {
baseLine = isHorizontalLayout ? yAxis.scale(baseValue) : xAxis.scale(baseValue);
}
return {
points,
baseLine,
isRange
};
}
function AreaFn(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultAreaProps);
var isPanorama = useIsPanorama();
// Report all props to Redux store first, before calling any hooks, to avoid circular dependencies.
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "area"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetLegendPayload, {
legendPayload: computeLegendPayloadFromAreaData(props)
}), /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: props
}), /*#__PURE__*/React.createElement(SetCartesianGraphicalItem, {
type: "area",
id: id,
data: props.data,
dataKey: props.dataKey,
xAxisId: props.xAxisId,
yAxisId: props.yAxisId,
zAxisId: 0,
stackId: getNormalizedStackId(props.stackId),
hide: props.hide,
barSize: undefined,
baseValue: props.baseValue,
isPanorama: isPanorama,
connectNulls: props.connectNulls
}), /*#__PURE__*/React.createElement(AreaImpl, _extends({}, props, {
id: id
}))));
}
export var Area = /*#__PURE__*/React.memo(AreaFn);
Area.displayName = 'Area';

664
frontend/node_modules/recharts/es6/cartesian/Bar.js generated vendored Normal file
View File

@@ -0,0 +1,664 @@
var _excluded = ["onMouseEnter", "onMouseLeave", "onClick"],
_excluded2 = ["value", "background", "tooltipPosition"],
_excluded3 = ["id"],
_excluded4 = ["onMouseEnter", "onClick", "onMouseLeave"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { PureComponent, useCallback, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { Cell } from '../component/Cell';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { interpolate, isNan, mathSign } from '../util/DataUtils';
import { findAllByType } from '../util/ReactUtils';
import { Global } from '../util/Global';
import { getBaseValueOfBar, getCateCoordinateOfBar, getNormalizedStackId, getTooltipNameProp, getValueByDataKey, truncateByDomain } from '../util/ChartUtils';
import { adaptEventsOfChild } from '../util/types';
import { BarRectangle, minPointSizeCallback } from '../util/BarUtils';
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { SetErrorBarContext } from '../context/ErrorBarContext';
import { GraphicalItemClipPath, useNeedsClip } from './GraphicalItemClipPath';
import { useChartLayout } from '../context/chartLayoutContext';
import { selectBarRectangles } from '../state/selectors/barSelectors';
import { useAppSelector } from '../state/hooks';
import { useIsPanorama } from '../context/PanoramaContext';
import { selectActiveTooltipDataKey, selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
import { SetLegendPayload } from '../state/SetLegendPayload';
import { useAnimationId } from '../util/useAnimationId';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetCartesianGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
import { getZIndexFromUnknown } from '../zIndex/getZIndexFromUnknown';
var computeLegendPayloadFromBarData = props => {
var {
dataKey,
name,
fill,
legendType,
hide
} = props;
return [{
inactive: hide,
dataKey,
type: legendType,
color: fill,
value: getTooltipNameProp(name, dataKey),
payload: props
}];
};
function getTooltipEntrySettings(props) {
var {
dataKey,
stroke,
strokeWidth,
fill,
name,
hide,
unit
} = props;
return {
dataDefinedOnItem: undefined,
positions: undefined,
settings: {
stroke,
strokeWidth,
fill,
dataKey,
nameKey: undefined,
name: getTooltipNameProp(name, dataKey),
hide,
type: props.tooltipType,
color: props.fill,
unit
}
};
}
function BarBackground(props) {
var activeIndex = useAppSelector(selectActiveTooltipIndex);
var {
data,
dataKey,
background: backgroundFromProps,
allOtherBarProps
} = props;
var {
onMouseEnter: onMouseEnterFromProps,
onMouseLeave: onMouseLeaveFromProps,
onClick: onItemClickFromProps
} = allOtherBarProps,
restOfAllOtherProps = _objectWithoutProperties(allOtherBarProps, _excluded);
// @ts-expect-error bar mouse events are not compatible with recharts mouse events
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, dataKey);
// @ts-expect-error bar mouse events are not compatible with recharts mouse events
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
// @ts-expect-error bar mouse events are not compatible with recharts mouse events
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, dataKey);
if (!backgroundFromProps || data == null) {
return null;
}
var backgroundProps = svgPropertiesNoEventsFromUnknown(backgroundFromProps);
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: getZIndexFromUnknown(backgroundFromProps, DefaultZIndexes.barBackground)
}, data.map((entry, i) => {
var {
value,
background: backgroundFromDataEntry,
tooltipPosition
} = entry,
rest = _objectWithoutProperties(entry, _excluded2);
if (!backgroundFromDataEntry) {
return null;
}
// @ts-expect-error BarRectangleItem type definition says it's missing properties, but I can see them present in debugger!
var onMouseEnter = onMouseEnterFromContext(entry, i);
// @ts-expect-error BarRectangleItem type definition says it's missing properties, but I can see them present in debugger!
var onMouseLeave = onMouseLeaveFromContext(entry, i);
// @ts-expect-error BarRectangleItem type definition says it's missing properties, but I can see them present in debugger!
var onClick = onClickFromContext(entry, i);
var barRectangleProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
option: backgroundFromProps,
isActive: String(i) === activeIndex
}, rest), {}, {
// @ts-expect-error backgroundProps is contributing unknown props
fill: '#eee'
}, backgroundFromDataEntry), backgroundProps), adaptEventsOfChild(restOfAllOtherProps, entry, i)), {}, {
onMouseEnter,
onMouseLeave,
onClick,
dataKey,
index: i,
className: 'recharts-bar-background-rectangle'
});
return /*#__PURE__*/React.createElement(BarRectangle, _extends({
key: "background-bar-".concat(i)
}, barRectangleProps));
}));
}
function BarLabelListProvider(_ref) {
var {
showLabels,
children,
rects
} = _ref;
var labelListEntries = rects === null || rects === void 0 ? void 0 : rects.map(entry => {
var viewBox = {
x: entry.x,
y: entry.y,
width: entry.width,
lowerWidth: entry.width,
upperWidth: entry.width,
height: entry.height
};
return _objectSpread(_objectSpread({}, viewBox), {}, {
value: entry.value,
payload: entry.payload,
parentViewBox: entry.parentViewBox,
viewBox,
fill: entry.fill
});
});
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function BarRectangleWithActiveState(props) {
var {
shape,
activeBar,
baseProps,
entry,
index,
dataKey
} = props;
var activeIndex = useAppSelector(selectActiveTooltipIndex);
var activeDataKey = useAppSelector(selectActiveTooltipDataKey);
/*
* Bars support stacking, meaning that there can be multiple bars at the same x value.
* With Tooltip shared=false we only want to highlight the currently active Bar, not all.
*
* Also, if the tooltip is shared, we want to highlight all bars at the same x value
* regardless of the dataKey.
*
* With shared Tooltip, the activeDataKey is undefined.
*/
var isActive = activeBar && String(index) === activeIndex && (activeDataKey == null || dataKey === activeDataKey);
var option = isActive ? activeBar : shape;
if (isActive) {
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: DefaultZIndexes.activeBar
}, /*#__PURE__*/React.createElement(BarRectangle, _extends({}, baseProps, {
name: String(baseProps.name)
}, entry, {
isActive: isActive,
option: option,
index: index,
dataKey: dataKey
})));
}
return /*#__PURE__*/React.createElement(BarRectangle, _extends({}, baseProps, {
name: String(baseProps.name)
}, entry, {
isActive: isActive,
option: option,
index: index,
dataKey: dataKey
}));
}
function BarRectangleNeverActive(props) {
var {
shape,
baseProps,
entry,
index,
dataKey
} = props;
return /*#__PURE__*/React.createElement(BarRectangle, _extends({}, baseProps, {
name: String(baseProps.name)
}, entry, {
isActive: false,
option: shape,
index: index,
dataKey: dataKey
}));
}
function BarRectangles(_ref2) {
var _svgPropertiesNoEvent;
var {
data,
props
} = _ref2;
var _ref3 = (_svgPropertiesNoEvent = svgPropertiesNoEvents(props)) !== null && _svgPropertiesNoEvent !== void 0 ? _svgPropertiesNoEvent : {},
{
id
} = _ref3,
baseProps = _objectWithoutProperties(_ref3, _excluded3);
var {
shape,
dataKey,
activeBar
} = props;
var {
onMouseEnter: onMouseEnterFromProps,
onClick: onItemClickFromProps,
onMouseLeave: onMouseLeaveFromProps
} = props,
restOfAllOtherProps = _objectWithoutProperties(props, _excluded4);
// @ts-expect-error bar mouse events are not compatible with recharts mouse events
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, dataKey);
// @ts-expect-error bar mouse events are not compatible with recharts mouse events
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
// @ts-expect-error bar mouse events are not compatible with recharts mouse events
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, dataKey);
if (!data) {
return null;
}
return /*#__PURE__*/React.createElement(React.Fragment, null, data.map((entry, i) => {
return /*#__PURE__*/React.createElement(Layer
// https://github.com/recharts/recharts/issues/5415
, _extends({
key: "rectangle-".concat(entry === null || entry === void 0 ? void 0 : entry.x, "-").concat(entry === null || entry === void 0 ? void 0 : entry.y, "-").concat(entry === null || entry === void 0 ? void 0 : entry.value, "-").concat(i),
className: "recharts-bar-rectangle"
}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
// @ts-expect-error BarRectangleItem type definition says it's missing properties, but I can see them present in debugger!
onMouseEnter: onMouseEnterFromContext(entry, i)
// @ts-expect-error BarRectangleItem type definition says it's missing properties, but I can see them present in debugger!
,
onMouseLeave: onMouseLeaveFromContext(entry, i)
// @ts-expect-error BarRectangleItem type definition says it's missing properties, but I can see them present in debugger!
,
onClick: onClickFromContext(entry, i)
}), activeBar ? /*#__PURE__*/React.createElement(BarRectangleWithActiveState, {
shape: shape,
activeBar: activeBar,
baseProps: baseProps,
entry: entry,
index: i,
dataKey: dataKey
}) :
/*#__PURE__*/
/*
* If the `activeBar` prop is falsy, then let's call the variant without hooks.
* Using the `selectActiveTooltipIndex` selector is usually fast
* but in charts with large-ish amount of data even the few nanoseconds add up to a noticeable jank.
* If the activeBar is false then we don't need to know which index is active - because we won't use it anyway.
* So let's just skip the hooks altogether. That way, React can skip rendering the component,
* and can skip the tree reconciliation for its children too.
* Because we can't call hooks conditionally, we need to have a separate component for that.
*/
React.createElement(BarRectangleNeverActive, {
shape: shape,
baseProps: baseProps,
entry: entry,
index: i,
dataKey: dataKey
}));
}));
}
function RectanglesWithAnimation(_ref4) {
var {
props,
previousRectanglesRef
} = _ref4;
var {
data,
layout,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
onAnimationEnd,
onAnimationStart
} = props;
var prevData = previousRectanglesRef.current;
var animationId = useAnimationId(props, 'recharts-bar-');
var [isAnimating, setIsAnimating] = useState(false);
var showLabels = !isAnimating;
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
return /*#__PURE__*/React.createElement(BarLabelListProvider, {
showLabels: showLabels,
rects: data
}, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
onAnimationEnd: handleAnimationEnd,
onAnimationStart: handleAnimationStart,
key: animationId
}, t => {
var stepData = t === 1 ? data : data === null || data === void 0 ? void 0 : data.map((entry, index) => {
var prev = prevData && prevData[index];
if (prev) {
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(prev.x, entry.x, t),
y: interpolate(prev.y, entry.y, t),
width: interpolate(prev.width, entry.width, t),
height: interpolate(prev.height, entry.height, t)
});
}
if (layout === 'horizontal') {
var height = interpolate(0, entry.height, t);
var y = interpolate(entry.stackedBarStart, entry.y, t);
return _objectSpread(_objectSpread({}, entry), {}, {
y,
height
});
}
var w = interpolate(0, entry.width, t);
var x = interpolate(entry.stackedBarStart, entry.x, t);
return _objectSpread(_objectSpread({}, entry), {}, {
width: w,
x
});
});
if (t > 0) {
// eslint-disable-next-line no-param-reassign
previousRectanglesRef.current = stepData !== null && stepData !== void 0 ? stepData : null;
}
if (stepData == null) {
return null;
}
return /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement(BarRectangles, {
props: props,
data: stepData
}));
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}), props.children);
}
function RenderRectangles(props) {
var previousRectanglesRef = useRef(null);
return /*#__PURE__*/React.createElement(RectanglesWithAnimation, {
previousRectanglesRef: previousRectanglesRef,
props: props
});
}
var defaultMinPointSize = 0;
var errorBarDataPointFormatter = (dataPoint, dataKey) => {
/**
* if the value coming from `selectBarRectangles` is an array then this is a stacked bar chart.
* arr[1] represents end value of the bar since the data is in the form of [startValue, endValue].
* */
var value = Array.isArray(dataPoint.value) ? dataPoint.value[1] : dataPoint.value;
return {
x: dataPoint.x,
y: dataPoint.y,
value,
// @ts-expect-error getValueByDataKey does not validate the output type
errorVal: getValueByDataKey(dataPoint, dataKey)
};
};
class BarWithState extends PureComponent {
render() {
var {
hide,
data,
dataKey,
className,
xAxisId,
yAxisId,
needClip,
background,
id
} = this.props;
if (hide || data == null) {
return null;
}
var layerClass = clsx('recharts-bar', className);
var clipPathId = id;
return /*#__PURE__*/React.createElement(Layer, {
className: layerClass,
id: id
}, needClip && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement(GraphicalItemClipPath, {
clipPathId: clipPathId,
xAxisId: xAxisId,
yAxisId: yAxisId
})), /*#__PURE__*/React.createElement(Layer, {
className: "recharts-bar-rectangles",
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined
}, /*#__PURE__*/React.createElement(BarBackground, {
data: data,
dataKey: dataKey,
background: background,
allOtherBarProps: this.props
}), /*#__PURE__*/React.createElement(RenderRectangles, this.props)));
}
}
var defaultBarProps = {
activeBar: false,
animationBegin: 0,
animationDuration: 400,
animationEasing: 'ease',
hide: false,
isAnimationActive: !Global.isSsr,
legendType: 'rect',
minPointSize: defaultMinPointSize,
xAxisId: 0,
yAxisId: 0,
zIndex: DefaultZIndexes.bar
};
function BarImpl(props) {
var {
xAxisId,
yAxisId,
hide,
legendType,
minPointSize,
activeBar,
animationBegin,
animationDuration,
animationEasing,
isAnimationActive
} = props;
var {
needClip
} = useNeedsClip(xAxisId, yAxisId);
var layout = useChartLayout();
var isPanorama = useIsPanorama();
var cells = findAllByType(props.children, Cell);
var rects = useAppSelector(state => selectBarRectangles(state, xAxisId, yAxisId, isPanorama, props.id, cells));
if (layout !== 'vertical' && layout !== 'horizontal') {
return null;
}
var errorBarOffset;
var firstDataPoint = rects === null || rects === void 0 ? void 0 : rects[0];
if (firstDataPoint == null || firstDataPoint.height == null || firstDataPoint.width == null) {
errorBarOffset = 0;
} else {
errorBarOffset = layout === 'vertical' ? firstDataPoint.height / 2 : firstDataPoint.width / 2;
}
return /*#__PURE__*/React.createElement(SetErrorBarContext, {
xAxisId: xAxisId,
yAxisId: yAxisId,
data: rects,
dataPointFormatter: errorBarDataPointFormatter,
errorBarOffset: errorBarOffset
}, /*#__PURE__*/React.createElement(BarWithState, _extends({}, props, {
layout: layout,
needClip: needClip,
data: rects,
xAxisId: xAxisId,
yAxisId: yAxisId,
hide: hide,
legendType: legendType,
minPointSize: minPointSize,
activeBar: activeBar,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
isAnimationActive: isAnimationActive
})));
}
export function computeBarRectangles(_ref5) {
var {
layout,
barSettings: {
dataKey,
minPointSize: minPointSizeProp
},
pos,
bandSize,
xAxis,
yAxis,
xAxisTicks,
yAxisTicks,
stackedData,
displayedData,
offset,
cells,
parentViewBox,
dataStartIndex
} = _ref5;
var numericAxis = layout === 'horizontal' ? yAxis : xAxis;
// @ts-expect-error this assumes that the domain is always numeric, but doesn't check for it
var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
var baseValue = getBaseValueOfBar({
numericAxis
});
var stackedBarStart = numericAxis.scale(baseValue);
return displayedData.map((entry, index) => {
var value, x, y, width, height, background;
if (stackedData) {
// Use dataStartIndex to access the correct element in the full stackedData array
value = truncateByDomain(stackedData[index + dataStartIndex], stackedDomain);
} else {
value = getValueByDataKey(entry, dataKey);
if (!Array.isArray(value)) {
value = [baseValue, value];
}
}
var minPointSize = minPointSizeCallback(minPointSizeProp, defaultMinPointSize)(value[1], index);
if (layout === 'horizontal') {
var _ref6;
var [baseValueScale, currentValueScale] = [yAxis.scale(value[0]), yAxis.scale(value[1])];
x = getCateCoordinateOfBar({
axis: xAxis,
ticks: xAxisTicks,
bandSize,
offset: pos.offset,
entry,
index
});
y = (_ref6 = currentValueScale !== null && currentValueScale !== void 0 ? currentValueScale : baseValueScale) !== null && _ref6 !== void 0 ? _ref6 : undefined;
width = pos.size;
var computedHeight = baseValueScale - currentValueScale;
height = isNan(computedHeight) ? 0 : computedHeight;
background = {
x,
y: offset.top,
width,
height: offset.height
};
if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
var delta = mathSign(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
y -= delta;
height += delta;
}
} else {
var [_baseValueScale, _currentValueScale] = [xAxis.scale(value[0]), xAxis.scale(value[1])];
x = _baseValueScale;
y = getCateCoordinateOfBar({
axis: yAxis,
ticks: yAxisTicks,
bandSize,
offset: pos.offset,
entry,
index
});
width = _currentValueScale - _baseValueScale;
height = pos.size;
background = {
x: offset.left,
y,
width: offset.width,
height
};
if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
var _delta = mathSign(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
width += _delta;
}
}
if (x == null || y == null || width == null || height == null) {
return null;
}
var barRectangleItem = _objectSpread(_objectSpread({}, entry), {}, {
stackedBarStart,
x,
y,
width,
height,
value: stackedData ? value : value[1],
payload: entry,
background,
tooltipPosition: {
x: x + width / 2,
y: y + height / 2
},
parentViewBox
}, cells && cells[index] && cells[index].props);
return barRectangleItem;
}).filter(Boolean);
}
function BarFn(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultBarProps);
var isPanorama = useIsPanorama();
// Report all props to Redux store first, before calling any hooks, to avoid circular dependencies.
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "bar"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetLegendPayload, {
legendPayload: computeLegendPayloadFromBarData(props)
}), /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: props
}), /*#__PURE__*/React.createElement(SetCartesianGraphicalItem, {
type: "bar",
id: id
// Bar does not allow setting data directly on the graphical item (why?)
,
data: undefined,
xAxisId: props.xAxisId,
yAxisId: props.yAxisId,
zAxisId: 0,
dataKey: props.dataKey,
stackId: getNormalizedStackId(props.stackId),
hide: props.hide,
barSize: props.barSize,
minPointSize: props.minPointSize,
maxBarSize: props.maxBarSize,
isPanorama: isPanorama
}), /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(BarImpl, _extends({}, props, {
id: id
})))));
}
export var Bar = /*#__PURE__*/React.memo(BarFn);
Bar.displayName = 'Bar';

865
frontend/node_modules/recharts/es6/cartesian/Brush.js generated vendored Normal file
View File

@@ -0,0 +1,865 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { Children, PureComponent, useCallback, useContext, useEffect } from 'react';
import { clsx } from 'clsx';
import { scalePoint } from 'victory-vendor/d3-scale';
import range from 'es-toolkit/compat/range';
import { Layer } from '../container/Layer';
import { Text } from '../component/Text';
import { getValueByDataKey } from '../util/ChartUtils';
import { isNumber, isNotNil } from '../util/DataUtils';
import { generatePrefixStyle } from '../util/CssPrefixUtils';
import { useChartData, useDataIndex } from '../context/chartDataContext';
import { BrushUpdateDispatchContext } from '../context/brushUpdateContext';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { setDataStartEndIndexes } from '../state/chartDataSlice';
import { setBrushSettings } from '../state/brushSlice';
import { PanoramaContextProvider } from '../context/PanoramaContext';
import { selectBrushDimensions } from '../state/selectors/brushSelectors';
import { useBrushChartSynchronisation } from '../synchronisation/useChartSynchronisation';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
// Why is this tickFormatter different from the other TickFormatters? This one allows to return numbers too for some reason.
function DefaultTraveller(props) {
var {
x,
y,
width,
height,
stroke
} = props;
var lineY = Math.floor(y + height / 2) - 1;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("rect", {
x: x,
y: y,
width: width,
height: height,
fill: stroke,
stroke: "none"
}), /*#__PURE__*/React.createElement("line", {
x1: x + 1,
y1: lineY,
x2: x + width - 1,
y2: lineY,
fill: "none",
stroke: "#fff"
}), /*#__PURE__*/React.createElement("line", {
x1: x + 1,
y1: lineY + 2,
x2: x + width - 1,
y2: lineY + 2,
fill: "none",
stroke: "#fff"
}));
}
function Traveller(props) {
var {
travellerProps,
travellerType
} = props;
if (/*#__PURE__*/React.isValidElement(travellerType)) {
// @ts-expect-error element cloning disagrees with the types (and it should)
return /*#__PURE__*/React.cloneElement(travellerType, travellerProps);
}
if (typeof travellerType === 'function') {
return travellerType(travellerProps);
}
return /*#__PURE__*/React.createElement(DefaultTraveller, travellerProps);
}
function TravellerLayer(_ref) {
var _data$startIndex, _data$endIndex;
var {
otherProps,
travellerX,
id,
onMouseEnter,
onMouseLeave,
onMouseDown,
onTouchStart,
onTravellerMoveKeyboard,
onFocus,
onBlur
} = _ref;
var {
y,
x: xFromProps,
travellerWidth,
height,
traveller,
ariaLabel,
data,
startIndex,
endIndex
} = otherProps;
var x = Math.max(travellerX, xFromProps);
var travellerProps = _objectSpread(_objectSpread({}, svgPropertiesNoEvents(otherProps)), {}, {
x,
y,
width: travellerWidth,
height
});
var ariaLabelBrush = ariaLabel || "Min value: ".concat((_data$startIndex = data[startIndex]) === null || _data$startIndex === void 0 ? void 0 : _data$startIndex.name, ", Max value: ").concat((_data$endIndex = data[endIndex]) === null || _data$endIndex === void 0 ? void 0 : _data$endIndex.name);
return /*#__PURE__*/React.createElement(Layer, {
tabIndex: 0,
role: "slider",
"aria-label": ariaLabelBrush,
"aria-valuenow": travellerX,
className: "recharts-brush-traveller",
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onMouseDown: onMouseDown,
onTouchStart: onTouchStart,
onKeyDown: e => {
if (!['ArrowLeft', 'ArrowRight'].includes(e.key)) {
return;
}
e.preventDefault();
e.stopPropagation();
onTravellerMoveKeyboard(e.key === 'ArrowRight' ? 1 : -1, id);
},
onFocus: onFocus,
onBlur: onBlur,
style: {
cursor: 'col-resize'
}
}, /*#__PURE__*/React.createElement(Traveller, {
travellerType: traveller,
travellerProps: travellerProps
}));
}
/*
* This one cannot be a React Component because React is not happy with it returning only string | number.
* React wants a full React.JSX.Element but that is not compatible with Text component.
*/
function getTextOfTick(props) {
var {
index,
data,
tickFormatter,
dataKey
} = props;
// @ts-expect-error getValueByDataKey does not validate the output type
var text = getValueByDataKey(data[index], dataKey, index);
return typeof tickFormatter === 'function' ? tickFormatter(text, index) : text;
}
function getIndexInRange(valueRange, x) {
var len = valueRange.length;
var start = 0;
var end = len - 1;
while (end - start > 1) {
var middle = Math.floor((start + end) / 2);
if (valueRange[middle] > x) {
end = middle;
} else {
start = middle;
}
}
return x >= valueRange[end] ? end : start;
}
function getIndex(_ref2) {
var {
startX,
endX,
scaleValues,
gap,
data
} = _ref2;
var lastIndex = data.length - 1;
var min = Math.min(startX, endX);
var max = Math.max(startX, endX);
var minIndex = getIndexInRange(scaleValues, min);
var maxIndex = getIndexInRange(scaleValues, max);
return {
startIndex: minIndex - minIndex % gap,
endIndex: maxIndex === lastIndex ? lastIndex : maxIndex - maxIndex % gap
};
}
function Background(_ref3) {
var {
x,
y,
width,
height,
fill,
stroke
} = _ref3;
return /*#__PURE__*/React.createElement("rect", {
stroke: stroke,
fill: fill,
x: x,
y: y,
width: width,
height: height
});
}
function BrushText(_ref4) {
var {
startIndex,
endIndex,
y,
height,
travellerWidth,
stroke,
tickFormatter,
dataKey,
data,
startX,
endX
} = _ref4;
var offset = 5;
var attrs = {
pointerEvents: 'none',
fill: stroke
};
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-brush-texts"
}, /*#__PURE__*/React.createElement(Text, _extends({
textAnchor: "end",
verticalAnchor: "middle",
x: Math.min(startX, endX) - offset,
y: y + height / 2
}, attrs), getTextOfTick({
index: startIndex,
tickFormatter,
dataKey,
data
})), /*#__PURE__*/React.createElement(Text, _extends({
textAnchor: "start",
verticalAnchor: "middle",
x: Math.max(startX, endX) + travellerWidth + offset,
y: y + height / 2
}, attrs), getTextOfTick({
index: endIndex,
tickFormatter,
dataKey,
data
})));
}
function Slide(_ref5) {
var {
y,
height,
stroke,
travellerWidth,
startX,
endX,
onMouseEnter,
onMouseLeave,
onMouseDown,
onTouchStart
} = _ref5;
var x = Math.min(startX, endX) + travellerWidth;
var width = Math.max(Math.abs(endX - startX) - travellerWidth, 0);
return /*#__PURE__*/React.createElement("rect", {
className: "recharts-brush-slide",
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onMouseDown: onMouseDown,
onTouchStart: onTouchStart,
style: {
cursor: 'move'
},
stroke: "none",
fill: stroke,
fillOpacity: 0.2,
x: x,
y: y,
width: width,
height: height
});
}
function Panorama(_ref6) {
var {
x,
y,
width,
height,
data,
children,
padding
} = _ref6;
var isPanoramic = React.Children.count(children) === 1;
if (!isPanoramic) {
return null;
}
var chartElement = Children.only(children);
if (!chartElement) {
return null;
}
return /*#__PURE__*/React.cloneElement(chartElement, {
x,
y,
width,
height,
margin: padding,
compact: true,
data
});
}
var createScale = _ref7 => {
var {
data,
startIndex,
endIndex,
x,
width,
travellerWidth
} = _ref7;
if (!data || !data.length) {
return {};
}
var len = data.length;
var scale = scalePoint().domain(range(0, len)).range([x, x + width - travellerWidth]);
var scaleValues = scale.domain().map(entry => scale(entry)).filter(isNotNil);
return {
isTextActive: false,
isSlideMoving: false,
isTravellerMoving: false,
isTravellerFocused: false,
startX: scale(startIndex),
endX: scale(endIndex),
scale,
scaleValues
};
};
var isTouch = e => e.changedTouches && !!e.changedTouches.length;
class BrushWithState extends PureComponent {
constructor(props) {
super(props);
_defineProperty(this, "handleDrag", e => {
if (this.leaveTimer) {
clearTimeout(this.leaveTimer);
this.leaveTimer = null;
}
if (this.state.isTravellerMoving) {
this.handleTravellerMove(e);
} else if (this.state.isSlideMoving) {
this.handleSlideDrag(e);
}
});
_defineProperty(this, "handleTouchMove", e => {
if (e.changedTouches != null && e.changedTouches.length > 0) {
this.handleDrag(e.changedTouches[0]);
}
});
_defineProperty(this, "handleDragEnd", () => {
this.setState({
isTravellerMoving: false,
isSlideMoving: false
}, () => {
var {
endIndex,
onDragEnd,
startIndex
} = this.props;
onDragEnd === null || onDragEnd === void 0 || onDragEnd({
endIndex,
startIndex
});
});
this.detachDragEndListener();
});
_defineProperty(this, "handleLeaveWrapper", () => {
if (this.state.isTravellerMoving || this.state.isSlideMoving) {
this.leaveTimer = window.setTimeout(this.handleDragEnd, this.props.leaveTimeOut);
}
});
_defineProperty(this, "handleEnterSlideOrTraveller", () => {
this.setState({
isTextActive: true
});
});
_defineProperty(this, "handleLeaveSlideOrTraveller", () => {
this.setState({
isTextActive: false
});
});
_defineProperty(this, "handleSlideDragStart", e => {
var event = isTouch(e) ? e.changedTouches[0] : e;
this.setState({
isTravellerMoving: false,
isSlideMoving: true,
slideMoveStartX: event.pageX
});
this.attachDragEndListener();
});
_defineProperty(this, "handleTravellerMoveKeyboard", (direction, id) => {
var {
data,
gap,
startIndex,
endIndex
} = this.props;
// scaleValues are a list of coordinates. For example: [65, 250, 435, 620, 805, 990].
var {
scaleValues,
startX,
endX
} = this.state;
if (scaleValues == null) {
return;
}
// unless we search for the closest scaleValue to the current coordinate
// we need to move travelers via index when using the keyboard
var currentIndex = -1;
if (id === 'startX') {
currentIndex = startIndex;
} else if (id === 'endX') {
currentIndex = endIndex;
}
if (currentIndex < 0 || currentIndex >= data.length) {
return;
}
var newIndex = currentIndex + direction;
if (newIndex === -1 || newIndex >= scaleValues.length) {
return;
}
var newScaleValue = scaleValues[newIndex];
// Prevent travellers from being on top of each other or overlapping
if (id === 'startX' && newScaleValue >= endX || id === 'endX' && newScaleValue <= startX) {
return;
}
this.setState(
// @ts-expect-error not sure why typescript is not happy with this, partial update is fine in React
{
[id]: newScaleValue
}, () => {
this.props.onChange(getIndex({
startX: this.state.startX,
endX: this.state.endX,
data,
gap,
scaleValues
}));
});
});
this.travellerDragStartHandlers = {
startX: this.handleTravellerDragStart.bind(this, 'startX'),
endX: this.handleTravellerDragStart.bind(this, 'endX')
};
this.state = {
brushMoveStartX: 0,
movingTravellerId: undefined,
endX: 0,
startX: 0,
slideMoveStartX: 0
};
}
static getDerivedStateFromProps(nextProps, prevState) {
var {
data,
width,
x,
travellerWidth,
startIndex,
endIndex,
startIndexControlledFromProps,
endIndexControlledFromProps
} = nextProps;
if (data !== prevState.prevData) {
return _objectSpread({
prevData: data,
prevTravellerWidth: travellerWidth,
prevX: x,
prevWidth: width
}, data && data.length ? createScale({
data,
width,
x,
travellerWidth,
startIndex,
endIndex
}) : {
scale: undefined,
scaleValues: undefined
});
}
var prevScale = prevState.scale;
if (prevScale && (width !== prevState.prevWidth || x !== prevState.prevX || travellerWidth !== prevState.prevTravellerWidth)) {
prevScale.range([x, x + width - travellerWidth]);
var scaleValues = prevScale.domain().map(entry => prevScale(entry)).filter(value => value != null);
return {
prevData: data,
prevTravellerWidth: travellerWidth,
prevX: x,
prevWidth: width,
startX: prevScale(nextProps.startIndex),
endX: prevScale(nextProps.endIndex),
scaleValues
};
}
if (prevState.scale && !prevState.isSlideMoving && !prevState.isTravellerMoving && !prevState.isTravellerFocused && !prevState.isTextActive) {
/*
* If the startIndex or endIndex are controlled from the outside,
* we need to keep the startX and end up to date.
* Also we do not want to do that while user is interacting in the brush,
* because this will trigger re-render and interrupt the drag&drop.
*/
if (startIndexControlledFromProps != null && prevState.prevStartIndexControlledFromProps !== startIndexControlledFromProps) {
return {
startX: prevState.scale(startIndexControlledFromProps),
prevStartIndexControlledFromProps: startIndexControlledFromProps
};
}
if (endIndexControlledFromProps != null && prevState.prevEndIndexControlledFromProps !== endIndexControlledFromProps) {
return {
endX: prevState.scale(endIndexControlledFromProps),
prevEndIndexControlledFromProps: endIndexControlledFromProps
};
}
}
return null;
}
componentWillUnmount() {
if (this.leaveTimer) {
clearTimeout(this.leaveTimer);
this.leaveTimer = null;
}
this.detachDragEndListener();
}
attachDragEndListener() {
window.addEventListener('mouseup', this.handleDragEnd, true);
window.addEventListener('touchend', this.handleDragEnd, true);
window.addEventListener('mousemove', this.handleDrag, true);
}
detachDragEndListener() {
window.removeEventListener('mouseup', this.handleDragEnd, true);
window.removeEventListener('touchend', this.handleDragEnd, true);
window.removeEventListener('mousemove', this.handleDrag, true);
}
handleSlideDrag(e) {
var {
slideMoveStartX,
startX,
endX,
scaleValues
} = this.state;
if (scaleValues == null) {
return;
}
var {
x,
width,
travellerWidth,
startIndex,
endIndex,
onChange,
data,
gap
} = this.props;
var delta = e.pageX - slideMoveStartX;
if (delta > 0) {
delta = Math.min(delta, x + width - travellerWidth - endX, x + width - travellerWidth - startX);
} else if (delta < 0) {
delta = Math.max(delta, x - startX, x - endX);
}
var newIndex = getIndex({
startX: startX + delta,
endX: endX + delta,
data,
gap,
scaleValues
});
if ((newIndex.startIndex !== startIndex || newIndex.endIndex !== endIndex) && onChange) {
onChange(newIndex);
}
this.setState({
startX: startX + delta,
endX: endX + delta,
slideMoveStartX: e.pageX
});
}
handleTravellerDragStart(id, e) {
var event = isTouch(e) ? e.changedTouches[0] : e;
this.setState({
isSlideMoving: false,
isTravellerMoving: true,
movingTravellerId: id,
brushMoveStartX: event.pageX
});
this.attachDragEndListener();
}
handleTravellerMove(e) {
var {
brushMoveStartX,
movingTravellerId,
endX,
startX,
scaleValues
} = this.state;
if (movingTravellerId == null || scaleValues == null) {
return;
}
var prevValue = this.state[movingTravellerId];
var {
x,
width,
travellerWidth,
onChange,
gap,
data
} = this.props;
var params = {
startX: this.state.startX,
endX: this.state.endX,
data,
gap,
scaleValues
};
var delta = e.pageX - brushMoveStartX;
if (delta > 0) {
delta = Math.min(delta, x + width - travellerWidth - prevValue);
} else if (delta < 0) {
delta = Math.max(delta, x - prevValue);
}
params[movingTravellerId] = prevValue + delta;
var newIndex = getIndex(params);
var {
startIndex,
endIndex
} = newIndex;
var isFullGap = () => {
var lastIndex = data.length - 1;
if (movingTravellerId === 'startX' && (endX > startX ? startIndex % gap === 0 : endIndex % gap === 0) || endX < startX && endIndex === lastIndex || movingTravellerId === 'endX' && (endX > startX ? endIndex % gap === 0 : startIndex % gap === 0) || endX > startX && endIndex === lastIndex) {
return true;
}
return false;
};
this.setState(
// @ts-expect-error not sure why typescript is not happy with this, partial update is fine in React
{
[movingTravellerId]: prevValue + delta,
brushMoveStartX: e.pageX
}, () => {
if (onChange) {
if (isFullGap()) {
onChange(newIndex);
}
}
});
}
render() {
var {
data,
className,
children,
x,
y,
dy,
width,
height,
alwaysShowText,
fill,
stroke,
startIndex,
endIndex,
travellerWidth,
tickFormatter,
dataKey,
padding
} = this.props;
var {
startX,
endX,
isTextActive,
isSlideMoving,
isTravellerMoving,
isTravellerFocused
} = this.state;
if (!data || !data.length || !isNumber(x) || !isNumber(y) || !isNumber(width) || !isNumber(height) || width <= 0 || height <= 0) {
return null;
}
var layerClass = clsx('recharts-brush', className);
var style = generatePrefixStyle('userSelect', 'none');
var calculatedY = y + (dy !== null && dy !== void 0 ? dy : 0);
return /*#__PURE__*/React.createElement(Layer, {
className: layerClass,
onMouseLeave: this.handleLeaveWrapper,
onTouchMove: this.handleTouchMove,
style: style
}, /*#__PURE__*/React.createElement(Background, {
x: x,
y: calculatedY,
width: width,
height: height,
fill: fill,
stroke: stroke
}), /*#__PURE__*/React.createElement(PanoramaContextProvider, null, /*#__PURE__*/React.createElement(Panorama, {
x: x,
y: calculatedY,
width: width,
height: height,
data: data,
padding: padding
}, children)), /*#__PURE__*/React.createElement(Slide, {
y: calculatedY,
height: height,
stroke: stroke,
travellerWidth: travellerWidth,
startX: startX,
endX: endX,
onMouseEnter: this.handleEnterSlideOrTraveller,
onMouseLeave: this.handleLeaveSlideOrTraveller,
onMouseDown: this.handleSlideDragStart,
onTouchStart: this.handleSlideDragStart
}), /*#__PURE__*/React.createElement(TravellerLayer, {
travellerX: startX,
id: "startX",
otherProps: _objectSpread(_objectSpread({}, this.props), {}, {
y: calculatedY
}),
onMouseEnter: this.handleEnterSlideOrTraveller,
onMouseLeave: this.handleLeaveSlideOrTraveller,
onMouseDown: this.travellerDragStartHandlers.startX,
onTouchStart: this.travellerDragStartHandlers.startX,
onTravellerMoveKeyboard: this.handleTravellerMoveKeyboard,
onFocus: () => {
this.setState({
isTravellerFocused: true
});
},
onBlur: () => {
this.setState({
isTravellerFocused: false
});
}
}), /*#__PURE__*/React.createElement(TravellerLayer, {
travellerX: endX,
id: "endX",
otherProps: _objectSpread(_objectSpread({}, this.props), {}, {
y: calculatedY
}),
onMouseEnter: this.handleEnterSlideOrTraveller,
onMouseLeave: this.handleLeaveSlideOrTraveller,
onMouseDown: this.travellerDragStartHandlers.endX,
onTouchStart: this.travellerDragStartHandlers.endX,
onTravellerMoveKeyboard: this.handleTravellerMoveKeyboard,
onFocus: () => {
this.setState({
isTravellerFocused: true
});
},
onBlur: () => {
this.setState({
isTravellerFocused: false
});
}
}), (isTextActive || isSlideMoving || isTravellerMoving || isTravellerFocused || alwaysShowText) && /*#__PURE__*/React.createElement(BrushText, {
startIndex: startIndex,
endIndex: endIndex,
y: calculatedY,
height: height,
travellerWidth: travellerWidth,
stroke: stroke,
tickFormatter: tickFormatter,
dataKey: dataKey,
data: data,
startX: startX,
endX: endX
}));
}
}
function BrushInternal(props) {
var dispatch = useAppDispatch();
var chartData = useChartData();
var dataIndexes = useDataIndex();
var onChangeFromContext = useContext(BrushUpdateDispatchContext);
var onChangeFromProps = props.onChange;
var {
startIndex: startIndexFromProps,
endIndex: endIndexFromProps
} = props;
useEffect(() => {
// start and end index can be controlled from props, and we need them to stay up-to-date in the Redux state too
dispatch(setDataStartEndIndexes({
startIndex: startIndexFromProps,
endIndex: endIndexFromProps
}));
}, [dispatch, endIndexFromProps, startIndexFromProps]);
useBrushChartSynchronisation();
var onChange = useCallback(nextState => {
if (dataIndexes == null) {
return;
}
var {
startIndex,
endIndex
} = dataIndexes;
if (nextState.startIndex !== startIndex || nextState.endIndex !== endIndex) {
onChangeFromContext === null || onChangeFromContext === void 0 || onChangeFromContext(nextState);
onChangeFromProps === null || onChangeFromProps === void 0 || onChangeFromProps(nextState);
dispatch(setDataStartEndIndexes(nextState));
}
}, [onChangeFromProps, onChangeFromContext, dispatch, dataIndexes]);
var brushDimensions = useAppSelector(selectBrushDimensions);
if (brushDimensions == null || dataIndexes == null || chartData == null || !chartData.length) {
return null;
}
var {
startIndex,
endIndex
} = dataIndexes;
var {
x,
y,
width
} = brushDimensions;
var contextProperties = {
data: chartData,
x,
y,
width,
startIndex,
endIndex,
onChange
};
return /*#__PURE__*/React.createElement(BrushWithState, _extends({}, props, contextProperties, {
startIndexControlledFromProps: startIndexFromProps !== null && startIndexFromProps !== void 0 ? startIndexFromProps : undefined,
endIndexControlledFromProps: endIndexFromProps !== null && endIndexFromProps !== void 0 ? endIndexFromProps : undefined
}));
}
function BrushSettingsDispatcher(props) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setBrushSettings(props));
return () => {
dispatch(setBrushSettings(null));
};
}, [dispatch, props]);
return null;
}
var defaultBrushProps = {
height: 40,
travellerWidth: 5,
gap: 1,
fill: '#fff',
stroke: '#666',
padding: {
top: 1,
right: 1,
bottom: 1,
left: 1
},
leaveTimeOut: 1000,
alwaysShowText: false
};
export function Brush(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultBrushProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BrushSettingsDispatcher, {
height: props.height,
x: props.x,
y: props.y,
width: props.width,
padding: props.padding
}), /*#__PURE__*/React.createElement(BrushInternal, props));
}
Brush.displayName = 'Brush';

View File

@@ -0,0 +1,447 @@
var _excluded = ["axisLine", "width", "height", "className", "hide", "ticks", "axisType"],
_excluded2 = ["viewBox"],
_excluded3 = ["viewBox"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* @fileOverview Cartesian Axis
*/
import * as React from 'react';
import { useState, useRef, useCallback, forwardRef, useImperativeHandle } from 'react';
import get from 'es-toolkit/compat/get';
import { clsx } from 'clsx';
import { shallowEqual } from '../util/ShallowEqual';
import { Layer } from '../container/Layer';
import { Text } from '../component/Text';
import { CartesianLabelContextProvider, CartesianLabelFromLabelProp } from '../component/Label';
import { isNumber } from '../util/DataUtils';
import { adaptEventsOfChild } from '../util/types';
import { getTicks } from './getTicks';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { getCalculatedYAxisWidth } from '../util/YAxisUtils';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/** The orientation of the axis in correspondence to the chart */
/** A unit to be appended to a value */
/** The formatter function of tick */
export var defaultCartesianAxisProps = {
x: 0,
y: 0,
width: 0,
height: 0,
viewBox: {
x: 0,
y: 0,
width: 0,
height: 0
},
// The orientation of axis
orientation: 'bottom',
// The ticks
ticks: [],
stroke: '#666',
tickLine: true,
axisLine: true,
tick: true,
mirror: false,
minTickGap: 5,
// The width or height of tick
tickSize: 6,
tickMargin: 2,
interval: 'preserveEnd',
zIndex: DefaultZIndexes.axis
};
/*
* `viewBox` and `scale` are SVG attributes.
* Recharts however - unfortunately - has its own attributes named `viewBox` and `scale`
* that are completely different data shape and different purpose.
*/
function AxisLine(axisLineProps) {
var {
x,
y,
width,
height,
orientation,
mirror,
axisLine,
otherSvgProps
} = axisLineProps;
if (!axisLine) {
return null;
}
var props = _objectSpread(_objectSpread(_objectSpread({}, otherSvgProps), svgPropertiesNoEvents(axisLine)), {}, {
fill: 'none'
});
if (orientation === 'top' || orientation === 'bottom') {
var needHeight = +(orientation === 'top' && !mirror || orientation === 'bottom' && mirror);
props = _objectSpread(_objectSpread({}, props), {}, {
x1: x,
y1: y + needHeight * height,
x2: x + width,
y2: y + needHeight * height
});
} else {
var needWidth = +(orientation === 'left' && !mirror || orientation === 'right' && mirror);
props = _objectSpread(_objectSpread({}, props), {}, {
x1: x + needWidth * width,
y1: y,
x2: x + needWidth * width,
y2: y + height
});
}
return /*#__PURE__*/React.createElement("line", _extends({}, props, {
className: clsx('recharts-cartesian-axis-line', get(axisLine, 'className'))
}));
}
/**
* Calculate the coordinates of endpoints in ticks.
* @param data The data of a simple tick.
* @param x The x-coordinate of the axis.
* @param y The y-coordinate of the axis.
* @param width The width of the axis.
* @param height The height of the axis.
* @param orientation The orientation of the axis.
* @param tickSize The length of the tick line.
* @param mirror If true, the ticks are mirrored.
* @param tickMargin The margin between the tick line and the tick text.
* @returns An object with `line` and `tick` coordinates.
* `line` is the coordinates for the tick line, and `tick` is the coordinate for the tick text.
*/
function getTickLineCoord(data, x, y, width, height, orientation, tickSize, mirror, tickMargin) {
var x1, x2, y1, y2, tx, ty;
var sign = mirror ? -1 : 1;
var finalTickSize = data.tickSize || tickSize;
var tickCoord = isNumber(data.tickCoord) ? data.tickCoord : data.coordinate;
switch (orientation) {
case 'top':
x1 = x2 = data.coordinate;
y2 = y + +!mirror * height;
y1 = y2 - sign * finalTickSize;
ty = y1 - sign * tickMargin;
tx = tickCoord;
break;
case 'left':
y1 = y2 = data.coordinate;
x2 = x + +!mirror * width;
x1 = x2 - sign * finalTickSize;
tx = x1 - sign * tickMargin;
ty = tickCoord;
break;
case 'right':
y1 = y2 = data.coordinate;
x2 = x + +mirror * width;
x1 = x2 + sign * finalTickSize;
tx = x1 + sign * tickMargin;
ty = tickCoord;
break;
default:
x1 = x2 = data.coordinate;
y2 = y + +mirror * height;
y1 = y2 + sign * finalTickSize;
ty = y1 + sign * tickMargin;
tx = tickCoord;
break;
}
return {
line: {
x1,
y1,
x2,
y2
},
tick: {
x: tx,
y: ty
}
};
}
/**
* @param orientation The orientation of the axis.
* @param mirror If true, the ticks are mirrored.
* @returns The text anchor of the tick.
*/
function getTickTextAnchor(orientation, mirror) {
switch (orientation) {
case 'left':
return mirror ? 'start' : 'end';
case 'right':
return mirror ? 'end' : 'start';
default:
return 'middle';
}
}
/**
* @param orientation The orientation of the axis.
* @param mirror If true, the ticks are mirrored.
* @returns The vertical text anchor of the tick.
*/
function getTickVerticalAnchor(orientation, mirror) {
switch (orientation) {
case 'left':
case 'right':
return 'middle';
case 'top':
return mirror ? 'start' : 'end';
default:
return mirror ? 'end' : 'start';
}
}
function TickItem(props) {
var {
option,
tickProps,
value
} = props;
var tickItem;
var combinedClassName = clsx(tickProps.className, 'recharts-cartesian-axis-tick-value');
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error element cloning is not typed
tickItem = /*#__PURE__*/React.cloneElement(option, _objectSpread(_objectSpread({}, tickProps), {}, {
className: combinedClassName
}));
} else if (typeof option === 'function') {
tickItem = option(_objectSpread(_objectSpread({}, tickProps), {}, {
className: combinedClassName
}));
} else {
var className = 'recharts-cartesian-axis-tick-value';
if (typeof option !== 'boolean') {
className = clsx(className, option === null || option === void 0 ? void 0 : option.className);
}
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, tickProps, {
className: className
}), value);
}
return tickItem;
}
var Ticks = /*#__PURE__*/forwardRef((props, ref) => {
var {
ticks = [],
tick,
tickLine,
stroke,
tickFormatter,
unit,
padding,
tickTextProps,
orientation,
mirror,
x,
y,
width,
height,
tickSize,
tickMargin,
fontSize,
letterSpacing,
getTicksConfig,
events,
axisType
} = props;
// @ts-expect-error some properties are optional in props but required in getTicks
var finalTicks = getTicks(_objectSpread(_objectSpread({}, getTicksConfig), {}, {
ticks
}), fontSize, letterSpacing);
var textAnchor = getTickTextAnchor(orientation, mirror);
var verticalAnchor = getTickVerticalAnchor(orientation, mirror);
var axisProps = svgPropertiesNoEvents(getTicksConfig);
var customTickProps = svgPropertiesNoEventsFromUnknown(tick);
var tickLinePropsObject = {};
if (typeof tickLine === 'object') {
tickLinePropsObject = tickLine;
}
var tickLineProps = _objectSpread(_objectSpread({}, axisProps), {}, {
fill: 'none'
}, tickLinePropsObject);
var tickLineCoords = finalTicks.map(entry => _objectSpread({
entry
}, getTickLineCoord(entry, x, y, width, height, orientation, tickSize, mirror, tickMargin)));
var tickLines = tickLineCoords.map(_ref => {
var {
entry,
line: lineCoord
} = _ref;
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-cartesian-axis-tick",
key: "tick-".concat(entry.value, "-").concat(entry.coordinate, "-").concat(entry.tickCoord)
}, tickLine && /*#__PURE__*/React.createElement("line", _extends({}, tickLineProps, lineCoord, {
className: clsx('recharts-cartesian-axis-tick-line', get(tickLine, 'className'))
})));
});
var tickLabels = tickLineCoords.map((_ref2, i) => {
var {
entry,
tick: tickCoord
} = _ref2;
var tickProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
// @ts-expect-error textAnchor from axisProps is typed as `string` but Text wants type `TextAnchor`
textAnchor,
verticalAnchor
}, axisProps), {}, {
// @ts-expect-error customTickProps is contributing unknown props
stroke: 'none',
// @ts-expect-error customTickProps is contributing unknown props
fill: stroke
}, customTickProps), tickCoord), {}, {
index: i,
payload: entry,
visibleTicksCount: finalTicks.length,
tickFormatter,
padding
}, tickTextProps);
return /*#__PURE__*/React.createElement(Layer, _extends({
className: "recharts-cartesian-axis-tick-label",
key: "tick-label-".concat(entry.value, "-").concat(entry.coordinate, "-").concat(entry.tickCoord)
}, adaptEventsOfChild(events, entry, i)), tick && /*#__PURE__*/React.createElement(TickItem, {
option: tick,
tickProps: tickProps,
value: "".concat(typeof tickFormatter === 'function' ? tickFormatter(entry.value, i) : entry.value).concat(unit || '')
}));
});
return /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-axis-ticks recharts-".concat(axisType, "-ticks")
}, tickLabels.length > 0 && /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: DefaultZIndexes.label
}, /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-axis-tick-labels recharts-".concat(axisType, "-tick-labels"),
ref: ref
}, tickLabels)), tickLines.length > 0 && /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-axis-tick-lines recharts-".concat(axisType, "-tick-lines")
}, tickLines));
});
var CartesianAxisComponent = /*#__PURE__*/forwardRef((props, ref) => {
var {
axisLine,
width,
height,
className,
hide,
ticks,
axisType
} = props,
rest = _objectWithoutProperties(props, _excluded);
var [fontSize, setFontSize] = useState('');
var [letterSpacing, setLetterSpacing] = useState('');
var tickRefs = useRef(null);
useImperativeHandle(ref, () => ({
getCalculatedWidth: () => {
var _props$labelRef;
return getCalculatedYAxisWidth({
ticks: tickRefs.current,
label: (_props$labelRef = props.labelRef) === null || _props$labelRef === void 0 ? void 0 : _props$labelRef.current,
labelGapWithTick: 5,
tickSize: props.tickSize,
tickMargin: props.tickMargin
});
}
}));
var layerRef = useCallback(el => {
if (el) {
var tickNodes = el.getElementsByClassName('recharts-cartesian-axis-tick-value');
tickRefs.current = tickNodes;
var tick = tickNodes[0];
if (tick) {
var computedStyle = window.getComputedStyle(tick);
var calculatedFontSize = computedStyle.fontSize;
var calculatedLetterSpacing = computedStyle.letterSpacing;
if (calculatedFontSize !== fontSize || calculatedLetterSpacing !== letterSpacing) {
setFontSize(calculatedFontSize);
setLetterSpacing(calculatedLetterSpacing);
}
}
}
}, [fontSize, letterSpacing]);
if (hide) {
return null;
}
/*
* This is different condition from what validateWidthHeight is doing;
* the CartesianAxis does allow width or height to be undefined.
*/
if (width != null && width <= 0 || height != null && height <= 0) {
return null;
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: clsx('recharts-cartesian-axis', className)
}, /*#__PURE__*/React.createElement(AxisLine, {
x: props.x,
y: props.y,
width: width,
height: height,
orientation: props.orientation,
mirror: props.mirror,
axisLine: axisLine,
otherSvgProps: svgPropertiesNoEvents(props)
}), /*#__PURE__*/React.createElement(Ticks, {
ref: layerRef,
axisType: axisType,
events: rest,
fontSize: fontSize,
getTicksConfig: props,
height: props.height,
letterSpacing: letterSpacing,
mirror: props.mirror,
orientation: props.orientation,
padding: props.padding,
stroke: props.stroke,
tick: props.tick,
tickFormatter: props.tickFormatter,
tickLine: props.tickLine,
tickMargin: props.tickMargin,
tickSize: props.tickSize,
tickTextProps: props.tickTextProps,
ticks: ticks,
unit: props.unit,
width: props.width,
x: props.x,
y: props.y
}), /*#__PURE__*/React.createElement(CartesianLabelContextProvider, {
x: props.x,
y: props.y,
width: props.width,
height: props.height,
lowerWidth: props.width,
upperWidth: props.width
}, /*#__PURE__*/React.createElement(CartesianLabelFromLabelProp, {
label: props.label,
labelRef: props.labelRef
}), props.children)));
});
var MemoCartesianAxis = /*#__PURE__*/React.memo(CartesianAxisComponent, (prevProps, nextProps) => {
var {
viewBox: prevViewBox
} = prevProps,
prevRestProps = _objectWithoutProperties(prevProps, _excluded2);
var {
viewBox: nextViewBox
} = nextProps,
nextRestProps = _objectWithoutProperties(nextProps, _excluded3);
return shallowEqual(prevViewBox, nextViewBox) && shallowEqual(prevRestProps, nextRestProps);
});
export var CartesianAxis = /*#__PURE__*/React.forwardRef((outsideProps, ref) => {
var props = resolveDefaultProps(outsideProps, defaultCartesianAxisProps);
return /*#__PURE__*/React.createElement(MemoCartesianAxis, _extends({}, props, {
ref: ref
}));
});
CartesianAxis.displayName = 'CartesianAxis';

View File

@@ -0,0 +1,406 @@
var _excluded = ["x1", "y1", "x2", "y2", "key"],
_excluded2 = ["offset"],
_excluded3 = ["xAxisId", "yAxisId"],
_excluded4 = ["xAxisId", "yAxisId"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Cartesian Grid
*/
import * as React from 'react';
import { warn } from '../util/LogUtils';
import { isNumber } from '../util/DataUtils';
import { getCoordinatesOfGrid, getTicksOfAxis } from '../util/ChartUtils';
import { getTicks } from './getTicks';
import { defaultCartesianAxisProps } from './CartesianAxis';
import { useChartHeight, useChartWidth, useOffsetInternal } from '../context/chartLayoutContext';
import { selectAxisPropsNeededForCartesianGridTicksGenerator } from '../state/selectors/axisSelectors';
import { useAppSelector } from '../state/hooks';
import { useIsPanorama } from '../context/PanoramaContext';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* The <CartesianGrid horizontal
*/
var Background = props => {
var {
fill
} = props;
if (!fill || fill === 'none') {
return null;
}
var {
fillOpacity,
x,
y,
width,
height,
ry
} = props;
return /*#__PURE__*/React.createElement("rect", {
x: x,
y: y,
ry: ry,
width: width,
height: height,
stroke: "none",
fill: fill,
fillOpacity: fillOpacity,
className: "recharts-cartesian-grid-bg"
});
};
function LineItem(_ref) {
var {
option,
lineItemProps
} = _ref;
var lineItem;
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error typescript does not see the props type when cloning an element
lineItem = /*#__PURE__*/React.cloneElement(option, lineItemProps);
} else if (typeof option === 'function') {
lineItem = option(lineItemProps);
} else {
var _svgPropertiesNoEvent;
var {
x1,
y1,
x2,
y2,
key
} = lineItemProps,
others = _objectWithoutProperties(lineItemProps, _excluded);
var _ref2 = (_svgPropertiesNoEvent = svgPropertiesNoEvents(others)) !== null && _svgPropertiesNoEvent !== void 0 ? _svgPropertiesNoEvent : {},
{
offset: __
} = _ref2,
restOfFilteredProps = _objectWithoutProperties(_ref2, _excluded2);
lineItem = /*#__PURE__*/React.createElement("line", _extends({}, restOfFilteredProps, {
x1: x1,
y1: y1,
x2: x2,
y2: y2,
fill: "none",
key: key
}));
}
return lineItem;
}
function HorizontalGridLines(props) {
var {
x,
width,
horizontal = true,
horizontalPoints
} = props;
if (!horizontal || !horizontalPoints || !horizontalPoints.length) {
return null;
}
var {
xAxisId,
yAxisId
} = props,
otherLineItemProps = _objectWithoutProperties(props, _excluded3);
var items = horizontalPoints.map((entry, i) => {
var lineItemProps = _objectSpread(_objectSpread({}, otherLineItemProps), {}, {
x1: x,
y1: entry,
x2: x + width,
y2: entry,
key: "line-".concat(i),
index: i
});
return /*#__PURE__*/React.createElement(LineItem, {
key: "line-".concat(i),
option: horizontal,
lineItemProps: lineItemProps
});
});
return /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-grid-horizontal"
}, items);
}
function VerticalGridLines(props) {
var {
y,
height,
vertical = true,
verticalPoints
} = props;
if (!vertical || !verticalPoints || !verticalPoints.length) {
return null;
}
var {
xAxisId,
yAxisId
} = props,
otherLineItemProps = _objectWithoutProperties(props, _excluded4);
var items = verticalPoints.map((entry, i) => {
var lineItemProps = _objectSpread(_objectSpread({}, otherLineItemProps), {}, {
x1: entry,
y1: y,
x2: entry,
y2: y + height,
key: "line-".concat(i),
index: i
});
return /*#__PURE__*/React.createElement(LineItem, {
option: vertical,
lineItemProps: lineItemProps,
key: "line-".concat(i)
});
});
return /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-grid-vertical"
}, items);
}
function HorizontalStripes(props) {
var {
horizontalFill,
fillOpacity,
x,
y,
width,
height,
horizontalPoints,
horizontal = true
} = props;
if (!horizontal || !horizontalFill || !horizontalFill.length || horizontalPoints == null) {
return null;
}
var roundedSortedHorizontalPoints = horizontalPoints.map(e => Math.round(e + y - y)).sort((a, b) => a - b);
// Why is this condition `!==` instead of `<=` ?
if (y !== roundedSortedHorizontalPoints[0]) {
roundedSortedHorizontalPoints.unshift(0);
}
var items = roundedSortedHorizontalPoints.map((entry, i) => {
// Why do we strip only the last stripe if it is invisible, and not all invisible stripes?
var lastStripe = !roundedSortedHorizontalPoints[i + 1];
var lineHeight = lastStripe ? y + height - entry : roundedSortedHorizontalPoints[i + 1] - entry;
if (lineHeight <= 0) {
return null;
}
var colorIndex = i % horizontalFill.length;
return /*#__PURE__*/React.createElement("rect", {
key: "react-".concat(i),
y: entry,
x: x,
height: lineHeight,
width: width,
stroke: "none",
fill: horizontalFill[colorIndex],
fillOpacity: fillOpacity,
className: "recharts-cartesian-grid-bg"
});
});
return /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-gridstripes-horizontal"
}, items);
}
function VerticalStripes(props) {
var {
vertical = true,
verticalFill,
fillOpacity,
x,
y,
width,
height,
verticalPoints
} = props;
if (!vertical || !verticalFill || !verticalFill.length) {
return null;
}
var roundedSortedVerticalPoints = verticalPoints.map(e => Math.round(e + x - x)).sort((a, b) => a - b);
if (x !== roundedSortedVerticalPoints[0]) {
roundedSortedVerticalPoints.unshift(0);
}
var items = roundedSortedVerticalPoints.map((entry, i) => {
var lastStripe = !roundedSortedVerticalPoints[i + 1];
var lineWidth = lastStripe ? x + width - entry : roundedSortedVerticalPoints[i + 1] - entry;
if (lineWidth <= 0) {
return null;
}
var colorIndex = i % verticalFill.length;
return /*#__PURE__*/React.createElement("rect", {
key: "react-".concat(i),
x: entry,
y: y,
width: lineWidth,
height: height,
stroke: "none",
fill: verticalFill[colorIndex],
fillOpacity: fillOpacity,
className: "recharts-cartesian-grid-bg"
});
});
return /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-gridstripes-vertical"
}, items);
}
var defaultVerticalCoordinatesGenerator = (_ref3, syncWithTicks) => {
var {
xAxis,
width,
height,
offset
} = _ref3;
return getCoordinatesOfGrid(getTicks(_objectSpread(_objectSpread(_objectSpread({}, defaultCartesianAxisProps), xAxis), {}, {
ticks: getTicksOfAxis(xAxis, true),
viewBox: {
x: 0,
y: 0,
width,
height
}
})), offset.left, offset.left + offset.width, syncWithTicks);
};
var defaultHorizontalCoordinatesGenerator = (_ref4, syncWithTicks) => {
var {
yAxis,
width,
height,
offset
} = _ref4;
return getCoordinatesOfGrid(getTicks(_objectSpread(_objectSpread(_objectSpread({}, defaultCartesianAxisProps), yAxis), {}, {
ticks: getTicksOfAxis(yAxis, true),
viewBox: {
x: 0,
y: 0,
width,
height
}
})), offset.top, offset.top + offset.height, syncWithTicks);
};
var defaultCartesianGridProps = {
horizontal: true,
vertical: true,
// The ordinates of horizontal grid lines
horizontalPoints: [],
// The abscissas of vertical grid lines
verticalPoints: [],
stroke: '#ccc',
fill: 'none',
// The fill of colors of grid lines
verticalFill: [],
horizontalFill: [],
xAxisId: 0,
yAxisId: 0,
syncWithTicks: false,
zIndex: DefaultZIndexes.grid
};
export function CartesianGrid(props) {
var chartWidth = useChartWidth();
var chartHeight = useChartHeight();
var offset = useOffsetInternal();
var propsIncludingDefaults = _objectSpread(_objectSpread({}, resolveDefaultProps(props, defaultCartesianGridProps)), {}, {
x: isNumber(props.x) ? props.x : offset.left,
y: isNumber(props.y) ? props.y : offset.top,
width: isNumber(props.width) ? props.width : offset.width,
height: isNumber(props.height) ? props.height : offset.height
});
var {
xAxisId,
yAxisId,
x,
y,
width,
height,
syncWithTicks,
horizontalValues,
verticalValues
} = propsIncludingDefaults;
var isPanorama = useIsPanorama();
var xAxis = useAppSelector(state => selectAxisPropsNeededForCartesianGridTicksGenerator(state, 'xAxis', xAxisId, isPanorama));
var yAxis = useAppSelector(state => selectAxisPropsNeededForCartesianGridTicksGenerator(state, 'yAxis', yAxisId, isPanorama));
if (!isPositiveNumber(width) || !isPositiveNumber(height) || !isNumber(x) || !isNumber(y)) {
return null;
}
/*
* verticalCoordinatesGenerator and horizontalCoordinatesGenerator are defined
* outside the propsIncludingDefaults because they were never part of the original props
* and they were never passed as a prop down to horizontal/vertical custom elements.
* If we add these two to propsIncludingDefaults then we are changing public API.
* Not a bad thing per se but also not necessary.
*/
var verticalCoordinatesGenerator = propsIncludingDefaults.verticalCoordinatesGenerator || defaultVerticalCoordinatesGenerator;
var horizontalCoordinatesGenerator = propsIncludingDefaults.horizontalCoordinatesGenerator || defaultHorizontalCoordinatesGenerator;
var {
horizontalPoints,
verticalPoints
} = propsIncludingDefaults;
// No horizontal points are specified
if ((!horizontalPoints || !horizontalPoints.length) && typeof horizontalCoordinatesGenerator === 'function') {
var isHorizontalValues = horizontalValues && horizontalValues.length;
var generatorResult = horizontalCoordinatesGenerator({
yAxis: yAxis ? _objectSpread(_objectSpread({}, yAxis), {}, {
ticks: isHorizontalValues ? horizontalValues : yAxis.ticks
}) : undefined,
width: chartWidth !== null && chartWidth !== void 0 ? chartWidth : width,
height: chartHeight !== null && chartHeight !== void 0 ? chartHeight : height,
offset
}, isHorizontalValues ? true : syncWithTicks);
warn(Array.isArray(generatorResult), "horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof generatorResult, "]"));
if (Array.isArray(generatorResult)) {
horizontalPoints = generatorResult;
}
}
// No vertical points are specified
if ((!verticalPoints || !verticalPoints.length) && typeof verticalCoordinatesGenerator === 'function') {
var isVerticalValues = verticalValues && verticalValues.length;
var _generatorResult = verticalCoordinatesGenerator({
xAxis: xAxis ? _objectSpread(_objectSpread({}, xAxis), {}, {
ticks: isVerticalValues ? verticalValues : xAxis.ticks
}) : undefined,
width: chartWidth !== null && chartWidth !== void 0 ? chartWidth : width,
height: chartHeight !== null && chartHeight !== void 0 ? chartHeight : height,
offset
}, isVerticalValues ? true : syncWithTicks);
warn(Array.isArray(_generatorResult), "verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof _generatorResult, "]"));
if (Array.isArray(_generatorResult)) {
verticalPoints = _generatorResult;
}
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: propsIncludingDefaults.zIndex
}, /*#__PURE__*/React.createElement("g", {
className: "recharts-cartesian-grid"
}, /*#__PURE__*/React.createElement(Background, {
fill: propsIncludingDefaults.fill,
fillOpacity: propsIncludingDefaults.fillOpacity,
x: propsIncludingDefaults.x,
y: propsIncludingDefaults.y,
width: propsIncludingDefaults.width,
height: propsIncludingDefaults.height,
ry: propsIncludingDefaults.ry
}), /*#__PURE__*/React.createElement(HorizontalStripes, _extends({}, propsIncludingDefaults, {
horizontalPoints: horizontalPoints
})), /*#__PURE__*/React.createElement(VerticalStripes, _extends({}, propsIncludingDefaults, {
verticalPoints: verticalPoints
})), /*#__PURE__*/React.createElement(HorizontalGridLines, _extends({}, propsIncludingDefaults, {
offset: offset,
horizontalPoints: horizontalPoints,
xAxis: xAxis,
yAxis: yAxis
})), /*#__PURE__*/React.createElement(VerticalGridLines, _extends({}, propsIncludingDefaults, {
offset: offset,
verticalPoints: verticalPoints,
xAxis: xAxis,
yAxis: yAxis
}))));
}
CartesianGrid.displayName = 'CartesianGrid';

View File

@@ -0,0 +1,235 @@
var _excluded = ["direction", "width", "dataKey", "isAnimationActive", "animationBegin", "animationDuration", "animationEasing"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Render a group of error bar
*/
import * as React from 'react';
import { Component } from 'react';
import { Layer } from '../container/Layer';
import { ReportErrorBarSettings, useErrorBarContext } from '../context/ErrorBarContext';
import { useXAxis, useYAxis } from '../hooks';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { useChartLayout } from '../context/chartLayoutContext';
import { CSSTransitionAnimate } from '../animation/CSSTransitionAnimate';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* So usually the direction is decided by the chart layout.
* Horizontal layout means error bars are vertical means direction=y
* Vertical layout means error bars are horizontal means direction=x
*
* Except! In Scatter chart, error bars can go both ways.
*
* So this property is only ever used in Scatter chart, and ignored elsewhere.
*/
/**
* External ErrorBar props, visible for users of the library
*/
/**
* Props after defaults, and required props have been applied.
*/
function ErrorBarImpl(props) {
var {
direction,
width,
dataKey,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing
} = props,
others = _objectWithoutProperties(props, _excluded);
var svgProps = svgPropertiesNoEvents(others);
var {
data,
dataPointFormatter,
xAxisId,
yAxisId,
errorBarOffset: offset
} = useErrorBarContext();
var xAxis = useXAxis(xAxisId);
var yAxis = useYAxis(yAxisId);
if ((xAxis === null || xAxis === void 0 ? void 0 : xAxis.scale) == null || (yAxis === null || yAxis === void 0 ? void 0 : yAxis.scale) == null || data == null) {
return null;
}
// ErrorBar requires type number XAxis, why?
if (direction === 'x' && xAxis.type !== 'number') {
return null;
}
var errorBars = data.map(entry => {
var {
x,
y,
value,
errorVal
} = dataPointFormatter(entry, dataKey, direction);
if (!errorVal || x == null || y == null) {
return null;
}
var lineCoordinates = [];
var lowBound, highBound;
if (Array.isArray(errorVal)) {
[lowBound, highBound] = errorVal;
} else {
lowBound = highBound = errorVal;
}
if (direction === 'x') {
// error bar for horizontal charts, the y is fixed, x is a range value
var {
scale
} = xAxis;
var yMid = y + offset;
var yMin = yMid + width;
var yMax = yMid - width;
var xMin = scale(value - lowBound);
var xMax = scale(value + highBound);
// the right line of |--|
lineCoordinates.push({
x1: xMax,
y1: yMin,
x2: xMax,
y2: yMax
});
// the middle line of |--|
lineCoordinates.push({
x1: xMin,
y1: yMid,
x2: xMax,
y2: yMid
});
// the left line of |--|
lineCoordinates.push({
x1: xMin,
y1: yMin,
x2: xMin,
y2: yMax
});
} else if (direction === 'y') {
// error bar for horizontal charts, the x is fixed, y is a range value
var {
scale: _scale
} = yAxis;
var xMid = x + offset;
var _xMin = xMid - width;
var _xMax = xMid + width;
var _yMin = _scale(value - lowBound);
var _yMax = _scale(value + highBound);
// the top line
lineCoordinates.push({
x1: _xMin,
y1: _yMax,
x2: _xMax,
y2: _yMax
});
// the middle line
lineCoordinates.push({
x1: xMid,
y1: _yMin,
x2: xMid,
y2: _yMax
});
// the bottom line
lineCoordinates.push({
x1: _xMin,
y1: _yMin,
x2: _xMax,
y2: _yMin
});
}
var scaleDirection = direction === 'x' ? 'scaleX' : 'scaleY';
var transformOrigin = "".concat(x + offset, "px ").concat(y + offset, "px");
return /*#__PURE__*/React.createElement(Layer, _extends({
className: "recharts-errorBar",
key: "bar-".concat(lineCoordinates.map(c => "".concat(c.x1, "-").concat(c.x2, "-").concat(c.y1, "-").concat(c.y2)))
}, svgProps), lineCoordinates.map(c => {
var lineStyle = isAnimationActive ? {
transformOrigin
} : undefined;
return /*#__PURE__*/React.createElement(CSSTransitionAnimate, {
animationId: "error-bar-".concat(direction, "_").concat(c.x1, "-").concat(c.x2, "-").concat(c.y1, "-").concat(c.y2),
from: "".concat(scaleDirection, "(0)"),
to: "".concat(scaleDirection, "(1)"),
attributeName: "transform",
begin: animationBegin,
easing: animationEasing,
isActive: isAnimationActive,
duration: animationDuration,
key: "errorbar-".concat(c.x1, "-").concat(c.x2, "-").concat(c.y1, "-").concat(c.y2)
}, style => /*#__PURE__*/React.createElement("line", _extends({}, c, {
style: _objectSpread(_objectSpread({}, lineStyle), style)
})));
}));
});
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-errorBars"
}, errorBars);
}
function useErrorBarDirection(directionFromProps) {
var layout = useChartLayout();
if (directionFromProps != null) {
return directionFromProps;
}
if (layout != null) {
return layout === 'horizontal' ? 'y' : 'x';
}
return 'x';
}
var errorBarDefaultProps = {
stroke: 'black',
strokeWidth: 1.5,
width: 5,
offset: 0,
isAnimationActive: true,
animationBegin: 0,
animationDuration: 400,
animationEasing: 'ease-in-out',
zIndex: DefaultZIndexes.line
};
function ErrorBarInternal(props) {
var realDirection = useErrorBarDirection(props.direction);
var {
width,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
zIndex
} = resolveDefaultProps(props, errorBarDefaultProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportErrorBarSettings, {
dataKey: props.dataKey,
direction: realDirection
}), /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex
}, /*#__PURE__*/React.createElement(ErrorBarImpl, _extends({}, props, {
direction: realDirection,
width: width,
isAnimationActive: isAnimationActive,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing
}))));
}
// eslint-disable-next-line react/prefer-stateless-function
export class ErrorBar extends Component {
render() {
return /*#__PURE__*/React.createElement(ErrorBarInternal, this.props);
}
}
_defineProperty(ErrorBar, "defaultProps", errorBarDefaultProps);
_defineProperty(ErrorBar, "displayName", 'ErrorBar');

427
frontend/node_modules/recharts/es6/cartesian/Funnel.js generated vendored Normal file
View File

@@ -0,0 +1,427 @@
var _excluded = ["onMouseEnter", "onClick", "onMouseLeave", "shape", "activeShape"],
_excluded2 = ["stroke", "fill", "legendType", "hide", "isAnimationActive", "animationBegin", "animationDuration", "animationEasing", "nameKey", "lastShapeType"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/* eslint-disable max-classes-per-file */
import * as React from 'react';
import { PureComponent, useCallback, useMemo, useRef, useState } from 'react';
import omit from 'es-toolkit/compat/omit';
import { clsx } from 'clsx';
import { selectActiveIndex } from '../state/selectors/selectors';
import { useAppSelector } from '../state/hooks';
import { Layer } from '../container/Layer';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { Global } from '../util/Global';
import { getPercentValue, interpolate } from '../util/DataUtils';
import { getValueByDataKey } from '../util/ChartUtils';
import { adaptEventsOfChild } from '../util/types';
import { FunnelTrapezoid } from '../util/FunnelUtils';
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { selectFunnelTrapezoids } from '../state/selectors/funnelSelectors';
import { findAllByType } from '../util/ReactUtils';
import { Cell } from '../component/Cell';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { usePlotArea } from '../hooks';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { useAnimationId } from '../util/useAnimationId';
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
/**
* External props, intended for end users to fill in
*/
function getTooltipEntrySettings(props) {
var {
dataKey,
nameKey,
stroke,
strokeWidth,
fill,
name,
hide,
tooltipType,
data
} = props;
return {
dataDefinedOnItem: data,
positions: props.trapezoids.map(_ref => {
var {
tooltipPosition
} = _ref;
return tooltipPosition;
}),
settings: {
stroke,
strokeWidth,
fill,
dataKey,
name,
nameKey,
hide,
type: tooltipType,
color: fill,
unit: '' // Funnel does not have unit, why?
}
};
}
function FunnelLabelListProvider(_ref2) {
var {
showLabels,
trapezoids,
children
} = _ref2;
var labelListEntries = useMemo(() => {
if (!showLabels) {
return undefined;
}
return trapezoids === null || trapezoids === void 0 ? void 0 : trapezoids.map(entry => {
var viewBox = entry.labelViewBox;
return _objectSpread(_objectSpread({}, viewBox), {}, {
value: entry.name,
payload: entry.payload,
parentViewBox: entry.parentViewBox,
viewBox,
fill: entry.fill
});
});
}, [showLabels, trapezoids]);
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: labelListEntries
}, children);
}
function FunnelTrapezoids(props) {
var {
trapezoids,
allOtherFunnelProps
} = props;
var activeItemIndex = useAppSelector(state => selectActiveIndex(state, 'item', state.tooltip.settings.trigger, undefined));
var {
onMouseEnter: onMouseEnterFromProps,
onClick: onItemClickFromProps,
onMouseLeave: onMouseLeaveFromProps,
shape,
activeShape
} = allOtherFunnelProps,
restOfAllOtherProps = _objectWithoutProperties(allOtherFunnelProps, _excluded);
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherFunnelProps.dataKey);
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherFunnelProps.dataKey);
return /*#__PURE__*/React.createElement(React.Fragment, null, trapezoids.map((entry, i) => {
var isActiveIndex = Boolean(activeShape) && activeItemIndex === String(i);
var trapezoidOptions = isActiveIndex ? activeShape : shape;
var trapezoidProps = _objectSpread(_objectSpread({}, entry), {}, {
option: trapezoidOptions,
isActive: isActiveIndex,
stroke: entry.stroke
});
return /*#__PURE__*/React.createElement(Layer, _extends({
key: "trapezoid-".concat(entry === null || entry === void 0 ? void 0 : entry.x, "-").concat(entry === null || entry === void 0 ? void 0 : entry.y, "-").concat(entry === null || entry === void 0 ? void 0 : entry.name, "-").concat(entry === null || entry === void 0 ? void 0 : entry.value),
className: "recharts-funnel-trapezoid"
}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
// @ts-expect-error the types need a bit of attention
onMouseEnter: onMouseEnterFromContext(entry, i)
// @ts-expect-error the types need a bit of attention
,
onMouseLeave: onMouseLeaveFromContext(entry, i)
// @ts-expect-error the types need a bit of attention
,
onClick: onClickFromContext(entry, i)
}), /*#__PURE__*/React.createElement(FunnelTrapezoid, trapezoidProps));
}));
}
function TrapezoidsWithAnimation(_ref3) {
var {
previousTrapezoidsRef,
props
} = _ref3;
var {
trapezoids,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
onAnimationEnd,
onAnimationStart
} = props;
var prevTrapezoids = previousTrapezoidsRef.current;
var [isAnimating, setIsAnimating] = useState(false);
var showLabels = !isAnimating;
var animationId = useAnimationId(trapezoids, 'recharts-funnel-');
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
return /*#__PURE__*/React.createElement(FunnelLabelListProvider, {
showLabels: showLabels,
trapezoids: trapezoids
}, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
key: animationId,
onAnimationStart: handleAnimationStart,
onAnimationEnd: handleAnimationEnd
}, t => {
var stepData = t === 1 ? trapezoids : trapezoids.map((entry, index) => {
var prev = prevTrapezoids && prevTrapezoids[index];
if (prev) {
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(prev.x, entry.x, t),
y: interpolate(prev.y, entry.y, t),
upperWidth: interpolate(prev.upperWidth, entry.upperWidth, t),
lowerWidth: interpolate(prev.lowerWidth, entry.lowerWidth, t),
height: interpolate(prev.height, entry.height, t)
});
}
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(entry.x + entry.upperWidth / 2, entry.x, t),
y: interpolate(entry.y + entry.height / 2, entry.y, t),
upperWidth: interpolate(0, entry.upperWidth, t),
lowerWidth: interpolate(0, entry.lowerWidth, t),
height: interpolate(0, entry.height, t)
});
});
if (t > 0) {
// eslint-disable-next-line no-param-reassign
previousTrapezoidsRef.current = stepData;
}
return /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement(FunnelTrapezoids, {
trapezoids: stepData,
allOtherFunnelProps: props
}));
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}), props.children);
}
function RenderTrapezoids(props) {
var previousTrapezoidsRef = useRef(undefined);
return /*#__PURE__*/React.createElement(TrapezoidsWithAnimation, {
props: props,
previousTrapezoidsRef: previousTrapezoidsRef
});
}
var getRealWidthHeight = (customWidth, offset) => {
var {
width,
height,
left,
top
} = offset;
var realWidth = getPercentValue(customWidth, width, width);
return {
realWidth,
realHeight: height,
offsetX: left,
offsetY: top
};
};
export class FunnelWithState extends PureComponent {
render() {
var {
className
} = this.props;
var layerClass = clsx('recharts-trapezoids', className);
return /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, /*#__PURE__*/React.createElement(RenderTrapezoids, this.props));
}
}
var defaultFunnelProps = {
stroke: '#fff',
fill: '#808080',
legendType: 'rect',
hide: false,
isAnimationActive: !Global.isSsr,
animationBegin: 400,
animationDuration: 1500,
animationEasing: 'ease',
nameKey: 'name',
lastShapeType: 'triangle'
};
function FunnelImpl(props) {
var plotArea = usePlotArea();
var _resolveDefaultProps = resolveDefaultProps(props, defaultFunnelProps),
{
stroke,
fill,
legendType,
hide,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
nameKey,
lastShapeType
} = _resolveDefaultProps,
everythingElse = _objectWithoutProperties(_resolveDefaultProps, _excluded2);
var presentationProps = svgPropertiesNoEvents(props);
var cells = findAllByType(props.children, Cell);
var funnelSettings = useMemo(() => ({
dataKey: props.dataKey,
nameKey,
data: props.data,
tooltipType: props.tooltipType,
lastShapeType,
reversed: props.reversed,
customWidth: props.width,
cells,
presentationProps
}), [props.dataKey, nameKey, props.data, props.tooltipType, lastShapeType, props.reversed, props.width, cells, presentationProps]);
var trapezoids = useAppSelector(state => selectFunnelTrapezoids(state, funnelSettings));
if (hide || !trapezoids || !trapezoids.length || !plotArea) {
return null;
}
var {
height,
width
} = plotArea;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: _objectSpread(_objectSpread({}, props), {}, {
trapezoids
})
}), /*#__PURE__*/React.createElement(FunnelWithState, _extends({}, everythingElse, {
stroke: stroke,
fill: fill,
nameKey: nameKey,
lastShapeType: lastShapeType,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
isAnimationActive: isAnimationActive,
hide: hide,
legendType: legendType,
height: height,
width: width,
trapezoids: trapezoids
})));
}
export function computeFunnelTrapezoids(_ref4) {
var {
dataKey,
nameKey,
displayedData,
tooltipType,
lastShapeType,
reversed,
offset,
customWidth
} = _ref4;
var {
realHeight,
realWidth,
offsetX,
offsetY
} = getRealWidthHeight(customWidth, offset);
var maxValue = Math.max.apply(null, displayedData.map(entry => getValueByDataKey(entry, dataKey, 0)));
var len = displayedData.length;
var rowHeight = realHeight / len;
var parentViewBox = {
x: offset.left,
y: offset.top,
width: offset.width,
height: offset.height
};
var trapezoids = displayedData.map((entry, i) => {
// @ts-expect-error getValueByDataKey does not validate the output type
var rawVal = getValueByDataKey(entry, dataKey, 0);
var name = String(getValueByDataKey(entry, nameKey, i));
var val = rawVal;
var nextVal;
if (i !== len - 1) {
nextVal = getValueByDataKey(displayedData[i + 1], dataKey, 0);
if (nextVal instanceof Array) {
[val, nextVal] = nextVal;
}
} else if (rawVal instanceof Array && rawVal.length === 2) {
[val, nextVal] = rawVal;
} else if (lastShapeType === 'rectangle') {
nextVal = val;
} else {
nextVal = 0;
}
// @ts-expect-error this is a problem if we have ranged values because `val` can be an array
var x = (maxValue - val) * realWidth / (2 * maxValue) + offsetX;
var y = rowHeight * i + offsetY;
// @ts-expect-error getValueByDataKey does not validate the output type
var upperWidth = val / maxValue * realWidth;
var lowerWidth = nextVal / maxValue * realWidth;
var tooltipPayload = [{
name,
value: val,
payload: entry,
dataKey,
type: tooltipType
}];
var tooltipPosition = {
x: x + upperWidth / 2,
y: y + rowHeight / 2
};
var trapezoidViewBox = {
x,
y,
upperWidth,
lowerWidth,
width: Math.max(upperWidth, lowerWidth),
height: rowHeight
};
return _objectSpread(_objectSpread(_objectSpread({}, trapezoidViewBox), {}, {
name,
val,
tooltipPayload,
tooltipPosition
}, omit(entry, ['width'])), {}, {
payload: entry,
parentViewBox,
labelViewBox: trapezoidViewBox
});
});
if (reversed) {
trapezoids = trapezoids.map((entry, index) => {
var reversedViewBox = {
x: entry.x - (entry.lowerWidth - entry.upperWidth) / 2,
y: entry.y - index * rowHeight + (len - 1 - index) * rowHeight,
upperWidth: entry.lowerWidth,
lowerWidth: entry.upperWidth,
width: Math.max(entry.lowerWidth, entry.upperWidth),
height: rowHeight
};
return _objectSpread(_objectSpread(_objectSpread({}, entry), reversedViewBox), {}, {
tooltipPosition: _objectSpread(_objectSpread({}, entry.tooltipPosition), {}, {
y: entry.y - index * rowHeight + (len - 1 - index) * rowHeight + rowHeight / 2
}),
labelViewBox: reversedViewBox
});
});
}
return trapezoids;
}
export class Funnel extends PureComponent {
render() {
return /*#__PURE__*/React.createElement(FunnelImpl, this.props);
}
}
_defineProperty(Funnel, "displayName", 'Funnel');
_defineProperty(Funnel, "defaultProps", defaultFunnelProps);

View File

@@ -0,0 +1,47 @@
import * as React from 'react';
import { useAppSelector } from '../state/hooks';
import { implicitXAxis, implicitYAxis, selectXAxisSettings, selectYAxisSettings } from '../state/selectors/axisSelectors';
import { usePlotArea } from '../hooks';
export function useNeedsClip(xAxisId, yAxisId) {
var _xAxis$allowDataOverf, _yAxis$allowDataOverf;
var xAxis = useAppSelector(state => selectXAxisSettings(state, xAxisId));
var yAxis = useAppSelector(state => selectYAxisSettings(state, yAxisId));
var needClipX = (_xAxis$allowDataOverf = xAxis === null || xAxis === void 0 ? void 0 : xAxis.allowDataOverflow) !== null && _xAxis$allowDataOverf !== void 0 ? _xAxis$allowDataOverf : implicitXAxis.allowDataOverflow;
var needClipY = (_yAxis$allowDataOverf = yAxis === null || yAxis === void 0 ? void 0 : yAxis.allowDataOverflow) !== null && _yAxis$allowDataOverf !== void 0 ? _yAxis$allowDataOverf : implicitYAxis.allowDataOverflow;
var needClip = needClipX || needClipY;
return {
needClip,
needClipX,
needClipY
};
}
export function GraphicalItemClipPath(_ref) {
var {
xAxisId,
yAxisId,
clipPathId
} = _ref;
var plotArea = usePlotArea();
var {
needClipX,
needClipY,
needClip
} = useNeedsClip(xAxisId, yAxisId);
if (!needClip || !plotArea) {
return null;
}
var {
x,
y,
width,
height
} = plotArea;
return /*#__PURE__*/React.createElement("clipPath", {
id: "clipPath-".concat(clipPathId)
}, /*#__PURE__*/React.createElement("rect", {
x: needClipX ? x : x - width / 2,
y: needClipY ? y : y - height / 2,
width: needClipX ? width : width * 2,
height: needClipY ? height : height * 2
}));
}

644
frontend/node_modules/recharts/es6/cartesian/Line.js generated vendored Executable file
View File

@@ -0,0 +1,644 @@
var _excluded = ["id"],
_excluded2 = ["type", "layout", "connectNulls", "needClip", "shape"],
_excluded3 = ["activeDot", "animateNewValues", "animationBegin", "animationDuration", "animationEasing", "connectNulls", "dot", "hide", "isAnimationActive", "label", "legendType", "xAxisId", "yAxisId", "id"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { Component, useCallback, useMemo, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { Dots } from '../component/Dots';
import { interpolate, isNullish } from '../util/DataUtils';
import { isClipDot } from '../util/ReactUtils';
import { Global } from '../util/Global';
import { getCateCoordinateOfLine, getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
import { ActivePoints } from '../component/ActivePoints';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { SetErrorBarContext } from '../context/ErrorBarContext';
import { GraphicalItemClipPath, useNeedsClip } from './GraphicalItemClipPath';
import { useChartLayout } from '../context/chartLayoutContext';
import { useIsPanorama } from '../context/PanoramaContext';
import { selectLinePoints } from '../state/selectors/lineSelectors';
import { useAppSelector } from '../state/hooks';
import { SetLegendPayload } from '../state/SetLegendPayload';
import { useAnimationId } from '../util/useAnimationId';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { usePlotArea } from '../hooks';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetCartesianGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { getRadiusAndStrokeWidthFromDot } from '../util/getRadiusAndStrokeWidthFromDot';
import { Shape } from '../util/ActiveShapeUtils';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
/**
* External props, intended for end users to fill in
*/
/**
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
*/
var computeLegendPayloadFromAreaData = props => {
var {
dataKey,
name,
stroke,
legendType,
hide
} = props;
return [{
inactive: hide,
dataKey,
type: legendType,
color: stroke,
value: getTooltipNameProp(name, dataKey),
payload: props
}];
};
function getTooltipEntrySettings(props) {
var {
dataKey,
data,
stroke,
strokeWidth,
fill,
name,
hide,
unit
} = props;
return {
dataDefinedOnItem: data,
positions: undefined,
settings: {
stroke,
strokeWidth,
fill,
dataKey,
nameKey: undefined,
name: getTooltipNameProp(name, dataKey),
hide,
type: props.tooltipType,
color: props.stroke,
unit
}
};
}
var generateSimpleStrokeDasharray = (totalLength, length) => {
return "".concat(length, "px ").concat(totalLength - length, "px");
};
function repeat(lines, count) {
var linesUnit = lines.length % 2 !== 0 ? [...lines, 0] : lines;
var result = [];
for (var i = 0; i < count; ++i) {
result = [...result, ...linesUnit];
}
return result;
}
var getStrokeDasharray = (length, totalLength, lines) => {
var lineLength = lines.reduce((pre, next) => pre + next);
// if lineLength is 0 return the default when no strokeDasharray is provided
if (!lineLength) {
return generateSimpleStrokeDasharray(totalLength, length);
}
var count = Math.floor(length / lineLength);
var remainLength = length % lineLength;
var restLength = totalLength - length;
var remainLines = [];
for (var i = 0, sum = 0; i < lines.length; sum += lines[i], ++i) {
if (sum + lines[i] > remainLength) {
remainLines = [...lines.slice(0, i), remainLength - sum];
break;
}
}
var emptyLines = remainLines.length % 2 === 0 ? [0, restLength] : [restLength];
return [...repeat(lines, count), ...remainLines, ...emptyLines].map(line => "".concat(line, "px")).join(', ');
};
function LineDotsWrapper(_ref) {
var {
clipPathId,
points,
props
} = _ref;
var {
dot,
dataKey,
needClip
} = props;
/*
* Exclude ID from the props passed to the Dots component
* because then the ID would be applied to multiple dots, and it would no longer be unique.
*/
var {
id
} = props,
propsWithoutId = _objectWithoutProperties(props, _excluded);
var lineProps = svgPropertiesNoEvents(propsWithoutId);
return /*#__PURE__*/React.createElement(Dots, {
points: points,
dot: dot,
className: "recharts-line-dots",
dotClassName: "recharts-line-dot",
dataKey: dataKey,
baseProps: lineProps,
needClip: needClip,
clipPathId: clipPathId
});
}
function LineLabelListProvider(_ref2) {
var {
showLabels,
children,
points
} = _ref2;
var labelListEntries = useMemo(() => {
return points === null || points === void 0 ? void 0 : points.map(point => {
var _point$x, _point$y;
var viewBox = {
x: (_point$x = point.x) !== null && _point$x !== void 0 ? _point$x : 0,
y: (_point$y = point.y) !== null && _point$y !== void 0 ? _point$y : 0,
width: 0,
lowerWidth: 0,
upperWidth: 0,
height: 0
};
return _objectSpread(_objectSpread({}, viewBox), {}, {
value: point.value,
payload: point.payload,
viewBox,
/*
* Line is not passing parentViewBox to the LabelList so the labels can escape - looks like a bug, should we pass parentViewBox?
* Or should this just be the root chart viewBox?
*/
parentViewBox: undefined,
fill: undefined
});
});
}, [points]);
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function StaticCurve(_ref3) {
var {
clipPathId,
pathRef,
points,
strokeDasharray,
props
} = _ref3;
var {
type,
layout,
connectNulls,
needClip,
shape
} = props,
others = _objectWithoutProperties(props, _excluded2);
var curveProps = _objectSpread(_objectSpread({}, svgPropertiesAndEvents(others)), {}, {
fill: 'none',
className: 'recharts-line-curve',
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined,
points,
type,
layout,
connectNulls,
strokeDasharray: strokeDasharray !== null && strokeDasharray !== void 0 ? strokeDasharray : props.strokeDasharray
});
return /*#__PURE__*/React.createElement(React.Fragment, null, (points === null || points === void 0 ? void 0 : points.length) > 1 && /*#__PURE__*/React.createElement(Shape, _extends({
shapeType: "curve",
option: shape
}, curveProps, {
pathRef: pathRef
})), /*#__PURE__*/React.createElement(LineDotsWrapper, {
points: points,
clipPathId: clipPathId,
props: props
}));
}
function getTotalLength(mainCurve) {
try {
return mainCurve && mainCurve.getTotalLength && mainCurve.getTotalLength() || 0;
} catch (_unused) {
return 0;
}
}
function CurveWithAnimation(_ref4) {
var {
clipPathId,
props,
pathRef,
previousPointsRef,
longestAnimatedLengthRef
} = _ref4;
var {
points,
strokeDasharray,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
animateNewValues,
width,
height,
onAnimationEnd,
onAnimationStart
} = props;
var prevPoints = previousPointsRef.current;
var animationId = useAnimationId(props, 'recharts-line-');
var [isAnimating, setIsAnimating] = useState(false);
var showLabels = !isAnimating;
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
var totalLength = getTotalLength(pathRef.current);
/*
* Here we want to detect if the length animation has been interrupted.
* For that we keep a reference to the furthest length that has been animated.
*
* And then, to keep things smooth, we add to it the current length that is being animated right now.
*
* If we did Math.max then it makes the length animation "pause" but we want to keep it smooth
* so in case we have some "leftover" length from the previous animation we add it to the current length.
*
* This is not perfect because the animation changes speed due to easing. The default easing is 'ease' which is not linear
* and makes it stand out. But it's good enough I suppose.
* If we want to fix it then we need to keep track of multiple animations and their easing and timings.
*
* If you want to see this in action, try to change the dataKey of the line chart while the initial animation is running.
* The Line begins with zero length and slowly grows to the full length. While this growth is in progress,
* change the dataKey and the Line will continue growing from where it has grown so far.
*/
var startingPoint = longestAnimatedLengthRef.current;
return /*#__PURE__*/React.createElement(LineLabelListProvider, {
points: points,
showLabels: showLabels
}, props.children, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
onAnimationEnd: handleAnimationEnd,
onAnimationStart: handleAnimationStart,
key: animationId
}, t => {
var lengthInterpolated = interpolate(startingPoint, totalLength + startingPoint, t);
var curLength = Math.min(lengthInterpolated, totalLength);
var currentStrokeDasharray;
if (isAnimationActive) {
if (strokeDasharray) {
var lines = "".concat(strokeDasharray).split(/[,\s]+/gim).map(num => parseFloat(num));
currentStrokeDasharray = getStrokeDasharray(curLength, totalLength, lines);
} else {
currentStrokeDasharray = generateSimpleStrokeDasharray(totalLength, curLength);
}
} else {
currentStrokeDasharray = strokeDasharray == null ? undefined : String(strokeDasharray);
}
if (prevPoints) {
var prevPointsDiffFactor = prevPoints.length / points.length;
var stepData = t === 1 ? points : points.map((entry, index) => {
var prevPointIndex = Math.floor(index * prevPointsDiffFactor);
if (prevPoints[prevPointIndex]) {
var prev = prevPoints[prevPointIndex];
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(prev.x, entry.x, t),
y: interpolate(prev.y, entry.y, t)
});
}
// magic number of faking previous x and y location
if (animateNewValues) {
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(width * 2, entry.x, t),
y: interpolate(height / 2, entry.y, t)
});
}
return _objectSpread(_objectSpread({}, entry), {}, {
x: entry.x,
y: entry.y
});
});
// eslint-disable-next-line no-param-reassign
previousPointsRef.current = stepData;
return /*#__PURE__*/React.createElement(StaticCurve, {
props: props,
points: stepData,
clipPathId: clipPathId,
pathRef: pathRef,
strokeDasharray: currentStrokeDasharray
});
}
/*
* Here it is important to wait a little bit with updating the previousPointsRef
* before the animation has a time to initialize.
* If we set the previous pointsRef immediately, we set it before the Legend height it calculated
* and before pathRef is set.
* If that happens, the Line will re-render again after Legend had reported its height
* which will start a new animation with the previous points as the starting point
* which gives the effect of the Line animating slightly upwards (where the animation distance equals the Legend height).
* Waiting for t > 0 is indirect but good enough to ensure that the Legend height is calculated and animation works properly.
*
* Total length similarly is calculated from the pathRef. We should not update the previousPointsRef
* before the pathRef is set, otherwise we will have a wrong total length.
*/
if (t > 0 && totalLength > 0) {
// eslint-disable-next-line no-param-reassign
previousPointsRef.current = points;
/*
* totalLength is set from a ref and is not updated in the first tick of the animation.
* It defaults to zero which is exactly what we want here because we want to grow from zero,
* however the same happens when the data change.
*
* In that case we want to remember the previous length and continue from there, and only animate the shape.
*
* Therefore the totalLength > 0 check.
*
* The Animate is about to fire handleAnimationStart which will update the state
* and cause a re-render and read a new proper totalLength which will be used in the next tick
* and update the longestAnimatedLengthRef.
*/
// eslint-disable-next-line no-param-reassign
longestAnimatedLengthRef.current = curLength;
}
return /*#__PURE__*/React.createElement(StaticCurve, {
props: props,
points: points,
clipPathId: clipPathId,
pathRef: pathRef,
strokeDasharray: currentStrokeDasharray
});
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}));
}
function RenderCurve(_ref5) {
var {
clipPathId,
props
} = _ref5;
var previousPointsRef = useRef(null);
var longestAnimatedLengthRef = useRef(0);
var pathRef = useRef(null);
return /*#__PURE__*/React.createElement(CurveWithAnimation, {
props: props,
clipPathId: clipPathId,
previousPointsRef: previousPointsRef,
longestAnimatedLengthRef: longestAnimatedLengthRef,
pathRef: pathRef
});
}
var errorBarDataPointFormatter = (dataPoint, dataKey) => {
var _dataPoint$x, _dataPoint$y;
return {
x: (_dataPoint$x = dataPoint.x) !== null && _dataPoint$x !== void 0 ? _dataPoint$x : undefined,
y: (_dataPoint$y = dataPoint.y) !== null && _dataPoint$y !== void 0 ? _dataPoint$y : undefined,
value: dataPoint.value,
// @ts-expect-error getValueByDataKey does not validate the output type
errorVal: getValueByDataKey(dataPoint.payload, dataKey)
};
};
// eslint-disable-next-line react/prefer-stateless-function
class LineWithState extends Component {
render() {
var {
hide,
dot,
points,
className,
xAxisId,
yAxisId,
top,
left,
width,
height,
id,
needClip,
zIndex
} = this.props;
if (hide) {
return null;
}
var layerClass = clsx('recharts-line', className);
var clipPathId = id;
var {
r,
strokeWidth
} = getRadiusAndStrokeWidthFromDot(dot);
var clipDot = isClipDot(dot);
var dotSize = r * 2 + strokeWidth;
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, needClip && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement(GraphicalItemClipPath, {
clipPathId: clipPathId,
xAxisId: xAxisId,
yAxisId: yAxisId
}), !clipDot && /*#__PURE__*/React.createElement("clipPath", {
id: "clipPath-dots-".concat(clipPathId)
}, /*#__PURE__*/React.createElement("rect", {
x: left - dotSize / 2,
y: top - dotSize / 2,
width: width + dotSize,
height: height + dotSize
}))), /*#__PURE__*/React.createElement(SetErrorBarContext, {
xAxisId: xAxisId,
yAxisId: yAxisId,
data: points,
dataPointFormatter: errorBarDataPointFormatter,
errorBarOffset: 0
}, /*#__PURE__*/React.createElement(RenderCurve, {
props: this.props,
clipPathId: clipPathId
}))), /*#__PURE__*/React.createElement(ActivePoints, {
activeDot: this.props.activeDot,
points: points,
mainColor: this.props.stroke,
itemDataKey: this.props.dataKey
}));
}
}
var defaultLineProps = {
activeDot: true,
animateNewValues: true,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease',
connectNulls: false,
dot: true,
fill: '#fff',
hide: false,
isAnimationActive: !Global.isSsr,
label: false,
legendType: 'line',
stroke: '#3182bd',
strokeWidth: 1,
xAxisId: 0,
yAxisId: 0,
zIndex: DefaultZIndexes.line
};
function LineImpl(props) {
var _resolveDefaultProps = resolveDefaultProps(props, defaultLineProps),
{
activeDot,
animateNewValues,
animationBegin,
animationDuration,
animationEasing,
connectNulls,
dot,
hide,
isAnimationActive,
label,
legendType,
xAxisId,
yAxisId,
id
} = _resolveDefaultProps,
everythingElse = _objectWithoutProperties(_resolveDefaultProps, _excluded3);
var {
needClip
} = useNeedsClip(xAxisId, yAxisId);
var plotArea = usePlotArea();
var layout = useChartLayout();
var isPanorama = useIsPanorama();
var points = useAppSelector(state => selectLinePoints(state, xAxisId, yAxisId, isPanorama, id));
if (layout !== 'horizontal' && layout !== 'vertical' || points == null || plotArea == null) {
// Cannot render Line in an unsupported layout
return null;
}
var {
height,
width,
x: left,
y: top
} = plotArea;
return /*#__PURE__*/React.createElement(LineWithState, _extends({}, everythingElse, {
id: id,
connectNulls: connectNulls,
dot: dot,
activeDot: activeDot,
animateNewValues: animateNewValues,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
isAnimationActive: isAnimationActive,
hide: hide,
label: label,
legendType: legendType,
xAxisId: xAxisId,
yAxisId: yAxisId,
points: points,
layout: layout,
height: height,
width: width,
left: left,
top: top,
needClip: needClip
}));
}
export function computeLinePoints(_ref6) {
var {
layout,
xAxis,
yAxis,
xAxisTicks,
yAxisTicks,
dataKey,
bandSize,
displayedData
} = _ref6;
return displayedData.map((entry, index) => {
// @ts-expect-error getValueByDataKey does not validate the output type
var value = getValueByDataKey(entry, dataKey);
if (layout === 'horizontal') {
var _x = getCateCoordinateOfLine({
axis: xAxis,
ticks: xAxisTicks,
bandSize,
entry,
index
});
var _y = isNullish(value) ? null : yAxis.scale(value);
return {
x: _x,
y: _y,
value,
payload: entry
};
}
var x = isNullish(value) ? null : xAxis.scale(value);
var y = getCateCoordinateOfLine({
axis: yAxis,
ticks: yAxisTicks,
bandSize,
entry,
index
});
if (x == null || y == null) {
return null;
}
return {
x,
y,
value,
payload: entry
};
}).filter(Boolean);
}
function LineFn(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultLineProps);
var isPanorama = useIsPanorama();
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "line"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetLegendPayload, {
legendPayload: computeLegendPayloadFromAreaData(props)
}), /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: props
}), /*#__PURE__*/React.createElement(SetCartesianGraphicalItem, {
type: "line",
id: id,
data: props.data,
xAxisId: props.xAxisId,
yAxisId: props.yAxisId,
zAxisId: 0,
dataKey: props.dataKey,
hide: props.hide,
isPanorama: isPanorama
}), /*#__PURE__*/React.createElement(LineImpl, _extends({}, props, {
id: id
}))));
}
export var Line = /*#__PURE__*/React.memo(LineFn);
Line.displayName = 'Line';

View File

@@ -0,0 +1,150 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { useEffect } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { CartesianLabelContextProvider, CartesianLabelFromLabelProp } from '../component/Label';
import { createLabeledScales, rectWithPoints } from '../util/CartesianUtils';
import { isNumOrStr } from '../util/DataUtils';
import { Rectangle } from '../shape/Rectangle';
import { addArea, removeArea } from '../state/referenceElementsSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { selectAxisScale } from '../state/selectors/axisSelectors';
import { useIsPanorama } from '../context/PanoramaContext';
import { useClipPathId } from '../container/ClipPathProvider';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
var getRect = (hasX1, hasX2, hasY1, hasY2, xAxisScale, yAxisScale, props) => {
var {
x1: xValue1,
x2: xValue2,
y1: yValue1,
y2: yValue2
} = props;
if (xAxisScale == null || yAxisScale == null) {
return null;
}
var scales = createLabeledScales({
x: xAxisScale,
y: yAxisScale
});
var p1 = {
x: hasX1 ? scales.x.apply(xValue1, {
position: 'start'
}) : scales.x.rangeMin,
y: hasY1 ? scales.y.apply(yValue1, {
position: 'start'
}) : scales.y.rangeMin
};
var p2 = {
x: hasX2 ? scales.x.apply(xValue2, {
position: 'end'
}) : scales.x.rangeMax,
y: hasY2 ? scales.y.apply(yValue2, {
position: 'end'
}) : scales.y.rangeMax
};
if (props.ifOverflow === 'discard' && (!scales.isInRange(p1) || !scales.isInRange(p2))) {
return null;
}
return rectWithPoints(p1, p2);
};
var renderRect = (option, props) => {
var rect;
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error element cloning is not typed
rect = /*#__PURE__*/React.cloneElement(option, props);
} else if (typeof option === 'function') {
rect = option(props);
} else {
rect = /*#__PURE__*/React.createElement(Rectangle, _extends({}, props, {
className: "recharts-reference-area-rect"
}));
}
return rect;
};
function ReportReferenceArea(props) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(addArea(props));
return () => {
dispatch(removeArea(props));
};
});
return null;
}
function ReferenceAreaImpl(props) {
var {
x1,
x2,
y1,
y2,
className,
shape,
xAxisId,
yAxisId
} = props;
var clipPathId = useClipPathId();
var isPanorama = useIsPanorama();
var xAxisScale = useAppSelector(state => selectAxisScale(state, 'xAxis', xAxisId, isPanorama));
var yAxisScale = useAppSelector(state => selectAxisScale(state, 'yAxis', yAxisId, isPanorama));
if (xAxisScale == null || !yAxisScale == null) {
return null;
}
var hasX1 = isNumOrStr(x1);
var hasX2 = isNumOrStr(x2);
var hasY1 = isNumOrStr(y1);
var hasY2 = isNumOrStr(y2);
if (!hasX1 && !hasX2 && !hasY1 && !hasY2 && !shape) {
return null;
}
var rect = getRect(hasX1, hasX2, hasY1, hasY2, xAxisScale, yAxisScale, props);
if (!rect && !shape) {
return null;
}
var isOverflowHidden = props.ifOverflow === 'hidden';
var clipPath = isOverflowHidden ? "url(#".concat(clipPathId, ")") : undefined;
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: clsx('recharts-reference-area', className)
}, renderRect(shape, _objectSpread(_objectSpread({
clipPath
}, svgPropertiesAndEvents(props)), rect)), rect != null && /*#__PURE__*/React.createElement(CartesianLabelContextProvider, _extends({}, rect, {
lowerWidth: rect.width,
upperWidth: rect.width
}), /*#__PURE__*/React.createElement(CartesianLabelFromLabelProp, {
label: props.label
}), props.children)));
}
var referenceAreaDefaultProps = {
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
r: 10,
fill: '#ccc',
fillOpacity: 0.5,
stroke: 'none',
strokeWidth: 1,
zIndex: DefaultZIndexes.area
};
export function ReferenceArea(outsideProps) {
var props = resolveDefaultProps(outsideProps, referenceAreaDefaultProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportReferenceArea, {
yAxisId: props.yAxisId,
xAxisId: props.xAxisId,
ifOverflow: props.ifOverflow,
x1: props.x1,
x2: props.x2,
y1: props.y1,
y2: props.y2
}), /*#__PURE__*/React.createElement(ReferenceAreaImpl, props));
}
ReferenceArea.displayName = 'ReferenceArea';

View File

@@ -0,0 +1,146 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { useEffect } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { Dot } from '../shape/Dot';
import { CartesianLabelContextProvider, CartesianLabelFromLabelProp } from '../component/Label';
import { isNumOrStr } from '../util/DataUtils';
import { createLabeledScales } from '../util/CartesianUtils';
import { addDot, removeDot } from '../state/referenceElementsSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { selectAxisScale } from '../state/selectors/axisSelectors';
import { useIsPanorama } from '../context/PanoramaContext';
import { useClipPathId } from '../container/ClipPathProvider';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
var useCoordinate = (x, y, xAxisId, yAxisId, ifOverflow) => {
var isX = isNumOrStr(x);
var isY = isNumOrStr(y);
var isPanorama = useIsPanorama();
var xAxisScale = useAppSelector(state => selectAxisScale(state, 'xAxis', xAxisId, isPanorama));
var yAxisScale = useAppSelector(state => selectAxisScale(state, 'yAxis', yAxisId, isPanorama));
if (!isX || !isY || xAxisScale == null || yAxisScale == null) {
return null;
}
var scales = createLabeledScales({
x: xAxisScale,
y: yAxisScale
});
var result = scales.apply({
x,
y
}, {
bandAware: true
});
if (ifOverflow === 'discard' && !scales.isInRange(result)) {
return null;
}
return result;
};
function ReportReferenceDot(props) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(addDot(props));
return () => {
dispatch(removeDot(props));
};
});
return null;
}
var renderDot = (option, props) => {
var dot;
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error element cloning is not typed
dot = /*#__PURE__*/React.cloneElement(option, props);
} else if (typeof option === 'function') {
dot = option(props);
} else {
dot = /*#__PURE__*/React.createElement(Dot, _extends({}, props, {
cx: props.cx,
cy: props.cy,
className: "recharts-reference-dot-dot"
}));
}
return dot;
};
function ReferenceDotImpl(props) {
var {
x,
y,
r
} = props;
var clipPathId = useClipPathId();
var coordinate = useCoordinate(x, y, props.xAxisId, props.yAxisId, props.ifOverflow);
if (!coordinate) {
return null;
}
var {
x: cx,
y: cy
} = coordinate;
var {
shape,
className,
ifOverflow
} = props;
var clipPath = ifOverflow === 'hidden' ? "url(#".concat(clipPathId, ")") : undefined;
var dotProps = _objectSpread(_objectSpread({
clipPath
}, svgPropertiesAndEvents(props)), {}, {
cx,
cy
});
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: clsx('recharts-reference-dot', className)
}, renderDot(shape, dotProps), /*#__PURE__*/React.createElement(CartesianLabelContextProvider, {
x: cx - r,
y: cy - r,
width: 2 * r,
height: 2 * r,
upperWidth: 2 * r,
lowerWidth: 2 * r
}, /*#__PURE__*/React.createElement(CartesianLabelFromLabelProp, {
label: props.label
}), props.children)));
}
var referenceDotDefaultProps = {
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
r: 10,
fill: '#fff',
stroke: '#ccc',
fillOpacity: 1,
strokeWidth: 1,
zIndex: DefaultZIndexes.scatter
};
export function ReferenceDot(outsideProps) {
var props = resolveDefaultProps(outsideProps, referenceDotDefaultProps);
var {
x,
y,
r,
ifOverflow,
yAxisId,
xAxisId
} = props;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportReferenceDot, {
y: y,
x: x,
r: r,
yAxisId: yAxisId,
xAxisId: xAxisId,
ifOverflow: ifOverflow
}), /*#__PURE__*/React.createElement(ReferenceDotImpl, props));
}
ReferenceDot.displayName = 'ReferenceDot';

View File

@@ -0,0 +1,228 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/**
* @fileOverview Reference Line
*/
import * as React from 'react';
import { useEffect } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { CartesianLabelContextProvider, CartesianLabelFromLabelProp } from '../component/Label';
import { isNan, isNumOrStr } from '../util/DataUtils';
import { createLabeledScales, rectWithCoords } from '../util/CartesianUtils';
import { useViewBox } from '../context/chartLayoutContext';
import { addLine, removeLine } from '../state/referenceElementsSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { selectAxisScale, selectXAxisSettings, selectYAxisSettings } from '../state/selectors/axisSelectors';
import { useIsPanorama } from '../context/PanoramaContext';
import { useClipPathId } from '../container/ClipPathProvider';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
import { isWellBehavedNumber } from '../util/isWellBehavedNumber';
/**
* Single point that defines one end of a segment.
* These coordinates are in data space, meaning that you should provide
* values that correspond to the data domain of the axes.
* So you would provide a value of `Page A` to indicate the data value `Page A`
* and then recharts will convert that to pixels.
*
* Likewise for numbers. If your x-axis goes from 0 to 100,
* and you want the line to end at 50, you would provide `50` here.
*/
/**
* This excludes `viewBox` prop from svg for two reasons:
* 1. The components wants viewBox of object type, and svg wants string
* - so there's a conflict, and the component will throw if it gets string
* 2. Internally the component calls `svgPropertiesNoEvents` which filters the viewBox away anyway
*/
var renderLine = (option, props) => {
var line;
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error element cloning is not typed
line = /*#__PURE__*/React.cloneElement(option, props);
} else if (typeof option === 'function') {
line = option(props);
} else {
if (!isWellBehavedNumber(props.x1) || !isWellBehavedNumber(props.y1) || !isWellBehavedNumber(props.x2) || !isWellBehavedNumber(props.y2)) {
return null;
}
line = /*#__PURE__*/React.createElement("line", _extends({}, props, {
className: "recharts-reference-line-line"
}));
}
return line;
};
var getHorizontalLineEndPoints = (yCoord, ifOverflow, position, yAxisOrientation, scales, viewBox) => {
var {
x,
width
} = viewBox;
var coord = scales.y.apply(yCoord, {
position
});
// don't render the line if the scale can't compute a result that makes sense
if (isNan(coord)) return null;
if (ifOverflow === 'discard' && !scales.y.isInRange(coord)) {
return null;
}
var points = [{
x: x + width,
y: coord
}, {
x,
y: coord
}];
return yAxisOrientation === 'left' ? points.reverse() : points;
};
var getVerticalLineEndPoints = (xCoord, ifOverflow, position, xAxisOrientation, scales, viewBox) => {
var {
y,
height
} = viewBox;
var coord = scales.x.apply(xCoord, {
position
});
// don't render the line if the scale can't compute a result that makes sense
if (isNan(coord)) return null;
if (ifOverflow === 'discard' && !scales.x.isInRange(coord)) {
return null;
}
var points = [{
x: coord,
y: y + height
}, {
x: coord,
y
}];
return xAxisOrientation === 'top' ? points.reverse() : points;
};
var getSegmentLineEndPoints = (segment, ifOverflow, position, scales) => {
var points = segment.map(p => scales.apply(p, {
position
}));
if (ifOverflow === 'discard' && points.some(p => !scales.isInRange(p))) {
return null;
}
return points;
};
export var getEndPoints = (scales, viewBox, position, xAxisOrientation, yAxisOrientation, props) => {
var {
x: xCoord,
y: yCoord,
segment,
ifOverflow
} = props;
var isFixedX = isNumOrStr(xCoord);
var isFixedY = isNumOrStr(yCoord);
if (isFixedY) {
return getHorizontalLineEndPoints(yCoord, ifOverflow, position, yAxisOrientation, scales, viewBox);
}
if (isFixedX) {
return getVerticalLineEndPoints(xCoord, ifOverflow, position, xAxisOrientation, scales, viewBox);
}
if (segment != null && segment.length === 2) {
return getSegmentLineEndPoints(segment, ifOverflow, position, scales);
}
return null;
};
function ReportReferenceLine(props) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(addLine(props));
return () => {
dispatch(removeLine(props));
};
});
return null;
}
function ReferenceLineImpl(props) {
var {
xAxisId,
yAxisId,
shape,
className,
ifOverflow
} = props;
var isPanorama = useIsPanorama();
var clipPathId = useClipPathId();
var xAxis = useAppSelector(state => selectXAxisSettings(state, xAxisId));
var yAxis = useAppSelector(state => selectYAxisSettings(state, yAxisId));
var xAxisScale = useAppSelector(state => selectAxisScale(state, 'xAxis', xAxisId, isPanorama));
var yAxisScale = useAppSelector(state => selectAxisScale(state, 'yAxis', yAxisId, isPanorama));
var viewBox = useViewBox();
if (!clipPathId || !viewBox || xAxis == null || yAxis == null || xAxisScale == null || yAxisScale == null) {
return null;
}
var scales = createLabeledScales({
x: xAxisScale,
y: yAxisScale
});
var endPoints = getEndPoints(scales, viewBox, props.position, xAxis.orientation, yAxis.orientation, props);
if (!endPoints) {
return null;
}
var [{
x: x1,
y: y1
}, {
x: x2,
y: y2
}] = endPoints;
var clipPath = ifOverflow === 'hidden' ? "url(#".concat(clipPathId, ")") : undefined;
var lineProps = _objectSpread(_objectSpread({
clipPath
}, svgPropertiesAndEvents(props)), {}, {
x1,
y1,
x2,
y2
});
var rect = rectWithCoords({
x1,
y1,
x2,
y2
});
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: clsx('recharts-reference-line', className)
}, renderLine(shape, lineProps), /*#__PURE__*/React.createElement(CartesianLabelContextProvider, _extends({}, rect, {
lowerWidth: rect.width,
upperWidth: rect.width
}), /*#__PURE__*/React.createElement(CartesianLabelFromLabelProp, {
label: props.label
}), props.children)));
}
var referenceLineDefaultProps = {
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
fill: 'none',
stroke: '#ccc',
fillOpacity: 1,
strokeWidth: 1,
position: 'middle',
zIndex: DefaultZIndexes.line
};
export function ReferenceLine(outsideProps) {
var props = resolveDefaultProps(outsideProps, referenceLineDefaultProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportReferenceLine, {
yAxisId: props.yAxisId,
xAxisId: props.xAxisId,
ifOverflow: props.ifOverflow,
x: props.x,
y: props.y,
segment: props.segment
}), /*#__PURE__*/React.createElement(ReferenceLineImpl, props));
}
ReferenceLine.displayName = 'ReferenceLine';

586
frontend/node_modules/recharts/es6/cartesian/Scatter.js generated vendored Normal file
View File

@@ -0,0 +1,586 @@
var _excluded = ["onMouseEnter", "onClick", "onMouseLeave"],
_excluded2 = ["id"],
_excluded3 = ["animationBegin", "animationDuration", "animationEasing", "hide", "isAnimationActive", "legendType", "lineJointType", "lineType", "shape", "xAxisId", "yAxisId", "zAxisId"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { findAllByType } from '../util/ReactUtils';
import { Global } from '../util/Global';
import { Curve } from '../shape/Curve';
import { Cell } from '../component/Cell';
import { getLinearRegression, interpolate, isNullish } from '../util/DataUtils';
import { getCateCoordinateOfLine, getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
import { adaptEventsOfChild, isNonEmptyArray } from '../util/types';
import { ScatterSymbol } from '../util/ScatterUtils';
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { SetErrorBarContext } from '../context/ErrorBarContext';
import { GraphicalItemClipPath, useNeedsClip } from './GraphicalItemClipPath';
import { selectScatterPoints } from '../state/selectors/scatterSelectors';
import { useAppSelector } from '../state/hooks';
import { implicitZAxis } from '../state/selectors/axisSelectors';
import { useIsPanorama } from '../context/PanoramaContext';
import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
import { SetLegendPayload } from '../state/SetLegendPayload';
import { DATA_ITEM_DATAKEY_ATTRIBUTE_NAME, DATA_ITEM_INDEX_ATTRIBUTE_NAME } from '../util/Constants';
import { useAnimationId } from '../util/useAnimationId';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetCartesianGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { useViewBox } from '../context/chartLayoutContext';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* Scatter coordinates are nullable because sometimes the point value is out of the domain
* and we can't compute a valid coordinate for it.
*
* Scatter -> Symbol ignores points with null cx or cy so those won't render if using the default shapes.
* However the points are exposed via various props and can be used in custom shapes so we keep them around.
*/
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
/**
* External props, intended for end users to fill in
*/
/**
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
*/
var computeLegendPayloadFromScatterProps = props => {
var {
dataKey,
name,
fill,
legendType,
hide
} = props;
return [{
inactive: hide,
dataKey,
type: legendType,
color: fill,
value: getTooltipNameProp(name, dataKey),
payload: props
}];
};
function ScatterLine(_ref) {
var {
points,
props
} = _ref;
var {
line,
lineType,
lineJointType
} = props;
if (!line) {
return null;
}
var scatterProps = svgPropertiesNoEvents(props);
var customLineProps = svgPropertiesNoEventsFromUnknown(line);
var linePoints, lineItem;
if (lineType === 'joint') {
linePoints = points.map(entry => {
var _entry$cx, _entry$cy;
return {
x: (_entry$cx = entry.cx) !== null && _entry$cx !== void 0 ? _entry$cx : null,
y: (_entry$cy = entry.cy) !== null && _entry$cy !== void 0 ? _entry$cy : null
};
});
} else if (lineType === 'fitting') {
var {
xmin,
xmax,
a,
b
} = getLinearRegression(points);
var linearExp = x => a * x + b;
linePoints = [{
x: xmin,
y: linearExp(xmin)
}, {
x: xmax,
y: linearExp(xmax)
}];
}
var lineProps = _objectSpread(_objectSpread(_objectSpread({}, scatterProps), {}, {
// @ts-expect-error customLineProps is contributing unknown props
fill: 'none',
// @ts-expect-error customLineProps is contributing unknown props
stroke: scatterProps && scatterProps.fill
}, customLineProps), {}, {
// @ts-expect-error linePoints is used before it is assigned (???)
points: linePoints
});
if (/*#__PURE__*/React.isValidElement(line)) {
lineItem = /*#__PURE__*/React.cloneElement(line, lineProps);
} else if (typeof line === 'function') {
lineItem = line(lineProps);
} else {
lineItem = /*#__PURE__*/React.createElement(Curve, _extends({}, lineProps, {
type: lineJointType
}));
}
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-scatter-line",
key: "recharts-scatter-line"
}, lineItem);
}
function ScatterLabelListProvider(_ref2) {
var {
showLabels,
points,
children
} = _ref2;
var chartViewBox = useViewBox();
var labelListEntries = useMemo(() => {
return points === null || points === void 0 ? void 0 : points.map(point => {
var _point$x, _point$y;
var viewBox = {
/*
* Scatter label uses x and y as the reference point for the label,
* not cx and cy.
*/
x: (_point$x = point.x) !== null && _point$x !== void 0 ? _point$x : 0,
/*
* Scatter label uses x and y as the reference point for the label,
* not cx and cy.
*/
y: (_point$y = point.y) !== null && _point$y !== void 0 ? _point$y : 0,
width: point.width,
height: point.height,
lowerWidth: point.width,
upperWidth: point.width
};
return _objectSpread(_objectSpread({}, viewBox), {}, {
/*
* Here we put undefined because Scatter shows two values usually, one for X and one for Y.
* LabelList will see this undefined and will use its own `dataKey` prop to determine which value to show,
* using the payload below.
*/
value: undefined,
payload: point.payload,
viewBox,
parentViewBox: chartViewBox,
fill: undefined
});
});
}, [chartViewBox, points]);
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function ScatterSymbols(props) {
var {
points,
allOtherScatterProps
} = props;
var {
shape,
activeShape,
dataKey
} = allOtherScatterProps;
var activeIndex = useAppSelector(selectActiveTooltipIndex);
var {
onMouseEnter: onMouseEnterFromProps,
onClick: onItemClickFromProps,
onMouseLeave: onMouseLeaveFromProps
} = allOtherScatterProps,
restOfAllOtherProps = _objectWithoutProperties(allOtherScatterProps, _excluded);
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherScatterProps.dataKey);
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherScatterProps.dataKey);
if (!isNonEmptyArray(points)) {
return null;
}
var {
id
} = allOtherScatterProps,
allOtherPropsWithoutId = _objectWithoutProperties(allOtherScatterProps, _excluded2);
var baseProps = svgPropertiesNoEvents(allOtherPropsWithoutId);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScatterLine, {
points: points,
props: allOtherPropsWithoutId
}), points.map((entry, i) => {
var hasActiveShape = activeShape != null && activeShape !== false;
var isActive = hasActiveShape && activeIndex === String(i);
var option = hasActiveShape && isActive ? activeShape : shape;
var symbolProps = _objectSpread(_objectSpread(_objectSpread({
key: "symbol-".concat(i)
}, baseProps), entry), {}, {
[DATA_ITEM_INDEX_ATTRIBUTE_NAME]: i,
[DATA_ITEM_DATAKEY_ATTRIBUTE_NAME]: String(dataKey)
});
return /*#__PURE__*/React.createElement(ZIndexLayer, {
key: "symbol-".concat(entry === null || entry === void 0 ? void 0 : entry.cx, "-").concat(entry === null || entry === void 0 ? void 0 : entry.cy, "-").concat(entry === null || entry === void 0 ? void 0 : entry.size, "-").concat(i)
/*
* inactive Scatters use the parent zIndex, which is represented by undefined here.
* ZIndexLayer will render undefined zIndex as-is, as regular children, without portals.
* Active Scatters use the activeDot zIndex so they render above other elements.
*/,
zIndex: isActive ? DefaultZIndexes.activeDot : undefined
}, /*#__PURE__*/React.createElement(Layer, _extends({
className: "recharts-scatter-symbol"
}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
// @ts-expect-error the types need a bit of attention
onMouseEnter: onMouseEnterFromContext(entry, i)
// @ts-expect-error the types need a bit of attention
,
onMouseLeave: onMouseLeaveFromContext(entry, i)
// @ts-expect-error the types need a bit of attention
,
onClick: onClickFromContext(entry, i)
}), /*#__PURE__*/React.createElement(ScatterSymbol, _extends({
option: option,
isActive: isActive
}, symbolProps))));
}));
}
function SymbolsWithAnimation(_ref3) {
var {
previousPointsRef,
props
} = _ref3;
var {
points,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing
} = props;
var prevPoints = previousPointsRef.current;
var animationId = useAnimationId(props, 'recharts-scatter-');
var [isAnimating, setIsAnimating] = useState(false);
var handleAnimationEnd = useCallback(() => {
// Scatter doesn't have onAnimationEnd prop, and if we want to add it we do it here
// if (typeof onAnimationEnd === 'function') {
// onAnimationEnd();
// }
setIsAnimating(false);
}, []);
var handleAnimationStart = useCallback(() => {
// Scatter doesn't have onAnimationStart prop, and if we want to add it we do it here
// if (typeof onAnimationStart === 'function') {
// onAnimationStart();
// }
setIsAnimating(true);
}, []);
var showLabels = !isAnimating;
return /*#__PURE__*/React.createElement(ScatterLabelListProvider, {
showLabels: showLabels,
points: points
}, props.children, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
onAnimationEnd: handleAnimationEnd,
onAnimationStart: handleAnimationStart,
key: animationId
}, t => {
var stepData = t === 1 ? points : points === null || points === void 0 ? void 0 : points.map((entry, index) => {
var prev = prevPoints && prevPoints[index];
if (prev) {
return _objectSpread(_objectSpread({}, entry), {}, {
cx: entry.cx == null ? undefined : interpolate(prev.cx, entry.cx, t),
cy: entry.cy == null ? undefined : interpolate(prev.cy, entry.cy, t),
size: interpolate(prev.size, entry.size, t)
});
}
return _objectSpread(_objectSpread({}, entry), {}, {
size: interpolate(0, entry.size, t)
});
});
if (t > 0) {
// eslint-disable-next-line no-param-reassign
previousPointsRef.current = stepData;
}
return /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement(ScatterSymbols, {
points: stepData,
allOtherScatterProps: props,
showLabels: showLabels
}));
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}));
}
function getTooltipEntrySettings(props) {
var {
dataKey,
points,
stroke,
strokeWidth,
fill,
name,
hide,
tooltipType
} = props;
return {
dataDefinedOnItem: points === null || points === void 0 ? void 0 : points.map(p => p.tooltipPayload),
positions: points === null || points === void 0 ? void 0 : points.map(p => p.tooltipPosition),
settings: {
stroke,
strokeWidth,
fill,
nameKey: undefined,
dataKey,
name: getTooltipNameProp(name, dataKey),
hide,
type: tooltipType,
color: fill,
unit: '' // why doesn't Scatter support unit?
}
};
}
export function computeScatterPoints(_ref4) {
var {
displayedData,
xAxis,
yAxis,
zAxis,
scatterSettings,
xAxisTicks,
yAxisTicks,
cells
} = _ref4;
var xAxisDataKey = isNullish(xAxis.dataKey) ? scatterSettings.dataKey : xAxis.dataKey;
var yAxisDataKey = isNullish(yAxis.dataKey) ? scatterSettings.dataKey : yAxis.dataKey;
var zAxisDataKey = zAxis && zAxis.dataKey;
var defaultRangeZ = zAxis ? zAxis.range : implicitZAxis.range;
var defaultZ = defaultRangeZ && defaultRangeZ[0];
var xBandSize = xAxis.scale.bandwidth ? xAxis.scale.bandwidth() : 0;
var yBandSize = yAxis.scale.bandwidth ? yAxis.scale.bandwidth() : 0;
return displayedData.map((entry, index) => {
var x = getValueByDataKey(entry, xAxisDataKey);
var y = getValueByDataKey(entry, yAxisDataKey);
var z = !isNullish(zAxisDataKey) && getValueByDataKey(entry, zAxisDataKey) || '-';
var tooltipPayload = [{
name: isNullish(xAxis.dataKey) ? scatterSettings.name : xAxis.name || String(xAxis.dataKey),
unit: xAxis.unit || '',
// @ts-expect-error getValueByDataKey does not validate the output type
value: x,
payload: entry,
dataKey: xAxisDataKey,
type: scatterSettings.tooltipType
}, {
name: isNullish(yAxis.dataKey) ? scatterSettings.name : yAxis.name || String(yAxis.dataKey),
unit: yAxis.unit || '',
// @ts-expect-error getValueByDataKey does not validate the output type
value: y,
payload: entry,
dataKey: yAxisDataKey,
type: scatterSettings.tooltipType
}];
if (z !== '-') {
tooltipPayload.push({
// @ts-expect-error name prop should not have dataKey in it
name: zAxis.name || zAxis.dataKey,
unit: zAxis.unit || '',
// @ts-expect-error getValueByDataKey does not validate the output type
value: z,
payload: entry,
dataKey: zAxisDataKey,
type: scatterSettings.tooltipType
});
}
var cx = getCateCoordinateOfLine({
axis: xAxis,
ticks: xAxisTicks,
bandSize: xBandSize,
entry,
index,
dataKey: xAxisDataKey
});
var cy = getCateCoordinateOfLine({
axis: yAxis,
ticks: yAxisTicks,
bandSize: yBandSize,
entry,
index,
dataKey: yAxisDataKey
});
var size = z !== '-' ? zAxis.scale(z) : defaultZ;
var radius = Math.sqrt(Math.max(size, 0) / Math.PI);
return _objectSpread(_objectSpread({}, entry), {}, {
cx,
cy,
x: cx == null ? undefined : cx - radius,
y: cy == null ? undefined : cy - radius,
width: 2 * radius,
height: 2 * radius,
size,
node: {
x,
y,
z
},
tooltipPayload,
tooltipPosition: {
x: cx,
y: cy
},
payload: entry
}, cells && cells[index] && cells[index].props);
});
}
var errorBarDataPointFormatter = (dataPoint, dataKey, direction) => {
return {
x: dataPoint.cx,
y: dataPoint.cy,
value: direction === 'x' ? Number(dataPoint.node.x) : Number(dataPoint.node.y),
// @ts-expect-error getValueByDataKey does not validate the output type
errorVal: getValueByDataKey(dataPoint, dataKey)
};
};
function ScatterWithId(props) {
var {
hide,
points,
className,
needClip,
xAxisId,
yAxisId,
id
} = props;
var previousPointsRef = useRef(null);
if (hide) {
return null;
}
var layerClass = clsx('recharts-scatter', className);
var clipPathId = id;
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass,
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined,
id: id
}, needClip && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement(GraphicalItemClipPath, {
clipPathId: clipPathId,
xAxisId: xAxisId,
yAxisId: yAxisId
})), /*#__PURE__*/React.createElement(SetErrorBarContext, {
xAxisId: xAxisId,
yAxisId: yAxisId,
data: points,
dataPointFormatter: errorBarDataPointFormatter,
errorBarOffset: 0
}, /*#__PURE__*/React.createElement(Layer, {
key: "recharts-scatter-symbols"
}, /*#__PURE__*/React.createElement(SymbolsWithAnimation, {
props: props,
previousPointsRef: previousPointsRef
})))));
}
var defaultScatterProps = {
xAxisId: 0,
yAxisId: 0,
zAxisId: 0,
legendType: 'circle',
lineType: 'joint',
lineJointType: 'linear',
data: [],
shape: 'circle',
hide: false,
isAnimationActive: !Global.isSsr,
animationBegin: 0,
animationDuration: 400,
animationEasing: 'linear',
zIndex: DefaultZIndexes.scatter
};
function ScatterImpl(props) {
var _resolveDefaultProps = resolveDefaultProps(props, defaultScatterProps),
{
animationBegin,
animationDuration,
animationEasing,
hide,
isAnimationActive,
legendType,
lineJointType,
lineType,
shape,
xAxisId,
yAxisId,
zAxisId
} = _resolveDefaultProps,
everythingElse = _objectWithoutProperties(_resolveDefaultProps, _excluded3);
var {
needClip
} = useNeedsClip(xAxisId, yAxisId);
var cells = useMemo(() => findAllByType(props.children, Cell), [props.children]);
var isPanorama = useIsPanorama();
var points = useAppSelector(state => {
return selectScatterPoints(state, xAxisId, yAxisId, zAxisId, props.id, cells, isPanorama);
});
if (needClip == null) {
return null;
}
if (points == null) {
return null;
}
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: _objectSpread(_objectSpread({}, props), {}, {
points
})
}), /*#__PURE__*/React.createElement(ScatterWithId, _extends({}, everythingElse, {
xAxisId: xAxisId,
yAxisId: yAxisId,
zAxisId: zAxisId,
lineType: lineType,
lineJointType: lineJointType,
legendType: legendType,
shape: shape,
hide: hide,
isAnimationActive: isAnimationActive,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
points: points,
needClip: needClip
})));
}
function ScatterFn(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultScatterProps);
var isPanorama = useIsPanorama();
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "scatter"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetLegendPayload, {
legendPayload: computeLegendPayloadFromScatterProps(props)
}), /*#__PURE__*/React.createElement(SetCartesianGraphicalItem, {
type: "scatter",
id: id,
data: props.data,
xAxisId: props.xAxisId,
yAxisId: props.yAxisId,
zAxisId: props.zAxisId,
dataKey: props.dataKey,
hide: props.hide,
name: props.name,
tooltipType: props.tooltipType,
isPanorama: isPanorama
}), /*#__PURE__*/React.createElement(ScatterImpl, _extends({}, props, {
id: id
}))));
}
export var Scatter = /*#__PURE__*/React.memo(ScatterFn);
Scatter.displayName = 'Scatter';

142
frontend/node_modules/recharts/es6/cartesian/XAxis.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
var _excluded = ["dangerouslySetInnerHTML", "ticks"],
_excluded2 = ["id"],
_excluded3 = ["domain"],
_excluded4 = ["domain"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview X Axis
*/
import * as React from 'react';
import { useLayoutEffect } from 'react';
import { clsx } from 'clsx';
import { CartesianAxis } from './CartesianAxis';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { addXAxis, removeXAxis } from '../state/cartesianAxisSlice';
import { implicitXAxis, selectAxisScale, selectTicksOfAxis, selectXAxisPosition, selectXAxisSettingsNoDefaults, selectXAxisSize } from '../state/selectors/axisSelectors';
import { selectAxisViewBox } from '../state/selectors/selectChartOffsetInternal';
import { useIsPanorama } from '../context/PanoramaContext';
import { shallowEqual } from '../util/ShallowEqual';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
function SetXAxisSettings(settings) {
var dispatch = useAppDispatch();
useLayoutEffect(() => {
dispatch(addXAxis(settings));
return () => {
dispatch(removeXAxis(settings));
};
}, [settings, dispatch]);
return null;
}
var XAxisImpl = props => {
var {
xAxisId,
className
} = props;
var viewBox = useAppSelector(selectAxisViewBox);
var isPanorama = useIsPanorama();
var axisType = 'xAxis';
var scale = useAppSelector(state => selectAxisScale(state, axisType, xAxisId, isPanorama));
var cartesianTickItems = useAppSelector(state => selectTicksOfAxis(state, axisType, xAxisId, isPanorama));
var axisSize = useAppSelector(state => selectXAxisSize(state, xAxisId));
var position = useAppSelector(state => selectXAxisPosition(state, xAxisId));
/*
* Here we select settings from the store and prefer to use them instead of the actual props
* so that the chart is consistent. If we used the props directly, some components will use axis settings
* from state and some from props and because there is a render step between these two, they might be showing different things.
* https://github.com/recharts/recharts/issues/6257
*/
var synchronizedSettings = useAppSelector(state => selectXAxisSettingsNoDefaults(state, xAxisId));
if (axisSize == null || position == null || synchronizedSettings == null) {
return null;
}
var {
dangerouslySetInnerHTML,
ticks
} = props,
allOtherProps = _objectWithoutProperties(props, _excluded);
var {
id
} = synchronizedSettings,
restSynchronizedSettings = _objectWithoutProperties(synchronizedSettings, _excluded2);
return /*#__PURE__*/React.createElement(CartesianAxis, _extends({}, allOtherProps, restSynchronizedSettings, {
scale: scale,
x: position.x,
y: position.y,
width: axisSize.width,
height: axisSize.height,
className: clsx("recharts-".concat(axisType, " ").concat(axisType), className),
viewBox: viewBox,
ticks: cartesianTickItems,
axisType: axisType
}));
};
var xAxisDefaultProps = {
allowDataOverflow: implicitXAxis.allowDataOverflow,
allowDecimals: implicitXAxis.allowDecimals,
allowDuplicatedCategory: implicitXAxis.allowDuplicatedCategory,
height: implicitXAxis.height,
hide: false,
mirror: implicitXAxis.mirror,
orientation: implicitXAxis.orientation,
padding: implicitXAxis.padding,
reversed: implicitXAxis.reversed,
scale: implicitXAxis.scale,
tickCount: implicitXAxis.tickCount,
type: implicitXAxis.type,
xAxisId: 0
};
var XAxisSettingsDispatcher = outsideProps => {
var _props$interval, _props$includeHidden, _props$angle, _props$minTickGap, _props$tick;
var props = resolveDefaultProps(outsideProps, xAxisDefaultProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetXAxisSettings, {
interval: (_props$interval = props.interval) !== null && _props$interval !== void 0 ? _props$interval : 'preserveEnd',
id: props.xAxisId,
scale: props.scale,
type: props.type,
padding: props.padding,
allowDataOverflow: props.allowDataOverflow,
domain: props.domain,
dataKey: props.dataKey,
allowDuplicatedCategory: props.allowDuplicatedCategory,
allowDecimals: props.allowDecimals,
tickCount: props.tickCount,
includeHidden: (_props$includeHidden = props.includeHidden) !== null && _props$includeHidden !== void 0 ? _props$includeHidden : false,
reversed: props.reversed,
ticks: props.ticks,
height: props.height,
orientation: props.orientation,
mirror: props.mirror,
hide: props.hide,
unit: props.unit,
name: props.name,
angle: (_props$angle = props.angle) !== null && _props$angle !== void 0 ? _props$angle : 0,
minTickGap: (_props$minTickGap = props.minTickGap) !== null && _props$minTickGap !== void 0 ? _props$minTickGap : 5,
tick: (_props$tick = props.tick) !== null && _props$tick !== void 0 ? _props$tick : true,
tickFormatter: props.tickFormatter
}), /*#__PURE__*/React.createElement(XAxisImpl, props));
};
var XAxisMemoComparator = (prevProps, nextProps) => {
var {
domain: prevDomain
} = prevProps,
prevRest = _objectWithoutProperties(prevProps, _excluded3);
var {
domain: nextDomain
} = nextProps,
nextRest = _objectWithoutProperties(nextProps, _excluded4);
if (!shallowEqual(prevRest, nextRest)) {
return false;
}
if (Array.isArray(prevDomain) && prevDomain.length === 2 && Array.isArray(nextDomain) && nextDomain.length === 2) {
return prevDomain[0] === nextDomain[0] && prevDomain[1] === nextDomain[1];
}
return shallowEqual({
domain: prevDomain
}, {
domain: nextDomain
});
};
export var XAxis = /*#__PURE__*/React.memo(XAxisSettingsDispatcher, XAxisMemoComparator);
XAxis.displayName = 'XAxis';

176
frontend/node_modules/recharts/es6/cartesian/YAxis.js generated vendored Normal file
View File

@@ -0,0 +1,176 @@
var _excluded = ["dangerouslySetInnerHTML", "ticks"],
_excluded2 = ["id"],
_excluded3 = ["domain"],
_excluded4 = ["domain"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { isValidElement, useLayoutEffect, useRef } from 'react';
import { clsx } from 'clsx';
import { CartesianAxis } from './CartesianAxis';
import { addYAxis, removeYAxis, updateYAxisWidth } from '../state/cartesianAxisSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { implicitYAxis, selectAxisScale, selectTicksOfAxis, selectYAxisPosition, selectYAxisSettingsNoDefaults, selectYAxisSize } from '../state/selectors/axisSelectors';
import { selectAxisViewBox } from '../state/selectors/selectChartOffsetInternal';
import { useIsPanorama } from '../context/PanoramaContext';
import { isLabelContentAFunction } from '../component/Label';
import { shallowEqual } from '../util/ShallowEqual';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
function SetYAxisSettings(settings) {
var dispatch = useAppDispatch();
useLayoutEffect(() => {
dispatch(addYAxis(settings));
return () => {
dispatch(removeYAxis(settings));
};
}, [settings, dispatch]);
return null;
}
var YAxisImpl = props => {
var {
yAxisId,
className,
width,
label
} = props;
var cartesianAxisRef = useRef(null);
var labelRef = useRef(null);
var viewBox = useAppSelector(selectAxisViewBox);
var isPanorama = useIsPanorama();
var dispatch = useAppDispatch();
var axisType = 'yAxis';
var scale = useAppSelector(state => selectAxisScale(state, axisType, yAxisId, isPanorama));
var axisSize = useAppSelector(state => selectYAxisSize(state, yAxisId));
var position = useAppSelector(state => selectYAxisPosition(state, yAxisId));
var cartesianTickItems = useAppSelector(state => selectTicksOfAxis(state, axisType, yAxisId, isPanorama));
/*
* Here we select settings from the store and prefer to use them instead of the actual props
* so that the chart is consistent. If we used the props directly, some components will use axis settings
* from state and some from props and because there is a render step between these two, they might be showing different things.
* https://github.com/recharts/recharts/issues/6257
*/
var synchronizedSettings = useAppSelector(state => selectYAxisSettingsNoDefaults(state, yAxisId));
useLayoutEffect(() => {
// No dynamic width calculation is done when width !== 'auto'
// or when a function/react element is used for label
if (width !== 'auto' || !axisSize || isLabelContentAFunction(label) || /*#__PURE__*/isValidElement(label) || synchronizedSettings == null) {
return;
}
var axisComponent = cartesianAxisRef.current;
if (!axisComponent) {
return;
}
var updatedYAxisWidth = axisComponent.getCalculatedWidth();
// if the width has changed, dispatch an action to update the width
if (Math.round(axisSize.width) !== Math.round(updatedYAxisWidth)) {
dispatch(updateYAxisWidth({
id: yAxisId,
width: updatedYAxisWidth
}));
}
}, [
// The dependency on cartesianAxisRef.current is not needed because useLayoutEffect will run after every render.
// The ref will be populated by then.
// To re-run this effect when ticks change, we can depend on the ticks array from the store.
cartesianTickItems, axisSize, dispatch, label, yAxisId, width, synchronizedSettings]);
if (axisSize == null || position == null || synchronizedSettings == null) {
return null;
}
var {
dangerouslySetInnerHTML,
ticks
} = props,
allOtherProps = _objectWithoutProperties(props, _excluded);
var {
id
} = synchronizedSettings,
restSynchronizedSettings = _objectWithoutProperties(synchronizedSettings, _excluded2);
return /*#__PURE__*/React.createElement(CartesianAxis, _extends({}, allOtherProps, restSynchronizedSettings, {
ref: cartesianAxisRef,
labelRef: labelRef,
scale: scale,
x: position.x,
y: position.y,
tickTextProps: width === 'auto' ? {
width: undefined
} : {
width
},
width: axisSize.width,
height: axisSize.height,
className: clsx("recharts-".concat(axisType, " ").concat(axisType), className),
viewBox: viewBox,
ticks: cartesianTickItems,
axisType: axisType
}));
};
export var yAxisDefaultProps = {
allowDataOverflow: implicitYAxis.allowDataOverflow,
allowDecimals: implicitYAxis.allowDecimals,
allowDuplicatedCategory: implicitYAxis.allowDuplicatedCategory,
hide: false,
mirror: implicitYAxis.mirror,
orientation: implicitYAxis.orientation,
padding: implicitYAxis.padding,
reversed: implicitYAxis.reversed,
scale: implicitYAxis.scale,
tickCount: implicitYAxis.tickCount,
type: implicitYAxis.type,
width: implicitYAxis.width,
yAxisId: 0
};
var YAxisSettingsDispatcher = outsideProps => {
var _props$interval, _props$includeHidden, _props$angle, _props$minTickGap, _props$tick;
var props = resolveDefaultProps(outsideProps, yAxisDefaultProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetYAxisSettings, {
interval: (_props$interval = props.interval) !== null && _props$interval !== void 0 ? _props$interval : 'preserveEnd',
id: props.yAxisId,
scale: props.scale,
type: props.type,
domain: props.domain,
allowDataOverflow: props.allowDataOverflow,
dataKey: props.dataKey,
allowDuplicatedCategory: props.allowDuplicatedCategory,
allowDecimals: props.allowDecimals,
tickCount: props.tickCount,
padding: props.padding,
includeHidden: (_props$includeHidden = props.includeHidden) !== null && _props$includeHidden !== void 0 ? _props$includeHidden : false,
reversed: props.reversed,
ticks: props.ticks,
width: props.width,
orientation: props.orientation,
mirror: props.mirror,
hide: props.hide,
unit: props.unit,
name: props.name,
angle: (_props$angle = props.angle) !== null && _props$angle !== void 0 ? _props$angle : 0,
minTickGap: (_props$minTickGap = props.minTickGap) !== null && _props$minTickGap !== void 0 ? _props$minTickGap : 5,
tick: (_props$tick = props.tick) !== null && _props$tick !== void 0 ? _props$tick : true,
tickFormatter: props.tickFormatter
}), /*#__PURE__*/React.createElement(YAxisImpl, props));
};
var YAxisMemoComparator = (prevProps, nextProps) => {
var {
domain: prevDomain
} = prevProps,
prevRest = _objectWithoutProperties(prevProps, _excluded3);
var {
domain: nextDomain
} = nextProps,
nextRest = _objectWithoutProperties(nextProps, _excluded4);
if (!shallowEqual(prevRest, nextRest)) {
return false;
}
if (Array.isArray(prevDomain) && prevDomain.length === 2 && Array.isArray(nextDomain) && nextDomain.length === 2) {
return prevDomain[0] === nextDomain[0] && prevDomain[1] === nextDomain[1];
}
return shallowEqual({
domain: prevDomain
}, {
domain: nextDomain
});
};
export var YAxis = /*#__PURE__*/React.memo(YAxisSettingsDispatcher, YAxisMemoComparator);
YAxis.displayName = 'YAxis';

40
frontend/node_modules/recharts/es6/cartesian/ZAxis.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import * as React from 'react';
import { useEffect } from 'react';
import { addZAxis, removeZAxis } from '../state/cartesianAxisSlice';
import { useAppDispatch } from '../state/hooks';
import { implicitZAxis } from '../state/selectors/axisSelectors';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
function SetZAxisSettings(settings) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(addZAxis(settings));
return () => {
dispatch(removeZAxis(settings));
};
}, [settings, dispatch]);
return null;
}
var zAxisDefaultProps = {
zAxisId: 0,
range: implicitZAxis.range,
scale: implicitZAxis.scale,
type: implicitZAxis.type
};
export function ZAxis(outsideProps) {
var props = resolveDefaultProps(outsideProps, zAxisDefaultProps);
return /*#__PURE__*/React.createElement(SetZAxisSettings, {
domain: props.domain,
id: props.zAxisId,
dataKey: props.dataKey,
name: props.name,
unit: props.unit,
range: props.range,
scale: props.scale,
type: props.type,
allowDuplicatedCategory: implicitZAxis.allowDuplicatedCategory,
allowDataOverflow: implicitZAxis.allowDataOverflow,
reversed: implicitZAxis.reversed,
includeHidden: implicitZAxis.includeHidden
});
}
ZAxis.displayName = 'ZAxis';

View File

@@ -0,0 +1,58 @@
import { isVisible } from '../util/TickUtils';
import { getEveryNthWithCondition } from '../util/getEveryNthWithCondition';
export function getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap) {
// If the ticks are readonly, then the slice might not be necessary
var result = (ticks || []).slice();
var {
start: initialStart,
end
} = boundaries;
var index = 0;
// Premature optimisation idea 1: Estimate a lower bound, and start from there.
// For now, start from every tick
var stepsize = 1;
var start = initialStart;
var _loop = function _loop() {
// Given stepsize, evaluate whether every stepsize-th tick can be shown.
// If it can not, then increase the stepsize by 1, and try again.
var entry = ticks === null || ticks === void 0 ? void 0 : ticks[index];
// Break condition - If we have evaluated all the ticks, then we are done.
if (entry === undefined) {
return {
v: getEveryNthWithCondition(ticks, stepsize)
};
}
// Check if the element collides with the next element
var i = index;
var size;
var getSize = () => {
if (size === undefined) {
size = getTickSize(entry, i);
}
return size;
};
var tickCoord = entry.coordinate;
// We will always show the first tick.
var isShow = index === 0 || isVisible(sign, tickCoord, getSize, start, end);
if (!isShow) {
// Start all over with a larger stepsize
index = 0;
start = initialStart;
stepsize += 1;
}
if (isShow) {
// If it can be shown, update the start
start = tickCoord + sign * (getSize() / 2 + minTickGap);
index += stepsize;
}
},
_ret;
while (stepsize <= result.length) {
_ret = _loop();
if (_ret) return _ret.v;
}
return [];
}

View File

@@ -0,0 +1,165 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { mathSign, isNumber } from '../util/DataUtils';
import { getStringSize } from '../util/DOMUtils';
import { Global } from '../util/Global';
import { isVisible, getTickBoundaries, getNumberIntervalTicks, getAngledTickWidth } from '../util/TickUtils';
import { getEquidistantTicks } from './getEquidistantTicks';
function getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap) {
var result = (ticks || []).slice();
var len = result.length;
var {
start
} = boundaries;
var {
end
} = boundaries;
var _loop = function _loop(i) {
var entry = result[i];
var size;
var getSize = () => {
if (size === undefined) {
size = getTickSize(entry, i);
}
return size;
};
if (i === len - 1) {
var gap = sign * (entry.coordinate + sign * getSize() / 2 - end);
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: gap > 0 ? entry.coordinate - gap * sign : entry.coordinate
});
} else {
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: entry.coordinate
});
}
if (entry.tickCoord != null) {
var isShow = isVisible(sign, entry.tickCoord, getSize, start, end);
if (isShow) {
end = entry.tickCoord - sign * (getSize() / 2 + minTickGap);
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
isShow: true
});
}
}
};
for (var i = len - 1; i >= 0; i--) {
_loop(i);
}
return result;
}
function getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, preserveEnd) {
// This method is mutating the array so clone is indeed necessary here
var result = (ticks || []).slice();
var len = result.length;
var {
start,
end
} = boundaries;
if (preserveEnd) {
// Try to guarantee the tail to be displayed
var tail = ticks[len - 1];
var tailSize = getTickSize(tail, len - 1);
var tailGap = sign * (tail.coordinate + sign * tailSize / 2 - end);
result[len - 1] = tail = _objectSpread(_objectSpread({}, tail), {}, {
tickCoord: tailGap > 0 ? tail.coordinate - tailGap * sign : tail.coordinate
});
if (tail.tickCoord != null) {
var isTailShow = isVisible(sign, tail.tickCoord, () => tailSize, start, end);
if (isTailShow) {
end = tail.tickCoord - sign * (tailSize / 2 + minTickGap);
result[len - 1] = _objectSpread(_objectSpread({}, tail), {}, {
isShow: true
});
}
}
}
var count = preserveEnd ? len - 1 : len;
var _loop2 = function _loop2(i) {
var entry = result[i];
var size;
var getSize = () => {
if (size === undefined) {
size = getTickSize(entry, i);
}
return size;
};
if (i === 0) {
var gap = sign * (entry.coordinate - sign * getSize() / 2 - start);
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: gap < 0 ? entry.coordinate - gap * sign : entry.coordinate
});
} else {
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: entry.coordinate
});
}
if (entry.tickCoord != null) {
var isShow = isVisible(sign, entry.tickCoord, getSize, start, end);
if (isShow) {
start = entry.tickCoord + sign * (getSize() / 2 + minTickGap);
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
isShow: true
});
}
}
};
for (var i = 0; i < count; i++) {
_loop2(i);
}
return result;
}
export function getTicks(props, fontSize, letterSpacing) {
var {
tick,
ticks,
viewBox,
minTickGap,
orientation,
interval,
tickFormatter,
unit,
angle
} = props;
if (!ticks || !ticks.length || !tick) {
return [];
}
if (isNumber(interval) || Global.isSsr) {
var _getNumberIntervalTic;
return (_getNumberIntervalTic = getNumberIntervalTicks(ticks, isNumber(interval) ? interval : 0)) !== null && _getNumberIntervalTic !== void 0 ? _getNumberIntervalTic : [];
}
var candidates = [];
var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
var unitSize = unit && sizeKey === 'width' ? getStringSize(unit, {
fontSize,
letterSpacing
}) : {
width: 0,
height: 0
};
var getTickSize = (content, index) => {
var value = typeof tickFormatter === 'function' ? tickFormatter(content.value, index) : content.value;
// Recharts only supports angles when sizeKey === 'width'
return sizeKey === 'width' ? getAngledTickWidth(getStringSize(value, {
fontSize,
letterSpacing
}), unitSize, angle) : getStringSize(value, {
fontSize,
letterSpacing
})[sizeKey];
};
var sign = ticks.length >= 2 ? mathSign(ticks[1].coordinate - ticks[0].coordinate) : 1;
var boundaries = getTickBoundaries(viewBox, sign, sizeKey);
if (interval === 'equidistantPreserveStart') {
return getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap);
}
if (interval === 'preserveStart' || interval === 'preserveStartEnd') {
candidates = getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, interval === 'preserveStartEnd');
} else {
candidates = getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap);
}
return candidates.filter(entry => entry.isShow);
}

15
frontend/node_modules/recharts/es6/chart/AreaChart.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { CartesianChart } from './CartesianChart';
var allowedTooltipTypes = ['axis'];
export var AreaChart = /*#__PURE__*/forwardRef((props, ref) => {
return /*#__PURE__*/React.createElement(CartesianChart, {
chartName: "AreaChart",
defaultTooltipEventType: "axis",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: props,
ref: ref
});
});

15
frontend/node_modules/recharts/es6/chart/BarChart.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { CartesianChart } from './CartesianChart';
var allowedTooltipTypes = ['axis', 'item'];
export var BarChart = /*#__PURE__*/forwardRef((props, ref) => {
return /*#__PURE__*/React.createElement(CartesianChart, {
chartName: "BarChart",
defaultTooltipEventType: "axis",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: props,
ref: ref
});
});

View File

@@ -0,0 +1,75 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { forwardRef } from 'react';
import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
import { ChartDataContextProvider } from '../context/chartDataContext';
import { ReportMainChartProps } from '../state/ReportMainChartProps';
import { ReportChartProps } from '../state/ReportChartProps';
import { CategoricalChart } from './CategoricalChart';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
var defaultMargin = {
top: 5,
right: 5,
bottom: 5,
left: 5
};
var defaultProps = {
accessibilityLayer: true,
layout: 'horizontal',
stackOffset: 'none',
barCategoryGap: '10%',
barGap: 4,
margin: defaultMargin,
reverseStackOrder: false,
syncMethod: 'index',
responsive: false
};
/**
* These are one-time, immutable options that decide the chart's behavior.
* Users who wish to call CartesianChart may decide to pass these options explicitly,
* but usually we would expect that they use one of the convenience components like BarChart, LineChart, etc.
*/
export var CartesianChart = /*#__PURE__*/forwardRef(function CartesianChart(props, ref) {
var _categoricalChartProp;
var rootChartProps = resolveDefaultProps(props.categoricalChartProps, defaultProps);
var {
chartName,
defaultTooltipEventType,
validateTooltipEventTypes,
tooltipPayloadSearcher,
categoricalChartProps
} = props;
var options = {
chartName,
defaultTooltipEventType,
validateTooltipEventTypes,
tooltipPayloadSearcher,
eventEmitter: undefined
};
return /*#__PURE__*/React.createElement(RechartsStoreProvider, {
preloadedState: {
options
},
reduxStoreName: (_categoricalChartProp = categoricalChartProps.id) !== null && _categoricalChartProp !== void 0 ? _categoricalChartProp : chartName
}, /*#__PURE__*/React.createElement(ChartDataContextProvider, {
chartData: categoricalChartProps.data
}), /*#__PURE__*/React.createElement(ReportMainChartProps, {
layout: rootChartProps.layout,
margin: rootChartProps.margin
}), /*#__PURE__*/React.createElement(ReportChartProps, {
baseValue: rootChartProps.baseValue,
accessibilityLayer: rootChartProps.accessibilityLayer,
barCategoryGap: rootChartProps.barCategoryGap,
maxBarSize: rootChartProps.maxBarSize,
stackOffset: rootChartProps.stackOffset,
barGap: rootChartProps.barGap,
barSize: rootChartProps.barSize,
syncId: rootChartProps.syncId,
syncMethod: rootChartProps.syncMethod,
className: rootChartProps.className
}), /*#__PURE__*/React.createElement(CategoricalChart, _extends({}, rootChartProps, {
ref: ref
})));
});

View File

@@ -0,0 +1,63 @@
var _excluded = ["width", "height", "responsive", "children", "className", "style", "compact", "title", "desc"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { forwardRef } from 'react';
import { RootSurface } from '../container/RootSurface';
import { RechartsWrapper } from './RechartsWrapper';
import { ClipPathProvider } from '../container/ClipPathProvider';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { ReportChartSize } from '../context/chartLayoutContext';
export var CategoricalChart = /*#__PURE__*/forwardRef((props, ref) => {
var {
width,
height,
responsive,
children,
className,
style,
compact,
title,
desc
} = props,
others = _objectWithoutProperties(props, _excluded);
var attrs = svgPropertiesNoEvents(others);
/*
* The "compact" mode is used as the panorama within Brush.
* However because `compact` is a public prop, let's assume that it can render outside of Brush too.
*/
if (compact) {
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportChartSize, {
width: width,
height: height
}), /*#__PURE__*/React.createElement(RootSurface, {
otherAttributes: attrs,
title: title,
desc: desc
}, children));
}
return /*#__PURE__*/React.createElement(RechartsWrapper, {
className: className,
style: style,
width: width,
height: height,
responsive: responsive !== null && responsive !== void 0 ? responsive : false,
onClick: props.onClick,
onMouseLeave: props.onMouseLeave,
onMouseEnter: props.onMouseEnter,
onMouseMove: props.onMouseMove,
onMouseDown: props.onMouseDown,
onMouseUp: props.onMouseUp,
onContextMenu: props.onContextMenu,
onDoubleClick: props.onDoubleClick,
onTouchStart: props.onTouchStart,
onTouchMove: props.onTouchMove,
onTouchEnd: props.onTouchEnd
}, /*#__PURE__*/React.createElement(RootSurface, {
otherAttributes: attrs,
title: title,
desc: desc,
ref: ref
}, /*#__PURE__*/React.createElement(ClipPathProvider, null, children)));
});

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { CartesianChart } from './CartesianChart';
var allowedTooltipTypes = ['axis'];
export var ComposedChart = /*#__PURE__*/forwardRef((props, ref) => {
return /*#__PURE__*/React.createElement(CartesianChart, {
chartName: "ComposedChart",
defaultTooltipEventType: "axis",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: props,
ref: ref
});
});

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { CartesianChart } from './CartesianChart';
var allowedTooltipTypes = ['item'];
export var FunnelChart = /*#__PURE__*/forwardRef((props, ref) => {
return /*#__PURE__*/React.createElement(CartesianChart, {
chartName: "FunnelChart",
defaultTooltipEventType: "item",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: props,
ref: ref
});
});

15
frontend/node_modules/recharts/es6/chart/LineChart.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { CartesianChart } from './CartesianChart';
var allowedTooltipTypes = ['axis'];
export var LineChart = /*#__PURE__*/forwardRef((props, ref) => {
return /*#__PURE__*/React.createElement(CartesianChart, {
chartName: "LineChart",
defaultTooltipEventType: "axis",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: props,
ref: ref
});
});

26
frontend/node_modules/recharts/es6/chart/PieChart.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { PolarChart } from './PolarChart';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
var allowedTooltipTypes = ['item'];
var defaultProps = {
layout: 'centric',
startAngle: 0,
endAngle: 360,
cx: '50%',
cy: '50%',
innerRadius: 0,
outerRadius: '80%'
};
export var PieChart = /*#__PURE__*/forwardRef((props, ref) => {
var propsWithDefaults = resolveDefaultProps(props, defaultProps);
return /*#__PURE__*/React.createElement(PolarChart, {
chartName: "PieChart",
defaultTooltipEventType: "item",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: propsWithDefaults,
ref: ref
});
});

102
frontend/node_modules/recharts/es6/chart/PolarChart.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
var _excluded = ["layout"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import { forwardRef } from 'react';
import * as React from 'react';
import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
import { ChartDataContextProvider } from '../context/chartDataContext';
import { ReportMainChartProps } from '../state/ReportMainChartProps';
import { ReportChartProps } from '../state/ReportChartProps';
import { ReportPolarOptions } from '../state/ReportPolarOptions';
import { CategoricalChart } from './CategoricalChart';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
var defaultMargin = {
top: 5,
right: 5,
bottom: 5,
left: 5
};
/**
* These default props are the same for all PolarChart components.
*/
var defaultProps = {
accessibilityLayer: true,
stackOffset: 'none',
barCategoryGap: '10%',
barGap: 4,
margin: defaultMargin,
reverseStackOrder: false,
syncMethod: 'index',
layout: 'radial',
responsive: false
};
/**
* These props are required for the PolarChart to function correctly.
* Users usually would not need to specify these explicitly,
* because the convenience components like PieChart, RadarChart, etc.
* will provide these defaults.
* We can't have the defaults in this file because each of those convenience components
* have their own opinions about what they should be.
*/
/**
* These are one-time, immutable options that decide the chart's behavior.
* Users who wish to call CartesianChart may decide to pass these options explicitly,
* but usually we would expect that they use one of the convenience components like PieChart, RadarChart, etc.
*/
export var PolarChart = /*#__PURE__*/forwardRef(function PolarChart(props, ref) {
var _polarChartProps$id;
var polarChartProps = resolveDefaultProps(props.categoricalChartProps, defaultProps);
var {
layout
} = polarChartProps,
otherCategoricalProps = _objectWithoutProperties(polarChartProps, _excluded);
var {
chartName,
defaultTooltipEventType,
validateTooltipEventTypes,
tooltipPayloadSearcher
} = props;
var options = {
chartName,
defaultTooltipEventType,
validateTooltipEventTypes,
tooltipPayloadSearcher,
eventEmitter: undefined
};
return /*#__PURE__*/React.createElement(RechartsStoreProvider, {
preloadedState: {
options
},
reduxStoreName: (_polarChartProps$id = polarChartProps.id) !== null && _polarChartProps$id !== void 0 ? _polarChartProps$id : chartName
}, /*#__PURE__*/React.createElement(ChartDataContextProvider, {
chartData: polarChartProps.data
}), /*#__PURE__*/React.createElement(ReportMainChartProps, {
layout: layout,
margin: polarChartProps.margin
}), /*#__PURE__*/React.createElement(ReportChartProps, {
baseValue: undefined,
accessibilityLayer: polarChartProps.accessibilityLayer,
barCategoryGap: polarChartProps.barCategoryGap,
maxBarSize: polarChartProps.maxBarSize,
stackOffset: polarChartProps.stackOffset,
barGap: polarChartProps.barGap,
barSize: polarChartProps.barSize,
syncId: polarChartProps.syncId,
syncMethod: polarChartProps.syncMethod,
className: polarChartProps.className
}), /*#__PURE__*/React.createElement(ReportPolarOptions, {
cx: polarChartProps.cx,
cy: polarChartProps.cy,
startAngle: polarChartProps.startAngle,
endAngle: polarChartProps.endAngle,
innerRadius: polarChartProps.innerRadius,
outerRadius: polarChartProps.outerRadius
}), /*#__PURE__*/React.createElement(CategoricalChart, _extends({}, otherCategoricalProps, {
ref: ref
})));
});

26
frontend/node_modules/recharts/es6/chart/RadarChart.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { PolarChart } from './PolarChart';
var allowedTooltipTypes = ['axis'];
var defaultProps = {
layout: 'centric',
startAngle: 90,
endAngle: -270,
cx: '50%',
cy: '50%',
innerRadius: 0,
outerRadius: '80%'
};
export var RadarChart = /*#__PURE__*/forwardRef((props, ref) => {
var propsWithDefaults = resolveDefaultProps(props, defaultProps);
return /*#__PURE__*/React.createElement(PolarChart, {
chartName: "RadarChart",
defaultTooltipEventType: "axis",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: propsWithDefaults,
ref: ref
});
});

View File

@@ -0,0 +1,26 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { PolarChart } from './PolarChart';
var allowedTooltipTypes = ['axis', 'item'];
var defaultProps = {
layout: 'radial',
startAngle: 0,
endAngle: 360,
cx: '50%',
cy: '50%',
innerRadius: 0,
outerRadius: '80%'
};
export var RadialBarChart = /*#__PURE__*/forwardRef((props, ref) => {
var propsWithDefaults = resolveDefaultProps(props, defaultProps);
return /*#__PURE__*/React.createElement(PolarChart, {
chartName: "RadialBarChart",
defaultTooltipEventType: "axis",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: propsWithDefaults,
ref: ref
});
});

View File

@@ -0,0 +1,325 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { mouseLeaveChart } from '../state/tooltipSlice';
import { useAppDispatch } from '../state/hooks';
import { mouseClickAction, mouseMoveAction } from '../state/mouseEventsMiddleware';
import { useSynchronisedEventsFromOtherCharts } from '../synchronisation/useChartSynchronisation';
import { focusAction, keyDownAction } from '../state/keyboardEventsMiddleware';
import { useReportScale } from '../util/useReportScale';
import { externalEventAction } from '../state/externalEventsMiddleware';
import { touchEventAction } from '../state/touchEventsMiddleware';
import { TooltipPortalContext } from '../context/tooltipPortalContext';
import { LegendPortalContext } from '../context/legendPortalContext';
import { ReportChartSize } from '../context/chartLayoutContext';
import { useResponsiveContainerContext } from '../component/ResponsiveContainer';
import { isPercent } from '../util/DataUtils';
var EventSynchronizer = () => {
useSynchronisedEventsFromOtherCharts();
return null;
};
function getNumberOrZero(value) {
if (typeof value === 'number') {
return value;
}
if (typeof value === 'string') {
var parsed = parseFloat(value);
if (!Number.isNaN(parsed)) {
return parsed;
}
}
return 0;
}
var ResponsiveDiv = /*#__PURE__*/forwardRef((props, ref) => {
var _props$style, _props$style2;
var observerRef = useRef(null);
var [sizes, setSizes] = useState({
containerWidth: getNumberOrZero((_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.width),
containerHeight: getNumberOrZero((_props$style2 = props.style) === null || _props$style2 === void 0 ? void 0 : _props$style2.height)
});
var setContainerSize = useCallback((newWidth, newHeight) => {
setSizes(prevState => {
var roundedWidth = Math.round(newWidth);
var roundedHeight = Math.round(newHeight);
if (prevState.containerWidth === roundedWidth && prevState.containerHeight === roundedHeight) {
return prevState;
}
return {
containerWidth: roundedWidth,
containerHeight: roundedHeight
};
});
}, []);
var innerRef = useCallback(node => {
if (typeof ref === 'function') {
ref(node);
}
if (node != null && typeof ResizeObserver !== 'undefined') {
var {
width: containerWidth,
height: containerHeight
} = node.getBoundingClientRect();
setContainerSize(containerWidth, containerHeight);
var callback = entries => {
var {
width,
height
} = entries[0].contentRect;
setContainerSize(width, height);
};
var observer = new ResizeObserver(callback);
observer.observe(node);
observerRef.current = observer;
}
}, [ref, setContainerSize]);
useEffect(() => {
return () => {
var observer = observerRef.current;
if (observer != null) {
observer.disconnect();
}
};
}, [setContainerSize]);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportChartSize, {
width: sizes.containerWidth,
height: sizes.containerHeight
}), /*#__PURE__*/React.createElement("div", _extends({
ref: innerRef
}, props)));
});
var ReadSizeOnceDiv = /*#__PURE__*/forwardRef((props, ref) => {
var {
width,
height
} = props;
var [sizes, setSizes] = useState({
containerWidth: getNumberOrZero(width),
containerHeight: getNumberOrZero(height)
});
var setContainerSize = useCallback((newWidth, newHeight) => {
setSizes(prevState => {
var roundedWidth = Math.round(newWidth);
var roundedHeight = Math.round(newHeight);
if (prevState.containerWidth === roundedWidth && prevState.containerHeight === roundedHeight) {
return prevState;
}
return {
containerWidth: roundedWidth,
containerHeight: roundedHeight
};
});
}, []);
var innerRef = useCallback(node => {
if (typeof ref === 'function') {
ref(node);
}
if (node != null) {
var {
width: containerWidth,
height: containerHeight
} = node.getBoundingClientRect();
setContainerSize(containerWidth, containerHeight);
}
}, [ref, setContainerSize]);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportChartSize, {
width: sizes.containerWidth,
height: sizes.containerHeight
}), /*#__PURE__*/React.createElement("div", _extends({
ref: innerRef
}, props)));
});
var StaticDiv = /*#__PURE__*/forwardRef((props, ref) => {
var {
width,
height
} = props;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReportChartSize, {
width: width,
height: height
}), /*#__PURE__*/React.createElement("div", _extends({
ref: ref
}, props)));
});
var NonResponsiveDiv = /*#__PURE__*/forwardRef((props, ref) => {
var {
width,
height
} = props;
if (isPercent(width) || isPercent(height)) {
return /*#__PURE__*/React.createElement(ReadSizeOnceDiv, _extends({}, props, {
ref: ref
}));
}
return /*#__PURE__*/React.createElement(StaticDiv, _extends({}, props, {
ref: ref
}));
});
function getWrapperDivComponent(responsive) {
return responsive === true ? ResponsiveDiv : NonResponsiveDiv;
}
export var RechartsWrapper = /*#__PURE__*/forwardRef((props, ref) => {
var {
children,
className,
height: heightFromProps,
onClick,
onContextMenu,
onDoubleClick,
onMouseDown,
onMouseEnter,
onMouseLeave,
onMouseMove,
onMouseUp,
onTouchEnd,
onTouchMove,
onTouchStart,
style,
width: widthFromProps,
responsive,
dispatchTouchEvents = true
} = props;
var containerRef = useRef(null);
var dispatch = useAppDispatch();
var [tooltipPortal, setTooltipPortal] = useState(null);
var [legendPortal, setLegendPortal] = useState(null);
var setScaleRef = useReportScale();
var responsiveContainerCalculations = useResponsiveContainerContext();
var width = (responsiveContainerCalculations === null || responsiveContainerCalculations === void 0 ? void 0 : responsiveContainerCalculations.width) > 0 ? responsiveContainerCalculations.width : widthFromProps;
var height = (responsiveContainerCalculations === null || responsiveContainerCalculations === void 0 ? void 0 : responsiveContainerCalculations.height) > 0 ? responsiveContainerCalculations.height : heightFromProps;
var innerRef = useCallback(node => {
setScaleRef(node);
if (typeof ref === 'function') {
ref(node);
}
setTooltipPortal(node);
setLegendPortal(node);
if (node != null) {
containerRef.current = node;
}
}, [setScaleRef, ref, setTooltipPortal, setLegendPortal]);
var myOnClick = useCallback(e => {
dispatch(mouseClickAction(e));
dispatch(externalEventAction({
handler: onClick,
reactEvent: e
}));
}, [dispatch, onClick]);
var myOnMouseEnter = useCallback(e => {
dispatch(mouseMoveAction(e));
dispatch(externalEventAction({
handler: onMouseEnter,
reactEvent: e
}));
}, [dispatch, onMouseEnter]);
var myOnMouseLeave = useCallback(e => {
dispatch(mouseLeaveChart());
dispatch(externalEventAction({
handler: onMouseLeave,
reactEvent: e
}));
}, [dispatch, onMouseLeave]);
var myOnMouseMove = useCallback(e => {
dispatch(mouseMoveAction(e));
dispatch(externalEventAction({
handler: onMouseMove,
reactEvent: e
}));
}, [dispatch, onMouseMove]);
var onFocus = useCallback(() => {
dispatch(focusAction());
}, [dispatch]);
var onKeyDown = useCallback(e => {
dispatch(keyDownAction(e.key));
}, [dispatch]);
var myOnContextMenu = useCallback(e => {
dispatch(externalEventAction({
handler: onContextMenu,
reactEvent: e
}));
}, [dispatch, onContextMenu]);
var myOnDoubleClick = useCallback(e => {
dispatch(externalEventAction({
handler: onDoubleClick,
reactEvent: e
}));
}, [dispatch, onDoubleClick]);
var myOnMouseDown = useCallback(e => {
dispatch(externalEventAction({
handler: onMouseDown,
reactEvent: e
}));
}, [dispatch, onMouseDown]);
var myOnMouseUp = useCallback(e => {
dispatch(externalEventAction({
handler: onMouseUp,
reactEvent: e
}));
}, [dispatch, onMouseUp]);
var myOnTouchStart = useCallback(e => {
dispatch(externalEventAction({
handler: onTouchStart,
reactEvent: e
}));
}, [dispatch, onTouchStart]);
/*
* onTouchMove is special because it behaves different from mouse events.
* Mouse events have 'enter' + 'leave' combo that notify us when the mouse is over
* a certain element. Touch events don't have that; touch only gives us
* start (finger down), end (finger up) and move (finger moving).
* So we need to figure out which element the user is touching
* ourselves. Fortunately, there's a convenient method for that:
* https://developer.mozilla.org/en-US/docs/Web/API/Document/elementFromPoint
*/
var myOnTouchMove = useCallback(e => {
if (dispatchTouchEvents) {
dispatch(touchEventAction(e));
}
dispatch(externalEventAction({
handler: onTouchMove,
reactEvent: e
}));
}, [dispatch, dispatchTouchEvents, onTouchMove]);
var myOnTouchEnd = useCallback(e => {
dispatch(externalEventAction({
handler: onTouchEnd,
reactEvent: e
}));
}, [dispatch, onTouchEnd]);
var WrapperDiv = getWrapperDivComponent(responsive);
return /*#__PURE__*/React.createElement(TooltipPortalContext.Provider, {
value: tooltipPortal
}, /*#__PURE__*/React.createElement(LegendPortalContext.Provider, {
value: legendPortal
}, /*#__PURE__*/React.createElement(WrapperDiv, {
width: width !== null && width !== void 0 ? width : style === null || style === void 0 ? void 0 : style.width,
height: height !== null && height !== void 0 ? height : style === null || style === void 0 ? void 0 : style.height,
className: clsx('recharts-wrapper', className),
style: _objectSpread({
position: 'relative',
cursor: 'default',
width,
height
}, style),
onClick: myOnClick,
onContextMenu: myOnContextMenu,
onDoubleClick: myOnDoubleClick,
onFocus: onFocus,
onKeyDown: onKeyDown,
onMouseDown: myOnMouseDown,
onMouseEnter: myOnMouseEnter,
onMouseLeave: myOnMouseLeave,
onMouseMove: myOnMouseMove,
onMouseUp: myOnMouseUp,
onTouchEnd: myOnTouchEnd,
onTouchMove: myOnTouchMove,
onTouchStart: myOnTouchStart,
ref: innerRef
}, /*#__PURE__*/React.createElement(EventSynchronizer, null), children)));
});

796
frontend/node_modules/recharts/es6/chart/Sankey.js generated vendored Normal file
View File

@@ -0,0 +1,796 @@
var _excluded = ["sourceX", "sourceY", "sourceControlX", "targetX", "targetY", "targetControlX", "linkWidth"],
_excluded2 = ["className", "style", "children"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { useCallback, useMemo, useState } from 'react';
import maxBy from 'es-toolkit/compat/maxBy';
import sumBy from 'es-toolkit/compat/sumBy';
import get from 'es-toolkit/compat/get';
import { Surface } from '../container/Surface';
import { Layer } from '../container/Layer';
import { Rectangle } from '../shape/Rectangle';
import { getValueByDataKey } from '../util/ChartUtils';
import { ReportChartMargin, ReportChartSize, useChartHeight, useChartWidth } from '../context/chartLayoutContext';
import { TooltipPortalContext } from '../context/tooltipPortalContext';
import { RechartsWrapper } from './RechartsWrapper';
import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
import { useAppDispatch } from '../state/hooks';
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { SetComputedData } from '../context/chartDataContext';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
var interpolationGenerator = (a, b) => {
var ka = +a;
var kb = b - ka;
return t => ka + kb * t;
};
var centerY = node => node.y + node.dy / 2;
var getValue = entry => entry && entry.value || 0;
var getSumOfIds = (links, ids) => ids.reduce((result, id) => result + getValue(links[id]), 0);
var getSumWithWeightedSource = (tree, links, ids) => ids.reduce((result, id) => {
var link = links[id];
var sourceNode = tree[link.source];
return result + centerY(sourceNode) * getValue(links[id]);
}, 0);
var getSumWithWeightedTarget = (tree, links, ids) => ids.reduce((result, id) => {
var link = links[id];
var targetNode = tree[link.target];
return result + centerY(targetNode) * getValue(links[id]);
}, 0);
var ascendingY = (a, b) => a.y - b.y;
var searchTargetsAndSources = (links, id) => {
var sourceNodes = [];
var sourceLinks = [];
var targetNodes = [];
var targetLinks = [];
for (var i = 0, len = links.length; i < len; i++) {
var link = links[i];
if (link.source === id) {
targetNodes.push(link.target);
targetLinks.push(i);
}
if (link.target === id) {
sourceNodes.push(link.source);
sourceLinks.push(i);
}
}
return {
sourceNodes,
sourceLinks,
targetLinks,
targetNodes
};
};
var updateDepthOfTargets = (tree, curNode) => {
var {
targetNodes
} = curNode;
for (var i = 0, len = targetNodes.length; i < len; i++) {
var target = tree[targetNodes[i]];
if (target) {
target.depth = Math.max(curNode.depth + 1, target.depth);
updateDepthOfTargets(tree, target);
}
}
};
var getNodesTree = (_ref, width, nodeWidth, align) => {
var _maxBy$depth, _maxBy;
var {
nodes,
links
} = _ref;
var tree = nodes.map((entry, index) => {
var result = searchTargetsAndSources(links, index);
return _objectSpread(_objectSpread(_objectSpread({}, entry), result), {}, {
value: Math.max(getSumOfIds(links, result.sourceLinks), getSumOfIds(links, result.targetLinks)),
depth: 0
});
});
for (var i = 0, len = tree.length; i < len; i++) {
var node = tree[i];
if (!node.sourceNodes.length) {
updateDepthOfTargets(tree, node);
}
}
var maxDepth = (_maxBy$depth = (_maxBy = maxBy(tree, entry => entry.depth)) === null || _maxBy === void 0 ? void 0 : _maxBy.depth) !== null && _maxBy$depth !== void 0 ? _maxBy$depth : 0;
if (maxDepth >= 1) {
var childWidth = (width - nodeWidth) / maxDepth;
for (var _i = 0, _len = tree.length; _i < _len; _i++) {
var _node = tree[_i];
if (!_node.targetNodes.length) {
if (align === 'justify') {
_node.depth = maxDepth;
}
}
_node.x = _node.depth * childWidth;
_node.dx = nodeWidth;
}
}
return {
tree,
maxDepth
};
};
var getDepthTree = tree => {
var result = [];
for (var i = 0, len = tree.length; i < len; i++) {
var node = tree[i];
if (!result[node.depth]) {
result[node.depth] = [];
}
result[node.depth].push(node);
}
return result;
};
var updateYOfTree = (depthTree, height, nodePadding, links, verticalAlign) => {
var yRatio = Math.min(...depthTree.map(nodes => (height - (nodes.length - 1) * nodePadding) / sumBy(nodes, getValue)));
for (var d = 0, maxDepth = depthTree.length; d < maxDepth; d++) {
var nodes = depthTree[d];
if (verticalAlign === 'top') {
var currentY = 0;
for (var i = 0, len = nodes.length; i < len; i++) {
var node = nodes[i];
node.dy = node.value * yRatio;
node.y = currentY;
currentY += node.dy + nodePadding;
}
} else {
for (var _i2 = 0, _len2 = nodes.length; _i2 < _len2; _i2++) {
var _node2 = nodes[_i2];
_node2.y = _i2;
_node2.dy = _node2.value * yRatio;
}
}
}
return links.map(link => _objectSpread(_objectSpread({}, link), {}, {
dy: getValue(link) * yRatio
}));
};
var resolveCollisions = function resolveCollisions(depthTree, height, nodePadding) {
var sort = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
for (var i = 0, len = depthTree.length; i < len; i++) {
var nodes = depthTree[i];
var n = nodes.length;
// Sort by the value of y
if (sort) {
nodes.sort(ascendingY);
}
var y0 = 0;
for (var j = 0; j < n; j++) {
var node = nodes[j];
var dy = y0 - node.y;
if (dy > 0) {
node.y += dy;
}
y0 = node.y + node.dy + nodePadding;
}
y0 = height + nodePadding;
for (var _j = n - 1; _j >= 0; _j--) {
var _node3 = nodes[_j];
var _dy = _node3.y + _node3.dy + nodePadding - y0;
if (_dy > 0) {
_node3.y -= _dy;
y0 = _node3.y;
} else {
break;
}
}
}
};
var relaxLeftToRight = (tree, depthTree, links, alpha) => {
for (var i = 0, maxDepth = depthTree.length; i < maxDepth; i++) {
var nodes = depthTree[i];
for (var j = 0, len = nodes.length; j < len; j++) {
var node = nodes[j];
if (node.sourceLinks.length) {
var sourceSum = getSumOfIds(links, node.sourceLinks);
var weightedSum = getSumWithWeightedSource(tree, links, node.sourceLinks);
var y = weightedSum / sourceSum;
node.y += (y - centerY(node)) * alpha;
}
}
}
};
var relaxRightToLeft = (tree, depthTree, links, alpha) => {
for (var i = depthTree.length - 1; i >= 0; i--) {
var nodes = depthTree[i];
for (var j = 0, len = nodes.length; j < len; j++) {
var node = nodes[j];
if (node.targetLinks.length) {
var targetSum = getSumOfIds(links, node.targetLinks);
var weightedSum = getSumWithWeightedTarget(tree, links, node.targetLinks);
var y = weightedSum / targetSum;
node.y += (y - centerY(node)) * alpha;
}
}
}
};
var updateYOfLinks = (tree, links) => {
for (var i = 0, len = tree.length; i < len; i++) {
var node = tree[i];
var sy = 0;
var ty = 0;
node.targetLinks.sort((a, b) => tree[links[a].target].y - tree[links[b].target].y);
node.sourceLinks.sort((a, b) => tree[links[a].source].y - tree[links[b].source].y);
for (var j = 0, tLen = node.targetLinks.length; j < tLen; j++) {
var link = links[node.targetLinks[j]];
if (link) {
// @ts-expect-error we should refactor this to immutable
link.sy = sy;
sy += link.dy;
}
}
for (var _j2 = 0, sLen = node.sourceLinks.length; _j2 < sLen; _j2++) {
var _link = links[node.sourceLinks[_j2]];
if (_link) {
// @ts-expect-error we should refactor this to immutable
_link.ty = ty;
ty += _link.dy;
}
}
}
};
var computeData = _ref2 => {
var {
data,
width,
height,
iterations,
nodeWidth,
nodePadding,
sort,
verticalAlign,
align
} = _ref2;
var {
links
} = data;
var {
tree
} = getNodesTree(data, width, nodeWidth, align);
var depthTree = getDepthTree(tree);
var linksWithDy = updateYOfTree(depthTree, height, nodePadding, links, verticalAlign);
resolveCollisions(depthTree, height, nodePadding, sort);
if (verticalAlign === 'justify') {
var alpha = 1;
for (var i = 1; i <= iterations; i++) {
relaxRightToLeft(tree, depthTree, linksWithDy, alpha *= 0.99);
resolveCollisions(depthTree, height, nodePadding, sort);
relaxLeftToRight(tree, depthTree, linksWithDy, alpha);
resolveCollisions(depthTree, height, nodePadding, sort);
}
}
updateYOfLinks(tree, linksWithDy);
// @ts-expect-error updateYOfLinks modifies the links array to add sy and ty in place
var newLinks = linksWithDy;
return {
nodes: tree,
links: newLinks
};
};
var getNodeCoordinateOfTooltip = item => {
return {
x: +item.x + +item.width / 2,
y: +item.y + +item.height / 2
};
};
var getLinkCoordinateOfTooltip = item => {
return 'sourceX' in item ? {
x: (item.sourceX + item.targetX) / 2,
y: (item.sourceY + item.targetY) / 2
} : undefined;
};
var getPayloadOfTooltip = (item, type, nameKey) => {
var {
payload
} = item;
if (type === 'node') {
return {
payload,
name: getValueByDataKey(payload, nameKey, ''),
value: getValueByDataKey(payload, 'value')
};
}
if ('source' in payload && payload.source && payload.target) {
var sourceName = getValueByDataKey(payload.source, nameKey, '');
var targetName = getValueByDataKey(payload.target, nameKey, '');
return {
payload,
name: "".concat(sourceName, " - ").concat(targetName),
value: getValueByDataKey(payload, 'value')
};
}
return undefined;
};
export var sankeyPayloadSearcher = (_, activeIndex, computedData, nameKey) => {
if (activeIndex == null || typeof activeIndex !== 'string') {
return undefined;
}
var splitIndex = activeIndex.split('-');
var [targetType, index] = splitIndex;
var item = get(computedData, "".concat(targetType, "s[").concat(index, "]"));
if (item) {
var payload = getPayloadOfTooltip(item, targetType, nameKey);
return payload;
}
return undefined;
};
var options = {
chartName: 'Sankey',
defaultTooltipEventType: 'item',
validateTooltipEventTypes: ['item'],
tooltipPayloadSearcher: sankeyPayloadSearcher,
eventEmitter: undefined
};
function getTooltipEntrySettings(props) {
var {
dataKey,
nameKey,
stroke,
strokeWidth,
fill,
name,
data
} = props;
return {
dataDefinedOnItem: data,
positions: undefined,
settings: {
stroke,
strokeWidth,
fill,
dataKey,
name,
nameKey,
color: fill,
unit: '' // Sankey does not have unit, why?
}
};
}
// TODO: improve types - NodeOptions uses SankeyNode, LinkOptions uses LinkProps. Standardize.
function renderLinkItem(option, props) {
if (/*#__PURE__*/React.isValidElement(option)) {
return /*#__PURE__*/React.cloneElement(option, props);
}
if (typeof option === 'function') {
return option(props);
}
var {
sourceX,
sourceY,
sourceControlX,
targetX,
targetY,
targetControlX,
linkWidth
} = props,
others = _objectWithoutProperties(props, _excluded);
return /*#__PURE__*/React.createElement("path", _extends({
className: "recharts-sankey-link",
d: "\n M".concat(sourceX, ",").concat(sourceY, "\n C").concat(sourceControlX, ",").concat(sourceY, " ").concat(targetControlX, ",").concat(targetY, " ").concat(targetX, ",").concat(targetY, "\n "),
fill: "none",
stroke: "#333",
strokeWidth: linkWidth,
strokeOpacity: "0.2"
}, svgPropertiesNoEvents(others)));
}
var buildLinkProps = _ref3 => {
var {
link,
nodes,
left,
top,
i,
linkContent,
linkCurvature
} = _ref3;
var {
sy: sourceRelativeY,
ty: targetRelativeY,
dy: linkWidth
} = link;
var sourceNode = nodes[link.source];
var targetNode = nodes[link.target];
var sourceX = sourceNode.x + sourceNode.dx + left;
var targetX = targetNode.x + left;
var interpolationFunc = interpolationGenerator(sourceX, targetX);
var sourceControlX = interpolationFunc(linkCurvature);
var targetControlX = interpolationFunc(1 - linkCurvature);
var sourceY = sourceNode.y + sourceRelativeY + linkWidth / 2 + top;
var targetY = targetNode.y + targetRelativeY + linkWidth / 2 + top;
var linkProps = _objectSpread({
sourceX,
// @ts-expect-error the linkContent from below is contributing unknown props
targetX,
sourceY,
// @ts-expect-error the linkContent from below is contributing unknown props
targetY,
sourceControlX,
targetControlX,
sourceRelativeY,
targetRelativeY,
linkWidth,
index: i,
payload: _objectSpread(_objectSpread({}, link), {}, {
source: sourceNode,
target: targetNode
})
}, svgPropertiesNoEventsFromUnknown(linkContent));
return linkProps;
};
function SankeyLinkElement(_ref4) {
var {
props,
i,
linkContent,
onMouseEnter: _onMouseEnter,
onMouseLeave: _onMouseLeave,
onClick: _onClick,
dataKey
} = _ref4;
var activeCoordinate = getLinkCoordinateOfTooltip(props);
var activeIndex = "link-".concat(i);
var dispatch = useAppDispatch();
var events = {
onMouseEnter: e => {
dispatch(setActiveMouseOverItemIndex({
activeIndex,
activeDataKey: dataKey,
activeCoordinate
}));
_onMouseEnter(props, e);
},
onMouseLeave: e => {
dispatch(mouseLeaveItem());
_onMouseLeave(props, e);
},
onClick: e => {
dispatch(setActiveClickItemIndex({
activeIndex,
activeDataKey: dataKey,
activeCoordinate
}));
_onClick(props, e);
}
};
return /*#__PURE__*/React.createElement(Layer, events, renderLinkItem(linkContent, props));
}
function AllSankeyLinkElements(_ref5) {
var {
modifiedLinks,
links,
linkContent,
onMouseEnter,
onMouseLeave,
onClick,
dataKey
} = _ref5;
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-sankey-links",
key: "recharts-sankey-links"
}, links.map((link, i) => {
var linkProps = modifiedLinks[i];
return /*#__PURE__*/React.createElement(SankeyLinkElement, {
key: "link-".concat(link.source, "-").concat(link.target, "-").concat(link.value),
props: linkProps,
linkContent: linkContent,
i: i,
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick,
dataKey: dataKey
});
}));
}
function renderNodeItem(option, props) {
if (/*#__PURE__*/React.isValidElement(option)) {
return /*#__PURE__*/React.cloneElement(option, props);
}
if (typeof option === 'function') {
return option(props);
}
return (
/*#__PURE__*/
// @ts-expect-error recharts radius is not compatible with SVG radius
React.createElement(Rectangle, _extends({
className: "recharts-sankey-node",
fill: "#0088fe",
fillOpacity: "0.8"
}, svgPropertiesNoEvents(props)))
);
}
var buildNodeProps = _ref6 => {
var {
node,
nodeContent,
top,
left,
i
} = _ref6;
var {
x,
y,
dx,
dy
} = node;
// @ts-expect-error nodeContent is passing in unknown props
var nodeProps = _objectSpread(_objectSpread({}, svgPropertiesNoEventsFromUnknown(nodeContent)), {}, {
x: x + left,
y: y + top,
width: dx,
height: dy,
index: i,
payload: node
});
return nodeProps;
};
function NodeElement(_ref7) {
var {
props,
nodeContent,
i,
onMouseEnter: _onMouseEnter2,
onMouseLeave: _onMouseLeave2,
onClick: _onClick2,
dataKey
} = _ref7;
var dispatch = useAppDispatch();
var activeCoordinate = getNodeCoordinateOfTooltip(props);
var activeIndex = "node-".concat(i);
var events = {
onMouseEnter: e => {
dispatch(setActiveMouseOverItemIndex({
activeIndex,
activeDataKey: dataKey,
activeCoordinate
}));
_onMouseEnter2(props, e);
},
onMouseLeave: e => {
dispatch(mouseLeaveItem());
_onMouseLeave2(props, e);
},
onClick: e => {
dispatch(setActiveClickItemIndex({
activeIndex,
activeDataKey: dataKey,
activeCoordinate
}));
_onClick2(props, e);
}
};
return /*#__PURE__*/React.createElement(Layer, events, renderNodeItem(nodeContent, props));
}
function AllNodeElements(_ref8) {
var {
modifiedNodes,
nodeContent,
onMouseEnter,
onMouseLeave,
onClick,
dataKey
} = _ref8;
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-sankey-nodes",
key: "recharts-sankey-nodes"
}, modifiedNodes.map((modifiedNode, i) => {
return /*#__PURE__*/React.createElement(NodeElement, {
key: "node-".concat(modifiedNode.index, "-").concat(modifiedNode.x, "-").concat(modifiedNode.y),
props: modifiedNode,
nodeContent: nodeContent,
i: i,
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick,
dataKey: dataKey
});
}));
}
var sankeyDefaultProps = {
nameKey: 'name',
dataKey: 'value',
nodePadding: 10,
nodeWidth: 10,
linkCurvature: 0.5,
iterations: 32,
margin: {
top: 5,
right: 5,
bottom: 5,
left: 5
},
sort: true,
verticalAlign: 'justify',
align: 'justify'
};
function SankeyImpl(props) {
var {
className,
style,
children
} = props,
others = _objectWithoutProperties(props, _excluded2);
var {
link,
dataKey,
node,
onMouseEnter,
onMouseLeave,
onClick,
data,
iterations,
nodeWidth,
nodePadding,
sort,
linkCurvature,
margin,
verticalAlign,
align
} = props;
var attrs = svgPropertiesNoEvents(others);
var width = useChartWidth();
var height = useChartHeight();
var {
links,
modifiedLinks,
modifiedNodes
} = useMemo(() => {
var _margin$left, _margin$right, _margin$top, _margin$bottom;
if (!data || !width || !height || width <= 0 || height <= 0) {
return {
nodes: [],
links: [],
modifiedLinks: [],
modifiedNodes: []
};
}
var contentWidth = width - ((_margin$left = margin.left) !== null && _margin$left !== void 0 ? _margin$left : 0) - ((_margin$right = margin.right) !== null && _margin$right !== void 0 ? _margin$right : 0);
var contentHeight = height - ((_margin$top = margin.top) !== null && _margin$top !== void 0 ? _margin$top : 0) - ((_margin$bottom = margin.bottom) !== null && _margin$bottom !== void 0 ? _margin$bottom : 0);
var computed = computeData({
data,
width: contentWidth,
height: contentHeight,
iterations,
nodeWidth,
nodePadding,
sort,
verticalAlign,
align
});
var top = margin.top || 0;
var left = margin.left || 0;
var newModifiedLinks = computed.links.map((l, i) => {
return buildLinkProps({
link: l,
nodes: computed.nodes,
i,
top,
left,
linkContent: link,
linkCurvature
});
});
var newModifiedNodes = computed.nodes.map((n, i) => {
return buildNodeProps({
node: n,
nodeContent: node,
i,
top,
left
});
});
return {
nodes: computed.nodes,
links: computed.links,
modifiedLinks: newModifiedLinks,
modifiedNodes: newModifiedNodes
};
}, [data, width, height, margin, iterations, nodeWidth, nodePadding, sort, link, node, linkCurvature, align, verticalAlign]);
var handleMouseEnter = useCallback((item, type, e) => {
if (onMouseEnter) {
onMouseEnter(item, type, e);
}
}, [onMouseEnter]);
var handleMouseLeave = useCallback((item, type, e) => {
if (onMouseLeave) {
onMouseLeave(item, type, e);
}
}, [onMouseLeave]);
var handleClick = useCallback((item, type, e) => {
if (onClick) {
onClick(item, type, e);
}
}, [onClick]);
if (!isPositiveNumber(width) || !isPositiveNumber(height) || !data || !data.links || !data.nodes) {
return null;
}
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetComputedData, {
computedData: {
links: modifiedLinks,
nodes: modifiedNodes
}
}), /*#__PURE__*/React.createElement(Surface, _extends({}, attrs, {
width: width,
height: height
}), children, /*#__PURE__*/React.createElement(AllSankeyLinkElements, {
links: links,
modifiedLinks: modifiedLinks,
linkContent: link,
dataKey: dataKey,
onMouseEnter: (linkProps, e) => handleMouseEnter(linkProps, 'link', e),
onMouseLeave: (linkProps, e) => handleMouseLeave(linkProps, 'link', e),
onClick: (linkProps, e) => handleClick(linkProps, 'link', e)
}), /*#__PURE__*/React.createElement(AllNodeElements, {
modifiedNodes: modifiedNodes,
nodeContent: node,
dataKey: dataKey,
onMouseEnter: (nodeProps, e) => handleMouseEnter(nodeProps, 'node', e),
onMouseLeave: (nodeProps, e) => handleMouseLeave(nodeProps, 'node', e),
onClick: (nodeProps, e) => handleClick(nodeProps, 'node', e)
})));
}
export function Sankey(outsideProps) {
var props = resolveDefaultProps(outsideProps, sankeyDefaultProps);
var {
width,
height,
style,
className
} = props;
var [tooltipPortal, setTooltipPortal] = useState(null);
return /*#__PURE__*/React.createElement(RechartsStoreProvider, {
preloadedState: {
options
},
reduxStoreName: className !== null && className !== void 0 ? className : 'Sankey'
}, /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: props
}), /*#__PURE__*/React.createElement(ReportChartSize, {
width: width,
height: height
}), /*#__PURE__*/React.createElement(ReportChartMargin, {
margin: props.margin
}), /*#__PURE__*/React.createElement(RechartsWrapper, {
className: className,
style: style,
width: width,
height: height
/*
* Sankey, same as Treemap, suffers from overfilling the container
* and causing infinite render loops where the chart keeps growing.
*/,
responsive: false,
ref: node => {
if (node && !tooltipPortal) {
setTooltipPortal(node);
}
},
onMouseEnter: undefined,
onMouseLeave: undefined,
onClick: undefined,
onMouseMove: undefined,
onMouseDown: undefined,
onMouseUp: undefined,
onContextMenu: undefined,
onDoubleClick: undefined,
onTouchStart: undefined,
onTouchMove: undefined,
onTouchEnd: undefined
}, /*#__PURE__*/React.createElement(TooltipPortalContext.Provider, {
value: tooltipPortal
}, /*#__PURE__*/React.createElement(SankeyImpl, props))));
}
Sankey.displayName = 'Sankey';

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { forwardRef } from 'react';
import { arrayTooltipSearcher } from '../state/optionsSlice';
import { CartesianChart } from './CartesianChart';
var allowedTooltipTypes = ['item'];
export var ScatterChart = /*#__PURE__*/forwardRef((props, ref) => {
return /*#__PURE__*/React.createElement(CartesianChart, {
chartName: "ScatterChart",
defaultTooltipEventType: "item",
validateTooltipEventTypes: allowedTooltipTypes,
tooltipPayloadSearcher: arrayTooltipSearcher,
categoricalChartProps: props,
ref: ref
});
});

View File

@@ -0,0 +1,288 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { useState } from 'react';
import { scaleLinear } from 'victory-vendor/d3-scale';
import { clsx } from 'clsx';
import get from 'es-toolkit/compat/get';
import { Surface } from '../container/Surface';
import { Layer } from '../container/Layer';
import { Sector } from '../shape/Sector';
import { Text } from '../component/Text';
import { polarToCartesian } from '../util/PolarUtils';
import { ReportChartMargin, ReportChartSize, useChartHeight, useChartWidth } from '../context/chartLayoutContext';
import { TooltipPortalContext } from '../context/tooltipPortalContext';
import { RechartsWrapper } from './RechartsWrapper';
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
import { useAppDispatch } from '../state/hooks';
var defaultTextProps = {
fontWeight: 'bold',
paintOrder: 'stroke fill',
fontSize: '.75rem',
stroke: '#FFF',
fill: 'black',
pointerEvents: 'none'
};
function getMaxDepthOf(node) {
if (!node.children || node.children.length === 0) return 1;
// Calculate depth for each child and find the maximum
var childDepths = node.children.map(d => getMaxDepthOf(d));
return 1 + Math.max(...childDepths);
}
function convertMapToRecord(map) {
var record = {};
map.forEach((value, key) => {
record[key] = value;
});
return record;
}
function getTooltipEntrySettings(_ref) {
var {
dataKey,
nameKey,
data,
stroke,
fill,
positions
} = _ref;
return {
dataDefinedOnItem: data.children,
// Redux store will not accept a Map because it's not serializable
positions: convertMapToRecord(positions),
// Sunburst does not support many of the properties as other charts do so there's plenty of defaults here
settings: {
stroke,
strokeWidth: undefined,
fill,
nameKey,
dataKey,
// if there is a nameKey use it, otherwise make the name of the tooltip the dataKey itself
name: nameKey ? undefined : dataKey,
hide: false,
type: undefined,
color: fill,
unit: ''
}
};
}
// Why is margin not a sunburst prop? No clue. Probably it should be
var defaultSunburstMargin = {
top: 0,
right: 0,
bottom: 0,
left: 0
};
export var payloadSearcher = (data, activeIndex) => {
if (activeIndex == null) {
return undefined;
}
return get(data, activeIndex);
};
export var addToSunburstNodeIndex = function addToSunburstNodeIndex(indexInChildrenArr) {
var activeTooltipIndexSoFar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return "".concat(activeTooltipIndexSoFar, "children[").concat(indexInChildrenArr, "]");
};
var preloadedState = {
options: {
validateTooltipEventTypes: ['item'],
defaultTooltipEventType: 'item',
chartName: 'Sunburst',
tooltipPayloadSearcher: payloadSearcher,
eventEmitter: undefined
}
};
var SunburstChartImpl = _ref2 => {
var {
className,
data,
children,
padding = 2,
dataKey = 'value',
nameKey = 'name',
ringPadding = 2,
innerRadius = 50,
fill = '#333',
stroke = '#FFF',
textOptions = defaultTextProps,
outerRadius: outerRadiusFromProps,
cx: cxFromProps,
cy: cyFromProps,
startAngle = 0,
endAngle = 360,
onClick,
onMouseEnter,
onMouseLeave,
responsive = false,
style
} = _ref2;
var dispatch = useAppDispatch();
var width = useChartWidth();
var height = useChartHeight();
var [tooltipPortal, setTooltipPortal] = useState(null);
if (width == null || height == null) {
return null;
}
var outerRadius = outerRadiusFromProps !== null && outerRadiusFromProps !== void 0 ? outerRadiusFromProps : Math.min(width, height) / 2;
var cx = cxFromProps !== null && cxFromProps !== void 0 ? cxFromProps : width / 2;
var cy = cyFromProps !== null && cyFromProps !== void 0 ? cyFromProps : height / 2;
var rScale = scaleLinear([0, data[dataKey]], [0, endAngle]);
var treeDepth = getMaxDepthOf(data);
var thickness = (outerRadius - innerRadius) / treeDepth;
var sectors = [];
var positions = new Map([]);
// event handlers
function handleMouseEnter(node, e) {
if (onMouseEnter) onMouseEnter(node, e);
dispatch(setActiveMouseOverItemIndex({
activeIndex: node.tooltipIndex,
activeDataKey: dataKey,
activeCoordinate: positions.get(node.name)
}));
}
function handleMouseLeave(node, e) {
if (onMouseLeave) onMouseLeave(node, e);
dispatch(mouseLeaveItem());
}
function handleClick(node) {
if (onClick) onClick(node);
dispatch(setActiveClickItemIndex({
activeIndex: node.tooltipIndex,
activeDataKey: dataKey,
activeCoordinate: positions.get(node.name)
}));
}
// recursively add nodes for each data point and its children
function drawArcs(childNodes, options) {
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var {
radius,
innerR,
initialAngle,
childColor,
nestedActiveTooltipIndex
} = options;
var currentAngle = initialAngle;
if (!childNodes) return; // base case: no children of this node
childNodes.forEach((d, i) => {
var _ref3, _d$fill;
var currentTooltipIndex = depth === 1 ? "[".concat(i, "]") : addToSunburstNodeIndex(i, nestedActiveTooltipIndex);
var nodeWithIndex = _objectSpread(_objectSpread({}, d), {}, {
tooltipIndex: currentTooltipIndex
});
var arcLength = rScale(d[dataKey]);
var start = currentAngle;
// color priority - if there's a color on the individual point use that, otherwise use parent color or default
var fillColor = (_ref3 = (_d$fill = d === null || d === void 0 ? void 0 : d.fill) !== null && _d$fill !== void 0 ? _d$fill : childColor) !== null && _ref3 !== void 0 ? _ref3 : fill;
var {
x: textX,
y: textY
} = polarToCartesian(0, 0, innerR + radius / 2, -(start + arcLength - arcLength / 2));
currentAngle += arcLength;
sectors.push(/*#__PURE__*/React.createElement("g", {
key: "sunburst-sector-".concat(d.name, "-").concat(i)
}, /*#__PURE__*/React.createElement(Sector, {
onClick: () => handleClick(nodeWithIndex),
onMouseEnter: e => handleMouseEnter(nodeWithIndex, e),
onMouseLeave: e => handleMouseLeave(nodeWithIndex, e),
fill: fillColor,
stroke: stroke,
strokeWidth: padding,
startAngle: start,
endAngle: start + arcLength,
innerRadius: innerR,
outerRadius: innerR + radius,
cx: cx,
cy: cy
}), /*#__PURE__*/React.createElement(Text, _extends({}, textOptions, {
alignmentBaseline: "middle",
textAnchor: "middle",
x: textX + cx,
y: cy - textY
}), d[dataKey])));
var {
x: tooltipX,
y: tooltipY
} = polarToCartesian(cx, cy, innerR + radius / 2, start);
positions.set(d.name, {
x: tooltipX,
y: tooltipY
});
return drawArcs(d.children, {
radius,
innerR: innerR + radius + ringPadding,
initialAngle: start,
childColor: fillColor,
nestedActiveTooltipIndex: currentTooltipIndex
}, depth + 1);
});
}
drawArcs(data.children, {
radius: thickness,
innerR: innerRadius,
initialAngle: startAngle
});
var layerClass = clsx('recharts-sunburst', className);
return /*#__PURE__*/React.createElement(TooltipPortalContext.Provider, {
value: tooltipPortal
}, /*#__PURE__*/React.createElement(RechartsWrapper, {
className: className,
width: width,
height: height,
responsive: responsive,
style: style,
ref: node => {
if (tooltipPortal == null && node != null) {
setTooltipPortal(node);
}
},
onMouseEnter: undefined,
onMouseLeave: undefined,
onClick: undefined,
onMouseMove: undefined,
onMouseDown: undefined,
onMouseUp: undefined,
onContextMenu: undefined,
onDoubleClick: undefined,
onTouchStart: undefined,
onTouchMove: undefined,
onTouchEnd: undefined
}, /*#__PURE__*/React.createElement(Surface, {
width: width,
height: height
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, sectors), /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: {
dataKey,
data,
stroke,
fill,
nameKey,
positions
}
}), children)));
};
export var SunburstChart = props => {
var _props$className;
return /*#__PURE__*/React.createElement(RechartsStoreProvider, {
preloadedState: preloadedState,
reduxStoreName: (_props$className = props.className) !== null && _props$className !== void 0 ? _props$className : 'SunburstChart'
}, /*#__PURE__*/React.createElement(ReportChartSize, {
width: props.width,
height: props.height
}), /*#__PURE__*/React.createElement(ReportChartMargin, {
margin: defaultSunburstMargin
}), /*#__PURE__*/React.createElement(SunburstChartImpl, props));
};

790
frontend/node_modules/recharts/es6/chart/Treemap.js generated vendored Normal file
View File

@@ -0,0 +1,790 @@
var _excluded = ["width", "height", "className", "style", "children", "type"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { PureComponent, useCallback, useState } from 'react';
import omit from 'es-toolkit/compat/omit';
import get from 'es-toolkit/compat/get';
import { Layer } from '../container/Layer';
import { Surface } from '../container/Surface';
import { Polygon } from '../shape/Polygon';
import { Rectangle } from '../shape/Rectangle';
import { getValueByDataKey } from '../util/ChartUtils';
import { COLOR_PANEL } from '../util/Constants';
import { isNan, uniqueId } from '../util/DataUtils';
import { getStringSize } from '../util/DOMUtils';
import { Global } from '../util/Global';
import { ReportChartMargin, useChartHeight, useChartWidth } from '../context/chartLayoutContext';
import { TooltipPortalContext } from '../context/tooltipPortalContext';
import { RechartsWrapper } from './RechartsWrapper';
import { setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
import { useAppDispatch } from '../state/hooks';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { CSSTransitionAnimate } from '../animation/CSSTransitionAnimate';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
var NODE_VALUE_KEY = 'value';
/**
* This is what end users defines as `data` on Treemap.
*/
/**
* This is what is returned from `squarify`, the final treemap data structure
* that gets rendered and is stored in
*/
export var treemapPayloadSearcher = (data, activeIndex) => {
if (!data || !activeIndex) {
return undefined;
}
return get(data, activeIndex);
};
export var addToTreemapNodeIndex = function addToTreemapNodeIndex(indexInChildrenArr) {
var activeTooltipIndexSoFar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return "".concat(activeTooltipIndexSoFar, "children[").concat(indexInChildrenArr, "]");
};
var options = {
chartName: 'Treemap',
defaultTooltipEventType: 'item',
validateTooltipEventTypes: ['item'],
tooltipPayloadSearcher: treemapPayloadSearcher,
eventEmitter: undefined
};
export var computeNode = _ref => {
var {
depth,
node,
index,
dataKey,
nameKey,
nestedActiveTooltipIndex
} = _ref;
var currentTooltipIndex = depth === 0 ? '' : addToTreemapNodeIndex(index, nestedActiveTooltipIndex);
var {
children
} = node;
var childDepth = depth + 1;
var computedChildren = children && children.length ? children.map((child, i) => computeNode({
depth: childDepth,
node: child,
index: i,
dataKey,
nameKey,
nestedActiveTooltipIndex: currentTooltipIndex
})) : null;
var nodeValue;
if (computedChildren && computedChildren.length) {
nodeValue = computedChildren.reduce((result, child) => result + child[NODE_VALUE_KEY], 0);
} else {
// TODO need to verify dataKey
nodeValue = isNan(node[dataKey]) || node[dataKey] <= 0 ? 0 : node[dataKey];
}
return _objectSpread(_objectSpread({}, node), {}, {
children: computedChildren,
// @ts-expect-error getValueByDataKey does not validate the output type
name: getValueByDataKey(node, nameKey, ''),
[NODE_VALUE_KEY]: nodeValue,
depth,
index,
tooltipIndex: currentTooltipIndex
});
};
var filterRect = node => ({
x: node.x,
y: node.y,
width: node.width,
height: node.height
});
// Compute the area for each child based on value & scale.
var getAreaOfChildren = (children, areaValueRatio) => {
var ratio = areaValueRatio < 0 ? 0 : areaValueRatio;
return children.map(child => {
var area = child[NODE_VALUE_KEY] * ratio;
return _objectSpread(_objectSpread({}, child), {}, {
area: isNan(area) || area <= 0 ? 0 : area
});
});
};
// Computes the score for the specified row, as the worst aspect ratio.
var getWorstScore = (row, parentSize, aspectRatio) => {
var parentArea = parentSize * parentSize;
var rowArea = row.area * row.area;
var {
min,
max
} = row.reduce((result, child) => ({
min: Math.min(result.min, child.area),
max: Math.max(result.max, child.area)
}), {
min: Infinity,
max: 0
});
return rowArea ? Math.max(parentArea * max * aspectRatio / rowArea, rowArea / (parentArea * min * aspectRatio)) : Infinity;
};
var horizontalPosition = (row, parentSize, parentRect, isFlush) => {
var rowHeight = parentSize ? Math.round(row.area / parentSize) : 0;
if (isFlush || rowHeight > parentRect.height) {
rowHeight = parentRect.height;
}
var curX = parentRect.x;
var child;
for (var i = 0, len = row.length; i < len; i++) {
child = row[i];
child.x = curX;
child.y = parentRect.y;
child.height = rowHeight;
child.width = Math.min(rowHeight ? Math.round(child.area / rowHeight) : 0, parentRect.x + parentRect.width - curX);
curX += child.width;
}
// add the remain x to the last one of row
if (child != null) {
child.width += parentRect.x + parentRect.width - curX;
}
return _objectSpread(_objectSpread({}, parentRect), {}, {
y: parentRect.y + rowHeight,
height: parentRect.height - rowHeight
});
};
var verticalPosition = (row, parentSize, parentRect, isFlush) => {
var rowWidth = parentSize ? Math.round(row.area / parentSize) : 0;
if (isFlush || rowWidth > parentRect.width) {
rowWidth = parentRect.width;
}
var curY = parentRect.y;
var child;
for (var i = 0, len = row.length; i < len; i++) {
child = row[i];
child.x = parentRect.x;
child.y = curY;
child.width = rowWidth;
child.height = Math.min(rowWidth ? Math.round(child.area / rowWidth) : 0, parentRect.y + parentRect.height - curY);
curY += child.height;
}
if (child) {
child.height += parentRect.y + parentRect.height - curY;
}
return _objectSpread(_objectSpread({}, parentRect), {}, {
x: parentRect.x + rowWidth,
width: parentRect.width - rowWidth
});
};
var position = (row, parentSize, parentRect, isFlush) => {
if (parentSize === parentRect.width) {
return horizontalPosition(row, parentSize, parentRect, isFlush);
}
return verticalPosition(row, parentSize, parentRect, isFlush);
};
// Recursively arranges the specified node's children into squarified rows.
var squarify = (node, aspectRatio) => {
var {
children
} = node;
if (children && children.length) {
var rect = filterRect(node);
// @ts-expect-error we can't create an array with static property on a single line so typescript will complain.
var row = [];
var best = Infinity; // the best row score so far
var child, score; // the current row score
var size = Math.min(rect.width, rect.height); // initial orientation
var scaleChildren = getAreaOfChildren(children, rect.width * rect.height / node[NODE_VALUE_KEY]);
var tempChildren = scaleChildren.slice();
// why are we setting static properties on an array?
row.area = 0;
while (tempChildren.length > 0) {
// row first
// eslint-disable-next-line prefer-destructuring
row.push(child = tempChildren[0]);
row.area += child.area;
score = getWorstScore(row, size, aspectRatio);
if (score <= best) {
// continue with this orientation
tempChildren.shift();
best = score;
} else {
var _row$pop$area, _row$pop;
// abort, and try a different orientation
row.area -= (_row$pop$area = (_row$pop = row.pop()) === null || _row$pop === void 0 ? void 0 : _row$pop.area) !== null && _row$pop$area !== void 0 ? _row$pop$area : 0;
rect = position(row, size, rect, false);
size = Math.min(rect.width, rect.height);
row.length = row.area = 0;
best = Infinity;
}
}
if (row.length) {
rect = position(row, size, rect, true);
row.length = row.area = 0;
}
return _objectSpread(_objectSpread({}, node), {}, {
children: scaleChildren.map(c => squarify(c, aspectRatio))
});
}
return node;
};
var defaultTreeMapProps = {
aspectRatio: 0.5 * (1 + Math.sqrt(5)),
dataKey: 'value',
nameKey: 'name',
type: 'flat',
isAnimationActive: !Global.isSsr,
isUpdateAnimationActive: !Global.isSsr,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'linear'
};
var defaultState = {
isAnimationFinished: false,
formatRoot: null,
currentRoot: null,
nestIndex: [],
prevAspectRatio: defaultTreeMapProps.aspectRatio,
prevDataKey: defaultTreeMapProps.dataKey
};
function ContentItem(_ref2) {
var {
content,
nodeProps,
type,
colorPanel,
onMouseEnter,
onMouseLeave,
onClick
} = _ref2;
if (/*#__PURE__*/React.isValidElement(content)) {
return /*#__PURE__*/React.createElement(Layer, {
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick
}, /*#__PURE__*/React.cloneElement(content, nodeProps));
}
if (typeof content === 'function') {
return /*#__PURE__*/React.createElement(Layer, {
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick
}, content(nodeProps));
}
// optimize default shape
var {
x,
y,
width,
height,
index
} = nodeProps;
var arrow = null;
if (width > 10 && height > 10 && nodeProps.children && type === 'nest') {
arrow = /*#__PURE__*/React.createElement(Polygon, {
points: [{
x: x + 2,
y: y + height / 2
}, {
x: x + 6,
y: y + height / 2 + 3
}, {
x: x + 2,
y: y + height / 2 + 6
}]
});
}
var text = null;
var nameSize = getStringSize(nodeProps.name);
if (width > 20 && height > 20 && nameSize.width < width && nameSize.height < height) {
text = /*#__PURE__*/React.createElement("text", {
x: x + 8,
y: y + height / 2 + 7,
fontSize: 14
}, nodeProps.name);
}
var colors = colorPanel || COLOR_PANEL;
return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement(Rectangle, _extends({
fill: nodeProps.depth < 2 ? colors[index % colors.length] : 'rgba(255,255,255,0)',
stroke: "#fff"
}, omit(nodeProps, ['children']), {
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick,
"data-recharts-item-index": nodeProps.tooltipIndex
})), arrow, text);
}
function ContentItemWithEvents(props) {
var dispatch = useAppDispatch();
var activeCoordinate = {
x: props.nodeProps.x + props.nodeProps.width / 2,
y: props.nodeProps.y + props.nodeProps.height / 2
};
var onMouseEnter = () => {
dispatch(setActiveMouseOverItemIndex({
activeIndex: props.nodeProps.tooltipIndex,
activeDataKey: props.dataKey,
activeCoordinate
}));
};
var onMouseLeave = () => {
// clearing state on mouseLeaveItem causes re-rendering issues
// we don't actually want to do this for TreeMap - we clear state when we leave the entire chart instead
};
var onClick = () => {
dispatch(setActiveClickItemIndex({
activeIndex: props.nodeProps.tooltipIndex,
activeDataKey: props.dataKey,
activeCoordinate
}));
};
return /*#__PURE__*/React.createElement(ContentItem, _extends({}, props, {
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick
}));
}
function getTooltipEntrySettings(_ref3) {
var {
props,
currentRoot
} = _ref3;
var {
dataKey,
nameKey,
stroke,
fill
} = props;
return {
dataDefinedOnItem: currentRoot,
positions: undefined,
// TODO I think Treemap has the capability of computing positions and supporting defaultIndex? Except it doesn't yet
settings: {
stroke,
strokeWidth: undefined,
fill,
dataKey,
nameKey,
name: undefined,
// Each TreemapNode has its own name
hide: false,
type: undefined,
color: fill,
unit: ''
}
};
}
// Why is margin not a treemap prop? No clue. Probably it should be
var defaultTreemapMargin = {
top: 0,
right: 0,
bottom: 0,
left: 0
};
function TreemapItem(_ref4) {
var {
content,
nodeProps,
isLeaf,
treemapProps,
onNestClick
} = _ref4;
var {
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
isUpdateAnimationActive,
type,
colorPanel,
dataKey,
onAnimationStart,
onAnimationEnd,
onMouseEnter: onMouseEnterFromProps,
onClick: onItemClickFromProps,
onMouseLeave: onMouseLeaveFromProps
} = treemapProps;
var {
width,
height,
x,
y
} = nodeProps;
var translateX = -x - width;
var translateY = 0;
var onMouseEnter = e => {
if ((isLeaf || type === 'nest') && typeof onMouseEnterFromProps === 'function') {
onMouseEnterFromProps(nodeProps, e);
}
};
var onMouseLeave = e => {
if ((isLeaf || type === 'nest') && typeof onMouseLeaveFromProps === 'function') {
onMouseLeaveFromProps(nodeProps, e);
}
};
var onClick = () => {
if (type === 'nest') {
onNestClick(nodeProps);
}
if ((isLeaf || type === 'nest') && typeof onItemClickFromProps === 'function') {
onItemClickFromProps(nodeProps);
}
};
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
}, [onAnimationStart]);
return /*#__PURE__*/React.createElement(CSSTransitionAnimate, {
animationId: "treemap-".concat(nodeProps.tooltipIndex),
from: "translate(".concat(translateX, "px, ").concat(translateY, "px)"),
to: "translate(0, 0)",
attributeName: "transform",
begin: animationBegin,
easing: animationEasing,
isActive: isAnimationActive,
duration: animationDuration,
onAnimationStart: handleAnimationStart,
onAnimationEnd: handleAnimationEnd
}, style => /*#__PURE__*/React.createElement(Layer, {
onMouseEnter: onMouseEnter,
onMouseLeave: onMouseLeave,
onClick: onClick,
style: _objectSpread(_objectSpread({}, style), {}, {
transformOrigin: "".concat(x, " ").concat(y)
})
}, /*#__PURE__*/React.createElement(ContentItemWithEvents, {
content: content,
dataKey: dataKey,
nodeProps: _objectSpread(_objectSpread({}, nodeProps), {}, {
isAnimationActive,
isUpdateAnimationActive: !isUpdateAnimationActive,
width,
height,
x,
y
}),
type: type,
colorPanel: colorPanel
})));
}
class TreemapWithState extends PureComponent {
constructor() {
super(...arguments);
_defineProperty(this, "state", _objectSpread({}, defaultState));
_defineProperty(this, "handleClick", node => {
var {
onClick,
type
} = this.props;
if (type === 'nest' && node.children) {
var {
width,
height,
dataKey,
nameKey,
aspectRatio
} = this.props;
var root = computeNode({
depth: 0,
node: _objectSpread(_objectSpread({}, node), {}, {
x: 0,
y: 0,
width,
height
}),
index: 0,
dataKey,
nameKey,
// with Treemap nesting, should this continue nesting the index or start from empty string?
nestedActiveTooltipIndex: node.tooltipIndex
});
var formatRoot = squarify(root, aspectRatio);
var {
nestIndex
} = this.state;
nestIndex.push(node);
this.setState({
formatRoot,
currentRoot: root,
nestIndex
});
}
if (onClick) {
onClick(node);
}
});
_defineProperty(this, "handleTouchMove", e => {
var touchEvent = e.touches[0];
var target = document.elementFromPoint(touchEvent.clientX, touchEvent.clientY);
if (!target || !target.getAttribute || this.state.formatRoot == null) {
return;
}
var itemIndex = target.getAttribute('data-recharts-item-index');
var activeNode = treemapPayloadSearcher(this.state.formatRoot, itemIndex);
if (!activeNode) {
return;
}
var {
dataKey,
dispatch
} = this.props;
var activeCoordinate = {
x: activeNode.x + activeNode.width / 2,
y: activeNode.y + activeNode.height / 2
};
// Treemap does not support onTouchMove prop, but it could
// onTouchMove?.(activeNode, Number(itemIndex), e);
dispatch(setActiveMouseOverItemIndex({
activeIndex: itemIndex,
activeDataKey: dataKey,
activeCoordinate
}));
});
}
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.data !== prevState.prevData || nextProps.type !== prevState.prevType || nextProps.width !== prevState.prevWidth || nextProps.height !== prevState.prevHeight || nextProps.dataKey !== prevState.prevDataKey || nextProps.aspectRatio !== prevState.prevAspectRatio) {
var root = computeNode({
depth: 0,
// @ts-expect-error missing properties
node: {
children: nextProps.data,
x: 0,
y: 0,
width: nextProps.width,
height: nextProps.height
},
index: 0,
dataKey: nextProps.dataKey,
nameKey: nextProps.nameKey
});
var formatRoot = squarify(root, nextProps.aspectRatio);
return _objectSpread(_objectSpread({}, prevState), {}, {
formatRoot,
currentRoot: root,
nestIndex: [root],
prevAspectRatio: nextProps.aspectRatio,
prevData: nextProps.data,
prevWidth: nextProps.width,
prevHeight: nextProps.height,
prevDataKey: nextProps.dataKey,
prevType: nextProps.type
});
}
return null;
}
handleNestIndex(node, i) {
var {
nestIndex
} = this.state;
var {
width,
height,
dataKey,
nameKey,
aspectRatio
} = this.props;
var root = computeNode({
depth: 0,
node: _objectSpread(_objectSpread({}, node), {}, {
x: 0,
y: 0,
width,
height
}),
index: 0,
dataKey,
nameKey,
// with Treemap nesting, should this continue nesting the index or start from empty string?
nestedActiveTooltipIndex: node.tooltipIndex
});
var formatRoot = squarify(root, aspectRatio);
nestIndex = nestIndex.slice(0, i + 1);
this.setState({
formatRoot,
currentRoot: node,
nestIndex
});
}
renderNode(root, node) {
var {
content,
type
} = this.props;
var nodeProps = _objectSpread(_objectSpread(_objectSpread({}, svgPropertiesNoEvents(this.props)), node), {}, {
root
});
var isLeaf = !node.children || !node.children.length;
var {
currentRoot
} = this.state;
var isCurrentRootChild = ((currentRoot === null || currentRoot === void 0 ? void 0 : currentRoot.children) || []).filter(item => item.depth === node.depth && item.name === node.name);
if (!isCurrentRootChild.length && root.depth && type === 'nest') {
return null;
}
return /*#__PURE__*/React.createElement(Layer, {
key: "recharts-treemap-node-".concat(nodeProps.x, "-").concat(nodeProps.y, "-").concat(nodeProps.name),
className: "recharts-treemap-depth-".concat(node.depth)
}, /*#__PURE__*/React.createElement(TreemapItem, {
isLeaf: isLeaf,
content: content,
nodeProps: nodeProps,
treemapProps: this.props,
onNestClick: this.handleClick
}), node.children && node.children.length ? node.children.map(child => this.renderNode(node, child)) : null);
}
renderAllNodes() {
var {
formatRoot
} = this.state;
if (!formatRoot) {
return null;
}
return this.renderNode(formatRoot, formatRoot);
}
// render nest treemap
renderNestIndex() {
var {
nameKey,
nestIndexContent
} = this.props;
var {
nestIndex
} = this.state;
return /*#__PURE__*/React.createElement("div", {
className: "recharts-treemap-nest-index-wrapper",
style: {
marginTop: '8px',
textAlign: 'center'
}
}, nestIndex.map((item, i) => {
// TODO need to verify nameKey type
var name = get(item, nameKey, 'root');
var content;
if (/*#__PURE__*/React.isValidElement(nestIndexContent)) {
// the cloned content is ignored at all times - let's remove it?
content = /*#__PURE__*/React.cloneElement(nestIndexContent, item, i);
}
if (typeof nestIndexContent === 'function') {
content = nestIndexContent(item, i);
} else {
content = name;
}
return (
/*#__PURE__*/
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
React.createElement("div", {
onClick: this.handleNestIndex.bind(this, item, i),
key: "nest-index-".concat(uniqueId()),
className: "recharts-treemap-nest-index-box",
style: {
cursor: 'pointer',
display: 'inline-block',
padding: '0 7px',
background: '#000',
color: '#fff',
marginRight: '3px'
}
}, content)
);
}));
}
render() {
var _this$props = this.props,
{
width,
height,
className,
style,
children,
type
} = _this$props,
others = _objectWithoutProperties(_this$props, _excluded);
var attrs = svgPropertiesNoEvents(others);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: {
props: this.props,
currentRoot: this.state.currentRoot
}
}), /*#__PURE__*/React.createElement(Surface, _extends({}, attrs, {
width: width,
height: type === 'nest' ? height - 30 : height,
onTouchMove: this.handleTouchMove
}), this.renderAllNodes(), children), type === 'nest' && this.renderNestIndex());
}
}
_defineProperty(TreemapWithState, "displayName", 'Treemap');
function TreemapDispatchInject(props) {
var dispatch = useAppDispatch();
var width = useChartWidth();
var height = useChartHeight();
if (!isPositiveNumber(width) || !isPositiveNumber(height)) {
return null;
}
return /*#__PURE__*/React.createElement(TreemapWithState, _extends({}, props, {
width: width,
height: height,
dispatch: dispatch
}));
}
export function Treemap(outsideProps) {
var _props$className;
var props = resolveDefaultProps(outsideProps, defaultTreeMapProps);
var {
className,
style,
width,
height
} = props;
var [tooltipPortal, setTooltipPortal] = useState(null);
return /*#__PURE__*/React.createElement(RechartsStoreProvider, {
preloadedState: {
options
},
reduxStoreName: (_props$className = props.className) !== null && _props$className !== void 0 ? _props$className : 'Treemap'
}, /*#__PURE__*/React.createElement(ReportChartMargin, {
margin: defaultTreemapMargin
}), /*#__PURE__*/React.createElement(RechartsWrapper, {
dispatchTouchEvents: false,
className: className,
style: style,
width: width,
height: height
/*
* Treemap has a bug where it doesn't include strokeWidth in its dimension calculation
* which makes the actual chart exactly {strokeWidth} larger than asked for.
* It's not a huge deal usually, but it makes the responsive option cycle infinitely.
*/,
responsive: false,
ref: node => {
if (tooltipPortal == null && node != null) {
setTooltipPortal(node);
}
},
onMouseEnter: undefined,
onMouseLeave: undefined,
onClick: undefined,
onMouseMove: undefined,
onMouseDown: undefined,
onMouseUp: undefined,
onContextMenu: undefined,
onDoubleClick: undefined,
onTouchStart: undefined,
onTouchMove: undefined,
onTouchEnd: undefined
}, /*#__PURE__*/React.createElement(TooltipPortalContext.Provider, {
value: tooltipPortal
}, /*#__PURE__*/React.createElement(TreemapDispatchInject, props))));
}

1
frontend/node_modules/recharts/es6/chart/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,83 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { cloneElement, isValidElement } from 'react';
import { adaptEventHandlers } from '../util/types';
import { Dot } from '../shape/Dot';
import { Layer } from '../container/Layer';
import { useAppSelector } from '../state/hooks';
import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
import { useActiveTooltipDataPoints } from '../hooks';
import { isNullish } from '../util/DataUtils';
import { svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
var ActivePoint = _ref => {
var {
point,
childIndex,
mainColor,
activeDot,
dataKey
} = _ref;
if (activeDot === false || point.x == null || point.y == null) {
return null;
}
var dotPropsTyped = {
index: childIndex,
dataKey,
cx: point.x,
cy: point.y,
r: 4,
fill: mainColor !== null && mainColor !== void 0 ? mainColor : 'none',
strokeWidth: 2,
stroke: '#fff',
payload: point.payload,
value: point.value
};
// @ts-expect-error svgPropertiesNoEventsFromUnknown(activeDot) is contributing unknown props
var dotProps = _objectSpread(_objectSpread(_objectSpread({}, dotPropsTyped), svgPropertiesNoEventsFromUnknown(activeDot)), adaptEventHandlers(activeDot));
var dot;
if (/*#__PURE__*/isValidElement(activeDot)) {
// @ts-expect-error we're improperly typing events
dot = /*#__PURE__*/cloneElement(activeDot, dotProps);
} else if (typeof activeDot === 'function') {
dot = activeDot(dotProps);
} else {
dot = /*#__PURE__*/React.createElement(Dot, dotProps);
}
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-active-dot"
}, dot);
};
export function ActivePoints(_ref2) {
var {
points,
mainColor,
activeDot,
itemDataKey,
zIndex = DefaultZIndexes.activeDot
} = _ref2;
var activeTooltipIndex = useAppSelector(selectActiveTooltipIndex);
var activeDataPoints = useActiveTooltipDataPoints();
if (points == null || activeDataPoints == null) {
return null;
}
var activePoint = points.find(p => activeDataPoints.includes(p.payload));
if (isNullish(activePoint)) {
return null;
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex
}, /*#__PURE__*/React.createElement(ActivePoint, {
point: activePoint,
childIndex: Number(activeTooltipIndex),
mainColor: mainColor,
dataKey: itemDataKey,
activeDot: activeDot
}));
}

6
frontend/node_modules/recharts/es6/component/Cell.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* @fileOverview Cross
*/
export var Cell = _props => null;
Cell.displayName = 'Cell';

137
frontend/node_modules/recharts/es6/component/Cursor.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { cloneElement, createElement, isValidElement } from 'react';
import { clsx } from 'clsx';
import { isPolarCoordinate } from '../util/types';
import { Curve } from '../shape/Curve';
import { Cross } from '../shape/Cross';
import { getCursorRectangle } from '../util/cursor/getCursorRectangle';
import { Rectangle } from '../shape/Rectangle';
import { getRadialCursorPoints } from '../util/cursor/getRadialCursorPoints';
import { Sector } from '../shape/Sector';
import { getCursorPoints } from '../util/cursor/getCursorPoints';
import { useChartLayout, useOffsetInternal } from '../context/chartLayoutContext';
import { useTooltipAxisBandSize } from '../context/useTooltipAxis';
import { useChartName } from '../state/selectors/selectors';
import { svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* If set false, no cursor will be drawn when tooltip is active.
* If set an object, the option is the configuration of cursor.
* If set a React element, the option is the custom react element of drawing cursor
*/
function RenderCursor(_ref) {
var {
cursor,
cursorComp,
cursorProps
} = _ref;
if (/*#__PURE__*/isValidElement(cursor)) {
return /*#__PURE__*/cloneElement(cursor, cursorProps);
}
return /*#__PURE__*/createElement(cursorComp, cursorProps);
}
export function CursorInternal(props) {
var _props$zIndex;
var {
coordinate,
payload,
index,
offset,
tooltipAxisBandSize,
layout,
cursor,
tooltipEventType,
chartName
} = props;
// The cursor is a part of the Tooltip, and it should be shown (by default) when the Tooltip is active.
var activeCoordinate = coordinate;
var activePayload = payload;
var activeTooltipIndex = index;
if (!cursor || !activeCoordinate || chartName !== 'ScatterChart' && tooltipEventType !== 'axis') {
return null;
}
var restProps, cursorComp, preferredZIndex;
if (chartName === 'ScatterChart') {
restProps = activeCoordinate;
cursorComp = Cross;
preferredZIndex = DefaultZIndexes.cursorLine;
} else if (chartName === 'BarChart') {
restProps = getCursorRectangle(layout, activeCoordinate, offset, tooltipAxisBandSize);
cursorComp = Rectangle;
preferredZIndex = DefaultZIndexes.cursorRectangle;
} else if (layout === 'radial' && isPolarCoordinate(activeCoordinate)) {
var {
cx,
cy,
radius,
startAngle,
endAngle
} = getRadialCursorPoints(activeCoordinate);
restProps = {
cx,
cy,
startAngle,
endAngle,
innerRadius: radius,
outerRadius: radius
};
cursorComp = Sector;
preferredZIndex = DefaultZIndexes.cursorLine;
} else {
restProps = {
points: getCursorPoints(layout, activeCoordinate, offset)
};
cursorComp = Curve;
preferredZIndex = DefaultZIndexes.cursorLine;
}
var extraClassName = typeof cursor === 'object' && 'className' in cursor ? cursor.className : undefined;
var cursorProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
stroke: '#ccc',
pointerEvents: 'none'
}, offset), restProps), svgPropertiesNoEventsFromUnknown(cursor)), {}, {
payload: activePayload,
payloadIndex: activeTooltipIndex,
className: clsx('recharts-tooltip-cursor', extraClassName)
});
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: (_props$zIndex = props.zIndex) !== null && _props$zIndex !== void 0 ? _props$zIndex : preferredZIndex
}, /*#__PURE__*/React.createElement(RenderCursor, {
cursor: cursor,
cursorComp: cursorComp,
cursorProps: cursorProps
}));
}
/*
* Cursor is the background, or a highlight,
* that shows when user mouses over or activates
* an area.
*
* It usually shows together with a tooltip
* to emphasise which part of the chart does the tooltip refer to.
*/
export function Cursor(props) {
var tooltipAxisBandSize = useTooltipAxisBandSize();
var offset = useOffsetInternal();
var layout = useChartLayout();
var chartName = useChartName();
if (tooltipAxisBandSize == null || offset == null || layout == null || chartName == null) {
return null;
}
return /*#__PURE__*/React.createElement(CursorInternal, _extends({}, props, {
offset: offset,
layout: layout,
tooltipAxisBandSize: tooltipAxisBandSize,
chartName: chartName
}));
}

View File

@@ -0,0 +1,33 @@
var _excluded = ["component"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Customized
*/
import * as React from 'react';
import { isValidElement, cloneElement, createElement } from 'react';
import { Layer } from '../container/Layer';
import { warn } from '../util/LogUtils';
/**
* custom svg elements by rechart instance props and state.
* @returns {Object} svg elements
*/
export function Customized(_ref) {
var {
component
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
var child;
if (/*#__PURE__*/isValidElement(component)) {
child = /*#__PURE__*/cloneElement(component, props);
} else if (typeof component === 'function') {
// @ts-expect-error TS cannot verify that C is FunctionComponent<P> here
child = /*#__PURE__*/createElement(component, props);
} else {
warn(false, "Customized's props `component` must be React.element or Function, but got %s.", typeof component);
}
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-customized-wrapper"
}, child);
}
Customized.displayName = 'Customized';

View File

@@ -0,0 +1,162 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* @fileOverview Default Legend Content
*/
import * as React from 'react';
import { clsx } from 'clsx';
import { Surface } from '../container/Surface';
import { Symbols } from '../shape/Symbols';
import { adaptEventsOfChild } from '../util/types';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
var SIZE = 32;
var defaultLegendContentDefaultProps = {
align: 'center',
iconSize: 14,
inactiveColor: '#ccc',
layout: 'horizontal',
verticalAlign: 'middle'
};
function Icon(_ref) {
var {
data,
iconType,
inactiveColor
} = _ref;
var halfSize = SIZE / 2;
var sixthSize = SIZE / 6;
var thirdSize = SIZE / 3;
var color = data.inactive ? inactiveColor : data.color;
var preferredIcon = iconType !== null && iconType !== void 0 ? iconType : data.type;
if (preferredIcon === 'none') {
return null;
}
if (preferredIcon === 'plainline') {
var _data$payload;
return /*#__PURE__*/React.createElement("line", {
strokeWidth: 4,
fill: "none",
stroke: color,
strokeDasharray: (_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.strokeDasharray,
x1: 0,
y1: halfSize,
x2: SIZE,
y2: halfSize,
className: "recharts-legend-icon"
});
}
if (preferredIcon === 'line') {
return /*#__PURE__*/React.createElement("path", {
strokeWidth: 4,
fill: "none",
stroke: color,
d: "M0,".concat(halfSize, "h").concat(thirdSize, "\n A").concat(sixthSize, ",").concat(sixthSize, ",0,1,1,").concat(2 * thirdSize, ",").concat(halfSize, "\n H").concat(SIZE, "M").concat(2 * thirdSize, ",").concat(halfSize, "\n A").concat(sixthSize, ",").concat(sixthSize, ",0,1,1,").concat(thirdSize, ",").concat(halfSize),
className: "recharts-legend-icon"
});
}
if (preferredIcon === 'rect') {
return /*#__PURE__*/React.createElement("path", {
stroke: "none",
fill: color,
d: "M0,".concat(SIZE / 8, "h").concat(SIZE, "v").concat(SIZE * 3 / 4, "h").concat(-SIZE, "z"),
className: "recharts-legend-icon"
});
}
if (/*#__PURE__*/React.isValidElement(data.legendIcon)) {
var iconProps = _objectSpread({}, data);
delete iconProps.legendIcon;
return /*#__PURE__*/React.cloneElement(data.legendIcon, iconProps);
}
return /*#__PURE__*/React.createElement(Symbols, {
fill: color,
cx: halfSize,
cy: halfSize,
size: SIZE,
sizeType: "diameter",
type: preferredIcon
});
}
function Items(props) {
var {
payload,
iconSize,
layout,
formatter,
inactiveColor,
iconType
} = props;
var viewBox = {
x: 0,
y: 0,
width: SIZE,
height: SIZE
};
var itemStyle = {
display: layout === 'horizontal' ? 'inline-block' : 'block',
marginRight: 10
};
var svgStyle = {
display: 'inline-block',
verticalAlign: 'middle',
marginRight: 4
};
return payload.map((entry, i) => {
var finalFormatter = entry.formatter || formatter;
var className = clsx({
'recharts-legend-item': true,
["legend-item-".concat(i)]: true,
inactive: entry.inactive
});
if (entry.type === 'none') {
return null;
}
var color = entry.inactive ? inactiveColor : entry.color;
var finalValue = finalFormatter ? finalFormatter(entry.value, entry, i) : entry.value;
return /*#__PURE__*/React.createElement("li", _extends({
className: className,
style: itemStyle,
key: "legend-item-".concat(i)
}, adaptEventsOfChild(props, entry, i)), /*#__PURE__*/React.createElement(Surface, {
width: iconSize,
height: iconSize,
viewBox: viewBox,
style: svgStyle,
"aria-label": "".concat(finalValue, " legend icon")
}, /*#__PURE__*/React.createElement(Icon, {
data: entry,
iconType: iconType,
inactiveColor: inactiveColor
})), /*#__PURE__*/React.createElement("span", {
className: "recharts-legend-item-text",
style: {
color
}
}, finalValue));
});
}
export var DefaultLegendContent = outsideProps => {
var props = resolveDefaultProps(outsideProps, defaultLegendContentDefaultProps);
var {
payload,
layout,
align
} = props;
if (!payload || !payload.length) {
return null;
}
var finalStyle = {
padding: 0,
margin: 0,
textAlign: layout === 'horizontal' ? align : 'left'
};
return /*#__PURE__*/React.createElement("ul", {
className: "recharts-default-legend",
style: finalStyle
}, /*#__PURE__*/React.createElement(Items, _extends({}, props, {
payload: payload
})));
};

View File

@@ -0,0 +1,115 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* @fileOverview Default Tooltip Content
*/
import * as React from 'react';
import sortBy from 'es-toolkit/compat/sortBy';
import { clsx } from 'clsx';
import { isNullish, isNumOrStr } from '../util/DataUtils';
function defaultFormatter(value) {
return Array.isArray(value) && isNumOrStr(value[0]) && isNumOrStr(value[1]) ? value.join(' ~ ') : value;
}
export var DefaultTooltipContent = props => {
var {
separator = ' : ',
contentStyle = {},
itemStyle = {},
labelStyle = {},
payload,
formatter,
itemSorter,
wrapperClassName,
labelClassName,
label,
labelFormatter,
accessibilityLayer = false
} = props;
var renderContent = () => {
if (payload && payload.length) {
var listStyle = {
padding: 0,
margin: 0
};
var items = (itemSorter ? sortBy(payload, itemSorter) : payload).map((entry, i) => {
if (entry.type === 'none') {
return null;
}
var finalFormatter = entry.formatter || formatter || defaultFormatter;
var {
value,
name
} = entry;
var finalValue = value;
var finalName = name;
if (finalFormatter) {
var formatted = finalFormatter(value, name, entry, i, payload);
if (Array.isArray(formatted)) {
[finalValue, finalName] = formatted;
} else if (formatted != null) {
finalValue = formatted;
} else {
return null;
}
}
var finalItemStyle = _objectSpread({
display: 'block',
paddingTop: 4,
paddingBottom: 4,
color: entry.color || '#000'
}, itemStyle);
return /*#__PURE__*/React.createElement("li", {
className: "recharts-tooltip-item",
key: "tooltip-item-".concat(i),
style: finalItemStyle
}, isNumOrStr(finalName) ? /*#__PURE__*/React.createElement("span", {
className: "recharts-tooltip-item-name"
}, finalName) : null, isNumOrStr(finalName) ? /*#__PURE__*/React.createElement("span", {
className: "recharts-tooltip-item-separator"
}, separator) : null, /*#__PURE__*/React.createElement("span", {
className: "recharts-tooltip-item-value"
}, finalValue), /*#__PURE__*/React.createElement("span", {
className: "recharts-tooltip-item-unit"
}, entry.unit || ''));
});
return /*#__PURE__*/React.createElement("ul", {
className: "recharts-tooltip-item-list",
style: listStyle
}, items);
}
return null;
};
var finalStyle = _objectSpread({
margin: 0,
padding: 10,
backgroundColor: '#fff',
border: '1px solid #ccc',
whiteSpace: 'nowrap'
}, contentStyle);
var finalLabelStyle = _objectSpread({
margin: 0
}, labelStyle);
var hasLabel = !isNullish(label);
var finalLabel = hasLabel ? label : '';
var wrapperCN = clsx('recharts-default-tooltip', wrapperClassName);
var labelCN = clsx('recharts-tooltip-label', labelClassName);
if (hasLabel && labelFormatter && payload !== undefined && payload !== null) {
finalLabel = labelFormatter(label, payload);
}
var accessibilityAttributes = accessibilityLayer ? {
role: 'status',
'aria-live': 'assertive'
} : {};
return /*#__PURE__*/React.createElement("div", _extends({
className: wrapperCN,
style: finalStyle
}, accessibilityAttributes), /*#__PURE__*/React.createElement("p", {
className: labelCN,
style: finalLabelStyle
}, /*#__PURE__*/React.isValidElement(finalLabel) ? finalLabel : "".concat(finalLabel)), renderContent());
};

97
frontend/node_modules/recharts/es6/component/Dots.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
var _excluded = ["points"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { cloneElement, isValidElement } from 'react';
import { clsx } from 'clsx';
import { Dot } from '../shape/Dot';
import { Layer } from '../container/Layer';
import { isClipDot } from '../util/ReactUtils';
import { svgPropertiesAndEventsFromUnknown } from '../util/svgPropertiesAndEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
function DotItem(_ref) {
var {
option,
dotProps,
className
} = _ref;
if (/*#__PURE__*/isValidElement(option)) {
// @ts-expect-error we can't type check element cloning properly
return /*#__PURE__*/cloneElement(option, dotProps);
}
if (typeof option === 'function') {
return option(dotProps);
}
var finalClassName = clsx(className, typeof option !== 'boolean' ? option.className : '');
var _ref2 = dotProps !== null && dotProps !== void 0 ? dotProps : {},
{
points
} = _ref2,
props = _objectWithoutProperties(_ref2, _excluded);
return /*#__PURE__*/React.createElement(Dot, _extends({}, props, {
className: finalClassName
}));
}
function shouldRenderDots(points, dot) {
if (points == null) {
return false;
}
if (dot) {
return true;
}
return points.length === 1;
}
export function Dots(_ref3) {
var {
points,
dot,
className,
dotClassName,
dataKey,
baseProps,
needClip,
clipPathId,
zIndex = DefaultZIndexes.scatter
} = _ref3;
if (!shouldRenderDots(points, dot)) {
return null;
}
var clipDot = isClipDot(dot);
var customDotProps = svgPropertiesAndEventsFromUnknown(dot);
var dots = points.map((entry, i) => {
var _entry$x, _entry$y;
var dotProps = _objectSpread(_objectSpread(_objectSpread({
r: 3
}, baseProps), customDotProps), {}, {
index: i,
cx: (_entry$x = entry.x) !== null && _entry$x !== void 0 ? _entry$x : undefined,
cy: (_entry$y = entry.y) !== null && _entry$y !== void 0 ? _entry$y : undefined,
dataKey,
value: entry.value,
payload: entry.payload,
points
});
return /*#__PURE__*/React.createElement(DotItem, {
key: "dot-".concat(i),
option: dot,
dotProps: dotProps,
className: dotClassName
});
});
var layerProps = {};
if (needClip && clipPathId != null) {
layerProps.clipPath = "url(#clipPath-".concat(clipDot ? '' : 'dots-').concat(clipPathId, ")");
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex
}, /*#__PURE__*/React.createElement(Layer, _extends({
className: className
}, layerProps), dots));
}

521
frontend/node_modules/recharts/es6/component/Label.js generated vendored Normal file
View File

@@ -0,0 +1,521 @@
var _excluded = ["labelRef"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { cloneElement, createContext, createElement, isValidElement, useContext, useMemo } from 'react';
import { clsx } from 'clsx';
import { isValidTextAnchor, Text } from './Text';
import { getPercentValue, isNullish, isNumber, isNumOrStr, isPercent, mathSign, uniqueId } from '../util/DataUtils';
import { polarToCartesian } from '../util/PolarUtils';
import { cartesianViewBoxToTrapezoid, useViewBox } from '../context/chartLayoutContext';
import { useAppSelector } from '../state/hooks';
import { selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
var CartesianLabelContext = /*#__PURE__*/createContext(null);
export var CartesianLabelContextProvider = _ref => {
var {
x,
y,
upperWidth,
lowerWidth,
width,
height,
children
} = _ref;
var viewBox = useMemo(() => ({
x,
y,
upperWidth,
lowerWidth,
width,
height
}), [x, y, upperWidth, lowerWidth, width, height]);
return /*#__PURE__*/React.createElement(CartesianLabelContext.Provider, {
value: viewBox
}, children);
};
var useCartesianLabelContext = () => {
var labelChildContext = useContext(CartesianLabelContext);
var chartContext = useViewBox();
return labelChildContext || cartesianViewBoxToTrapezoid(chartContext);
};
var PolarLabelContext = /*#__PURE__*/createContext(null);
export var PolarLabelContextProvider = _ref2 => {
var {
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle,
clockWise,
children
} = _ref2;
var viewBox = useMemo(() => ({
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle,
clockWise
}), [cx, cy, innerRadius, outerRadius, startAngle, endAngle, clockWise]);
return /*#__PURE__*/React.createElement(PolarLabelContext.Provider, {
value: viewBox
}, children);
};
export var usePolarLabelContext = () => {
var labelChildContext = useContext(PolarLabelContext);
var chartContext = useAppSelector(selectPolarViewBox);
return labelChildContext || chartContext;
};
var getLabel = props => {
var {
value,
formatter
} = props;
var label = isNullish(props.children) ? value : props.children;
if (typeof formatter === 'function') {
return formatter(label);
}
return label;
};
export var isLabelContentAFunction = content => {
return content != null && typeof content === 'function';
};
var getDeltaAngle = (startAngle, endAngle) => {
var sign = mathSign(endAngle - startAngle);
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
return sign * deltaAngle;
};
var renderRadialLabel = (labelProps, position, label, attrs, viewBox) => {
var {
offset,
className
} = labelProps;
var {
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle,
clockWise
} = viewBox;
var radius = (innerRadius + outerRadius) / 2;
var deltaAngle = getDeltaAngle(startAngle, endAngle);
var sign = deltaAngle >= 0 ? 1 : -1;
var labelAngle, direction;
switch (position) {
case 'insideStart':
labelAngle = startAngle + sign * offset;
direction = clockWise;
break;
case 'insideEnd':
labelAngle = endAngle - sign * offset;
direction = !clockWise;
break;
case 'end':
labelAngle = endAngle + sign * offset;
direction = clockWise;
break;
default:
throw new Error("Unsupported position ".concat(position));
}
direction = deltaAngle <= 0 ? direction : !direction;
var startPoint = polarToCartesian(cx, cy, radius, labelAngle);
var endPoint = polarToCartesian(cx, cy, radius, labelAngle + (direction ? 1 : -1) * 359);
var path = "M".concat(startPoint.x, ",").concat(startPoint.y, "\n A").concat(radius, ",").concat(radius, ",0,1,").concat(direction ? 0 : 1, ",\n ").concat(endPoint.x, ",").concat(endPoint.y);
var id = isNullish(labelProps.id) ? uniqueId('recharts-radial-line-') : labelProps.id;
return /*#__PURE__*/React.createElement("text", _extends({}, attrs, {
dominantBaseline: "central",
className: clsx('recharts-radial-bar-label', className)
}), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
id: id,
d: path
})), /*#__PURE__*/React.createElement("textPath", {
xlinkHref: "#".concat(id)
}, label));
};
var getAttrsOfPolarLabel = (viewBox, offset, position) => {
var {
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle
} = viewBox;
var midAngle = (startAngle + endAngle) / 2;
if (position === 'outside') {
var {
x: _x,
y: _y
} = polarToCartesian(cx, cy, outerRadius + offset, midAngle);
return {
x: _x,
y: _y,
textAnchor: _x >= cx ? 'start' : 'end',
verticalAnchor: 'middle'
};
}
if (position === 'center') {
return {
x: cx,
y: cy,
textAnchor: 'middle',
verticalAnchor: 'middle'
};
}
if (position === 'centerTop') {
return {
x: cx,
y: cy,
textAnchor: 'middle',
verticalAnchor: 'start'
};
}
if (position === 'centerBottom') {
return {
x: cx,
y: cy,
textAnchor: 'middle',
verticalAnchor: 'end'
};
}
var r = (innerRadius + outerRadius) / 2;
var {
x,
y
} = polarToCartesian(cx, cy, r, midAngle);
return {
x,
y,
textAnchor: 'middle',
verticalAnchor: 'middle'
};
};
var isPolar = viewBox => 'cx' in viewBox && isNumber(viewBox.cx);
export var getAttrsOfCartesianLabel = (props, viewBox) => {
var {
parentViewBox: parentViewBoxFromProps,
offset,
position
} = props;
var parentViewBox;
if (parentViewBoxFromProps != null && !isPolar(parentViewBoxFromProps)) {
// Check that nobody is trying to pass a polar viewBox to a cartesian label
parentViewBox = parentViewBoxFromProps;
}
var {
x,
y,
upperWidth,
lowerWidth,
height
} = viewBox;
// Funnel.tsx provides a viewBox where `x` is the top-left of the trapezoid shape.
var upperX = x;
// The trapezoid is centered, so we can calculate the other corners from the top-left.
var lowerX = x + (upperWidth - lowerWidth) / 2;
// middleX is the x-coordinate of the left edge at the vertical midpoint of the trapezoid.
var middleX = (upperX + lowerX) / 2;
// The width of the trapezoid at its vertical midpoint.
var midHeightWidth = (upperWidth + lowerWidth) / 2;
// The center x-coordinate is constant for the entire height of the trapezoid.
var centerX = upperX + upperWidth / 2;
// Define vertical offsets and position inverts based on the value being positive or negative.
// This allows labels to be positioned correctly for bars with negative height.
var verticalSign = height >= 0 ? 1 : -1;
var verticalOffset = verticalSign * offset;
var verticalEnd = verticalSign > 0 ? 'end' : 'start';
var verticalStart = verticalSign > 0 ? 'start' : 'end';
// Define horizontal offsets and position inverts based on the value being positive or negative.
// This allows labels to be positioned correctly for bars with negative width.
var horizontalSign = upperWidth >= 0 ? 1 : -1;
var horizontalOffset = horizontalSign * offset;
var horizontalEnd = horizontalSign > 0 ? 'end' : 'start';
var horizontalStart = horizontalSign > 0 ? 'start' : 'end';
if (position === 'top') {
var attrs = {
x: upperX + upperWidth / 2,
y: y - verticalOffset,
textAnchor: 'middle',
verticalAnchor: verticalEnd
};
return _objectSpread(_objectSpread({}, attrs), parentViewBox ? {
height: Math.max(y - parentViewBox.y, 0),
width: upperWidth
} : {});
}
if (position === 'bottom') {
var _attrs = {
x: lowerX + lowerWidth / 2,
y: y + height + verticalOffset,
textAnchor: 'middle',
verticalAnchor: verticalStart
};
return _objectSpread(_objectSpread({}, _attrs), parentViewBox ? {
height: Math.max(parentViewBox.y + parentViewBox.height - (y + height), 0),
width: lowerWidth
} : {});
}
if (position === 'left') {
var _attrs2 = {
x: middleX - horizontalOffset,
y: y + height / 2,
textAnchor: horizontalEnd,
verticalAnchor: 'middle'
};
return _objectSpread(_objectSpread({}, _attrs2), parentViewBox ? {
width: Math.max(_attrs2.x - parentViewBox.x, 0),
height
} : {});
}
if (position === 'right') {
var _attrs3 = {
x: middleX + midHeightWidth + horizontalOffset,
y: y + height / 2,
textAnchor: horizontalStart,
verticalAnchor: 'middle'
};
return _objectSpread(_objectSpread({}, _attrs3), parentViewBox ? {
width: Math.max(parentViewBox.x + parentViewBox.width - _attrs3.x, 0),
height
} : {});
}
var sizeAttrs = parentViewBox ? {
width: midHeightWidth,
height
} : {};
if (position === 'insideLeft') {
return _objectSpread({
x: middleX + horizontalOffset,
y: y + height / 2,
textAnchor: horizontalStart,
verticalAnchor: 'middle'
}, sizeAttrs);
}
if (position === 'insideRight') {
return _objectSpread({
x: middleX + midHeightWidth - horizontalOffset,
y: y + height / 2,
textAnchor: horizontalEnd,
verticalAnchor: 'middle'
}, sizeAttrs);
}
if (position === 'insideTop') {
return _objectSpread({
x: upperX + upperWidth / 2,
y: y + verticalOffset,
textAnchor: 'middle',
verticalAnchor: verticalStart
}, sizeAttrs);
}
if (position === 'insideBottom') {
return _objectSpread({
x: lowerX + lowerWidth / 2,
y: y + height - verticalOffset,
textAnchor: 'middle',
verticalAnchor: verticalEnd
}, sizeAttrs);
}
if (position === 'insideTopLeft') {
return _objectSpread({
x: upperX + horizontalOffset,
y: y + verticalOffset,
textAnchor: horizontalStart,
verticalAnchor: verticalStart
}, sizeAttrs);
}
if (position === 'insideTopRight') {
return _objectSpread({
x: upperX + upperWidth - horizontalOffset,
y: y + verticalOffset,
textAnchor: horizontalEnd,
verticalAnchor: verticalStart
}, sizeAttrs);
}
if (position === 'insideBottomLeft') {
return _objectSpread({
x: lowerX + horizontalOffset,
y: y + height - verticalOffset,
textAnchor: horizontalStart,
verticalAnchor: verticalEnd
}, sizeAttrs);
}
if (position === 'insideBottomRight') {
return _objectSpread({
x: lowerX + lowerWidth - horizontalOffset,
y: y + height - verticalOffset,
textAnchor: horizontalEnd,
verticalAnchor: verticalEnd
}, sizeAttrs);
}
if (!!position && typeof position === 'object' && (isNumber(position.x) || isPercent(position.x)) && (isNumber(position.y) || isPercent(position.y))) {
// TODO: This is not quite right. The width of the trapezoid changes with y.
// A percentage-based x should be relative to the width at that y.
// For now, we use the mid-height width as a reasonable approximation.
return _objectSpread({
x: x + getPercentValue(position.x, midHeightWidth),
y: y + getPercentValue(position.y, height),
textAnchor: 'end',
verticalAnchor: 'end'
}, sizeAttrs);
}
return _objectSpread({
x: centerX,
y: y + height / 2,
textAnchor: 'middle',
verticalAnchor: 'middle'
}, sizeAttrs);
};
var defaultLabelProps = {
offset: 5,
zIndex: DefaultZIndexes.label
};
export function Label(outerProps) {
var props = resolveDefaultProps(outerProps, defaultLabelProps);
var {
viewBox: viewBoxFromProps,
position,
value,
children,
content,
className = '',
textBreakAll,
labelRef
} = props;
var polarViewBox = usePolarLabelContext();
var cartesianViewBox = useCartesianLabelContext();
/*
* I am not proud about this solution, but it's a quick fix for https://github.com/recharts/recharts/issues/6030#issuecomment-3155352460.
* What we should really do is split Label into two components: CartesianLabel and PolarLabel and then handle their respective viewBoxes separately.
* Also other components should set its own viewBox in a context so that we can fix https://github.com/recharts/recharts/issues/6156
*/
var resolvedViewBox = position === 'center' ? cartesianViewBox : polarViewBox !== null && polarViewBox !== void 0 ? polarViewBox : cartesianViewBox;
var viewBox, label, positionAttrs;
if (viewBoxFromProps == null) {
viewBox = resolvedViewBox;
} else if (isPolar(viewBoxFromProps)) {
viewBox = viewBoxFromProps;
} else {
viewBox = cartesianViewBoxToTrapezoid(viewBoxFromProps);
}
if (!viewBox || isNullish(value) && isNullish(children) && ! /*#__PURE__*/isValidElement(content) && typeof content !== 'function') {
return null;
}
var propsWithViewBox = _objectSpread(_objectSpread({}, props), {}, {
viewBox
});
if (/*#__PURE__*/isValidElement(content)) {
var {
labelRef: _
} = propsWithViewBox,
propsWithoutLabelRef = _objectWithoutProperties(propsWithViewBox, _excluded);
return /*#__PURE__*/cloneElement(content, propsWithoutLabelRef);
}
if (typeof content === 'function') {
// @ts-expect-error we're not checking if the content component returns something that Text is able to render
label = /*#__PURE__*/createElement(content, propsWithViewBox);
if (/*#__PURE__*/isValidElement(label)) {
return label;
}
} else {
label = getLabel(props);
}
var attrs = svgPropertiesAndEvents(props);
if (isPolar(viewBox)) {
if (position === 'insideStart' || position === 'insideEnd' || position === 'end') {
return renderRadialLabel(props, position, label, attrs, viewBox);
}
positionAttrs = getAttrsOfPolarLabel(viewBox, props.offset, props.position);
} else {
positionAttrs = getAttrsOfCartesianLabel(props, viewBox);
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Text, _extends({
ref: labelRef,
className: clsx('recharts-label', className)
}, attrs, positionAttrs, {
/*
* textAnchor is decided by default based on the `position`
* but we allow overriding via props for precise control.
*/
textAnchor: isValidTextAnchor(attrs.textAnchor) ? attrs.textAnchor : positionAttrs.textAnchor,
breakAll: textBreakAll
}), label));
}
Label.displayName = 'Label';
var parseLabel = (label, viewBox, labelRef) => {
if (!label) {
return null;
}
var commonProps = {
viewBox,
labelRef
};
if (label === true) {
return /*#__PURE__*/React.createElement(Label, _extends({
key: "label-implicit"
}, commonProps));
}
if (isNumOrStr(label)) {
return /*#__PURE__*/React.createElement(Label, _extends({
key: "label-implicit",
value: label
}, commonProps));
}
if (/*#__PURE__*/isValidElement(label)) {
if (label.type === Label) {
return /*#__PURE__*/cloneElement(label, _objectSpread({
key: 'label-implicit'
}, commonProps));
}
return /*#__PURE__*/React.createElement(Label, _extends({
key: "label-implicit",
content: label
}, commonProps));
}
if (isLabelContentAFunction(label)) {
return /*#__PURE__*/React.createElement(Label, _extends({
key: "label-implicit",
content: label
}, commonProps));
}
if (label && typeof label === 'object') {
return /*#__PURE__*/React.createElement(Label, _extends({}, label, {
key: "label-implicit"
}, commonProps));
}
return null;
};
export function CartesianLabelFromLabelProp(_ref3) {
var {
label,
labelRef
} = _ref3;
var viewBox = useCartesianLabelContext();
return parseLabel(label, viewBox, labelRef) || null;
}
export function PolarLabelFromLabelProp(_ref4) {
var {
label
} = _ref4;
var viewBox = usePolarLabelContext();
return parseLabel(label, viewBox) || null;
}

View File

@@ -0,0 +1,136 @@
var _excluded = ["valueAccessor"],
_excluded2 = ["dataKey", "clockWise", "id", "textBreakAll", "zIndex"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { createContext, useContext } from 'react';
import last from 'es-toolkit/compat/last';
import { isLabelContentAFunction, Label } from './Label';
import { Layer } from '../container/Layer';
import { getValueByDataKey } from '../util/ChartUtils';
import { isNullish } from '../util/DataUtils';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* This is public API because we expose it as the valueAccessor parameter.
*
* The properties of "viewBox" are repeated as the root props of the entry object.
* So it doesn't matter if you read entry.x or entry.viewBox.x, they are the same.
*
* It's not necessary to pass redundant data, but we keep it for backward compatibility.
*/
/**
* LabelList props do not allow refs because the same props are reused in multiple elements so we don't have a good single place to ref to.
*/
/**
* This is the type accepted for the `label` prop on various graphical items.
* It accepts:
*
* boolean:
* true = labels show,
* false = labels don't show
* React element:
* will be cloned with extra props
* function:
* is used as <Label content={function} />, so this will be called once for each individual label (so typically once for each data point)
* object:
* the props to be passed to a LabelList component
*/
var defaultAccessor = entry => Array.isArray(entry.value) ? last(entry.value) : entry.value;
var CartesianLabelListContext = /*#__PURE__*/createContext(undefined);
export var CartesianLabelListContextProvider = CartesianLabelListContext.Provider;
var PolarLabelListContext = /*#__PURE__*/createContext(undefined);
export var PolarLabelListContextProvider = PolarLabelListContext.Provider;
function useCartesianLabelListContext() {
return useContext(CartesianLabelListContext);
}
function usePolarLabelListContext() {
return useContext(PolarLabelListContext);
}
export function LabelList(_ref) {
var {
valueAccessor = defaultAccessor
} = _ref,
restProps = _objectWithoutProperties(_ref, _excluded);
var {
dataKey,
clockWise,
id,
textBreakAll,
zIndex
} = restProps,
others = _objectWithoutProperties(restProps, _excluded2);
var cartesianData = useCartesianLabelListContext();
var polarData = usePolarLabelListContext();
var data = cartesianData || polarData;
if (!data || !data.length) {
return null;
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : DefaultZIndexes.label
}, /*#__PURE__*/React.createElement(Layer, {
className: "recharts-label-list"
}, data.map((entry, index) => {
var _restProps$fill;
var value = isNullish(dataKey) ? valueAccessor(entry, index) : getValueByDataKey(entry && entry.payload, dataKey);
var idProps = isNullish(id) ? {} : {
id: "".concat(id, "-").concat(index)
};
return /*#__PURE__*/React.createElement(Label, _extends({
key: "label-".concat(index)
}, svgPropertiesAndEvents(entry), others, idProps, {
/*
* Prefer to use the explicit fill from LabelList props.
* Only in an absence of that, fall back to the fill of the entry.
* The entry fill can be quite difficult to see especially in Bar, Pie, RadialBar in inside positions.
* On the other hand it's quite convenient in Scatter, Line, or when the position is outside the Bar, Pie filled shapes.
*/
fill: (_restProps$fill = restProps.fill) !== null && _restProps$fill !== void 0 ? _restProps$fill : entry.fill,
parentViewBox: entry.parentViewBox,
value: value,
textBreakAll: textBreakAll,
viewBox: entry.viewBox,
index: index
/*
* Here we don't want to use the default Label zIndex,
* we want it to inherit the zIndex of the LabelList itself
* which means just rendering as a regular child, without portaling anywhere.
*/,
zIndex: 0
}));
})));
}
LabelList.displayName = 'LabelList';
export function LabelListFromLabelProp(_ref2) {
var {
label
} = _ref2;
if (!label) {
return null;
}
if (label === true) {
return /*#__PURE__*/React.createElement(LabelList, {
key: "labelList-implicit"
});
}
if (/*#__PURE__*/React.isValidElement(label) || isLabelContentAFunction(label)) {
return /*#__PURE__*/React.createElement(LabelList, {
key: "labelList-implicit",
content: label
});
}
if (typeof label === 'object') {
return /*#__PURE__*/React.createElement(LabelList, _extends({
key: "labelList-implicit"
}, label, {
type: String(label.type)
}));
}
return null;
}

169
frontend/node_modules/recharts/es6/component/Legend.js generated vendored Normal file
View File

@@ -0,0 +1,169 @@
var _excluded = ["contextPayload"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { useEffect } from 'react';
import { createPortal } from 'react-dom';
import { useLegendPortal } from '../context/legendPortalContext';
import { DefaultLegendContent } from './DefaultLegendContent';
import { isNumber } from '../util/DataUtils';
import { getUniqPayload } from '../util/payload/getUniqPayload';
import { useLegendPayload } from '../context/legendPayloadContext';
import { useElementOffset } from '../util/useElementOffset';
import { useChartHeight, useChartWidth, useMargin } from '../context/chartLayoutContext';
import { setLegendSettings, setLegendSize } from '../state/legendSlice';
import { useAppDispatch } from '../state/hooks';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
function defaultUniqBy(entry) {
return entry.value;
}
function LegendContent(props) {
var {
contextPayload
} = props,
otherProps = _objectWithoutProperties(props, _excluded);
var finalPayload = getUniqPayload(contextPayload, props.payloadUniqBy, defaultUniqBy);
var contentProps = _objectSpread(_objectSpread({}, otherProps), {}, {
payload: finalPayload
});
if (/*#__PURE__*/React.isValidElement(props.content)) {
return /*#__PURE__*/React.cloneElement(props.content, contentProps);
}
if (typeof props.content === 'function') {
return /*#__PURE__*/React.createElement(props.content, contentProps);
}
return /*#__PURE__*/React.createElement(DefaultLegendContent, contentProps);
}
function getDefaultPosition(style, props, margin, chartWidth, chartHeight, box) {
var {
layout,
align,
verticalAlign
} = props;
var hPos, vPos;
if (!style || (style.left === undefined || style.left === null) && (style.right === undefined || style.right === null)) {
if (align === 'center' && layout === 'vertical') {
hPos = {
left: ((chartWidth || 0) - box.width) / 2
};
} else {
hPos = align === 'right' ? {
right: margin && margin.right || 0
} : {
left: margin && margin.left || 0
};
}
}
if (!style || (style.top === undefined || style.top === null) && (style.bottom === undefined || style.bottom === null)) {
if (verticalAlign === 'middle') {
vPos = {
top: ((chartHeight || 0) - box.height) / 2
};
} else {
vPos = verticalAlign === 'bottom' ? {
bottom: margin && margin.bottom || 0
} : {
top: margin && margin.top || 0
};
}
}
return _objectSpread(_objectSpread({}, hPos), vPos);
}
function LegendSettingsDispatcher(props) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setLegendSettings(props));
}, [dispatch, props]);
return null;
}
function LegendSizeDispatcher(props) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setLegendSize(props));
return () => {
dispatch(setLegendSize({
width: 0,
height: 0
}));
};
}, [dispatch, props]);
return null;
}
function getWidthOrHeight(layout, height, width, maxWidth) {
if (layout === 'vertical' && isNumber(height)) {
return {
height
};
}
if (layout === 'horizontal') {
return {
width: width || maxWidth
};
}
return null;
}
var legendDefaultProps = {
align: 'center',
iconSize: 14,
itemSorter: 'value',
layout: 'horizontal',
verticalAlign: 'bottom'
};
export function Legend(outsideProps) {
var props = resolveDefaultProps(outsideProps, legendDefaultProps);
var contextPayload = useLegendPayload();
var legendPortalFromContext = useLegendPortal();
var margin = useMargin();
var {
width: widthFromProps,
height: heightFromProps,
wrapperStyle,
portal: portalFromProps
} = props;
// The contextPayload is not used directly inside the hook, but we need the onBBoxUpdate call
// when the payload changes, therefore it's here as a dependency.
var [lastBoundingBox, updateBoundingBox] = useElementOffset([contextPayload]);
var chartWidth = useChartWidth();
var chartHeight = useChartHeight();
if (chartWidth == null || chartHeight == null) {
return null;
}
var maxWidth = chartWidth - ((margin === null || margin === void 0 ? void 0 : margin.left) || 0) - ((margin === null || margin === void 0 ? void 0 : margin.right) || 0);
var widthOrHeight = getWidthOrHeight(props.layout, heightFromProps, widthFromProps, maxWidth);
// if the user supplies their own portal, only use their defined wrapper styles
var outerStyle = portalFromProps ? wrapperStyle : _objectSpread(_objectSpread({
position: 'absolute',
width: (widthOrHeight === null || widthOrHeight === void 0 ? void 0 : widthOrHeight.width) || widthFromProps || 'auto',
height: (widthOrHeight === null || widthOrHeight === void 0 ? void 0 : widthOrHeight.height) || heightFromProps || 'auto'
}, getDefaultPosition(wrapperStyle, props, margin, chartWidth, chartHeight, lastBoundingBox)), wrapperStyle);
var legendPortal = portalFromProps !== null && portalFromProps !== void 0 ? portalFromProps : legendPortalFromContext;
if (legendPortal == null || contextPayload == null) {
return null;
}
var legendElement = /*#__PURE__*/React.createElement("div", {
className: "recharts-legend-wrapper",
style: outerStyle,
ref: updateBoundingBox
}, /*#__PURE__*/React.createElement(LegendSettingsDispatcher, {
layout: props.layout,
align: props.align,
verticalAlign: props.verticalAlign,
itemSorter: props.itemSorter
}), /*#__PURE__*/React.createElement(LegendSizeDispatcher, {
width: lastBoundingBox.width,
height: lastBoundingBox.height
}), /*#__PURE__*/React.createElement(LegendContent, _extends({}, props, widthOrHeight, {
margin: margin,
chartWidth: chartWidth,
chartHeight: chartHeight,
contextPayload: contextPayload
})));
return /*#__PURE__*/createPortal(legendElement, legendPortal);
}
Legend.displayName = 'Legend';

View File

@@ -0,0 +1,224 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { clsx } from 'clsx';
import * as React from 'react';
import { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
import throttle from 'es-toolkit/compat/throttle';
import { isNumber, noop } from '../util/DataUtils';
import { warn } from '../util/LogUtils';
import { calculateChartDimensions, getDefaultWidthAndHeight, getInnerDivStyle } from './responsiveContainerUtils';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
var ResponsiveContainerContext = /*#__PURE__*/createContext({
width: -1,
height: -1
});
function isAcceptableSize(size) {
return isPositiveNumber(size.width) && isPositiveNumber(size.height);
}
function ResponsiveContainerContextProvider(_ref) {
var {
children,
width,
height
} = _ref;
var size = useMemo(() => ({
width,
height
}), [width, height]);
if (!isAcceptableSize(size)) {
/*
* Don't render the container if width or height is non-positive because
* in that case the chart will not be rendered properly anyway.
* We will instead wait for the next resize event to provide the correct dimensions.
*/
return null;
}
return /*#__PURE__*/React.createElement(ResponsiveContainerContext.Provider, {
value: size
}, children);
}
export var useResponsiveContainerContext = () => useContext(ResponsiveContainerContext);
var SizeDetectorContainer = /*#__PURE__*/forwardRef((_ref2, ref) => {
var {
aspect,
initialDimension = {
width: -1,
height: -1
},
width,
height,
/*
* default min-width to 0 if not specified - 'auto' causes issues with flexbox
* https://github.com/recharts/recharts/issues/172
*/
minWidth = 0,
minHeight,
maxHeight,
children,
debounce = 0,
id,
className,
onResize,
style = {}
} = _ref2;
var containerRef = useRef(null);
/*
* We are using a ref to avoid re-creating the ResizeObserver when the onResize function changes.
* The ref is updated on every render, so the latest onResize function is always available in the effect.
*/
var onResizeRef = useRef();
onResizeRef.current = onResize;
useImperativeHandle(ref, () => containerRef.current);
var [sizes, setSizes] = useState({
containerWidth: initialDimension.width,
containerHeight: initialDimension.height
});
var setContainerSize = useCallback((newWidth, newHeight) => {
setSizes(prevState => {
var roundedWidth = Math.round(newWidth);
var roundedHeight = Math.round(newHeight);
if (prevState.containerWidth === roundedWidth && prevState.containerHeight === roundedHeight) {
return prevState;
}
return {
containerWidth: roundedWidth,
containerHeight: roundedHeight
};
});
}, []);
useEffect(() => {
if (containerRef.current == null || typeof ResizeObserver === 'undefined') {
return noop;
}
var callback = entries => {
var _onResizeRef$current;
var {
width: containerWidth,
height: containerHeight
} = entries[0].contentRect;
setContainerSize(containerWidth, containerHeight);
(_onResizeRef$current = onResizeRef.current) === null || _onResizeRef$current === void 0 || _onResizeRef$current.call(onResizeRef, containerWidth, containerHeight);
};
if (debounce > 0) {
callback = throttle(callback, debounce, {
trailing: true,
leading: false
});
}
var observer = new ResizeObserver(callback);
var {
width: containerWidth,
height: containerHeight
} = containerRef.current.getBoundingClientRect();
setContainerSize(containerWidth, containerHeight);
observer.observe(containerRef.current);
return () => {
observer.disconnect();
};
}, [setContainerSize, debounce]);
var {
containerWidth,
containerHeight
} = sizes;
warn(!aspect || aspect > 0, 'The aspect(%s) must be greater than zero.', aspect);
var {
calculatedWidth,
calculatedHeight
} = calculateChartDimensions(containerWidth, containerHeight, {
width,
height,
aspect,
maxHeight
});
warn(calculatedWidth != null && calculatedWidth > 0 || calculatedHeight != null && calculatedHeight > 0, "The width(%s) and height(%s) of chart should be greater than 0,\n please check the style of container, or the props width(%s) and height(%s),\n or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the\n height and width.", calculatedWidth, calculatedHeight, width, height, minWidth, minHeight, aspect);
return /*#__PURE__*/React.createElement("div", {
id: id ? "".concat(id) : undefined,
className: clsx('recharts-responsive-container', className),
style: _objectSpread(_objectSpread({}, style), {}, {
width,
height,
minWidth,
minHeight,
maxHeight
}),
ref: containerRef
}, /*#__PURE__*/React.createElement("div", {
style: getInnerDivStyle({
width,
height
})
}, /*#__PURE__*/React.createElement(ResponsiveContainerContextProvider, {
width: calculatedWidth,
height: calculatedHeight
}, children)));
});
/**
* The `ResponsiveContainer` component is a container that adjusts its width and height based on the size of its parent element.
* It is used to create responsive charts that adapt to different screen sizes.
*
* This component uses the `ResizeObserver` API to monitor changes to the size of its parent element.
* If you need to support older browsers that do not support this API, you may need to include a polyfill.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver
*/
export var ResponsiveContainer = /*#__PURE__*/forwardRef((props, ref) => {
var responsiveContainerContext = useResponsiveContainerContext();
if (isPositiveNumber(responsiveContainerContext.width) && isPositiveNumber(responsiveContainerContext.height)) {
/*
* If we detect that we are already inside another ResponsiveContainer,
* we do not attempt to add another layer of responsiveness.
*/
return props.children;
}
var {
width,
height
} = getDefaultWidthAndHeight({
width: props.width,
height: props.height,
aspect: props.aspect
});
/*
* Let's try to get the calculated dimensions without having the div container set up.
* Sometimes this does produce fixed, positive dimensions. If so, we can skip rendering the div and monitoring its size.
*/
var {
calculatedWidth,
calculatedHeight
} = calculateChartDimensions(undefined, undefined, {
width,
height,
aspect: props.aspect,
maxHeight: props.maxHeight
});
if (isNumber(calculatedWidth) && isNumber(calculatedHeight)) {
/*
* If it just so happens that the combination of width, height, and aspect ratio
* results in fixed dimensions, then we don't need to monitor the container's size.
* We can just provide these fixed dimensions to the context.
*
* Note that here we are not checking for positive numbers;
* if the user provides a zero or negative width/height, we will just pass that along
* as whatever size we detect won't be helping anyway.
*/
return /*#__PURE__*/React.createElement(ResponsiveContainerContextProvider, {
width: calculatedWidth,
height: calculatedHeight
}, props.children);
}
/*
* Static analysis did not produce fixed dimensions,
* so we need to render a special div and monitor its size.
*/
return /*#__PURE__*/React.createElement(SizeDetectorContainer, _extends({}, props, {
width: width,
height: height,
ref: ref
}));
});

269
frontend/node_modules/recharts/es6/component/Text.js generated vendored Normal file
View File

@@ -0,0 +1,269 @@
var _excluded = ["x", "y", "lineHeight", "capHeight", "fill", "scaleToFit", "textAnchor", "verticalAnchor"],
_excluded2 = ["dx", "dy", "angle", "className", "breakAll"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { useMemo, forwardRef } from 'react';
import { clsx } from 'clsx';
import { isNullish, isNumber, isNumOrStr } from '../util/DataUtils';
import { Global } from '../util/Global';
import { getStringSize } from '../util/DOMUtils';
import { reduceCSSCalc } from '../util/ReduceCSSCalc';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { isWellBehavedNumber } from '../util/isWellBehavedNumber';
var BREAKING_SPACES = /[ \f\n\r\t\v\u2028\u2029]+/;
var calculateWordWidths = _ref => {
var {
children,
breakAll,
style
} = _ref;
try {
var words = [];
if (!isNullish(children)) {
if (breakAll) {
words = children.toString().split('');
} else {
words = children.toString().split(BREAKING_SPACES);
}
}
var wordsWithComputedWidth = words.map(word => ({
word,
width: getStringSize(word, style).width
}));
var spaceWidth = breakAll ? 0 : getStringSize('\u00A0', style).width;
return {
wordsWithComputedWidth,
spaceWidth
};
} catch (_unused) {
return null;
}
};
export function isValidTextAnchor(value) {
return value === 'start' || value === 'middle' || value === 'end' || value === 'inherit';
}
var calculate = (words, lineWidth, spaceWidth, scaleToFit) => words.reduce((result, _ref2) => {
var {
word,
width
} = _ref2;
var currentLine = result[result.length - 1];
if (currentLine && width != null && (lineWidth == null || scaleToFit || currentLine.width + width + spaceWidth < Number(lineWidth))) {
// Word can be added to an existing line
currentLine.words.push(word);
currentLine.width += width + spaceWidth;
} else {
// Add first word to line or word is too long to scaleToFit on existing line
var newLine = {
words: [word],
width
};
result.push(newLine);
}
return result;
}, []);
var findLongestLine = words => words.reduce((a, b) => a.width > b.width ? a : b);
var suffix = '…';
var checkOverflow = (text, index, breakAll, style, maxLines, lineWidth, spaceWidth, scaleToFit) => {
var tempText = text.slice(0, index);
var words = calculateWordWidths({
breakAll,
style,
children: tempText + suffix
});
if (!words) {
return [false, []];
}
var result = calculate(words.wordsWithComputedWidth, lineWidth, spaceWidth, scaleToFit);
var doesOverflow = result.length > maxLines || findLongestLine(result).width > Number(lineWidth);
return [doesOverflow, result];
};
var calculateWordsByLines = (_ref3, initialWordsWithComputedWith, spaceWidth, lineWidth, scaleToFit) => {
var {
maxLines,
children,
style,
breakAll
} = _ref3;
var shouldLimitLines = isNumber(maxLines);
var text = String(children);
var originalResult = calculate(initialWordsWithComputedWith, lineWidth, spaceWidth, scaleToFit);
if (!shouldLimitLines || scaleToFit) {
return originalResult;
}
var overflows = originalResult.length > maxLines || findLongestLine(originalResult).width > Number(lineWidth);
if (!overflows) {
return originalResult;
}
var start = 0;
var end = text.length - 1;
var iterations = 0;
var trimmedResult;
while (start <= end && iterations <= text.length - 1) {
var middle = Math.floor((start + end) / 2);
var prev = middle - 1;
var [doesPrevOverflow, result] = checkOverflow(text, prev, breakAll, style, maxLines, lineWidth, spaceWidth, scaleToFit);
var [doesMiddleOverflow] = checkOverflow(text, middle, breakAll, style, maxLines, lineWidth, spaceWidth, scaleToFit);
if (!doesPrevOverflow && !doesMiddleOverflow) {
start = middle + 1;
}
if (doesPrevOverflow && doesMiddleOverflow) {
end = middle - 1;
}
if (!doesPrevOverflow && doesMiddleOverflow) {
trimmedResult = result;
break;
}
iterations++;
}
// Fallback to originalResult (result without trimming) if we cannot find the
// where to trim. This should not happen :tm:
return trimmedResult || originalResult;
};
var getWordsWithoutCalculate = children => {
var words = !isNullish(children) ? children.toString().split(BREAKING_SPACES) : [];
return [{
words,
width: undefined
}];
};
export var getWordsByLines = _ref4 => {
var {
width,
scaleToFit,
children,
style,
breakAll,
maxLines
} = _ref4;
// Only perform calculations if using features that require them (multiline, scaleToFit)
if ((width || scaleToFit) && !Global.isSsr) {
var wordsWithComputedWidth, spaceWidth;
var wordWidths = calculateWordWidths({
breakAll,
children,
style
});
if (wordWidths) {
var {
wordsWithComputedWidth: wcw,
spaceWidth: sw
} = wordWidths;
wordsWithComputedWidth = wcw;
spaceWidth = sw;
} else {
return getWordsWithoutCalculate(children);
}
return calculateWordsByLines({
breakAll,
children,
maxLines,
style
}, wordsWithComputedWidth, spaceWidth, width, Boolean(scaleToFit));
}
return getWordsWithoutCalculate(children);
};
var DEFAULT_FILL = '#808080';
var textDefaultProps = {
breakAll: false,
// Magic number from d3
capHeight: '0.71em',
fill: DEFAULT_FILL,
lineHeight: '1em',
scaleToFit: false,
textAnchor: 'start',
// Maintain compat with existing charts / default SVG behavior
verticalAnchor: 'end',
x: 0,
y: 0
};
export var Text = /*#__PURE__*/forwardRef((outsideProps, ref) => {
var _resolveDefaultProps = resolveDefaultProps(outsideProps, textDefaultProps),
{
x: propsX,
y: propsY,
lineHeight,
capHeight,
fill,
scaleToFit,
textAnchor,
verticalAnchor
} = _resolveDefaultProps,
props = _objectWithoutProperties(_resolveDefaultProps, _excluded);
var wordsByLines = useMemo(() => {
return getWordsByLines({
breakAll: props.breakAll,
children: props.children,
maxLines: props.maxLines,
scaleToFit,
style: props.style,
width: props.width
});
}, [props.breakAll, props.children, props.maxLines, scaleToFit, props.style, props.width]);
var {
dx,
dy,
angle,
className,
breakAll
} = props,
textProps = _objectWithoutProperties(props, _excluded2);
if (!isNumOrStr(propsX) || !isNumOrStr(propsY) || wordsByLines.length === 0) {
return null;
}
var x = Number(propsX) + (isNumber(dx) ? dx : 0);
var y = Number(propsY) + (isNumber(dy) ? dy : 0);
if (!isWellBehavedNumber(x) || !isWellBehavedNumber(y)) {
return null;
}
var startDy;
switch (verticalAnchor) {
case 'start':
startDy = reduceCSSCalc("calc(".concat(capHeight, ")"));
break;
case 'middle':
startDy = reduceCSSCalc("calc(".concat((wordsByLines.length - 1) / 2, " * -").concat(lineHeight, " + (").concat(capHeight, " / 2))"));
break;
default:
startDy = reduceCSSCalc("calc(".concat(wordsByLines.length - 1, " * -").concat(lineHeight, ")"));
break;
}
var transforms = [];
if (scaleToFit) {
var lineWidth = wordsByLines[0].width;
var {
width
} = props;
transforms.push("scale(".concat(isNumber(width) && isNumber(lineWidth) ? width / lineWidth : 1, ")"));
}
if (angle) {
transforms.push("rotate(".concat(angle, ", ").concat(x, ", ").concat(y, ")"));
}
if (transforms.length) {
textProps.transform = transforms.join(' ');
}
return /*#__PURE__*/React.createElement("text", _extends({}, svgPropertiesAndEvents(textProps), {
ref: ref,
x: x,
y: y,
className: clsx('recharts-text', className),
textAnchor: textAnchor,
fill: fill.includes('url') ? DEFAULT_FILL : fill
}), wordsByLines.map((line, index) => {
var words = line.words.join(breakAll ? '' : ' ');
return (
/*#__PURE__*/
// duplicate words will cause duplicate keys which is why we add the array index here
React.createElement("tspan", {
x: x,
dy: index === 0 ? startDy : lineHeight,
key: "".concat(words, "-").concat(index)
}, words)
);
}));
});
Text.displayName = 'Text';

163
frontend/node_modules/recharts/es6/component/Tooltip.js generated vendored Normal file
View File

@@ -0,0 +1,163 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { useEffect } from 'react';
import { createPortal } from 'react-dom';
import { DefaultTooltipContent } from './DefaultTooltipContent';
import { TooltipBoundingBox } from './TooltipBoundingBox';
import { Global } from '../util/Global';
import { getUniqPayload } from '../util/payload/getUniqPayload';
import { useViewBox } from '../context/chartLayoutContext';
import { useAccessibilityLayer } from '../context/accessibilityContext';
import { useElementOffset } from '../util/useElementOffset';
import { Cursor } from './Cursor';
import { selectActiveCoordinate, selectActiveLabel, selectIsTooltipActive, selectTooltipPayload } from '../state/selectors/selectors';
import { useTooltipPortal } from '../context/tooltipPortalContext';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { setTooltipSettingsState } from '../state/tooltipSlice';
import { useTooltipChartSynchronisation } from '../synchronisation/useChartSynchronisation';
import { useTooltipEventType } from '../state/selectors/selectTooltipEventType';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
function defaultUniqBy(entry) {
return entry.dataKey;
}
function renderContent(content, props) {
if (/*#__PURE__*/React.isValidElement(content)) {
return /*#__PURE__*/React.cloneElement(content, props);
}
if (typeof content === 'function') {
return /*#__PURE__*/React.createElement(content, props);
}
return /*#__PURE__*/React.createElement(DefaultTooltipContent, props);
}
var emptyPayload = [];
var defaultTooltipProps = {
allowEscapeViewBox: {
x: false,
y: false
},
animationDuration: 400,
animationEasing: 'ease',
axisId: 0,
contentStyle: {},
cursor: true,
filterNull: true,
isAnimationActive: !Global.isSsr,
itemSorter: 'name',
itemStyle: {},
labelStyle: {},
offset: 10,
reverseDirection: {
x: false,
y: false
},
separator: ' : ',
trigger: 'hover',
useTranslate3d: false,
wrapperStyle: {}
};
export function Tooltip(outsideProps) {
var _useAppSelector, _ref;
var props = resolveDefaultProps(outsideProps, defaultTooltipProps);
var {
active: activeFromProps,
allowEscapeViewBox,
animationDuration,
animationEasing,
content,
filterNull,
isAnimationActive,
offset,
payloadUniqBy,
position,
reverseDirection,
useTranslate3d,
wrapperStyle,
cursor,
shared,
trigger,
defaultIndex,
portal: portalFromProps,
axisId
} = props;
var dispatch = useAppDispatch();
var defaultIndexAsString = typeof defaultIndex === 'number' ? String(defaultIndex) : defaultIndex;
useEffect(() => {
dispatch(setTooltipSettingsState({
shared,
trigger,
axisId,
active: activeFromProps,
defaultIndex: defaultIndexAsString
}));
}, [dispatch, shared, trigger, axisId, activeFromProps, defaultIndexAsString]);
var viewBox = useViewBox();
var accessibilityLayer = useAccessibilityLayer();
var tooltipEventType = useTooltipEventType(shared);
var {
activeIndex,
isActive
} = (_useAppSelector = useAppSelector(state => selectIsTooltipActive(state, tooltipEventType, trigger, defaultIndexAsString))) !== null && _useAppSelector !== void 0 ? _useAppSelector : {};
var payloadFromRedux = useAppSelector(state => selectTooltipPayload(state, tooltipEventType, trigger, defaultIndexAsString));
var labelFromRedux = useAppSelector(state => selectActiveLabel(state, tooltipEventType, trigger, defaultIndexAsString));
var coordinate = useAppSelector(state => selectActiveCoordinate(state, tooltipEventType, trigger, defaultIndexAsString));
var payload = payloadFromRedux;
var tooltipPortalFromContext = useTooltipPortal();
/*
* The user can set `active=true` on the Tooltip in which case the Tooltip will stay always active,
* or `active=false` in which case the Tooltip never shows.
*
* If the `active` prop is not defined then it will show and hide based on mouse or keyboard activity.
*/
var finalIsActive = (_ref = activeFromProps !== null && activeFromProps !== void 0 ? activeFromProps : isActive) !== null && _ref !== void 0 ? _ref : false;
var [lastBoundingBox, updateBoundingBox] = useElementOffset([payload, finalIsActive]);
var finalLabel = tooltipEventType === 'axis' ? labelFromRedux : undefined;
useTooltipChartSynchronisation(tooltipEventType, trigger, coordinate, finalLabel, activeIndex, finalIsActive);
var tooltipPortal = portalFromProps !== null && portalFromProps !== void 0 ? portalFromProps : tooltipPortalFromContext;
if (tooltipPortal == null || viewBox == null || tooltipEventType == null) {
return null;
}
var finalPayload = payload !== null && payload !== void 0 ? payload : emptyPayload;
if (!finalIsActive) {
finalPayload = emptyPayload;
}
if (filterNull && finalPayload.length) {
finalPayload = getUniqPayload(finalPayload.filter(entry => entry.value != null && (entry.hide !== true || props.includeHidden)), payloadUniqBy, defaultUniqBy);
}
var hasPayload = finalPayload.length > 0;
var tooltipElement = /*#__PURE__*/React.createElement(TooltipBoundingBox, {
allowEscapeViewBox: allowEscapeViewBox,
animationDuration: animationDuration,
animationEasing: animationEasing,
isAnimationActive: isAnimationActive,
active: finalIsActive,
coordinate: coordinate,
hasPayload: hasPayload,
offset: offset,
position: position,
reverseDirection: reverseDirection,
useTranslate3d: useTranslate3d,
viewBox: viewBox,
wrapperStyle: wrapperStyle,
lastBoundingBox: lastBoundingBox,
innerRef: updateBoundingBox,
hasPortalFromProps: Boolean(portalFromProps)
}, renderContent(content, _objectSpread(_objectSpread({}, props), {}, {
payload: finalPayload,
label: finalLabel,
active: finalIsActive,
activeIndex,
coordinate,
accessibilityLayer
})));
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/createPortal(tooltipElement, tooltipPortal), finalIsActive && /*#__PURE__*/React.createElement(Cursor, {
cursor: cursor,
tooltipEventType: tooltipEventType,
coordinate: coordinate,
payload: finalPayload,
index: activeIndex
}));
}

View File

@@ -0,0 +1,110 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { PureComponent } from 'react';
import { getTooltipTranslate } from '../util/tooltip/translate';
export class TooltipBoundingBox extends PureComponent {
constructor() {
super(...arguments);
_defineProperty(this, "state", {
dismissed: false,
dismissedAtCoordinate: {
x: 0,
y: 0
}
});
_defineProperty(this, "handleKeyDown", event => {
if (event.key === 'Escape') {
var _this$props$coordinat, _this$props$coordinat2, _this$props$coordinat3, _this$props$coordinat4;
this.setState({
dismissed: true,
dismissedAtCoordinate: {
x: (_this$props$coordinat = (_this$props$coordinat2 = this.props.coordinate) === null || _this$props$coordinat2 === void 0 ? void 0 : _this$props$coordinat2.x) !== null && _this$props$coordinat !== void 0 ? _this$props$coordinat : 0,
y: (_this$props$coordinat3 = (_this$props$coordinat4 = this.props.coordinate) === null || _this$props$coordinat4 === void 0 ? void 0 : _this$props$coordinat4.y) !== null && _this$props$coordinat3 !== void 0 ? _this$props$coordinat3 : 0
}
});
}
});
}
componentDidMount() {
document.addEventListener('keydown', this.handleKeyDown);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.handleKeyDown);
}
componentDidUpdate() {
var _this$props$coordinat5, _this$props$coordinat6;
if (!this.state.dismissed) {
return;
}
if (((_this$props$coordinat5 = this.props.coordinate) === null || _this$props$coordinat5 === void 0 ? void 0 : _this$props$coordinat5.x) !== this.state.dismissedAtCoordinate.x || ((_this$props$coordinat6 = this.props.coordinate) === null || _this$props$coordinat6 === void 0 ? void 0 : _this$props$coordinat6.y) !== this.state.dismissedAtCoordinate.y) {
this.state.dismissed = false;
}
}
render() {
var {
active,
allowEscapeViewBox,
animationDuration,
animationEasing,
children,
coordinate,
hasPayload,
isAnimationActive,
offset,
position,
reverseDirection,
useTranslate3d,
viewBox,
wrapperStyle,
lastBoundingBox,
innerRef,
hasPortalFromProps
} = this.props;
var {
cssClasses,
cssProperties
} = getTooltipTranslate({
allowEscapeViewBox,
coordinate,
offsetTopLeft: offset,
position,
reverseDirection,
tooltipBox: {
height: lastBoundingBox.height,
width: lastBoundingBox.width
},
useTranslate3d,
viewBox
});
// do not use absolute styles if the user has passed a custom portal prop
var positionStyles = hasPortalFromProps ? {} : _objectSpread(_objectSpread({
transition: isAnimationActive && active ? "transform ".concat(animationDuration, "ms ").concat(animationEasing) : undefined
}, cssProperties), {}, {
pointerEvents: 'none',
visibility: !this.state.dismissed && active && hasPayload ? 'visible' : 'hidden',
position: 'absolute',
top: 0,
left: 0
});
var outerStyle = _objectSpread(_objectSpread({}, positionStyles), {}, {
visibility: !this.state.dismissed && active && hasPayload ? 'visible' : 'hidden'
}, wrapperStyle);
return (
/*#__PURE__*/
// This element allow listening to the `Escape` key. See https://github.com/recharts/recharts/pull/2925
React.createElement("div", {
// @ts-expect-error typescript library does not recognize xmlns attribute, but it's required for an HTML chunk inside SVG.
xmlns: "http://www.w3.org/1999/xhtml",
tabIndex: -1,
className: cssClasses,
style: outerStyle,
ref: innerRef
}, children)
);
}
}

View File

@@ -0,0 +1,103 @@
import { isPercent } from '../util/DataUtils';
export var calculateChartDimensions = (containerWidth, containerHeight, props) => {
var {
width = '100%',
height = '100%',
aspect,
maxHeight
} = props;
/*
* The containerWidth and containerHeight are already percentage based because it's set as that percentage in CSS.
* Means we don't have to calculate percentages here.
*/
var calculatedWidth = isPercent(width) ? containerWidth : Number(width);
var calculatedHeight = isPercent(height) ? containerHeight : Number(height);
if (aspect && aspect > 0) {
// Preserve the desired aspect ratio
if (calculatedWidth) {
// Will default to using width for aspect ratio
calculatedHeight = calculatedWidth / aspect;
} else if (calculatedHeight) {
// But we should also take height into consideration
calculatedWidth = calculatedHeight * aspect;
}
// if maxHeight is set, overwrite if calculatedHeight is greater than maxHeight
if (maxHeight && calculatedHeight != null && calculatedHeight > maxHeight) {
calculatedHeight = maxHeight;
}
}
return {
calculatedWidth,
calculatedHeight
};
};
var bothOverflow = {
width: 0,
height: 0,
overflow: 'visible'
};
var overflowX = {
width: 0,
overflowX: 'visible'
};
var overflowY = {
height: 0,
overflowY: 'visible'
};
var noStyle = {};
/**
* This zero-size, overflow-visible is required to allow the chart to shrink.
* Without it, the chart itself will fill the ResponsiveContainer, and while it allows the chart to grow,
* it would always keep the container at the size of the chart,
* and ResizeObserver would never fire.
* With this zero-size element, the chart itself never actually fills the container,
* it just so happens that it is visible because it overflows.
* I learned this trick from the `react-virtualized` library: https://github.com/bvaughn/react-virtualized-auto-sizer/blob/master/src/AutoSizer.ts
* See https://github.com/recharts/recharts/issues/172 and also https://github.com/bvaughn/react-virtualized/issues/68
*
* Also, we don't need to apply the zero-size style if the dimension is a fixed number (or undefined),
* because in that case the chart can't shrink in that dimension anyway.
* This fixes defining the dimensions using aspect ratio: https://github.com/recharts/recharts/issues/6245
*/
export var getInnerDivStyle = props => {
var {
width,
height
} = props;
var isWidthPercent = isPercent(width);
var isHeightPercent = isPercent(height);
if (isWidthPercent && isHeightPercent) {
return bothOverflow;
}
if (isWidthPercent) {
return overflowX;
}
if (isHeightPercent) {
return overflowY;
}
return noStyle;
};
export function getDefaultWidthAndHeight(_ref) {
var {
width,
height,
aspect
} = _ref;
var calculatedWidth = width;
var calculatedHeight = height;
if (calculatedWidth === undefined && calculatedHeight === undefined) {
calculatedWidth = '100%';
calculatedHeight = '100%';
} else if (calculatedWidth === undefined) {
calculatedWidth = aspect && aspect > 0 ? undefined : '100%';
} else if (calculatedHeight === undefined) {
calculatedHeight = aspect && aspect > 0 ? undefined : '100%';
}
return {
width: calculatedWidth,
height: calculatedHeight
};
}

View File

@@ -0,0 +1,45 @@
import * as React from 'react';
import { createContext, useContext, useState } from 'react';
import { uniqueId } from '../util/DataUtils';
import { usePlotArea } from '../hooks';
var ClipPathIdContext = /*#__PURE__*/createContext(undefined);
/**
* Generates a unique clip path ID for use in SVG elements,
* and puts it in a context provider.
*
* To read the clip path ID, use the `useClipPathId` hook,
* or render `<ClipPath>` component which will automatically use the ID from this context.
*
* @param props children - React children to be wrapped by the provider
* @returns React Context Provider
*/
export var ClipPathProvider = _ref => {
var {
children
} = _ref;
var [clipPathId] = useState("".concat(uniqueId('recharts'), "-clip"));
var plotArea = usePlotArea();
if (plotArea == null) {
return null;
}
var {
x,
y,
width,
height
} = plotArea;
return /*#__PURE__*/React.createElement(ClipPathIdContext.Provider, {
value: clipPathId
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
id: clipPathId
}, /*#__PURE__*/React.createElement("rect", {
x: x,
y: y,
height: height,
width: width
}))), children);
};
export var useClipPathId = () => {
return useContext(ClipPathIdContext);
};

20
frontend/node_modules/recharts/es6/container/Layer.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var _excluded = ["children", "className"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { clsx } from 'clsx';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
export var Layer = /*#__PURE__*/React.forwardRef((props, ref) => {
var {
children,
className
} = props,
others = _objectWithoutProperties(props, _excluded);
var layerClass = clsx('recharts-layer', className);
return /*#__PURE__*/React.createElement("g", _extends({
className: layerClass
}, svgPropertiesAndEvents(others), {
ref: ref
}), children);
});

View File

@@ -0,0 +1,103 @@
var _excluded = ["children"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { forwardRef } from 'react';
import { useChartHeight, useChartWidth } from '../context/chartLayoutContext';
import { useAccessibilityLayer } from '../context/accessibilityContext';
import { useIsPanorama } from '../context/PanoramaContext';
import { Surface } from './Surface';
import { useAppSelector } from '../state/hooks';
import { selectBrushDimensions } from '../state/selectors/brushSelectors';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
import { AllZIndexPortals } from '../zIndex/ZIndexPortal';
var FULL_WIDTH_AND_HEIGHT = {
width: '100%',
height: '100%',
/*
* display: block is necessary here because the default for an SVG is display: inline,
* which in some browsers (Chrome) adds a little bit of extra space above and below the SVG
* to make space for the descender of letters like "g" and "y". This throws off the height calculation
* and causes the container to grow indefinitely on each render with responsive=true.
* Display: block removes that extra space.
*
* Interestingly, Firefox does not have this problem, but it doesn't hurt to add the style anyway.
*/
display: 'block'
};
var MainChartSurface = /*#__PURE__*/forwardRef((props, ref) => {
var width = useChartWidth();
var height = useChartHeight();
var hasAccessibilityLayer = useAccessibilityLayer();
if (!isPositiveNumber(width) || !isPositiveNumber(height)) {
return null;
}
var {
children,
otherAttributes,
title,
desc
} = props;
var tabIndex, role;
if (otherAttributes != null) {
if (typeof otherAttributes.tabIndex === 'number') {
tabIndex = otherAttributes.tabIndex;
} else {
tabIndex = hasAccessibilityLayer ? 0 : undefined;
}
if (typeof otherAttributes.role === 'string') {
role = otherAttributes.role;
} else {
role = hasAccessibilityLayer ? 'application' : undefined;
}
}
return /*#__PURE__*/React.createElement(Surface, _extends({}, otherAttributes, {
title: title,
desc: desc,
role: role,
tabIndex: tabIndex,
width: width,
height: height,
style: FULL_WIDTH_AND_HEIGHT,
ref: ref
}), children);
});
var BrushPanoramaSurface = _ref => {
var {
children
} = _ref;
var brushDimensions = useAppSelector(selectBrushDimensions);
if (!brushDimensions) {
return null;
}
var {
width,
height,
y,
x
} = brushDimensions;
return /*#__PURE__*/React.createElement(Surface, {
width: width,
height: height,
x: x,
y: y
}, children);
};
export var RootSurface = /*#__PURE__*/forwardRef((_ref2, ref) => {
var {
children
} = _ref2,
rest = _objectWithoutProperties(_ref2, _excluded);
var isPanorama = useIsPanorama();
if (isPanorama) {
return /*#__PURE__*/React.createElement(BrushPanoramaSurface, null, /*#__PURE__*/React.createElement(AllZIndexPortals, {
isPanorama: true
}, children));
}
return /*#__PURE__*/React.createElement(MainChartSurface, _extends({
ref: ref
}, rest), /*#__PURE__*/React.createElement(AllZIndexPortals, {
isPanorama: false
}, children));
});

View File

@@ -0,0 +1,39 @@
var _excluded = ["children", "width", "height", "viewBox", "className", "style", "title", "desc"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Surface
*/
import * as React from 'react';
import { forwardRef } from 'react';
import { clsx } from 'clsx';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
export var Surface = /*#__PURE__*/forwardRef((props, ref) => {
var {
children,
width,
height,
viewBox,
className,
style,
title,
desc
} = props,
others = _objectWithoutProperties(props, _excluded);
var svgView = viewBox || {
width,
height,
x: 0,
y: 0
};
var layerClass = clsx('recharts-surface', className);
return /*#__PURE__*/React.createElement("svg", _extends({}, svgPropertiesAndEvents(others), {
className: layerClass,
width: width,
height: height,
style: style,
viewBox: "".concat(svgView.x, " ").concat(svgView.y, " ").concat(svgView.width, " ").concat(svgView.height),
ref: ref
}), /*#__PURE__*/React.createElement("title", null, title), /*#__PURE__*/React.createElement("desc", null, desc), children);
});

View File

@@ -0,0 +1,66 @@
var _excluded = ["children"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { createContext, useContext, useEffect, useRef } from 'react';
import { addErrorBar, removeErrorBar, replaceErrorBar } from '../state/errorBarSlice';
import { useAppDispatch } from '../state/hooks';
import { useGraphicalItemId } from './RegisterGraphicalItemId';
var initialContextState = {
data: [],
xAxisId: 'xAxis-0',
yAxisId: 'yAxis-0',
dataPointFormatter: () => ({
x: 0,
y: 0,
value: 0
}),
errorBarOffset: 0
};
var ErrorBarContext = /*#__PURE__*/createContext(initialContextState);
export function SetErrorBarContext(props) {
var {
children
} = props,
rest = _objectWithoutProperties(props, _excluded);
return /*#__PURE__*/React.createElement(ErrorBarContext.Provider, {
value: rest
}, children);
}
export var useErrorBarContext = () => useContext(ErrorBarContext);
export function ReportErrorBarSettings(props) {
var dispatch = useAppDispatch();
var graphicalItemId = useGraphicalItemId();
var prevPropsRef = useRef(null);
useEffect(() => {
if (graphicalItemId == null) {
// ErrorBar outside a graphical item context does not do anything.
return;
}
if (prevPropsRef.current === null) {
dispatch(addErrorBar({
itemId: graphicalItemId,
errorBar: props
}));
} else if (prevPropsRef.current !== props) {
dispatch(replaceErrorBar({
itemId: graphicalItemId,
prev: prevPropsRef.current,
next: props
}));
}
prevPropsRef.current = props;
}, [dispatch, graphicalItemId, props]);
useEffect(() => {
return () => {
if (prevPropsRef.current != null && graphicalItemId != null) {
dispatch(removeErrorBar({
itemId: graphicalItemId,
errorBar: prevPropsRef.current
}));
prevPropsRef.current = null;
}
};
}, [dispatch, graphicalItemId]);
return null;
}

View File

@@ -0,0 +1,12 @@
import * as React from 'react';
import { createContext, useContext } from 'react';
var PanoramaContext = /*#__PURE__*/createContext(null);
export var useIsPanorama = () => useContext(PanoramaContext) != null;
export var PanoramaContextProvider = _ref => {
var {
children
} = _ref;
return /*#__PURE__*/React.createElement(PanoramaContext.Provider, {
value: true
}, children);
};

View File

@@ -0,0 +1,18 @@
import * as React from 'react';
import { createContext, useContext } from 'react';
import { useUniqueId } from '../util/useUniqueId';
var GraphicalItemIdContext = /*#__PURE__*/createContext(undefined);
export var RegisterGraphicalItemId = _ref => {
var {
id,
type,
children
} = _ref;
var resolvedId = useUniqueId("recharts-".concat(type), id);
return /*#__PURE__*/React.createElement(GraphicalItemIdContext.Provider, {
value: resolvedId
}, children(resolvedId));
};
export function useGraphicalItemId() {
return useContext(GraphicalItemIdContext);
}

View File

@@ -0,0 +1,5 @@
import { useAppSelector } from '../state/hooks';
export var useAccessibilityLayer = () => {
var _useAppSelector;
return (_useAppSelector = useAppSelector(state => state.rootProps.accessibilityLayer)) !== null && _useAppSelector !== void 0 ? _useAppSelector : true;
};

View File

@@ -0,0 +1,2 @@
import { createContext } from 'react';
export var BrushUpdateDispatchContext = /*#__PURE__*/createContext(() => {});

View File

@@ -0,0 +1,78 @@
import { useEffect } from 'react';
import { setChartData, setComputedData } from '../state/chartDataSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { useIsPanorama } from './PanoramaContext';
export var ChartDataContextProvider = props => {
var {
chartData
} = props;
var dispatch = useAppDispatch();
var isPanorama = useIsPanorama();
useEffect(() => {
if (isPanorama) {
// Panorama mode reuses data from the main chart, so we must not overwrite it here.
return () => {
// there is nothing to clean up
};
}
dispatch(setChartData(chartData));
return () => {
dispatch(setChartData(undefined));
};
}, [chartData, dispatch, isPanorama]);
return null;
};
export var SetComputedData = props => {
var {
computedData
} = props;
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setComputedData(computedData));
return () => {
dispatch(setChartData(undefined));
};
}, [computedData, dispatch]);
return null;
};
var selectChartData = state => state.chartData.chartData;
/**
* "data" is the data of the chart - it has no type because this part of recharts is very flexible.
* Basically it's an array of "something" and then there's the dataKey property in various places
* that's meant to pull other things away from the data.
*
* Some charts have `data` defined on the chart root, and they will return the array through this hook.
* For example: <ComposedChart data={data} />.
*
* Other charts, such as Pie, have data defined on individual graphical elements.
* These charts will return `undefined` through this hook, and you need to read the data from children.
* For example: <PieChart><Pie data={data} />
*
* Some charts also allow setting both - data on the parent, and data on the children at the same time!
* However, this particular selector will only return the ones defined on the parent.
*
* @deprecated use one of the other selectors instead - which one, depends on how do you identify the applicable graphical items.
*
* @return data array for some charts and undefined for other
*/
export var useChartData = () => useAppSelector(selectChartData);
var selectDataIndex = state => {
var {
dataStartIndex,
dataEndIndex
} = state.chartData;
return {
startIndex: dataStartIndex,
endIndex: dataEndIndex
};
};
/**
* startIndex and endIndex are data boundaries, set through Brush.
*
* @return object with startIndex and endIndex
*/
export var useDataIndex = () => {
return useAppSelector(selectDataIndex);
};

View File

@@ -0,0 +1,192 @@
import { useEffect } from 'react';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { setChartSize, setMargin } from '../state/layoutSlice';
import { selectChartOffsetInternal, selectChartViewBox } from '../state/selectors/selectChartOffsetInternal';
import { selectChartHeight, selectChartWidth } from '../state/selectors/containerSelectors';
import { useIsPanorama } from './PanoramaContext';
import { selectBrushDimensions, selectBrushSettings } from '../state/selectors/brushSelectors';
import { useResponsiveContainerContext } from '../component/ResponsiveContainer';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
export function cartesianViewBoxToTrapezoid(box) {
if (!box) {
return undefined;
}
return {
x: box.x,
y: box.y,
upperWidth: 'upperWidth' in box ? box.upperWidth : box.width,
lowerWidth: 'lowerWidth' in box ? box.lowerWidth : box.width,
width: box.width,
height: box.height
};
}
export var useViewBox = () => {
var _useAppSelector;
var panorama = useIsPanorama();
var rootViewBox = useAppSelector(selectChartViewBox);
var brushDimensions = useAppSelector(selectBrushDimensions);
var brushPadding = (_useAppSelector = useAppSelector(selectBrushSettings)) === null || _useAppSelector === void 0 ? void 0 : _useAppSelector.padding;
if (!panorama || !brushDimensions || !brushPadding) {
return rootViewBox;
}
return {
width: brushDimensions.width - brushPadding.left - brushPadding.right,
height: brushDimensions.height - brushPadding.top - brushPadding.bottom,
x: brushPadding.left,
y: brushPadding.top
};
};
var manyComponentsThrowErrorsIfOffsetIsUndefined = {
top: 0,
bottom: 0,
left: 0,
right: 0,
width: 0,
height: 0,
brushBottom: 0
};
/**
* For internal use only. If you want this information, `import { useOffset } from 'recharts'` instead.
*
* Returns the offset of the chart in pixels.
*
* @returns {ChartOffsetInternal} The offset of the chart in pixels, or a default value if not in a chart context.
*/
export var useOffsetInternal = () => {
var _useAppSelector2;
return (_useAppSelector2 = useAppSelector(selectChartOffsetInternal)) !== null && _useAppSelector2 !== void 0 ? _useAppSelector2 : manyComponentsThrowErrorsIfOffsetIsUndefined;
};
/**
* Returns the width of the chart in pixels.
*
* If you are using chart with hardcoded `width` prop, then the width returned will be the same
* as the `width` prop on the main chart element.
*
* If you are using a chart with a `ResponsiveContainer`, the width will be the size of the chart
* as the ResponsiveContainer has decided it would be.
*
* If the chart has any axes or legend, the `width` will be the size of the chart
* including the axes and legend. Meaning: adding axes and legend will not change the width.
*
* The dimensions do not scale, meaning as user zoom in and out, the width number will not change
* as the chart gets visually larger or smaller.
*
* Returns `undefined` if used outside a chart context.
*
* @returns {number | undefined} The width of the chart in pixels, or `undefined` if not in a chart context.
*/
export var useChartWidth = () => {
return useAppSelector(selectChartWidth);
};
/**
* Returns the height of the chart in pixels.
*
* If you are using chart with hardcoded `height` props, then the height returned will be the same
* as the `height` prop on the main chart element.
*
* If you are using a chart with a `ResponsiveContainer`, the height will be the size of the chart
* as the ResponsiveContainer has decided it would be.
*
* If the chart has any axes or legend, the `height` will be the size of the chart
* including the axes and legend. Meaning: adding axes and legend will not change the height.
*
* The dimensions do not scale, meaning as user zoom in and out, the height number will not change
* as the chart gets visually larger or smaller.
*
* Returns `undefined` if used outside a chart context.
*
* @returns {number | undefined} The height of the chart in pixels, or `undefined` if not in a chart context.
*/
export var useChartHeight = () => {
return useAppSelector(selectChartHeight);
};
/**
* Margin is the empty space around the chart. Excludes axes and legend and brushes and the like.
* This is declared by the user in the chart props.
* If you are interested in the space occupied by axes, legend, or brushes,
* use `useOffset` instead.
*
* Returns `undefined` if used outside a chart context.
*
* @returns {Margin | undefined} The margin of the chart in pixels, or `undefined` if not in a chart context.
*/
export var useMargin = () => {
return useAppSelector(state => state.layout.margin);
};
export var selectChartLayout = state => state.layout.layoutType;
export var useChartLayout = () => useAppSelector(selectChartLayout);
/**
* Returns true if the component is rendered inside a chart context.
* Some components may be used both inside and outside of charts,
* and this hook allows them to determine if they are in a chart context or not.
*
* Other selectors may return undefined when used outside a chart context,
* or undefined when inside a chart, but without relevant data.
* This hook provides a more explicit way to check for chart context.
*
* @returns {boolean} True if in chart context, false otherwise.
*/
export var useIsInChartContext = () => {
/*
* All charts provide a layout type in the chart context.
* If we have a layout type, we are in a chart context.
*/
var layout = useChartLayout();
return layout !== undefined;
};
export var ReportChartSize = props => {
var dispatch = useAppDispatch();
/*
* Skip dispatching properties in panorama chart for two reasons:
* 1. The root chart should be deciding on these properties, and
* 2. Brush reads these properties from redux store, and so they must remain stable
* to avoid circular dependency and infinite re-rendering.
*/
var isPanorama = useIsPanorama();
var {
width: widthFromProps,
height: heightFromProps
} = props;
var responsiveContainerCalculations = useResponsiveContainerContext();
var width = widthFromProps;
var height = heightFromProps;
if (responsiveContainerCalculations) {
/*
* In case we receive width and height from ResponsiveContainer,
* we will always prefer those.
* Only in case ResponsiveContainer does not provide width or height,
* we will fall back to the explicitly provided width and height.
*
* This to me feels backwards - we should allow override by the more specific props on individual charts, right?
* But this is 3.x behaviour, so let's keep it for backwards compatibility.
*
* We can change this in 4.x if we want to.
*/
width = responsiveContainerCalculations.width > 0 ? responsiveContainerCalculations.width : widthFromProps;
height = responsiveContainerCalculations.height > 0 ? responsiveContainerCalculations.height : heightFromProps;
}
useEffect(() => {
if (!isPanorama && isPositiveNumber(width) && isPositiveNumber(height)) {
dispatch(setChartSize({
width,
height
}));
}
}, [dispatch, isPanorama, width, height]);
return null;
};
export var ReportChartMargin = _ref => {
var {
margin
} = _ref;
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setMargin(margin));
}, [dispatch, margin]);
return null;
};

View File

@@ -0,0 +1,10 @@
import { useAppSelector } from '../state/hooks';
import { selectLegendPayload } from '../state/selectors/legendSelectors';
/**
* Use this hook in Legend, or anywhere else where you want to read the current Legend items.
* @return all Legend items ready to be rendered
*/
export function useLegendPayload() {
return useAppSelector(selectLegendPayload);
}

View File

@@ -0,0 +1,3 @@
import { createContext, useContext } from 'react';
export var LegendPortalContext = /*#__PURE__*/createContext(null);
export var useLegendPortal = () => useContext(LegendPortalContext);

View File

@@ -0,0 +1,31 @@
import { useAppDispatch } from '../state/hooks';
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
export var useMouseEnterItemDispatch = (onMouseEnterFromProps, dataKey) => {
var dispatch = useAppDispatch();
return (data, index) => event => {
onMouseEnterFromProps === null || onMouseEnterFromProps === void 0 || onMouseEnterFromProps(data, index, event);
dispatch(setActiveMouseOverItemIndex({
activeIndex: String(index),
activeDataKey: dataKey,
activeCoordinate: data.tooltipPosition
}));
};
};
export var useMouseLeaveItemDispatch = onMouseLeaveFromProps => {
var dispatch = useAppDispatch();
return (data, index) => event => {
onMouseLeaveFromProps === null || onMouseLeaveFromProps === void 0 || onMouseLeaveFromProps(data, index, event);
dispatch(mouseLeaveItem());
};
};
export var useMouseClickItemDispatch = (onMouseClickFromProps, dataKey) => {
var dispatch = useAppDispatch();
return (data, index) => event => {
onMouseClickFromProps === null || onMouseClickFromProps === void 0 || onMouseClickFromProps(data, index, event);
dispatch(setActiveClickItemIndex({
activeIndex: String(index),
activeDataKey: dataKey,
activeCoordinate: data.tooltipPosition
}));
};
};

View File

@@ -0,0 +1,3 @@
import { createContext, useContext } from 'react';
export var TooltipPortalContext = /*#__PURE__*/createContext(null);
export var useTooltipPortal = () => useContext(TooltipPortalContext);

View File

@@ -0,0 +1,21 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { useAppSelector } from '../state/hooks';
import { getBandSizeOfAxis } from '../util/ChartUtils';
import { selectTooltipAxis } from '../state/selectors/axisSelectors';
import { selectTooltipAxisScale, selectTooltipAxisTicks } from '../state/selectors/tooltipSelectors';
export var useTooltipAxis = () => useAppSelector(selectTooltipAxis);
export var useTooltipAxisBandSize = () => {
var tooltipAxis = useTooltipAxis();
var tooltipTicks = useAppSelector(selectTooltipAxisTicks);
var tooltipAxisScale = useAppSelector(selectTooltipAxisScale);
if (!tooltipAxis || !tooltipAxisScale) {
return getBandSizeOfAxis(undefined, tooltipTicks);
}
return getBandSizeOfAxis(_objectSpread(_objectSpread({}, tooltipAxis), {}, {
scale: tooltipAxisScale
}), tooltipTicks);
};

112
frontend/node_modules/recharts/es6/hooks.js generated vendored Normal file
View File

@@ -0,0 +1,112 @@
import { defaultAxisId } from './state/cartesianAxisSlice';
import { selectAxisDomain, selectAxisWithScale } from './state/selectors/axisSelectors';
import { useAppSelector } from './state/hooks';
import { useIsPanorama } from './context/PanoramaContext';
import { selectActiveLabel, selectActiveTooltipDataPoints } from './state/selectors/tooltipSelectors';
import { selectChartOffset } from './state/selectors/selectChartOffset';
import { selectPlotArea } from './state/selectors/selectPlotArea';
export var useXAxis = xAxisId => {
var isPanorama = useIsPanorama();
return useAppSelector(state => selectAxisWithScale(state, 'xAxis', xAxisId, isPanorama));
};
export var useYAxis = yAxisId => {
var isPanorama = useIsPanorama();
return useAppSelector(state => selectAxisWithScale(state, 'yAxis', yAxisId, isPanorama));
};
/**
* Returns the active tooltip label. The label is one of the values from the chart data,
* and is used to display in the tooltip content.
*
* Returns undefined if there is no active user interaction or if used outside a chart context
*
* @returns string | undefined
*/
export var useActiveTooltipLabel = () => {
return useAppSelector(selectActiveLabel);
};
/**
* Offset defines the blank space between the chart and the plot area.
* This blank space is occupied by supporting elements like axes, legends, and brushes.
* This also includes any margins that might be applied to the chart.
* If you are interested in the margin alone, use `useMargin` instead.
*
* @returns Offset of the chart in pixels, or undefined if used outside a chart context.
*/
export var useOffset = () => {
return useAppSelector(selectChartOffset);
};
/**
* Plot area is the area where the actual chart data is rendered.
* This means: bars, lines, scatter points, etc.
*
* The plot area is calculated based on the chart dimensions and the offset.
*
* @returns Plot area of the chart in pixels, or undefined if used outside a chart context.
*/
export var usePlotArea = () => {
return useAppSelector(selectPlotArea);
};
/**
* Returns the currently active data points being displayed in the Tooltip.
* Active means that it is currently visible; this hook will return `undefined` if there is no current interaction.
*
* This follows the `<Tooltip />` props, if the Tooltip element is present in the chart.
* If there is no `<Tooltip />` then this hook will follow the default Tooltip props.
*
* Data point is whatever you pass as an input to the chart using the `data={}` prop.
*
* This returns an array because a chart can have multiple graphical items in it (multiple Lines for example)
* and tooltip with `shared={true}` will display all items at the same time.
*
* Returns undefined when used outside a chart context.
*
* @returns Data points that are currently visible in a Tooltip
*/
export var useActiveTooltipDataPoints = () => {
return useAppSelector(selectActiveTooltipDataPoints);
};
/**
* Returns the calculated domain of an X-axis.
*
* The domain can be numerical: `[min, max]`, or categorical: `['a', 'b', 'c']`.
*
* The type of the domain is defined by the `type` prop of the XAxis.
*
* The values of the domain are calculated based on the data and the `dataKey` of the axis.
*
* If the chart has a Brush, the domain will be filtered to the brushed indexes if the hook is used outside a Brush context,
* and the full domain will be returned if the hook is used inside a Brush context.
*
* @param xAxisId The `xAxisId` of the X-axis. Defaults to `0` if not provided.
* @returns The domain of the X-axis, or `undefined` if it cannot be calculated or if used outside a chart context.
*/
export var useXAxisDomain = function useXAxisDomain() {
var xAxisId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultAxisId;
var isPanorama = useIsPanorama();
return useAppSelector(state => selectAxisDomain(state, 'xAxis', xAxisId, isPanorama));
};
/**
* Returns the calculated domain of a Y-axis.
*
* The domain can be numerical: `[min, max]`, or categorical: `['a', 'b', 'c']`.
*
* The type of the domain is defined by the `type` prop of the YAxis.
*
* The values of the domain are calculated based on the data and the `dataKey` of the axis.
*
* Does not interact with Brushes, as Y-axes do not support brushing.
*
* @param yAxisId The `yAxisId` of the Y-axis. Defaults to `0` if not provided.
* @returns The domain of the Y-axis, or `undefined` if it cannot be calculated or if used outside a chart context.
*/
export var useYAxisDomain = function useYAxisDomain() {
var yAxisId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultAxisId;
var isPanorama = useIsPanorama();
return useAppSelector(state => selectAxisDomain(state, 'yAxis', yAxisId, isPanorama));
};

66
frontend/node_modules/recharts/es6/index.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
// "export type" declarations on separate lines are in use
// to workaround babel issue(s) 11465 12578
//
// see https://github.com/babel/babel/issues/11464#issuecomment-617606898
export { Surface } from './container/Surface';
export { Layer } from './container/Layer';
export { Legend } from './component/Legend';
export { DefaultLegendContent } from './component/DefaultLegendContent';
export { Tooltip } from './component/Tooltip';
export { DefaultTooltipContent } from './component/DefaultTooltipContent';
export { ResponsiveContainer } from './component/ResponsiveContainer';
export { Cell } from './component/Cell';
export { Text } from './component/Text';
export { Label } from './component/Label';
export { LabelList } from './component/LabelList';
export { Customized } from './component/Customized';
export { Sector } from './shape/Sector';
export { Curve } from './shape/Curve';
export { Rectangle } from './shape/Rectangle';
export { Polygon } from './shape/Polygon';
export { Dot } from './shape/Dot';
export { Cross } from './shape/Cross';
export { Symbols } from './shape/Symbols';
export { PolarGrid } from './polar/PolarGrid';
export { PolarRadiusAxis } from './polar/PolarRadiusAxis';
export { PolarAngleAxis } from './polar/PolarAngleAxis';
export { Pie } from './polar/Pie';
export { Radar } from './polar/Radar';
export { RadialBar } from './polar/RadialBar';
export { Brush } from './cartesian/Brush';
export { ReferenceLine } from './cartesian/ReferenceLine';
export { ReferenceDot } from './cartesian/ReferenceDot';
export { ReferenceArea } from './cartesian/ReferenceArea';
export { CartesianAxis } from './cartesian/CartesianAxis';
export { CartesianGrid } from './cartesian/CartesianGrid';
export { Line } from './cartesian/Line';
export { Area } from './cartesian/Area';
export { Bar } from './cartesian/Bar';
export { Scatter } from './cartesian/Scatter';
export { XAxis } from './cartesian/XAxis';
export { YAxis } from './cartesian/YAxis';
export { ZAxis } from './cartesian/ZAxis';
export { ErrorBar } from './cartesian/ErrorBar';
export { LineChart } from './chart/LineChart';
export { BarChart } from './chart/BarChart';
export { PieChart } from './chart/PieChart';
export { Treemap } from './chart/Treemap';
export { Sankey } from './chart/Sankey';
export { RadarChart } from './chart/RadarChart';
export { ScatterChart } from './chart/ScatterChart';
export { AreaChart } from './chart/AreaChart';
export { RadialBarChart } from './chart/RadialBarChart';
export { ComposedChart } from './chart/ComposedChart';
export { SunburstChart } from './chart/SunburstChart';
export { Funnel } from './cartesian/Funnel';
export { FunnelChart } from './chart/FunnelChart';
export { Trapezoid } from './shape/Trapezoid';
export { Global } from './util/Global';
export { ZIndexLayer } from './zIndex/ZIndexLayer';
export { DefaultZIndexes } from './zIndex/DefaultZIndexes';
/** export getNiceTickValues so this can be used as a replacement for what is in recharts-scale */
export { getNiceTickValues } from './util/scale/getNiceTickValues';
export { useActiveTooltipLabel, useOffset, usePlotArea, useActiveTooltipDataPoints, useXAxisDomain, useYAxisDomain } from './hooks';
export { useChartHeight, useChartWidth, useMargin } from './context/chartLayoutContext';

593
frontend/node_modules/recharts/es6/polar/Pie.js generated vendored Normal file
View File

@@ -0,0 +1,593 @@
var _excluded = ["onMouseEnter", "onClick", "onMouseLeave"],
_excluded2 = ["id"],
_excluded3 = ["id"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import get from 'es-toolkit/compat/get';
import { clsx } from 'clsx';
import { selectPieLegend, selectPieSectors } from '../state/selectors/pieSelectors';
import { useAppSelector } from '../state/hooks';
import { Layer } from '../container/Layer';
import { Curve } from '../shape/Curve';
import { Text } from '../component/Text';
import { Cell } from '../component/Cell';
import { findAllByType } from '../util/ReactUtils';
import { Global } from '../util/Global';
import { getMaxRadius, polarToCartesian } from '../util/PolarUtils';
import { getPercentValue, interpolate, isNumber, mathSign } from '../util/DataUtils';
import { getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
import { adaptEventsOfChild } from '../util/types';
import { Shape } from '../util/ActiveShapeUtils';
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
import { SetPolarLegendPayload } from '../state/SetLegendPayload';
import { DATA_ITEM_DATAKEY_ATTRIBUTE_NAME, DATA_ITEM_INDEX_ATTRIBUTE_NAME } from '../util/Constants';
import { useAnimationId } from '../util/useAnimationId';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetPolarGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { LabelListFromLabelProp, PolarLabelListContextProvider } from '../component/LabelList';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
/**
* The `label` prop in Pie accepts a variety of alternatives.
*/
/**
* We spread the data object into the sector data item,
* so we can't really know what is going to be inside.
*
* This type represents our best effort, but it all depends on the input data
* and what is inside of it.
*
* https://github.com/recharts/recharts/issues/6380
* https://github.com/recharts/recharts/discussions/6375
*/
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
function SetPiePayloadLegend(props) {
var cells = useMemo(() => findAllByType(props.children, Cell), [props.children]);
var legendPayload = useAppSelector(state => selectPieLegend(state, props.id, cells));
if (legendPayload == null) {
return null;
}
return /*#__PURE__*/React.createElement(SetPolarLegendPayload, {
legendPayload: legendPayload
});
}
function getTooltipEntrySettings(props) {
var {
dataKey,
nameKey,
sectors,
stroke,
strokeWidth,
fill,
name,
hide,
tooltipType
} = props;
return {
dataDefinedOnItem: sectors.map(p => p.tooltipPayload),
positions: sectors.map(p => p.tooltipPosition),
settings: {
stroke,
strokeWidth,
fill,
dataKey,
nameKey,
name: getTooltipNameProp(name, dataKey),
hide,
type: tooltipType,
color: fill,
unit: '' // why doesn't Pie support unit?
}
};
}
var getTextAnchor = (x, cx) => {
if (x > cx) {
return 'start';
}
if (x < cx) {
return 'end';
}
return 'middle';
};
var getOuterRadius = (dataPoint, outerRadius, maxPieRadius) => {
if (typeof outerRadius === 'function') {
return getPercentValue(outerRadius(dataPoint), maxPieRadius, maxPieRadius * 0.8);
}
return getPercentValue(outerRadius, maxPieRadius, maxPieRadius * 0.8);
};
var parseCoordinateOfPie = (pieSettings, offset, dataPoint) => {
var {
top,
left,
width,
height
} = offset;
var maxPieRadius = getMaxRadius(width, height);
var cx = left + getPercentValue(pieSettings.cx, width, width / 2);
var cy = top + getPercentValue(pieSettings.cy, height, height / 2);
var innerRadius = getPercentValue(pieSettings.innerRadius, maxPieRadius, 0);
var outerRadius = getOuterRadius(dataPoint, pieSettings.outerRadius, maxPieRadius);
var maxRadius = pieSettings.maxRadius || Math.sqrt(width * width + height * height) / 2;
return {
cx,
cy,
innerRadius,
outerRadius,
maxRadius
};
};
var parseDeltaAngle = (startAngle, endAngle) => {
var sign = mathSign(endAngle - startAngle);
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 360);
return sign * deltaAngle;
};
function getClassNamePropertyIfExists(u) {
if (u && typeof u === 'object' && 'className' in u && typeof u.className === 'string') {
return u.className;
}
return '';
}
var renderLabelLineItem = (option, props) => {
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error we can't know if the type of props matches the element
return /*#__PURE__*/React.cloneElement(option, props);
}
if (typeof option === 'function') {
return option(props);
}
var className = clsx('recharts-pie-label-line', typeof option !== 'boolean' ? option.className : '');
return /*#__PURE__*/React.createElement(Curve, _extends({}, props, {
type: "linear",
className: className
}));
};
var renderLabelItem = (option, props, value) => {
if (/*#__PURE__*/React.isValidElement(option)) {
// @ts-expect-error element cloning is not typed
return /*#__PURE__*/React.cloneElement(option, props);
}
var label = value;
if (typeof option === 'function') {
label = option(props);
if (/*#__PURE__*/React.isValidElement(label)) {
return label;
}
}
var className = clsx('recharts-pie-label-text', getClassNamePropertyIfExists(option));
return /*#__PURE__*/React.createElement(Text, _extends({}, props, {
alignmentBaseline: "middle",
className: className
}), label);
};
function PieLabels(_ref) {
var {
sectors,
props,
showLabels
} = _ref;
var {
label,
labelLine,
dataKey
} = props;
if (!showLabels || !label || !sectors) {
return null;
}
var pieProps = svgPropertiesNoEvents(props);
var customLabelProps = svgPropertiesNoEventsFromUnknown(label);
var customLabelLineProps = svgPropertiesNoEventsFromUnknown(labelLine);
var offsetRadius = typeof label === 'object' && 'offsetRadius' in label && typeof label.offsetRadius === 'number' && label.offsetRadius || 20;
var labels = sectors.map((entry, i) => {
var midAngle = (entry.startAngle + entry.endAngle) / 2;
var endPoint = polarToCartesian(entry.cx, entry.cy, entry.outerRadius + offsetRadius, midAngle);
var labelProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
// @ts-expect-error customLabelProps is contributing unknown props
stroke: 'none'
}, customLabelProps), {}, {
index: i,
textAnchor: getTextAnchor(endPoint.x, entry.cx)
}, endPoint);
var lineProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieProps), entry), {}, {
// @ts-expect-error customLabelLineProps is contributing unknown props
fill: 'none',
// @ts-expect-error customLabelLineProps is contributing unknown props
stroke: entry.fill
}, customLabelLineProps), {}, {
index: i,
points: [polarToCartesian(entry.cx, entry.cy, entry.outerRadius, midAngle), endPoint],
key: 'line'
});
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: DefaultZIndexes.label,
key: "label-".concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(entry.midAngle, "-").concat(i)
}, /*#__PURE__*/React.createElement(Layer, null, labelLine && renderLabelLineItem(labelLine, lineProps), renderLabelItem(label, labelProps, getValueByDataKey(entry, dataKey))));
});
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-pie-labels"
}, labels);
}
function PieLabelList(_ref2) {
var {
sectors,
props,
showLabels
} = _ref2;
var {
label
} = props;
if (typeof label === 'object' && label != null && 'position' in label) {
return /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: label
});
}
return /*#__PURE__*/React.createElement(PieLabels, {
sectors: sectors,
props: props,
showLabels: showLabels
});
}
function PieSectors(props) {
var {
sectors,
activeShape,
inactiveShape: inactiveShapeProp,
allOtherPieProps
} = props;
var activeIndex = useAppSelector(selectActiveTooltipIndex);
var {
onMouseEnter: onMouseEnterFromProps,
onClick: onItemClickFromProps,
onMouseLeave: onMouseLeaveFromProps
} = allOtherPieProps,
restOfAllOtherProps = _objectWithoutProperties(allOtherPieProps, _excluded);
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherPieProps.dataKey);
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherPieProps.dataKey);
if (sectors == null || sectors.length === 0) {
return null;
}
return /*#__PURE__*/React.createElement(React.Fragment, null, sectors.map((entry, i) => {
if ((entry === null || entry === void 0 ? void 0 : entry.startAngle) === 0 && (entry === null || entry === void 0 ? void 0 : entry.endAngle) === 0 && sectors.length !== 1) return null;
var isSectorActive = activeShape && String(i) === activeIndex;
var inactiveShape = activeIndex ? inactiveShapeProp : null;
var sectorOptions = isSectorActive ? activeShape : inactiveShape;
var sectorProps = _objectSpread(_objectSpread({}, entry), {}, {
stroke: entry.stroke,
tabIndex: -1,
[DATA_ITEM_INDEX_ATTRIBUTE_NAME]: i,
[DATA_ITEM_DATAKEY_ATTRIBUTE_NAME]: allOtherPieProps.dataKey
});
return /*#__PURE__*/React.createElement(Layer, _extends({
key: "sector-".concat(entry === null || entry === void 0 ? void 0 : entry.startAngle, "-").concat(entry === null || entry === void 0 ? void 0 : entry.endAngle, "-").concat(entry.midAngle, "-").concat(i),
tabIndex: -1,
className: "recharts-pie-sector"
}, adaptEventsOfChild(restOfAllOtherProps, entry, i), {
// @ts-expect-error the types need a bit of attention
onMouseEnter: onMouseEnterFromContext(entry, i)
// @ts-expect-error the types need a bit of attention
,
onMouseLeave: onMouseLeaveFromContext(entry, i)
// @ts-expect-error the types need a bit of attention
,
onClick: onClickFromContext(entry, i)
}), /*#__PURE__*/React.createElement(Shape, _extends({
option: sectorOptions,
isActive: isSectorActive,
shapeType: "sector"
}, sectorProps)));
}));
}
export function computePieSectors(_ref3) {
var _pieSettings$paddingA;
var {
pieSettings,
displayedData,
cells,
offset
} = _ref3;
var {
cornerRadius,
startAngle,
endAngle,
dataKey,
nameKey,
tooltipType
} = pieSettings;
var minAngle = Math.abs(pieSettings.minAngle);
var deltaAngle = parseDeltaAngle(startAngle, endAngle);
var absDeltaAngle = Math.abs(deltaAngle);
var paddingAngle = displayedData.length <= 1 ? 0 : (_pieSettings$paddingA = pieSettings.paddingAngle) !== null && _pieSettings$paddingA !== void 0 ? _pieSettings$paddingA : 0;
var notZeroItemCount = displayedData.filter(entry => getValueByDataKey(entry, dataKey, 0) !== 0).length;
var totalPaddingAngle = (absDeltaAngle >= 360 ? notZeroItemCount : notZeroItemCount - 1) * paddingAngle;
var realTotalAngle = absDeltaAngle - notZeroItemCount * minAngle - totalPaddingAngle;
var sum = displayedData.reduce((result, entry) => {
var val = getValueByDataKey(entry, dataKey, 0);
return result + (isNumber(val) ? val : 0);
}, 0);
var sectors;
if (sum > 0) {
var prev;
sectors = displayedData.map((entry, i) => {
// @ts-expect-error getValueByDataKey does not validate the output type
var val = getValueByDataKey(entry, dataKey, 0);
// @ts-expect-error getValueByDataKey does not validate the output type
var name = getValueByDataKey(entry, nameKey, i);
var coordinate = parseCoordinateOfPie(pieSettings, offset, entry);
var percent = (isNumber(val) ? val : 0) / sum;
var tempStartAngle;
var entryWithCellInfo = _objectSpread(_objectSpread({}, entry), cells && cells[i] && cells[i].props);
if (i) {
tempStartAngle = prev.endAngle + mathSign(deltaAngle) * paddingAngle * (val !== 0 ? 1 : 0);
} else {
tempStartAngle = startAngle;
}
var tempEndAngle = tempStartAngle + mathSign(deltaAngle) * ((val !== 0 ? minAngle : 0) + percent * realTotalAngle);
var midAngle = (tempStartAngle + tempEndAngle) / 2;
var middleRadius = (coordinate.innerRadius + coordinate.outerRadius) / 2;
var tooltipPayload = [{
name,
value: val,
payload: entryWithCellInfo,
dataKey,
type: tooltipType
}];
var tooltipPosition = polarToCartesian(coordinate.cx, coordinate.cy, middleRadius, midAngle);
prev = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, pieSettings.presentationProps), {}, {
percent,
cornerRadius: typeof cornerRadius === 'string' ? parseFloat(cornerRadius) : cornerRadius,
name,
tooltipPayload,
midAngle,
middleRadius,
tooltipPosition
}, entryWithCellInfo), coordinate), {}, {
value: val,
startAngle: tempStartAngle,
endAngle: tempEndAngle,
payload: entryWithCellInfo,
paddingAngle: mathSign(deltaAngle) * paddingAngle
});
return prev;
});
}
return sectors;
}
function PieLabelListProvider(_ref4) {
var {
showLabels,
sectors,
children
} = _ref4;
var labelListEntries = useMemo(() => {
if (!showLabels || !sectors) {
return [];
}
return sectors.map(entry => ({
value: entry.value,
payload: entry.payload,
clockWise: false,
parentViewBox: undefined,
viewBox: {
cx: entry.cx,
cy: entry.cy,
innerRadius: entry.innerRadius,
outerRadius: entry.outerRadius,
startAngle: entry.startAngle,
endAngle: entry.endAngle,
clockWise: false
},
fill: entry.fill
}));
}, [sectors, showLabels]);
return /*#__PURE__*/React.createElement(PolarLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function SectorsWithAnimation(_ref5) {
var {
props,
previousSectorsRef
} = _ref5;
var {
sectors,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
activeShape,
inactiveShape,
onAnimationStart,
onAnimationEnd
} = props;
var animationId = useAnimationId(props, 'recharts-pie-');
var prevSectors = previousSectorsRef.current;
var [isAnimating, setIsAnimating] = useState(false);
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
return /*#__PURE__*/React.createElement(PieLabelListProvider, {
showLabels: !isAnimating,
sectors: sectors
}, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
onAnimationStart: handleAnimationStart,
onAnimationEnd: handleAnimationEnd,
key: animationId
}, t => {
var stepData = [];
var first = sectors && sectors[0];
var curAngle = first === null || first === void 0 ? void 0 : first.startAngle;
sectors === null || sectors === void 0 || sectors.forEach((entry, index) => {
var prev = prevSectors && prevSectors[index];
var paddingAngle = index > 0 ? get(entry, 'paddingAngle', 0) : 0;
if (prev) {
var angle = interpolate(prev.endAngle - prev.startAngle, entry.endAngle - entry.startAngle, t);
var latest = _objectSpread(_objectSpread({}, entry), {}, {
startAngle: curAngle + paddingAngle,
endAngle: curAngle + angle + paddingAngle
});
stepData.push(latest);
curAngle = latest.endAngle;
} else {
var {
endAngle,
startAngle
} = entry;
var deltaAngle = interpolate(0, endAngle - startAngle, t);
var _latest = _objectSpread(_objectSpread({}, entry), {}, {
startAngle: curAngle + paddingAngle,
endAngle: curAngle + deltaAngle + paddingAngle
});
stepData.push(_latest);
curAngle = _latest.endAngle;
}
});
// eslint-disable-next-line no-param-reassign
previousSectorsRef.current = stepData;
return /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement(PieSectors, {
sectors: stepData,
activeShape: activeShape,
inactiveShape: inactiveShape,
allOtherPieProps: props
}));
}), /*#__PURE__*/React.createElement(PieLabelList, {
showLabels: !isAnimating,
sectors: sectors,
props: props
}), props.children);
}
var defaultPieProps = {
animationBegin: 400,
animationDuration: 1500,
animationEasing: 'ease',
cx: '50%',
cy: '50%',
dataKey: 'value',
endAngle: 360,
fill: '#808080',
hide: false,
innerRadius: 0,
isAnimationActive: !Global.isSsr,
labelLine: true,
legendType: 'rect',
minAngle: 0,
nameKey: 'name',
outerRadius: '80%',
paddingAngle: 0,
rootTabIndex: 0,
startAngle: 0,
stroke: '#fff',
zIndex: DefaultZIndexes.area
};
function PieImpl(props) {
var {
id
} = props,
propsWithoutId = _objectWithoutProperties(props, _excluded2);
var {
hide,
className,
rootTabIndex
} = props;
var cells = useMemo(() => findAllByType(props.children, Cell), [props.children]);
var sectors = useAppSelector(state => selectPieSectors(state, id, cells));
var previousSectorsRef = useRef(null);
var layerClass = clsx('recharts-pie', className);
if (hide || sectors == null) {
previousSectorsRef.current = null;
return /*#__PURE__*/React.createElement(Layer, {
tabIndex: rootTabIndex,
className: layerClass
});
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: _objectSpread(_objectSpread({}, props), {}, {
sectors
})
}), /*#__PURE__*/React.createElement(Layer, {
tabIndex: rootTabIndex,
className: layerClass
}, /*#__PURE__*/React.createElement(SectorsWithAnimation, {
props: _objectSpread(_objectSpread({}, propsWithoutId), {}, {
sectors
}),
previousSectorsRef: previousSectorsRef
})));
}
export function Pie(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultPieProps);
var {
id: externalId
} = props,
propsWithoutId = _objectWithoutProperties(props, _excluded3);
var presentationProps = svgPropertiesNoEvents(propsWithoutId);
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: externalId,
type: "pie"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetPolarGraphicalItem, {
type: "pie",
id: id,
data: propsWithoutId.data,
dataKey: propsWithoutId.dataKey,
hide: propsWithoutId.hide,
angleAxisId: 0,
radiusAxisId: 0,
name: propsWithoutId.name,
nameKey: propsWithoutId.nameKey,
tooltipType: propsWithoutId.tooltipType,
legendType: propsWithoutId.legendType,
fill: propsWithoutId.fill,
cx: propsWithoutId.cx,
cy: propsWithoutId.cy,
startAngle: propsWithoutId.startAngle,
endAngle: propsWithoutId.endAngle,
paddingAngle: propsWithoutId.paddingAngle,
minAngle: propsWithoutId.minAngle,
innerRadius: propsWithoutId.innerRadius,
outerRadius: propsWithoutId.outerRadius,
cornerRadius: propsWithoutId.cornerRadius,
presentationProps: presentationProps,
maxRadius: props.maxRadius
}), /*#__PURE__*/React.createElement(SetPiePayloadLegend, _extends({}, propsWithoutId, {
id: id
})), /*#__PURE__*/React.createElement(PieImpl, _extends({}, propsWithoutId, {
id: id
}))));
}
Pie.displayName = 'Pie';

View File

@@ -0,0 +1,259 @@
var _excluded = ["children"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { useEffect, useMemo } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { Dot } from '../shape/Dot';
import { Polygon } from '../shape/Polygon';
import { Text } from '../component/Text';
import { adaptEventsOfChild } from '../util/types';
import { degreeToRadian, getTickClassName, polarToCartesian } from '../util/PolarUtils';
import { addAngleAxis, removeAngleAxis } from '../state/polarAxisSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { selectPolarAxisScale, selectPolarAxisTicks } from '../state/selectors/polarScaleSelectors';
import { selectAngleAxis, selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
import { defaultPolarAngleAxisProps } from './defaultPolarAngleAxisProps';
import { useIsPanorama } from '../context/PanoramaContext';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
var eps = 1e-5;
var COS_45 = Math.cos(degreeToRadian(45));
var AXIS_TYPE = 'angleAxis';
function SetAngleAxisSettings(props) {
var dispatch = useAppDispatch();
var settings = useMemo(() => {
var {
children
} = props,
rest = _objectWithoutProperties(props, _excluded);
return rest;
}, [props]);
var synchronizedSettings = useAppSelector(state => selectAngleAxis(state, settings.id));
var settingsAreSynchronized = settings === synchronizedSettings;
useEffect(() => {
dispatch(addAngleAxis(settings));
return () => {
dispatch(removeAngleAxis(settings));
};
}, [dispatch, settings]);
if (settingsAreSynchronized) {
return props.children;
}
return null;
}
/**
* Calculate the coordinate of line endpoint
* @param data The data if there are ticks
* @param props axis settings
* @return (x1, y1): The point close to text,
* (x2, y2): The point close to axis
*/
var getTickLineCoord = (data, props) => {
var {
cx,
cy,
radius,
orientation,
tickSize
} = props;
var tickLineSize = tickSize || 8;
var p1 = polarToCartesian(cx, cy, radius, data.coordinate);
var p2 = polarToCartesian(cx, cy, radius + (orientation === 'inner' ? -1 : 1) * tickLineSize, data.coordinate);
return {
x1: p1.x,
y1: p1.y,
x2: p2.x,
y2: p2.y
};
};
/**
* Get the text-anchor of each tick
* @param data Data of ticks
* @param orientation of the axis ticks
* @return text-anchor
*/
var getTickTextAnchor = (data, orientation) => {
var cos = Math.cos(degreeToRadian(-data.coordinate));
if (cos > eps) {
return orientation === 'outer' ? 'start' : 'end';
}
if (cos < -eps) {
return orientation === 'outer' ? 'end' : 'start';
}
return 'middle';
};
/**
* Get the text vertical anchor of each tick
* @param data Data of a tick
* @return text vertical anchor
*/
var getTickTextVerticalAnchor = data => {
var cos = Math.cos(degreeToRadian(-data.coordinate));
var sin = Math.sin(degreeToRadian(-data.coordinate));
// handle top and bottom sectors: 90±45deg and 270±45deg
if (Math.abs(cos) <= COS_45) {
// sin > 0: top sector, sin < 0: bottom sector
return sin > 0 ? 'start' : 'end';
}
return 'middle';
};
var AxisLine = props => {
var {
cx,
cy,
radius,
axisLineType,
axisLine,
ticks
} = props;
if (!axisLine) {
return null;
}
var axisLineProps = _objectSpread(_objectSpread({}, svgPropertiesNoEvents(props)), {}, {
fill: 'none'
}, svgPropertiesNoEvents(axisLine));
if (axisLineType === 'circle') {
// @ts-expect-error wrong SVG element type
return /*#__PURE__*/React.createElement(Dot, _extends({
className: "recharts-polar-angle-axis-line"
}, axisLineProps, {
cx: cx,
cy: cy,
r: radius
}));
}
var points = ticks.map(entry => polarToCartesian(cx, cy, radius, entry.coordinate));
// @ts-expect-error wrong SVG element type
return /*#__PURE__*/React.createElement(Polygon, _extends({
className: "recharts-polar-angle-axis-line"
}, axisLineProps, {
points: points
}));
};
var TickItemText = _ref => {
var {
tick,
tickProps,
value
} = _ref;
if (!tick) {
return null;
}
if (/*#__PURE__*/React.isValidElement(tick)) {
// @ts-expect-error element cloning makes typescript unhappy and me too
return /*#__PURE__*/React.cloneElement(tick, tickProps);
}
if (typeof tick === 'function') {
return tick(tickProps);
}
return /*#__PURE__*/React.createElement(Text, _extends({}, tickProps, {
className: "recharts-polar-angle-axis-tick-value"
}), value);
};
var Ticks = props => {
var {
tick,
tickLine,
tickFormatter,
stroke,
ticks
} = props;
var axisProps = svgPropertiesNoEvents(props);
var customTickProps = svgPropertiesNoEventsFromUnknown(tick);
var tickLineProps = _objectSpread(_objectSpread({}, axisProps), {}, {
fill: 'none'
}, svgPropertiesNoEvents(tickLine));
var items = ticks.map((entry, i) => {
var lineCoord = getTickLineCoord(entry, props);
var textAnchor = getTickTextAnchor(entry, props.orientation);
var verticalAnchor = getTickTextVerticalAnchor(entry);
var tickProps = _objectSpread(_objectSpread(_objectSpread({}, axisProps), {}, {
// @ts-expect-error customTickProps is contributing unknown props
textAnchor,
verticalAnchor,
// @ts-expect-error customTickProps is contributing unknown props
stroke: 'none',
// @ts-expect-error customTickProps is contributing unknown props
fill: stroke
}, customTickProps), {}, {
index: i,
payload: entry,
x: lineCoord.x2,
y: lineCoord.y2
});
return /*#__PURE__*/React.createElement(Layer, _extends({
className: clsx('recharts-polar-angle-axis-tick', getTickClassName(tick)),
key: "tick-".concat(entry.coordinate)
}, adaptEventsOfChild(props, entry, i)), tickLine && /*#__PURE__*/React.createElement("line", _extends({
className: "recharts-polar-angle-axis-tick-line"
}, tickLineProps, lineCoord)), /*#__PURE__*/React.createElement(TickItemText, {
tick: tick,
tickProps: tickProps,
value: tickFormatter ? tickFormatter(entry.value, i) : entry.value
}));
});
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-polar-angle-axis-ticks"
}, items);
};
export var PolarAngleAxisWrapper = defaultsAndInputs => {
var {
angleAxisId
} = defaultsAndInputs;
var viewBox = useAppSelector(selectPolarViewBox);
var scale = useAppSelector(state => selectPolarAxisScale(state, 'angleAxis', angleAxisId));
var isPanorama = useIsPanorama();
var ticks = useAppSelector(state => selectPolarAxisTicks(state, 'angleAxis', angleAxisId, isPanorama));
if (viewBox == null || !ticks || !ticks.length || scale == null) {
return null;
}
var props = _objectSpread(_objectSpread(_objectSpread({}, defaultsAndInputs), {}, {
scale
}, viewBox), {}, {
radius: viewBox.outerRadius,
ticks
});
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: clsx('recharts-polar-angle-axis', AXIS_TYPE, props.className)
}, /*#__PURE__*/React.createElement(AxisLine, props), /*#__PURE__*/React.createElement(Ticks, props)));
};
export function PolarAngleAxis(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultPolarAngleAxisProps);
return /*#__PURE__*/React.createElement(SetAngleAxisSettings, {
id: props.angleAxisId,
scale: props.scale,
type: props.type,
dataKey: props.dataKey,
unit: undefined,
name: props.name,
allowDuplicatedCategory: false // Ignoring the prop on purpose because axis calculation behaves as if it was false and Tooltip requires it to be true.
,
allowDataOverflow: false,
reversed: props.reversed,
includeHidden: false,
allowDecimals: props.allowDecimals,
tickCount: props.tickCount
// @ts-expect-error the type does not match. Is RadiusAxis really expecting what it says?
,
ticks: props.ticks,
tick: props.tick,
domain: props.domain
}, /*#__PURE__*/React.createElement(PolarAngleAxisWrapper, props));
}
PolarAngleAxis.displayName = 'PolarAngleAxis';

195
frontend/node_modules/recharts/es6/polar/PolarGrid.js generated vendored Normal file
View File

@@ -0,0 +1,195 @@
var _excluded = ["gridType", "radialLines", "angleAxisId", "radiusAxisId", "cx", "cy", "innerRadius", "outerRadius", "polarAngles", "polarRadius"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { clsx } from 'clsx';
import * as React from 'react';
import { polarToCartesian } from '../util/PolarUtils';
import { useAppSelector } from '../state/hooks';
import { selectPolarGridAngles, selectPolarGridRadii } from '../state/selectors/polarGridSelectors';
import { selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
var getPolygonPath = (radius, cx, cy, polarAngles) => {
var path = '';
polarAngles.forEach((angle, i) => {
var point = polarToCartesian(cx, cy, radius, angle);
if (i) {
path += "L ".concat(point.x, ",").concat(point.y);
} else {
path += "M ".concat(point.x, ",").concat(point.y);
}
});
path += 'Z';
return path;
};
// Draw axis of radial line
var PolarAngles = props => {
var {
cx,
cy,
innerRadius,
outerRadius,
polarAngles,
radialLines
} = props;
if (!polarAngles || !polarAngles.length || !radialLines) {
return null;
}
var polarAnglesProps = _objectSpread({
stroke: '#ccc'
}, svgPropertiesNoEvents(props));
return /*#__PURE__*/React.createElement("g", {
className: "recharts-polar-grid-angle"
}, polarAngles.map(entry => {
var start = polarToCartesian(cx, cy, innerRadius, entry);
var end = polarToCartesian(cx, cy, outerRadius, entry);
return /*#__PURE__*/React.createElement("line", _extends({
key: "line-".concat(entry)
}, polarAnglesProps, {
x1: start.x,
y1: start.y,
x2: end.x,
y2: end.y
}));
}));
};
// Draw concentric circles
var ConcentricCircle = props => {
var {
cx,
cy,
radius
} = props;
var concentricCircleProps = _objectSpread({
stroke: '#ccc',
fill: 'none'
}, svgPropertiesNoEvents(props));
return (
/*#__PURE__*/
// @ts-expect-error wrong SVG element type
React.createElement("circle", _extends({}, concentricCircleProps, {
className: clsx('recharts-polar-grid-concentric-circle', props.className),
cx: cx,
cy: cy,
r: radius
}))
);
};
// Draw concentric polygons
var ConcentricPolygon = props => {
var {
radius
} = props;
var concentricPolygonProps = _objectSpread({
stroke: '#ccc',
fill: 'none'
}, svgPropertiesNoEvents(props));
return /*#__PURE__*/React.createElement("path", _extends({}, concentricPolygonProps, {
className: clsx('recharts-polar-grid-concentric-polygon', props.className),
d: getPolygonPath(radius, props.cx, props.cy, props.polarAngles)
}));
};
// Draw concentric axis
var ConcentricGridPath = props => {
var {
polarRadius,
gridType
} = props;
if (!polarRadius || !polarRadius.length) {
return null;
}
var maxPolarRadius = Math.max(...polarRadius);
var renderBackground = props.fill && props.fill !== 'none';
return /*#__PURE__*/React.createElement("g", {
className: "recharts-polar-grid-concentric"
}, renderBackground && gridType === 'circle' && /*#__PURE__*/React.createElement(ConcentricCircle, _extends({}, props, {
radius: maxPolarRadius
})), renderBackground && gridType !== 'circle' && /*#__PURE__*/React.createElement(ConcentricPolygon, _extends({}, props, {
radius: maxPolarRadius
})), polarRadius.map((entry, i) => {
var key = i;
if (gridType === 'circle') {
return /*#__PURE__*/React.createElement(ConcentricCircle, _extends({
key: key
}, props, {
fill: "none",
radius: entry
}));
}
return /*#__PURE__*/React.createElement(ConcentricPolygon, _extends({
key: key
}, props, {
fill: "none",
radius: entry
}));
}));
};
export var PolarGrid = _ref => {
var _ref2, _polarViewBox$cx, _ref3, _polarViewBox$cy, _ref4, _polarViewBox$innerRa, _ref5, _polarViewBox$outerRa, _inputs$zIndex;
var {
gridType = 'polygon',
radialLines = true,
angleAxisId = 0,
radiusAxisId = 0,
cx: cxFromOutside,
cy: cyFromOutside,
innerRadius: innerRadiusFromOutside,
outerRadius: outerRadiusFromOutside,
polarAngles: polarAnglesInput,
polarRadius: polarRadiusInput
} = _ref,
inputs = _objectWithoutProperties(_ref, _excluded);
var polarViewBox = useAppSelector(selectPolarViewBox);
var polarAnglesFromRedux = useAppSelector(state => selectPolarGridAngles(state, angleAxisId));
var polarRadiiFromRedux = useAppSelector(state => selectPolarGridRadii(state, radiusAxisId));
var polarAngles = Array.isArray(polarAnglesInput) ? polarAnglesInput : polarAnglesFromRedux;
var polarRadius = Array.isArray(polarRadiusInput) ? polarRadiusInput : polarRadiiFromRedux;
if (polarAngles == null || polarRadius == null) {
return null;
}
var props = _objectSpread(_objectSpread({
cx: (_ref2 = (_polarViewBox$cx = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.cx) !== null && _polarViewBox$cx !== void 0 ? _polarViewBox$cx : cxFromOutside) !== null && _ref2 !== void 0 ? _ref2 : 0,
cy: (_ref3 = (_polarViewBox$cy = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.cy) !== null && _polarViewBox$cy !== void 0 ? _polarViewBox$cy : cyFromOutside) !== null && _ref3 !== void 0 ? _ref3 : 0,
innerRadius: (_ref4 = (_polarViewBox$innerRa = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.innerRadius) !== null && _polarViewBox$innerRa !== void 0 ? _polarViewBox$innerRa : innerRadiusFromOutside) !== null && _ref4 !== void 0 ? _ref4 : 0,
outerRadius: (_ref5 = (_polarViewBox$outerRa = polarViewBox === null || polarViewBox === void 0 ? void 0 : polarViewBox.outerRadius) !== null && _polarViewBox$outerRa !== void 0 ? _polarViewBox$outerRa : outerRadiusFromOutside) !== null && _ref5 !== void 0 ? _ref5 : 0,
polarAngles,
polarRadius
}, inputs), {}, {
zIndex: (_inputs$zIndex = inputs.zIndex) !== null && _inputs$zIndex !== void 0 ? _inputs$zIndex : DefaultZIndexes.grid
});
var {
outerRadius
} = props;
if (outerRadius <= 0) {
return null;
}
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement("g", {
className: "recharts-polar-grid"
}, /*#__PURE__*/React.createElement(ConcentricGridPath, _extends({
gridType: gridType,
radialLines: radialLines
}, props, {
polarAngles: polarAngles,
polarRadius: polarRadius
})), /*#__PURE__*/React.createElement(PolarAngles, _extends({
gridType: gridType,
radialLines: radialLines
}, props, {
polarAngles: polarAngles,
polarRadius: polarRadius
}))));
};
PolarGrid.displayName = 'PolarGrid';

View File

@@ -0,0 +1,203 @@
var _excluded = ["cx", "cy", "angle", "axisLine"],
_excluded2 = ["angle", "tickFormatter", "stroke", "tick"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { useEffect } from 'react';
import maxBy from 'es-toolkit/compat/maxBy';
import minBy from 'es-toolkit/compat/minBy';
import { clsx } from 'clsx';
import { Text } from '../component/Text';
import { PolarLabelContextProvider, PolarLabelFromLabelProp } from '../component/Label';
import { Layer } from '../container/Layer';
import { getTickClassName, polarToCartesian } from '../util/PolarUtils';
import { adaptEventsOfChild } from '../util/types';
import { addRadiusAxis, removeRadiusAxis } from '../state/polarAxisSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { selectPolarAxisScale, selectPolarAxisTicks } from '../state/selectors/polarScaleSelectors';
import { selectPolarViewBox } from '../state/selectors/polarAxisSelectors';
import { defaultPolarRadiusAxisProps } from './defaultPolarRadiusAxisProps';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
var AXIS_TYPE = 'radiusAxis';
function SetRadiusAxisSettings(settings) {
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(addRadiusAxis(settings));
return () => {
dispatch(removeRadiusAxis(settings));
};
});
return null;
}
/**
* Calculate the coordinate of tick
* @param coordinate The radius of tick
* @param angle from props
* @param cx from chart
* @param cy from chart
* @return (x, y)
*/
var getTickValueCoord = (_ref, angle, cx, cy) => {
var {
coordinate
} = _ref;
return polarToCartesian(cx, cy, coordinate, angle);
};
var getTickTextAnchor = orientation => {
var textAnchor;
switch (orientation) {
case 'left':
textAnchor = 'end';
break;
case 'right':
textAnchor = 'start';
break;
default:
textAnchor = 'middle';
break;
}
return textAnchor;
};
var getViewBox = (angle, cx, cy, ticks) => {
var maxRadiusTick = maxBy(ticks, entry => entry.coordinate || 0);
var minRadiusTick = minBy(ticks, entry => entry.coordinate || 0);
return {
cx,
cy,
startAngle: angle,
endAngle: angle,
innerRadius: (minRadiusTick === null || minRadiusTick === void 0 ? void 0 : minRadiusTick.coordinate) || 0,
outerRadius: (maxRadiusTick === null || maxRadiusTick === void 0 ? void 0 : maxRadiusTick.coordinate) || 0,
clockWise: false
};
};
var renderAxisLine = (props, ticks) => {
var {
cx,
cy,
angle,
axisLine
} = props,
others = _objectWithoutProperties(props, _excluded);
var extent = ticks.reduce((result, entry) => [Math.min(result[0], entry.coordinate), Math.max(result[1], entry.coordinate)], [Infinity, -Infinity]);
var point0 = polarToCartesian(cx, cy, extent[0], angle);
var point1 = polarToCartesian(cx, cy, extent[1], angle);
var axisLineProps = _objectSpread(_objectSpread(_objectSpread({}, svgPropertiesNoEvents(others)), {}, {
fill: 'none'
}, svgPropertiesNoEvents(axisLine)), {}, {
x1: point0.x,
y1: point0.y,
x2: point1.x,
y2: point1.y
});
// @ts-expect-error wrong SVG element type
return /*#__PURE__*/React.createElement("line", _extends({
className: "recharts-polar-radius-axis-line"
}, axisLineProps));
};
var renderTickItem = (option, tickProps, value) => {
var tickItem;
if (/*#__PURE__*/React.isValidElement(option)) {
tickItem = /*#__PURE__*/React.cloneElement(option, tickProps);
} else if (typeof option === 'function') {
tickItem = option(tickProps);
} else {
tickItem = /*#__PURE__*/React.createElement(Text, _extends({}, tickProps, {
className: "recharts-polar-radius-axis-tick-value"
}), value);
}
return tickItem;
};
var renderTicks = (props, ticks) => {
var {
angle,
tickFormatter,
stroke,
tick
} = props,
others = _objectWithoutProperties(props, _excluded2);
var textAnchor = getTickTextAnchor(props.orientation);
var axisProps = svgPropertiesNoEvents(others);
var customTickProps = svgPropertiesNoEventsFromUnknown(tick);
var items = ticks.map((entry, i) => {
var coord = getTickValueCoord(entry, props.angle, props.cx, props.cy);
var tickProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
textAnchor,
transform: "rotate(".concat(90 - angle, ", ").concat(coord.x, ", ").concat(coord.y, ")")
}, axisProps), {}, {
stroke: 'none',
fill: stroke
}, customTickProps), {}, {
index: i
}, coord), {}, {
payload: entry
});
return /*#__PURE__*/React.createElement(Layer, _extends({
className: clsx('recharts-polar-radius-axis-tick', getTickClassName(tick)),
key: "tick-".concat(entry.coordinate)
}, adaptEventsOfChild(props, entry, i)), renderTickItem(tick, tickProps, tickFormatter ? tickFormatter(entry.value, i) : entry.value));
});
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-polar-radius-axis-ticks"
}, items);
};
export var PolarRadiusAxisWrapper = defaultsAndInputs => {
var {
radiusAxisId
} = defaultsAndInputs;
var viewBox = useAppSelector(selectPolarViewBox);
var scale = useAppSelector(state => selectPolarAxisScale(state, 'radiusAxis', radiusAxisId));
var ticks = useAppSelector(state => selectPolarAxisTicks(state, 'radiusAxis', radiusAxisId, false));
if (viewBox == null || !ticks || !ticks.length || scale == null) {
return null;
}
var props = _objectSpread(_objectSpread(_objectSpread({}, defaultsAndInputs), {}, {
scale
}, viewBox), {}, {
radius: viewBox.outerRadius
});
var {
tick,
axisLine
} = props;
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: clsx('recharts-polar-radius-axis', AXIS_TYPE, props.className)
}, axisLine && renderAxisLine(props, ticks), tick && renderTicks(props, ticks), /*#__PURE__*/React.createElement(PolarLabelContextProvider, getViewBox(props.angle, props.cx, props.cy, ticks), /*#__PURE__*/React.createElement(PolarLabelFromLabelProp, {
label: props.label
}), props.children)));
};
export function PolarRadiusAxis(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultPolarRadiusAxisProps);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetRadiusAxisSettings, {
domain: props.domain,
id: props.radiusAxisId,
scale: props.scale,
type: props.type,
dataKey: props.dataKey,
unit: undefined,
name: props.name,
allowDuplicatedCategory: props.allowDuplicatedCategory,
allowDataOverflow: props.allowDataOverflow,
reversed: props.reversed,
includeHidden: props.includeHidden,
allowDecimals: props.allowDecimals
// @ts-expect-error the type does not match. Is RadiusAxis really expecting what it says?
,
ticks: props.ticks,
tickCount: props.tickCount,
tick: props.tick
}), /*#__PURE__*/React.createElement(PolarRadiusAxisWrapper, props));
}
PolarRadiusAxis.displayName = 'PolarRadiusAxis';

432
frontend/node_modules/recharts/es6/polar/Radar.js generated vendored Normal file
View File

@@ -0,0 +1,432 @@
var _excluded = ["id"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { useCallback, useRef, useState } from 'react';
import last from 'es-toolkit/compat/last';
import { clsx } from 'clsx';
import { interpolate, isNullish } from '../util/DataUtils';
import { Global } from '../util/Global';
import { polarToCartesian } from '../util/PolarUtils';
import { getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
import { Polygon } from '../shape/Polygon';
import { Layer } from '../container/Layer';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { Dots } from '../component/Dots';
import { ActivePoints } from '../component/ActivePoints';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { selectRadarPoints } from '../state/selectors/radarSelectors';
import { useAppSelector } from '../state/hooks';
import { useIsPanorama } from '../context/PanoramaContext';
import { SetPolarLegendPayload } from '../state/SetLegendPayload';
import { useAnimationId } from '../util/useAnimationId';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetPolarGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
function getLegendItemColor(stroke, fill) {
return stroke && stroke !== 'none' ? stroke : fill;
}
var computeLegendPayloadFromRadarSectors = props => {
var {
dataKey,
name,
stroke,
fill,
legendType,
hide
} = props;
return [{
inactive: hide,
dataKey,
type: legendType,
color: getLegendItemColor(stroke, fill),
value: getTooltipNameProp(name, dataKey),
payload: props
}];
};
function getTooltipEntrySettings(props) {
var {
dataKey,
stroke,
strokeWidth,
fill,
name,
hide,
tooltipType
} = props;
return {
/*
* I suppose this here _could_ return props.points
* because while Radar does not support item tooltip mode, it _could_ support it.
* But when I actually do return the points here, a defaultIndex test starts failing.
* So, undefined it is.
*/
dataDefinedOnItem: undefined,
positions: undefined,
settings: {
stroke,
strokeWidth,
fill,
nameKey: undefined,
// RadarChart does not have nameKey unfortunately
dataKey,
name: getTooltipNameProp(name, dataKey),
hide,
type: tooltipType,
color: getLegendItemColor(stroke, fill),
unit: '' // why doesn't Radar support unit?
}
};
}
function RadarDotsWrapper(_ref) {
var {
points,
props
} = _ref;
var {
dot,
dataKey
} = props;
var {
id
} = props,
propsWithoutId = _objectWithoutProperties(props, _excluded);
var baseProps = svgPropertiesNoEvents(propsWithoutId);
return /*#__PURE__*/React.createElement(Dots, {
points: points,
dot: dot,
className: "recharts-radar-dots",
dotClassName: "recharts-radar-dot",
dataKey: dataKey,
baseProps: baseProps
});
}
export function computeRadarPoints(_ref2) {
var {
radiusAxis,
angleAxis,
displayedData,
dataKey,
bandSize
} = _ref2;
var {
cx,
cy
} = angleAxis;
var isRange = false;
var points = [];
var angleBandSize = angleAxis.type !== 'number' ? bandSize !== null && bandSize !== void 0 ? bandSize : 0 : 0;
displayedData.forEach((entry, i) => {
var name = getValueByDataKey(entry, angleAxis.dataKey, i);
var value = getValueByDataKey(entry, dataKey);
var angle = angleAxis.scale(name) + angleBandSize;
var pointValue = Array.isArray(value) ? last(value) : value;
var radius = isNullish(pointValue) ? 0 : radiusAxis.scale(pointValue);
if (Array.isArray(value) && value.length >= 2) {
isRange = true;
}
points.push(_objectSpread(_objectSpread({}, polarToCartesian(cx, cy, radius, angle)), {}, {
// @ts-expect-error getValueByDataKey does not validate the output type
name,
// @ts-expect-error getValueByDataKey does not validate the output type
value,
cx,
cy,
radius,
angle,
payload: entry
}));
});
var baseLinePoints = [];
if (isRange) {
points.forEach(point => {
if (Array.isArray(point.value)) {
var baseValue = point.value[0];
var radius = isNullish(baseValue) ? 0 : radiusAxis.scale(baseValue);
baseLinePoints.push(_objectSpread(_objectSpread({}, point), {}, {
radius
}, polarToCartesian(cx, cy, radius, point.angle)));
} else {
baseLinePoints.push(point);
}
});
}
return {
points,
isRange,
baseLinePoints
};
}
function RadarLabelListProvider(_ref3) {
var {
showLabels,
points,
children
} = _ref3;
/*
* Radar provides a Cartesian label list context. Do we want to also provide a polar label list context?
* That way, users can choose to use polar positions for the Radar labels.
*/
// const labelListEntries: ReadonlyArray<PolarLabelListEntry> = points.map(
// (point): PolarLabelListEntry => ({
// value: point.value,
// payload: point.payload,
// parentViewBox: undefined,
// clockWise: false,
// viewBox: {
// cx: point.cx,
// cy: point.cy,
// innerRadius: point.radius,
// outerRadius: point.radius,
// startAngle: point.angle,
// endAngle: point.angle,
// clockWise: false,
// },
// }),
// );
var labelListEntries = points.map(point => {
var _point$value;
var viewBox = {
x: point.x,
y: point.y,
width: 0,
lowerWidth: 0,
upperWidth: 0,
height: 0
};
return _objectSpread(_objectSpread({}, viewBox), {}, {
value: (_point$value = point.value) !== null && _point$value !== void 0 ? _point$value : '',
payload: point.payload,
parentViewBox: undefined,
viewBox,
fill: undefined
});
});
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function StaticPolygon(_ref4) {
var {
points,
baseLinePoints,
props
} = _ref4;
if (points == null) {
return null;
}
var {
shape,
isRange,
connectNulls
} = props;
var handleMouseEnter = e => {
var {
onMouseEnter
} = props;
if (onMouseEnter) {
onMouseEnter(props, e);
}
};
var handleMouseLeave = e => {
var {
onMouseLeave
} = props;
if (onMouseLeave) {
onMouseLeave(props, e);
}
};
var radar;
if (/*#__PURE__*/React.isValidElement(shape)) {
radar = /*#__PURE__*/React.cloneElement(shape, _objectSpread(_objectSpread({}, props), {}, {
points
}));
} else if (typeof shape === 'function') {
radar = shape(_objectSpread(_objectSpread({}, props), {}, {
points
}));
} else {
radar = /*#__PURE__*/React.createElement(Polygon, _extends({}, svgPropertiesAndEvents(props), {
onMouseEnter: handleMouseEnter,
onMouseLeave: handleMouseLeave,
points: points,
baseLinePoints: isRange ? baseLinePoints : undefined,
connectNulls: connectNulls
}));
}
return /*#__PURE__*/React.createElement(Layer, {
className: "recharts-radar-polygon"
}, radar, /*#__PURE__*/React.createElement(RadarDotsWrapper, {
props: props,
points: points
}));
}
var interpolatePolarPoint = (prevPoints, prevPointsDiffFactor, t) => (entry, index) => {
var prev = prevPoints && prevPoints[Math.floor(index * prevPointsDiffFactor)];
if (prev) {
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(prev.x, entry.x, t),
y: interpolate(prev.y, entry.y, t)
});
}
return _objectSpread(_objectSpread({}, entry), {}, {
x: interpolate(entry.cx, entry.x, t),
y: interpolate(entry.cy, entry.y, t)
});
};
function PolygonWithAnimation(_ref5) {
var {
props,
previousPointsRef,
previousBaseLinePointsRef
} = _ref5;
var {
points,
baseLinePoints,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
onAnimationEnd,
onAnimationStart
} = props;
var prevPoints = previousPointsRef.current;
var prevBaseLinePoints = previousBaseLinePointsRef.current;
var prevPointsDiffFactor = prevPoints ? prevPoints.length / points.length : 1;
var prevBaseLinePointsDiffFactor = prevBaseLinePoints ? prevBaseLinePoints.length / baseLinePoints.length : 1;
var animationId = useAnimationId(props, 'recharts-radar-');
var [isAnimating, setIsAnimating] = useState(false);
var showLabels = !isAnimating;
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
return /*#__PURE__*/React.createElement(RadarLabelListProvider, {
showLabels: showLabels,
points: points
}, /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
key: "radar-".concat(animationId),
onAnimationEnd: handleAnimationEnd,
onAnimationStart: handleAnimationStart
}, t => {
var stepData = t === 1 ? points : points.map(interpolatePolarPoint(prevPoints, prevPointsDiffFactor, t));
var stepBaseLinePoints = t === 1 ? baseLinePoints : baseLinePoints === null || baseLinePoints === void 0 ? void 0 : baseLinePoints.map(interpolatePolarPoint(prevBaseLinePoints, prevBaseLinePointsDiffFactor, t));
if (t > 0) {
// eslint-disable-next-line no-param-reassign
previousPointsRef.current = stepData;
// eslint-disable-next-line no-param-reassign
previousBaseLinePointsRef.current = stepBaseLinePoints;
}
return /*#__PURE__*/React.createElement(StaticPolygon, {
points: stepData,
baseLinePoints: stepBaseLinePoints,
props: props
});
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}), props.children);
}
function RenderPolygon(props) {
var previousPointsRef = useRef(undefined);
var previousBaseLinePointsRef = useRef(undefined);
return /*#__PURE__*/React.createElement(PolygonWithAnimation, {
props: props,
previousPointsRef: previousPointsRef,
previousBaseLinePointsRef: previousBaseLinePointsRef
});
}
var defaultRadarProps = {
angleAxisId: 0,
radiusAxisId: 0,
hide: false,
activeDot: true,
dot: false,
legendType: 'rect',
isAnimationActive: !Global.isSsr,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease',
zIndex: DefaultZIndexes.area
};
function RadarWithState(props) {
var {
hide,
className,
points
} = props;
if (hide) {
return null;
}
var layerClass = clsx('recharts-radar', className);
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, /*#__PURE__*/React.createElement(RenderPolygon, props)), /*#__PURE__*/React.createElement(ActivePoints, {
points: points,
mainColor: getLegendItemColor(props.stroke, props.fill),
itemDataKey: props.dataKey,
activeDot: props.activeDot
}));
}
function RadarImpl(props) {
var isPanorama = useIsPanorama();
var radarPoints = useAppSelector(state => selectRadarPoints(state, props.radiusAxisId, props.angleAxisId, isPanorama, props.id));
if ((radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.points) == null) {
return null;
}
return /*#__PURE__*/React.createElement(RadarWithState, _extends({}, props, {
points: radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.points,
baseLinePoints: radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.baseLinePoints,
isRange: radarPoints === null || radarPoints === void 0 ? void 0 : radarPoints.isRange
}));
}
export function Radar(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultRadarProps);
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "radar"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetPolarGraphicalItem, {
type: "radar",
id: id,
data: undefined // Radar does not have data prop, why?
,
dataKey: props.dataKey,
hide: props.hide,
angleAxisId: props.angleAxisId,
radiusAxisId: props.radiusAxisId
}), /*#__PURE__*/React.createElement(SetPolarLegendPayload, {
legendPayload: computeLegendPayloadFromRadarSectors(props)
}), /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: props
}), /*#__PURE__*/React.createElement(RadarImpl, _extends({}, props, {
id: id
}))));
}
Radar.displayName = 'Radar';

454
frontend/node_modules/recharts/es6/polar/RadialBar.js generated vendored Normal file
View File

@@ -0,0 +1,454 @@
var _excluded = ["shape", "activeShape", "cornerRadius", "id"],
_excluded2 = ["onMouseEnter", "onClick", "onMouseLeave"],
_excluded3 = ["value", "background"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { PureComponent, useCallback, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { parseCornerRadius, RadialBarSector } from '../util/RadialBarUtils';
import { Layer } from '../container/Layer';
import { findAllByType } from '../util/ReactUtils';
import { Global } from '../util/Global';
import { LabelListFromLabelProp, PolarLabelListContextProvider } from '../component/LabelList';
import { Cell } from '../component/Cell';
import { interpolate, mathSign } from '../util/DataUtils';
import { getCateCoordinateOfBar, getNormalizedStackId, getTooltipNameProp, getValueByDataKey, truncateByDomain } from '../util/ChartUtils';
import { adaptEventsOfChild } from '../util/types';
import { useMouseClickItemDispatch, useMouseEnterItemDispatch, useMouseLeaveItemDispatch } from '../context/tooltipContext';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { selectRadialBarLegendPayload, selectRadialBarSectors } from '../state/selectors/radialBarSelectors';
import { useAppSelector } from '../state/hooks';
import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
import { SetPolarLegendPayload } from '../state/SetLegendPayload';
import { useAnimationId } from '../util/useAnimationId';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetPolarGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents, svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
import { getZIndexFromUnknown } from '../zIndex/getZIndexFromUnknown';
var STABLE_EMPTY_ARRAY = [];
function RadialBarLabelListProvider(_ref) {
var {
showLabels,
sectors,
children
} = _ref;
var labelListEntries = sectors.map(sector => ({
value: sector.value,
payload: sector.payload,
parentViewBox: undefined,
clockWise: false,
viewBox: {
cx: sector.cx,
cy: sector.cy,
innerRadius: sector.innerRadius,
outerRadius: sector.outerRadius,
startAngle: sector.startAngle,
endAngle: sector.endAngle,
clockWise: false
},
fill: sector.fill
}));
return /*#__PURE__*/React.createElement(PolarLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function RadialBarSectors(_ref2) {
var {
sectors,
allOtherRadialBarProps,
showLabels
} = _ref2;
var {
shape,
activeShape,
cornerRadius,
id
} = allOtherRadialBarProps,
others = _objectWithoutProperties(allOtherRadialBarProps, _excluded);
var baseProps = svgPropertiesNoEvents(others);
var activeIndex = useAppSelector(selectActiveTooltipIndex);
var {
onMouseEnter: onMouseEnterFromProps,
onClick: onItemClickFromProps,
onMouseLeave: onMouseLeaveFromProps
} = allOtherRadialBarProps,
restOfAllOtherProps = _objectWithoutProperties(allOtherRadialBarProps, _excluded2);
var onMouseEnterFromContext = useMouseEnterItemDispatch(onMouseEnterFromProps, allOtherRadialBarProps.dataKey);
var onMouseLeaveFromContext = useMouseLeaveItemDispatch(onMouseLeaveFromProps);
var onClickFromContext = useMouseClickItemDispatch(onItemClickFromProps, allOtherRadialBarProps.dataKey);
if (sectors == null) {
return null;
}
return /*#__PURE__*/React.createElement(RadialBarLabelListProvider, {
showLabels: showLabels,
sectors: sectors
}, sectors.map((entry, i) => {
var isActive = activeShape && activeIndex === String(i);
// @ts-expect-error the types need a bit of attention
var onMouseEnter = onMouseEnterFromContext(entry, i);
// @ts-expect-error the types need a bit of attention
var onMouseLeave = onMouseLeaveFromContext(entry, i);
// @ts-expect-error the types need a bit of attention
var onClick = onClickFromContext(entry, i);
var radialBarSectorProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, baseProps), {}, {
cornerRadius: parseCornerRadius(cornerRadius)
}, entry), adaptEventsOfChild(restOfAllOtherProps, entry, i)), {}, {
onMouseEnter,
onMouseLeave,
onClick,
className: "recharts-radial-bar-sector ".concat(entry.className),
forceCornerRadius: others.forceCornerRadius,
cornerIsExternal: others.cornerIsExternal,
isActive,
option: isActive ? activeShape : shape
});
if (isActive) {
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: DefaultZIndexes.activeBar,
key: "sector-".concat(entry.cx, "-").concat(entry.cy, "-").concat(entry.innerRadius, "-").concat(entry.outerRadius, "-").concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(i)
}, /*#__PURE__*/React.createElement(RadialBarSector, radialBarSectorProps));
}
return /*#__PURE__*/React.createElement(RadialBarSector, _extends({
key: "sector-".concat(entry.cx, "-").concat(entry.cy, "-").concat(entry.innerRadius, "-").concat(entry.outerRadius, "-").concat(entry.startAngle, "-").concat(entry.endAngle, "-").concat(i)
}, radialBarSectorProps));
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: allOtherRadialBarProps.label
}), allOtherRadialBarProps.children);
}
function SectorsWithAnimation(_ref3) {
var {
props,
previousSectorsRef
} = _ref3;
var {
data,
isAnimationActive,
animationBegin,
animationDuration,
animationEasing,
onAnimationEnd,
onAnimationStart
} = props;
var animationId = useAnimationId(props, 'recharts-radialbar-');
var prevData = previousSectorsRef.current;
var [isAnimating, setIsAnimating] = useState(false);
var handleAnimationEnd = useCallback(() => {
if (typeof onAnimationEnd === 'function') {
onAnimationEnd();
}
setIsAnimating(false);
}, [onAnimationEnd]);
var handleAnimationStart = useCallback(() => {
if (typeof onAnimationStart === 'function') {
onAnimationStart();
}
setIsAnimating(true);
}, [onAnimationStart]);
return /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
begin: animationBegin,
duration: animationDuration,
isActive: isAnimationActive,
easing: animationEasing,
onAnimationStart: handleAnimationStart,
onAnimationEnd: handleAnimationEnd,
key: animationId
}, t => {
var stepData = t === 1 ? data : (data !== null && data !== void 0 ? data : STABLE_EMPTY_ARRAY).map((entry, index) => {
var prev = prevData && prevData[index];
if (prev) {
return _objectSpread(_objectSpread({}, entry), {}, {
startAngle: interpolate(prev.startAngle, entry.startAngle, t),
endAngle: interpolate(prev.endAngle, entry.endAngle, t)
});
}
var {
endAngle,
startAngle
} = entry;
return _objectSpread(_objectSpread({}, entry), {}, {
endAngle: interpolate(startAngle, endAngle, t)
});
});
if (t > 0) {
// eslint-disable-next-line no-param-reassign
previousSectorsRef.current = stepData !== null && stepData !== void 0 ? stepData : null;
}
return /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement(RadialBarSectors, {
sectors: stepData !== null && stepData !== void 0 ? stepData : STABLE_EMPTY_ARRAY,
allOtherRadialBarProps: props,
showLabels: !isAnimating
}));
});
}
function RenderSectors(props) {
var previousSectorsRef = useRef(null);
return /*#__PURE__*/React.createElement(SectorsWithAnimation, {
props: props,
previousSectorsRef: previousSectorsRef
});
}
function SetRadialBarPayloadLegend(props) {
var legendPayload = useAppSelector(state => selectRadialBarLegendPayload(state, props.legendType));
return /*#__PURE__*/React.createElement(SetPolarLegendPayload, {
legendPayload: legendPayload !== null && legendPayload !== void 0 ? legendPayload : []
});
}
function getTooltipEntrySettings(props) {
var {
dataKey,
data,
stroke,
strokeWidth,
name,
hide,
fill,
tooltipType
} = props;
return {
dataDefinedOnItem: data,
positions: undefined,
settings: {
stroke,
strokeWidth,
fill,
nameKey: undefined,
// RadialBar does not have nameKey, why?
dataKey,
name: getTooltipNameProp(name, dataKey),
hide,
type: tooltipType,
color: fill,
unit: '' // Why does RadialBar not support unit?
}
};
}
class RadialBarWithState extends PureComponent {
renderBackground(sectors) {
if (sectors == null) {
return null;
}
var {
cornerRadius
} = this.props;
var backgroundProps = svgPropertiesNoEventsFromUnknown(this.props.background);
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: getZIndexFromUnknown(this.props.background, DefaultZIndexes.barBackground)
}, sectors.map((entry, i) => {
var {
value,
background
} = entry,
rest = _objectWithoutProperties(entry, _excluded3);
if (!background) {
return null;
}
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
cornerRadius: parseCornerRadius(cornerRadius)
}, rest), {}, {
// @ts-expect-error backgroundProps is contributing unknown props
fill: '#eee'
}, background), backgroundProps), adaptEventsOfChild(this.props, entry, i)), {}, {
index: i,
className: clsx('recharts-radial-bar-background-sector', String(backgroundProps === null || backgroundProps === void 0 ? void 0 : backgroundProps.className)),
option: background,
isActive: false
});
return /*#__PURE__*/React.createElement(RadialBarSector, _extends({
key: "background-".concat(rest.cx, "-").concat(rest.cy, "-").concat(rest.innerRadius, "-").concat(rest.outerRadius, "-").concat(rest.startAngle, "-").concat(rest.endAngle, "-").concat(i)
}, props));
}));
}
render() {
var {
hide,
data,
className,
background
} = this.props;
if (hide) {
return null;
}
var layerClass = clsx('recharts-area', className);
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: this.props.zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, background && /*#__PURE__*/React.createElement(Layer, {
className: "recharts-radial-bar-background"
}, this.renderBackground(data)), /*#__PURE__*/React.createElement(Layer, {
className: "recharts-radial-bar-sectors"
}, /*#__PURE__*/React.createElement(RenderSectors, this.props))));
}
}
function RadialBarImpl(props) {
var _useAppSelector;
var cells = findAllByType(props.children, Cell);
var radialBarSettings = {
data: undefined,
hide: false,
id: props.id,
dataKey: props.dataKey,
minPointSize: props.minPointSize,
stackId: getNormalizedStackId(props.stackId),
maxBarSize: props.maxBarSize,
barSize: props.barSize,
type: 'radialBar',
angleAxisId: props.angleAxisId,
radiusAxisId: props.radiusAxisId
};
var data = (_useAppSelector = useAppSelector(state => selectRadialBarSectors(state, props.radiusAxisId, props.angleAxisId, radialBarSettings, cells))) !== null && _useAppSelector !== void 0 ? _useAppSelector : STABLE_EMPTY_ARRAY;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
fn: getTooltipEntrySettings,
args: _objectSpread(_objectSpread({}, props), {}, {
data
})
}), /*#__PURE__*/React.createElement(RadialBarWithState, _extends({}, props, {
data: data
})));
}
var defaultRadialBarProps = {
angleAxisId: 0,
radiusAxisId: 0,
minPointSize: 0,
hide: false,
legendType: 'rect',
data: [],
isAnimationActive: !Global.isSsr,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease',
forceCornerRadius: false,
cornerIsExternal: false,
zIndex: DefaultZIndexes.bar
};
export function computeRadialBarDataItems(_ref4) {
var {
displayedData,
stackedData,
dataStartIndex,
stackedDomain,
dataKey,
baseValue,
layout,
radiusAxis,
radiusAxisTicks,
bandSize,
pos,
angleAxis,
minPointSize,
cx,
cy,
angleAxisTicks,
cells,
startAngle: rootStartAngle,
endAngle: rootEndAngle
} = _ref4;
if (angleAxisTicks == null || radiusAxisTicks == null) {
return STABLE_EMPTY_ARRAY;
}
return (displayedData !== null && displayedData !== void 0 ? displayedData : []).map((entry, index) => {
var value, innerRadius, outerRadius, startAngle, endAngle, backgroundSector;
if (stackedData) {
// @ts-expect-error truncateByDomain expects only numerical domain, but it can received categorical domain too
value = truncateByDomain(stackedData[dataStartIndex + index], stackedDomain);
} else {
value = getValueByDataKey(entry, dataKey);
if (!Array.isArray(value)) {
value = [baseValue, value];
}
}
if (layout === 'radial') {
innerRadius = getCateCoordinateOfBar({
axis: radiusAxis,
ticks: radiusAxisTicks,
bandSize,
offset: pos.offset,
entry,
index
});
endAngle = angleAxis.scale(value[1]);
startAngle = angleAxis.scale(value[0]);
outerRadius = (innerRadius !== null && innerRadius !== void 0 ? innerRadius : 0) + pos.size;
var deltaAngle = endAngle - startAngle;
if (Math.abs(minPointSize) > 0 && Math.abs(deltaAngle) < Math.abs(minPointSize)) {
var delta = mathSign(deltaAngle || minPointSize) * (Math.abs(minPointSize) - Math.abs(deltaAngle));
endAngle += delta;
}
backgroundSector = {
background: {
cx,
cy,
innerRadius,
outerRadius,
startAngle: rootStartAngle,
endAngle: rootEndAngle
}
};
} else {
innerRadius = radiusAxis.scale(value[0]);
outerRadius = radiusAxis.scale(value[1]);
startAngle = getCateCoordinateOfBar({
axis: angleAxis,
ticks: angleAxisTicks,
bandSize,
offset: pos.offset,
entry,
index
});
endAngle = (startAngle !== null && startAngle !== void 0 ? startAngle : 0) + pos.size;
var deltaRadius = outerRadius - innerRadius;
if (Math.abs(minPointSize) > 0 && Math.abs(deltaRadius) < Math.abs(minPointSize)) {
var _delta = mathSign(deltaRadius || minPointSize) * (Math.abs(minPointSize) - Math.abs(deltaRadius));
outerRadius += _delta;
}
}
return _objectSpread(_objectSpread(_objectSpread({}, entry), backgroundSector), {}, {
payload: entry,
value: stackedData ? value : value[1],
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle
}, cells && cells[index] && cells[index].props);
});
}
export function RadialBar(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultRadialBarProps);
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "radialBar"
}, id => {
var _props$hide, _props$angleAxisId, _props$radiusAxisId;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetPolarGraphicalItem, {
type: "radialBar",
id: id,
data: undefined // why does RadialBar not allow data defined on the item?
,
dataKey: props.dataKey,
hide: (_props$hide = props.hide) !== null && _props$hide !== void 0 ? _props$hide : defaultRadialBarProps.hide,
angleAxisId: (_props$angleAxisId = props.angleAxisId) !== null && _props$angleAxisId !== void 0 ? _props$angleAxisId : defaultRadialBarProps.angleAxisId,
radiusAxisId: (_props$radiusAxisId = props.radiusAxisId) !== null && _props$radiusAxisId !== void 0 ? _props$radiusAxisId : defaultRadialBarProps.radiusAxisId,
stackId: getNormalizedStackId(props.stackId),
barSize: props.barSize,
minPointSize: props.minPointSize,
maxBarSize: props.maxBarSize
}), /*#__PURE__*/React.createElement(SetRadialBarPayloadLegend, props), /*#__PURE__*/React.createElement(RadialBarImpl, _extends({}, props, {
id: id
})));
});
}
RadialBar.displayName = 'RadialBar';

View File

@@ -0,0 +1,18 @@
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
export var defaultPolarAngleAxisProps = {
allowDecimals: false,
allowDuplicatedCategory: true,
// if I set this to false then Tooltip synchronisation stops working in Radar, wtf
angleAxisId: 0,
axisLine: true,
cx: 0,
cy: 0,
orientation: 'outer',
reversed: false,
scale: 'auto',
tick: true,
tickLine: true,
tickSize: 8,
type: 'category',
zIndex: DefaultZIndexes.axis
};

View File

@@ -0,0 +1,20 @@
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
export var defaultPolarRadiusAxisProps = {
allowDataOverflow: false,
allowDecimals: false,
allowDuplicatedCategory: true,
angle: 0,
axisLine: true,
cx: 0,
cy: 0,
includeHidden: false,
orientation: 'right',
radiusAxisId: 0,
reversed: false,
scale: 'auto',
stroke: '#ccc',
tick: true,
tickCount: 5,
type: 'number',
zIndex: DefaultZIndexes.axis
};

46
frontend/node_modules/recharts/es6/shape/Cross.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var _excluded = ["x", "y", "top", "left", "width", "height", "className"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Cross
*/
import * as React from 'react';
import { clsx } from 'clsx';
import { isNumber } from '../util/DataUtils';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
var getPath = (x, y, width, height, top, left) => {
return "M".concat(x, ",").concat(top, "v").concat(height, "M").concat(left, ",").concat(y, "h").concat(width);
};
export var Cross = _ref => {
var {
x = 0,
y = 0,
top = 0,
left = 0,
width = 0,
height = 0,
className
} = _ref,
rest = _objectWithoutProperties(_ref, _excluded);
var props = _objectSpread({
x,
y,
top,
left,
width,
height
}, rest);
if (!isNumber(x) || !isNumber(y) || !isNumber(width) || !isNumber(height) || !isNumber(top) || !isNumber(left)) {
return null;
}
return /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(props), {
className: clsx('recharts-cross', className),
d: getPath(x, y, width, height, top, left)
}));
};

114
frontend/node_modules/recharts/es6/shape/Curve.js generated vendored Normal file
View File

@@ -0,0 +1,114 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* @fileOverview Curve
*/
import * as React from 'react';
import { line as shapeLine, area as shapeArea, curveBasisClosed, curveBasisOpen, curveBasis, curveBumpX, curveBumpY, curveLinearClosed, curveLinear, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore } from 'victory-vendor/d3-shape';
import { clsx } from 'clsx';
import { adaptEventHandlers } from '../util/types';
import { isNumber, upperFirst } from '../util/DataUtils';
import { isWellBehavedNumber } from '../util/isWellBehavedNumber';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
var CURVE_FACTORIES = {
curveBasisClosed,
curveBasisOpen,
curveBasis,
curveBumpX,
curveBumpY,
curveLinearClosed,
curveLinear,
curveMonotoneX,
curveMonotoneY,
curveNatural,
curveStep,
curveStepAfter,
curveStepBefore
};
var defined = p => isWellBehavedNumber(p.x) && isWellBehavedNumber(p.y);
var areaDefined = d => d.base != null && defined(d.base) && defined(d);
var getX = p => p.x;
var getY = p => p.y;
var getCurveFactory = (type, layout) => {
if (typeof type === 'function') {
return type;
}
var name = "curve".concat(upperFirst(type));
if ((name === 'curveMonotone' || name === 'curveBump') && layout) {
return CURVE_FACTORIES["".concat(name).concat(layout === 'vertical' ? 'Y' : 'X')];
}
return CURVE_FACTORIES[name] || curveLinear;
};
/**
* Calculate the path of curve. Returns null if points is an empty array.
* @return path or null
*/
export var getPath = _ref => {
var {
type = 'linear',
points = [],
baseLine,
layout,
connectNulls = false
} = _ref;
var curveFactory = getCurveFactory(type, layout);
var formatPoints = connectNulls ? points.filter(defined) : points;
var lineFunction;
// When dealing with an area chart (where `baseLine` is an array),
// we need to pair points with their corresponding `baseLine` points first.
// This is to ensure that we filter points and their baseline counterparts together,
// preventing errors from mismatched array lengths and ensuring `defined` checks both.
if (Array.isArray(baseLine)) {
var areaPoints = points.map((entry, index) => _objectSpread(_objectSpread({}, entry), {}, {
base: baseLine[index]
}));
if (layout === 'vertical') {
lineFunction = shapeArea().y(getY).x1(getX).x0(d => d.base.x);
} else {
lineFunction = shapeArea().x(getX).y1(getY).y0(d => d.base.y);
}
/*
* What happens here is that the `.defined()` call will make it so that this function can accept
* nullable points, and internally it will filter them out and skip when generating the path.
* So on the input it accepts NullableCoordinate, but it never calls getX/getY on null points because of the defined() filter.
*
* The d3 type definition has only one generic so it doesn't allow to describe this properly.
* However. d3 types are mutable, but we can pretend that they are not and we can pretend
* that calling defined() returns a new function with a different generic type.
*/
var _nullableLineFunction = lineFunction.defined(areaDefined).curve(curveFactory);
var finalPoints = connectNulls ? areaPoints.filter(areaDefined) : areaPoints;
return _nullableLineFunction(finalPoints);
}
if (layout === 'vertical' && isNumber(baseLine)) {
lineFunction = shapeArea().y(getY).x1(getX).x0(baseLine);
} else if (isNumber(baseLine)) {
lineFunction = shapeArea().x(getX).y1(getY).y0(baseLine);
} else {
lineFunction = shapeLine().x(getX).y(getY);
}
var nullableLineFunction = lineFunction.defined(defined).curve(curveFactory);
return nullableLineFunction(formatPoints);
};
export var Curve = props => {
var {
className,
points,
path,
pathRef
} = props;
if ((!points || !points.length) && !path) {
return null;
}
var realPath = points && points.length ? getPath(props) : path;
return /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesNoEvents(props), adaptEventHandlers(props), {
className: clsx('recharts-curve', className),
d: realPath === null ? undefined : realPath,
ref: pathRef
}));
};

27
frontend/node_modules/recharts/es6/shape/Dot.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/**
* @fileOverview Dot
*/
import * as React from 'react';
import { clsx } from 'clsx';
import { adaptEventHandlers } from '../util/types';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { isNumber } from '../util/DataUtils';
export var Dot = props => {
var {
cx,
cy,
r,
className
} = props;
var layerClass = clsx('recharts-dot', className);
if (isNumber(cx) && isNumber(cy) && isNumber(r)) {
return /*#__PURE__*/React.createElement("circle", _extends({}, svgPropertiesNoEvents(props), adaptEventHandlers(props), {
className: layerClass,
cx: cx,
cy: cy,
r: r
}));
}
return null;
};

86
frontend/node_modules/recharts/es6/shape/Polygon.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
var _excluded = ["points", "className", "baseLinePoints", "connectNulls"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Polygon
*/
import * as React from 'react';
import { clsx } from 'clsx';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
var isValidatePoint = point => {
return point && point.x === +point.x && point.y === +point.y;
};
var getParsedPoints = function getParsedPoints() {
var points = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var segmentPoints = [[]];
points.forEach(entry => {
if (isValidatePoint(entry)) {
segmentPoints[segmentPoints.length - 1].push(entry);
} else if (segmentPoints[segmentPoints.length - 1].length > 0) {
// add another path
segmentPoints.push([]);
}
});
if (isValidatePoint(points[0])) {
segmentPoints[segmentPoints.length - 1].push(points[0]);
}
if (segmentPoints[segmentPoints.length - 1].length <= 0) {
segmentPoints = segmentPoints.slice(0, -1);
}
return segmentPoints;
};
var getSinglePolygonPath = (points, connectNulls) => {
var segmentPoints = getParsedPoints(points);
if (connectNulls) {
segmentPoints = [segmentPoints.reduce((res, segPoints) => {
return [...res, ...segPoints];
}, [])];
}
var polygonPath = segmentPoints.map(segPoints => {
return segPoints.reduce((path, point, index) => {
return "".concat(path).concat(index === 0 ? 'M' : 'L').concat(point.x, ",").concat(point.y);
}, '');
}).join('');
return segmentPoints.length === 1 ? "".concat(polygonPath, "Z") : polygonPath;
};
var getRanglePath = (points, baseLinePoints, connectNulls) => {
var outerPath = getSinglePolygonPath(points, connectNulls);
return "".concat(outerPath.slice(-1) === 'Z' ? outerPath.slice(0, -1) : outerPath, "L").concat(getSinglePolygonPath(Array.from(baseLinePoints).reverse(), connectNulls).slice(1));
};
export var Polygon = props => {
var {
points,
className,
baseLinePoints,
connectNulls
} = props,
others = _objectWithoutProperties(props, _excluded);
if (!points || !points.length) {
return null;
}
var layerClass = clsx('recharts-polygon', className);
if (baseLinePoints && baseLinePoints.length) {
var hasStroke = others.stroke && others.stroke !== 'none';
var rangePath = getRanglePath(points, baseLinePoints, connectNulls);
return /*#__PURE__*/React.createElement("g", {
className: layerClass
}, /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(others), {
fill: rangePath.slice(-1) === 'Z' ? others.fill : 'none',
stroke: "none",
d: rangePath
})), hasStroke ? /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(others), {
fill: "none",
d: getSinglePolygonPath(points, connectNulls)
})) : null, hasStroke ? /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(others), {
fill: "none",
d: getSinglePolygonPath(baseLinePoints, connectNulls)
})) : null);
}
var singlePath = getSinglePolygonPath(points, connectNulls);
return /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(others), {
fill: singlePath.slice(-1) === 'Z' ? others.fill : 'none',
className: layerClass,
d: singlePath
}));
};

187
frontend/node_modules/recharts/es6/shape/Rectangle.js generated vendored Normal file
View File

@@ -0,0 +1,187 @@
var _excluded = ["radius"],
_excluded2 = ["radius"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
* @fileOverview Rectangle
*/
import * as React from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { interpolate } from '../util/DataUtils';
import { useAnimationId } from '../util/useAnimationId';
import { getTransitionVal } from '../animation/util';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
var getRectanglePath = (x, y, width, height, radius) => {
var maxRadius = Math.min(Math.abs(width) / 2, Math.abs(height) / 2);
var ySign = height >= 0 ? 1 : -1;
var xSign = width >= 0 ? 1 : -1;
var clockWise = height >= 0 && width >= 0 || height < 0 && width < 0 ? 1 : 0;
var path;
if (maxRadius > 0 && radius instanceof Array) {
var newRadius = [0, 0, 0, 0];
for (var i = 0, len = 4; i < len; i++) {
newRadius[i] = radius[i] > maxRadius ? maxRadius : radius[i];
}
path = "M".concat(x, ",").concat(y + ySign * newRadius[0]);
if (newRadius[0] > 0) {
path += "A ".concat(newRadius[0], ",").concat(newRadius[0], ",0,0,").concat(clockWise, ",").concat(x + xSign * newRadius[0], ",").concat(y);
}
path += "L ".concat(x + width - xSign * newRadius[1], ",").concat(y);
if (newRadius[1] > 0) {
path += "A ".concat(newRadius[1], ",").concat(newRadius[1], ",0,0,").concat(clockWise, ",\n ").concat(x + width, ",").concat(y + ySign * newRadius[1]);
}
path += "L ".concat(x + width, ",").concat(y + height - ySign * newRadius[2]);
if (newRadius[2] > 0) {
path += "A ".concat(newRadius[2], ",").concat(newRadius[2], ",0,0,").concat(clockWise, ",\n ").concat(x + width - xSign * newRadius[2], ",").concat(y + height);
}
path += "L ".concat(x + xSign * newRadius[3], ",").concat(y + height);
if (newRadius[3] > 0) {
path += "A ".concat(newRadius[3], ",").concat(newRadius[3], ",0,0,").concat(clockWise, ",\n ").concat(x, ",").concat(y + height - ySign * newRadius[3]);
}
path += 'Z';
} else if (maxRadius > 0 && radius === +radius && radius > 0) {
var _newRadius = Math.min(maxRadius, radius);
path = "M ".concat(x, ",").concat(y + ySign * _newRadius, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x + xSign * _newRadius, ",").concat(y, "\n L ").concat(x + width - xSign * _newRadius, ",").concat(y, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x + width, ",").concat(y + ySign * _newRadius, "\n L ").concat(x + width, ",").concat(y + height - ySign * _newRadius, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x + width - xSign * _newRadius, ",").concat(y + height, "\n L ").concat(x + xSign * _newRadius, ",").concat(y + height, "\n A ").concat(_newRadius, ",").concat(_newRadius, ",0,0,").concat(clockWise, ",").concat(x, ",").concat(y + height - ySign * _newRadius, " Z");
} else {
path = "M ".concat(x, ",").concat(y, " h ").concat(width, " v ").concat(height, " h ").concat(-width, " Z");
}
return path;
};
var defaultProps = {
x: 0,
y: 0,
width: 0,
height: 0,
// The radius of border
// The radius of four corners when radius is a number
// The radius of left-top, right-top, right-bottom, left-bottom when radius is an array
radius: 0,
isAnimationActive: false,
isUpdateAnimationActive: false,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease'
};
export var Rectangle = rectangleProps => {
var props = resolveDefaultProps(rectangleProps, defaultProps);
var pathRef = useRef(null);
var [totalLength, setTotalLength] = useState(-1);
useEffect(() => {
if (pathRef.current && pathRef.current.getTotalLength) {
try {
var pathTotalLength = pathRef.current.getTotalLength();
if (pathTotalLength) {
setTotalLength(pathTotalLength);
}
} catch (_unused) {
// calculate total length error
}
}
}, []);
var {
x,
y,
width,
height,
radius,
className
} = props;
var {
animationEasing,
animationDuration,
animationBegin,
isAnimationActive,
isUpdateAnimationActive
} = props;
var prevWidthRef = useRef(width);
var prevHeightRef = useRef(height);
var prevXRef = useRef(x);
var prevYRef = useRef(y);
var animationIdInput = useMemo(() => ({
x,
y,
width,
height,
radius
}), [x, y, width, height, radius]);
var animationId = useAnimationId(animationIdInput, 'rectangle-');
if (x !== +x || y !== +y || width !== +width || height !== +height || width === 0 || height === 0) {
return null;
}
var layerClass = clsx('recharts-rectangle', className);
if (!isUpdateAnimationActive) {
var _svgPropertiesAndEven = svgPropertiesAndEvents(props),
{
radius: _
} = _svgPropertiesAndEven,
otherPathProps = _objectWithoutProperties(_svgPropertiesAndEven, _excluded);
return /*#__PURE__*/React.createElement("path", _extends({}, otherPathProps, {
radius: typeof radius === 'number' ? radius : undefined,
className: layerClass,
d: getRectanglePath(x, y, width, height, radius)
}));
}
var prevWidth = prevWidthRef.current;
var prevHeight = prevHeightRef.current;
var prevX = prevXRef.current;
var prevY = prevYRef.current;
var from = "0px ".concat(totalLength === -1 ? 1 : totalLength, "px");
var to = "".concat(totalLength, "px 0px");
var transition = getTransitionVal(['strokeDasharray'], animationDuration, typeof animationEasing === 'string' ? animationEasing : defaultProps.animationEasing);
return /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
key: animationId,
canBegin: totalLength > 0,
duration: animationDuration,
easing: animationEasing,
isActive: isUpdateAnimationActive,
begin: animationBegin
}, t => {
var currWidth = interpolate(prevWidth, width, t);
var currHeight = interpolate(prevHeight, height, t);
var currX = interpolate(prevX, x, t);
var currY = interpolate(prevY, y, t);
if (pathRef.current) {
prevWidthRef.current = currWidth;
prevHeightRef.current = currHeight;
prevXRef.current = currX;
prevYRef.current = currY;
}
var animationStyle;
if (!isAnimationActive) {
animationStyle = {
strokeDasharray: to
};
} else if (t > 0) {
animationStyle = {
transition,
strokeDasharray: to
};
} else {
animationStyle = {
strokeDasharray: from
};
}
var _svgPropertiesAndEven2 = svgPropertiesAndEvents(props),
{
radius: _
} = _svgPropertiesAndEven2,
otherPathProps = _objectWithoutProperties(_svgPropertiesAndEven2, _excluded2);
return /*#__PURE__*/React.createElement("path", _extends({}, otherPathProps, {
radius: typeof radius === 'number' ? radius : undefined,
className: layerClass,
d: getRectanglePath(currX, currY, currWidth, currHeight, radius),
ref: pathRef,
style: _objectSpread(_objectSpread({}, animationStyle), props.style)
}));
});
};

222
frontend/node_modules/recharts/es6/shape/Sector.js generated vendored Normal file
View File

@@ -0,0 +1,222 @@
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import * as React from 'react';
import { clsx } from 'clsx';
import { polarToCartesian, RADIAN } from '../util/PolarUtils';
import { getPercentValue, mathSign } from '../util/DataUtils';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
var getDeltaAngle = (startAngle, endAngle) => {
var sign = mathSign(endAngle - startAngle);
var deltaAngle = Math.min(Math.abs(endAngle - startAngle), 359.999);
return sign * deltaAngle;
};
var getTangentCircle = _ref => {
var {
cx,
cy,
radius,
angle,
sign,
isExternal,
cornerRadius,
cornerIsExternal
} = _ref;
var centerRadius = cornerRadius * (isExternal ? 1 : -1) + radius;
var theta = Math.asin(cornerRadius / centerRadius) / RADIAN;
var centerAngle = cornerIsExternal ? angle : angle + sign * theta;
var center = polarToCartesian(cx, cy, centerRadius, centerAngle);
// The coordinate of point which is tangent to the circle
var circleTangency = polarToCartesian(cx, cy, radius, centerAngle);
// The coordinate of point which is tangent to the radius line
var lineTangencyAngle = cornerIsExternal ? angle - sign * theta : angle;
var lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN), lineTangencyAngle);
return {
center,
circleTangency,
lineTangency,
theta
};
};
var getSectorPath = _ref2 => {
var {
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle
} = _ref2;
var angle = getDeltaAngle(startAngle, endAngle);
// When the angle of sector equals to 360, star point and end point coincide
var tempEndAngle = startAngle + angle;
var outerStartPoint = polarToCartesian(cx, cy, outerRadius, startAngle);
var outerEndPoint = polarToCartesian(cx, cy, outerRadius, tempEndAngle);
var path = "M ".concat(outerStartPoint.x, ",").concat(outerStartPoint.y, "\n A ").concat(outerRadius, ",").concat(outerRadius, ",0,\n ").concat(+(Math.abs(angle) > 180), ",").concat(+(startAngle > tempEndAngle), ",\n ").concat(outerEndPoint.x, ",").concat(outerEndPoint.y, "\n ");
if (innerRadius > 0) {
var innerStartPoint = polarToCartesian(cx, cy, innerRadius, startAngle);
var innerEndPoint = polarToCartesian(cx, cy, innerRadius, tempEndAngle);
path += "L ".concat(innerEndPoint.x, ",").concat(innerEndPoint.y, "\n A ").concat(innerRadius, ",").concat(innerRadius, ",0,\n ").concat(+(Math.abs(angle) > 180), ",").concat(+(startAngle <= tempEndAngle), ",\n ").concat(innerStartPoint.x, ",").concat(innerStartPoint.y, " Z");
} else {
path += "L ".concat(cx, ",").concat(cy, " Z");
}
return path;
};
var getSectorWithCorner = _ref3 => {
var {
cx,
cy,
innerRadius,
outerRadius,
cornerRadius,
forceCornerRadius,
cornerIsExternal,
startAngle,
endAngle
} = _ref3;
var sign = mathSign(endAngle - startAngle);
var {
circleTangency: soct,
lineTangency: solt,
theta: sot
} = getTangentCircle({
cx,
cy,
radius: outerRadius,
angle: startAngle,
sign,
cornerRadius,
cornerIsExternal
});
var {
circleTangency: eoct,
lineTangency: eolt,
theta: eot
} = getTangentCircle({
cx,
cy,
radius: outerRadius,
angle: endAngle,
sign: -sign,
cornerRadius,
cornerIsExternal
});
var outerArcAngle = cornerIsExternal ? Math.abs(startAngle - endAngle) : Math.abs(startAngle - endAngle) - sot - eot;
if (outerArcAngle < 0) {
if (forceCornerRadius) {
return "M ".concat(solt.x, ",").concat(solt.y, "\n a").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,1,").concat(cornerRadius * 2, ",0\n a").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,1,").concat(-cornerRadius * 2, ",0\n ");
}
return getSectorPath({
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle
});
}
var path = "M ".concat(solt.x, ",").concat(solt.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(soct.x, ",").concat(soct.y, "\n A").concat(outerRadius, ",").concat(outerRadius, ",0,").concat(+(outerArcAngle > 180), ",").concat(+(sign < 0), ",").concat(eoct.x, ",").concat(eoct.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(eolt.x, ",").concat(eolt.y, "\n ");
if (innerRadius > 0) {
var {
circleTangency: sict,
lineTangency: silt,
theta: sit
} = getTangentCircle({
cx,
cy,
radius: innerRadius,
angle: startAngle,
sign,
isExternal: true,
cornerRadius,
cornerIsExternal
});
var {
circleTangency: eict,
lineTangency: eilt,
theta: eit
} = getTangentCircle({
cx,
cy,
radius: innerRadius,
angle: endAngle,
sign: -sign,
isExternal: true,
cornerRadius,
cornerIsExternal
});
var innerArcAngle = cornerIsExternal ? Math.abs(startAngle - endAngle) : Math.abs(startAngle - endAngle) - sit - eit;
if (innerArcAngle < 0 && cornerRadius === 0) {
return "".concat(path, "L").concat(cx, ",").concat(cy, "Z");
}
path += "L".concat(eilt.x, ",").concat(eilt.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(eict.x, ",").concat(eict.y, "\n A").concat(innerRadius, ",").concat(innerRadius, ",0,").concat(+(innerArcAngle > 180), ",").concat(+(sign > 0), ",").concat(sict.x, ",").concat(sict.y, "\n A").concat(cornerRadius, ",").concat(cornerRadius, ",0,0,").concat(+(sign < 0), ",").concat(silt.x, ",").concat(silt.y, "Z");
} else {
path += "L".concat(cx, ",").concat(cy, "Z");
}
return path;
};
/**
* SVG cx, cy are `string | number | undefined`, but internally we use `number` so let's
* override the types here.
*/
var defaultProps = {
cx: 0,
cy: 0,
innerRadius: 0,
outerRadius: 0,
startAngle: 0,
endAngle: 0,
cornerRadius: 0,
forceCornerRadius: false,
cornerIsExternal: false
};
export var Sector = sectorProps => {
var props = resolveDefaultProps(sectorProps, defaultProps);
var {
cx,
cy,
innerRadius,
outerRadius,
cornerRadius,
forceCornerRadius,
cornerIsExternal,
startAngle,
endAngle,
className
} = props;
if (outerRadius < innerRadius || startAngle === endAngle) {
return null;
}
var layerClass = clsx('recharts-sector', className);
var deltaRadius = outerRadius - innerRadius;
var cr = getPercentValue(cornerRadius, deltaRadius, 0, true);
var path;
if (cr > 0 && Math.abs(startAngle - endAngle) < 360) {
path = getSectorWithCorner({
cx,
cy,
innerRadius,
outerRadius,
cornerRadius: Math.min(cr, deltaRadius / 2),
forceCornerRadius,
cornerIsExternal,
startAngle,
endAngle
});
} else {
path = getSectorPath({
cx,
cy,
innerRadius,
outerRadius,
startAngle,
endAngle
});
}
return /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(props), {
className: layerClass,
d: path
}));
};

108
frontend/node_modules/recharts/es6/shape/Symbols.js generated vendored Normal file
View File

@@ -0,0 +1,108 @@
var _excluded = ["type", "size", "sizeType"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { symbol as shapeSymbol, symbolCircle, symbolCross, symbolDiamond, symbolSquare, symbolStar, symbolTriangle, symbolWye } from 'victory-vendor/d3-shape';
import { clsx } from 'clsx';
import { isNumber, upperFirst } from '../util/DataUtils';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
var symbolFactories = {
symbolCircle,
symbolCross,
symbolDiamond,
symbolSquare,
symbolStar,
symbolTriangle,
symbolWye
};
var RADIAN = Math.PI / 180;
var getSymbolFactory = type => {
var name = "symbol".concat(upperFirst(type));
return symbolFactories[name] || symbolCircle;
};
var calculateAreaSize = (size, sizeType, type) => {
if (sizeType === 'area') {
return size;
}
switch (type) {
case 'cross':
return 5 * size * size / 9;
case 'diamond':
return 0.5 * size * size / Math.sqrt(3);
case 'square':
return size * size;
case 'star':
{
var angle = 18 * RADIAN;
return 1.25 * size * size * (Math.tan(angle) - Math.tan(angle * 2) * Math.tan(angle) ** 2);
}
case 'triangle':
return Math.sqrt(3) * size * size / 4;
case 'wye':
return (21 - 10 * Math.sqrt(3)) * size * size / 8;
default:
return Math.PI * size * size / 4;
}
};
var registerSymbol = (key, factory) => {
symbolFactories["symbol".concat(upperFirst(key))] = factory;
};
export var Symbols = _ref => {
var {
type = 'circle',
size = 64,
sizeType = 'area'
} = _ref,
rest = _objectWithoutProperties(_ref, _excluded);
var props = _objectSpread(_objectSpread({}, rest), {}, {
type,
size,
sizeType
});
var realType = 'circle';
if (typeof type === 'string') {
/*
* Our type guard is not as strong as it could be (i.e. non-existent),
* and so despite the typescript type saying that `type` is a `SymbolType`,
* we can get numbers or really anything, so let's have a runtime check here to fix the exception.
*
* https://github.com/recharts/recharts/issues/6197
*/
realType = type;
}
/**
* Calculate the path of curve
* @return {String} path
*/
var getPath = () => {
var symbolFactory = getSymbolFactory(realType);
var symbol = shapeSymbol().type(symbolFactory).size(calculateAreaSize(size, sizeType, realType));
var s = symbol();
if (s === null) {
return undefined;
}
return s;
};
var {
className,
cx,
cy
} = props;
var filteredProps = svgPropertiesAndEvents(props);
if (isNumber(cx) && isNumber(cy) && isNumber(size)) {
return /*#__PURE__*/React.createElement("path", _extends({}, filteredProps, {
className: clsx('recharts-symbols', className),
transform: "translate(".concat(cx, ", ").concat(cy, ")"),
d: getPath()
}));
}
return null;
};
Symbols.registerSymbol = registerSymbol;

128
frontend/node_modules/recharts/es6/shape/Trapezoid.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
/**
* @fileOverview Rectangle
*/
import * as React from 'react';
import { useEffect, useRef, useState } from 'react';
import { clsx } from 'clsx';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { JavascriptAnimate } from '../animation/JavascriptAnimate';
import { useAnimationId } from '../util/useAnimationId';
import { interpolate } from '../util/DataUtils';
import { getTransitionVal } from '../animation/util';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
var getTrapezoidPath = (x, y, upperWidth, lowerWidth, height) => {
var widthGap = upperWidth - lowerWidth;
var path;
path = "M ".concat(x, ",").concat(y);
path += "L ".concat(x + upperWidth, ",").concat(y);
path += "L ".concat(x + upperWidth - widthGap / 2, ",").concat(y + height);
path += "L ".concat(x + upperWidth - widthGap / 2 - lowerWidth, ",").concat(y + height);
path += "L ".concat(x, ",").concat(y, " Z");
return path;
};
var defaultProps = {
x: 0,
y: 0,
upperWidth: 0,
lowerWidth: 0,
height: 0,
isUpdateAnimationActive: false,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease'
};
export var Trapezoid = outsideProps => {
var trapezoidProps = resolveDefaultProps(outsideProps, defaultProps);
var {
x,
y,
upperWidth,
lowerWidth,
height,
className
} = trapezoidProps;
var {
animationEasing,
animationDuration,
animationBegin,
isUpdateAnimationActive
} = trapezoidProps;
var pathRef = useRef(null);
var [totalLength, setTotalLength] = useState(-1);
var prevUpperWidthRef = useRef(upperWidth);
var prevLowerWidthRef = useRef(lowerWidth);
var prevHeightRef = useRef(height);
var prevXRef = useRef(x);
var prevYRef = useRef(y);
var animationId = useAnimationId(outsideProps, 'trapezoid-');
useEffect(() => {
if (pathRef.current && pathRef.current.getTotalLength) {
try {
var pathTotalLength = pathRef.current.getTotalLength();
if (pathTotalLength) {
setTotalLength(pathTotalLength);
}
} catch (_unused) {
// calculate total length error
}
}
}, []);
if (x !== +x || y !== +y || upperWidth !== +upperWidth || lowerWidth !== +lowerWidth || height !== +height || upperWidth === 0 && lowerWidth === 0 || height === 0) {
return null;
}
var layerClass = clsx('recharts-trapezoid', className);
if (!isUpdateAnimationActive) {
return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(trapezoidProps), {
className: layerClass,
d: getTrapezoidPath(x, y, upperWidth, lowerWidth, height)
})));
}
var prevUpperWidth = prevUpperWidthRef.current;
var prevLowerWidth = prevLowerWidthRef.current;
var prevHeight = prevHeightRef.current;
var prevX = prevXRef.current;
var prevY = prevYRef.current;
var from = "0px ".concat(totalLength === -1 ? 1 : totalLength, "px");
var to = "".concat(totalLength, "px 0px");
var transition = getTransitionVal(['strokeDasharray'], animationDuration, animationEasing);
return /*#__PURE__*/React.createElement(JavascriptAnimate, {
animationId: animationId,
key: animationId,
canBegin: totalLength > 0,
duration: animationDuration,
easing: animationEasing,
isActive: isUpdateAnimationActive,
begin: animationBegin
}, t => {
var currUpperWidth = interpolate(prevUpperWidth, upperWidth, t);
var currLowerWidth = interpolate(prevLowerWidth, lowerWidth, t);
var currHeight = interpolate(prevHeight, height, t);
var currX = interpolate(prevX, x, t);
var currY = interpolate(prevY, y, t);
if (pathRef.current) {
prevUpperWidthRef.current = currUpperWidth;
prevLowerWidthRef.current = currLowerWidth;
prevHeightRef.current = currHeight;
prevXRef.current = currX;
prevYRef.current = currY;
}
var animationStyle = t > 0 ? {
transition,
strokeDasharray: to
} : {
strokeDasharray: from
};
return /*#__PURE__*/React.createElement("path", _extends({}, svgPropertiesAndEvents(trapezoidProps), {
className: layerClass,
d: getTrapezoidPath(currX, currY, currUpperWidth, currLowerWidth, currHeight),
ref: pathRef,
style: _objectSpread(_objectSpread({}, animationStyle), trapezoidProps.style)
}));
});
};

View File

@@ -0,0 +1,17 @@
import { createContext } from 'react';
/*
* This is a copy of the React-Redux context type, but with our own store type.
* We could import directly from react-redux like this:
* import { ReactReduxContextValue } from 'react-redux/src/components/Context';
* but that makes typescript angry with some errors I am not sure how to resolve
* so copy it is.
*/
/**
* We need to use our own independent Redux context because we need to avoid interfering with other people's Redux stores
* in case they decide to install and use Recharts in another Redux app which is likely to happen.
*
* https://react-redux.js.org/using-react-redux/accessing-store#providing-custom-context
*/
export var RechartsReduxContext = /*#__PURE__*/createContext(null);

Some files were not shown because too many files have changed in this diff Show More