nanoplot 0.0.33 → 0.0.35
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 +8 -0
- package/dist/src/components/Area/Area.d.ts +7 -2
- package/dist/src/components/Area/Area.js +27 -24
- package/dist/src/components/Bars/Bars.d.ts +2 -2
- package/dist/src/components/Bars/Bars.js +2 -2
- package/dist/src/components/Bars/components/BarsVerticalLoading.d.ts +1 -1
- package/dist/src/components/Bars/components/BarsVerticalLoading.js +4 -3
- package/dist/src/components/Bars/components/HorizontalBars.d.ts +1 -1
- package/dist/src/components/Bars/components/HorizontalBars.js +32 -26
- package/dist/src/components/Bars/components/Rect.d.ts +1 -1
- package/dist/src/components/Bars/components/Rect.js +12 -3
- package/dist/src/components/Bars/components/VerticalBars.d.ts +1 -1
- package/dist/src/components/Bars/components/VerticalBars.js +32 -26
- package/dist/src/components/Graph/Graph.d.ts +4 -4
- package/dist/src/components/Graph/Graph.js +6 -5
- package/dist/src/components/GridLines/GridLines.d.ts +1 -1
- package/dist/src/components/GridLines/GridLines.js +11 -4
- package/dist/src/components/Heatmap/Heatmap.d.ts +1 -1
- package/dist/src/components/Heatmap/Heatmap.js +27 -23
- package/dist/src/components/HydrateContext/HydrateContext.d.ts +1 -1
- package/dist/src/components/HydrateContext/HydrateContext.js +5 -2
- package/dist/src/components/Legend/Legend.d.ts +1 -1
- package/dist/src/components/Legend/Legend.js +22 -19
- package/dist/src/components/LinearGradient/LinearGradient.d.ts +2 -1
- package/dist/src/components/LinearGradient/LinearGradient.js +2 -2
- package/dist/src/components/Lines/Lines.d.ts +7 -2
- package/dist/src/components/Lines/Lines.js +28 -21
- package/dist/src/components/Lines/components/Line.d.ts +1 -1
- package/dist/src/components/Lines/components/Line.js +9 -3
- package/dist/src/components/Lines/components/LinesLoading.d.ts +2 -1
- package/dist/src/components/Lines/components/LinesLoading.js +4 -2
- package/dist/src/components/Lines/components/LinesTooltip.d.ts +10 -1
- package/dist/src/components/Lines/components/LinesTooltip.js +30 -21
- package/dist/src/components/Overlay/Overlay.d.ts +1 -1
- package/dist/src/components/Overlay/Overlay.js +4 -4
- package/dist/src/components/Overlay/OverlayRect.js +3 -3
- package/dist/src/components/Pie/Pie.d.ts +2 -2
- package/dist/src/components/Pie/Pie.js +31 -9
- package/dist/src/components/Pie/components/PieEmpty.d.ts +2 -1
- package/dist/src/components/Pie/components/PieEmpty.js +9 -3
- package/dist/src/components/Pie/components/PieLoading.d.ts +2 -1
- package/dist/src/components/Pie/components/PieLoading.js +7 -3
- package/dist/src/components/Portal/Portal.d.ts +2 -1
- package/dist/src/components/Portal/Portal.js +2 -2
- package/dist/src/components/Radar/Radar.d.ts +2 -1
- package/dist/src/components/Radar/Radar.js +99 -70
- package/dist/src/components/Radar/components/RadarSkeleton.d.ts +2 -1
- package/dist/src/components/Radar/components/RadarSkeleton.js +4 -2
- package/dist/src/components/Scatter/Scatter.d.ts +5 -5
- package/dist/src/components/Scatter/Scatter.js +9 -7
- package/dist/src/components/Scatter/components/ScatterLabels.d.ts +1 -1
- package/dist/src/components/Scatter/components/ScatterLabels.js +33 -32
- package/dist/src/components/Scatter/components/ScatterLoading.d.ts +2 -1
- package/dist/src/components/Scatter/components/ScatterLoading.js +4 -2
- package/dist/src/components/Scatter/components/ScatterQuadrant.d.ts +1 -1
- package/dist/src/components/Scatter/components/ScatterQuadrant.js +2 -2
- package/dist/src/components/Scatter/components/ScatterTooltip.d.ts +2 -2
- package/dist/src/components/Scatter/components/ScatterTooltip.js +18 -6
- package/dist/src/components/Sunburst/Sunburst.d.ts +2 -2
- package/dist/src/components/Sunburst/Sunburst.js +24 -21
- package/dist/src/components/Sunburst/SunburstLoading.d.ts +2 -1
- package/dist/src/components/Sunburst/SunburstLoading.js +2 -2
- package/dist/src/components/Tooltip/Popup.d.ts +2 -2
- package/dist/src/components/Tooltip/Popup.js +3 -2
- package/dist/src/components/Tooltip/Tooltip.d.ts +3 -3
- package/dist/src/components/Tooltip/Tooltip.js +17 -12
- package/dist/src/components/Worldmap/Worldmap.d.ts +1 -1
- package/dist/src/components/Worldmap/Worldmap.js +37 -33
- package/dist/src/components/XAxis/XAxis.d.ts +1 -1
- package/dist/src/components/XAxis/XAxis.js +16 -9
- package/dist/src/components/YAxis/YAxis.d.ts +1 -1
- package/dist/src/components/YAxis/YAxis.js +16 -11
- package/dist/src/hooks/use-graph/use-client-graph.d.ts +1 -1
- package/dist/src/hooks/use-graph/use-client-graph.js +2 -2
- package/dist/src/hooks/use-graph/use-server-graph.d.ts +2 -1
- package/dist/src/hooks/use-graph/use-server-graph.js +2 -2
- package/dist/tsconfig.typings.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/tsconfig.typings.json +1 -1
package/dist/index.css
CHANGED
|
@@ -185,6 +185,10 @@
|
|
|
185
185
|
margin-top: 0.25rem;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
.mt-10 {
|
|
189
|
+
margin-top: 2.5rem;
|
|
190
|
+
}
|
|
191
|
+
|
|
188
192
|
.mt-2 {
|
|
189
193
|
margin-top: 0.5rem;
|
|
190
194
|
}
|
|
@@ -583,6 +587,10 @@
|
|
|
583
587
|
border-bottom-width: 1px;
|
|
584
588
|
}
|
|
585
589
|
|
|
590
|
+
.border-solid {
|
|
591
|
+
border-style: solid;
|
|
592
|
+
}
|
|
593
|
+
|
|
586
594
|
.border-dotted {
|
|
587
595
|
border-style: dotted;
|
|
588
596
|
}
|
|
@@ -7,8 +7,13 @@ interface Props extends React.SVGAttributes<SVGSVGElement> {
|
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare const Area: {
|
|
10
|
-
({ className, curve, children, loading }: Props):
|
|
10
|
+
({ className, curve, children, loading }: Props): React.JSX.Element | null;
|
|
11
11
|
context(ctx: GraphContext): GraphContext;
|
|
12
|
-
Tooltip:
|
|
12
|
+
Tooltip: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & {
|
|
13
|
+
tooltip?: (points: Array<Omit<import("../../export").CartesianDataset[number], "data"> & {
|
|
14
|
+
data: import("../../export").CartesianDataset[number]["data"][number];
|
|
15
|
+
}>, x: number | string | Date) => React.ReactNode;
|
|
16
|
+
joints?: boolean;
|
|
17
|
+
}>;
|
|
13
18
|
};
|
|
14
19
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { GraphUtils } from "../../utils/graph/graph";
|
|
4
3
|
import { useGraph } from "../../hooks/use-graph/use-graph";
|
|
@@ -24,30 +23,34 @@ export const Area = ({ className, curve = "linear", children, loading }) => {
|
|
|
24
23
|
})) });
|
|
25
24
|
});
|
|
26
25
|
const grouped = Object.entries(ObjectUtils.groupBy(lines, ({ group, id }) => group !== null && group !== void 0 ? group : id));
|
|
27
|
-
return (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return Object.assign(Object.assign({}, line), { data, stroke: (_b = (_a = line.stroke) !== null && _a !== void 0 ? _a : colors[i]) !== null && _b !== void 0 ? _b : colors.at(-1), path: CurveUtils[curve](data) });
|
|
37
|
-
}).map(({ id, stroke, data, path, fill }, i, segments) => {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const previous = segments[i - 1] ? CurveUtils[curve]((_a = segments[i - 1]) === null || _a === void 0 ? void 0 : _a.data.reverse()).replace("M", "L") : undefined;
|
|
40
|
-
const disabled = pinned.length && !pinned.includes(id) && !hovered.includes(id);
|
|
41
|
-
const filled = (() => {
|
|
42
|
-
if (fill)
|
|
43
|
-
return fill;
|
|
44
|
-
if (stroke.includes("linear-gradient"))
|
|
45
|
-
return "transparent";
|
|
46
|
-
return stroke;
|
|
47
|
-
})();
|
|
48
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Line, { d: path, disabled: Boolean(disabled), stroke: stroke, fill: "transparent", className: "area__stroke" }), _jsx(Line, { d: path + (previous !== null && previous !== void 0 ? previous : ` L ${viewbox.x} ${viewbox.y} L 0 ${viewbox.y} L ${(_b = data[0]) === null || _b === void 0 ? void 0 : _b.x} ${viewbox.y} Z`), disabled: Boolean(disabled), stroke: "transparent", fill: filled, className: "area__fill" })] }, i + "|" + index));
|
|
26
|
+
return (React.createElement("svg", { viewBox: `0 0 ${viewbox.x} ${viewbox.y}`, preserveAspectRatio: "none", className: cx("area h-full w-full [grid-area:graph]", className) },
|
|
27
|
+
grouped.flatMap(([, lines], index) => {
|
|
28
|
+
return lines === null || lines === void 0 ? void 0 : lines.map((line, i) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const data = line.data.map(({ x, y }, ii) => {
|
|
31
|
+
return {
|
|
32
|
+
x: x,
|
|
33
|
+
y: y - lines.slice(0, i).reduce((acc, { data }) => acc + (viewbox.y - data[ii].y), 0),
|
|
34
|
+
};
|
|
49
35
|
});
|
|
50
|
-
|
|
36
|
+
return Object.assign(Object.assign({}, line), { data, stroke: (_b = (_a = line.stroke) !== null && _a !== void 0 ? _a : colors[i]) !== null && _b !== void 0 ? _b : colors.at(-1), path: CurveUtils[curve](data) });
|
|
37
|
+
}).map(({ id, stroke, data, path, fill }, i, segments) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const previous = segments[i - 1] ? CurveUtils[curve]((_a = segments[i - 1]) === null || _a === void 0 ? void 0 : _a.data.reverse()).replace("M", "L") : undefined;
|
|
40
|
+
const disabled = pinned.length && !pinned.includes(id) && !hovered.includes(id);
|
|
41
|
+
const filled = (() => {
|
|
42
|
+
if (fill)
|
|
43
|
+
return fill;
|
|
44
|
+
if (stroke.includes("linear-gradient"))
|
|
45
|
+
return "transparent";
|
|
46
|
+
return stroke;
|
|
47
|
+
})();
|
|
48
|
+
return (React.createElement(React.Fragment, { key: i + "|" + index },
|
|
49
|
+
React.createElement(Line, { d: path, disabled: Boolean(disabled), stroke: stroke, fill: "transparent", className: "area__stroke" }),
|
|
50
|
+
React.createElement(Line, { d: path + (previous !== null && previous !== void 0 ? previous : ` L ${viewbox.x} ${viewbox.y} L 0 ${viewbox.y} L ${(_b = data[0]) === null || _b === void 0 ? void 0 : _b.x} ${viewbox.y} Z`), disabled: Boolean(disabled), stroke: "transparent", fill: filled, className: "area__fill" })));
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
children));
|
|
51
54
|
};
|
|
52
55
|
Area.context = (ctx) => {
|
|
53
56
|
return Object.assign(Object.assign({}, ctx), { colors: ColorUtils.scheme.sunset });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
1
|
+
import React, { ComponentProps } from "react";
|
|
2
2
|
import { HorizontalBars } from "./components/HorizontalBars";
|
|
3
3
|
import { VerticalBars } from "./components/VerticalBars";
|
|
4
4
|
import { GraphContext } from "../../hooks/use-graph/use-graph";
|
|
@@ -9,7 +9,7 @@ type HorizontalProps = {
|
|
|
9
9
|
horizontal?: true;
|
|
10
10
|
} & ComponentProps<typeof HorizontalBars>;
|
|
11
11
|
export declare const Bars: {
|
|
12
|
-
({ horizontal, ...props }: VerticalProps | HorizontalProps):
|
|
12
|
+
({ horizontal, ...props }: VerticalProps | HorizontalProps): React.JSX.Element;
|
|
13
13
|
context(ctx: GraphContext): GraphContext;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -9,13 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
12
|
+
import React from "react";
|
|
13
13
|
import { HorizontalBars } from "./components/HorizontalBars";
|
|
14
14
|
import { VerticalBars } from "./components/VerticalBars";
|
|
15
15
|
import { ColorUtils } from "../../utils/color/color";
|
|
16
16
|
export const Bars = (_a) => {
|
|
17
17
|
var { horizontal } = _a, props = __rest(_a, ["horizontal"]);
|
|
18
|
-
return horizontal ?
|
|
18
|
+
return horizontal ? React.createElement(HorizontalBars, Object.assign({}, props)) : React.createElement(VerticalBars, Object.assign({}, props));
|
|
19
19
|
};
|
|
20
20
|
Bars.context = (ctx) => {
|
|
21
21
|
return Object.assign(Object.assign({}, ctx), { colors: ColorUtils.scheme.contrast });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BarsVerticalLoading: () => import("react
|
|
1
|
+
export declare const BarsVerticalLoading: () => import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { useId } from "react";
|
|
3
2
|
import { cx } from "../../../utils/cx/cx";
|
|
4
3
|
import { useGraph } from "../../../hooks/use-graph/use-graph";
|
|
@@ -9,8 +8,10 @@ export const BarsVerticalLoading = () => {
|
|
|
9
8
|
const CY = viewbox.y / 2;
|
|
10
9
|
const BAR_GAP = 20;
|
|
11
10
|
const BAR_WIDTH = viewbox.x * 0.08;
|
|
12
|
-
return (
|
|
11
|
+
return (React.createElement("svg", { id: "loading", role: "status", "aria-busy": true, viewBox: `0 0 ${viewbox.x} ${viewbox.y}`, className: cx("[grid-area:graph] h-full w-full"), preserveAspectRatio: "none" },
|
|
12
|
+
React.createElement("path", { vectorEffect: "non-scaling-stroke", d: `
|
|
13
13
|
M${CX - BAR_WIDTH - BAR_GAP - BAR_WIDTH / 2} ${viewbox.y} L${CX - BAR_WIDTH - BAR_GAP - BAR_WIDTH / 2} ${(viewbox.y / 30) * 20} L${CX - BAR_WIDTH - BAR_GAP + BAR_WIDTH - BAR_WIDTH / 2} ${(viewbox.y / 30) * 20} L${CX - BAR_WIDTH - BAR_GAP + BAR_WIDTH - BAR_WIDTH / 2} ${viewbox.y}
|
|
14
14
|
M ${CX - BAR_WIDTH / 2} ${viewbox.y} L${CX - BAR_WIDTH / 2} ${(viewbox.y / 30) * 10} L${CX + BAR_WIDTH - BAR_WIDTH / 2} ${(viewbox.y / 30) * 10} L${CX + BAR_WIDTH - BAR_WIDTH / 2} ${viewbox.y}
|
|
15
|
-
M${BAR_GAP + CX + BAR_WIDTH - BAR_WIDTH / 2} ${viewbox.y} L${BAR_GAP + CX + BAR_WIDTH - BAR_WIDTH / 2} ${(viewbox.y / 30) * 16} L${BAR_GAP + CX + 2 * BAR_WIDTH - BAR_WIDTH / 2} ${(viewbox.y / 30) * 16} L${BAR_GAP + CX + 2 * BAR_WIDTH - BAR_WIDTH / 2} ${viewbox.y}`, className: "[filter:brightness(300%)] dark:[filter:brightness(100%)]", mask: `url(#${maskId})
|
|
15
|
+
M${BAR_GAP + CX + BAR_WIDTH - BAR_WIDTH / 2} ${viewbox.y} L${BAR_GAP + CX + BAR_WIDTH - BAR_WIDTH / 2} ${(viewbox.y / 30) * 16} L${BAR_GAP + CX + 2 * BAR_WIDTH - BAR_WIDTH / 2} ${(viewbox.y / 30) * 16} L${BAR_GAP + CX + 2 * BAR_WIDTH - BAR_WIDTH / 2} ${viewbox.y}`, className: "[filter:brightness(300%)] dark:[filter:brightness(100%)]", mask: `url(#${maskId})` },
|
|
16
|
+
React.createElement("animate", { attributeName: "fill", values: "#2d2d2d; #3c3c3c; #2d2d2d; #2d2d2d; ", dur: "2s", repeatCount: "indefinite" }))));
|
|
16
17
|
};
|
|
@@ -9,5 +9,5 @@ type Props = React.SVGAttributes<SVGSVGElement> & {
|
|
|
9
9
|
display: (value: string | number | Date) => string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const HorizontalBars: ({ children, labels, size, radius, className }: Props) =>
|
|
12
|
+
export declare const HorizontalBars: ({ children, labels, size, radius, className }: Props) => React.JSX.Element | null;
|
|
13
13
|
export {};
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
12
|
+
import React from "react";
|
|
13
13
|
import { CoordinatesUtils } from "../../../utils/coordinates/coordinates";
|
|
14
14
|
import { GraphUtils } from "../../../utils/graph/graph";
|
|
15
15
|
import { useGraph } from "../../../hooks/use-graph/use-graph";
|
|
@@ -43,29 +43,35 @@ export const HorizontalBars = ({ children, labels, size = 50, radius = 0, classN
|
|
|
43
43
|
});
|
|
44
44
|
})
|
|
45
45
|
.filter((x) => !!x);
|
|
46
|
-
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
return (React.createElement(React.Fragment, null,
|
|
47
|
+
React.createElement("svg", { viewBox: `0 0 ${context.viewbox.x} ${context.viewbox.y}`, className: cx("horizontal-bars [grid-area:graph] h-full w-full", className), preserveAspectRatio: "none" },
|
|
48
|
+
dataset.map((_a, index) => {
|
|
49
|
+
var { x1, x2, y1, y2 } = _a, bar = __rest(_a, ["x1", "x2", "y1", "y2"]);
|
|
50
|
+
return (React.createElement(Rect, { key: index, x1: x1, x2: x2, y2: y2, y1: y1, fill: String(bar.fill), stroke: bar.stroke, radius: bar.radius, glow: false, horizontal: true, className: "horizontal-bars__rect" }));
|
|
51
|
+
}),
|
|
52
|
+
children),
|
|
53
|
+
labels &&
|
|
54
|
+
dataset.map((bar, i) => {
|
|
55
|
+
const position = typeof labels === "object" && "position" in labels ? labels.position : "center";
|
|
56
|
+
const collision = typeof labels === "object" && "collision" in labels ? labels.collision : true;
|
|
57
|
+
const width = Math.abs(MathUtils.scale(bar.x2 - bar.x1, context.viewbox.x, 100) - (position === "above" ? 100 : 0)) + "%";
|
|
58
|
+
const height = MathUtils.scale(bar.y2 - bar.y1, context.viewbox.y, 100);
|
|
59
|
+
const top = MathUtils.scale(bar.y1, context.viewbox.y, 100);
|
|
60
|
+
const label = (() => {
|
|
61
|
+
var _a;
|
|
62
|
+
if (typeof labels === "object" && "position" in labels)
|
|
63
|
+
return labels.display(bar.data.x);
|
|
64
|
+
return (_a = (labels === true ? bar.data.y : labels(bar.data.y))) !== null && _a !== void 0 ? _a : "";
|
|
65
|
+
})();
|
|
66
|
+
const breakpoint = [2, 4, 6, 8, 10, 15, 20].find((bp) => bp >= label.toString().length);
|
|
67
|
+
return (React.createElement(overlay.div, { key: i, className: "horizontal-bars__label @container-[size] absolute text-center", style: {
|
|
68
|
+
width,
|
|
69
|
+
height: height + "%",
|
|
70
|
+
left: position === "above" ? "unset" : 0,
|
|
71
|
+
right: position === "above" ? 0 : "unset",
|
|
72
|
+
top: top + "%",
|
|
73
|
+
} },
|
|
74
|
+
React.createElement("div", { className: "h-full w-full relative" },
|
|
75
|
+
React.createElement("span", { className: cx("text-xs horizontal-bars__label-text absolute", position === "center" && "top-[50%] left-[50%] transform -translate-x-1/2 -translate-y-1/2", position === "above" && "top-[50%] left-2 transform -translate-y-1/2", collision && "invisible", breakpoint === 2 && collision && "@[width:2ch|height:1.25em]:!visible", breakpoint === 4 && collision && "@[width:4ch|height:1.25em]:!visible", breakpoint === 6 && collision && "@[width:6ch|height:1.25em]:!visible", breakpoint === 8 && collision && "@[width:8ch|height:1.25em]:!visible", breakpoint === 10 && collision && "@[width:10ch|height:1.25em]:!visible", breakpoint === 15 && collision && "@[width:15ch|height:1.25em]:!visible", breakpoint === 20 && collision && "@[width:20ch|height:1.25em]:!visible"), style: { color: position === "center" ? ColorUtils.textFor(String(bar.fill)) : undefined } }, label.toString()))));
|
|
76
|
+
})));
|
|
71
77
|
};
|
|
@@ -8,5 +8,5 @@ type Props = JSX.IntrinsicElements["path"] & {
|
|
|
8
8
|
horizontal?: boolean;
|
|
9
9
|
glow?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare const Rect: ({ x1, y1, x2, y2, radius, glow, horizontal, ...rest }: Props) =>
|
|
11
|
+
export declare const Rect: ({ x1, y1, x2, y2, radius, glow, horizontal, ...rest }: Props) => JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -9,8 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
13
|
-
import { useId } from "react";
|
|
12
|
+
import React, { useId } from "react";
|
|
14
13
|
import { LinearGradient } from "../../LinearGradient/LinearGradient";
|
|
15
14
|
import { PathUtils } from "../../../utils/path/path";
|
|
16
15
|
import { useGraph } from "../../../hooks/use-graph/use-graph";
|
|
@@ -29,5 +28,15 @@ export const Rect = (_a) => {
|
|
|
29
28
|
const isGradientStroke = (_d = rest.stroke) === null || _d === void 0 ? void 0 : _d.includes("gradient");
|
|
30
29
|
const path = PathUtils.borderRadius({ x: x1, y: y1 }, { x: x2, y: y2 }, radius !== null && radius !== void 0 ? radius : 0, horizontal);
|
|
31
30
|
const height = MathUtils.scale(y2 - y1, viewbox.y, 100);
|
|
32
|
-
return (
|
|
31
|
+
return (React.createElement(React.Fragment, null,
|
|
32
|
+
isFillGradient && rest.fill && React.createElement(LinearGradient, { id: fillId, gradient: rest.fill }),
|
|
33
|
+
isGradientStroke && rest.stroke && React.createElement(LinearGradient, { id: strokeId, gradient: rest.stroke }),
|
|
34
|
+
React.createElement("path", { id: clipId, d: path }),
|
|
35
|
+
React.createElement("clipPath", { id: clip },
|
|
36
|
+
React.createElement("use", { xlinkHref: "#" + clipId })),
|
|
37
|
+
glow && (React.createElement(React.Fragment, null,
|
|
38
|
+
React.createElement("use", { xlinkHref: `#${glowId}`, filter: "blur(45px)", opacity: 0.5 }),
|
|
39
|
+
React.createElement("g", { id: glowId },
|
|
40
|
+
React.createElement("path", { fill: isFillGradient ? `url(#${fillId})` : rest.fill, stroke: "transparent", d: path, vectorEffect: "non-scaling-stroke", className: rest.className, strokeWidth: 5 })))),
|
|
41
|
+
isFillMasked ? (React.createElement("rect", { x: x1, y: 0, width: x2 - x1, height: "100%", fill: `url(#${fillId})`, clipPath: `url(#${clip})` })) : (React.createElement("path", { fill: isFillGradient ? `url(#${fillId})` : rest.fill, stroke: isGradientStroke ? `url(#${strokeId})` : rest.stroke, d: path, vectorEffect: "non-scaling-stroke", strokeWidth: 10, className: rest.className, clipPath: `url(#${clip})` }))));
|
|
33
42
|
};
|
|
@@ -11,5 +11,5 @@ type Props = React.SVGAttributes<SVGSVGElement> & {
|
|
|
11
11
|
display: (value: string | number | Date) => string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare const VerticalBars: ({ children, size, labels, radius, glow, className, loading, ...rest }: Props) =>
|
|
14
|
+
export declare const VerticalBars: ({ children, size, labels, radius, glow, className, loading, ...rest }: Props) => React.JSX.Element | null;
|
|
15
15
|
export {};
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
12
|
+
import React from "react";
|
|
13
13
|
import { useGraph } from "../../../hooks/use-graph/use-graph";
|
|
14
14
|
import { GraphUtils } from "../../../utils/graph/graph";
|
|
15
15
|
import { BarsVerticalLoading } from "./BarsVerticalLoading";
|
|
@@ -26,7 +26,7 @@ export const VerticalBars = (_a) => {
|
|
|
26
26
|
if (!GraphUtils.isXYData(context.data))
|
|
27
27
|
return null;
|
|
28
28
|
if (loading)
|
|
29
|
-
return
|
|
29
|
+
return React.createElement(BarsVerticalLoading, null);
|
|
30
30
|
const yForValue = CoordinatesUtils.yCoordinateFor(context);
|
|
31
31
|
const bars = context.data.flatMap((bar, i, bars) => bar.data.map((xy) => {
|
|
32
32
|
var _a, _b, _c, _d, _e;
|
|
@@ -46,28 +46,34 @@ export const VerticalBars = (_a) => {
|
|
|
46
46
|
});
|
|
47
47
|
})
|
|
48
48
|
.filter((x) => !!x);
|
|
49
|
-
return (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
return (React.createElement(React.Fragment, null,
|
|
50
|
+
React.createElement("svg", Object.assign({}, rest, { viewBox: `0 0 ${context.viewbox.x} ${context.viewbox.y}`, className: cx("horizontal-bars [grid-area:graph] h-full w-full bars", className), preserveAspectRatio: "none" }),
|
|
51
|
+
dataset.map((_a, index) => {
|
|
52
|
+
var { x1, x2, y1, y2 } = _a, bar = __rest(_a, ["x1", "x2", "y1", "y2"]);
|
|
53
|
+
return (React.createElement(Rect, { key: index, x1: x1, x2: x2, y2: y2, y1: y1, fill: String(bar.fill), stroke: bar.stroke, radius: bar.radius, glow: glow, className: "horizontal-bars__rect" }));
|
|
54
|
+
}),
|
|
55
|
+
children),
|
|
56
|
+
labels &&
|
|
57
|
+
dataset.map((bar, i) => {
|
|
58
|
+
const position = typeof labels === "object" && "position" in labels ? labels.position : "center";
|
|
59
|
+
const collision = typeof labels === "object" && "collision" in labels ? labels.collision : true;
|
|
60
|
+
const width = MathUtils.scale(bar.x2 - bar.x1, context.viewbox.x, 100) + "%";
|
|
61
|
+
const height = MathUtils.scale(bar.y1 - bar.y2, context.viewbox.y, 100);
|
|
62
|
+
const top = position === "above" ? -4 : MathUtils.scale(bar.y2, context.viewbox.y, 100) + "%";
|
|
63
|
+
const label = (() => {
|
|
64
|
+
var _a;
|
|
65
|
+
if (typeof labels === "object" && "position" in labels)
|
|
66
|
+
return labels.display(bar.data.y);
|
|
67
|
+
return (_a = (labels === true ? bar.data.y : labels(bar.data.y))) !== null && _a !== void 0 ? _a : "";
|
|
68
|
+
})();
|
|
69
|
+
const breakpoint = [2, 4, 6, 8, 10, 15, 20].find((bp) => bp >= label.toString().length);
|
|
70
|
+
return (React.createElement(overlay.div, { key: i, className: "horizontal-bars__label @container-[size] absolute text-center", style: {
|
|
71
|
+
width,
|
|
72
|
+
height: Math.abs(height - (position === "above" ? 100 : 0)) + "%",
|
|
73
|
+
left: `${MathUtils.scale(bar.x1, context.viewbox.x, 100)}%`,
|
|
74
|
+
top: top,
|
|
75
|
+
} },
|
|
76
|
+
React.createElement("div", { className: "h-full w-full relative" },
|
|
77
|
+
React.createElement("span", { className: cx("horizontal-bars__label-text text-xs absolute", position === "center" && "top-[50%] left-[50%] transform -translate-x-1/2 -translate-y-1/2", position === "above" && "text-black dark:text-white bottom-0 left-[50%] transform -translate-x-1/2", collision && "invisible", breakpoint === 2 && collision && "@[width:2ch|height:1.25em]:!visible", breakpoint === 4 && collision && "@[width:4ch|height:1.25em]:!visible", breakpoint === 6 && collision && "@[width:6ch|height:1.25em]:!visible", breakpoint === 8 && collision && "@[width:8ch|height:1.25em]:!visible", breakpoint === 10 && collision && "@[width:10ch|height:1.25em]:!visible", breakpoint === 15 && collision && "@[width:15ch|height:1.25em]:!visible", breakpoint === 20 && collision && "@[width:20ch|height:1.25em]:!visible"), style: { color: position === "center" ? ColorUtils.textFor(String(bar.fill)) : undefined } }, label.toString()))));
|
|
78
|
+
})));
|
|
73
79
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
1
|
+
import React, { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
2
2
|
import { GraphContext } from "../../hooks/use-graph/use-graph";
|
|
3
3
|
type Props = {
|
|
4
4
|
data?: GraphContext["data"];
|
|
@@ -17,8 +17,8 @@ type Props = {
|
|
|
17
17
|
className?: string;
|
|
18
18
|
};
|
|
19
19
|
export declare const Graph: {
|
|
20
|
-
({ data, gap, children, interactions, style, className }: Props):
|
|
21
|
-
Row({ children, ...rest }: HTMLAttributes<HTMLDivElement>):
|
|
22
|
-
Column({ children, ...rest }: HTMLAttributes<HTMLDivElement>):
|
|
20
|
+
({ data, gap, children, interactions, style, className }: Props): React.JSX.Element;
|
|
21
|
+
Row({ children, ...rest }: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
22
|
+
Column({ children, ...rest }: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
23
23
|
};
|
|
24
24
|
export {};
|
|
@@ -9,8 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
13
|
-
import { useId } from "react";
|
|
12
|
+
import React, { useId } from "react";
|
|
14
13
|
import { GraphContextProvider } from "../../hooks/use-graph/use-graph";
|
|
15
14
|
import { ChildrenUtils } from "../../utils/children/children";
|
|
16
15
|
import { GraphUtils } from "../../utils/graph/graph";
|
|
@@ -49,13 +48,15 @@ export const Graph = ({ data = [], gap, children, interactions, style, className
|
|
|
49
48
|
var _a, _b, _c;
|
|
50
49
|
return Object.assign({ id: (_a = dp.id) !== null && _a !== void 0 ? _a : dp.name, stroke: typeof dp.fill === "string" && !dp.stroke ? dp.fill : ((_c = (_b = dp.stroke) !== null && _b !== void 0 ? _b : ctx.colors[i]) !== null && _c !== void 0 ? _c : ctx.colors.at(-1)) }, dp);
|
|
51
50
|
}) });
|
|
52
|
-
return (
|
|
51
|
+
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) }),
|
|
52
|
+
React.createElement("script", { id: id + "-context", type: "application/json", dangerouslySetInnerHTML: { __html: JSON.stringify(colorized) } }),
|
|
53
|
+
React.createElement(GraphContextProvider, { value: colorized }, children)));
|
|
53
54
|
};
|
|
54
55
|
Graph.Row = (_a) => {
|
|
55
56
|
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
56
|
-
return (
|
|
57
|
+
return (React.createElement("div", Object.assign({}, rest, { className: cx("col-span-full", rest.className) }), children));
|
|
57
58
|
};
|
|
58
59
|
Graph.Column = (_a) => {
|
|
59
60
|
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
60
|
-
return
|
|
61
|
+
return React.createElement("div", Object.assign({}, rest), children);
|
|
61
62
|
};
|
|
@@ -5,5 +5,5 @@ interface Props extends React.SVGAttributes<SVGSVGElement> {
|
|
|
5
5
|
horizontal?: boolean;
|
|
6
6
|
vertical?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare const GridLines: ({ border, horizontal, vertical, className }: Props) =>
|
|
8
|
+
export declare const GridLines: ({ border, horizontal, vertical, className }: Props) => React.JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { cx } from "../../utils/cx/cx";
|
|
3
3
|
import { useGraph } from "../../hooks/use-graph/use-graph";
|
|
4
4
|
export const GridLines = ({ border, horizontal, vertical, className }) => {
|
|
5
5
|
const context = useGraph();
|
|
6
6
|
const { x, y } = context.viewbox;
|
|
7
7
|
const { domain } = context;
|
|
8
|
-
return (
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
return (React.createElement("svg", { viewBox: `0 0 ${x} ${y}`, className: cx("[grid-area:graph] h-full w-full", className), preserveAspectRatio: "none" },
|
|
9
|
+
border && (React.createElement(React.Fragment, null,
|
|
10
|
+
React.createElement("line", { x1: 0, y1: 0, x2: x, y2: 0, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: "stroke-gray-200 dark:stroke-dark-priority-100 dark:stroke-dark-priority-100 grid-lines__border" }),
|
|
11
|
+
React.createElement("line", { x1: x, y1: 0, x2: x, y2: y, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: "stroke-gray-200 dark:stroke-dark-priority-100 dark:stroke-dark-priority-100 grid-lines__border" }),
|
|
12
|
+
React.createElement("line", { x1: x, y1: y, x2: 0, y2: y, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: "stroke-gray-200 dark:stroke-dark-priority-100 dark:stroke-dark-priority-100 grid-lines__border" }),
|
|
13
|
+
React.createElement("line", { x1: 0, y1: y, x2: 0, y2: 0, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: "stroke-gray-200 dark:stroke-dark-priority-100 dark:stroke-dark-priority-100 grid-lines__border" }))),
|
|
14
|
+
horizontal &&
|
|
15
|
+
domain.y.map(({ coordinate }) => (React.createElement("line", { key: coordinate, x1: 0, y1: coordinate, x2: x, y2: coordinate, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: "stroke-gray-200 dark:stroke-dark-priority-100 dark:stroke-dark-priority-100 grid-lines__horizontal" }))),
|
|
16
|
+
vertical &&
|
|
17
|
+
domain.x.map(({ coordinate }) => (React.createElement("line", { key: coordinate, x1: coordinate, y1: 0, x2: coordinate, y2: y, strokeWidth: 1, vectorEffect: "non-scaling-stroke", className: "stroke-gray-200 dark:stroke-dark-priority-100 dark:stroke-dark-priority-100 grid-lines__vertical" })))));
|
|
11
18
|
};
|
|
@@ -10,5 +10,5 @@ type Props = React.HTMLAttributes<SVGSVGElement> & {
|
|
|
10
10
|
display: (value: string | number | Date) => string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare const Heatmap: ({ labels, scalars, gradient, className, ...rest }: Props) =>
|
|
13
|
+
export declare const Heatmap: ({ labels, scalars, gradient, className, ...rest }: Props) => React.JSX.Element | null;
|
|
14
14
|
export {};
|
|
@@ -9,7 +9,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
12
|
import { useGraph } from "../../hooks/use-graph/use-graph";
|
|
14
13
|
import { cx } from "../../utils/cx/cx";
|
|
15
14
|
import { Rect } from "../Bars/components/Rect";
|
|
@@ -19,6 +18,7 @@ import { MathUtils } from "../../utils/math/math";
|
|
|
19
18
|
import { GradientUtils } from "../../utils/gradient/gradient";
|
|
20
19
|
import { overlay } from "../Overlay/Overlay";
|
|
21
20
|
import { ColorUtils } from "../../utils/color/color";
|
|
21
|
+
import React from "react";
|
|
22
22
|
import { ScalarUtils } from "../../utils/scalars/scalars";
|
|
23
23
|
export const Heatmap = (_a) => {
|
|
24
24
|
var { labels = true, scalars, gradient, className } = _a, rest = __rest(_a, ["labels", "scalars", "gradient", "className"]);
|
|
@@ -50,26 +50,30 @@ export const Heatmap = (_a) => {
|
|
|
50
50
|
};
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
-
return (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
53
|
+
return (React.createElement(React.Fragment, null,
|
|
54
|
+
React.createElement("svg", Object.assign({}, rest, { viewBox: `0 0 ${viewbox.x} ${viewbox.y}`, className: cx("heatmap [grid-area:graph] h-full w-full bars", className), preserveAspectRatio: "none" }), dataset.flatMap(({ x1, x2, y1, y2, fill }, i) => {
|
|
55
|
+
return React.createElement(Rect, { key: i, x1: x1, x2: x2, y1: y1, y2: y2, fill: fill });
|
|
56
|
+
})),
|
|
57
|
+
labels &&
|
|
58
|
+
dataset.map((rect, i) => {
|
|
59
|
+
const collision = typeof labels === "object" && "collision" in labels ? labels.collision : true;
|
|
60
|
+
const width = MathUtils.scale(rect.x2 - rect.x1, context.viewbox.x, 100) + "%";
|
|
61
|
+
const height = MathUtils.scale(rect.y2 - rect.y1, context.viewbox.y, 100);
|
|
62
|
+
const top = MathUtils.scale(rect.y1, context.viewbox.y, 100);
|
|
63
|
+
const label = (() => {
|
|
64
|
+
var _a;
|
|
65
|
+
if (typeof labels === "object")
|
|
66
|
+
return labels.display(rect.data.z);
|
|
67
|
+
return (_a = (labels === true ? rect.data.z.toString() : labels(rect.data.z))) !== null && _a !== void 0 ? _a : "";
|
|
68
|
+
})();
|
|
69
|
+
const breakpoint = [2, 4, 6, 8, 10, 15, 20].find((bp) => bp >= label.toString().length);
|
|
70
|
+
return (React.createElement(overlay.div, { key: i, className: "heatmap__labels @container-[size] absolute text-center", style: {
|
|
71
|
+
width,
|
|
72
|
+
height: height + "%",
|
|
73
|
+
left: `${MathUtils.scale(rect.x1, context.viewbox.x, 100)}%`,
|
|
74
|
+
top: top + "%",
|
|
75
|
+
} },
|
|
76
|
+
React.createElement("div", { className: "h-full w-full relative" },
|
|
77
|
+
React.createElement("span", { className: cx("text-xs horizontal-bars__label-text absolute top-[50%] left-[50%] transform -translate-x-1/2 -translate-y-1/2", collision && "invisible", breakpoint === 2 && collision && "@[width:2ch|height:1.25em]:!visible", breakpoint === 4 && collision && "@[width:4ch|height:1.25em]:!visible", breakpoint === 6 && collision && "@[width:6ch|height:1.25em]:!visible", breakpoint === 8 && collision && "@[width:8ch|height:1.25em]:!visible", breakpoint === 10 && collision && "@[width:10ch|height:1.25em]:!visible", breakpoint === 15 && collision && "@[width:15ch|height:1.25em]:!visible", breakpoint === 20 && collision && "@[width:20ch|height:1.25em]:!visible"), style: { color: ColorUtils.textFor(String(rect.fill)) } }, label))));
|
|
78
|
+
})));
|
|
75
79
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
export declare const HydrateContext: <PROPS extends Record<
|
|
2
|
+
export declare const HydrateContext: <PROPS extends Record<string | number | symbol, any>>(Component: React.ComponentType<PROPS>) => React.ComponentType<PROPS>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { useContext, useMemo } from "react";
|
|
3
3
|
import { ClientContext, GraphContextClient } from "../../hooks/use-graph/use-client-graph";
|
|
4
4
|
import { useStatefulRef } from "../../hooks/use-stateful-ref";
|
|
@@ -18,6 +18,9 @@ export const HydrateContext = (Component) => {
|
|
|
18
18
|
return null;
|
|
19
19
|
return contextFromParse(context);
|
|
20
20
|
}, [ref.current]);
|
|
21
|
-
return (
|
|
21
|
+
return (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement("div", { className: "[grid-area:graph]", ref: setRef }),
|
|
23
|
+
ctx && (React.createElement(GraphContextClient, { value: ctx },
|
|
24
|
+
React.createElement(Component, Object.assign({}, props))))));
|
|
22
25
|
};
|
|
23
26
|
};
|
|
@@ -6,7 +6,7 @@ type Props = {
|
|
|
6
6
|
children?: ReactNode;
|
|
7
7
|
};
|
|
8
8
|
export declare const Legend: {
|
|
9
|
-
({ position, alignment }: Props):
|
|
9
|
+
({ position, alignment }: Props): React.JSX.Element;
|
|
10
10
|
context(ctx: GraphContext, props: Props): {
|
|
11
11
|
layout: {
|
|
12
12
|
rows: string;
|