@elliemae/ds-dataviz 3.6.0-next.3
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/cjs/graphs/Chart/Chart.js +61 -0
- package/dist/cjs/graphs/Chart/Chart.js.map +7 -0
- package/dist/cjs/graphs/Chart/ChartContext.js +67 -0
- package/dist/cjs/graphs/Chart/ChartContext.js.map +7 -0
- package/dist/cjs/graphs/Chart/Pie.js +49 -0
- package/dist/cjs/graphs/Chart/Pie.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useChart.js +109 -0
- package/dist/cjs/graphs/Chart/config/useChart.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +119 -0
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useScales.js +107 -0
- package/dist/cjs/graphs/Chart/config/useScales.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/index.js +83 -0
- package/dist/cjs/graphs/Chart/helpers/index.js.map +7 -0
- package/dist/cjs/graphs/Chart/index.js +26 -0
- package/dist/cjs/graphs/Chart/index.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js +83 -0
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/AxisBottom.js +86 -0
- package/dist/cjs/graphs/Chart/parts/AxisBottom.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/AxisLeft.js +79 -0
- package/dist/cjs/graphs/Chart/parts/AxisLeft.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/AxisRight.js +63 -0
- package/dist/cjs/graphs/Chart/parts/AxisRight.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +78 -0
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/ColorLegend.js +70 -0
- package/dist/cjs/graphs/Chart/parts/ColorLegend.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js +116 -0
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Scrapper.js +130 -0
- package/dist/cjs/graphs/Chart/parts/Scrapper.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +82 -0
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/VerticalScrapper.js +138 -0
- package/dist/cjs/graphs/Chart/parts/VerticalScrapper.js.map +7 -0
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js +57 -0
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Area.js +73 -0
- package/dist/cjs/graphs/Chart/series/Area.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Bars.js +68 -0
- package/dist/cjs/graphs/Chart/series/Bars.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Line.js +70 -0
- package/dist/cjs/graphs/Chart/series/Line.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Pie.js +46 -0
- package/dist/cjs/graphs/Chart/series/Pie.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Point.js +67 -0
- package/dist/cjs/graphs/Chart/series/Point.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Points.js +84 -0
- package/dist/cjs/graphs/Chart/series/Points.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Rect.js +78 -0
- package/dist/cjs/graphs/Chart/series/Rect.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/StackedBar.js +66 -0
- package/dist/cjs/graphs/Chart/series/StackedBar.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/index.js +32 -0
- package/dist/cjs/graphs/Chart/series/index.js.map +7 -0
- package/dist/cjs/graphs/Chart/styles.js +123 -0
- package/dist/cjs/graphs/Chart/styles.js.map +7 -0
- package/dist/cjs/graphs/constants.js +37 -0
- package/dist/cjs/graphs/constants.js.map +7 -0
- package/dist/cjs/graphs/index.js +27 -0
- package/dist/cjs/graphs/index.js.map +7 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/graphs/Chart/Chart.js +35 -0
- package/dist/esm/graphs/Chart/Chart.js.map +7 -0
- package/dist/esm/graphs/Chart/ChartContext.js +41 -0
- package/dist/esm/graphs/Chart/ChartContext.js.map +7 -0
- package/dist/esm/graphs/Chart/Pie.js +23 -0
- package/dist/esm/graphs/Chart/Pie.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useChart.js +83 -0
- package/dist/esm/graphs/Chart/config/useChart.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +93 -0
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useScales.js +81 -0
- package/dist/esm/graphs/Chart/config/useScales.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/index.js +57 -0
- package/dist/esm/graphs/Chart/helpers/index.js.map +7 -0
- package/dist/esm/graphs/Chart/index.js +3 -0
- package/dist/esm/graphs/Chart/index.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/ActivePoint.js +57 -0
- package/dist/esm/graphs/Chart/parts/ActivePoint.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/AxisBottom.js +60 -0
- package/dist/esm/graphs/Chart/parts/AxisBottom.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/AxisLeft.js +53 -0
- package/dist/esm/graphs/Chart/parts/AxisLeft.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/AxisRight.js +37 -0
- package/dist/esm/graphs/Chart/parts/AxisRight.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +52 -0
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/ColorLegend.js +44 -0
- package/dist/esm/graphs/Chart/parts/ColorLegend.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js +90 -0
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Scrapper.js +104 -0
- package/dist/esm/graphs/Chart/parts/Scrapper.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js +56 -0
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/VerticalScrapper.js +112 -0
- package/dist/esm/graphs/Chart/parts/VerticalScrapper.js.map +7 -0
- package/dist/esm/graphs/Chart/react-desc-prop-types.js +31 -0
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Area.js +47 -0
- package/dist/esm/graphs/Chart/series/Area.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Bars.js +42 -0
- package/dist/esm/graphs/Chart/series/Bars.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Line.js +44 -0
- package/dist/esm/graphs/Chart/series/Line.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Pie.js +20 -0
- package/dist/esm/graphs/Chart/series/Pie.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Point.js +41 -0
- package/dist/esm/graphs/Chart/series/Point.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Points.js +58 -0
- package/dist/esm/graphs/Chart/series/Points.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Rect.js +52 -0
- package/dist/esm/graphs/Chart/series/Rect.js.map +7 -0
- package/dist/esm/graphs/Chart/series/StackedBar.js +40 -0
- package/dist/esm/graphs/Chart/series/StackedBar.js.map +7 -0
- package/dist/esm/graphs/Chart/series/index.js +9 -0
- package/dist/esm/graphs/Chart/series/index.js.map +7 -0
- package/dist/esm/graphs/Chart/styles.js +97 -0
- package/dist/esm/graphs/Chart/styles.js.map +7 -0
- package/dist/esm/graphs/constants.js +11 -0
- package/dist/esm/graphs/constants.js.map +7 -0
- package/dist/esm/graphs/index.js +4 -0
- package/dist/esm/graphs/index.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/package.json +76 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { ChartContext } from "../ChartContext";
|
|
5
|
+
const ColorLegend = ({ tickSpacing = 20, tickSize = 5, tickTextOffset = 20 }) => {
|
|
6
|
+
const {
|
|
7
|
+
colorScale,
|
|
8
|
+
innerWidth,
|
|
9
|
+
props: { colorLegend }
|
|
10
|
+
} = useContext(ChartContext);
|
|
11
|
+
if (!colorLegend)
|
|
12
|
+
return null;
|
|
13
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
14
|
+
transform: `translate(${innerWidth + 30},30)`,
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ jsx("text", {
|
|
17
|
+
x: 35,
|
|
18
|
+
y: -25,
|
|
19
|
+
className: "axis-label",
|
|
20
|
+
textAnchor: "middle",
|
|
21
|
+
children: colorLegend.label
|
|
22
|
+
}),
|
|
23
|
+
colorScale.domain().map((domainValue, i) => /* @__PURE__ */ jsxs("g", {
|
|
24
|
+
className: "tick",
|
|
25
|
+
transform: `translate(0,${i * tickSpacing})`,
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx("circle", {
|
|
28
|
+
fill: colorScale(domainValue),
|
|
29
|
+
r: 4
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ jsx("text", {
|
|
32
|
+
x: tickTextOffset,
|
|
33
|
+
dy: ".32em",
|
|
34
|
+
children: domainValue
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
}))
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
ColorLegend
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=ColorLegend.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/ColorLegend.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { ChartContext } from '../ChartContext';\n\nexport const ColorLegend = ({ tickSpacing = 20, tickSize = 5, tickTextOffset = 20 }) => {\n const {\n colorScale,\n innerWidth,\n props: { colorLegend },\n } = useContext(ChartContext);\n\n if (!colorLegend) return null;\n return (\n <g transform={`translate(${innerWidth + 30},30)`}>\n <text x={35} y={-25} className=\"axis-label\" textAnchor=\"middle\">\n {colorLegend.label}\n </text>\n {colorScale.domain().map((domainValue, i) => (\n <g className=\"tick\" transform={`translate(0,${i * tickSpacing})`}>\n <circle fill={colorScale(domainValue)} r={4} />\n <text x={tickTextOffset} dy=\".32em\">\n {domainValue}\n </text>\n </g>\n ))}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,kBAAkB;AAClC,SAAS,oBAAoB;AAEtB,MAAM,cAAc,CAAC,EAAE,cAAc,IAAI,WAAW,GAAG,iBAAiB,GAAG,MAAM;AACtF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE,YAAY;AAAA,EACvB,IAAI,WAAW,YAAY;AAE3B,MAAI,CAAC;AAAa,WAAO;AACzB,SACE,qBAAC;AAAA,IAAE,WAAW,aAAa,aAAa;AAAA,IACtC;AAAA,0BAAC;AAAA,QAAK,GAAG;AAAA,QAAI,GAAG;AAAA,QAAK,WAAU;AAAA,QAAa,YAAW;AAAA,QACpD,sBAAY;AAAA,OACf;AAAA,MACC,WAAW,OAAO,EAAE,IAAI,CAAC,aAAa,MACrC,qBAAC;AAAA,QAAE,WAAU;AAAA,QAAO,WAAW,eAAe,IAAI;AAAA,QAChD;AAAA,8BAAC;AAAA,YAAO,MAAM,WAAW,WAAW;AAAA,YAAG,GAAG;AAAA,WAAG;AAAA,UAC7C,oBAAC;AAAA,YAAK,GAAG;AAAA,YAAgB,IAAG;AAAA,YACzB;AAAA,WACH;AAAA;AAAA,OACF,CACD;AAAA;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useCallback, useContext } from "react";
|
|
4
|
+
import { DSPopperJS } from "@elliemae/ds-popperjs";
|
|
5
|
+
import { ThemeContext, styled } from "@elliemae/ds-system";
|
|
6
|
+
import { ChartContext } from "../ChartContext";
|
|
7
|
+
import { StyleFocusableRegion } from "../styles";
|
|
8
|
+
const StyledTooltipContainer = styled.div`
|
|
9
|
+
text-align: center;
|
|
10
|
+
min-width: ${({ theme }) => theme.space.l};
|
|
11
|
+
max-width: 250px;
|
|
12
|
+
min-height: 30px;
|
|
13
|
+
display: grid;
|
|
14
|
+
align-items: center;
|
|
15
|
+
padding: ${({ theme }) => `${theme.space.xxxs} ${theme.space.xs}`};
|
|
16
|
+
position: relative;
|
|
17
|
+
background-color: white;
|
|
18
|
+
border-radius: 2px;
|
|
19
|
+
font-size: 13px;
|
|
20
|
+
color: ${({ theme }) => theme.colors.neutral[600]};
|
|
21
|
+
`;
|
|
22
|
+
const StyledMouseOverDetectionBox = styled.div`
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: -15px;
|
|
25
|
+
right: -15px;
|
|
26
|
+
width: calc(100% + 30px);
|
|
27
|
+
height: calc(100% + 30px);
|
|
28
|
+
z-index: -1;
|
|
29
|
+
`;
|
|
30
|
+
const FocusableRegion = (props) => {
|
|
31
|
+
const { activePoint } = useContext(ChartContext);
|
|
32
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
33
|
+
const theme = useContext(ThemeContext);
|
|
34
|
+
const [showPopover, setShowPopover] = useState(false);
|
|
35
|
+
const { id, pointRadius, content, ...rest } = props;
|
|
36
|
+
const isFocused = activePoint === id;
|
|
37
|
+
const focusableElement = useRef(null);
|
|
38
|
+
const handleRef = useCallback(
|
|
39
|
+
(newRef) => {
|
|
40
|
+
if (focusableElement.current)
|
|
41
|
+
focusableElement.current = newRef;
|
|
42
|
+
if (isFocused)
|
|
43
|
+
newRef?.focus();
|
|
44
|
+
},
|
|
45
|
+
[isFocused]
|
|
46
|
+
);
|
|
47
|
+
const onMouseEnter = () => {
|
|
48
|
+
setShowPopover(true);
|
|
49
|
+
};
|
|
50
|
+
const onMouseLeave = () => {
|
|
51
|
+
setShowPopover(false);
|
|
52
|
+
};
|
|
53
|
+
const onFocus = () => {
|
|
54
|
+
setShowPopover(true);
|
|
55
|
+
};
|
|
56
|
+
const onBlur = () => {
|
|
57
|
+
setShowPopover(false);
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsx("foreignObject", {
|
|
60
|
+
...rest,
|
|
61
|
+
onFocus,
|
|
62
|
+
onBlur,
|
|
63
|
+
ref: setReferenceElement,
|
|
64
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsx(StyleFocusableRegion, {
|
|
67
|
+
s: pointRadius,
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
ref: handleRef
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsxs(DSPopperJS, {
|
|
72
|
+
withoutAnimation: true,
|
|
73
|
+
referenceElement,
|
|
74
|
+
showPopover,
|
|
75
|
+
zIndex: theme.zIndex.tooltip,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsx(StyledMouseOverDetectionBox, {}),
|
|
78
|
+
/* @__PURE__ */ jsx(StyledTooltipContainer, {
|
|
79
|
+
children: content
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
FocusableRegion
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=FocusableRegion.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/FocusableRegion.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useState, useRef, useCallback, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ThemeContext, styled } from '@elliemae/ds-system';\nimport { ChartContext } from '../ChartContext';\n\nimport { StyleFocusableRegion } from '../styles';\n\nconst StyledTooltipContainer = styled.div`\n text-align: center;\n min-width: ${({ theme }) => theme.space.l};\n max-width: 250px;\n min-height: 30px;\n display: grid;\n align-items: center;\n padding: ${({ theme }) => `${theme.space.xxxs} ${theme.space.xs}`};\n position: relative;\n background-color: white;\n border-radius: 2px;\n font-size: 13px;\n color: ${({ theme }) => theme.colors.neutral[600]};\n`;\n\nconst StyledMouseOverDetectionBox = styled.div`\n position: absolute;\n top: -15px;\n right: -15px;\n width: calc(100% + 30px);\n height: calc(100% + 30px);\n z-index: -1;\n`;\n\nexport const FocusableRegion: React.ComponentType<any> = (props) => {\n const { activePoint } = useContext(ChartContext);\n\n const [referenceElement, setReferenceElement] = useState<HTMLSpanElement | null>();\n const theme = useContext(ThemeContext);\n\n const [showPopover, setShowPopover] = useState(false);\n const { id, pointRadius, content, ...rest } = props;\n const isFocused = activePoint === id;\n\n const focusableElement = useRef(null);\n const handleRef = useCallback(\n (newRef: HTMLDivElement) => {\n if (focusableElement.current) focusableElement.current = newRef;\n if (isFocused) newRef?.focus();\n },\n [isFocused],\n );\n\n const onMouseEnter = () => {\n setShowPopover(true);\n };\n\n const onMouseLeave = () => {\n setShowPopover(false);\n };\n\n const onFocus = () => {\n setShowPopover(true);\n };\n\n const onBlur = () => {\n setShowPopover(false);\n };\n\n return (\n <foreignObject\n {...rest}\n // onMouseEnter={onMouseEnter}\n // onMouseLeave={onMouseLeave}\n // onPointerEnter={onMouseEnter}\n // onPointerLeave={onMouseLeave}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={setReferenceElement}\n >\n <div>\n <StyleFocusableRegion\n s={pointRadius}\n // aria-label={`${xValue} ${d[yValue]}`}\n tabIndex={-1}\n ref={handleRef}\n ></StyleFocusableRegion>\n\n <DSPopperJS\n withoutAnimation\n referenceElement={referenceElement}\n showPopover={showPopover}\n zIndex={theme.zIndex.tooltip}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>{content}</StyledTooltipContainer>\n </DSPopperJS>\n </div>\n </foreignObject>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,UAAU,QAAQ,aAAa,kBAAkB;AACjE,SAAS,kBAAkB;AAC3B,SAAS,cAAc,cAAc;AACrC,SAAS,oBAAoB;AAE7B,SAAS,4BAA4B;AAErC,MAAM,yBAAyB,OAAO;AAAA;AAAA,eAEvB,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,aAK7B,CAAC,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,QAAQ,MAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,WAKpD,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ;AAAA;AAG/C,MAAM,8BAA8B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASpC,MAAM,kBAA4C,CAAC,UAAU;AAClE,QAAM,EAAE,YAAY,IAAI,WAAW,YAAY;AAE/C,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAiC;AACjF,QAAM,QAAQ,WAAW,YAAY;AAErC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,EAAE,IAAI,aAAa,YAAY,KAAK,IAAI;AAC9C,QAAM,YAAY,gBAAgB;AAElC,QAAM,mBAAmB,OAAO,IAAI;AACpC,QAAM,YAAY;AAAA,IAChB,CAAC,WAA2B;AAC1B,UAAI,iBAAiB;AAAS,yBAAiB,UAAU;AACzD,UAAI;AAAW,gBAAQ,MAAM;AAAA,IAC/B;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AAEA,QAAM,eAAe,MAAM;AACzB,mBAAe,IAAI;AAAA,EACrB;AAEA,QAAM,eAAe,MAAM;AACzB,mBAAe,KAAK;AAAA,EACtB;AAEA,QAAM,UAAU,MAAM;AACpB,mBAAe,IAAI;AAAA,EACrB;AAEA,QAAM,SAAS,MAAM;AACnB,mBAAe,KAAK;AAAA,EACtB;AAEA,SACE,oBAAC;AAAA,IACE,GAAG;AAAA,IAKJ;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IAEL,+BAAC;AAAA,MACC;AAAA,4BAAC;AAAA,UACC,GAAG;AAAA,UAEH,UAAU;AAAA,UACV,KAAK;AAAA,SACN;AAAA,QAED,qBAAC;AAAA,UACC,kBAAgB;AAAA,UAChB;AAAA,UACA;AAAA,UACA,QAAQ,MAAM,OAAO;AAAA,UAErB;AAAA,gCAAC,+BAA4B;AAAA,YAC7B,oBAAC;AAAA,cAAwB;AAAA,aAAQ;AAAA;AAAA,SACnC;AAAA;AAAA,KACF;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo, useState } from "react";
|
|
4
|
+
import { DSPopperJS } from "@elliemae/ds-popperjs";
|
|
5
|
+
import { ThemeContext } from "@elliemae/ds-system";
|
|
6
|
+
import { ChartContext } from "../ChartContext";
|
|
7
|
+
import { StyledMouseOverDetectionBox, StyledTooltipContainer } from "../styles";
|
|
8
|
+
const Scrapper = () => {
|
|
9
|
+
const {
|
|
10
|
+
yScale,
|
|
11
|
+
y2Scale,
|
|
12
|
+
scrapperPosY,
|
|
13
|
+
setScrapperPosY,
|
|
14
|
+
xScale,
|
|
15
|
+
innerHeight,
|
|
16
|
+
innerWidth,
|
|
17
|
+
props: { TooltipRenderer, xAxis, data, scrapper }
|
|
18
|
+
} = useContext(ChartContext);
|
|
19
|
+
const theme = useContext(ThemeContext);
|
|
20
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
21
|
+
const uniqueData = useMemo(() => {
|
|
22
|
+
const valueToPositionPerSeries = data.map(
|
|
23
|
+
(serie) => serie.data.map((datum, i) => ({
|
|
24
|
+
position: serie.scale === "y" || !serie.scale ? yScale(datum.value) : y2Scale(datum.value),
|
|
25
|
+
name: serie.name,
|
|
26
|
+
xValue: xAxis.cols[i],
|
|
27
|
+
yValue: datum.value
|
|
28
|
+
}))
|
|
29
|
+
).flat(1);
|
|
30
|
+
const postionUniqueData = {};
|
|
31
|
+
valueToPositionPerSeries.forEach((set) => {
|
|
32
|
+
if (postionUniqueData[[set.position]]) {
|
|
33
|
+
postionUniqueData[[set.position]] = [...postionUniqueData[[set.position]], { ...set }];
|
|
34
|
+
} else {
|
|
35
|
+
postionUniqueData[[set.position]] = [{ ...set }];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return postionUniqueData;
|
|
39
|
+
}, [data, xAxis.cols, y2Scale, yScale]);
|
|
40
|
+
return /* @__PURE__ */ jsx("g", {
|
|
41
|
+
children: Object.keys(uniqueData).map((key) => {
|
|
42
|
+
const yPosition = parseFloat(key);
|
|
43
|
+
const datum = uniqueData[key];
|
|
44
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
45
|
+
children: [
|
|
46
|
+
scrapperPosY === yPosition ? /* @__PURE__ */ jsxs("g", {
|
|
47
|
+
children: [
|
|
48
|
+
TooltipRenderer ? /* @__PURE__ */ jsx("foreignObject", {
|
|
49
|
+
children: /* @__PURE__ */ jsxs(DSPopperJS, {
|
|
50
|
+
withoutAnimation: true,
|
|
51
|
+
withoutArrow: true,
|
|
52
|
+
customOffset: [0, 5],
|
|
53
|
+
referenceElement,
|
|
54
|
+
showPopover: true,
|
|
55
|
+
zIndex: theme.zIndex.tooltip,
|
|
56
|
+
startPlacementPreference: scrapper.tooltipPreference,
|
|
57
|
+
children: [
|
|
58
|
+
/* @__PURE__ */ jsx(StyledMouseOverDetectionBox, {}),
|
|
59
|
+
/* @__PURE__ */ jsx(StyledTooltipContainer, {
|
|
60
|
+
children: /* @__PURE__ */ jsx(TooltipRenderer, {
|
|
61
|
+
data: datum
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
})
|
|
66
|
+
}) : null,
|
|
67
|
+
/* @__PURE__ */ jsx("line", {
|
|
68
|
+
ref: setReferenceElement,
|
|
69
|
+
x1: innerWidth,
|
|
70
|
+
strokeWidth: "2px",
|
|
71
|
+
stroke: "transparent",
|
|
72
|
+
y1: yPosition,
|
|
73
|
+
x2: innerWidth,
|
|
74
|
+
y2: yPosition
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx("line", {
|
|
77
|
+
x1: 0,
|
|
78
|
+
strokeWidth: "2px",
|
|
79
|
+
stroke: "grey",
|
|
80
|
+
strokeDasharray: (4, 4),
|
|
81
|
+
y1: yPosition,
|
|
82
|
+
x2: innerWidth,
|
|
83
|
+
y2: yPosition
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}) : null,
|
|
87
|
+
/* @__PURE__ */ jsx("line", {
|
|
88
|
+
onMouseEnter: () => setScrapperPosY(yPosition),
|
|
89
|
+
x1: 0,
|
|
90
|
+
strokeWidth: "4px",
|
|
91
|
+
stroke: "transparent",
|
|
92
|
+
y1: yPosition,
|
|
93
|
+
x2: innerWidth,
|
|
94
|
+
y2: yPosition
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
}, key);
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
Scrapper
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=Scrapper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/Scrapper.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useState } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ThemeContext, styled } from '@elliemae/ds-system';\nimport { ChartContext } from '../ChartContext';\nimport { StyledMouseOverDetectionBox, StyledTooltipContainer } from '../styles';\n\nexport const Scrapper = () => {\n const {\n yScale,\n y2Scale,\n scrapperPosY,\n setScrapperPosY,\n xScale,\n innerHeight,\n innerWidth,\n props: { TooltipRenderer, xAxis, data, scrapper },\n } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n const [referenceElement, setReferenceElement] = useState<React.SVGProps<SVGLineElement> | null>();\n\n const uniqueData = useMemo(() => {\n const valueToPositionPerSeries = data\n .map((serie) =>\n serie.data.map((datum, i) => ({\n position: serie.scale === 'y' || !serie.scale ? yScale(datum.value) : y2Scale(datum.value),\n name: serie.name,\n xValue: xAxis.cols[i],\n yValue: datum.value,\n })),\n )\n .flat(1);\n\n const postionUniqueData = {};\n\n valueToPositionPerSeries.forEach((set) => {\n if (postionUniqueData[[set.position]]) {\n postionUniqueData[[set.position]] = [...postionUniqueData[[set.position]], { ...set }];\n } else {\n postionUniqueData[[set.position]] = [{ ...set }];\n }\n });\n\n return postionUniqueData;\n }, [data, xAxis.cols, y2Scale, yScale]);\n\n return (\n <g>\n {Object.keys(uniqueData).map((key) => {\n const yPosition = parseFloat(key);\n const datum = uniqueData[key];\n return (\n <g key={key}>\n {scrapperPosY === yPosition ? (\n <g>\n {TooltipRenderer ? (\n <foreignObject>\n <DSPopperJS\n withoutAnimation\n withoutArrow\n customOffset={[0, 5]}\n referenceElement={referenceElement}\n showPopover\n zIndex={theme.zIndex.tooltip}\n // placementOrderPreference=\"\"\n startPlacementPreference={scrapper.tooltipPreference}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer data={datum} />\n </StyledTooltipContainer>\n </DSPopperJS>\n </foreignObject>\n ) : null}\n <line\n ref={setReferenceElement}\n x1={innerWidth}\n strokeWidth=\"2px\"\n stroke=\"transparent\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n <line\n // ref={setReferenceElement}\n x1={0}\n strokeWidth=\"2px\"\n stroke=\"grey\"\n strokeDasharray={(4, 4)}\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n </g>\n ) : null}\n <line\n onMouseEnter={() => setScrapperPosY(yPosition)}\n // onMouseLeave={() => setScrapperPosY('')}\n // id=\"horizontal-scrapper-zone\"\n x1={0}\n strokeWidth=\"4px\"\n stroke=\"transparent\"\n y1={yPosition}\n x2={innerWidth}\n y2={yPosition}\n />\n </g>\n );\n })}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,gBAAgB;AACrD,SAAS,kBAAkB;AAC3B,SAAS,oBAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B,8BAA8B;AAE7D,MAAM,WAAW,MAAM;AAC5B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,iBAAiB,OAAO,MAAM,SAAS;AAAA,EAClD,IAAI,WAAW,YAAY;AAC3B,QAAM,QAAQ,WAAW,YAAY;AACrC,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAgD;AAEhG,QAAM,aAAa,QAAQ,MAAM;AAC/B,UAAM,2BAA2B,KAC9B;AAAA,MAAI,CAAC,UACJ,MAAM,KAAK,IAAI,CAAC,OAAO,OAAO;AAAA,QAC5B,UAAU,MAAM,UAAU,OAAO,CAAC,MAAM,QAAQ,OAAO,MAAM,KAAK,IAAI,QAAQ,MAAM,KAAK;AAAA,QACzF,MAAM,MAAM;AAAA,QACZ,QAAQ,MAAM,KAAK;AAAA,QACnB,QAAQ,MAAM;AAAA,MAChB,EAAE;AAAA,IACJ,EACC,KAAK,CAAC;AAET,UAAM,oBAAoB,CAAC;AAE3B,6BAAyB,QAAQ,CAAC,QAAQ;AACxC,UAAI,kBAAkB,CAAC,IAAI,QAAQ,IAAI;AACrC,0BAAkB,CAAC,IAAI,QAAQ,KAAK,CAAC,GAAG,kBAAkB,CAAC,IAAI,QAAQ,IAAI,EAAE,GAAG,IAAI,CAAC;AAAA,MACvF,OAAO;AACL,0BAAkB,CAAC,IAAI,QAAQ,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC;AAAA,MACjD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,MAAM,MAAM,MAAM,SAAS,MAAM,CAAC;AAEtC,SACE,oBAAC;AAAA,IACE,iBAAO,KAAK,UAAU,EAAE,IAAI,CAAC,QAAQ;AACpC,YAAM,YAAY,WAAW,GAAG;AAChC,YAAM,QAAQ,WAAW;AACzB,aACE,qBAAC;AAAA,QACE;AAAA,2BAAiB,YAChB,qBAAC;AAAA,YACE;AAAA,gCACC,oBAAC;AAAA,gBACC,+BAAC;AAAA,kBACC,kBAAgB;AAAA,kBAChB,cAAY;AAAA,kBACZ,cAAc,CAAC,GAAG,CAAC;AAAA,kBACnB;AAAA,kBACA,aAAW;AAAA,kBACX,QAAQ,MAAM,OAAO;AAAA,kBAErB,0BAA0B,SAAS;AAAA,kBAEnC;AAAA,wCAAC,+BAA4B;AAAA,oBAC7B,oBAAC;AAAA,sBACC,8BAAC;AAAA,wBAAgB,MAAM;AAAA,uBAAO;AAAA,qBAChC;AAAA;AAAA,iBACF;AAAA,eACF,IACE;AAAA,cACJ,oBAAC;AAAA,gBACC,KAAK;AAAA,gBACL,IAAI;AAAA,gBACJ,aAAY;AAAA,gBACZ,QAAO;AAAA,gBACP,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,IAAI;AAAA,eACN;AAAA,cACA,oBAAC;AAAA,gBAEC,IAAI;AAAA,gBACJ,aAAY;AAAA,gBACZ,QAAO;AAAA,gBACP,kBAAkB,GAAG;AAAA,gBACrB,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,IAAI;AAAA,eACN;AAAA;AAAA,WACF,IACE;AAAA,UACJ,oBAAC;AAAA,YACC,cAAc,MAAM,gBAAgB,SAAS;AAAA,YAG7C,IAAI;AAAA,YACJ,aAAY;AAAA,YACZ,QAAO;AAAA,YACP,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,WACN;AAAA;AAAA,SArDM,GAsDR;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
|
+
import { ChartContext } from "../ChartContext";
|
|
5
|
+
import { Line, Points, Bars, StackedBar, Area, Pie } from "../series";
|
|
6
|
+
import { getStackedIndex } from "../helpers";
|
|
7
|
+
const SeriesFactory = () => {
|
|
8
|
+
const {
|
|
9
|
+
props: { data, groups, types }
|
|
10
|
+
} = useContext(ChartContext);
|
|
11
|
+
const render = useMemo(() => {
|
|
12
|
+
if (types === "pie") {
|
|
13
|
+
return /* @__PURE__ */ jsx(Pie, {});
|
|
14
|
+
}
|
|
15
|
+
return data.map((serie) => {
|
|
16
|
+
const serieProps = {
|
|
17
|
+
key: serie.key,
|
|
18
|
+
serie
|
|
19
|
+
};
|
|
20
|
+
if (serie.type === "bar" && groups && getStackedIndex(groups, serie.name) > -1) {
|
|
21
|
+
return /* @__PURE__ */ jsx(StackedBar, {
|
|
22
|
+
...serieProps
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (serie.type === "bar") {
|
|
26
|
+
return /* @__PURE__ */ jsx(Bars, {
|
|
27
|
+
...serieProps
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (types === "scatter" && !serie.type || serie.type === "point") {
|
|
31
|
+
return /* @__PURE__ */ jsx(Points, {
|
|
32
|
+
...serieProps
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (serie.type === "line") {
|
|
36
|
+
return /* @__PURE__ */ jsx(Line, {
|
|
37
|
+
...serieProps
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (serie.type === "area") {
|
|
41
|
+
return /* @__PURE__ */ jsx(Area, {
|
|
42
|
+
...serieProps
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
46
|
+
});
|
|
47
|
+
}, [data, groups, types]);
|
|
48
|
+
return /* @__PURE__ */ jsx("g", {
|
|
49
|
+
className: "content",
|
|
50
|
+
children: render
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
SeriesFactory
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=SeriesFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/SeriesFactory.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { Line, Points, Bars, StackedBar, Area, Pie } from '../series';\nimport { getStackedIndex } from '../helpers';\nexport const SeriesFactory = () => {\n const {\n props: { data, groups, types },\n } = useContext(ChartContext);\n\n const render: JSX.Element | JSX.Element[] = useMemo(() => {\n if (types === 'pie') {\n return <Pie />;\n }\n return data.map((serie) => {\n const serieProps = {\n key: serie.key,\n serie,\n };\n if (serie.type === 'bar' && groups && getStackedIndex(groups, serie.name) > -1) {\n return <StackedBar {...serieProps} />;\n }\n if (serie.type === 'bar') {\n return <Bars {...serieProps} />;\n }\n if ((types === 'scatter' && !serie.type) || serie.type === 'point') {\n return <Points {...serieProps} />;\n }\n if (serie.type === 'line') {\n return <Line {...serieProps} />;\n }\n if (serie.type === 'area') {\n return <Area {...serieProps} />;\n }\n return <></>;\n }) as JSX.Element[];\n }, [data, groups, types]);\n return <g className=\"content\">{render}</g>;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAEA,SAAgB,YAAY,eAAe;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,MAAM,QAAQ,MAAM,YAAY,MAAM,WAAW;AAC1D,SAAS,uBAAuB;AACzB,MAAM,gBAAgB,MAAM;AACjC,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM,QAAQ,MAAM;AAAA,EAC/B,IAAI,WAAW,YAAY;AAE3B,QAAM,SAAsC,QAAQ,MAAM;AACxD,QAAI,UAAU,OAAO;AACnB,aAAO,oBAAC,OAAI;AAAA,IACd;AACA,WAAO,KAAK,IAAI,CAAC,UAAU;AACzB,YAAM,aAAa;AAAA,QACjB,KAAK,MAAM;AAAA,QACX;AAAA,MACF;AACA,UAAI,MAAM,SAAS,SAAS,UAAU,gBAAgB,QAAQ,MAAM,IAAI,IAAI,IAAI;AAC9E,eAAO,oBAAC;AAAA,UAAY,GAAG;AAAA,SAAY;AAAA,MACrC;AACA,UAAI,MAAM,SAAS,OAAO;AACxB,eAAO,oBAAC;AAAA,UAAM,GAAG;AAAA,SAAY;AAAA,MAC/B;AACA,UAAK,UAAU,aAAa,CAAC,MAAM,QAAS,MAAM,SAAS,SAAS;AAClE,eAAO,oBAAC;AAAA,UAAQ,GAAG;AAAA,SAAY;AAAA,MACjC;AACA,UAAI,MAAM,SAAS,QAAQ;AACzB,eAAO,oBAAC;AAAA,UAAM,GAAG;AAAA,SAAY;AAAA,MAC/B;AACA,UAAI,MAAM,SAAS,QAAQ;AACzB,eAAO,oBAAC;AAAA,UAAM,GAAG;AAAA,SAAY;AAAA,MAC/B;AACA,aAAO,gCAAE;AAAA,IACX,CAAC;AAAA,EACH,GAAG,CAAC,MAAM,QAAQ,KAAK,CAAC;AACxB,SAAO,oBAAC;AAAA,IAAE,WAAU;AAAA,IAAW;AAAA,GAAO;AACxC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo, useState } from "react";
|
|
4
|
+
import { DSPopperJS } from "@elliemae/ds-popperjs";
|
|
5
|
+
import { ThemeContext } from "@elliemae/ds-system";
|
|
6
|
+
import { ChartContext } from "../ChartContext";
|
|
7
|
+
import { StyledMouseOverDetectionBox, StyledTooltipContainer } from "../styles";
|
|
8
|
+
const VerticalScrapper = () => {
|
|
9
|
+
const {
|
|
10
|
+
xScale,
|
|
11
|
+
scrapperPosX,
|
|
12
|
+
setScrapperPosX,
|
|
13
|
+
innerHeight,
|
|
14
|
+
innerWidth,
|
|
15
|
+
getBandwidth,
|
|
16
|
+
props: { TooltipRenderer, xAxis, data, scrapper }
|
|
17
|
+
} = useContext(ChartContext);
|
|
18
|
+
const theme = useContext(ThemeContext);
|
|
19
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
20
|
+
const isBandAxis = !!(!xAxis.type || xAxis.cols);
|
|
21
|
+
const uniqueData = useMemo(() => {
|
|
22
|
+
let valueToPositionPerSeries;
|
|
23
|
+
if (isBandAxis) {
|
|
24
|
+
valueToPositionPerSeries = data.map(
|
|
25
|
+
(serie) => serie.data.map((datum) => {
|
|
26
|
+
const x = xAxis.cols ? xAxis.cols[datum.position] : datum.value.x;
|
|
27
|
+
const y = typeof datum.value === "number" ? datum.value : datum.value.y;
|
|
28
|
+
return {
|
|
29
|
+
position: xScale(x),
|
|
30
|
+
name: serie.name,
|
|
31
|
+
xValue: x,
|
|
32
|
+
yValue: y
|
|
33
|
+
};
|
|
34
|
+
})
|
|
35
|
+
).flat(1);
|
|
36
|
+
} else {
|
|
37
|
+
valueToPositionPerSeries = data.map(
|
|
38
|
+
(serie) => serie.data.map((datum) => ({
|
|
39
|
+
position: xScale(datum.value.x),
|
|
40
|
+
name: serie.name,
|
|
41
|
+
xValue: datum.value.x,
|
|
42
|
+
yValue: datum.value.y
|
|
43
|
+
}))
|
|
44
|
+
).flat(1);
|
|
45
|
+
}
|
|
46
|
+
const postionUniqueData = {};
|
|
47
|
+
valueToPositionPerSeries.forEach((set) => {
|
|
48
|
+
if (postionUniqueData[[set.position]]) {
|
|
49
|
+
postionUniqueData[[set.position]] = [...postionUniqueData[[set.position]], { ...set }];
|
|
50
|
+
} else {
|
|
51
|
+
postionUniqueData[[set.position]] = [{ ...set }];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return postionUniqueData;
|
|
55
|
+
}, [isBandAxis, data, xScale, xAxis.cols]);
|
|
56
|
+
return /* @__PURE__ */ jsx("g", {
|
|
57
|
+
children: Object.keys(uniqueData).map((key) => {
|
|
58
|
+
const xPosition = parseFloat(key) + (isBandAxis ? getBandwidth() / 2 : 0);
|
|
59
|
+
const datum = uniqueData[key];
|
|
60
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
61
|
+
children: [
|
|
62
|
+
scrapperPosX === xPosition ? /* @__PURE__ */ jsxs("g", {
|
|
63
|
+
children: [
|
|
64
|
+
TooltipRenderer ? /* @__PURE__ */ jsx("foreignObject", {
|
|
65
|
+
children: /* @__PURE__ */ jsxs(DSPopperJS, {
|
|
66
|
+
withoutAnimation: true,
|
|
67
|
+
withoutArrow: true,
|
|
68
|
+
customOffset: [0, 5],
|
|
69
|
+
referenceElement,
|
|
70
|
+
showPopover: true,
|
|
71
|
+
zIndex: theme.zIndex.tooltip,
|
|
72
|
+
startPlacementPreference: scrapper.tooltipPreference,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx(StyledMouseOverDetectionBox, {}),
|
|
75
|
+
/* @__PURE__ */ jsx(StyledTooltipContainer, {
|
|
76
|
+
children: /* @__PURE__ */ jsx(TooltipRenderer, {
|
|
77
|
+
data: datum
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
}) : null,
|
|
83
|
+
/* @__PURE__ */ jsx("line", {
|
|
84
|
+
ref: setReferenceElement,
|
|
85
|
+
x1: xPosition,
|
|
86
|
+
strokeWidth: "2px",
|
|
87
|
+
stroke: scrapper.color,
|
|
88
|
+
y1: 0,
|
|
89
|
+
x2: xPosition,
|
|
90
|
+
y2: innerHeight,
|
|
91
|
+
strokeDasharray: (4, 4)
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
}) : null,
|
|
95
|
+
/* @__PURE__ */ jsx("line", {
|
|
96
|
+
onMouseEnter: () => setScrapperPosX(xPosition),
|
|
97
|
+
x1: xPosition,
|
|
98
|
+
strokeWidth: `${isBandAxis ? getBandwidth() : "2"}px`,
|
|
99
|
+
stroke: "transparent",
|
|
100
|
+
y1: 0,
|
|
101
|
+
x2: xPosition,
|
|
102
|
+
y2: innerHeight
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
}, key);
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
export {
|
|
110
|
+
VerticalScrapper
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=VerticalScrapper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/VerticalScrapper.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useState } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport { ThemeContext, styled } from '@elliemae/ds-system';\nimport { ChartContext } from '../ChartContext';\nimport { StyledMouseOverDetectionBox, StyledTooltipContainer } from '../styles';\n\nexport const VerticalScrapper = () => {\n const {\n xScale,\n scrapperPosX,\n setScrapperPosX,\n innerHeight,\n innerWidth,\n getBandwidth,\n props: { TooltipRenderer, xAxis, data, scrapper },\n } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n const [referenceElement, setReferenceElement] = useState<React.SVGProps<SVGLineElement> | null>();\n\n const isBandAxis = !!(!xAxis.type || xAxis.cols);\n\n const uniqueData = useMemo(() => {\n let valueToPositionPerSeries;\n if (isBandAxis) {\n valueToPositionPerSeries = data\n .map((serie) =>\n serie.data.map((datum) => {\n const x = xAxis.cols ? xAxis.cols[datum.position] : datum.value.x;\n const y = typeof datum.value === 'number' ? datum.value : datum.value.y;\n return {\n position: xScale(x),\n name: serie.name,\n xValue: x,\n yValue: y,\n };\n }),\n )\n .flat(1);\n } else {\n valueToPositionPerSeries = data\n .map((serie) =>\n serie.data.map((datum) => ({\n position: xScale(datum.value.x),\n name: serie.name,\n xValue: datum.value.x,\n yValue: datum.value.y,\n })),\n )\n .flat(1);\n }\n\n const postionUniqueData = {};\n\n valueToPositionPerSeries.forEach((set) => {\n if (postionUniqueData[[set.position]]) {\n postionUniqueData[[set.position]] = [...postionUniqueData[[set.position]], { ...set }];\n } else {\n postionUniqueData[[set.position]] = [{ ...set }];\n }\n });\n\n return postionUniqueData;\n }, [isBandAxis, data, xScale, xAxis.cols]);\n\n return (\n <g>\n {Object.keys(uniqueData).map((key) => {\n const xPosition = parseFloat(key) + (isBandAxis ? getBandwidth() / 2 : 0);\n const datum = uniqueData[key];\n return (\n <g key={key}>\n {scrapperPosX === xPosition ? (\n <g>\n {TooltipRenderer ? (\n <foreignObject>\n <DSPopperJS\n withoutAnimation\n withoutArrow\n customOffset={[0, 5]}\n referenceElement={referenceElement}\n showPopover\n zIndex={theme.zIndex.tooltip}\n startPlacementPreference={scrapper.tooltipPreference}\n >\n <StyledMouseOverDetectionBox />\n <StyledTooltipContainer>\n <TooltipRenderer data={datum} />\n </StyledTooltipContainer>\n </DSPopperJS>\n </foreignObject>\n ) : null}\n <line\n ref={setReferenceElement}\n x1={xPosition}\n strokeWidth=\"2px\"\n stroke={scrapper.color}\n y1={0}\n x2={xPosition}\n y2={innerHeight}\n strokeDasharray={(4, 4)}\n />\n </g>\n ) : null}\n <line\n onMouseEnter={() => setScrapperPosX(xPosition)}\n // onMouseLeave={() => setScrapperPosY('')}\n // id=\"horizontal-scrapper-zone\"\n x1={xPosition}\n strokeWidth={`${isBandAxis ? getBandwidth() : '2'}px`}\n stroke=\"transparent\"\n y1={0}\n x2={xPosition}\n y2={innerHeight}\n />\n </g>\n );\n })}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-utilities";
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
yAxis: {
|
|
5
|
+
showGrid: true,
|
|
6
|
+
color: "black",
|
|
7
|
+
type: "linear"
|
|
8
|
+
},
|
|
9
|
+
xAxis: {
|
|
10
|
+
showGrid: true,
|
|
11
|
+
color: "black",
|
|
12
|
+
type: "band"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const propTypes = {
|
|
16
|
+
...globalAttributesPropTypes,
|
|
17
|
+
height: PropTypes.number.isRequired.description("height").defaultValue(""),
|
|
18
|
+
width: PropTypes.number.isRequired.description("height").defaultValue(""),
|
|
19
|
+
margin: PropTypes.shape({
|
|
20
|
+
top: PropTypes.number,
|
|
21
|
+
bottom: PropTypes.number,
|
|
22
|
+
left: PropTypes.number,
|
|
23
|
+
right: PropTypes.number
|
|
24
|
+
}).isRequired.description("margin").defaultValue(""),
|
|
25
|
+
series: PropTypes.arrayOf(PropTypes.object).description("yValue").defaultValue("")
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
defaultProps,
|
|
29
|
+
propTypes
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/react-desc-prop-types.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\n\ntype MarginT = {\n top: number;\n left: number;\n right: number;\n bottom: number;\n};\n\nexport declare namespace DSPieT {\n export interface SeriesT {\n name: string;\n data: number;\n color: string;\n }\n export interface Props {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n }\n}\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'stackedBar' | 'spline';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export interface SeriesT {\n name: string;\n data: number[] | { x: number; y: number }[];\n type: SerieTypeT;\n scale?: string;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n type: AxisTypeT;\n cols?: number[] | string[] | Date[];\n padding?: number;\n beginAtZero?: boolean;\n }\n\n export interface InternalData {\n key: string;\n group: string;\n type: DSChartT.SerieTypeT;\n scale?: string;\n color: string;\n values: {\n key: string;\n value: number;\n position: number;\n }[];\n }\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter' | 'pie';\n }\n\n export interface DefaultProps {\n yAxis: AxisT;\n xAxis: AxisT;\n }\n\n export interface RequiredProps {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n }\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {\n yAxis: {\n showGrid: true,\n color: 'black',\n type: 'linear',\n },\n xAxis: {\n showGrid: true,\n color: 'black',\n type: 'band',\n },\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,2BAA2B,iBAAiB;AA6E9C,MAAM,eAAsC;AAAA,EACjD,OAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA,OAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AACF;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,UAAU;AAAA,IACf,QAAQ,UAAU;AAAA,IAClB,MAAM,UAAU;AAAA,IAChB,OAAO,UAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
|
+
import { area, curveMonotoneX } from "d3";
|
|
5
|
+
import { Points } from "./Points";
|
|
6
|
+
import { StyledArea } from "../styles";
|
|
7
|
+
import { ChartContext } from "../ChartContext";
|
|
8
|
+
import { getStackedData } from "../helpers";
|
|
9
|
+
const Area = ({ serie }) => {
|
|
10
|
+
const {
|
|
11
|
+
props: { xAxis },
|
|
12
|
+
xScale,
|
|
13
|
+
yScale,
|
|
14
|
+
innerHeight,
|
|
15
|
+
y2Scale,
|
|
16
|
+
colorScale,
|
|
17
|
+
activeSerie,
|
|
18
|
+
stackedData,
|
|
19
|
+
setActiveSerie
|
|
20
|
+
} = useContext(ChartContext);
|
|
21
|
+
const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
|
|
22
|
+
const areaD3 = useMemo(() => {
|
|
23
|
+
const serieWithStackedValues = getStackedData(stackedData, serie);
|
|
24
|
+
if (serieWithStackedValues) {
|
|
25
|
+
return area().x((_, i) => xScale(serie.data[i].value.x)).y0(([y1]) => finalYScale(y1)).y1(([, y2]) => finalYScale(y2)).curve(curveMonotoneX)(serieWithStackedValues);
|
|
26
|
+
}
|
|
27
|
+
return area().x((d) => xScale(d.value.x ?? xAxis?.cols?.[d.position] ?? d.position)).y0(innerHeight).y1((d) => finalYScale(d.value.y ?? d.value)).curve(curveMonotoneX)(serie.data);
|
|
28
|
+
}, [stackedData, serie, innerHeight, finalYScale, xScale, xAxis?.cols]);
|
|
29
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
30
|
+
onMouseEnter: () => setActiveSerie(serie.key),
|
|
31
|
+
onMouseLeave: () => setActiveSerie(""),
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx(StyledArea, {
|
|
34
|
+
d: areaD3,
|
|
35
|
+
isActiveArea: activeSerie === serie.key,
|
|
36
|
+
fill: colorScale(serie.name)
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ jsx(Points, {
|
|
39
|
+
serie
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
Area
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Area.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Area.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { area, curveMonotoneX } from 'd3';\nimport { Points } from './Points';\nimport { StyledArea } from '../styles';\nimport { ChartContext } from '../ChartContext';\nimport { getStackedData } from '../helpers';\nexport const Area = ({ serie }) => {\n const {\n props: { xAxis },\n xScale,\n yScale,\n innerHeight,\n y2Scale,\n colorScale,\n activeSerie,\n stackedData,\n setActiveSerie,\n } = useContext(ChartContext);\n\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n const areaD3 = useMemo(() => {\n const serieWithStackedValues = getStackedData(stackedData, serie);\n if (serieWithStackedValues) {\n return area()\n .x((_, i) => xScale(serie.data[i].value.x))\n .y0(([y1]) => finalYScale(y1))\n .y1(([, y2]) => finalYScale(y2))\n .curve(curveMonotoneX)(serieWithStackedValues);\n }\n return area()\n .x((d) => xScale(d.value.x ?? xAxis?.cols?.[d.position] ?? d.position))\n .y0(innerHeight)\n .y1((d) => finalYScale(d.value.y ?? d.value))\n .curve(curveMonotoneX)(serie.data);\n }, [stackedData, serie, innerHeight, finalYScale, xScale, xAxis?.cols]);\n\n return (\n <g\n // transform={getBandwidth ? `translate(${getBandwidth() / 2}, 0)` : ''}\n onMouseEnter={() => setActiveSerie(serie.key)}\n onMouseLeave={() => setActiveSerie('')}\n >\n <StyledArea d={areaD3} isActiveArea={activeSerie === serie.key} fill={colorScale(serie.name)} />\n <Points serie={serie} />\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,eAAe;AAC3C,SAAS,MAAM,sBAAsB;AACrC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AACxB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAM;AACjC,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,QAAM,SAAS,QAAQ,MAAM;AAC3B,UAAM,yBAAyB,eAAe,aAAa,KAAK;AAChE,QAAI,wBAAwB;AAC1B,aAAO,KAAK,EACT,EAAE,CAAC,GAAG,MAAM,OAAO,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,EACzC,GAAG,CAAC,CAAC,EAAE,MAAM,YAAY,EAAE,CAAC,EAC5B,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,YAAY,EAAE,CAAC,EAC9B,MAAM,cAAc,EAAE,sBAAsB;AAAA,IACjD;AACA,WAAO,KAAK,EACT,EAAE,CAAC,MAAM,OAAO,EAAE,MAAM,KAAK,OAAO,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EACrE,GAAG,WAAW,EACd,GAAG,CAAC,MAAM,YAAY,EAAE,MAAM,KAAK,EAAE,KAAK,CAAC,EAC3C,MAAM,cAAc,EAAE,MAAM,IAAI;AAAA,EACrC,GAAG,CAAC,aAAa,OAAO,aAAa,aAAa,QAAQ,OAAO,IAAI,CAAC;AAEtE,SACE,qBAAC;AAAA,IAEC,cAAc,MAAM,eAAe,MAAM,GAAG;AAAA,IAC5C,cAAc,MAAM,eAAe,EAAE;AAAA,IAErC;AAAA,0BAAC;AAAA,QAAW,GAAG;AAAA,QAAQ,cAAc,gBAAgB,MAAM;AAAA,QAAK,MAAM,WAAW,MAAM,IAAI;AAAA,OAAG;AAAA,MAC9F,oBAAC;AAAA,QAAO;AAAA,OAAc;AAAA;AAAA,GACxB;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { Rect } from "./Rect";
|
|
5
|
+
import { ChartContext } from "../ChartContext";
|
|
6
|
+
const Bars = ({ serie }) => {
|
|
7
|
+
const {
|
|
8
|
+
props: { xAxis, yAxis },
|
|
9
|
+
innerHeight,
|
|
10
|
+
xScale,
|
|
11
|
+
yScale,
|
|
12
|
+
getBandwidth,
|
|
13
|
+
subGroupScale,
|
|
14
|
+
colorScale
|
|
15
|
+
} = useContext(ChartContext);
|
|
16
|
+
const isHorizontal = !!yScale.bandwidth;
|
|
17
|
+
return /* @__PURE__ */ jsx("g", {
|
|
18
|
+
fill: colorScale(serie.name),
|
|
19
|
+
children: serie.data.map((bar, i) => {
|
|
20
|
+
const width = isHorizontal ? xScale(bar.value) : subGroupScale?.bandwidth();
|
|
21
|
+
const height = isHorizontal ? subGroupScale?.bandwidth() : innerHeight - yScale(bar.value.y ?? bar.value);
|
|
22
|
+
const x = xAxis?.cols?.[i] ?? bar.value.x ?? i;
|
|
23
|
+
const y = bar.value.y ?? bar.value;
|
|
24
|
+
const transformX = isHorizontal ? 0 : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? width / 2 * subGroupScale.domain().length : 0);
|
|
25
|
+
const transformY = isHorizontal ? subGroupScale(serie.name) + yScale(yAxis?.cols?.[i] ?? i) : yScale(y);
|
|
26
|
+
const diff = xScale(bar.value.x) - width / 2;
|
|
27
|
+
return /* @__PURE__ */ jsx("g", {
|
|
28
|
+
transform: `translate(${transformX},${transformY})`,
|
|
29
|
+
children: /* @__PURE__ */ jsx(Rect, {
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
label: serie.name,
|
|
33
|
+
id: bar.key
|
|
34
|
+
})
|
|
35
|
+
}, bar.key);
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
Bars
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=Bars.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Bars.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport { ScaleBand } from 'd3';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { DSChartT } from '../react-desc-prop-types';\n\ninterface BarsT {\n serie: DSChartT.InternalData;\n}\nexport const Bars = ({ serie }: BarsT) => {\n const {\n props: { xAxis, yAxis },\n innerHeight,\n xScale,\n yScale,\n getBandwidth,\n subGroupScale,\n colorScale,\n } = useContext(ChartContext);\n\n const isHorizontal = !!(yScale as ScaleBand<string>).bandwidth;\n return (\n <g fill={colorScale(serie.name)}>\n {serie.data.map((bar, i) => {\n const width = isHorizontal ? xScale(bar.value) : subGroupScale?.bandwidth();\n const height = isHorizontal ? subGroupScale?.bandwidth() : innerHeight - yScale(bar.value.y ?? bar.value);\n\n const x = xAxis?.cols?.[i] ?? bar.value.x ?? i;\n const y = bar.value.y ?? bar.value;\n\n const transformX = isHorizontal\n ? 0\n : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? (width / 2) * subGroupScale.domain().length : 0);\n const transformY = isHorizontal ? subGroupScale(serie.name) + yScale(yAxis?.cols?.[i] ?? i) : yScale(y);\n\n const diff = xScale(bar.value.x) - width / 2;\n return (\n <g key={bar.key} transform={`translate(${transformX},${transformY})`}>\n <Rect width={width} height={height} label={serie.name} id={bar.key} />\n </g>\n );\n })}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,kBAAkB;AAElC,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAMtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAa;AACxC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,MAAM;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,eAAe,CAAC,CAAE,OAA6B;AACrD,SACE,oBAAC;AAAA,IAAE,MAAM,WAAW,MAAM,IAAI;AAAA,IAC3B,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,YAAM,QAAQ,eAAe,OAAO,IAAI,KAAK,IAAI,eAAe,UAAU;AAC1E,YAAM,SAAS,eAAe,eAAe,UAAU,IAAI,cAAc,OAAO,IAAI,MAAM,KAAK,IAAI,KAAK;AAExG,YAAM,IAAI,OAAO,OAAO,MAAM,IAAI,MAAM,KAAK;AAC7C,YAAM,IAAI,IAAI,MAAM,KAAK,IAAI;AAE7B,YAAM,aAAa,eACf,IACA,cAAc,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,IAAK,QAAQ,IAAK,cAAc,OAAO,EAAE,SAAS;AACzG,YAAM,aAAa,eAAe,cAAc,MAAM,IAAI,IAAI,OAAO,OAAO,OAAO,MAAM,CAAC,IAAI,OAAO,CAAC;AAEtG,YAAM,OAAO,OAAO,IAAI,MAAM,CAAC,IAAI,QAAQ;AAC3C,aACE,oBAAC;AAAA,QAAgB,WAAW,aAAa,cAAc;AAAA,QACrD,8BAAC;AAAA,UAAK;AAAA,UAAc;AAAA,UAAgB,OAAO,MAAM;AAAA,UAAM,IAAI,IAAI;AAAA,SAAK;AAAA,SAD9D,IAAI,GAEZ;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|