@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,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var VerticalScrapper_exports = {};
|
|
26
|
+
__export(VerticalScrapper_exports, {
|
|
27
|
+
VerticalScrapper: () => VerticalScrapper
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(VerticalScrapper_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_ds_popperjs = require("@elliemae/ds-popperjs");
|
|
34
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
35
|
+
var import_ChartContext = require("../ChartContext");
|
|
36
|
+
var import_styles = require("../styles");
|
|
37
|
+
const VerticalScrapper = () => {
|
|
38
|
+
const {
|
|
39
|
+
xScale,
|
|
40
|
+
scrapperPosX,
|
|
41
|
+
setScrapperPosX,
|
|
42
|
+
innerHeight,
|
|
43
|
+
innerWidth,
|
|
44
|
+
getBandwidth,
|
|
45
|
+
props: { TooltipRenderer, xAxis, data, scrapper }
|
|
46
|
+
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
47
|
+
const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
|
|
48
|
+
const [referenceElement, setReferenceElement] = (0, import_react.useState)();
|
|
49
|
+
const isBandAxis = !!(!xAxis.type || xAxis.cols);
|
|
50
|
+
const uniqueData = (0, import_react.useMemo)(() => {
|
|
51
|
+
let valueToPositionPerSeries;
|
|
52
|
+
if (isBandAxis) {
|
|
53
|
+
valueToPositionPerSeries = data.map(
|
|
54
|
+
(serie) => serie.data.map((datum) => {
|
|
55
|
+
const x = xAxis.cols ? xAxis.cols[datum.position] : datum.value.x;
|
|
56
|
+
const y = typeof datum.value === "number" ? datum.value : datum.value.y;
|
|
57
|
+
return {
|
|
58
|
+
position: xScale(x),
|
|
59
|
+
name: serie.name,
|
|
60
|
+
xValue: x,
|
|
61
|
+
yValue: y
|
|
62
|
+
};
|
|
63
|
+
})
|
|
64
|
+
).flat(1);
|
|
65
|
+
} else {
|
|
66
|
+
valueToPositionPerSeries = data.map(
|
|
67
|
+
(serie) => serie.data.map((datum) => ({
|
|
68
|
+
position: xScale(datum.value.x),
|
|
69
|
+
name: serie.name,
|
|
70
|
+
xValue: datum.value.x,
|
|
71
|
+
yValue: datum.value.y
|
|
72
|
+
}))
|
|
73
|
+
).flat(1);
|
|
74
|
+
}
|
|
75
|
+
const postionUniqueData = {};
|
|
76
|
+
valueToPositionPerSeries.forEach((set) => {
|
|
77
|
+
if (postionUniqueData[[set.position]]) {
|
|
78
|
+
postionUniqueData[[set.position]] = [...postionUniqueData[[set.position]], { ...set }];
|
|
79
|
+
} else {
|
|
80
|
+
postionUniqueData[[set.position]] = [{ ...set }];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return postionUniqueData;
|
|
84
|
+
}, [isBandAxis, data, xScale, xAxis.cols]);
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
86
|
+
children: Object.keys(uniqueData).map((key) => {
|
|
87
|
+
const xPosition = parseFloat(key) + (isBandAxis ? getBandwidth() / 2 : 0);
|
|
88
|
+
const datum = uniqueData[key];
|
|
89
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
90
|
+
children: [
|
|
91
|
+
scrapperPosX === xPosition ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
92
|
+
children: [
|
|
93
|
+
TooltipRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("foreignObject", {
|
|
94
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_popperjs.DSPopperJS, {
|
|
95
|
+
withoutAnimation: true,
|
|
96
|
+
withoutArrow: true,
|
|
97
|
+
customOffset: [0, 5],
|
|
98
|
+
referenceElement,
|
|
99
|
+
showPopover: true,
|
|
100
|
+
zIndex: theme.zIndex.tooltip,
|
|
101
|
+
startPlacementPreference: scrapper.tooltipPreference,
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledMouseOverDetectionBox, {}),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTooltipContainer, {
|
|
105
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, {
|
|
106
|
+
data: datum
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
}) : null,
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", {
|
|
113
|
+
ref: setReferenceElement,
|
|
114
|
+
x1: xPosition,
|
|
115
|
+
strokeWidth: "2px",
|
|
116
|
+
stroke: scrapper.color,
|
|
117
|
+
y1: 0,
|
|
118
|
+
x2: xPosition,
|
|
119
|
+
y2: innerHeight,
|
|
120
|
+
strokeDasharray: (4, 4)
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
}) : null,
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", {
|
|
125
|
+
onMouseEnter: () => setScrapperPosX(xPosition),
|
|
126
|
+
x1: xPosition,
|
|
127
|
+
strokeWidth: `${isBandAxis ? getBandwidth() : "2"}px`,
|
|
128
|
+
stroke: "transparent",
|
|
129
|
+
y1: 0,
|
|
130
|
+
x2: xPosition,
|
|
131
|
+
y2: innerHeight
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
}, key);
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=VerticalScrapper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/graphs/Chart/parts/VerticalScrapper.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAAqD;AACrD,yBAA2B;AAC3B,uBAAqC;AACrC,0BAA6B;AAC7B,oBAAoE;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,QAAI,yBAAW,gCAAY;AAC3B,QAAM,YAAQ,yBAAW,6BAAY;AACrC,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAgD;AAEhG,QAAM,aAAa,CAAC,EAAE,CAAC,MAAM,QAAQ,MAAM;AAE3C,QAAM,iBAAa,sBAAQ,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;AAAA,QAAI,CAAC,UACJ,MAAM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,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,4CAAC;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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChartContainer } from "./parts/ChartContainer";
|
|
4
|
+
import { Pie } from "./series";
|
|
5
|
+
import { PieChartContext } from "./ChartContext";
|
|
6
|
+
import { usePie } from "./config/usePie";
|
|
7
|
+
import { ColorLegend } from "./parts/ColorLegend";
|
|
8
|
+
const PieChart = (props) => {
|
|
9
|
+
const ctx = usePie(props);
|
|
10
|
+
return /* @__PURE__ */ jsx(PieChartContext.Provider, {
|
|
11
|
+
value: ctx,
|
|
12
|
+
children: /* @__PURE__ */ jsxs(ChartContainer, {
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx(ColorLegend, {}),
|
|
15
|
+
/* @__PURE__ */ jsx(Pie, {})
|
|
16
|
+
]
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
PieChart
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=Pie.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/Pie.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { ChartContainer } from './parts/ChartContainer';\nimport { Pie } from './series';\nimport { PieChartContext } from './ChartContext';\nimport { usePie } from './config/usePie';\nimport type { DSPieT } from './react-desc-prop-types';\nimport { ColorLegend } from './parts/ColorLegend';\nexport const PieChart: React.ComponentType<DSPieT.Props> = (props) => {\n const ctx = usePie(props);\n return (\n <PieChartContext.Provider value={ctx}>\n <ChartContainer>\n <ColorLegend />\n <Pie />\n </ChartContainer>\n </PieChartContext.Provider>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,uBAAuB;AAChC,SAAS,cAAc;AAEvB,SAAS,mBAAmB;AACrB,MAAM,WAA8C,CAAC,UAAU;AACpE,QAAM,MAAM,OAAO,KAAK;AACxB,SACE,oBAAC,gBAAgB,UAAhB;AAAA,IAAyB,OAAO;AAAA,IAC/B,+BAAC;AAAA,MACC;AAAA,4BAAC,eAAY;AAAA,QACb,oBAAC,OAAI;AAAA;AAAA,KACP;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useEffect, useRef } from "react";
|
|
4
|
+
import { select, axisBottom, timeFormat } from "d3";
|
|
5
|
+
import { StyledAxis, StyledGrid } from "../styles";
|
|
6
|
+
import { ChartContext } from "../ChartContext";
|
|
7
|
+
const AxisBottom = () => {
|
|
8
|
+
const {
|
|
9
|
+
props: { xAxis, xAxisLabelOffset = 50, xAxisLabel },
|
|
10
|
+
innerHeight,
|
|
11
|
+
innerWidth,
|
|
12
|
+
xScale,
|
|
13
|
+
tickOffset = 3
|
|
14
|
+
} = useContext(ChartContext);
|
|
15
|
+
const axisRef = useRef();
|
|
16
|
+
const gridRef = useRef();
|
|
17
|
+
const ticks = xScale.ticks?.();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const grid = axisBottom(xScale).tickSize(xAxis?.showGrid ? -innerHeight : 0).tickFormat("").tickSizeOuter(0);
|
|
20
|
+
const axis = axisBottom(xScale);
|
|
21
|
+
if (xAxis.tickValues && ticks) {
|
|
22
|
+
console.log(ticks, "ticks");
|
|
23
|
+
const finalTicks = xAxis.overwriteTicks ? xAxis.tickValues : [...ticks, ...xAxis.tickValues];
|
|
24
|
+
axis.tickValues(finalTicks);
|
|
25
|
+
}
|
|
26
|
+
if (xAxis.tickFormat) {
|
|
27
|
+
if (typeof xAxis.tickFormat === "string") {
|
|
28
|
+
const formatGenerator = timeFormat(xAxis.tickFormat);
|
|
29
|
+
axis.tickFormat((d) => formatGenerator(d));
|
|
30
|
+
}
|
|
31
|
+
if (typeof xAxis.tickFormat === "function") {
|
|
32
|
+
axis.tickFormat(xAxis.tickFormat);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
select(gridRef.current).call(grid);
|
|
36
|
+
select(axisRef.current).call(axis);
|
|
37
|
+
}, [innerHeight, ticks, xAxis?.showGrid, xAxis.tickFormat, xAxis.tickValues, xScale]);
|
|
38
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
39
|
+
transform: `translate(0,${innerHeight})`,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(StyledAxis, {
|
|
42
|
+
ref: axisRef,
|
|
43
|
+
children: /* @__PURE__ */ jsx("text", {
|
|
44
|
+
className: "axis-label",
|
|
45
|
+
x: innerWidth / 2,
|
|
46
|
+
y: xAxisLabelOffset,
|
|
47
|
+
textAnchor: "middle",
|
|
48
|
+
children: xAxis.label
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsx(StyledGrid, {
|
|
52
|
+
ref: gridRef
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
AxisBottom
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=AxisBottom.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/AxisBottom.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect, useRef } from 'react';\nimport { select, axisBottom, timeFormat } from 'd3';\nimport { StyledAxis, StyledGrid } from '../styles';\nimport { ChartContext } from '../ChartContext';\n\nexport const AxisBottom = () => {\n const {\n props: { xAxis, xAxisLabelOffset = 50, xAxisLabel },\n innerHeight,\n innerWidth,\n xScale,\n tickOffset = 3,\n } = useContext(ChartContext);\n\n const axisRef = useRef();\n const gridRef = useRef();\n const ticks = xScale.ticks?.();\n useEffect(() => {\n const grid = axisBottom(xScale)\n .tickSize(xAxis?.showGrid ? -innerHeight : 0)\n .tickFormat('')\n .tickSizeOuter(0);\n\n const axis = axisBottom(xScale);\n\n if (xAxis.tickValues && ticks) {\n console.log(ticks, 'ticks');\n const finalTicks = xAxis.overwriteTicks ? xAxis.tickValues : [...ticks, ...xAxis.tickValues];\n axis.tickValues(finalTicks);\n }\n\n if (xAxis.tickFormat) {\n if (typeof xAxis.tickFormat === 'string') {\n const formatGenerator = timeFormat(xAxis.tickFormat);\n axis.tickFormat((d) => formatGenerator(d));\n }\n if (typeof xAxis.tickFormat === 'function') {\n axis.tickFormat(xAxis.tickFormat);\n }\n }\n\n select(gridRef.current).call(grid);\n select(axisRef.current).call(axis);\n }, [innerHeight, ticks, xAxis?.showGrid, xAxis.tickFormat, xAxis.tickValues, xScale]);\n\n return (\n <g transform={`translate(0,${innerHeight})`}>\n <StyledAxis ref={axisRef}>\n <text className=\"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AG,CAAC,aAAa,OAAO,OAAO,UAAU,MAAM,YAAY,MAAM,YAAY,MAAM,CAAC;AAEpF,SACE,qBAAC;AAAA,IAAE,WAAW,eAAe;AAAA,IAC3B;AAAA,0BAAC;AAAA,QAAW,KAAK;AAAA,QACf,8BAAC;AAAA,UAAK,WAAU;AAAA,UAAa,GAAG,aAAa;AAAA,UAAG,GAAG;AAAA,UAAkB,YAAW;AAAA,UAC7E,gBAAM;AAAA,SACT;AAAA,OACF;AAAA,MACA,oBAAC;AAAA,QAAW,KAAK;AAAA,OAAS;AAAA;AAAA,GAC5B;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useEffect, useRef } from "react";
|
|
4
|
+
import { select, axisLeft } from "d3";
|
|
5
|
+
import { StyledAxis, StyledGrid } from "../styles";
|
|
6
|
+
import { ChartContext } from "../ChartContext";
|
|
7
|
+
const AxisLeft = () => {
|
|
8
|
+
const {
|
|
9
|
+
props: { yAxis, yAxisLabelOffset = 45, yAxisLabel },
|
|
10
|
+
innerHeight,
|
|
11
|
+
innerWidth,
|
|
12
|
+
yScale
|
|
13
|
+
} = useContext(ChartContext);
|
|
14
|
+
const ref = useRef();
|
|
15
|
+
const gridRef = useRef();
|
|
16
|
+
const ticks = yScale.ticks?.();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const axis = axisLeft(yScale);
|
|
19
|
+
if (yAxis.tickValues && ticks) {
|
|
20
|
+
console.log(ticks, "ticks");
|
|
21
|
+
const finalTicks = yAxis.overwriteTicks ? yAxis.tickValues : [...ticks, ...yAxis.tickValues];
|
|
22
|
+
axis.tickValues(finalTicks);
|
|
23
|
+
}
|
|
24
|
+
if (yAxis.tickFormat) {
|
|
25
|
+
axis.tickFormat(yAxis.tickFormat);
|
|
26
|
+
}
|
|
27
|
+
const grid = axisLeft(yScale).tickFormat("").tickSize(yAxis?.showGrid ? -innerWidth : 0).tickSizeOuter(0);
|
|
28
|
+
select(ref.current).call(axis);
|
|
29
|
+
select(gridRef.current).call(grid);
|
|
30
|
+
}, [innerWidth, ticks, yAxis.overwriteTicks, yAxis?.showGrid, yAxis.tickFormat, yAxis.tickValues, yScale]);
|
|
31
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx(StyledAxis, {
|
|
34
|
+
ref,
|
|
35
|
+
color: yAxis.color,
|
|
36
|
+
children: /* @__PURE__ */ jsx("text", {
|
|
37
|
+
className: "axis-label",
|
|
38
|
+
textAnchor: "middle",
|
|
39
|
+
transform: `translate(${-yAxisLabelOffset},${innerHeight / 2}) rotate(-90)`,
|
|
40
|
+
children: yAxis?.label
|
|
41
|
+
})
|
|
42
|
+
}),
|
|
43
|
+
" ",
|
|
44
|
+
/* @__PURE__ */ jsx(StyledGrid, {
|
|
45
|
+
ref: gridRef
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
AxisLeft
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=AxisLeft.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/AxisLeft.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect, useRef } from 'react';\nimport { select, axisLeft } from 'd3';\nimport { StyledAxis, StyledGrid } from '../styles';\nimport { ChartContext } from '../ChartContext';\n\nexport const AxisLeft = () => {\n const {\n props: { yAxis, yAxisLabelOffset = 45, yAxisLabel },\n innerHeight,\n innerWidth,\n yScale,\n } = useContext(ChartContext);\n\n const ref = useRef();\n const gridRef = useRef();\n const ticks = yScale.ticks?.();\n\n useEffect(() => {\n const axis = axisLeft(yScale);\n\n if (yAxis.tickValues && ticks) {\n console.log(ticks, 'ticks');\n const finalTicks = yAxis.overwriteTicks ? yAxis.tickValues : [...ticks, ...yAxis.tickValues];\n axis.tickValues(finalTicks);\n }\n\n if (yAxis.tickFormat) {\n axis.tickFormat(yAxis.tickFormat);\n }\n\n const grid = axisLeft(yScale)\n .tickFormat('')\n .tickSize(yAxis?.showGrid ? -innerWidth : 0)\n .tickSizeOuter(0);\n\n select(ref.current).call(axis);\n select(gridRef.current).call(grid);\n }, [innerWidth, ticks, yAxis.overwriteTicks, yAxis?.showGrid, yAxis.tickFormat, yAxis.tickValues, yScale]);\n return (\n <g>\n <StyledAxis ref={ref} color={yAxis.color}>\n <text\n className=\"axis-label\"\n textAnchor=\"middle\"\n transform={`translate(${-yAxisLabelOffset},${innerHeight / 2}) rotate(-90)`}\n >\n {yAxis?.label}\n </text>\n </StyledAxis>{' '}\n <StyledGrid ref={gridRef}></StyledGrid>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,WAAW,cAAc;AACrD,SAAS,QAAQ,gBAAgB;AACjC,SAAS,YAAY,kBAAkB;AACvC,SAAS,oBAAoB;AAEtB,MAAM,WAAW,MAAM;AAC5B,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,mBAAmB,IAAI,WAAW;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,MAAM,OAAO;AACnB,QAAM,UAAU,OAAO;AACvB,QAAM,QAAQ,OAAO,QAAQ;AAE7B,YAAU,MAAM;AACd,UAAM,OAAO,SAAS,MAAM;AAE5B,QAAI,MAAM,cAAc,OAAO;AAC7B,cAAQ,IAAI,OAAO,OAAO;AAC1B,YAAM,aAAa,MAAM,iBAAiB,MAAM,aAAa,CAAC,GAAG,OAAO,GAAG,MAAM,UAAU;AAC3F,WAAK,WAAW,UAAU;AAAA,IAC5B;AAEA,QAAI,MAAM,YAAY;AACpB,WAAK,WAAW,MAAM,UAAU;AAAA,IAClC;AAEA,UAAM,OAAO,SAAS,MAAM,EACzB,WAAW,EAAE,EACb,SAAS,OAAO,WAAW,CAAC,aAAa,CAAC,EAC1C,cAAc,CAAC;AAElB,WAAO,IAAI,OAAO,EAAE,KAAK,IAAI;AAC7B,WAAO,QAAQ,OAAO,EAAE,KAAK,IAAI;AAAA,EACnC,GAAG,CAAC,YAAY,OAAO,MAAM,gBAAgB,OAAO,UAAU,MAAM,YAAY,MAAM,YAAY,MAAM,CAAC;AACzG,SACE,qBAAC;AAAA,IACC;AAAA,0BAAC;AAAA,QAAW;AAAA,QAAU,OAAO,MAAM;AAAA,QACjC,8BAAC;AAAA,UACC,WAAU;AAAA,UACV,YAAW;AAAA,UACX,WAAW,aAAa,CAAC,oBAAoB,cAAc;AAAA,UAE1D,iBAAO;AAAA,SACV;AAAA,OACF;AAAA,MAAc;AAAA,MACd,oBAAC;AAAA,QAAW,KAAK;AAAA,OAAS;AAAA;AAAA,GAC5B;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useEffect, useRef } from "react";
|
|
4
|
+
import { select, axisRight } from "d3";
|
|
5
|
+
import { StyledAxis } from "../styles";
|
|
6
|
+
import { ChartContext } from "../ChartContext";
|
|
7
|
+
const AxisRight = () => {
|
|
8
|
+
const {
|
|
9
|
+
props: { y2Axis, yAxisLabelOffset = 45, y2AxisLabel },
|
|
10
|
+
innerHeight,
|
|
11
|
+
innerWidth,
|
|
12
|
+
y2Scale
|
|
13
|
+
} = useContext(ChartContext);
|
|
14
|
+
if (!y2Axis)
|
|
15
|
+
return null;
|
|
16
|
+
const ref = useRef();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const axis = axisRight(y2Scale).tickSizeOuter(0);
|
|
19
|
+
select(ref.current).call(axis);
|
|
20
|
+
}, [innerWidth, y2Scale]);
|
|
21
|
+
return /* @__PURE__ */ jsx("g", {
|
|
22
|
+
transform: `translate(${innerWidth},0)`,
|
|
23
|
+
children: /* @__PURE__ */ jsx(StyledAxis, {
|
|
24
|
+
ref,
|
|
25
|
+
color: y2Axis.color,
|
|
26
|
+
children: /* @__PURE__ */ jsx("text", {
|
|
27
|
+
className: "axis-label",
|
|
28
|
+
textAnchor: "middle",
|
|
29
|
+
transform: `translate(${-yAxisLabelOffset},${innerHeight / 2}) rotate(-90)`
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
AxisRight
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=AxisRight.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/AxisRight.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect, useRef } from 'react';\nimport { select, axisRight } from 'd3';\nimport { StyledAxis } from '../styles';\nimport { ChartContext } from '../ChartContext';\n\nexport const AxisRight = () => {\n const {\n props: { y2Axis, yAxisLabelOffset = 45, y2AxisLabel },\n innerHeight,\n innerWidth,\n y2Scale,\n } = useContext(ChartContext);\n\n if (!y2Axis) return null;\n const ref = useRef();\n useEffect(() => {\n const axis = axisRight(y2Scale).tickSizeOuter(0);\n\n select(ref.current).call(axis);\n }, [innerWidth, y2Scale]);\n return (\n <g transform={`translate(${innerWidth},0)`}>\n <StyledAxis ref={ref} color={y2Axis.color}>\n <text\n className=\"axis-label\"\n textAnchor=\"middle\"\n transform={`translate(${-yAxisLabelOffset},${innerHeight / 2}) rotate(-90)`}\n >\n {/* {y2Axis?.label} */}\n </text>\n </StyledAxis>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,WAAW,cAAc;AACrD,SAAS,QAAQ,iBAAiB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAEtB,MAAM,YAAY,MAAM;AAC7B,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,mBAAmB,IAAI,YAAY;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,MAAI,CAAC;AAAQ,WAAO;AACpB,QAAM,MAAM,OAAO;AACnB,YAAU,MAAM;AACd,UAAM,OAAO,UAAU,OAAO,EAAE,cAAc,CAAC;AAE/C,WAAO,IAAI,OAAO,EAAE,KAAK,IAAI;AAAA,EAC/B,GAAG,CAAC,YAAY,OAAO,CAAC;AACxB,SACE,oBAAC;AAAA,IAAE,WAAW,aAAa;AAAA,IACzB,8BAAC;AAAA,MAAW;AAAA,MAAU,OAAO,OAAO;AAAA,MAClC,8BAAC;AAAA,QACC,WAAU;AAAA,QACV,YAAW;AAAA,QACX,WAAW,aAAa,CAAC,oBAAoB,cAAc;AAAA,OAG7D;AAAA,KACF;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -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,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,OA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