ag-common 0.0.650 → 0.0.652
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/ui/components/BarChart/Base.d.ts +3 -1
- package/dist/ui/components/BarChart/Base.js +8 -7
- package/dist/ui/components/BarChart/Item.d.ts +3 -1
- package/dist/ui/components/BarChart/Item.js +5 -4
- package/dist/ui/components/BarChart/Legend.d.ts +3 -1
- package/dist/ui/components/BarChart/Legend.js +7 -8
- package/dist/ui/components/BarChart/TooltipContent.d.ts +3 -1
- package/dist/ui/components/BarChart/TooltipContent.js +2 -4
- package/dist/ui/components/LineChart/Base.js +60 -46
- package/dist/ui/components/LineChart/{Legend.d.ts → LegendX.d.ts} +3 -1
- package/dist/ui/components/LineChart/{Legend.js → LegendX.js} +21 -15
- package/dist/ui/components/LineChart/LegendY.d.ts +7 -0
- package/dist/ui/components/LineChart/LegendY.js +44 -0
- package/dist/ui/components/LineChart/TooltipContent.d.ts +2 -1
- package/dist/ui/components/LineChart/TooltipContent.js +2 -4
- package/dist/ui/components/LineChart/types.d.ts +2 -0
- package/dist/ui/icons/Checkmark.js +1 -1
- package/dist/ui/icons/Circle.js +1 -1
- package/dist/ui/icons/Computer.js +1 -1
- package/dist/ui/icons/Magnify.js +1 -1
- package/dist/ui/icons/Moon.js +1 -1
- package/dist/ui/styles/common.d.ts +10 -1
- package/dist/ui/styles/common.js +6 -1
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type IVarStyles } from '../../styles/common';
|
|
2
3
|
import type { IBarChartData } from './types';
|
|
3
|
-
export declare const BarChart: ({ data: dataRaw }: {
|
|
4
|
+
export declare const BarChart: ({ data: dataRaw, style: sRaw, }: {
|
|
4
5
|
data: IBarChartData[];
|
|
6
|
+
style?: Partial<IVarStyles>;
|
|
5
7
|
}) => React.JSX.Element;
|
|
@@ -7,6 +7,7 @@ exports.BarChart = void 0;
|
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const useTooltip_1 = require("../../helpers/useTooltip");
|
|
10
|
+
const common_1 = require("../../styles/common");
|
|
10
11
|
const Item_1 = require("./Item");
|
|
11
12
|
const Legend_1 = require("./Legend");
|
|
12
13
|
const TooltipContent_1 = require("./TooltipContent");
|
|
@@ -17,7 +18,6 @@ const BarChartBase = styled_1.default.div `
|
|
|
17
18
|
height: 100%;
|
|
18
19
|
margin-top: 0.5rem;
|
|
19
20
|
position: relative;
|
|
20
|
-
background-color: var(--main-bg);
|
|
21
21
|
`;
|
|
22
22
|
const ItemStyled = (0, styled_1.default)(Item_1.Item) `
|
|
23
23
|
margin-bottom: 0.75rem;
|
|
@@ -26,21 +26,22 @@ const ItemStyled = (0, styled_1.default)(Item_1.Item) `
|
|
|
26
26
|
margin-bottom: 0;
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
|
-
const BarChart = ({ data: dataRaw }) => {
|
|
29
|
+
const BarChart = ({ data: dataRaw, style: sRaw, }) => {
|
|
30
|
+
const style = (0, common_1.getVarStyles)(sRaw);
|
|
30
31
|
const UT = (0, useTooltip_1.useTooltip)();
|
|
31
32
|
const maxWidth = Math.max(...dataRaw.map((a) => a.total));
|
|
32
|
-
return (react_1.default.createElement(BarChartBase, { "data-type": "bcb" },
|
|
33
|
-
react_1.default.createElement(UT.Comp, { pos: UT.pos }, (p) => react_1.default.createElement(TooltipContent_1.TooltipContent, Object.assign({}, p))),
|
|
34
|
-
dataRaw.map((data) => (react_1.default.createElement(ItemStyled, { key: data.name, data: data, maxWidth: maxWidth, onMouseLeave: () => UT.setPos(undefined), onMouseMove: (element) => {
|
|
33
|
+
return (react_1.default.createElement(BarChartBase, { "data-type": "bcb", style: style },
|
|
34
|
+
react_1.default.createElement(UT.Comp, { pos: UT.pos }, (p) => react_1.default.createElement(TooltipContent_1.TooltipContent, Object.assign({}, p, { style: style }))),
|
|
35
|
+
dataRaw.map((data) => (react_1.default.createElement(ItemStyled, { style: style, key: data.name, data: data, maxWidth: maxWidth, onMouseLeave: () => UT.setPos(undefined), onMouseMove: (element) => {
|
|
35
36
|
var _a, _b;
|
|
36
37
|
const selectedKey = (_b = (_a = document
|
|
37
38
|
.elementFromPoint(element.pageX, element.pageY)) === null || _a === void 0 ? void 0 : _a.getAttribute('data-barchartitem-key')) !== null && _b !== void 0 ? _b : '';
|
|
38
39
|
UT.setPos({
|
|
39
40
|
element,
|
|
40
41
|
parent: element.currentTarget.closest("[data-type='bcb']"),
|
|
41
|
-
data: {
|
|
42
|
+
data: { selectedKey, data },
|
|
42
43
|
});
|
|
43
44
|
} }))),
|
|
44
|
-
react_1.default.createElement(Legend_1.Legend, { data: dataRaw, maxWidth: maxWidth })));
|
|
45
|
+
react_1.default.createElement(Legend_1.Legend, { data: dataRaw, maxWidth: maxWidth, style: style })));
|
|
45
46
|
};
|
|
46
47
|
exports.BarChart = BarChart;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { MouseEventHandler } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { IVarStyles } from '../../styles';
|
|
3
4
|
import type { IBarChartData } from './types';
|
|
4
|
-
export declare const Item: ({ data, className, onMouseMove, onMouseLeave, maxWidth, }: {
|
|
5
|
+
export declare const Item: ({ data, className, onMouseMove, onMouseLeave, maxWidth, style, }: {
|
|
5
6
|
data: IBarChartData;
|
|
6
7
|
className?: string | undefined;
|
|
7
8
|
onMouseMove?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
8
9
|
onMouseLeave?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
9
10
|
maxWidth: number;
|
|
11
|
+
style: IVarStyles;
|
|
10
12
|
}) => React.JSX.Element;
|
|
@@ -18,11 +18,12 @@ const Base = styled_1.default.div `
|
|
|
18
18
|
const Title = styled_1.default.div `
|
|
19
19
|
position: absolute;
|
|
20
20
|
left: 0.25rem;
|
|
21
|
-
color: var(--main-fg);
|
|
22
|
-
${(0, styles_1.HardOutline)('var(--main-bg)')};
|
|
23
21
|
`;
|
|
24
|
-
const Item = ({ data, className, onMouseMove, onMouseLeave, maxWidth, }) => (react_1.default.createElement(Base, { className: className, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave },
|
|
25
|
-
react_1.default.createElement(Title,
|
|
22
|
+
const Item = ({ data, className, onMouseMove, onMouseLeave, maxWidth, style, }) => (react_1.default.createElement(Base, { className: className, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave, style: style },
|
|
23
|
+
react_1.default.createElement(Title, { style: {
|
|
24
|
+
color: style.color,
|
|
25
|
+
filter: (0, styles_1.HardOutlineFilter)(style.backgroundColor),
|
|
26
|
+
} }, data.name),
|
|
26
27
|
data.values.map((v) => (react_1.default.createElement("div", { "data-barchartitem-key": v.name, key: v.name, style: {
|
|
27
28
|
height: '100%',
|
|
28
29
|
width: `${(v.value / maxWidth) * 100}%`,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { IVarStyles } from '../../styles/common';
|
|
2
3
|
import type { IBarChartData } from './types';
|
|
3
|
-
export declare const Legend: ({ data, maxWidth, }: {
|
|
4
|
+
export declare const Legend: ({ data, maxWidth, style, }: {
|
|
4
5
|
data: IBarChartData[];
|
|
5
6
|
maxWidth: number;
|
|
7
|
+
style: IVarStyles;
|
|
6
8
|
}) => React.JSX.Element;
|
|
@@ -26,7 +26,6 @@ const Line = styled_1.default.div `
|
|
|
26
26
|
height: 2px;
|
|
27
27
|
left: 0;
|
|
28
28
|
right: 0;
|
|
29
|
-
background-color: var(--main-fg);
|
|
30
29
|
`;
|
|
31
30
|
const Numbers = styled_1.default.div `
|
|
32
31
|
width: 100%;
|
|
@@ -35,9 +34,6 @@ const Numbers = styled_1.default.div `
|
|
|
35
34
|
flex-flow: row;
|
|
36
35
|
justify-content: space-between;
|
|
37
36
|
z-index: 1;
|
|
38
|
-
> span {
|
|
39
|
-
background-color: var(--main-bg);
|
|
40
|
-
}
|
|
41
37
|
`;
|
|
42
38
|
const Items = styled_1.default.div `
|
|
43
39
|
width: 100%;
|
|
@@ -59,7 +55,7 @@ const Col = styled_1.default.div `
|
|
|
59
55
|
border-radius: 50%;
|
|
60
56
|
margin-right: 0.25rem;
|
|
61
57
|
`;
|
|
62
|
-
const Legend = ({ data, maxWidth, }) => {
|
|
58
|
+
const Legend = ({ data, maxWidth, style, }) => {
|
|
63
59
|
const items = [0];
|
|
64
60
|
if (maxWidth > 10) {
|
|
65
61
|
items.push(Math.floor(maxWidth * 0.25));
|
|
@@ -73,10 +69,13 @@ const Legend = ({ data, maxWidth, }) => {
|
|
|
73
69
|
name: v.name,
|
|
74
70
|
}));
|
|
75
71
|
})), (s) => s.name).sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
76
|
-
return (react_1.default.createElement(Base,
|
|
72
|
+
return (react_1.default.createElement(Base, { style: style },
|
|
77
73
|
react_1.default.createElement(Bar, null,
|
|
78
|
-
react_1.default.createElement(Line,
|
|
79
|
-
react_1.default.createElement(Numbers, null, items.map((i) => (react_1.default.createElement("span", {
|
|
74
|
+
react_1.default.createElement(Line, { style: { background: style.backgroundColor, color: style.color } }),
|
|
75
|
+
react_1.default.createElement(Numbers, null, items.map((i) => (react_1.default.createElement("span", { style: {
|
|
76
|
+
backgroundColor: style.backgroundColor,
|
|
77
|
+
color: style.color,
|
|
78
|
+
}, key: i }, i))))),
|
|
80
79
|
keys.length > 1 && (react_1.default.createElement(Items, null, keys.map((k) => (react_1.default.createElement(Item, { key: k.name },
|
|
81
80
|
react_1.default.createElement(Col, { style: { backgroundColor: k.colour } }),
|
|
82
81
|
k.name)))))));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { IVarStyles } from '../../styles/common';
|
|
2
3
|
import type { IBarChartData } from './types';
|
|
3
|
-
export declare const TooltipContent: ({ data, selectedKey, }: {
|
|
4
|
+
export declare const TooltipContent: ({ data, selectedKey, style, }: {
|
|
4
5
|
data: IBarChartData;
|
|
5
6
|
selectedKey?: string | undefined;
|
|
7
|
+
style: IVarStyles;
|
|
6
8
|
}) => React.JSX.Element;
|
|
@@ -8,8 +8,6 @@ const styled_1 = __importDefault(require("@emotion/styled"));
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const getLegendItems_1 = require("./getLegendItems");
|
|
10
10
|
const Base = styled_1.default.div `
|
|
11
|
-
background-color: var(--main-bg);
|
|
12
|
-
border: solid 1px var(--main-bg-mid);
|
|
13
11
|
padding: 0.5rem;
|
|
14
12
|
`;
|
|
15
13
|
const Title = styled_1.default.div `
|
|
@@ -34,9 +32,9 @@ const Total = styled_1.default.span `
|
|
|
34
32
|
text-decoration: underline;
|
|
35
33
|
}
|
|
36
34
|
`;
|
|
37
|
-
const TooltipContent = ({ data, selectedKey, }) => {
|
|
35
|
+
const TooltipContent = ({ data, selectedKey, style, }) => {
|
|
38
36
|
const { part, rest, restTotal } = (0, getLegendItems_1.getLegendItems)({ data, selectedKey });
|
|
39
|
-
return (react_1.default.createElement(Base,
|
|
37
|
+
return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { border: `solid 1px ${style.borderColor}` }) },
|
|
40
38
|
react_1.default.createElement(Title, null, data.name),
|
|
41
39
|
react_1.default.createElement(Row, null,
|
|
42
40
|
react_1.default.createElement("span", null, "total"),
|
|
@@ -10,15 +10,19 @@ const react_1 = __importDefault(require("react"));
|
|
|
10
10
|
const array_1 = require("../../../common/helpers/array");
|
|
11
11
|
const math_1 = require("../../../common/helpers/math");
|
|
12
12
|
const useTooltip_1 = require("../../helpers/useTooltip");
|
|
13
|
+
const common_1 = require("../../styles/common");
|
|
14
|
+
const FlexRow_1 = require("../FlexRow");
|
|
13
15
|
const dateHelpers_1 = require("./dateHelpers");
|
|
14
16
|
const getLegendItems_1 = require("./getLegendItems");
|
|
15
17
|
const interpolate_1 = require("./interpolate");
|
|
16
|
-
const
|
|
18
|
+
const LegendX_1 = require("./LegendX");
|
|
19
|
+
const LegendY_1 = require("./LegendY");
|
|
17
20
|
const TooltipContent_1 = require("./TooltipContent");
|
|
18
21
|
const Base = styled_1.default.div `
|
|
19
|
-
width: calc(100% - 1px);
|
|
20
|
-
height: calc(100% - 1px);
|
|
21
22
|
padding: 0.5rem;
|
|
23
|
+
width: calc(100% - 1rem);
|
|
24
|
+
height: calc(100% - 1rem);
|
|
25
|
+
|
|
22
26
|
display: flex;
|
|
23
27
|
flex-flow: column;
|
|
24
28
|
justify-content: center;
|
|
@@ -26,9 +30,15 @@ const Base = styled_1.default.div `
|
|
|
26
30
|
overflow: hidden;
|
|
27
31
|
position: relative;
|
|
28
32
|
`;
|
|
33
|
+
const Svg = styled_1.default.svg `
|
|
34
|
+
padding: 2px;
|
|
35
|
+
width: calc(100% - 5px);
|
|
36
|
+
height: calc(100% - 5px);
|
|
37
|
+
`;
|
|
29
38
|
const LineChart = (p) => {
|
|
30
39
|
var _a;
|
|
31
40
|
const UT = (0, useTooltip_1.useTooltip)();
|
|
41
|
+
const style = (0, common_1.getVarStyles)(p.style);
|
|
32
42
|
const { points, xTime } = (0, interpolate_1.interpolate)(p.data);
|
|
33
43
|
let tt = p.tooltipTitle;
|
|
34
44
|
if (!tt && xTime) {
|
|
@@ -47,49 +57,53 @@ const LineChart = (p) => {
|
|
|
47
57
|
const lt2 = lt;
|
|
48
58
|
const tt2 = tt;
|
|
49
59
|
const legendItems = (0, getLegendItems_1.getLegendItems)(Object.assign(Object.assign({ colours: p.colours, data: p.data, tt: tt2, lt: lt2 }, (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data), { fixed: false }));
|
|
50
|
-
|
|
60
|
+
const SvgC = (react_1.default.createElement(Svg, { style: {
|
|
61
|
+
borderLeft: `solid 1px ${style.borderColor}`,
|
|
62
|
+
borderTop: `solid 1px ${style.borderColor}`,
|
|
63
|
+
}, transform: "scale(-1,1) scale(-1,-1)", strokeWidth: '3px', fillOpacity: 1, preserveAspectRatio: "none", onMouseMove: (element) => {
|
|
64
|
+
const parent = element.currentTarget.closest("[data-type='lcb']");
|
|
65
|
+
const bb = parent === null || parent === void 0 ? void 0 : parent.getBoundingClientRect();
|
|
66
|
+
if (!bb) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const relativeX = (0, math_1.rangePercentage)({
|
|
70
|
+
value: element.pageX,
|
|
71
|
+
min: bb.left,
|
|
72
|
+
max: bb.left + bb.width,
|
|
73
|
+
}) * 100;
|
|
74
|
+
let selectedPoints = points.filter((p) => relativeX >= p.x1 && relativeX < p.x2);
|
|
75
|
+
//if there are just single dots on the graph, choose the ones that are closest (share the smallest gap distance)
|
|
76
|
+
if (selectedPoints.length === 0) {
|
|
77
|
+
const sp1 = points
|
|
78
|
+
.map((p) => (Object.assign(Object.assign({}, p), { gap: Math.abs(p.x1 - relativeX) })))
|
|
79
|
+
.sort((a, b) => (a.gap < b.gap ? -1 : 1));
|
|
80
|
+
const mingap = sp1 === null || sp1 === void 0 ? void 0 : sp1[0].gap;
|
|
81
|
+
selectedPoints = sp1.filter((r) => r.gap === mingap);
|
|
82
|
+
}
|
|
83
|
+
const selectedXs = (0, array_1.distinctBy)(p.data.filter(({ x, y }) => selectedPoints === null || selectedPoints === void 0 ? void 0 : selectedPoints.find((a) => a.origX === x && a.origY === y)), (s) => JSON.stringify(s));
|
|
84
|
+
UT.setPos({
|
|
85
|
+
element,
|
|
86
|
+
parent,
|
|
87
|
+
data: {
|
|
88
|
+
selectedPoints: selectedPoints.map((a) => ({
|
|
89
|
+
x: a.origX,
|
|
90
|
+
y: a.origY,
|
|
91
|
+
})),
|
|
92
|
+
selectedXs,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
} }, points.map((p2) => {
|
|
96
|
+
var _a, _b, _c;
|
|
97
|
+
return (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify(p2) },
|
|
98
|
+
(p2.origX === ((_c = (_b = (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data.selectedXs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.x) ||
|
|
99
|
+
p2.x1 === p2.x2) && (react_1.default.createElement("circle", { cx: `${p2.x2}%`, cy: `${p2.y2}%`, r: "8px", fill: p.colours[p2.name] })),
|
|
100
|
+
p2.x1 !== p2.x2 && (react_1.default.createElement("line", { strokeOpacity: legendItems.part.find((f) => f.name === p2.name) ? 1 : 0.3, x1: `${p2.x1}%`, x2: `${p2.x2}%`, y1: `${p2.y1}%`, y2: `${p2.y2}%`, style: { stroke: p.colours[p2.name] } }))));
|
|
101
|
+
})));
|
|
102
|
+
return (react_1.default.createElement(Base, { className: p.className, "data-type": "lcb", onMouseLeave: () => UT.setPos(undefined), style: style },
|
|
51
103
|
react_1.default.createElement(UT.Comp, { pos: UT.pos }, (p2) => (react_1.default.createElement(TooltipContent_1.TooltipContent, Object.assign({}, p2, { colours: p.colours, data: p.data, lt: lt2, tt: tt2, legendItems: legendItems })))),
|
|
52
|
-
react_1.default.createElement(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const bb = parent === null || parent === void 0 ? void 0 : parent.getBoundingClientRect();
|
|
57
|
-
if (!bb) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const relativeX = (0, math_1.rangePercentage)({
|
|
61
|
-
value: element.pageX,
|
|
62
|
-
min: bb.left,
|
|
63
|
-
max: bb.left + bb.width,
|
|
64
|
-
}) * 100;
|
|
65
|
-
let selectedPoints = points.filter((p) => relativeX >= p.x1 && relativeX < p.x2);
|
|
66
|
-
//if there are just single dots on the graph, choose the ones that are closest (share the smallest gap distance)
|
|
67
|
-
if (selectedPoints.length === 0) {
|
|
68
|
-
const sp1 = points
|
|
69
|
-
.map((p) => (Object.assign(Object.assign({}, p), { gap: Math.abs(p.x1 - relativeX) })))
|
|
70
|
-
.sort((a, b) => (a.gap < b.gap ? -1 : 1));
|
|
71
|
-
const mingap = sp1 === null || sp1 === void 0 ? void 0 : sp1[0].gap;
|
|
72
|
-
selectedPoints = sp1.filter((r) => r.gap === mingap);
|
|
73
|
-
}
|
|
74
|
-
const selectedXs = (0, array_1.distinctBy)(p.data.filter(({ x, y }) => selectedPoints === null || selectedPoints === void 0 ? void 0 : selectedPoints.find((a) => a.origX === x && a.origY === y)), (s) => JSON.stringify(s));
|
|
75
|
-
UT.setPos({
|
|
76
|
-
element,
|
|
77
|
-
parent,
|
|
78
|
-
data: {
|
|
79
|
-
selectedPoints: selectedPoints.map((a) => ({
|
|
80
|
-
x: a.origX,
|
|
81
|
-
y: a.origY,
|
|
82
|
-
})),
|
|
83
|
-
selectedXs,
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
} }, points.map((p2) => {
|
|
87
|
-
var _a, _b, _c;
|
|
88
|
-
return (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify(p2) },
|
|
89
|
-
(p2.origX === ((_c = (_b = (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data.selectedXs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.x) ||
|
|
90
|
-
p2.x1 === p2.x2) && (react_1.default.createElement("circle", { cx: p2.x2, cy: p2.y2, r: 1, fill: p.colours[p2.name] })),
|
|
91
|
-
p2.x1 !== p2.x2 && (react_1.default.createElement("line", { strokeOpacity: legendItems.part.find((f) => f.name === p2.name) ? 1 : 0.3, x1: p2.x1, x2: p2.x2, y1: p2.y1, y2: p2.y2, style: { stroke: p.colours[p2.name] } }))));
|
|
92
|
-
})),
|
|
93
|
-
react_1.default.createElement(Legend_1.Legend, { data: p.data, colours: p.colours, lt: lt, tt: tt })));
|
|
104
|
+
react_1.default.createElement(FlexRow_1.FlexRow, { noWrap: true },
|
|
105
|
+
react_1.default.createElement(LegendY_1.LegendY, { data: p.data, style: style }),
|
|
106
|
+
SvgC),
|
|
107
|
+
react_1.default.createElement(LegendX_1.LegendX, { data: p.data, colours: p.colours, lt: lt, tt: tt, style: style })));
|
|
94
108
|
};
|
|
95
109
|
exports.LineChart = LineChart;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { IVarStyles } from '../../styles/common';
|
|
2
3
|
import type { ILineChartItemRaw } from './types';
|
|
3
|
-
export declare const
|
|
4
|
+
export declare const LegendX: ({ data, lt, tt, colours, style, }: {
|
|
4
5
|
data: ILineChartItemRaw[];
|
|
5
6
|
colours: Record<string, string>;
|
|
6
7
|
lt: (a: number) => string;
|
|
7
8
|
tt: (a: number) => string;
|
|
9
|
+
style: IVarStyles;
|
|
8
10
|
}) => React.JSX.Element;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.LegendX = void 0;
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const common_1 = require("../../../common");
|
|
@@ -26,7 +26,6 @@ const Line = styled_1.default.div `
|
|
|
26
26
|
height: 2px;
|
|
27
27
|
left: 0;
|
|
28
28
|
right: 0;
|
|
29
|
-
background-color: var(--main-fg);
|
|
30
29
|
`;
|
|
31
30
|
const Numbers = styled_1.default.div `
|
|
32
31
|
width: 100%;
|
|
@@ -34,9 +33,6 @@ const Numbers = styled_1.default.div `
|
|
|
34
33
|
flex-flow: row;
|
|
35
34
|
justify-content: space-between;
|
|
36
35
|
z-index: 1;
|
|
37
|
-
> span {
|
|
38
|
-
background-color: var(--main-bg);
|
|
39
|
-
}
|
|
40
36
|
`;
|
|
41
37
|
const Items = styled_1.default.div `
|
|
42
38
|
width: 100%;
|
|
@@ -44,13 +40,19 @@ const Items = styled_1.default.div `
|
|
|
44
40
|
flex-flow: row wrap;
|
|
45
41
|
position: relative;
|
|
46
42
|
justify-content: space-between;
|
|
43
|
+
margin-top: 0.5rem;
|
|
47
44
|
`;
|
|
48
45
|
const Item = styled_1.default.div `
|
|
49
46
|
display: flex;
|
|
50
47
|
flex-flow: row;
|
|
51
48
|
position: relative;
|
|
52
49
|
align-items: center;
|
|
53
|
-
|
|
50
|
+
&:not(:first-of-type) {
|
|
51
|
+
padding-left: 0.5rem;
|
|
52
|
+
}
|
|
53
|
+
&:not(:last-of-type) {
|
|
54
|
+
padding-right: 0.5rem;
|
|
55
|
+
}
|
|
54
56
|
`;
|
|
55
57
|
const Col = styled_1.default.div `
|
|
56
58
|
width: 1rem;
|
|
@@ -58,7 +60,7 @@ const Col = styled_1.default.div `
|
|
|
58
60
|
border-radius: 50%;
|
|
59
61
|
margin-right: 0.25rem;
|
|
60
62
|
`;
|
|
61
|
-
const
|
|
63
|
+
const LegendX = ({ data, lt, tt, colours, style, }) => {
|
|
62
64
|
const legendItems = (0, getLegendItems_1.getLegendItems)({
|
|
63
65
|
data,
|
|
64
66
|
colours,
|
|
@@ -67,25 +69,29 @@ const Legend = ({ data, lt, tt, colours, }) => {
|
|
|
67
69
|
tt,
|
|
68
70
|
}).part;
|
|
69
71
|
const xs = data.map((a) => a.x);
|
|
72
|
+
const ys = data.map((a) => a.y);
|
|
70
73
|
const minX = Math.min(...xs);
|
|
71
74
|
const maxX = Math.max(...xs);
|
|
75
|
+
const maxY = Math.max(...ys);
|
|
72
76
|
const itemsRaw = [minX];
|
|
73
|
-
const
|
|
77
|
+
const gc = 8;
|
|
78
|
+
const gap = (maxX - minX) / gc;
|
|
74
79
|
if (gap > common_1.twelveHMs) {
|
|
75
|
-
for (let a = 1; a <
|
|
80
|
+
for (let a = 1; a < gc; a += 1) {
|
|
76
81
|
itemsRaw.push(itemsRaw[a - 1] + gap);
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
itemsRaw.push(maxX);
|
|
80
85
|
const items = itemsRaw.map((d) => { var _a; return (_a = lt(d)) !== null && _a !== void 0 ? _a : d; });
|
|
81
|
-
|
|
86
|
+
const ch = maxY.toString().length + 1;
|
|
87
|
+
return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { marginLeft: 'auto', width: `calc(100% - ${ch}ch)` }) },
|
|
82
88
|
react_1.default.createElement(Bar, null,
|
|
83
|
-
react_1.default.createElement(Line,
|
|
84
|
-
react_1.default.createElement(Numbers, null, items.map((i, i2) => (
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
react_1.default.createElement(Line, { style: { backgroundColor: style.color } }),
|
|
90
|
+
react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
|
|
91
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
92
|
+
key: i + i2, style: { backgroundColor: style.backgroundColor } }, i))))),
|
|
87
93
|
legendItems.length > 1 && (react_1.default.createElement(Items, null, legendItems.map((k) => (react_1.default.createElement(Item, { key: k.name },
|
|
88
94
|
react_1.default.createElement(Col, { style: { backgroundColor: k.colour } }),
|
|
89
95
|
k.name)))))));
|
|
90
96
|
};
|
|
91
|
-
exports.
|
|
97
|
+
exports.LegendX = LegendX;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LegendY = void 0;
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const Base = styled_1.default.div `
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-flow: row;
|
|
12
|
+
width: 100%;
|
|
13
|
+
`;
|
|
14
|
+
const Numbers = styled_1.default.div `
|
|
15
|
+
width: 100%;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-flow: column-reverse;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
> span {
|
|
21
|
+
text-align: right;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const LegendY = ({ data, style, }) => {
|
|
25
|
+
const ys = data.map((a) => a.y);
|
|
26
|
+
const minY = Math.min(...ys);
|
|
27
|
+
const maxY = Math.max(...ys);
|
|
28
|
+
const items = [minY];
|
|
29
|
+
const gc = 3;
|
|
30
|
+
const gap = (maxY - minY) / gc;
|
|
31
|
+
for (let a = 1; a < gc; a += 1) {
|
|
32
|
+
items.push(Math.floor(items[a - 1] + gap));
|
|
33
|
+
}
|
|
34
|
+
items.push(maxY);
|
|
35
|
+
const ch = maxY.toString().length;
|
|
36
|
+
return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { maxWidth: `${ch}ch`, paddingRight: '1ch' }) },
|
|
37
|
+
react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
|
|
38
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
39
|
+
key: i + i2, style: {
|
|
40
|
+
color: style.color,
|
|
41
|
+
backgroundColor: style.backgroundColor,
|
|
42
|
+
} }, i))))));
|
|
43
|
+
};
|
|
44
|
+
exports.LegendY = LegendY;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { IVarStyles } from '../../styles/common';
|
|
2
3
|
import type { ILegendItems } from './getLegendItems';
|
|
3
4
|
import type { ILineChartTooltip } from './types';
|
|
4
5
|
export declare const TooltipContent: (p: ILineChartTooltip & {
|
|
5
6
|
legendItems: ILegendItems;
|
|
6
|
-
}) => React.JSX.Element;
|
|
7
|
+
}, style: IVarStyles) => React.JSX.Element;
|
|
@@ -7,8 +7,6 @@ exports.TooltipContent = void 0;
|
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const Base = styled_1.default.div `
|
|
10
|
-
background-color: var(--main-bg);
|
|
11
|
-
border: solid 1px var(--main-bg-mid);
|
|
12
10
|
padding: 0.5rem;
|
|
13
11
|
`;
|
|
14
12
|
const Title = styled_1.default.div `
|
|
@@ -33,10 +31,10 @@ const Total = styled_1.default.span `
|
|
|
33
31
|
text-decoration: underline;
|
|
34
32
|
}
|
|
35
33
|
`;
|
|
36
|
-
const TooltipContent = (p) => {
|
|
34
|
+
const TooltipContent = (p, style) => {
|
|
37
35
|
var _a, _b, _c, _d;
|
|
38
36
|
const name = (_d = (_a = p.tt) === null || _a === void 0 ? void 0 : _a.call(p, (_c = (_b = p.selectedXs) === null || _b === void 0 ? void 0 : _b[0].x) !== null && _c !== void 0 ? _c : 0)) !== null && _d !== void 0 ? _d : '';
|
|
39
|
-
return (react_1.default.createElement(Base,
|
|
37
|
+
return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { border: `solid 1px ${style.borderColor}` }) },
|
|
40
38
|
react_1.default.createElement(Title, null, name),
|
|
41
39
|
react_1.default.createElement(Row, null,
|
|
42
40
|
react_1.default.createElement("span", null, "total"),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IVarStyles } from '../../styles/common';
|
|
1
2
|
export type ILineChartItemRaw = {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
@@ -23,4 +24,5 @@ export interface ILineChart {
|
|
|
23
24
|
colours: Record<string, string>;
|
|
24
25
|
tooltipTitle?: (a: number) => string;
|
|
25
26
|
legendTitle?: (a: number) => string;
|
|
27
|
+
style: Partial<IVarStyles>;
|
|
26
28
|
}
|
|
@@ -7,7 +7,7 @@ exports.Checkmark = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const Checkmark = ({ style, }) => {
|
|
9
9
|
var _a;
|
|
10
|
-
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style:
|
|
10
|
+
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style: style },
|
|
11
11
|
react_1.default.createElement("path", { fill: "none", stroke: (_a = style === null || style === void 0 ? void 0 : style.fill) !== null && _a !== void 0 ? _a : '#000', strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M8 12.333 10.461 15 16 9m5 3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" })));
|
|
12
12
|
};
|
|
13
13
|
exports.Checkmark = Checkmark;
|
package/dist/ui/icons/Circle.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Circle = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const Circle = ({ style, dotted = false, }) => {
|
|
9
9
|
var _a;
|
|
10
|
-
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style:
|
|
10
|
+
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "2 2 20 20", style: style },
|
|
11
11
|
react_1.default.createElement("path", { fill: "none", stroke: (_a = style === null || style === void 0 ? void 0 : style.fill) !== null && _a !== void 0 ? _a : '#000', strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: !dotted ? '' : '4 4', strokeWidth: "2", d: "M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" })));
|
|
12
12
|
};
|
|
13
13
|
exports.Circle = Circle;
|
|
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Computer = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const Computer = ({ style, }) => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style:
|
|
8
|
+
const Computer = ({ style, }) => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", style: style },
|
|
9
9
|
react_1.default.createElement("path", { fillRule: "evenodd", d: "M2 6a3 3 0 0 1 3-3h14a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-6v1h2a1 1 0 1 1 0 2H9a1 1 0 1 1 0-2h2v-1H5a3 3 0 0 1-3-3V6Zm3-1a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1H5Z", clipRule: "evenodd" })));
|
|
10
10
|
exports.Computer = Computer;
|
package/dist/ui/icons/Magnify.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Magnify = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const Magnify = ({ style, }) => {
|
|
9
9
|
var _a;
|
|
10
|
-
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 490 490", style:
|
|
10
|
+
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 490 490", style: style },
|
|
11
11
|
react_1.default.createElement("path", { fill: "none", stroke: (_a = style === null || style === void 0 ? void 0 : style.fill) !== null && _a !== void 0 ? _a : 'black', strokeWidth: "36", strokeLinecap: "round", d: "M280 278a153 153 0 1 0-2 2l170 170m-91-117 110 110-26 26-110-110" })));
|
|
12
12
|
};
|
|
13
13
|
exports.Magnify = Magnify;
|
package/dist/ui/icons/Moon.js
CHANGED
|
@@ -5,6 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Moon = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const Moon = ({ style, }) => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 35 35", style:
|
|
8
|
+
const Moon = ({ style, }) => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 35 35", style: style },
|
|
9
9
|
react_1.default.createElement("path", { d: "M18.44 34.68a18.22 18.22 0 0 1-2.94-.24 18.18 18.18 0 0 1-15-20.86A18.06 18.06 0 0 1 9.59.63a2.42 2.42 0 0 1 2.61.16 2.39 2.39 0 0 1 1 2.41l-1.3-.1 1.23.22A15.66 15.66 0 0 0 23.34 21a15.82 15.82 0 0 0 8.47.53A2.44 2.44 0 0 1 34.47 25a18.18 18.18 0 0 1-16.03 9.68ZM10.67 2.89a15.67 15.67 0 0 0-5 22.77A15.66 15.66 0 0 0 32.18 24a18.49 18.49 0 0 1-9.65-.64A18.18 18.18 0 0 1 10.67 2.89Z" })));
|
|
10
10
|
exports.Moon = Moon;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
2
|
/** function that returns css that gives a text outline drop shadow.
|
|
3
3
|
* @param outlineColour default='white'
|
|
4
4
|
* @param sizePx default = 1px
|
|
@@ -23,3 +23,12 @@ export declare const Card: import("@emotion/styled").StyledComponent<{
|
|
|
23
23
|
theme?: import("@emotion/react").Theme | undefined;
|
|
24
24
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
25
25
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
26
|
+
export interface IVarStyles {
|
|
27
|
+
/** default var(--main-fg) */
|
|
28
|
+
color: string;
|
|
29
|
+
/** default var(--main-bg) */
|
|
30
|
+
backgroundColor: string;
|
|
31
|
+
/** default var(--main-bg-mid) */
|
|
32
|
+
borderColor: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const getVarStyles: (raw?: Partial<IVarStyles & CSSProperties>) => IVarStyles;
|
package/dist/ui/styles/common.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Card = exports.bounce = exports.noDrag = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.HardOutlineFilter = exports.HardOutline = void 0;
|
|
7
|
+
exports.getVarStyles = exports.Card = exports.bounce = exports.noDrag = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.HardOutlineFilter = exports.HardOutline = void 0;
|
|
8
8
|
const react_1 = require("@emotion/react");
|
|
9
9
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
10
10
|
const colours_1 = require("./colours");
|
|
@@ -77,3 +77,8 @@ exports.Card = styled_1.default.div `
|
|
|
77
77
|
padding: 1rem;
|
|
78
78
|
border: solid 2px ${colours_1.colours.lighter};
|
|
79
79
|
`;
|
|
80
|
+
const getVarStyles = (raw) => {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
return (Object.assign(Object.assign({}, raw), { color: (_a = raw === null || raw === void 0 ? void 0 : raw.color) !== null && _a !== void 0 ? _a : 'var(--main-fg)', backgroundColor: (_b = raw === null || raw === void 0 ? void 0 : raw.backgroundColor) !== null && _b !== void 0 ? _b : 'var(--main-bg)', borderColor: (_c = raw === null || raw === void 0 ? void 0 : raw.borderColor) !== null && _c !== void 0 ? _c : 'var(--main-bg-mid)' }));
|
|
83
|
+
};
|
|
84
|
+
exports.getVarStyles = getVarStyles;
|
package/package.json
CHANGED