@oliasoft-open-source/charts-library 5.0.1 → 5.0.2-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Color-YHDXOIA2-D6i6tiFz.js → Color-YHDXOIA2-Df_YstNU.js} +1 -1
- package/dist/assets/{DocsRenderer-CFRXHY34-D88vu1Xb.js → DocsRenderer-CFRXHY34-DKIsUafc.js} +3 -3
- package/dist/assets/{bar-chart.stories-D9mtWCnD.js → bar-chart.stories-Eq_jQ19D.js} +1 -1
- package/dist/assets/{entry-preview-D2XJoWVM.js → entry-preview-CQnVs0vE.js} +1 -1
- package/dist/assets/{get-draggableData-DO0Px5pc.js → get-draggableData-CQpLHCdg.js} +1 -1
- package/dist/assets/{iframe-DLnw2TiW.js → iframe-DFPTtPL0.js} +2 -2
- package/dist/assets/{legend-context-BNCYpFYh.js → legend-context-vqtlaWwg.js} +2 -2
- package/dist/assets/{legend-BI53UIaI.js → legend-krJw8Ykb.js} +1 -1
- package/dist/assets/line-chart-Dv_KrvKB.js +1 -0
- package/dist/assets/{line-chart.stories-BVsiy8CQ.js → line-chart.stories-ChiBYJlu.js} +94 -69
- package/dist/assets/{line-chart.test-case.stories-DgfMW1VB.js → line-chart.test-case.stories-DWzxvnmk.js} +1 -1
- package/dist/assets/{pie-chart.stories-BVurv17M.js → pie-chart.stories-BiFagB5b.js} +1 -1
- package/dist/assets/{preview-XObsormK.js → preview-BSEAQ_IE.js} +1 -1
- package/dist/assets/{preview-CLM2f008.js → preview-DLeQ-_m8.js} +2 -2
- package/dist/assets/{scatter-chart.stories-DnivHhIH.js → scatter-chart.stories-BCbRBdJY.js} +1 -1
- package/dist/common/helpers/chart-utils.d.ts +1 -0
- package/dist/iframe.html +1 -1
- package/dist/index.js.js +15 -8
- package/dist/index.js.js.map +1 -1
- package/dist/line-chart/controls/axes-options/axes-options-interfaces.d.ts +7 -5
- package/dist/line-chart/controls/axes-options/axes-validation.d.ts +8 -0
- package/dist/line-chart/controls/controls-interfaces.d.ts +1 -1
- package/dist/line-chart/controls/controls.d.ts +1 -4
- package/dist/line-chart/hooks/use-chart-functions.d.ts +1 -1
- package/dist/line-chart/hooks/use-chart-state.d.ts +2 -3
- package/dist/line-chart/line-chart.interface.d.ts +4 -0
- package/dist/line-chart/state/action-types.d.ts +0 -1
- package/dist/line-chart/state/helpers.d.ts +13 -0
- package/dist/line-chart/state/state.interfaces.d.ts +3 -12
- package/dist/project.json +1 -1
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +1 -1
- package/package.json +1 -1
- package/dist/assets/line-chart-BdFuLh7N.js +0 -1
- package/dist/line-chart/controls/axes-options/action-types.d.ts +0 -5
- package/dist/line-chart/controls/axes-options/axes-options-form-state.d.ts +0 -23
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RefObject } from '../../../../../node_modules/react';
|
|
2
|
+
import { Chart } from 'chart.js';
|
|
3
|
+
import { IUnitOptions } from '../../line-chart.interface';
|
|
4
|
+
import { IAxisState, IState } from '../../state/state.interfaces';
|
|
3
5
|
export interface IDepthType {
|
|
4
6
|
selectedDepthType?: string;
|
|
5
7
|
setSelectedDepthType?: (type: string) => void;
|
|
@@ -10,8 +12,8 @@ export interface IAxisControlLabel {
|
|
|
10
12
|
label: string;
|
|
11
13
|
}
|
|
12
14
|
export interface IAxesOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
chartRef: RefObject<Chart>;
|
|
16
|
+
state: IState;
|
|
15
17
|
controlsAxesLabels: IAxisControlLabel[];
|
|
16
18
|
onUpdateAxes: ({ axes }: {
|
|
17
19
|
axes: IAxisState;
|
|
@@ -44,8 +46,8 @@ export interface IFormState extends IInitializeAxisFormState {
|
|
|
44
46
|
type ActionType = 'reset' | 'valueUpdated' | 'unitUpdated';
|
|
45
47
|
export type AxisKey = 'min' | 'max' | 'unit';
|
|
46
48
|
interface ActionPayload extends IOnEdit {
|
|
47
|
-
initialAxesRanges?: IInitAxisRange[];
|
|
48
49
|
axes?: IAxisState[];
|
|
50
|
+
chartRef?: RefObject<Chart>;
|
|
49
51
|
}
|
|
50
52
|
export interface IAction {
|
|
51
53
|
type: ActionType;
|
|
@@ -4,7 +4,7 @@ import { ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.in
|
|
|
4
4
|
import { IState } from '../state/state.interfaces';
|
|
5
5
|
export interface IControls {
|
|
6
6
|
headerComponent?: ReactNode;
|
|
7
|
-
subheaderComponent?:
|
|
7
|
+
subheaderComponent?: ReactNode;
|
|
8
8
|
table?: ReactNode;
|
|
9
9
|
chartRef: RefObject<Chart>;
|
|
10
10
|
state: IState;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { IControls } from './controls-interfaces';
|
|
2
|
-
|
|
3
|
-
* @param {import('./controls-interfaces').IControls} obj
|
|
4
|
-
*/
|
|
5
|
-
declare const Controls: ({ headerComponent, subheaderComponent, table, chartRef, state, options, dispatch, generatedDatasets, translations, controlsPortalId, }: IControls) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const Controls: ({ table, headerComponent, subheaderComponent, chartRef, state, options, dispatch, generatedDatasets, translations, controlsPortalId, }: IControls) => import("react/jsx-runtime").JSX.Element;
|
|
6
3
|
export default Controls;
|
|
@@ -15,7 +15,7 @@ interface IUseChartFunctions {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const useChartFunctions: ({ chartRef, state, options, dispatch, generatedDatasets, }: IUseChartFunctions) => {
|
|
17
17
|
resetZoom: () => void;
|
|
18
|
-
onHover: (hoveredPoint: ICommonDataValue | null, setHoveredPoint: Dispatch<SetStateAction<ICommonDataValue | null
|
|
18
|
+
onHover: (hoveredPoint: ICommonDataValue | null, setHoveredPoint: Dispatch<SetStateAction<ICommonDataValue | null>>, datasets: TGeneratedLineChartDatasets) => (evt: ChartEvent, hoveredItems: ICommonHoveredItems[]) => void;
|
|
19
19
|
handleDownload: () => void;
|
|
20
20
|
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
21
21
|
handleKeyUp: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Dispatch, RefObject } from '../../../../node_modules/react';
|
|
2
2
|
import { Chart } from 'chart.js';
|
|
3
3
|
import { IState } from '../state/state.interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
5
5
|
interface IUseChartState {
|
|
6
6
|
chartRef: RefObject<Chart>;
|
|
7
7
|
options: ILineChartOptions;
|
|
8
8
|
state: IState;
|
|
9
9
|
dispatch: Dispatch<any>;
|
|
10
10
|
persistenceId?: string;
|
|
11
|
-
generatedDatasets: ILineChartDataset[];
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* Hook for managing the state of the chart.
|
|
15
14
|
*/
|
|
16
|
-
export declare const useChartState: ({ chartRef, options, state, dispatch, persistenceId,
|
|
15
|
+
export declare const useChartState: ({ chartRef, options, state, dispatch, persistenceId, }: IUseChartState) => void;
|
|
17
16
|
export {};
|
|
@@ -46,6 +46,8 @@ export interface ILineChartAxis<PositionType = any> {
|
|
|
46
46
|
unit?: IUnitOptions;
|
|
47
47
|
stepSize?: number;
|
|
48
48
|
gridLines?: ILineChartGraph;
|
|
49
|
+
min?: number | string;
|
|
50
|
+
max?: number | string;
|
|
49
51
|
}
|
|
50
52
|
export interface ILineChartAxes {
|
|
51
53
|
x: ILineChartAxis<'top' | 'bottom'>[];
|
|
@@ -112,6 +114,8 @@ export interface ILineChartData extends ICommonData {
|
|
|
112
114
|
export interface ILineChartProps {
|
|
113
115
|
chart: ILineChartData;
|
|
114
116
|
table?: ReactNode;
|
|
117
|
+
headerComponent?: ReactNode;
|
|
118
|
+
subheaderComponent?: ReactNode;
|
|
115
119
|
}
|
|
116
120
|
export interface IGeneratedLineChartDataset {
|
|
117
121
|
label?: string;
|
|
@@ -4,7 +4,6 @@ export declare const TOGGLE_POINTS = "TOGGLE_POINTS";
|
|
|
4
4
|
export declare const TOGGLE_LINE = "TOGGLE_LINE";
|
|
5
5
|
export declare const TOGGLE_LEGEND = "TOGGLE_LEGEND";
|
|
6
6
|
export declare const TOGGLE_TABLE = "TOGGLE_TABLE";
|
|
7
|
-
export declare const SAVE_INITIAL_AXES_RANGES = "SAVE_INITIAL_AXES_RANGES";
|
|
8
7
|
export declare const RESET_AXES_RANGES = "RESET_AXES_RANGES";
|
|
9
8
|
export declare const UPDATE_AXES_RANGES = "UPDATE_AXES_RANGES";
|
|
10
9
|
export declare const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Chart } from 'chart.js';
|
|
2
|
+
import { RefObject } from '../../../../node_modules/react';
|
|
3
|
+
import { IState } from './state.interfaces';
|
|
4
|
+
export interface IGetInitAxes {
|
|
5
|
+
chartRef: RefObject<Chart>;
|
|
6
|
+
state: IState;
|
|
7
|
+
}
|
|
8
|
+
export declare const getInitAxes: ({ chartRef, state }: IGetInitAxes) => {
|
|
9
|
+
id: string;
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
unit: string | import('../line-chart.interface').IUnitOptions | undefined;
|
|
13
|
+
}[];
|
|
@@ -2,12 +2,12 @@ import { IUnitOptions } from '../line-chart.interface';
|
|
|
2
2
|
export interface IAxisState {
|
|
3
3
|
id?: string;
|
|
4
4
|
label?: string;
|
|
5
|
-
min?: number;
|
|
6
|
-
max?: number;
|
|
5
|
+
min?: number | string;
|
|
6
|
+
max?: number | string;
|
|
7
7
|
unit?: IUnitOptions | string;
|
|
8
8
|
axisType?: string;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface IState {
|
|
11
11
|
zoomEnabled: boolean;
|
|
12
12
|
panEnabled: boolean;
|
|
13
13
|
pointsEnabled: boolean;
|
|
@@ -19,15 +19,6 @@ export interface InitialState {
|
|
|
19
19
|
enableDragPoints: boolean;
|
|
20
20
|
enableDragAnnotation: boolean;
|
|
21
21
|
}
|
|
22
|
-
export interface IInitAxisRange {
|
|
23
|
-
id: string;
|
|
24
|
-
min: number;
|
|
25
|
-
max: number;
|
|
26
|
-
unit?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface IState extends InitialState {
|
|
29
|
-
initialAxesRanges: IInitAxisRange[];
|
|
30
|
-
}
|
|
31
22
|
export interface IAction<T = string, P = any> {
|
|
32
23
|
type: T;
|
|
33
24
|
payload?: P;
|
package/dist/project.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generatedAt":
|
|
1
|
+
{"generatedAt":1742904523156,"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":false,"hasStorybookEslint":true,"refCount":0,"testPackages":{"@storybook/testing-library":"0.2.2","eslint-plugin-vitest":null,"eslint-plugin-vitest-globals":"1.5.0","vitest":"3.0.9"},"hasRouterPackage":false,"packageManager":{"type":"yarn","version":"1.22.22"},"preview":{"usesGlobals":false},"framework":{"name":"@storybook/react-vite","options":{}},"builder":"@storybook/builder-vite","renderer":"@storybook/react","portableStoriesFileCount":0,"applicationFileCount":0,"storybookVersion":"8.6.7","storybookVersionSpecifier":"^8.6.7","language":"javascript","storybookPackages":{"@storybook/blocks":{"version":"8.6.7"},"@storybook/react":{"version":"8.6.7"},"@storybook/react-vite":{"version":"8.6.7"},"@storybook/testing-library":{"version":"0.2.2"},"eslint-plugin-storybook":{"version":"0.11.6"},"storybook":{"version":"8.6.7"}},"addons":{"@storybook/addon-actions":{"version":"8.6.7"},"@storybook/addon-docs":{"version":"8.6.7"},"storybook-dark-mode":{"version":"4.0.2"},"@storybook/addon-mdx-gfm":{"version":"8.6.7"}}}
|
|
@@ -15,7 +15,7 @@ interface IUseChartFunctions {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const useChartFunctions: ({ chartRef, state, options, dispatch, generatedDatasets, }: IUseChartFunctions) => {
|
|
17
17
|
resetZoom: () => void;
|
|
18
|
-
onHover: (hoveredPoint: ICommonDataValue | null, setHoveredPoint: Dispatch<SetStateAction<ICommonDataValue | null
|
|
18
|
+
onHover: (hoveredPoint: ICommonDataValue | null, setHoveredPoint: Dispatch<SetStateAction<ICommonDataValue | null>>, datasets: TGeneratedLineChartDatasets) => (evt: ChartEvent, hoveredItems: ICommonHoveredItems[]) => void;
|
|
19
19
|
handleDownload: () => void;
|
|
20
20
|
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
21
21
|
handleKeyUp: (event: KeyboardEvent<HTMLDivElement>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/charts-library",
|
|
3
|
-
"version": "5.0.1",
|
|
3
|
+
"version": "5.0.2-beta-1",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
|
|
6
6
|
"resolutions": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as x}from"./jsx-runtime-Y5Ju2SGo.js";import{r as O}from"./index-eCxJ45ll.js";import{$ as Ht,x as H,a0 as Ze,a1 as ee,A as X,P as ie,v as C,C as te,a2 as Ve,a3 as Yt,g as Ie,N as Wt,S as qt,y as $t,O as Zt,a4 as ae,a5 as ce,Q as ne,a6 as ge,E as ve,R as Kt,T as Jt,L as Ke,a as Qt,U as be,V as en,W as J,d as tn,r as nn,B as Je,a7 as sn,f as rn,a8 as on,I as ln,a9 as Y,aa as Re,ab as le,D as an,ac as Q,b as cn,s as un,F as dn,ad as fn,h as mn,i as gn,J as bn,Y as hn,j as pn,k as yn,p as _n,m as xn,n as En,o as Tn,q as Sn,t as Ln}from"./legend-context-BNCYpFYh.js";import{r as De,M as Xe,p as he,B as W,s as On,v as An,w as Qe,x as Cn,y as Pn,z as Dn,A as wn,E as Mn,N as et,G as Nn,S as In,f as vn,e as Fn,F as jn,T as bt,J as kn,K as Gn,h as zn,O as Un,Q as Bn,k as Vn,q as Rn,U as Xn,u as Hn,j as Yn,Z as Wn,t as qn,R as $n,m as Zn,H as Kn,L as Jn,n as Qn,o as es}from"./legend-BI53UIaI.js";import{c as ts,C as ns,f as tt,a as ss,b as rs}from"./get-draggableData-DO0Px5pc.js";import{e as os}from"./index-B-BONL6g.js";const ls="_chart_e3qdd_1",is="_canvas_e3qdd_11",as="_fixedHeight_e3qdd_20",cs="_stretchHeight_e3qdd_26",us="_squareAspectRatio_e3qdd_32",ds="_table_e3qdd_62",we={chart:ls,canvas:is,fixedHeight:as,stretchHeight:cs,squareAspectRatio:us,table:ds};var ht=Symbol.for("immer-nothing"),nt=Symbol.for("immer-draftable"),z=Symbol.for("immer-state");function V(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var se=Object.getPrototypeOf;function re(e){return!!e&&!!e[z]}function Z(e){var t;return e?pt(e)||Array.isArray(e)||!!e[nt]||!!((t=e.constructor)!=null&&t[nt])||Ae(e)||Ce(e):!1}var fs=Object.prototype.constructor.toString();function pt(e){if(!e||typeof e!="object")return!1;const t=se(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===fs}function pe(e,t){Oe(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,s)=>t(s,n,e))}function Oe(e){const t=e[z];return t?t.type_:Array.isArray(e)?1:Ae(e)?2:Ce(e)?3:0}function Fe(e,t){return Oe(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function yt(e,t,n){const s=Oe(e);s===2?e.set(t,n):s===3?e.add(n):e[t]=n}function ms(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ae(e){return e instanceof Map}function Ce(e){return e instanceof Set}function q(e){return e.copy_||e.base_}function je(e,t){if(Ae(e))return new Map(e);if(Ce(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=pt(e);if(t===!0||t==="class_only"&&!n){const s=Object.getOwnPropertyDescriptors(e);delete s[z];let r=Reflect.ownKeys(s);for(let i=0;i<r.length;i++){const o=r[i],l=s[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(s[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[o]})}return Object.create(se(e),s)}else{const s=se(e);if(s!==null&&n)return{...e};const r=Object.create(s);return Object.assign(r,e)}}function He(e,t=!1){return Pe(e)||re(e)||!Z(e)||(Oe(e)>1&&(e.set=e.add=e.clear=e.delete=gs),Object.freeze(e),t&&Object.entries(e).forEach(([n,s])=>He(s,!0))),e}function gs(){V(2)}function Pe(e){return Object.isFrozen(e)}var bs={};function K(e){const t=bs[e];return t||V(0,e),t}var ue;function _t(){return ue}function hs(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function st(e,t){t&&(K("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ke(e){Ge(e),e.drafts_.forEach(ps),e.drafts_=null}function Ge(e){e===ue&&(ue=e.parent_)}function rt(e){return ue=hs(ue,e)}function ps(e){const t=e[z];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ot(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[z].modified_&&(ke(t),V(4)),Z(e)&&(e=ye(t,e),t.parent_||_e(t,e)),t.patches_&&K("Patches").generateReplacementPatches_(n[z].base_,e,t.patches_,t.inversePatches_)):e=ye(t,n,[]),ke(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ht?e:void 0}function ye(e,t,n){if(Pe(t))return t;const s=t[z];if(!s)return pe(t,(r,i)=>lt(e,s,t,r,i,n)),t;if(s.scope_!==e)return t;if(!s.modified_)return _e(e,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const r=s.copy_;let i=r,o=!1;s.type_===3&&(i=new Set(r),r.clear(),o=!0),pe(i,(l,a)=>lt(e,s,r,l,a,n,o)),_e(e,r,!1),n&&e.patches_&&K("Patches").generatePatches_(s,n,e.patches_,e.inversePatches_)}return s.copy_}function lt(e,t,n,s,r,i,o){if(re(r)){const l=i&&t&&t.type_!==3&&!Fe(t.assigned_,s)?i.concat(s):void 0,a=ye(e,r,l);if(yt(n,s,a),re(a))e.canAutoFreeze_=!1;else return}else o&&n.add(r);if(Z(r)&&!Pe(r)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ye(e,r),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,s)&&_e(e,r)}}function _e(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&He(t,n)}function ys(e,t){const n=Array.isArray(e),s={type_:n?1:0,scope_:t?t.scope_:_t(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=s,i=Ye;n&&(r=[s],i=de);const{revoke:o,proxy:l}=Proxy.revocable(r,i);return s.draft_=l,s.revoke_=o,l}var Ye={get(e,t){if(t===z)return e;const n=q(e);if(!Fe(n,t))return _s(e,n,t);const s=n[t];return e.finalized_||!Z(s)?s:s===Me(e.base_,t)?(Ne(e),e.copy_[t]=Ue(s,e)):s},has(e,t){return t in q(e)},ownKeys(e){return Reflect.ownKeys(q(e))},set(e,t,n){const s=xt(q(e),t);if(s!=null&&s.set)return s.set.call(e.draft_,n),!0;if(!e.modified_){const r=Me(q(e),t),i=r==null?void 0:r[z];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(ms(n,r)&&(n!==void 0||Fe(e.base_,t)))return!0;Ne(e),ze(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Me(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ne(e),ze(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=q(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},defineProperty(){V(11)},getPrototypeOf(e){return se(e.base_)},setPrototypeOf(){V(12)}},de={};pe(Ye,(e,t)=>{de[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});de.deleteProperty=function(e,t){return de.set.call(this,e,t,void 0)};de.set=function(e,t,n){return Ye.set.call(this,e[0],t,n,e[0])};function Me(e,t){const n=e[z];return(n?q(n):e)[t]}function _s(e,t,n){var r;const s=xt(t,n);return s?"value"in s?s.value:(r=s.get)==null?void 0:r.call(e.draft_):void 0}function xt(e,t){if(!(t in e))return;let n=se(e);for(;n;){const s=Object.getOwnPropertyDescriptor(n,t);if(s)return s;n=se(n)}}function ze(e){e.modified_||(e.modified_=!0,e.parent_&&ze(e.parent_))}function Ne(e){e.copy_||(e.copy_=je(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var xs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,s)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const o=this;return function(a=i,...u){return o.produce(a,c=>n.call(this,c,...u))}}typeof n!="function"&&V(6),s!==void 0&&typeof s!="function"&&V(7);let r;if(Z(t)){const i=rt(this),o=Ue(t,void 0);let l=!0;try{r=n(o),l=!1}finally{l?ke(i):Ge(i)}return st(i,s),ot(r,i)}else if(!t||typeof t!="object"){if(r=n(t),r===void 0&&(r=t),r===ht&&(r=void 0),this.autoFreeze_&&He(r,!0),s){const i=[],o=[];K("Patches").generateReplacementPatches_(t,r,i,o),s(i,o)}return r}else V(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...l)=>this.produceWithPatches(o,a=>t(a,...l));let s,r;return[this.produce(t,n,(o,l)=>{s=o,r=l}),s,r]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Z(e)||V(8),re(e)&&(e=Es(e));const t=rt(this),n=Ue(e,void 0);return n[z].isManual_=!0,Ge(t),n}finishDraft(e,t){const n=e&&e[z];(!n||!n.isManual_)&&V(9);const{scope_:s}=n;return st(s,t),ot(void 0,s)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}n>-1&&(t=t.slice(n+1));const s=K("Patches").applyPatches_;return re(e)?s(e,t):this.produce(e,r=>s(r,t))}};function Ue(e,t){const n=Ae(e)?K("MapSet").proxyMap_(e,t):Ce(e)?K("MapSet").proxySet_(e,t):ys(e,t);return(t?t.scope_:_t()).drafts_.push(n),n}function Es(e){return re(e)||V(10,e),Et(e)}function Et(e){if(!Z(e)||Pe(e))return e;const t=e[z];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=je(e,t.scope_.immer_.useStrictShallowCopy_)}else n=je(e,!0);return pe(n,(s,r)=>{yt(n,s,Et(r))}),t&&(t.finalized_=!1),n}var U=new xs,xe=U.produce;U.produceWithPatches.bind(U);U.setAutoFreeze.bind(U);U.setUseStrictShallowCopy.bind(U);U.applyPatches.bind(U);U.createDraft.bind(U);U.finishDraft.bind(U);const Tt="TOGGLE_ZOOM",St="TOGGLE_PAN",Lt="TOGGLE_POINTS",Ot="TOGGLE_LINE",At="TOGGLE_LEGEND",Ct="TOGGLE_TABLE",Pt="SAVE_INITIAL_AXES_RANGES",Dt="RESET_AXES_RANGES",Ee="UPDATE_AXES_RANGES",wt="TOGGLE_DRAG_POINTS",Mt="TOGGLE_DRAG_ANNOTATION",Nt="DISABLE_DRAG_OPTIONS",Ts=(e,t)=>xe(e,n=>{switch(t.type){case Tt:{n.zoomEnabled=!n.zoomEnabled,n.panEnabled&&(n.panEnabled=!1),n.enableDragPoints&&(n.enableDragPoints=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case St:{n.panEnabled=!n.panEnabled,n.zoomEnabled&&(n.zoomEnabled=!1),n.enableDragPoints&&(n.enableDragPoints=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Lt:{n.pointsEnabled=!n.pointsEnabled;break}case Ot:{n.lineEnabled=!n.lineEnabled;break}case At:{n.legendEnabled=!n.legendEnabled;break}case Ct:{n.showTable=!n.showTable;break}case Pt:{const{initialAxesRanges:s}=t.payload;n.initialAxesRanges=s;break}case Ee:{const{axes:s}=t.payload;n.axes=s;break}case Dt:{const{initialAxesRanges:s}=n;n.axes=[...s];break}case wt:{n.enableDragPoints=!n.enableDragPoints,n.panEnabled&&(n.panEnabled=!1),n.zoomEnabled&&(n.zoomEnabled=!1),n.enableDragAnnotation&&(n.enableDragAnnotation=!1);break}case Mt:{n.enableDragAnnotation=!n.enableDragAnnotation,n.panEnabled&&(n.panEnabled=!1),n.zoomEnabled&&(n.zoomEnabled=!1);break}case Nt:{(n.enableDragAnnotation||n.enableDragPoints||n.panEnabled||n.zoomEnabled)&&(n.enableDragAnnotation=!1,n.enableDragPoints=!1,n.panEnabled=!1,n.zoomEnabled=!1);break}}}),Ss=(e,t)=>e===void 0||t===void 0||Number(e)<Number(t),Ls=(e,t)=>e===void 0||t===void 0||Number(e)>Number(t),Te=(e,t=0,n=!1)=>{const s=n&&t!==0?t+1:"";return`${e}${s}`},Os=e=>{var t;return((t=e==null?void 0:e.match(/[^0-9/]+/gi))==null?void 0:t[0])??""},As=e=>e.join(""),Wr=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Cs=e=>e?Object.values(e).some(t=>!Ht(t)):!1,Ps=e=>{if(!e)return null;const t=`line-chart-state-${e}`,n=localStorage.getItem(t);return n?JSON.parse(n).state:null},Ds=(e=72)=>{const t=new Date().getTime(),n=e*60*60*1e3;for(let s=0;s<localStorage.length;s++){const r=localStorage.key(s);if(r!=null&&r.includes("line-chart-state-")){const i=localStorage.getItem(r);if(i){const l=JSON.parse(i).timestamp;l&&t-l>n&&localStorage.removeItem(r)}}}},ws=(e,t)=>{if(!t)return;const n=new Date().getTime(),s=`line-chart-state-${t}`,r={state:e,timestamp:n};localStorage.setItem(s,JSON.stringify(r)),Ds()},Ms=({options:e,persistenceId:t})=>{const{additionalAxesOptions:{range:n={}},axes:s,chartOptions:{enableZoom:r,enablePan:i,showPoints:o,showLine:l,enableDragAnnotation:a},legend:{display:u},dragData:c}=e,f=(m,b)=>{var E,P,N,D,j;if(!s[m])return[];if(((E=s[m])==null?void 0:E.length)>1)return s[m].map((M,F)=>{var G,w;const I=Te(m,F,s[m].length>1),v=(G=b==null?void 0:b[I])==null?void 0:G.min,B=(w=b==null?void 0:b[I])==null?void 0:w.max,{unit:k}=M;return{id:I,...v?{min:v}:{},...B?{max:B}:{},...k?{unit:k}:{}}});{const M=Te(m),F=(P=b==null?void 0:b[M])==null?void 0:P.min,I=(N=b==null?void 0:b[M])==null?void 0:N.max,v=(j=(D=s==null?void 0:s[M])==null?void 0:D[0])==null?void 0:j.unit;return[{id:M,...F?{min:F}:{},...I?{max:I}:{},...v?{unit:v}:{}}]}},h=f(H.X,n),d=f(H.Y,n),y=[...h,...d],{zoomEnabled:_,panEnabled:p,pointsEnabled:g,lineEnabled:T,legendEnabled:A,enableDragPoints:S,enableDragAnnotation:L}=Ps(t)||{};return{zoomEnabled:a??L?!1:_??r,panEnabled:p??i,pointsEnabled:g??o,lineEnabled:T??l,legendEnabled:A??u,axes:y,showTable:!1,enableDragPoints:(c==null?void 0:c.enableDragData)&&S,enableDragAnnotation:a??L,initialAxesRanges:[]}},Ns=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...e},O.createElement("clipPath",{id:"a"},O.createElement("path",{d:"m0 0h12v12h-12z"})),O.createElement("g",{clipPath:"url(#a)"},O.createElement("path",{d:"m.5 6.5v-1h11v1c-4.16104 0-6.63549 0-11 0z"}))),Is=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e},O.createElement("circle",{cx:6,cy:6,r:2})),vs=e=>O.createElement("svg",{fill:"currentColor",height:"1em",viewBox:"0 0 12 12",width:"1em",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...e},O.createElement("clipPath",{id:"a"},O.createElement("path",{d:"m0 0h12v12h-12z"})),O.createElement("g",{clipPath:"url(#a)"},O.createElement("path",{d:"m7.937 6.5c-.11122.42912-.36179.80916-.71237 1.08047-.35058.2713-.78133.4185-1.22463.4185s-.87405-.1472-1.22463-.4185c-.35058-.27131-.60115-.65135-.71237-1.08047h-3.563v-1h3.563c.11122-.42912.36179-.80916.71237-1.08046s.78133-.41851 1.22463-.41851.87405.14721 1.22463.41851.60115.65134.71237 1.08046h3.563v1z"})));function Fs({lineEnabled:e,onToggleLine:t,onTogglePoints:n,pointsEnabled:s,translations:r}){return[{type:"Option",label:r.pointsLines,icon:x.jsx(De,{icon:x.jsx(vs,{})}),selected:s&&e,onClick:()=>{s||n(),e||t()}},{type:"Option",label:r.linesOnly,icon:x.jsx(De,{icon:x.jsx(Ns,{})}),selected:!s&&e,onClick:()=>{s&&n(),e||t()}},{type:"Option",label:r.pointsOnly,icon:x.jsx(De,{icon:x.jsx(Is,{})}),selected:s&&!e,onClick:()=>{s||n(),e&&t()}}]}const It=({options:e})=>{const[t,n]=O.useState(!1),s=e.find(r=>r.selected);return x.jsx(Xe,{open:t,setOpen:n,menu:{sections:e,trigger:"Component",component:x.jsx(he,{display:"inline-flex",text:s==null?void 0:s.label,placement:"bottom-start",enabled:!t,children:x.jsx(W,{colored:"muted",basic:!0,small:!0,round:!0,icon:s==null?void 0:s.icon})})}})};It.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function js({onTogglePan:e,onToggleZoom:t,panEnabled:n,zoomEnabled:s,enableDragPoints:r,enableDragAnnotation:i,isDragDataAllowed:o,isDragAnnotationAllowed:l,onToggleDragAnnotation:a,onToggleDragPoints:u,onDisableDragOptions:c,translations:{dragToZoom:f,doubleClickToReset:h,dragToPan:d,dragToMovePoints:y,dragDisabled:_,dragToMoveAnnotation:p}}){return[{label:f,description:h,icon:x.jsx(On,{}),selected:s,type:"Option",onClick:()=>{s||t()}},{label:d,description:h,icon:x.jsx(An,{}),selected:n,type:"Option",onClick:()=>{n||e()}},...o?[{label:y,icon:x.jsx(Qe,{}),selected:r,type:"Option",onClick:()=>{r||u()}}]:[],...l?[{label:p,icon:x.jsx(Qe,{}),selected:i,type:"Option",onClick:()=>{i||a()}}]:[],{label:_,icon:x.jsx(Cn,{}),selected:!s&&!n&&!r&&!i,type:"Option",onClick:c}]}const vt=({options:e})=>{const t=e.find(n=>n.selected);return x.jsx(Xe,{menu:{sections:e,trigger:"Component",component:x.jsx(W,{colored:"muted",basic:!0,small:!0,label:t==null?void 0:t.label,icon:t==null?void 0:t.icon})}})};vt.__docgenInfo={description:"@param {import('./drag-options-interfaces').IDragOptions} obj",methods:[],displayName:"DragOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};const ks="_controls_1edjs_1",Gs="_buttons_1edjs_6",it={controls:ks,buttons:Gs},zs=e=>{const t=O.useCallback(s=>()=>{e({type:s})},[e]);return{onToggleLegend:t(At),onToggleLine:t(Ot),onTogglePan:t(St),onTogglePoints:t(Lt),onToggleTable:t(Ct),onToggleZoom:t(Tt),onToggleDragPoints:t(wt),onToggleDragAnnotation:t(Mt),onDisableDragOptions:t(Nt)}},We=({chartRef:e,state:t,options:n,dispatch:s,generatedDatasets:r})=>{const{interactions:{onHover:i,onUnhover:o},axes:l}=n,a=O.useCallback(()=>{const g=e==null?void 0:e.current;g==null||g.resetZoom(),s({type:"RESET_AXES_RANGES"})},[e]),u=O.useCallback((g,T)=>(A,S)=>{if(!(S!=null&&S.length)&&o&&g&&(T(null),o(A)),S!=null&&S.length&&i){const{index:L,datasetIndex:m}=S[0],b=r[m],E=b==null?void 0:b.data[L];E&&g!==E&&(T(E),i(A,m,L,r))}},[]),c=O.useCallback(()=>ts(e,t),[e,t.axes]),f=O.useCallback(g=>{var T,A,S,L,m;if(g.key===Ze.Shift){const b=e.current,E=(S=(A=(T=b==null?void 0:b.config)==null?void 0:T.options)==null?void 0:A.plugins)==null?void 0:S.zoom;(L=E==null?void 0:E.zoom)!=null&&L.mode&&((m=E==null?void 0:E.pan)!=null&&m.mode)&&(E.zoom.mode=ee.Y,E.pan.mode=ee.Y,b==null||b.update())}},[e]),h=O.useCallback(g=>{var T,A,S,L,m;if(g.key===Ze.Shift){const b=e.current,E=(S=(A=(T=b==null?void 0:b.config)==null?void 0:T.options)==null?void 0:A.plugins)==null?void 0:S.zoom;(L=E==null?void 0:E.zoom)!=null&&L.mode&&((m=E==null?void 0:E.pan)!=null&&m.mode)&&(E.zoom.mode=ee.XY,E.pan.mode=ee.XY,b==null||b.update())}},[e]),d=O.useCallback(g=>{var S;if(!((S=Object.keys(g))!=null&&S.length))return[];const T=(L,m)=>{var b;return!L[m]||!((b=L[m])!=null&&b.length)?[]:L[m].map((E,P)=>({id:Te(m,P,L[m].length>1),label:(E==null?void 0:E.label)||""}))};return[...T(g,H.X),...T(g,H.Y)]},[l]),y=O.useCallback(()=>{var A;const{scales:g={}}=(e==null?void 0:e.current)||{},T=(A=Object.entries(g))==null?void 0:A.map(([S,{min:L,max:m}])=>({id:S,min:L??0,max:m??0}));s({type:Ee,payload:{axes:T}})},[l]),_=O.useCallback(()=>{s({type:Dt})},[]),p=O.useCallback(({axes:g})=>{s({type:Ee,payload:{axes:g}})},[]);return{resetZoom:a,onHover:u,handleDownload:c,handleKeyDown:f,handleKeyUp:h,controlsAxesLabels:d(l),updateAxesRangesFromChart:y,onResetAxes:_,onUpdateAxes:p}};var $=(e=>(e.Reset="reset",e.ValueUpdated="valueUpdated",e.UnitUpdated="unitUpdated",e))($||{});const Ft=({initialAxesRanges:e,axes:t=[]})=>(e==null?void 0:e.map(n=>{const s=t.find(r=>r.id===n.id);return{id:n.id,min:(s==null?void 0:s.min)??(n==null?void 0:n.min),max:(s==null?void 0:s.max)??(n==null?void 0:n.max),unit:s==null?void 0:s.unit}}))||[],Us=e=>e==="",at=(e,t,n)=>{const s=[];return Us(e)&&s.push("mustHaveAValue"),n==="min"&&!Ss(e,t)?s.push("mustBeLessThanMax"):n==="max"&&!Ls(e,t)&&s.push("mustBeGreaterThanMin"),s},Bs=e=>e.reduce((t,{id:n,min:s,max:r})=>xe(t,i=>{var l;const o={min:at(String(s),String(r),"min"),max:at(String(r),String(s),"max")};(l=i==null?void 0:i.errors)==null||l.push({id:n,...o}),i.valid=!(!t.valid||o.min.length||o.max.length)}),{errors:[],valid:!0}),Vs=(e,t)=>{switch(t.type){case $.Reset:{const{initialAxesRanges:n,axes:s}=t.payload;return Ft({initialAxesRanges:n,axes:s})}case $.ValueUpdated:return xe(e,n=>{const{name:s,value:r,id:i}=t.payload,o=n.find(l=>l.id===i);o&&r&&(o[s]=r)});case $.UnitUpdated:return xe(e,n=>{var l;const{name:s,value:r,id:i}=t.payload,o=(l=n.find(a=>a.id===i))==null?void 0:l.unit;o&&s&&(o[s]=r)});default:return e}},Rs=e=>{var L;const{initialAxesRanges:t,axes:n,controlsAxesLabels:s,onUpdateAxes:r,onResetAxes:i,depthType:o,translations:l,close:a}=e,[u,c]=O.useState(o==null?void 0:o.selectedDepthType),[f,h]=O.useReducer(Vs,{axes:n,initialAxesRanges:t},Ft),{errors:d,valid:y}=Bs(f),_=({name:m,value:b,id:E})=>{h({type:$.ValueUpdated,payload:{name:m,value:b,id:E}})},p=({name:m,value:b,id:E})=>{h({type:$.UnitUpdated,payload:{name:m,value:b,id:E}})},g=m=>{if(m.preventDefault(),y){const b=f.map(E=>({...E,min:typeof E.min=="string"?Number(E.min):E.min,max:typeof E.max=="string"?Number(E.max):E.max}));r({axes:b}),b.map((E,P)=>{var D,j,M;const N=(D=E.unit)==null?void 0:D.selectedUnit;N&&((M=(j=n==null?void 0:n[P])==null?void 0:j.unit)==null||M.setSelectedUnit(N))}),o&&(o!=null&&o.setSelectedDepthType)&&(o==null||o.setSelectedDepthType(u))}a==null||a()},T=()=>{h({type:$.Reset,payload:{axes:n,initialAxesRanges:t}}),t.map((m,b)=>{var P,N,D;const E=(P=m.unit)==null?void 0:P.selectedUnit;E&&((D=(N=n==null?void 0:n[b])==null?void 0:N.unit)==null||D.setSelectedUnit(E))}),i(),a==null||a()},A=n.filter(m=>m.max||m.min).length>0,S=m=>m.target.select();return x.jsxs("form",{onSubmit:g,children:[n.map((m,b)=>{var B,k,G;const E=s.find(w=>w.id===m.id),P=E==null?void 0:E.label,N=f.find(w=>w.id===m.id),D=d==null?void 0:d.find(w=>w.id===m.id),{min:j,max:M,unit:F}=N||{},I=(B=D==null?void 0:D.min)!=null&&B[0]?l[D.min[0]]:null,v=(k=D==null?void 0:D.max)!=null&&k[0]?l[D.max[0]]:null;return x.jsx(wn,{label:P||m.id||"",children:x.jsxs(Mn,{small:!0,width:"300px",children:[x.jsx(et,{name:"min",value:j,error:I,width:"100%",onChange:w=>_({name:w.target.name,value:w.target.value,id:m.id}),onFocus:S}),x.jsx(Nn,{children:"to"}),x.jsx(et,{name:"max",value:M,error:v,width:"100%",onChange:w=>_({name:w.target.name,value:w.target.value,id:m.id}),onFocus:S}),m.unit?x.jsx(In,{name:"selectedUnit",options:(G=m==null?void 0:m.unit)==null?void 0:G.options,value:typeof F!="string"?F==null?void 0:F.selectedUnit:void 0,onChange:w=>{p({name:w.target.name,value:w.target.value,id:m.id})},autoLayerWidth:!0,width:"15%"}):null]})},b)}),((L=o==null?void 0:o.options)==null?void 0:L.length)>0?x.jsxs(x.Fragment,{children:[x.jsx(vn,{items:o.options.map((m,b)=>({key:b,label:m})),onSelected:m=>{c(o.options[m])},small:!0,value:o.options.indexOf(u)}),x.jsx(Fn,{})]}):null,x.jsxs(jn,{gap:"8px",alignItems:"center",children:[x.jsx(W,{type:"submit",small:!0,colored:!0,label:l.done,disabled:!y}),x.jsx(W,{small:!0,name:"resetAxes",label:l.resetAxes,onClick:T,disabled:!A}),x.jsx(bt,{small:!0,muted:!0,children:l.orDoubleClickToCanvas})]})]})},jt=e=>{const{initialAxesRanges:t,axes:n,controlsAxesLabels:s,onUpdateAxes:r,onResetAxes:i,depthType:o,translations:l}=e;return x.jsx(Pn,{placement:"bottom-start",overflowContainer:!0,content:x.jsx(Rs,{initialAxesRanges:t,axes:n,controlsAxesLabels:s,onUpdateAxes:r,onResetAxes:i,depthType:o,translations:l}),children:x.jsx(he,{text:l.axesOptions,placement:"bottom-start",display:"inline-flex",children:x.jsx(W,{small:!0,basic:!0,colored:"muted",round:!0,icon:x.jsx(Dn,{})})})})};jt.__docgenInfo={description:"",methods:[],displayName:"AxesOptions",props:{initialAxesRanges:{required:!0,tsType:{name:"Array",elements:[{name:"IInitAxisRange"}],raw:"IInitAxisRange[]"},description:""},axes:{required:!0,tsType:{name:"Array",elements:[{name:"IAxisState"}],raw:"IAxisState[]"},description:""},controlsAxesLabels:{required:!0,tsType:{name:"Array",elements:[{name:"IAxisControlLabel"}],raw:"IAxisControlLabel[]"},description:""},onUpdateAxes:{required:!0,tsType:{name:"signature",type:"function",raw:"({ axes }: { axes: IAxisState }) => void",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ axes: IAxisState }",signature:{properties:[{key:"axes",value:{name:"IAxisState",required:!0}}]}},name:""}],return:{name:"void"}}},description:""},onResetAxes:{required:!0,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},depthType:{required:!1,tsType:{name:"union",raw:"IDepthType | object",elements:[{name:"IDepthType"},{name:"object"}]},description:""},close:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},translations:{required:!0,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""}}};const kt=({headerComponent:e,subheaderComponent:t,table:n,chartRef:s,state:r,options:i,dispatch:o,generatedDatasets:l,translations:a,controlsPortalId:u})=>{const{enableDragPoints:c,initialAxesRanges:f,lineEnabled:h,panEnabled:d,pointsEnabled:y,showTable:_,zoomEnabled:p,enableDragAnnotation:g}=r,{dragData:T,depthType:A,annotations:S}=i,{onToggleLine:L,onTogglePan:m,onTogglePoints:b,onToggleTable:E,onToggleZoom:P,onToggleDragPoints:N,onToggleDragAnnotation:D,onDisableDragOptions:j}=zs(o),{handleDownload:M,controlsAxesLabels:F,onResetAxes:I,onUpdateAxes:v}=We({chartRef:s,state:r,options:i,dispatch:o,generatedDatasets:l}),[B,{width:k}]=kn(),G=k<200,w=O.useMemo(()=>Fs({lineEnabled:h,onToggleLine:L,onTogglePoints:b,pointsEnabled:y,translations:a}),[h,y]),oe=O.useMemo(()=>js({onTogglePan:m,onToggleZoom:P,panEnabled:d,zoomEnabled:p,enableDragPoints:c,enableDragAnnotation:g,isDragDataAllowed:T==null?void 0:T.enableDragData,isDragAnnotationAllowed:S==null?void 0:S.enableDragAnnotation,onToggleDragAnnotation:D,onToggleDragPoints:N,onDisableDragOptions:j,translations:a}),[p,d,c,T==null?void 0:T.enableDragData,S==null?void 0:S.enableDragAnnotation]);return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:it.controls,children:[!!i.title&&x.jsx(bt,{bold:!0,children:i.title}),e,x.jsx(ns,{controlsPortalId:u??"",children:x.jsxs("div",{className:it.buttons,ref:B,children:[!_&&x.jsxs(x.Fragment,{children:[x.jsx(jt,{initialAxesRanges:f,axes:r.axes,controlsAxesLabels:F,onUpdateAxes:v,onResetAxes:I,depthType:A,translations:a}),G?x.jsx(Xe,{menu:{placement:"bottom-end",sections:[...w,{type:"Divider"},...oe,{type:"Divider"},{icon:"download",label:a.downloadAsPNG,type:"Option",onClick:M}],trigger:"Component",component:x.jsx(W,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):x.jsxs(x.Fragment,{children:[x.jsx(It,{options:w}),x.jsx(he,{display:"inline-flex",text:a.downloadAsPNG,placement:"bottom-end",children:x.jsx(W,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:M})}),x.jsx(vt,{options:oe})]})]}),n?x.jsx(he,{display:"inline-flex",text:_?a.showChart:a.showTable,placement:"bottom-end",children:x.jsx(W,{small:!0,basic:!0,colored:"muted",round:!0,icon:_?"chart":"table",onClick:E})}):null]})})]}),t]})};kt.__docgenInfo={description:"@param {import('./controls-interfaces').IControls} obj",methods:[],displayName:"Controls",props:{headerComponent:{required:!1,tsType:{name:"ReactNode"},description:""},subheaderComponent:{required:!1,tsType:{name:"Element"},description:""},table:{required:!1,tsType:{name:"ReactNode"},description:""},chartRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"Chart"}],raw:"RefObject<Chart>"},description:""},state:{required:!0,tsType:{name:"IState"},description:""},options:{required:!0,tsType:{name:"ILineChartOptions"},description:""},dispatch:{required:!0,tsType:{name:"Dispatch",elements:[{name:"any"}],raw:"Dispatch<any>"},description:""},generatedDatasets:{required:!0,tsType:{name:"Array",elements:[{name:"IGeneratedLineChartDataset"}],raw:"IGeneratedLineChartDataset[]"},description:""},translations:{required:!0,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""},controlsPortalId:{required:!1,tsType:{name:"string"},description:""}}};const R={TOP_LEFT:"top-left",TOP_CENTER:"top-center",TOP_RIGHT:"top-right",MIDDLE_LEFT:"middle-left",MIDDLE_CENTER:"middle-center",MIDDLE_RIGHT:"middle-right",BOTTOM_LEFT:"bottom-left",BOTTOM_CENTER:"bottom-center",BOTTOM_RIGHT:"bottom-right"},ct=e=>({label:"",position:e,color:"",unit:{options:[],selectedUnit:"",setSelectedUnit:()=>{}}}),Xs=e=>({x:(e==null?void 0:e.x)||[ct("bottom")],y:(e==null?void 0:e.y)||[ct("left")]}),Hs=e=>({chartScaleType:(e==null?void 0:e.chartScaleType)||"linear",reverse:(e==null?void 0:e.reverse)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!1,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,range:e==null?void 0:e.range,autoAxisPadding:(e==null?void 0:e.autoAxisPadding)??!1}),Ys=e=>({width:e==null?void 0:e.width,height:e==null?void 0:e.height,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)??!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)??!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,squareAspectRatio:(e==null?void 0:e.squareAspectRatio)??!1,layoutPadding:(e==null?void 0:e.layoutPadding)||{top:0,bottom:20,left:0,right:0}}),Ws=e=>({tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)??!1,hideSimulationName:(e==null?void 0:e.hideSimulationName)??!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),qs=e=>({lineTension:(e==null?void 0:e.lineTension)??.01,spanGaps:(e==null?void 0:e.spanGaps)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1,showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1}),$s=e=>e?e.map(t=>({...t,display:(t==null?void 0:t.display)??!0})):[],Zs=e=>{var t,n,s,r,i,o,l,a;return{labelAnnotation:{showLabel:((t=e==null?void 0:e.labelAnnotation)==null?void 0:t.showLabel)??!1,text:((n=e==null?void 0:e.labelAnnotation)==null?void 0:n.text)??"",position:((s=e==null?void 0:e.labelAnnotation)==null?void 0:s.position)??R.BOTTOM_RIGHT,fontSize:((r=e==null?void 0:e.labelAnnotation)==null?void 0:r.fontSize)??12,xOffset:((i=e==null?void 0:e.labelAnnotation)==null?void 0:i.xOffset)??5,yOffset:((o=e==null?void 0:e.labelAnnotation)==null?void 0:o.yOffset)??5,maxWidth:((l=e==null?void 0:e.labelAnnotation)==null?void 0:l.maxWidth)??300,lineHeight:((a=e==null?void 0:e.labelAnnotation)==null?void 0:a.lineHeight)??12},showAnnotations:(e==null?void 0:e.showAnnotations)??!1,controlAnnotation:(e==null?void 0:e.controlAnnotation)??!1,enableDragAnnotation:(e==null?void 0:e.enableDragAnnotation)??!1,annotationsData:$s(e==null?void 0:e.annotationsData)}},Ks=e=>({display:(e==null?void 0:e.display)??!0,position:(e==null?void 0:e.position)??ie.BottomLeft,align:(e==null?void 0:e.align)??X.Center,customLegend:(e==null?void 0:e.customLegend)??{customLegendPlugin:null,customLegendContainerID:""},usePointStyle:(e==null?void 0:e.usePointStyle)??!0}),Js=e=>({showPoints:(e==null?void 0:e.showPoints)??!0,showLine:(e==null?void 0:e.showLine)??!0,enableZoom:(e==null?void 0:e.enableZoom)??!0,enablePan:(e==null?void 0:e.enablePan)??!1,enableDragAnnotation:(e==null?void 0:e.enableDragAnnotation)??!1,closeOnOutsideClick:(e==null?void 0:e.closeOnOutsideClick)??!1}),Qs=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),er=e=>({enableDragData:(e==null?void 0:e.enableDragData)??!1,showTooltip:(e==null?void 0:e.showTooltip)??!0,roundPoints:(e==null?void 0:e.roundPoints)??!0,dragX:(e==null?void 0:e.dragX)??!0,dragY:(e==null?void 0:e.dragY)??!0,onDragStart:e==null?void 0:e.onDragStart,onDrag:e==null?void 0:e.onDrag,onDragEnd:e==null?void 0:e.onDragEnd}),Gt=e=>{const t=(e==null?void 0:e.chart)||{},n=(t==null?void 0:t.options)||{};return{persistenceId:(t==null?void 0:t.persistenceId)??"",controlsPortalId:(t==null?void 0:t.controlsPortalId)??"",testId:(t==null?void 0:t.testId)??void 0,data:t==null?void 0:t.data,options:{title:(n==null?void 0:n.title)??"",scales:(n==null?void 0:n.scales)??{},axes:Xs(n==null?void 0:n.axes),additionalAxesOptions:Hs(n==null?void 0:n.additionalAxesOptions),chartStyling:Ys(n==null?void 0:n.chartStyling),tooltip:Ws(n==null?void 0:n.tooltip),graph:qs(n==null?void 0:n.graph),annotations:Zs(n==null?void 0:n.annotations),legend:Ks(n==null?void 0:n.legend),chartOptions:Js(n==null?void 0:n.chartOptions),interactions:Qs(n==null?void 0:n.interactions),dragData:er(n==null?void 0:n.dragData),depthType:(n==null?void 0:n.depthType)??{}}}},tr=(e,t)=>{if(C.isEmpty(e)||C.isEmpty(t))return!1;const n=s=>typeof t=="string"?s&&C.has(s,t):C.isArray(t)?s&&C.some(t,r=>s&&C.has(s,r)):s&&C.some(Object.values(t),r=>s&&C.has(s,r));return C.isArray(e)?C.some(e,n):n(e)};var zt=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(zt||{});const nr=(e,t,n,{label:s})=>{const r=[...e??[]],{annotations:i,graph:o}=n??{},{controlAnnotation:l,showAnnotations:a,annotationsData:u=[]}=i??{};if(l&&a){const c=u.map((f,h)=>{const{type:d,...y}=f,_=y.color??te[h],p=Yt,g=Ve.INITIAL;return{...y,isAnnotation:!0,annotationType:d,label:y.label,annotationIndex:h,backgroundColor:_,pointBackgroundColor:_,borderColor:_,borderDash:p,borderWidth:g,data:[{}]}});r.push(...c)}return r==null?void 0:r.map((c,f)=>{var w,oe;const{formation:h,data:d=[],pointRadius:y,pointHoverRadius:_,borderWidth:p,borderColor:g,backgroundColor:T,pointBackgroundColor:A,borderDash:S,showPoints:L,showLine:m}=c??{},{lineEnabled:b,pointsEnabled:E,axes:P=[]}=t??{},{lineTension:N,spanGaps:D}=o??{};if(h){const qe=(w=P[0])==null?void 0:w.min,$e=(oe=P[0])==null?void 0:oe.max,[fe,me]=d;qe&&(fe!=null&&fe.x)&&(d[0].x=Math.max(qe,fe.x)),$e&&(me!=null&&me.x)&&(d[2].x=Math.min($e,me.x))}const j=tr(c,zt),M=d.filter(Boolean)||[],F=(M==null?void 0:M.length)===1;let I,v;L!==void 0?I=L:m===!1?I=!0:I=E||F,m!==void 0?v=m:L===!1?v=!0:v=b;const B=parseFloat(y)||zn,k=parseFloat(_)||Gn,G=te[f];return{...c,label:(c==null?void 0:c.label)??`${s} ${f+1}`,data:M,showLine:v,lineTension:(c==null?void 0:c.lineTension)??N,spanGaps:D,borderWidth:parseFloat(p)||Vn,borderDash:S||[],borderJoinStyle:Bn,borderColor:g??G??Ie(te),backgroundColor:T??Un,pointBackgroundColor:A??G??Ie(te),pointRadius:I?B:0,pointHoverRadius:k,pointHitRadius:(c==null?void 0:c.pointHitRadius)??k,...j?{hasCustomOpt:j}:{}}})},Ut=e=>e==null?void 0:e.reduce((t,n)=>({...t,[n.annotationAxis]:[...t[n.annotationAxis]||[],+n.value]}),{}),Bt=(e,t,n)=>{if(!e||!e.current)return null;const s=e.current.getSortedVisibleDatasetMetas(),r=Ut(n)[t]??[];let i=[];if(s.forEach(a=>{const u=a._parsed.map(c=>c[t]).filter(c=>c!=null&&!isNaN(c));i=i.concat(u)}),i=i.concat(r),i.length===0)return null;const o=Math.min(...i),l=Math.max(...i);return{min:o,max:l}},Be=(e,t,n,s,r=0)=>{var c,f,h,d,y,_,p;const i=s||e.axes[t][0]||{},o=n==null?void 0:n.axes.filter(g=>{var T;return(T=g==null?void 0:g.id)==null?void 0:T.startsWith(t)})[r],l=(f=(c=e==null?void 0:e.scales)==null?void 0:c[`${r===0?t:t+r}`])==null?void 0:f.ticks,{additionalAxesOptions:a}=e,u=()=>{const g=(a==null?void 0:a.chartScaleType)===qt.Logarithmic,T=(L,m,b)=>g?Zt.includes(L)?tt(L,b):"":tt(L,b);return{...g?{}:{stepSize:i.stepSize??(t===H.Y?a.stepSize:null)},callback:T,includeBounds:!1,...l,font:{size:$t}}};return{display:!0,type:a.chartScaleType,position:i.position,beginAtZero:a.beginAtZero,reverse:t===H.Y?a.reverse:!1,suggestedMax:a.suggestedMax,suggestedMin:a.suggestedMin,min:(o==null?void 0:o.min)??((d=(h=a==null?void 0:a.range)==null?void 0:h[t])==null?void 0:d.min),max:(o==null?void 0:o.max)??((_=(y=a==null?void 0:a.range)==null?void 0:y[t])==null?void 0:_.max),title:{display:(p=i.label)==null?void 0:p.length,text:i.label,padding:0},ticks:u(),grid:{...i.gridLines}}},ut=(e,t,n)=>e.axes[t].reduce((i,o,l)=>{const a=o;a.color=o.color||te[l]||Ie(te),a.position=o.position||Wt(t,l);const u=Be(e,t,n,a,l),c=Te(t,l,!0);return{...i,[c]:u}},{}),sr=(e,t)=>{var o,l;const n=((o=e.axes.x)==null?void 0:o.length)>1,s=((l=e.axes.y)==null?void 0:l.length)>1,r=n?ut(e,H.X,t):{x:Be(e,H.X,t)},i=s?ut(e,H.Y,t):{y:Be(e,H.Y,t)};return{...r,...i}},rr=e=>{var n;if(!Array.isArray(e)||!(e!=null&&e.length))return!1;const t=e==null?void 0:e.reduce((s,r)=>{var a,u,c,f;const i=(r==null?void 0:r.xAxisID)??"defaultX",o=(r==null?void 0:r.yAxisID)??"defaultY",l=(r==null?void 0:r.data)??[];if(l&&(l!=null&&l.length)){const{x:h,y:d}=(l==null?void 0:l[0])??{},{x:y=0,y:_=0}=(l==null?void 0:l.at(-1))??{},p=((a=s==null?void 0:s[i])==null?void 0:a.xFirst)??h,g=((u=s==null?void 0:s[i])==null?void 0:u.xLast)??y,T=((c=s==null?void 0:s[o])==null?void 0:c.yFirst)??d,A=((f=s==null?void 0:s[o])==null?void 0:f.yLast)??_,S=Math.min(h,p),L=Math.max(y,g),m=Math.min(d,T),b=Math.max(_,A);s={...s,[i]:{...s[i],xFirst:S,xLast:L},[o]:{yFirst:m,yLast:b}}}return s},{});return(n=Object.values(t))==null?void 0:n.some(({xFirst:s,xLast:r,yFirst:i,yLast:o})=>ae(s,r,{absoluteDiff:ce})||ae(i,o,{absoluteDiff:ce}))},dt=.05,or={min:-1,max:1},lr=({data:e,beginAtZero:t=!1,autoAxisPadding:n=!1})=>{const s=Math.min(...e.filter(d=>d!=null&&!isNaN(d))),r=Math.max(...e.filter(d=>d!=null&&!isNaN(d))),i=Math.sign(s)===-1||Math.sign(r)===-1,o=ae(s,0,{absoluteDiff:ce})&&ae(r,0,{absoluteDiff:ce});if(!(e!=null&&e.length)||o)return or;if(ae(s,r,{absoluteDiff:ce})){const d=r,y=d*dt,_=t&&!i?0:d-y,p=t&&i?0:d+y,g=ne(p,ge),T=ne(_,ge);return{min:g<0?g:T,max:T<0?T:g}}if(!n)return{min:void 0,max:void 0};const l=s===0||r===0||t,a=Math.sign(s)===-1&&Math.sign(r)===1,u=Math.abs(r-s),c=n?u*dt:0,f=!a&&l&&t&&!i?0:s-c,h=!a&&l&&t&&i?0:r+c;return{min:ne(f,ge),max:ne(h,ge)}},ir=(e,t,n)=>{var i;if(!e||!t)return{};const s=((i=e==null?void 0:e.current)==null?void 0:i.getSortedVisibleDatasetMetas())??[],r=Ut(n);return s&&(t==null?void 0:t.reduce((o,l)=>{const a=s.filter(u=>Object.values(u).includes(l)).flatMap(u=>u._parsed).map(u=>u[Os(l)]).concat((r==null?void 0:r[l])??[]);return{...o,[l]:[...new Set(a)]}},{}))},ft=(e,t)=>!C.isNil(e)||!C.isNil(t),ar=(e,t,n,s)=>{const{additionalAxesOptions:r,annotations:{annotationsData:i=[],controlAnnotation:o=!1}={}}=e||{},l=sr(e,t)||{},a=o?n.filter(({isAnnotation:h})=>!h):n;if(!(r!=null&&r.autoAxisPadding)&&!rr(a))return l;const u=Object.keys(l)??[],c=ir(s,u,i);return(c&&(u==null?void 0:u.reduce((h,d)=>{const y=l[d],{min:_=void 0,max:p=void 0}=y,{min:g,max:T}=Bt(s,d,i)??{},{min:A,max:S}=lr({data:c[d],beginAtZero:r==null?void 0:r.beginAtZero,autoAxisPadding:r==null?void 0:r.autoAxisPadding}),L={[d]:{...y,min:_??(ft(_,p)?g:A),max:p??(ft(_,p)?T:S)}};return{...h,...L}},{})))??l},cr=(e,t,n,s,r)=>{const o=e??0,l=t??0,a=n??0,u=s??0,c=r??0,f=o-100<=a,h=o+100>=u,d=o+100>=a&&o+100<u&&l+100>=c;return{overLeftSide:f,overRightSide:h,overBottomSide:d}},ur=e=>{var f;const{chart:t,dataIndex:n=0,datasetIndex:s=0}=e,{chartArea:r}=t,{left:i=null,right:o=null,bottom:l=null}=r,a=t.getDatasetMeta(s),{x:u=null,y:c=null}=((f=a==null?void 0:a.data)==null?void 0:f[n])||{};return{x:u,y:c,left:i,right:o,bottom:l}},dr=()=>e=>{const{x:t,y:n,left:s,right:r,bottom:i}=ur(e),{overLeftSide:o=!1,overRightSide:l=!1,overBottomSide:a=!1}=cr(t,n,s,r,i);return o&&X.Right||l&&X.Left||a&&X.End||X.Start},fr=e=>e.graph.showDataLabels?{display:ve,align:dr(),formatter:(t,n)=>{var r,i;const s=(i=(r=n==null?void 0:n.dataset)==null?void 0:r.data)==null?void 0:i[n==null?void 0:n.dataIndex];return s&&typeof(s==null?void 0:s.label)=="string"?s==null?void 0:s.label:""}}:{display:!1},mr=e=>{const t=e==null?void 0:e.match(/\[(.*)\]/g);return t&&(t==null?void 0:t.length)>0?t==null?void 0:t[0]:""},mt=(e,t)=>{let n={};return t?(Math.abs(e)<Rn||Math.abs(e)>Xn)&&(n={roundScientificCoefficient:3}):n={scientific:!1},tn(nn(e),n)},gr=e=>{const{scientificNotation:t}=e.tooltip,n=({xAxisID:i="",yAxisID:o=""})=>{var f,h,d;const l=(i==null?void 0:i.length)>1?Number(i[1])-1:0,a=(o==null?void 0:o.length)>1?Number(o[1])-1:0,u=e.axes.x[l],c=e.axes.y[a];return((d=(h=(f=e==null?void 0:e.axes)==null?void 0:f.x)==null?void 0:h[0])==null?void 0:d.position)===ie.Top?{titleAxisLabel:(c==null?void 0:c.label)||"",valueAxisLabel:(u==null?void 0:u.label)||"",titleLabel:J.Y,valueLabel:J.X}:{titleAxisLabel:(u==null?void 0:u.label)||"",valueAxisLabel:(c==null?void 0:c.label)||"",titleLabel:J.X,valueLabel:J.Y}},s=i=>{const o=n(i[0].dataset),{titleLabel:l,titleAxisLabel:a}=o??{},u=l===J.Y?i[0].parsed.y:i[0].parsed.x;return`${mt(u,t)} ${a}`},r=i=>{const{showLabelsInTooltips:o}=e.tooltip;let l=i.dataset.label||"";const a=n(i.dataset),{valueLabel:u="",valueAxisLabel:c=""}=a??{},h=(()=>{const _=u===J.X?i.parsed.x:i.parsed.y;return mt(_,t)})(),d=mr(c),y=en(i,o);return`${l}: ${h} ${d} ${y}`};return{enabled:e.tooltip.tooltips,mode:be.Nearest,intersect:!0,padding:Qt,usePointStyle:!0,boxWidth:Ke,boxHeight:Ke,boxPadding:Jt,callbacks:{title:s,label:r,afterLabel:Kt}}},br=({chartRef:e,state:t,options:n,dispatch:s,generatedDatasets:r})=>{const{interactions:{onAnimationComplete:i},annotations:{labelAnnotation:{showLabel:o,text:l,position:a,fontSize:u,xOffset:c,yOffset:f,maxWidth:h,lineHeight:d}={}},chartStyling:{layoutPadding:y}}=n,{enableDragPoints:_,zoomEnabled:p,panEnabled:g,lineEnabled:T}=t,[A,S]=O.useState(null),{updateAxesRangesFromChart:L,onHover:m}=We({chartRef:e,state:t,options:n,dispatch:s,generatedDatasets:r}),{legend:b,customLegendPlugin:E}=Hn({chartRef:e,options:n})??{},{state:P}=Yn()??{},{annotation:N}=P??{},D=fr(n),j=gr(n),M=O.useMemo(()=>ar(n,t,r,e),[n,t,r,e]),F=O.useMemo(()=>_&&ss(n),[_,n]),I=O.useMemo(()=>({enabled:g,mode:ee.XY,onPanComplete(){L()}}),[g]),v=O.useMemo(()=>({mode:ee.XY,drag:{enabled:p,threshold:3,backgroundColor:Wn,borderColor:Je,borderWidth:1},onZoomComplete(){L()}}),[p]),B={datalabels:D,annotationDraggerPlugin:{enabled:t==null?void 0:t.enableDragAnnotation},annotation:qn(N),zoom:{pan:I,zoom:v},tooltip:j,legend:{...b,display:!1,events:[]},customLegendPlugin:E,chartAreaBorder:{borderColor:Je},chartAreaText:{showLabel:o,text:l,position:a,fontSize:u,xOffset:c,yOffset:f,maxWidth:h,lineHeight:d},...F};return O.useMemo(()=>{var k,G,w;return{layout:{padding:y},onHover:m(A,S),maintainAspectRatio:(k=n==null?void 0:n.chartStyling)==null?void 0:k.maintainAspectRatio,aspectRatio:(G=n==null?void 0:n.chartStyling)!=null&&G.squareAspectRatio?1:0,animation:(w=n==null?void 0:n.chartStyling)!=null&&w.performanceMode?!1:{duration:rn.FAST,onComplete:i},hover:{mode:be.Nearest,intersect:!0},elements:{line:{pointStyle:sn.Circle,showLine:T,tension:0}},scales:M,plugins:B,events:Object.values(on)}},[t,n,e])},hr=({options:e,resetZoom:t})=>{const{graph:n,legend:s}=e,r=O.useCallback(C.debounce(()=>{t()},100),[t]),i=O.useCallback((o,l)=>{const{event:a}=l;a.type===$n&&r()},[r]);return O.useMemo(()=>[...ln(n,s),{id:"customEventCatcher",beforeEvent:i}],[i])},pr=1,yr=(e,t)=>{var n,s;O.useEffect(()=>{var r,i;if((i=(r=t==null?void 0:t.legend)==null?void 0:r.customLegend)!=null&&i.customLegendPlugin){const o=document.getElementById(t.legend.customLegend.customLegendContainerID);o!==null&&(o.style.visibility=e.legendEnabled?"visible":"hidden")}},[(s=(n=t==null?void 0:t.legend)==null?void 0:n.customLegend)==null?void 0:s.customLegendPlugin,e.legendEnabled])},_r=(e,t)=>{O.useEffect(()=>{ws(e,t)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},xr=({chartRef:e,range:t,state:n,dispatch:s,annotationsData:r})=>{const i=O.useRef(n.axes);O.useEffect(()=>{if(t&&Cs(t)){const o=Object.entries(t).map(([a,{min:u,max:c}])=>{const{min:f=0,max:h=0}=Bt(e,a,r)??{};let d=u??f,y=c??h;return d===y&&(y+=pr),{id:a,min:d,max:y}}),l=[...i.current??[]].map(a=>{const u=o.find(c=>c.id===a.id);return u?{...a,...u}:a});os(l,i.current)||(s({type:Ee,payload:{axes:l}}),i.current=l)}},[t])},Er=(e,t,n)=>{var i;const s=O.useRef(null),r=o=>{if(!o.length)return"";const l=o.map(a=>{const u=a.data??[];if(!u.length)return"empty";const c=u.at(0),f=u.at(-1),h=u.length;return c&&f?`${c.x},${c.y}-${f.x},${f.y}-${h}`:"invalid"});return`${o.length}-${l.join("|")}`};O.useEffect(()=>{var o;if((o=e==null?void 0:e.current)!=null&&o.scales){const l=s.current?r(s.current):"",a=r(n);if(l!==a){const u=e.current.scales,c=Object.entries(u).map(([f,{min:h,max:d,_range:y}])=>({id:f,min:(y==null?void 0:y.min)??h,max:(y==null?void 0:y.max)??d}));t({type:Pt,payload:{initialAxesRanges:c}}),s.current=n}}},[(i=e==null?void 0:e.current)==null?void 0:i.scales,n])},Tr=({chartRef:e,options:t,state:n,dispatch:s,persistenceId:r,generatedDatasets:i})=>{O.useEffect(()=>()=>{if(e!=null&&e.current){const c=e==null?void 0:e.current;c==null||c.destroy()}},[]);const o=O.useMemo(()=>n,[n]),l=O.useMemo(()=>t,[t]),{additionalAxesOptions:{range:a=void 0},annotations:{annotationsData:u=[]}={}}=l;_r(o,r),yr(o,l),xr({range:a,state:o,dispatch:s,chartRef:e,annotationsData:u}),Er(e,s,i)},Se=" ",Sr="rgba(0, 0, 0, 0.5)",Lr=e=>(Array.isArray(e)?e.join(Se):e).split(Se),Or=({ctx:e,lines:t,lineHeight:n,x:s,y:r,position:i})=>{t.forEach((o,l)=>{const a=i.includes("top")?r+n*(l+1)-5:r-(t.length-1-l)*n;e.fillText(o,s,a)})},Ar=(e,t)=>{const r=t<500?.5:t<700?.7:1;return e*r},Cr=e=>{const{legend:t}=e,n=t&&t.display&&t.options.position==="left"?t.width+t.options.labels.padding*2:0,s=t&&t.display&&(t.options.position==="top"||t.options.position==="bottom")?t.height+t.options.labels.padding*2:0;return{legendWidth:n,legendHeight:s}},Pr=(e,t,n,s)=>{const{chartArea:r,width:i}=t,o=i-8,{legendWidth:l,legendHeight:a}=Cr(t);switch(e){case R.TOP_LEFT:return[r.left+n+l,r.top+s+a];case R.TOP_CENTER:return[r.left+r.width/2,r.top+s+a];case R.TOP_RIGHT:return[o-n,r.top+s+a];case R.MIDDLE_LEFT:return[r.left+n+l,r.top+r.height/2];case R.MIDDLE_CENTER:return[r.left+r.width/2,r.top+r.height/2];case R.MIDDLE_RIGHT:return[o-n-l,r.top+r.height/2];case R.BOTTOM_LEFT:return[r.left+n+l,r.bottom-s-a];case R.BOTTOM_CENTER:return[r.left+r.width/2,r.bottom-s-a];case R.BOTTOM_RIGHT:default:return[o-n-l,r.bottom-s-a]}},Dr=e=>e.includes(X.Center)?X.Center:e.includes(X.Left)?X.Left:X.Right,wr=(e,t,n)=>{let s="",r=[];for(let i=0;i<e.length;i++){const o=`${s}${e[i]}${Se}`,{width:l}=n.measureText(o);l>t?(r.push(s.trim()),s=`${e[i]}${Se}`):s=o}return r.push(s.trim()),r},Mr=(e,t)=>{const{text:n,maxWidth:s,fontSize:r,lineHeight:i,x:o,y:l,position:a}=t,u=Lr(n),c=wr(u,s,e);e.save(),e.font=`${r}px Arial`,e.fillStyle=Sr,e.textAlign=Dr(a),Or({ctx:e,lines:c,lineHeight:i,x:o,y:l,position:a}),e.restore()},Nr={id:"chartAreaText",beforeDraw:(e,t,n)=>{const{showLabel:s,text:r,fontSize:i,xOffset:o,yOffset:l,lineHeight:a,maxWidth:u,position:c}=n;if(!s||!r)return;const{ctx:f,chartArea:h}=e,d=Ar(u,h.width),[y,_]=Pr(c,e,o,l);Mr(f,{text:r,maxWidth:d,fontSize:i,lineHeight:a,x:y,y:_,position:c})}},Vt=(e,t,n,s,r)=>{const i=t.getBoundingClientRect(),o=e.clientX-i.left,l=e.clientY-i.top,a=n[s],u=n[r],c=(a==null?void 0:a.getValueForPixel(o))??-1,f=(u==null?void 0:u.getValueForPixel(l))??-1;return{x:c,y:f}},Le=e=>{const{xMin:t,xMax:n,yMin:s,yMax:r,xValue:i,yValue:o,type:l}=e??{};let a,u,c,f;return!C.isNil(t)&&!C.isNil(n)&&!C.isNil(s)&&!C.isNil(r)&&l===Y.BOX?(a=(t+n)/2,u=(s+r)/2,c=n-t,f=r-s):!C.isNil(i)&&!C.isNil(o)&&l===Y.POINT&&(a=i,u=o,c=0,f=0),{centerX:a,centerY:u,width:c,height:f}},Rt=(e,t,n,s)=>{const{xMin:r,xMax:i,yMin:o,yMax:l,xValue:a,yValue:u,type:c}=e??{};let f,h,d,y;const _=t[n],p=t[s];if(!C.isNil(r)&&!C.isNil(i)&&!C.isNil(o)&&!C.isNil(l)&&c===Y.BOX){const g=(r+i)/2,T=(o+l)/2,A=(_==null?void 0:_.getPixelForValue(r))??0,S=(_==null?void 0:_.getPixelForValue(i))??0,L=(p==null?void 0:p.getPixelForValue(o))??0,m=(p==null?void 0:p.getPixelForValue(l))??0;d=A-S,y=L-m,f=(_==null?void 0:_.getPixelForValue(g))??-1,h=(p==null?void 0:p.getPixelForValue(T))??-1}else!C.isNil(a)&&!C.isNil(u)&&c===Y.POINT&&(d=0,y=0,f=(_==null?void 0:_.getPixelForValue(a))??-1,h=(p==null?void 0:p.getPixelForValue(u))??-1);return{centerX:f,centerY:h,width:d,height:y}},Ir=({x:e,y:t,chartArea:n,scales:s,metrics:r,resizable:i=!1,dragRange:o,annotationType:l,xScaleID:a,yScaleID:u})=>{if(i&&!o)return!0;if(o){const p=e!==void 0&&o.x?e>=o.x[0]&&e<=o.x[1]:!0,g=t!==void 0&&o.y?t>=o.y[0]&&t<=o.y[1]:!0;return p&&g}const c=s[a],f=s[u],h=(c==null?void 0:c.getValueForPixel(n.left))??Number.NEGATIVE_INFINITY,d=(c==null?void 0:c.getValueForPixel(n.right))??Number.POSITIVE_INFINITY,y=(f==null?void 0:f.getValueForPixel(n.bottom))??Number.NEGATIVE_INFINITY,_=(f==null?void 0:f.getValueForPixel(n.top))??Number.POSITIVE_INFINITY;if(l===Y.POINT){const p=e!==void 0?e>=h&&e<=d:!0,g=t!==void 0?t>=y&&t<=_:!0;return p&&g}if(l===Y.BOX&&r.width!==void 0&&r.height!==void 0){const p=e!==void 0?e-r.width/2:void 0,g=e!==void 0?e+r.width/2:void 0,T=t!==void 0?t-r.height/2:void 0,A=t!==void 0?t+r.height/2:void 0,S=p!==void 0&&g!==void 0?p>=h&&g<=d:!0,L=T!==void 0&&A!==void 0?T>=y&&A<=_:!0;return S&&L}return!0},gt=(e,t,n,s,r,i,o,l)=>{const{resizable:a,dragRange:u=null}=n??{};Ir({[e]:t,chartArea:s.chartArea,scales:r,resizable:a,dragRange:u,metrics:l||{},annotationType:n.type,xScaleID:i,yScaleID:o})&&(n.type===Y.POINT?e==="x"?n.xValue=t:e==="y"&&(n.yValue=t):n.type===Y.BOX&&l&&(e==="x"&&l.width&&(n.xMin=t-l.width/2,n.xMax=t+l.width/2),e==="y"&&l.height&&(n.yMin=t-l.height/2,n.yMax=t+l.height/2)))},Xt=(e,t,n)=>{var r,i,o;if(!t)return;const s=(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.annotation)==null?void 0:o.annotations;s&&t&&s[t]&&(s[t].borderWidth=n)},vr=(e,t,n,s,r,i)=>{const o=i?s==null?void 0:s[i]:null;if(!o)return;const{xScaleID:l="x",yScaleID:a="y"}=o,{x:u,y:c}=Vt(e,t,n,l,a),f=Le(o);if(o&&o.enableDrag&&!C.isNil(f.centerY)&&!C.isNil(f.centerX)){!C.isNil(t)&&!C.isNil(t.style)&&(t.style.cursor=Re.Move);const h=u-f.centerX,d=c-f.centerY;r(!0,o,h,d),o!=null&&o.onDragStart&&o.onDragStart({x:u,y:c},o)}},Fr=(e,t,n,s,r,i,o,l)=>{if(s&&r){!C.isNil(t)&&!C.isNil(t.style)&&(t.style.cursor=Re.Move);const a=r==null?void 0:r.id;Xt(l,a,Ve.HOVERED);const u=(r==null?void 0:r.dragAxis)??le.Both,{xScaleID:c="x",yScaleID:f="y"}=r,{x:h,y:d}=Vt(e,t,n,c,f),y=Le(r);let _=h-i,p=d-o;u!==le.Y&>(le.X,_,r,l,n,c,f,y),u!==le.X&>(le.Y,p,r,l,n,c,f,y),l.update(),r!=null&&r.onDrag&&r.onDrag({x:h,y:d},r);const{ctx:g,width:T,height:A}=l,{centerX:S,centerY:L}=Le(r)??{},{centerX:m,centerY:b}=Rt(r,n,c,f);if(!C.isNil(S)&&!C.isNil(L)&&!C.isNil(m)&&!C.isNil(b)&&(g.save(),g.clearRect(0,0,T,A),l.draw(),g.font=an,g.fillStyle="black",r!=null&&r.displayDragCoordinates)){let E=m-45,P=b-20;const N=`X: ${ne(S,2)}, Y: ${ne(L,2)}`,D=14;P-D<0&&(P=b+D+15),P>A&&(P=A-7),g.fillText(N,E,P),g.restore()}}},jr=(e,t,n,s,r)=>{if(e&&t){const i=t==null?void 0:t.id;Xt(n,i,Ve.ZERO);const{centerX:o=-1,centerY:l=-1}=Le(t)??{};C.isNil(t==null?void 0:t.onDragEnd)||t==null||t.onDragEnd({x:o,y:l},t),!C.isNil(s)&&!C.isNil(s.style)&&(s.style.cursor=Re.Pointer),r(!1,null)}},kr=(e,t,n)=>{Object.values(t).forEach(s=>{var r;if(s.type===Y.POINT&&!C.isNil(s==null?void 0:s.label)&&((r=s==null?void 0:s.label)!=null&&r.display)){const{content:i,font:o,color:l,position:a,padding:u}=(s==null?void 0:s.label)??{},{xScaleID:c="x",yScaleID:f="y"}=s;e.save(),e.font=o,e.fillStyle=l;const{centerX:h=-1,centerY:d=-1}=Rt(s,n,c,f),y=e.measureText(i).width;let _=h-y/2,p=d+20;switch(a){case ie.Top:p=d-20;break;case ie.Left:_=h-y-u,p=d;break;case ie.Right:_=h+u,p=d;break}e.fillText(i,_,p),e.restore()}})},Gr={id:"annotationDraggerPlugin",beforeDraw(e){var s,r,i,o,l,a,u,c;let t=((r=(s=e.options.plugins)==null?void 0:s.annotation)==null?void 0:r.annotations)??{};if(!t)return;kr(e.ctx,t,e.scales),(((o=(i=e==null?void 0:e.options)==null?void 0:i.plugins)==null?void 0:o.annotationDraggerPlugin)||{enabled:!1}).enabled?((a=(l=e==null?void 0:e.options)==null?void 0:l.plugins)!=null&&a.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((c=(u=e==null?void 0:e.options)==null?void 0:u.plugins)!=null&&c.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0})},afterUpdate(e){var h,d,y,_,p,g,T,A;const{canvas:t,scales:n,hoveredAnnotationId:s}=e??{},r=((d=(h=e==null?void 0:e.options)==null?void 0:h.plugins)==null?void 0:d.annotationDraggerPlugin)||{enabled:!1},i={...n,x:n.x,y:n.y};let o=((_=(y=e.options.plugins)==null?void 0:y.annotation)==null?void 0:_.annotations)??{};if(!e&&!o)return;r.enabled?((g=(p=e==null?void 0:e.options)==null?void 0:p.plugins)!=null&&g.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((A=(T=e==null?void 0:e.options)==null?void 0:T.plugins)!=null&&A.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0});let l=!1,a,u,c=null;const f=(S,L,m,b)=>{l=S,c=L,m!==void 0&&b!==void 0&&(a=m,u=b)};!t.dataset.annotationDraggerInitialized&&r.enabled&&s&&(t.addEventListener(Q.MOUSEDOWN,S=>{var L,m,b;vr(S,t,i,(b=(m=(L=e==null?void 0:e.options)==null?void 0:L.plugins)==null?void 0:m.annotation)==null?void 0:b.annotations,f,e.hoveredAnnotationId)}),t.addEventListener(Q.MOUSEMOVE,S=>{C.debounce(()=>Fr(S,t,i,l,c,a,u,e),5)()}),t.addEventListener(Q.MOUSEUP,S=>{const L=S.currentTarget;jr(l,c,e,L,f)}),t.dataset.annotationDraggerInitialized="true"),r.enabled||(t.removeEventListener(Q.MOUSEDOWN,()=>{}),t.removeEventListener(Q.MOUSEMOVE,()=>{}),t.removeEventListener(Q.MOUSEUP,()=>{}),t.dataset.annotationDraggerInitialized="")}};mn.register(gn,bn,hn,pn,yn,_n,xn,En,Tn,Sn,Ln,es,Nr,Gr);const zr=e=>{var E,P;un();const t=O.useRef(null),{table:n}=e??{},{translations:s,languageKey:r}=rs(),i=Gt(e),{data:{datasets:o}={datasets:[]},options:l,testId:a,persistenceId:u,controlsPortalId:c}=i,{annotations:f,axes:h,chartStyling:d,graph:y}=l??{},_=!((P=(E=l==null?void 0:l.legend)==null?void 0:E.customLegend)!=null&&P.customLegendContainerID),[p,g]=O.useReducer(Ts,{options:l,persistenceId:u},Ms),T=O.useMemo(()=>nr(o,p,l,s),[p.lineEnabled,p.pointsEnabled,h,f,y]);Tr({chartRef:t,options:l,state:p,dispatch:g,persistenceId:u,generatedDatasets:T});const{resetZoom:A,handleKeyDown:S,handleKeyUp:L}=We({chartRef:t,state:p,options:l,dispatch:g,generatedDatasets:T}),m=br({chartRef:t,state:p,options:l,dispatch:g,generatedDatasets:T}),b=hr({options:l,resetZoom:A});return x.jsxs("div",{className:dn(d,we),style:{width:d.width||ve,height:d.height||ve},tabIndex:0,onKeyDown:S,onKeyUp:L,"data-testid":a,children:[x.jsx(kt,{...e,chartRef:t,state:p,options:l,dispatch:g,generatedDatasets:T,translations:s,controlsPortalId:c}),n&&p.showTable?x.jsx("div",{className:we.table,children:n}):x.jsx(Zn,{backend:Kn,context:window,children:x.jsxs("div",{className:we.canvas,id:"canvas",children:[x.jsx(fn,{ref:t,data:{datasets:T},options:m,plugins:b}),_&&!!T.length&&x.jsx(Jn,{chartRef:t,legendConfig:{options:l,generatedDatasets:T,chartType:Qn.LINE}})]})})]},As([...Object.values(p),r]))},Ur=e=>{const{options:t}=Gt(e);return x.jsx(cn,{options:t,children:x.jsx(zr,{...e})})};Ur.__docgenInfo={description:"",methods:[],displayName:"LineChartWithLegend",props:{chart:{required:!0,tsType:{name:"ILineChartData"},description:""},table:{required:!1,tsType:{name:"ReactNode"},description:""}}};export{Ur as L,Wr as i};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { IState } from '../../state/state.interfaces';
|
|
2
|
-
import { IAction, IFormState, IInitializeAxisFormState } from './axes-options-interfaces.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Initialize local component form state for a custom loads density table
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} args
|
|
7
|
-
* @param {Object} args.initialAxesRanges
|
|
8
|
-
* @param {Array} [args.axes]
|
|
9
|
-
* @returns {Object} formState
|
|
10
|
-
*/
|
|
11
|
-
export declare const initializeFormState: ({ initialAxesRanges, axes, }: Partial<IState>) => IInitializeAxisFormState;
|
|
12
|
-
export declare const validateAxes: (formState: IFormState) => {
|
|
13
|
-
errors: never[];
|
|
14
|
-
valid: boolean;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Local component form state reducer for a axes options form
|
|
18
|
-
*
|
|
19
|
-
* @param {Object} state Local component form state
|
|
20
|
-
* @param {Action} action Action with type and payload
|
|
21
|
-
* @returns {Object} FormState
|
|
22
|
-
*/
|
|
23
|
-
export declare const reducer: (state: IFormState, action: IAction) => IInitializeAxisFormState;
|