@unovis/react 1.7.0-pre.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/components/annotations/index.d.ts +12 -10
- package/components/annotations/index.js +32 -27
- package/components/annotations/index.js.map +1 -1
- package/components/area/index.d.ts +13 -11
- package/components/area/index.js +33 -29
- package/components/area/index.js.map +1 -1
- package/components/axis/index.d.ts +13 -11
- package/components/axis/index.js +33 -29
- package/components/axis/index.js.map +1 -1
- package/components/boxplot/index.d.ts +13 -0
- package/components/boxplot/index.js +35 -0
- package/components/boxplot/index.js.map +1 -0
- package/components/brush/index.d.ts +13 -11
- package/components/brush/index.js +33 -29
- package/components/brush/index.js.map +1 -1
- package/components/chord-diagram/index.d.ts +17 -14
- package/components/chord-diagram/index.js +33 -29
- package/components/chord-diagram/index.js.map +1 -1
- package/components/crosshair/index.d.ts +13 -11
- package/components/crosshair/index.js +33 -29
- package/components/crosshair/index.js.map +1 -1
- package/components/donut/index.d.ts +13 -11
- package/components/donut/index.js +33 -29
- package/components/donut/index.js.map +1 -1
- package/components/free-brush/index.d.ts +13 -11
- package/components/free-brush/index.js +33 -29
- package/components/free-brush/index.js.map +1 -1
- package/components/graph/index.d.ts +39 -36
- package/components/graph/index.js +33 -29
- package/components/graph/index.js.map +1 -1
- package/components/grouped-bar/index.d.ts +13 -11
- package/components/grouped-bar/index.js +33 -29
- package/components/grouped-bar/index.js.map +1 -1
- package/components/heatmap/index.d.ts +13 -0
- package/components/heatmap/index.js +35 -0
- package/components/heatmap/index.js.map +1 -0
- package/components/line/index.d.ts +13 -11
- package/components/line/index.js +33 -29
- package/components/line/index.js.map +1 -1
- package/components/nested-donut/index.d.ts +13 -11
- package/components/nested-donut/index.js +33 -29
- package/components/nested-donut/index.js.map +1 -1
- package/components/plotband/index.d.ts +12 -10
- package/components/plotband/index.js +32 -27
- package/components/plotband/index.js.map +1 -1
- package/components/plotline/index.d.ts +12 -10
- package/components/plotline/index.js +32 -27
- package/components/plotline/index.js.map +1 -1
- package/components/radial-bar/index.d.ts +13 -0
- package/components/radial-bar/index.js +35 -0
- package/components/radial-bar/index.js.map +1 -0
- package/components/sankey/index.d.ts +17 -14
- package/components/sankey/index.js +33 -29
- package/components/sankey/index.js.map +1 -1
- package/components/scatter/index.d.ts +13 -11
- package/components/scatter/index.js +33 -29
- package/components/scatter/index.js.map +1 -1
- package/components/stacked-bar/index.d.ts +13 -11
- package/components/stacked-bar/index.js +33 -29
- package/components/stacked-bar/index.js.map +1 -1
- package/components/timeline/index.d.ts +13 -11
- package/components/timeline/index.js +33 -29
- package/components/timeline/index.js.map +1 -1
- package/components/tooltip/index.d.ts +12 -10
- package/components/tooltip/index.js +32 -27
- package/components/tooltip/index.js.map +1 -1
- package/components/topojson-map/index.d.ts +17 -15
- package/components/topojson-map/index.js +33 -29
- package/components/topojson-map/index.js.map +1 -1
- package/components/treemap/index.d.ts +13 -11
- package/components/treemap/index.js +33 -29
- package/components/treemap/index.js.map +1 -1
- package/components/xy-labels/index.d.ts +13 -11
- package/components/xy-labels/index.js +33 -29
- package/components/xy-labels/index.js.map +1 -1
- package/components.d.ts +30 -27
- package/composites/time-series/index.d.ts +55 -54
- package/composites/time-series/index.js +65 -60
- package/composites/time-series/index.js.map +1 -1
- package/composites/time-series/style.module.css.js +14 -7
- package/composites/time-series/style.module.css.js.map +1 -1
- package/composites.d.ts +1 -1
- package/containers/single-container/index.d.ts +9 -8
- package/containers/single-container/index.js +67 -49
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/index.d.ts +10 -9
- package/containers/xy-container/index.js +71 -57
- package/containers/xy-container/index.js.map +1 -1
- package/containers.d.ts +2 -2
- package/html-components/bullet-legend/index.d.ts +13 -11
- package/html-components/bullet-legend/index.js +30 -27
- package/html-components/bullet-legend/index.js.map +1 -1
- package/html-components/flow-legend/index.d.ts +13 -11
- package/html-components/flow-legend/index.js +30 -27
- package/html-components/flow-legend/index.js.map +1 -1
- package/html-components/leaflet-flow-map/index.d.ts +18 -15
- package/html-components/leaflet-flow-map/index.js +31 -29
- package/html-components/leaflet-flow-map/index.js.map +1 -1
- package/html-components/leaflet-map/index.d.ts +15 -12
- package/html-components/leaflet-map/index.js +31 -29
- package/html-components/leaflet-map/index.js.map +1 -1
- package/html-components/rolling-pin-legend/index.d.ts +13 -11
- package/html-components/rolling-pin-legend/index.js +30 -27
- package/html-components/rolling-pin-legend/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +111 -30
- package/index.js.map +1 -1
- package/package.json +25 -23
- package/types/dom.d.ts +3 -3
- package/utils/container.d.ts +5 -0
- package/utils/container.js +18 -0
- package/utils/container.js.map +1 -0
- package/utils/react.d.ts +5 -4
- package/utils/react.js +22 -29
- package/utils/react.js.map +1 -1
- package/external/style-inject/dist/style-inject.es.js +0 -29
- package/external/style-inject/dist/style-inject.es.js.map +0 -1
|
@@ -1,62 +1,67 @@
|
|
|
1
|
-
import React, { useState, useMemo } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
function VisTimeSeries(props) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import React, { useState, useMemo } from "react";
|
|
2
|
+
import { TextAlign } from "@unovis/ts/types/text";
|
|
3
|
+
import { Scale } from "@unovis/ts/types/scale";
|
|
4
|
+
import { VisXYContainer } from "../../containers/xy-container/index.js";
|
|
5
|
+
import { VisArea } from "../../components/area/index.js";
|
|
6
|
+
import { VisAxis } from "../../components/axis/index.js";
|
|
7
|
+
import { VisCrosshair } from "../../components/crosshair/index.js";
|
|
8
|
+
import { VisTooltip } from "../../components/tooltip/index.js";
|
|
9
|
+
import { VisBrush } from "../../components/brush/index.js";
|
|
10
|
+
import s from "./style.module.css.js";
|
|
11
|
+
function VisTimeSeries(props) {
|
|
12
|
+
const [selectedRange, setSelectedRange] = useState(void 0);
|
|
13
|
+
const [animationDuration, setAnimationDuration] = useState(0);
|
|
14
|
+
const xScale = useMemo(() => Scale.scaleTime(), []);
|
|
15
|
+
const xScaleNav = useMemo(() => Scale.scaleTime(), []);
|
|
16
|
+
const onBrushStart = useMemo(() => (selection, e, userDriven) => {
|
|
17
|
+
if (userDriven) setAnimationDuration(0);
|
|
18
|
+
props.onBrushStart?.(selection, e, userDriven);
|
|
19
|
+
}, []);
|
|
20
|
+
const onBrushMove = useMemo(() => (selection, e, userDriven) => {
|
|
21
|
+
if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection);
|
|
22
|
+
props.onBrushMove?.(selection, e, userDriven);
|
|
23
|
+
}, []);
|
|
24
|
+
const onBrushEnd = useMemo(() => (selection, e, userDriven) => {
|
|
25
|
+
if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection);
|
|
26
|
+
setAnimationDuration(void 0);
|
|
27
|
+
props.onBrushEnd?.(selection, e, userDriven);
|
|
28
|
+
}, []);
|
|
29
|
+
return /* @__PURE__ */ React.createElement("div", { className: `${s.timeSeriesContainer}${props.className ? `.${props.className}` : ""}`, style: { height: props.height } }, /* @__PURE__ */ React.createElement(
|
|
30
|
+
VisXYContainer,
|
|
31
|
+
{
|
|
32
|
+
className: s.timeSeriesModule,
|
|
33
|
+
data: props.data,
|
|
34
|
+
xScale,
|
|
35
|
+
xDomain: selectedRange,
|
|
36
|
+
duration: animationDuration,
|
|
37
|
+
scaleByDomain: true
|
|
38
|
+
},
|
|
39
|
+
/* @__PURE__ */ React.createElement(
|
|
40
|
+
VisArea,
|
|
41
|
+
{
|
|
42
|
+
x: props.x,
|
|
43
|
+
y: props.y,
|
|
44
|
+
color: props.color
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ React.createElement(VisAxis, { type: "x", numTicks: 5, tickFormat: props.formatXTicks, tickTextAlign: TextAlign.Center }),
|
|
48
|
+
/* @__PURE__ */ React.createElement(VisAxis, { type: "y", tickFormat: props.formatYTicks, label: props.yLabel }),
|
|
49
|
+
/* @__PURE__ */ React.createElement(VisTooltip, null),
|
|
50
|
+
/* @__PURE__ */ React.createElement(VisCrosshair, { template: props.crosshairTemplate })
|
|
51
|
+
), /* @__PURE__ */ React.createElement(VisXYContainer, { className: s.navigationModule, duration: 0, xScale: xScaleNav, data: props.data }, /* @__PURE__ */ React.createElement(VisArea, { x: props.x, y: props.y }), /* @__PURE__ */ React.createElement(VisBrush, { draggable: true, onBrushStart, onBrushMove, onBrushEnd }), /* @__PURE__ */ React.createElement(VisAxis, { type: "x", numTicks: 5, tickFormat: props.formatXTicks ?? props.formatNavXTicks, tickTextAlign: TextAlign.Right, label: props.xLabel }), /* @__PURE__ */ React.createElement(VisAxis, { type: "y", tickFormat: props.formatYTicks, minMaxTicksOnly: true, label: props.yLabel ? " " : void 0 })));
|
|
52
|
+
}
|
|
53
|
+
VisTimeSeries.defaultProps = {
|
|
54
|
+
margin: { top: 10, bottom: 10, left: 10, right: 10 },
|
|
55
|
+
autoMargin: true,
|
|
56
|
+
padding: {},
|
|
57
|
+
x: (d) => d.timestamp,
|
|
58
|
+
y: (d) => d.value,
|
|
59
|
+
id: (d) => d.id,
|
|
60
|
+
color: (d) => null,
|
|
61
|
+
formatYTicks: (d) => d.toFixed(1),
|
|
62
|
+
crosshairTemplate: (d) => `<div>Date: ${new Date(d.timestamp).toLocaleDateString()}</div><div>Value: ${d.value?.toFixed(1)}</div>`
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
VisTimeSeries
|
|
59
66
|
};
|
|
60
|
-
|
|
61
|
-
export { VisTimeSeries };
|
|
62
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/composites/time-series/index.tsx"],"sourcesContent":["import React, { useState, useMemo } from 'react'\nimport { Spacing
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/composites/time-series/index.tsx"],"sourcesContent":["import React, { useState, useMemo } from 'react'\nimport { Spacing } from '@unovis/ts/types/spacing'\nimport { TextAlign } from '@unovis/ts/types/text'\nimport { Scale } from '@unovis/ts/types/scale'\nimport { VisXYContainer } from '@unovis/react/containers/xy-container'\nimport { VisArea } from '@unovis/react/components/area'\nimport { VisAxis } from '@unovis/react/components/axis'\nimport { VisCrosshair } from '@unovis/react/components/crosshair'\nimport { VisTooltip } from '@unovis/react/components/tooltip'\nimport { VisBrush } from '@unovis/react/components/brush'\n\nimport s from './style.module.css'\n\nexport type VisTimeSeriesDatum = {\n timestamp: number;\n value: number;\n id?: string;\n color?: string;\n}\n\nexport type VisTimeSeriesProps<Datum> = {\n data: Datum[];\n margin: Spacing;\n autoMargin: boolean;\n\n x: (d: Datum, i: number) => number;\n y: (d: Datum, i: number) => number;\n id: (d: Datum, i: number) => string;\n color: (d: Datum[], i: number) => string | null;\n cursor: string | ((d: Datum, i: number) => string);\n formatXTicks?: (timestamp: number) => string;\n formatYTicks?: (timestamp: number) => string;\n\n selectionMinLength: number;\n onBrushStart?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n onBrushMove?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n onBrushEnd?: (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean) => void;\n formatNavXTicks?: (timestamp: number) => string;\n\n xLabel?: string;\n yLabel?: string;\n\n crosshairTemplate?: (d: Datum) => string | HTMLElement;\n\n className?: string;\n height?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function VisTimeSeries<Datum> (props: VisTimeSeriesProps<Datum>): JSX.Element {\n const [selectedRange, setSelectedRange] = useState<[number, number] | undefined>(undefined)\n const [animationDuration, setAnimationDuration] = useState<number | undefined>(0)\n const xScale = useMemo(() => Scale.scaleTime(), [])\n const xScaleNav = useMemo(() => Scale.scaleTime(), [])\n\n // On Mount\n // useEffect(() => {}, [])\n\n // On Props Update\n // useEffect(() => {})\n\n // Brush callbacks\n const onBrushStart = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven) setAnimationDuration(0)\n props.onBrushStart?.(selection, e, userDriven)\n }, [])\n\n const onBrushMove = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection)\n props.onBrushMove?.(selection, e, userDriven)\n }, [])\n\n const onBrushEnd = useMemo(() => (selection: [number, number], e?: { sourceEvent: MouseEvent }, userDriven?: boolean): void => {\n if (userDriven && selectedRange?.[0] !== selection[0] && selectedRange?.[1] !== selection[1]) setSelectedRange(selection)\n setAnimationDuration(undefined)\n props.onBrushEnd?.(selection, e, userDriven)\n }, [])\n\n return (\n <div className={`${s.timeSeriesContainer}${props.className ? `.${props.className}` : ''}`} style={{ height: props.height }}>\n <VisXYContainer\n className={s.timeSeriesModule}\n data={props.data}\n xScale={xScale}\n xDomain={selectedRange}\n duration={animationDuration}\n scaleByDomain={true}\n >\n <VisArea\n x={props.x}\n y={props.y}\n color={props.color}\n />\n <VisAxis type='x' numTicks={5} tickFormat={props.formatXTicks} tickTextAlign={TextAlign.Center}/>\n <VisAxis type='y' tickFormat={props.formatYTicks} label={props.yLabel}/>\n <VisTooltip />\n <VisCrosshair template={props.crosshairTemplate}/>\n </VisXYContainer>\n <VisXYContainer className={s.navigationModule} duration={0} xScale={xScaleNav} data={props.data}>\n <VisArea x={props.x} y={props.y} />\n <VisBrush draggable={true} onBrushStart={onBrushStart} onBrushMove={onBrushMove} onBrushEnd={onBrushEnd} />\n <VisAxis type='x' numTicks={5} tickFormat={props.formatXTicks ?? props.formatNavXTicks} tickTextAlign={TextAlign.Right} label={props.xLabel}/>\n <VisAxis type='y' tickFormat={props.formatYTicks} minMaxTicksOnly={true} label={props.yLabel ? ' ' : undefined}/>\n </VisXYContainer>\n </div>\n )\n}\n\nVisTimeSeries.defaultProps = {\n margin: { top: 10, bottom: 10, left: 10, right: 10 },\n autoMargin: true,\n padding: {},\n\n x: (d: VisTimeSeriesDatum) => d.timestamp,\n y: (d: VisTimeSeriesDatum) => d.value,\n id: (d: VisTimeSeriesDatum) => d.id,\n color: (d: VisTimeSeriesDatum[]) => null,\n\n formatYTicks: (d: number) => d.toFixed(1),\n\n crosshairTemplate: (d: VisTimeSeriesDatum) =>\n `<div>Date: ${new Date(d.timestamp).toLocaleDateString()}</div><div>Value: ${d.value?.toFixed(1)}</div>`,\n}\n"],"names":[],"mappings":";;;;;;;;;;AAiDO,SAAS,cAAsB,OAA+C;AACnF,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAuC,MAAS;AAC1F,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAA6B,CAAC;AAChF,QAAM,SAAS,QAAQ,MAAM,MAAM,UAAA,GAAa,CAAA,CAAE;AAClD,QAAM,YAAY,QAAQ,MAAM,MAAM,UAAA,GA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
+
const timeSeriesContainer = "_timeSeriesContainer_1ayv5_1";
|
|
2
|
+
const timeSeriesModule = "_timeSeriesModule_1ayv5_8";
|
|
3
|
+
const navigationModule = "_navigationModule_1ayv5_14";
|
|
4
|
+
const s = {
|
|
5
|
+
timeSeriesContainer,
|
|
6
|
+
timeSeriesModule,
|
|
7
|
+
navigationModule
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
s as default,
|
|
11
|
+
navigationModule,
|
|
12
|
+
timeSeriesContainer,
|
|
13
|
+
timeSeriesModule
|
|
14
|
+
};
|
|
8
15
|
//# sourceMappingURL=style.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":"style.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/composites.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './composites/time-series';
|
|
1
|
+
export * from './composites/time-series';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import { SingleContainerConfigInterface } from '@unovis/ts';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { SingleContainerConfigInterface } from '@unovis/ts/containers/single-container/config';
|
|
3
|
+
|
|
4
|
+
export type VisSingleContainerProps<Data> = SingleContainerConfigInterface<Data> & {
|
|
5
|
+
data?: Data;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties | Record<`--${string}`, string | number>;
|
|
8
|
+
};
|
|
9
|
+
export declare const VisSingleContainer: (<Data>(props: PropsWithChildren<VisSingleContainerProps<Data>>) => JSX.Element | null);
|
|
@@ -1,51 +1,69 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from
|
|
2
|
-
import { SingleContainer } from
|
|
3
|
-
import { arePropsEqual } from
|
|
4
|
-
|
|
5
|
-
function VisSingleContainerFC(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
1
|
+
import React, { useRef, useMemo, useEffect } from "react";
|
|
2
|
+
import { SingleContainer } from "@unovis/ts/containers/single-container";
|
|
3
|
+
import { arePropsEqual } from "../../utils/react.js";
|
|
4
|
+
import { VisContainerContext } from "../../utils/container.js";
|
|
5
|
+
function VisSingleContainerFC(props) {
|
|
6
|
+
const container = useRef(null);
|
|
7
|
+
const prevPropsRef = useRef({});
|
|
8
|
+
const chartRef = useRef(void 0);
|
|
9
|
+
const dataRef = useRef(void 0);
|
|
10
|
+
const animationFrameRef = useRef(null);
|
|
11
|
+
const renderRequestFrameRef = useRef(null);
|
|
12
|
+
const containerContext = useMemo(() => ({
|
|
13
|
+
requestRender: () => {
|
|
14
|
+
if (renderRequestFrameRef.current !== null) return;
|
|
15
|
+
renderRequestFrameRef.current = requestAnimationFrame(() => {
|
|
16
|
+
renderRequestFrameRef.current = null;
|
|
17
|
+
if (animationFrameRef.current !== null) return;
|
|
18
|
+
chartRef.current?.render();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}), []);
|
|
22
|
+
const getConfig = () => ({
|
|
23
|
+
...props,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
|
+
component: container.current?.querySelector("vis-component")?.__component__,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
tooltip: container.current?.querySelector("vis-tooltip")?.__component__,
|
|
28
|
+
annotations: container.current?.querySelector("vis-annotations")?.__component__
|
|
29
|
+
});
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const c = new SingleContainer(container.current, getConfig(), props.data);
|
|
32
|
+
chartRef.current = c;
|
|
33
|
+
prevPropsRef.current = props;
|
|
34
|
+
dataRef.current = props.data;
|
|
35
|
+
return () => {
|
|
36
|
+
if (animationFrameRef.current) {
|
|
37
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
38
|
+
animationFrameRef.current = null;
|
|
39
|
+
prevPropsRef.current = {};
|
|
40
|
+
}
|
|
41
|
+
if (renderRequestFrameRef.current !== null) {
|
|
42
|
+
cancelAnimationFrame(renderRequestFrameRef.current);
|
|
43
|
+
renderRequestFrameRef.current = null;
|
|
44
|
+
}
|
|
45
|
+
c.destroy();
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const preventRender = true;
|
|
50
|
+
if (props.data && props.data !== dataRef.current) {
|
|
51
|
+
chartRef.current?.setData(props.data, preventRender);
|
|
52
|
+
dataRef.current = props.data;
|
|
53
|
+
}
|
|
54
|
+
if (!arePropsEqual(prevPropsRef.current, props)) {
|
|
55
|
+
prevPropsRef.current = props;
|
|
56
|
+
if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current);
|
|
57
|
+
animationFrameRef.current = requestAnimationFrame(() => {
|
|
58
|
+
animationFrameRef.current = null;
|
|
59
|
+
chartRef.current?.updateContainer(getConfig());
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return /* @__PURE__ */ React.createElement("div", { ref: container, className: props.className, style: props.style }, /* @__PURE__ */ React.createElement(VisContainerContext.Provider, { value: containerContext }, props.children));
|
|
64
|
+
}
|
|
48
65
|
const VisSingleContainer = React.memo(VisSingleContainerFC, arePropsEqual);
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
export {
|
|
67
|
+
VisSingleContainer
|
|
68
|
+
};
|
|
51
69
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.tsx"],"sourcesContent":["// eslint-disable-next-line no-use-before-define\nimport React, { ReactNode, useEffect, useRef, useState, PropsWithChildren } from 'react'\nimport { SingleContainer
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/containers/single-container/index.tsx"],"sourcesContent":["// eslint-disable-next-line no-use-before-define\nimport React, { ReactNode, useEffect, useMemo, useRef, useState, PropsWithChildren } from 'react'\nimport { SingleContainer } from '@unovis/ts/containers/single-container'\nimport { SingleContainerConfigInterface } from '@unovis/ts/containers/single-container/config'\nimport { ComponentCore } from '@unovis/ts/core/component'\nimport { Tooltip } from '@unovis/ts/components/tooltip'\nimport { Annotations } from '@unovis/ts/components/annotations'\n\n// Utils\nimport { arePropsEqual } from 'src/utils/react'\nimport { VisContainerContext, VisContainerContextValue } from 'src/utils/container'\n\n// Types\nimport { VisComponentElement } from 'src/types/dom'\n\nexport type VisSingleContainerProps<Data> = SingleContainerConfigInterface<Data> & {\n data?: Data;\n className?: string;\n style?: React.CSSProperties | Record<`--${string}`, string | number>;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nfunction VisSingleContainerFC<Data> (props: PropsWithChildren<VisSingleContainerProps<Data>>): JSX.Element {\n const container = useRef<HTMLDivElement>(null)\n const prevPropsRef = useRef<PropsWithChildren<VisSingleContainerProps<Data>>>({})\n const chartRef = useRef<SingleContainer<Data> | undefined>(undefined)\n const dataRef = useRef<Data | undefined>(undefined)\n const animationFrameRef = useRef<number | null>(null)\n const renderRequestFrameRef = useRef<number | null>(null)\n\n // Children ask for a re-render when their own config changes. We coalesce the requests into a single\n // frame, and skip them when this container's props changed too, because the `updateContainer` call\n // scheduled below renders on its own.\n const containerContext = useMemo<VisContainerContextValue>(() => ({\n requestRender: () => {\n if (renderRequestFrameRef.current !== null) return\n renderRequestFrameRef.current = requestAnimationFrame(() => {\n renderRequestFrameRef.current = null\n if (animationFrameRef.current !== null) return\n chartRef.current?.render()\n })\n },\n }), [])\n\n const getConfig = (): SingleContainerConfigInterface<Data> => ({\n ...props,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n component: container.current?.querySelector<VisComponentElement<ComponentCore<Data>>>('vis-component')?.__component__,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tooltip: container.current?.querySelector<VisComponentElement<Tooltip>>('vis-tooltip')?.__component__,\n annotations: container.current?.querySelector<VisComponentElement<Annotations>>('vis-annotations')?.__component__,\n })\n\n // On Mount\n useEffect(() => {\n const c = new SingleContainer<Data>(container.current as HTMLDivElement, getConfig(), props.data)\n chartRef.current = c\n prevPropsRef.current = props\n dataRef.current = props.data\n\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = null\n prevPropsRef.current = {}\n }\n if (renderRequestFrameRef.current !== null) {\n cancelAnimationFrame(renderRequestFrameRef.current)\n renderRequestFrameRef.current = null\n }\n c.destroy()\n }\n }, [])\n\n // On Props Update\n useEffect(() => {\n const preventRender = true\n\n // Set new Data without re-render\n if (props.data && (props.data !== dataRef.current)) {\n chartRef.current?.setData(props.data, preventRender)\n dataRef.current = props.data\n }\n\n // Update and render\n // ! Experimental: we use `requestAnimationFrame` to make the wrapper compatible with React 18 Strict Mode.\n // React 18 in Strict Mode renders components twice. At the same time, this container will get updated only after\n // the first render of its children (VisSankey, VisGraph, ...) meaning that their wrong instances (the ones\n // that will be destroyed soon) are stored in the `__component__` property of their elements at that moment.\n // So we delay the container update with `requestAnimationFrame` to wait till the new instances of children\n // components are available at `__component__`.\n if (!arePropsEqual(prevPropsRef.current, props)) { // Checking whether the props have changed do avoid multiple renders\n prevPropsRef.current = props\n if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current)\n animationFrameRef.current = requestAnimationFrame(() => {\n animationFrameRef.current = null\n chartRef.current?.updateContainer(getConfig())\n })\n }\n })\n\n return (\n <div ref={container} className={props.className} style={props.style}>\n <VisContainerContext.Provider value={containerContext}>\n {props.children}\n </VisContainerContext.Provider>\n </div>\n )\n}\n\n// We export a memoized component to avoid unnecessary re-renders\n// and define its type explicitly to help react-docgen-typescript to extract information about props\nexport const VisSingleContainer: (<Data>(props: PropsWithChildren<VisSingleContainerProps<Data>>) => JSX.Element | null) =\n React.memo(VisSingleContainerFC, arePropsEqual)\n"],"names":[],"mappings":";;;;AAsBA,SAAS,qBAA4B,OAAsE;AACzG,QAAM,YAAY,OAAuB,IAAI;AAC7C,QAAM,eAAe,OAAyD,EAAE;AAChF,QAAM,WAAW,OAA0C,MAAS;AACpE,QAAM,UAAU,OAAyB,MAAS;AAClD,QAAM,oBAAoB,OAAsB,IAAI;AACpD,QAAM,wBAAwB,OAAsB,IAAI;AAKxD,QAAM,mBAAmB,QAAkC,OAAO;AAAA,IAChE,eAAe,MAAM;AACnB,UAAI,sBAAsB,YAAY,KAAM;AAC5C,4BAAsB,UAAU,sBAAsB,MAAM;AAC1D,8BAAsB,UAAU;AAChC,YAAI,kBAAkB,YAAY,KAAM;AACxC,iBAAS,SAAS,OAAA;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EAAA,IACE,CAAA,CAAE;AAEN,QAAM,YAAY,OAA6C;AAAA,IAC7D,GAAG;AAAA;AAAA,IAEH,WAAW,UAAU,SAAS,cAAwD,eAAe,GAAG;AAAA;AAAA,IAExG,SAAS,UAAU,SAAS,cAA4C,aAAa,GAAG;AAAA,IACxF,aAAa,UAAU,SAAS,cAAgD,iBAAiB,GAAG;AAAA,EAAA;AAItG,YAAU,MAAM;AACd,UAAM,IAAI,IAAI,gBAAsB,UAAU,SAA2B,UAAA,GAAa,MAAM,IAAI;AAChG,aAAS,UAAU;AACnB,iBAAa,UAAU;AACvB,YAAQ,UAAU,MAAM;AAExB,WAAO,MAAM;AACX,UAAI,kBAAkB,SAAS;AAC7B,6BAAqB,kBAAkB,OAAO;AAC9C,0BAAkB,UAAU;AAC5B,qBAAa,UAAU,CAAA;AAAA,MACzB;AACA,UAAI,sBAAsB,YAAY,MAAM;AAC1C,6BAAqB,sBAAsB,OAAO;AAClD,8BAAsB,UAAU;AAAA,MAClC;AACA,QAAE,QAAA;AAAA,IACJ;AAAA,EACF,GAAG,CAAA,CAAE;AAGL,YAAU,MAAM;AACd,UAAM,gBAAgB;AAGtB,QAAI,MAAM,QAAS,MAAM,SAAS,QAAQ,SAAU;AAClD,eAAS,SAAS,QAAQ,MAAM,MAAM,aAAa;AACnD,cAAQ,UAAU,MAAM;AAAA,IAC1B;AASA,QAAI,CAAC,cAAc,aAAa,SAAS,KAAK,GAAG;AAC/C,mBAAa,UAAU;AACvB,UAAI,kBAAkB,QAAS,sBAAqB,kBAAkB,OAAO;AAC7E,wBAAkB,UAAU,sBAAsB,MAAM;AACtD,0BAAkB,UAAU;AAC5B,iBAAS,SAAS,gBAAgB,WAAW;AAAA,MAC/C,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,6CACG,OAAA,EAAI,KAAK,WAAW,WAAW,MAAM,WAAW,OAAO,MAAM,MAAA,GAC5D,sBAAA,cAAC,oBAAoB,UAApB,EAA6B,OAAO,iBAAA,GAClC,MAAM,QACT,CACF;AAEJ;AAIO,MAAM,qBACX,MAAM,KAAK,sBAAsB,aAAa;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import { XYContainerConfigInterface } from '@unovis/ts';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export declare
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { XYContainerConfigInterface } from '@unovis/ts/containers/xy-container/config';
|
|
3
|
+
|
|
4
|
+
export type VisXYContainerProps<Datum> = XYContainerConfigInterface<Datum> & {
|
|
5
|
+
data?: Datum[];
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties | Record<`--${string}`, string | number>;
|
|
8
|
+
};
|
|
9
|
+
export declare function VisXYContainerFC<Datum>(props: PropsWithChildren<VisXYContainerProps<Datum>>): JSX.Element;
|
|
10
|
+
export declare const VisXYContainer: (<Datum>(props: PropsWithChildren<VisXYContainerProps<Datum>>) => JSX.Element | null);
|
|
@@ -1,59 +1,73 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from
|
|
2
|
-
import { XYContainer
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import React, { useRef, useMemo, useEffect } from "react";
|
|
2
|
+
import { XYContainer } from "@unovis/ts/containers/xy-container";
|
|
3
|
+
import { AxisType } from "@unovis/ts/components/axis/types";
|
|
4
|
+
import { arePropsEqual } from "../../utils/react.js";
|
|
5
|
+
import { VisContainerContext } from "../../utils/container.js";
|
|
6
|
+
function VisXYContainerFC(props) {
|
|
7
|
+
const container = useRef(null);
|
|
8
|
+
const prevPropsRef = useRef({});
|
|
9
|
+
const chartRef = useRef(void 0);
|
|
10
|
+
const dataRef = useRef(void 0);
|
|
11
|
+
const animationFrameRef = useRef(null);
|
|
12
|
+
const renderRequestFrameRef = useRef(null);
|
|
13
|
+
const containerContext = useMemo(() => ({
|
|
14
|
+
requestRender: () => {
|
|
15
|
+
if (renderRequestFrameRef.current !== null) return;
|
|
16
|
+
renderRequestFrameRef.current = requestAnimationFrame(() => {
|
|
17
|
+
renderRequestFrameRef.current = null;
|
|
18
|
+
if (animationFrameRef.current !== null) return;
|
|
19
|
+
chartRef.current?.render();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}), []);
|
|
23
|
+
const getConfig = () => ({
|
|
24
|
+
components: Array.from(container.current?.querySelectorAll("vis-component") ?? []).map((c) => c.__component__).filter(Boolean),
|
|
25
|
+
tooltip: container.current?.querySelector("vis-tooltip")?.__component__,
|
|
26
|
+
crosshair: container.current?.querySelector("vis-crosshair")?.__component__,
|
|
27
|
+
annotations: container.current?.querySelector("vis-annotations")?.__component__,
|
|
28
|
+
xAxis: Array.from(container.current?.querySelectorAll("vis-axis") ?? []).map((c) => c.__component__).find((c) => c.config.type === AxisType.X),
|
|
29
|
+
yAxis: Array.from(container.current?.querySelectorAll("vis-axis") ?? []).map((c) => c.__component__).find((c) => c.config.type === AxisType.Y),
|
|
30
|
+
margin: { top: 5, left: 5, right: 5, bottom: 5 },
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const c = new XYContainer(container.current, getConfig(), props.data);
|
|
35
|
+
chartRef.current = c;
|
|
36
|
+
prevPropsRef.current = props;
|
|
37
|
+
dataRef.current = props.data;
|
|
38
|
+
return () => {
|
|
39
|
+
if (animationFrameRef.current) {
|
|
40
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
41
|
+
animationFrameRef.current = null;
|
|
42
|
+
prevPropsRef.current = {};
|
|
43
|
+
}
|
|
44
|
+
if (renderRequestFrameRef.current !== null) {
|
|
45
|
+
cancelAnimationFrame(renderRequestFrameRef.current);
|
|
46
|
+
renderRequestFrameRef.current = null;
|
|
47
|
+
}
|
|
48
|
+
c.destroy();
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const preventRender = true;
|
|
53
|
+
if (props.data && props.data !== dataRef.current) {
|
|
54
|
+
chartRef.current?.setData(props.data, preventRender);
|
|
55
|
+
dataRef.current = props.data;
|
|
56
|
+
}
|
|
57
|
+
if (!arePropsEqual(prevPropsRef.current, props)) {
|
|
58
|
+
prevPropsRef.current = props;
|
|
59
|
+
if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current);
|
|
60
|
+
animationFrameRef.current = requestAnimationFrame(() => {
|
|
61
|
+
animationFrameRef.current = null;
|
|
62
|
+
chartRef.current?.updateContainer(getConfig());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return /* @__PURE__ */ React.createElement("div", { ref: container, className: props.className, style: props.style }, /* @__PURE__ */ React.createElement(VisContainerContext.Provider, { value: containerContext }, props.children));
|
|
67
|
+
}
|
|
56
68
|
const VisXYContainer = React.memo(VisXYContainerFC, arePropsEqual);
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
export {
|
|
70
|
+
VisXYContainer,
|
|
71
|
+
VisXYContainerFC
|
|
72
|
+
};
|
|
59
73
|
//# sourceMappingURL=index.js.map
|