nanoplot 0.0.90 → 0.0.92
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/index.css +26 -28
- package/dist/src/components/Area/Area.d.ts +2 -2
- package/dist/src/components/Bars/Bars.d.ts +6 -6
- package/dist/src/components/Bars/components/BarsBar.d.ts +3 -2
- package/dist/src/components/Bars/components/BarsMouse.d.ts +5 -4
- package/dist/src/components/Bars/components/HorizontalBars.js +3 -2
- package/dist/src/components/Bars/components/VerticalBars.d.ts +2 -2
- package/dist/src/components/Bars/components/VerticalBars.js +7 -8
- package/dist/src/components/GradientLegend/GradientLegend.d.ts +4 -4
- package/dist/src/components/Graph/Graph.js +1 -3
- package/dist/src/components/GridLines/GridLines.d.ts +2 -2
- package/dist/src/components/GridLines/GridLines.js +6 -15
- package/dist/src/components/Heatmap/Heatmap.d.ts +3 -2
- package/dist/src/components/Legend/Legend.d.ts +2 -2
- package/dist/src/components/Lines/Lines.d.ts +5 -5
- package/dist/src/components/Lines/components/LinesJoints.d.ts +2 -2
- package/dist/src/components/Lines/components/LinesReference.d.ts +3 -2
- package/dist/src/components/Lines/components/LinesTooltip.d.ts +3 -3
- package/dist/src/components/Lines/components/LinesTooltip.js +9 -8
- package/dist/src/components/Lines/components/LinesTooltipZone.d.ts +2 -2
- package/dist/src/components/Overlay/Overlay.d.ts +3 -2
- package/dist/src/components/Overlay/OverlayRect.d.ts +5 -4
- package/dist/src/components/Pie/Pie.d.ts +1 -3
- package/dist/src/components/Pie/Pie.js +5 -5
- package/dist/src/components/Pie/components/PieTooltip.d.ts +1 -3
- package/dist/src/components/Pie/components/PieTooltip.js +6 -12
- package/dist/src/components/Radar/Radar.js +3 -3
- package/dist/src/components/Scatter/Scatter.d.ts +7 -7
- package/dist/src/components/Scatter/components/ScatterQuadrant.d.ts +5 -4
- package/dist/src/components/Worldmap/Worldmap.d.ts +2 -2
- package/dist/src/components/XAxis/XAxis.d.ts +2 -2
- package/dist/src/components/YAxis/YAxis.d.ts +2 -2
- package/dist/src/hooks/use-graph/use-graph.d.ts +15 -14
- package/dist/src/hooks/use-mouse-coordinates.d.ts +13 -12
- package/dist/src/hooks/use-mouse-coordinates.js +25 -13
- package/dist/src/utils/coordinates/coordinates.d.ts +5 -5
- package/dist/src/utils/coordinates/coordinates.js +51 -130
- package/dist/src/utils/domain/domain.d.ts +2 -2
- package/dist/src/utils/domain/utils/auto-max.d.ts +2 -4
- package/dist/src/utils/domain/utils/auto-max.js +0 -5
- package/dist/src/utils/domain/utils/auto-minmax.d.ts +8 -4
- package/dist/src/utils/domain/utils/auto-minmax.js +42 -59
- package/dist/src/utils/domain/utils/range.d.ts +2 -2
- package/dist/src/utils/domain/utils/range.js +36 -71
- package/dist/src/utils/domain/utils/temporal-domain.d.ts +21 -0
- package/dist/src/utils/domain/utils/temporal-domain.js +204 -0
- package/dist/src/utils/domain/utils/temporal.d.ts +16 -0
- package/dist/src/utils/domain/utils/temporal.js +49 -0
- package/dist/src/utils/equals/equals.js +8 -0
- package/dist/src/utils/gradient/gradient.d.ts +3 -3
- package/dist/tsconfig.typings.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/temporal-polyfill.ts +3 -0
- package/tsconfig.json +42 -27
- package/dist/src/utils/domain/utils/date-domain.d.ts +0 -19
- package/dist/src/utils/domain/utils/date-domain.js +0 -343
package/dist/index.css
CHANGED
|
@@ -514,11 +514,6 @@
|
|
|
514
514
|
text-align: center;
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
-
.text-7xl {
|
|
518
|
-
font-size: 4.5rem;
|
|
519
|
-
line-height: 1;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
517
|
.text-\[0\.875rem\] {
|
|
523
518
|
font-size: 0.875rem;
|
|
524
519
|
}
|
|
@@ -630,6 +625,12 @@
|
|
|
630
625
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
631
626
|
}
|
|
632
627
|
|
|
628
|
+
.backdrop-blur-sm {
|
|
629
|
+
--tw-backdrop-blur: blur(4px);
|
|
630
|
+
-webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
631
|
+
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
632
|
+
}
|
|
633
|
+
|
|
633
634
|
.transition-all {
|
|
634
635
|
transition-property: all;
|
|
635
636
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -665,13 +666,12 @@
|
|
|
665
666
|
container-name: graph;
|
|
666
667
|
}
|
|
667
668
|
|
|
668
|
-
.\[--
|
|
669
|
-
--
|
|
669
|
+
.\[--fit-len\:min\(100cqw\2c 100cqh\)\] {
|
|
670
|
+
--fit-len: min(100cqw,100cqh);
|
|
670
671
|
}
|
|
671
672
|
|
|
672
|
-
.\[
|
|
673
|
-
-
|
|
674
|
-
backdrop-filter: blur(4px);
|
|
673
|
+
.\[--fit-num\:calc\(10000\*tan\(atan2\(var\(--fit-len\)\2c 10000px\)\)\)\] {
|
|
674
|
+
--fit-num: calc(10000 * tan(atan2(var(--fit-len),10000px)));
|
|
675
675
|
}
|
|
676
676
|
|
|
677
677
|
.\[backface-visibility\:hidden\] {
|
|
@@ -722,6 +722,10 @@
|
|
|
722
722
|
border: var(--b) solid #0000;
|
|
723
723
|
}
|
|
724
724
|
|
|
725
|
+
.\[container-type\:size\] {
|
|
726
|
+
container-type: size;
|
|
727
|
+
}
|
|
728
|
+
|
|
725
729
|
.\[container-type\:size_\!important\] {
|
|
726
730
|
container-type: size !important;
|
|
727
731
|
}
|
|
@@ -750,20 +754,20 @@
|
|
|
750
754
|
filter: invert(1);
|
|
751
755
|
}
|
|
752
756
|
|
|
753
|
-
.\[font-size
|
|
754
|
-
font-size
|
|
757
|
+
.\[font-size\:0\.75rem\] {
|
|
758
|
+
font-size: 0.75rem;
|
|
755
759
|
}
|
|
756
760
|
|
|
757
|
-
.\[font-size
|
|
758
|
-
font-size
|
|
761
|
+
.\[font-size\:calc\(28000px_\/var\(--fit-num\)\)\] {
|
|
762
|
+
font-size: calc(28000px / var(--fit-num));
|
|
759
763
|
}
|
|
760
764
|
|
|
761
|
-
.\[font-size\:
|
|
762
|
-
font-size:
|
|
765
|
+
.\[font-size\:calc\(41000px_\/_tan\(atan2\(min\(100cqw\2c 100cqh\)\2c 1px\)\)\)\] {
|
|
766
|
+
font-size: calc(41000px / tan(atan2(min(100cqw,100cqh),1px)));
|
|
763
767
|
}
|
|
764
768
|
|
|
765
|
-
.\[font-size\:calc\(
|
|
766
|
-
font-size: calc(
|
|
769
|
+
.\[font-size\:calc\(41000px_\/var\(--fit-num\)\)\] {
|
|
770
|
+
font-size: calc(41000px / var(--fit-num));
|
|
767
771
|
}
|
|
768
772
|
|
|
769
773
|
.\[grid-area\:graph\] {
|
|
@@ -846,17 +850,12 @@
|
|
|
846
850
|
writing-mode: vertical-rl;
|
|
847
851
|
}
|
|
848
852
|
|
|
849
|
-
|
|
850
|
-
https://dev.to/janeori/css-type-casting-to-numeric-tanatan2-scalars-582j
|
|
851
|
-
allows 100cqh in calc functions to prevent text scaling inside svg.
|
|
852
|
-
*/
|
|
853
|
-
|
|
854
|
-
@property --hundred-cqh {
|
|
853
|
+
@property --fit-len {
|
|
855
854
|
syntax: "<length>";
|
|
856
855
|
|
|
857
|
-
initial-value: 0px;
|
|
858
|
-
|
|
859
856
|
inherits: false;
|
|
857
|
+
|
|
858
|
+
initial-value: 1px;
|
|
860
859
|
}
|
|
861
860
|
|
|
862
861
|
.before\:absolute::before {
|
|
@@ -1315,5 +1314,4 @@
|
|
|
1315
1314
|
|
|
1316
1315
|
.has-\[path\:hover\]\:\[\&_\.label-path\]\:stroke-current .label-path:has(path:hover) {
|
|
1317
1316
|
stroke: currentColor;
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1317
|
+
}
|
|
@@ -12,8 +12,8 @@ export declare const Area: {
|
|
|
12
12
|
Tooltip: React.ComponentType<Omit<React.HTMLAttributes<HTMLDivElement> & {
|
|
13
13
|
tooltip?: ((points: Array<Omit<import("../../export").CartesianDataset[number], "data"> & {
|
|
14
14
|
data: import("../../export").CartesianDataset[number]["data"][number];
|
|
15
|
-
}>, x: number | string |
|
|
16
|
-
title?: (x: number | string |
|
|
15
|
+
}>, x: number | string | import("../../hooks/use-graph/use-graph").TemporalDate) => React.ReactNode) | {
|
|
16
|
+
title?: (x: number | string | import("../../hooks/use-graph/use-graph").TemporalDate) => React.ReactNode;
|
|
17
17
|
display?: (point: import("../../export").CartesianDataset[number]["data"][number]) => React.ReactNode;
|
|
18
18
|
};
|
|
19
19
|
joints?: boolean;
|
|
@@ -21,12 +21,12 @@ export declare const Bars: {
|
|
|
21
21
|
};
|
|
22
22
|
closest: {
|
|
23
23
|
datapoint: {
|
|
24
|
-
x:
|
|
25
|
-
y:
|
|
24
|
+
x: import("../../hooks/use-graph/use-graph").TemporalDate | string | number;
|
|
25
|
+
y: import("../../hooks/use-graph/use-graph").TemporalDate | string | number;
|
|
26
26
|
};
|
|
27
27
|
tick: {
|
|
28
|
-
x: string | number |
|
|
29
|
-
y: string | number |
|
|
28
|
+
x: string | number | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
29
|
+
y: string | number | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
}, e: React.MouseEvent<SVGSVGElement>) => void;
|
|
@@ -34,8 +34,8 @@ export declare const Bars: {
|
|
|
34
34
|
onLeave?: (e: React.MouseEvent<SVGSVGElement>) => void;
|
|
35
35
|
}) => React.JSX.Element;
|
|
36
36
|
Bar: ({ x, y, fill, stroke, size, horizontal, onMouseEnter, onMouseLeave, className }: {
|
|
37
|
-
x: number | string |
|
|
38
|
-
y: number | string |
|
|
37
|
+
x: number | string | import("../../hooks/use-graph/use-graph").TemporalDate | "auto";
|
|
38
|
+
y: number | string | import("../../hooks/use-graph/use-graph").TemporalDate | "auto";
|
|
39
39
|
fill?: string;
|
|
40
40
|
stroke?: string;
|
|
41
41
|
size?: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TemporalDate } from "../../../hooks/use-graph/use-graph";
|
|
1
2
|
type Props = {
|
|
2
|
-
x: number | string |
|
|
3
|
-
y: number | string |
|
|
3
|
+
x: number | string | TemporalDate | "auto";
|
|
4
|
+
y: number | string | TemporalDate | "auto";
|
|
4
5
|
fill?: string;
|
|
5
6
|
stroke?: string;
|
|
6
7
|
size?: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MouseEvent } from "react";
|
|
2
|
+
import { TemporalDate } from "../../../hooks/use-graph/use-graph";
|
|
2
3
|
type Props = {
|
|
3
4
|
className?: string;
|
|
4
5
|
onMove?: (mouse: null | {
|
|
@@ -9,12 +10,12 @@ type Props = {
|
|
|
9
10
|
};
|
|
10
11
|
closest: {
|
|
11
12
|
datapoint: {
|
|
12
|
-
x:
|
|
13
|
-
y:
|
|
13
|
+
x: TemporalDate | string | number;
|
|
14
|
+
y: TemporalDate | string | number;
|
|
14
15
|
};
|
|
15
16
|
tick: {
|
|
16
|
-
x: string | number |
|
|
17
|
-
y: string | number |
|
|
17
|
+
x: string | number | TemporalDate;
|
|
18
|
+
y: string | number | TemporalDate;
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
21
|
}, e: MouseEvent<SVGSVGElement>) => void;
|
|
@@ -19,6 +19,7 @@ import { Rect } from "./Rect";
|
|
|
19
19
|
import { scale } from "../../../utils/math/math";
|
|
20
20
|
import { overlay } from "../../Overlay/Overlay";
|
|
21
21
|
import { ColorUtils } from "../../../utils/color/color";
|
|
22
|
+
import { toEpochMs } from "../../../utils/domain/utils/temporal";
|
|
22
23
|
export const HorizontalBars = ({ children, fill, stroke, labels, size = 50, radius = 0, anchor = 0, interactions, onMouseEnter, onMouseLeave, className, }) => {
|
|
23
24
|
const context = useGraph();
|
|
24
25
|
if (!GraphUtils.isXYData(context.data))
|
|
@@ -30,11 +31,11 @@ export const HorizontalBars = ({ children, fill, stroke, labels, size = 50, radi
|
|
|
30
31
|
return (Object.assign(Object.assign({}, bar), { group: (_a = bar.group) !== null && _a !== void 0 ? _a : bar.id, data: xy }));
|
|
31
32
|
}));
|
|
32
33
|
const BAR_HEIGHT = Math.floor(context.viewbox.y / context.domain.y.length / new Set(bars.map((bar) => { var _a; return (_a = bar.group) !== null && _a !== void 0 ? _a : "no-group"; })).size) * (size / 100);
|
|
33
|
-
const yValues = new Set(bars.map((bar) => (bar.data.y
|
|
34
|
+
const yValues = new Set(bars.map((bar) => (typeof bar.data.y === "string" || typeof bar.data.y === "number" ? bar.data.y : toEpochMs(bar.data.y))));
|
|
34
35
|
const dataset = Array.from(yValues)
|
|
35
36
|
.flatMap((y) => {
|
|
36
37
|
const coordinate = yForValue(y);
|
|
37
|
-
const barsForTick = bars.filter((bar) => (bar.data.y
|
|
38
|
+
const barsForTick = bars.filter((bar) => (typeof bar.data.y === "string" || typeof bar.data.y === "number" ? bar.data.y : toEpochMs(bar.data.y)) === y);
|
|
38
39
|
return Object.entries(ObjectUtils.groupBy(barsForTick, ({ group }) => group)).flatMap(([, barsForGroup], i, groups) => {
|
|
39
40
|
const y1 = coordinate + BAR_HEIGHT * i - (BAR_HEIGHT * Object.keys(groups).length) / 2;
|
|
40
41
|
return barsForGroup === null || barsForGroup === void 0 ? void 0 : barsForGroup.map((bar) => (Object.assign(Object.assign({}, bar), { x1: xForValue(anchor), x2: xForValue(bar.data.x), y1, y2: y1 + BAR_HEIGHT }))).map((segment, ii, segments) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { MouseEvent, ReactNode } from "react";
|
|
2
|
-
import { InternalCartesianDataset, Simplify } from "../../../hooks/use-graph/use-graph";
|
|
2
|
+
import { InternalCartesianDataset, Simplify, TemporalDate } from "../../../hooks/use-graph/use-graph";
|
|
3
3
|
type Segment = Simplify<Omit<InternalCartesianDataset[number], "data"> & {
|
|
4
4
|
data: InternalCartesianDataset[number]["data"][number];
|
|
5
5
|
}>;
|
|
@@ -24,7 +24,7 @@ type Props = Omit<React.SVGAttributes<SVGSVGElement>, "onMouseEnter" | "onMouseL
|
|
|
24
24
|
*/
|
|
25
25
|
stroke?: (segment: Segment) => string;
|
|
26
26
|
interactions?: {
|
|
27
|
-
x?: number | string |
|
|
27
|
+
x?: number | string | TemporalDate;
|
|
28
28
|
};
|
|
29
29
|
onMouseEnter?: (rect: Segment, event: MouseEvent) => void;
|
|
30
30
|
onMouseLeave?: (event: MouseEvent) => void;
|
|
@@ -20,6 +20,7 @@ import { cx } from "../../../utils/cx/cx";
|
|
|
20
20
|
import { scale } from "../../../utils/math/math";
|
|
21
21
|
import { overlay } from "../../Overlay/Overlay";
|
|
22
22
|
import { ColorUtils } from "../../../utils/color/color";
|
|
23
|
+
import { toEpochMs } from "../../../utils/domain/utils/temporal";
|
|
23
24
|
export const VerticalBars = (_a) => {
|
|
24
25
|
var { children, fill, stroke, size = 50, anchor = 0, labels, radius = 0, glow, className, loading, interactions, onMouseEnter, onMouseLeave } = _a, rest = __rest(_a, ["children", "fill", "stroke", "size", "anchor", "labels", "radius", "glow", "className", "loading", "interactions", "onMouseEnter", "onMouseLeave"]);
|
|
25
26
|
const context = useGraph();
|
|
@@ -35,14 +36,13 @@ export const VerticalBars = (_a) => {
|
|
|
35
36
|
return (Object.assign(Object.assign({}, bar), { group: (_a = bar.group) !== null && _a !== void 0 ? _a : bar.id /* grouped unique if no group is defined */, data: xy }));
|
|
36
37
|
}));
|
|
37
38
|
const BAR_WIDTH = Math.floor(context.viewbox.x / context.domain.x.length / new Set(bars.map((bar) => bar.group)).size) * (size / 100); // this divided by number of unique groups?
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const isSingleBar = new Set(bars.map((bar) => bar.group)).size === 1;
|
|
41
|
-
const xValues = new Set(bars.map((bar) => (bar.data.x instanceof Date ? bar.data.x.getTime() : bar.data.x)));
|
|
39
|
+
const xValues = new Set(bars.map((bar) => (typeof bar.data.x === "string" || typeof bar.data.x === "number" ? bar.data.x : toEpochMs(bar.data.x))));
|
|
40
|
+
console.log(xValues);
|
|
42
41
|
const dataset = Array.from(xValues)
|
|
43
42
|
.flatMap((x) => {
|
|
44
43
|
const coordinate = xForValue(x);
|
|
45
|
-
const barsForTick = bars.filter((bar) => (bar.data.x
|
|
44
|
+
const barsForTick = bars.filter((bar) => (typeof bar.data.x === "string" || typeof bar.data.x === "number" ? bar.data.x : toEpochMs(bar.data.x)) === x);
|
|
45
|
+
console.log(barsForTick);
|
|
46
46
|
return Object.entries(ObjectUtils.groupBy(barsForTick, ({ group }) => group)).flatMap(([, barsForGroup], i, groups) => {
|
|
47
47
|
const x1 = coordinate + BAR_WIDTH * i - (BAR_WIDTH * Object.keys(groups).length) / 2;
|
|
48
48
|
return barsForGroup === null || barsForGroup === void 0 ? void 0 : barsForGroup.map((bar) => (Object.assign(Object.assign({}, bar), { x1, x2: x1 + BAR_WIDTH, y1: yForValue(bar.data.y), y2: yForValue(anchor) }))).map((segment, ii, segments) => {
|
|
@@ -78,7 +78,7 @@ export const VerticalBars = (_a) => {
|
|
|
78
78
|
dataset.map((bar, i) => {
|
|
79
79
|
const position = typeof labels === "object" && "position" in labels ? labels.position : "center";
|
|
80
80
|
const collision = typeof labels === "object" && "collision" in labels ? labels.collision : true;
|
|
81
|
-
const width = scale(
|
|
81
|
+
const width = scale(bar.x2 - bar.x1, context.viewbox.x, 100) + "%";
|
|
82
82
|
const height = scale(Math.abs(bar.y1 - bar.y2), context.viewbox.y, 100);
|
|
83
83
|
const top = position === "above" ? -4 : scale(Math.min(bar.y2, bar.y1), context.viewbox.y, 100) + "%";
|
|
84
84
|
const label = (() => {
|
|
@@ -88,11 +88,10 @@ export const VerticalBars = (_a) => {
|
|
|
88
88
|
return (_a = (labels === true ? bar.data.y : labels(bar))) !== null && _a !== void 0 ? _a : "";
|
|
89
89
|
})();
|
|
90
90
|
const breakpoint = [2, 4, 5, 6, 8, 10, 15, 20].find((bp) => bp >= label.toString().replace(".", "").length);
|
|
91
|
-
const xTick = xForValue(bar.data.x);
|
|
92
91
|
return (React.createElement(overlay.div, { key: i, className: "bars__label @container-[size] absolute text-center", style: {
|
|
93
92
|
width,
|
|
94
93
|
height: Math.abs(height - (position === "above" ? 100 : 0)) + "%",
|
|
95
|
-
left: scale(
|
|
94
|
+
left: scale(bar.x1, context.viewbox.x, 100) + "%",
|
|
96
95
|
top: top,
|
|
97
96
|
} },
|
|
98
97
|
React.createElement("div", { className: "h-full w-full relative" },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { InternalGraphContext } from "../../hooks/use-graph/use-graph";
|
|
2
|
+
import { InternalGraphContext, TemporalDate } from "../../hooks/use-graph/use-graph";
|
|
3
3
|
type Props = React.HTMLAttributes<HTMLDivElement> & {
|
|
4
4
|
position: "top" | "bottom";
|
|
5
5
|
alignment?: "start" | "center" | "end";
|
|
6
6
|
gradient: `linear-gradient(${string})`;
|
|
7
|
-
labels?: boolean | ((value: string | number |
|
|
7
|
+
labels?: boolean | ((value: string | number | TemporalDate) => string);
|
|
8
8
|
};
|
|
9
9
|
export declare const GradientLegend: {
|
|
10
10
|
({ position, alignment, gradient, labels, ...rest }: Props): React.JSX.Element;
|
|
@@ -33,11 +33,11 @@ export declare const GradientLegend: {
|
|
|
33
33
|
domain: {
|
|
34
34
|
x: Array<{
|
|
35
35
|
coordinate: number;
|
|
36
|
-
tick: string | number |
|
|
36
|
+
tick: string | number | TemporalDate;
|
|
37
37
|
}>;
|
|
38
38
|
y: Array<{
|
|
39
39
|
coordinate: number;
|
|
40
|
-
tick: string | number |
|
|
40
|
+
tick: string | number | TemporalDate;
|
|
41
41
|
}>;
|
|
42
42
|
};
|
|
43
43
|
colors: string[];
|
|
@@ -98,9 +98,7 @@ const GraphComponent = ({ data = [], gap, children, interactions, datasets = {},
|
|
|
98
98
|
};
|
|
99
99
|
const colorized = setDefaults(ctx);
|
|
100
100
|
return (React.createElement("div", Object.assign({ id: id, "data-ctx": "graph" }, ctx.attributes, { style: Object.assign(Object.assign(Object.assign({}, style), ctx.attributes.style), { gridTemplateColumns: ctx.layout.columns, gridTemplateRows: ctx.layout.rows, padding: `${ctx.gap.top}px ${ctx.gap.right}px ${ctx.gap.bottom}px ${ctx.gap.left}px` }), className: tw(ctx.attributes.className, className) }),
|
|
101
|
-
isServerComponent && (
|
|
102
|
-
/* CTX for server components. */
|
|
103
|
-
React.createElement("script", { id: id + "-context", type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(colorized) } })),
|
|
101
|
+
isServerComponent && (React.createElement("script", { id: id + "-context", type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(colorized) } })),
|
|
104
102
|
React.createElement(GraphContextProvider, { value: colorized }, children)));
|
|
105
103
|
};
|
|
106
104
|
export const Graph = Object.assign(GraphComponent, {
|
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
interface Props extends Omit<React.SVGAttributes<SVGSVGElement>, "className"> {
|
|
3
3
|
trendline?: boolean;
|
|
4
4
|
border?: boolean;
|
|
5
|
-
horizontal?: boolean
|
|
6
|
-
vertical?: boolean
|
|
5
|
+
horizontal?: boolean;
|
|
6
|
+
vertical?: boolean;
|
|
7
7
|
className?: string | {
|
|
8
8
|
root?: string;
|
|
9
9
|
vertical?: string;
|
|
@@ -14,24 +14,15 @@ export const GridLines = ({ border = true, horizontal = true, vertical = true, c
|
|
|
14
14
|
{ x1: 0, y1: y, x2: 0, y2: 0, side: "left" },
|
|
15
15
|
].map(({ x1, y1, x2, y2, side }, i) => (React.createElement("line", { key: i, x1: x1, y1: y1, x2: x2, y2: y2, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: tw("stroke-gray-200 dark:stroke-[#2d2d2d] grid-lines__border", typeof className === "object" && typeof className.border === "object" && className.border[side], typeof className === "object" && (className === null || className === void 0 ? void 0 : className.border)) }))),
|
|
16
16
|
horizontal &&
|
|
17
|
-
domain.y.map(({ coordinate }
|
|
18
|
-
if ((coordinate === 0 || coordinate === y) && border
|
|
17
|
+
domain.y.map(({ coordinate }) => {
|
|
18
|
+
if ((coordinate === 0 || coordinate === y) && border)
|
|
19
19
|
return null;
|
|
20
|
-
|
|
21
|
-
const next = ys[i + 1];
|
|
22
|
-
if (horizontal === "between" && !next)
|
|
23
|
-
return null;
|
|
24
|
-
const coordinateFor = horizontal === "between" && next ? (coordinate + next.coordinate) / 2 : coordinate;
|
|
25
|
-
return (React.createElement("line", { key: coordinateFor, x1: 0, y1: coordinateFor, x2: x, y2: coordinateFor, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: tw("stroke-gray-200 dark:stroke-[#2d2d2d] grid-lines__horizontal", typeof className === "object" && (className === null || className === void 0 ? void 0 : className.horizontal)) }));
|
|
20
|
+
return (React.createElement("line", { key: coordinate, x1: 0, y1: coordinate, x2: x, y2: coordinate, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: tw("stroke-gray-200 dark:stroke-[#2d2d2d] grid-lines__horizontal", typeof className === "object" && (className === null || className === void 0 ? void 0 : className.horizontal)) }));
|
|
26
21
|
}),
|
|
27
22
|
vertical &&
|
|
28
|
-
domain.x.map(({ coordinate }
|
|
29
|
-
if ((coordinate === 0 || coordinate === x) && border
|
|
30
|
-
return null;
|
|
31
|
-
const next = xs[i + 1];
|
|
32
|
-
if (vertical === "between" && !next)
|
|
23
|
+
domain.x.map(({ coordinate }) => {
|
|
24
|
+
if ((coordinate === 0 || coordinate === x) && border)
|
|
33
25
|
return null;
|
|
34
|
-
|
|
35
|
-
return (React.createElement("line", { key: coordinateFor, x1: coordinateFor, y1: 0, x2: coordinateFor, y2: y, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: tw("stroke-gray-200 dark:stroke-[#2d2d2d] grid-lines__vertical", typeof className === "object" && (className === null || className === void 0 ? void 0 : className.vertical)) }));
|
|
26
|
+
return (React.createElement("line", { key: coordinate, x1: coordinate, y1: 0, x2: coordinate, y2: y, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: tw("stroke-gray-200 dark:stroke-[#2d2d2d] grid-lines__vertical", typeof className === "object" && (className === null || className === void 0 ? void 0 : className.vertical)) }));
|
|
36
27
|
})));
|
|
37
28
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TemporalDate } from "../../hooks/use-graph/use-graph";
|
|
1
2
|
import React from "react";
|
|
2
3
|
type Props = React.HTMLAttributes<SVGSVGElement> & {
|
|
3
4
|
gradient: `linear-gradient(${string})`;
|
|
@@ -5,9 +6,9 @@ type Props = React.HTMLAttributes<SVGSVGElement> & {
|
|
|
5
6
|
tick: number;
|
|
6
7
|
percent: number;
|
|
7
8
|
}>;
|
|
8
|
-
labels?: boolean | ((value: string | number |
|
|
9
|
+
labels?: boolean | ((value: string | number | TemporalDate) => string) | {
|
|
9
10
|
collision?: boolean;
|
|
10
|
-
display: (value: string | number |
|
|
11
|
+
display: (value: string | number | TemporalDate) => string;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
export declare const Heatmap: ({ labels, scalars, gradient, className, ...rest }: Props) => React.JSX.Element | null;
|
|
@@ -37,11 +37,11 @@ export declare const Legend: {
|
|
|
37
37
|
domain: {
|
|
38
38
|
x: Array<{
|
|
39
39
|
coordinate: number;
|
|
40
|
-
tick: string | number |
|
|
40
|
+
tick: string | number | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
41
41
|
}>;
|
|
42
42
|
y: Array<{
|
|
43
43
|
coordinate: number;
|
|
44
|
-
tick: string | number |
|
|
44
|
+
tick: string | number | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
45
45
|
}>;
|
|
46
46
|
};
|
|
47
47
|
colors: string[];
|
|
@@ -16,8 +16,8 @@ export declare const Lines: {
|
|
|
16
16
|
Tooltip: React.ComponentType<Omit<React.HTMLAttributes<HTMLDivElement> & {
|
|
17
17
|
tooltip?: ((points: Array<Omit<import("../../export").CartesianDataset[number], "data"> & {
|
|
18
18
|
data: import("../../export").CartesianDataset[number]["data"][number];
|
|
19
|
-
}>, x: number | string |
|
|
20
|
-
title?: (x: number | string |
|
|
19
|
+
}>, x: number | string | import("../../hooks/use-graph/use-graph").TemporalDate) => React.ReactNode) | {
|
|
20
|
+
title?: (x: number | string | import("../../hooks/use-graph/use-graph").TemporalDate) => React.ReactNode;
|
|
21
21
|
display?: (point: import("../../export").CartesianDataset[number]["data"][number]) => React.ReactNode;
|
|
22
22
|
};
|
|
23
23
|
joints?: boolean;
|
|
@@ -39,15 +39,15 @@ export declare const Lines: {
|
|
|
39
39
|
}) => React.JSX.Element;
|
|
40
40
|
Joints: ({ context, border, at, strokeWidth }: {
|
|
41
41
|
at?: {
|
|
42
|
-
x: string | number |
|
|
42
|
+
x: string | number | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
43
43
|
};
|
|
44
44
|
border?: string;
|
|
45
45
|
strokeWidth?: number;
|
|
46
46
|
context: InternalGraphContext;
|
|
47
47
|
}) => (React.JSX.Element | null)[] | null;
|
|
48
48
|
Reference: ({ x, y, ...rest }: React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
49
|
-
x: number | string |
|
|
50
|
-
y: number | string |
|
|
49
|
+
x: number | string | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
50
|
+
y: number | string | import("../../hooks/use-graph/use-graph").TemporalDate;
|
|
51
51
|
}) => React.JSX.Element;
|
|
52
52
|
};
|
|
53
53
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { InternalGraphContext } from "../../../hooks/use-graph/use-graph";
|
|
1
|
+
import { InternalGraphContext, TemporalDate } from "../../../hooks/use-graph/use-graph";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
type Props = {
|
|
4
4
|
at?: {
|
|
5
|
-
x: string | number |
|
|
5
|
+
x: string | number | TemporalDate;
|
|
6
6
|
};
|
|
7
7
|
border?: string;
|
|
8
8
|
strokeWidth?: number;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ComponentProps, JSX } from "react";
|
|
2
|
+
import { TemporalDate } from "../../../hooks/use-graph/use-graph";
|
|
2
3
|
type Props = ComponentProps<"div"> & {
|
|
3
|
-
x: number | string |
|
|
4
|
-
y: number | string |
|
|
4
|
+
x: number | string | TemporalDate;
|
|
5
|
+
y: number | string | TemporalDate;
|
|
5
6
|
};
|
|
6
7
|
export declare const LinesReference: ({ x, y, ...rest }: Props) => JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { RefObject } from "react";
|
|
3
|
-
import { CartesianDataset } from "../../../hooks/use-graph/use-graph";
|
|
3
|
+
import { CartesianDataset, TemporalDate } from "../../../hooks/use-graph/use-graph";
|
|
4
4
|
type Props = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
5
|
tooltip?: ((points: Array<Omit<CartesianDataset[number], "data"> & {
|
|
6
6
|
data: CartesianDataset[number]["data"][number];
|
|
7
|
-
}>, x: number | string |
|
|
8
|
-
title?: (x: number | string |
|
|
7
|
+
}>, x: number | string | TemporalDate) => React.ReactNode) | {
|
|
8
|
+
title?: (x: number | string | TemporalDate) => React.ReactNode;
|
|
9
9
|
display?: (point: CartesianDataset[number]["data"][number]) => React.ReactNode;
|
|
10
10
|
};
|
|
11
11
|
joints?: boolean;
|
|
@@ -23,6 +23,7 @@ import { GradientUtils } from "../../../utils/gradient/gradient";
|
|
|
23
23
|
import { tw } from "../../../utils/cx/cx";
|
|
24
24
|
import { Portal } from "../../Portal/Portal";
|
|
25
25
|
import { useBoundingBox } from "../../../hooks/use-bounding-box";
|
|
26
|
+
import { equals } from "../../../utils/equals/equals";
|
|
26
27
|
const TOOLTIP_MARGIN = 20;
|
|
27
28
|
export const LinesTooltip = (_a) => {
|
|
28
29
|
var _b, _c, _d, _e, _f, _g;
|
|
@@ -42,7 +43,7 @@ export const LinesTooltip = (_a) => {
|
|
|
42
43
|
/* Turn dataset into a dataset with a single point instead of line of points where that point === value near mouse */
|
|
43
44
|
return data
|
|
44
45
|
.flatMap((line, i) => {
|
|
45
|
-
const point = line.data.find((d) =>
|
|
46
|
+
const point = line.data.find((d) => equals(d.x, closest));
|
|
46
47
|
if (!point)
|
|
47
48
|
return [];
|
|
48
49
|
const stroke = (() => {
|
|
@@ -50,7 +51,7 @@ export const LinesTooltip = (_a) => {
|
|
|
50
51
|
if ((_a = line.stroke) === null || _a === void 0 ? void 0 : _a.includes("linear-gradient")) {
|
|
51
52
|
return GradientUtils.gradientColorFromValue({
|
|
52
53
|
gradient: line.stroke,
|
|
53
|
-
point
|
|
54
|
+
point,
|
|
54
55
|
dataset: line.data,
|
|
55
56
|
viewbox,
|
|
56
57
|
domain,
|
|
@@ -68,8 +69,8 @@ export const LinesTooltip = (_a) => {
|
|
|
68
69
|
})();
|
|
69
70
|
const isRightAligned = mouse.px.x > width - tooltipWidth - TOOLTIP_MARGIN;
|
|
70
71
|
const { left, top } = {
|
|
71
|
-
left: Math.round(MathUtils.clamp(mouse.px.x, scale(xForValue(
|
|
72
|
-
? scale(xForValue(
|
|
72
|
+
left: Math.round(MathUtils.clamp(mouse.px.x, scale(xForValue(closest), viewbox.x, width) + TOOLTIP_MARGIN, isRightAligned
|
|
73
|
+
? scale(xForValue(closest), viewbox.x, width) - TOOLTIP_MARGIN - tooltipWidth
|
|
73
74
|
: width - tooltipWidth - TOOLTIP_MARGIN)),
|
|
74
75
|
top: Math.round(MathUtils.clamp(mouse.px.y, TOOLTIP_MARGIN, height - tooltipHeight - TOOLTIP_MARGIN)),
|
|
75
76
|
};
|
|
@@ -91,12 +92,12 @@ export const LinesTooltip = (_a) => {
|
|
|
91
92
|
return (React.createElement(React.Fragment, null,
|
|
92
93
|
React.createElement(Portal, null,
|
|
93
94
|
React.createElement("svg", { viewBox: `0 0 ${viewbox.x} ${viewbox.y}`, className: "[grid-area:graph] h-full w-full absolute overflow-visible pointer-events-none", style: { width: rect.width, height: rect.height, left: rect.left, top: rect.top }, preserveAspectRatio: "none" },
|
|
94
|
-
React.createElement("line", { x1: xForValue(
|
|
95
|
+
React.createElement("line", { x1: xForValue(closest), x2: xForValue(closest), y1: 0, y2: viewbox.y, className: "stroke-black dark:stroke-white", strokeWidth: 4 }),
|
|
95
96
|
joints &&
|
|
96
97
|
(jointPoints === null || jointPoints === void 0 ? void 0 : jointPoints.map(({ data: { x, y }, stroke }, i) => {
|
|
97
98
|
return (React.createElement("path", { key: i, stroke: stroke, fill: stroke, d: `M ${x} ${y} h 0.001`, strokeWidth: "8", strokeLinecap: "round", vectorEffect: "non-scaling-stroke" }));
|
|
98
99
|
}))),
|
|
99
|
-
ordered && (React.createElement(overlay.div, Object.assign({}, rest, { ref: setTooltipRef, className: tw("lines-tooltip__tooltip absolute pointer-events-none", rest.className), style: { left: left + rect.left, top: top + rect.top } }), typeof tooltip === "function" ? (tooltip(ordered, closest)) : (React.createElement("div", Object.assign({}, rest, { className: "text-[14px] leading-[14px] rounded border bg-opacity-60 shadow-md
|
|
100
|
+
ordered && (React.createElement(overlay.div, Object.assign({}, rest, { ref: setTooltipRef, className: tw("lines-tooltip__tooltip absolute pointer-events-none", rest.className), style: { left: left + rect.left, top: top + rect.top } }), typeof tooltip === "function" ? (tooltip(ordered, closest)) : (React.createElement("div", Object.assign({}, rest, { className: "text-[14px] leading-[14px] rounded border bg-opacity-60 shadow-md backdrop-blur-sm w-[250px] pb-1.5 border-gray-200 dark-border-[#454545]" }),
|
|
100
101
|
React.createElement("div", { className: "font-medium [background:linear-gradient(transparent,#CFCFCF)] dark:[background:linear-gradient(transparent,#3C3C3C)] pl-2 pr-2 pt-1.5 pb-1 mb-1.5" }, (() => {
|
|
101
102
|
if (tooltip === null || tooltip === void 0 ? void 0 : tooltip.title)
|
|
102
103
|
return tooltip.title(closest);
|
|
@@ -118,8 +119,8 @@ export const LinesTooltip = (_a) => {
|
|
|
118
119
|
});
|
|
119
120
|
if (tooltip === null || tooltip === void 0 ? void 0 : tooltip.display)
|
|
120
121
|
return tooltip.display(data);
|
|
121
|
-
if (data.y
|
|
122
|
-
return data.y.
|
|
122
|
+
if (typeof data.y !== "string" && typeof data.y !== "number")
|
|
123
|
+
return data.y.toString();
|
|
123
124
|
if (typeof data.y === "string")
|
|
124
125
|
return data.y;
|
|
125
126
|
return formatter.format(data.y);
|
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
export declare const LinesTooltipZone: React.ComponentType<Omit<React.HTMLAttributes<HTMLDivElement> & {
|
|
3
3
|
tooltip?: ((points: Array<Omit<import("../../../export").CartesianDataset[number], "data"> & {
|
|
4
4
|
data: import("../../../export").CartesianDataset[number]["data"][number];
|
|
5
|
-
}>, x: number | string |
|
|
6
|
-
title?: (x: number | string |
|
|
5
|
+
}>, x: number | string | import("../../../hooks/use-graph/use-graph").TemporalDate) => React.ReactNode) | {
|
|
6
|
+
title?: (x: number | string | import("../../../hooks/use-graph/use-graph").TemporalDate) => React.ReactNode;
|
|
7
7
|
display?: (point: import("../../../export").CartesianDataset[number]["data"][number]) => React.ReactNode;
|
|
8
8
|
};
|
|
9
9
|
joints?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode, Ref } from "react";
|
|
2
2
|
import { OverlayRect } from "./OverlayRect";
|
|
3
|
+
import { TemporalDate } from "../../hooks/use-graph/use-graph";
|
|
3
4
|
type HTMLElements = keyof React.JSX.IntrinsicElements;
|
|
4
5
|
type Props = React.HTMLAttributes<HTMLDivElement> & {
|
|
5
6
|
ref?: Ref<HTMLDivElement>;
|
|
@@ -7,12 +8,12 @@ type Props = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
7
8
|
x?: {
|
|
8
9
|
coordinate: number;
|
|
9
10
|
} | {
|
|
10
|
-
tick: number |
|
|
11
|
+
tick: number | TemporalDate | string;
|
|
11
12
|
};
|
|
12
13
|
y?: {
|
|
13
14
|
coordinate: number;
|
|
14
15
|
} | {
|
|
15
|
-
tick: number |
|
|
16
|
+
tick: number | TemporalDate | string;
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
export declare const Overlay: ({ children, tag, ref, x, y, ...rest }: Props) => React.JSX.Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { TemporalDate } from "../../hooks/use-graph/use-graph";
|
|
2
3
|
interface OverlayRectProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
x1:
|
|
4
|
-
y1:
|
|
5
|
-
x2:
|
|
6
|
-
y2?:
|
|
4
|
+
x1: TemporalDate | number | string;
|
|
5
|
+
y1: TemporalDate | number | string;
|
|
6
|
+
x2: TemporalDate | number | string;
|
|
7
|
+
y2?: TemporalDate | number | string;
|
|
7
8
|
}
|
|
8
9
|
export declare const OverlayRect: React.FC<OverlayRectProps>;
|
|
9
10
|
export {};
|
|
@@ -22,9 +22,7 @@ type Props = {
|
|
|
22
22
|
export declare const Pie: {
|
|
23
23
|
({ glow, donut, labels, radius, gap, total, loading, className, onMouseEnter, onMouseLeave, children }: Props): React.JSX.Element | null;
|
|
24
24
|
Tooltip: React.ComponentType<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children"> & {
|
|
25
|
-
children: (segment: InternalSegmentDataset[number]
|
|
26
|
-
percent: number;
|
|
27
|
-
}) => ReactNode;
|
|
25
|
+
children: (segment: InternalSegmentDataset[number]) => ReactNode;
|
|
28
26
|
}>;
|
|
29
27
|
context(ctx: InternalGraphContext, props: Props): InternalGraphContext;
|
|
30
28
|
};
|