@elliemae/ds-dataviz 3.8.0-rc.3 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/graphs/Chart/Pie.js +49 -0
- package/dist/cjs/graphs/Chart/Pie.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/ColorLegend.js +70 -0
- package/dist/cjs/graphs/Chart/parts/ColorLegend.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/VerticalScrapper.js +138 -0
- package/dist/cjs/graphs/Chart/parts/VerticalScrapper.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/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/ColorLegend.js +44 -0
- package/dist/esm/graphs/Chart/parts/ColorLegend.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/VerticalScrapper.js +112 -0
- package/dist/esm/graphs/Chart/parts/VerticalScrapper.js.map +7 -0
- package/package.json +8 -8
|
@@ -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": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,gBAAgB;AACrD,SAAS,kBAAkB;AAC3B,SAAS,oBAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B,8BAA8B;AAE7D,MAAM,mBAAmB,MAAM;AACpC,QAAM;AAAA,IACJ;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,CAAC,EAAE,CAAC,MAAM,QAAQ,MAAM;AAE3C,QAAM,aAAa,QAAQ,MAAM;AAC/B,QAAI;AACJ,QAAI,YAAY;AACd,iCAA2B,KACxB;AAAA,QAAI,CAAC,UACJ,MAAM,KAAK,IAAI,CAAC,UAAU;AACxB,gBAAM,IAAI,MAAM,OAAO,MAAM,KAAK,MAAM,YAAY,MAAM,MAAM;AAChE,gBAAM,IAAI,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ,MAAM,MAAM;AACtE,iBAAO;AAAA,YACL,UAAU,OAAO,CAAC;AAAA,YAClB,MAAM,MAAM;AAAA,YACZ,QAAQ;AAAA,YACR,QAAQ;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH,EACC,KAAK,CAAC;AAAA,IACX,OAAO;AACL,iCAA2B,KACxB;A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ACE;AAAA,cACJ,oBAAC;AAAA,gBACC,KAAK;AAAA,gBACL,IAAI;AAAA,gBACJ,aAAY;AAAA,gBACZ,QAAQ,SAAS;AAAA,gBACjB,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,kBAAkB,GAAG;AAAA,eACvB;AAAA;AAAA,WACF,IACE;AAAA,UACJ,oBAAC;AAAA,YACC,cAAc,MAAM,gBAAgB,SAAS;AAAA,YAG7C,IAAI;AAAA,YACJ,aAAa,GAAG,aAAa,aAAa,IAAI;AAAA,YAC9C,QAAO;AAAA,YACP,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,WACN;AAAA;AAAA,SA3CM,GA4CR;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-dataviz",
|
|
3
|
-
"version": "3.8.0
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - DataViz",
|
|
6
6
|
"files": [
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"indent": 4
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@elliemae/ds-grid": "3.8.0
|
|
39
|
-
"@elliemae/ds-icon": "3.8.0
|
|
40
|
-
"@elliemae/ds-icons": "3.8.0
|
|
41
|
-
"@elliemae/ds-popperjs": "3.8.0
|
|
42
|
-
"@elliemae/ds-system": "3.8.0
|
|
43
|
-
"@elliemae/ds-tooltip": "3.8.0
|
|
44
|
-
"@elliemae/ds-utilities": "3.8.0
|
|
38
|
+
"@elliemae/ds-grid": "3.8.0",
|
|
39
|
+
"@elliemae/ds-icon": "3.8.0",
|
|
40
|
+
"@elliemae/ds-icons": "3.8.0",
|
|
41
|
+
"@elliemae/ds-popperjs": "3.8.0",
|
|
42
|
+
"@elliemae/ds-system": "3.8.0",
|
|
43
|
+
"@elliemae/ds-tooltip": "3.8.0",
|
|
44
|
+
"@elliemae/ds-utilities": "3.8.0",
|
|
45
45
|
"d3": "~7.4.4"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|