@elliemae/ds-dataviz 3.13.0-next.3 → 3.13.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/ChartContext.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useChart.js +55 -10
- package/dist/cjs/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js +48 -19
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +3 -3
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +89 -7
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +25 -12
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useValidateProps.js +37 -0
- package/dist/cjs/graphs/Chart/config/useValidateProps.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +28 -10
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +5 -5
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +43 -43
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +12 -8
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +4 -10
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +5 -9
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +21 -18
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js +42 -19
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +28 -18
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js +14 -1
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Point.js +1 -2
- package/dist/cjs/graphs/Chart/series/Point.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js.map +1 -1
- package/dist/cjs/graphs/Chart/series/StackedBar.js +1 -1
- package/dist/cjs/graphs/Chart/series/StackedBar.js.map +1 -1
- package/dist/cjs/graphs/constants.js +7 -0
- package/dist/cjs/graphs/constants.js.map +2 -2
- package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChart.js +55 -10
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useInternalMargins.js +49 -20
- package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +90 -8
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useScales.js +25 -12
- package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useValidateProps.js +11 -0
- package/dist/esm/graphs/Chart/config/useValidateProps.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +28 -10
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +5 -5
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +44 -44
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +13 -9
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +4 -10
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +6 -10
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +23 -20
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js +44 -21
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +29 -19
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/esm/graphs/Chart/react-desc-prop-types.js +14 -1
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Point.js +1 -2
- package/dist/esm/graphs/Chart/series/Point.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js.map +1 -1
- package/dist/esm/graphs/Chart/series/StackedBar.js +1 -1
- package/dist/esm/graphs/Chart/series/StackedBar.js.map +1 -1
- package/dist/esm/graphs/constants.js +7 -0
- package/dist/esm/graphs/constants.js.map +2 -2
- package/package.json +4 -4
|
@@ -46,10 +46,11 @@ const LegendItem = ({ domainValue }) => {
|
|
|
46
46
|
colorScale,
|
|
47
47
|
setHiddenSeries,
|
|
48
48
|
hiddenSeries,
|
|
49
|
-
|
|
49
|
+
originalSeries: series,
|
|
50
|
+
props: { types }
|
|
50
51
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
51
52
|
const serieData = series.find((serie) => serie.name === domainValue);
|
|
52
|
-
const LegendIcon = LegendItemsMap[serieData
|
|
53
|
+
const LegendIcon = LegendItemsMap[serieData?.pointStyle] ?? (serieData?.type === "line" || types === "scatter" ? LegendItemCircle : LegendItemSquare);
|
|
53
54
|
const handleOnClick = (0, import_react.useCallback)(() => {
|
|
54
55
|
setHiddenSeries((prev) => {
|
|
55
56
|
if (prev.includes(domainValue))
|
|
@@ -68,19 +69,12 @@ const LegendItem = ({ domainValue }) => {
|
|
|
68
69
|
style: hiddenSeries.includes(domainValue) ? { opacity: 0.2, cursor: "pointer" } : { cursor: "pointer" },
|
|
69
70
|
children: [
|
|
70
71
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LegendIcon, { fill: colorScale(domainValue) }),
|
|
71
|
-
serieData.type === "line" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
|
-
LegendItemLine,
|
|
73
|
-
{
|
|
74
|
-
stroke: colorScale(domainValue),
|
|
75
|
-
strokeDasharray: import_constants.LINE.DASH_STYLE_VALUES[serieData.dashStyle]
|
|
76
|
-
}
|
|
77
|
-
) : null,
|
|
78
72
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: 24, dy: ".32em", fontWeight: "600", children: domainValue })
|
|
79
73
|
]
|
|
80
74
|
},
|
|
81
75
|
domainValue
|
|
82
76
|
),
|
|
83
|
-
[LegendIcon, colorScale, domainValue, handleOnClick, hiddenSeries
|
|
77
|
+
[LegendIcon, colorScale, domainValue, handleOnClick, hiddenSeries]
|
|
84
78
|
);
|
|
85
79
|
};
|
|
86
80
|
//# sourceMappingURL=LegendItem.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/graphs/Chart/parts/Legend/LegendItem.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo, useCallback } from 'react';\nimport { LINE } from '../../../constants';\nimport { ChartContext } from '../../ChartContext';\n\nconst LegendItemLine = (props) => <line x1={-18} x2={18} y1={0} y2={0} {...props} strokeWidth={2} />;\nconst LegendItemCircle = (props) => <circle r={6} {...props} />;\nconst LegendItemSquare = (props) => <rect x={-6} y={-6} width={12} height={12} {...props} />;\nconst LegendItemDiamond = (props) => (\n <g transform=\"rotate(45)\">\n <rect x={-6} y={-6} width={12} height={12} {...props} />\n </g>\n);\n\nconst LegendItemsMap = {\n [LINE.POINT_STYLE.CIRCLE]: LegendItemCircle,\n [LINE.POINT_STYLE.SQUARE]: LegendItemSquare,\n [LINE.POINT_STYLE.DIAMOND]: LegendItemDiamond,\n};\n\nexport const LegendItem = ({ domainValue }) => {\n const {\n colorScale,\n setHiddenSeries,\n hiddenSeries,\n props: {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIW;AAJlC,mBAAwD;AACxD,uBAAqB;AACrB,0BAA6B;AAE7B,MAAM,iBAAiB,CAAC,UAAU,4CAAC,UAAK,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,IAAI,GAAI,GAAG,OAAO,aAAa,GAAG;AAClG,MAAM,mBAAmB,CAAC,UAAU,4CAAC,YAAO,GAAG,GAAI,GAAG,OAAO;AAC7D,MAAM,mBAAmB,CAAC,UAAU,4CAAC,UAAK,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAK,GAAG,OAAO;AAC1F,MAAM,oBAAoB,CAAC,UACzB,4CAAC,OAAE,WAAU,cACX,sDAAC,UAAK,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAK,GAAG,OAAO,GACxD;AAGF,MAAM,iBAAiB;AAAA,EACrB,CAAC,sBAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,sBAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,sBAAK,YAAY,UAAU;AAC9B;AAEO,MAAM,aAAa,CAAC,EAAE,YAAY,MAAM;AAC7C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo, useCallback } from 'react';\nimport { LINE } from '../../../constants';\nimport { ChartContext } from '../../ChartContext';\n\nconst LegendItemLine = (props) => <line x1={-18} x2={18} y1={0} y2={0} {...props} strokeWidth={2} />;\nconst LegendItemCircle = (props) => <circle r={6} {...props} />;\nconst LegendItemSquare = (props) => <rect x={-6} y={-6} width={12} height={12} {...props} />;\nconst LegendItemDiamond = (props) => (\n <g transform=\"rotate(45)\">\n <rect x={-6} y={-6} width={12} height={12} {...props} />\n </g>\n);\n\nconst LegendItemsMap = {\n [LINE.POINT_STYLE.CIRCLE]: LegendItemCircle,\n [LINE.POINT_STYLE.SQUARE]: LegendItemSquare,\n [LINE.POINT_STYLE.DIAMOND]: LegendItemDiamond,\n};\n\nexport const LegendItem = ({ domainValue }) => {\n const {\n colorScale,\n setHiddenSeries,\n hiddenSeries,\n originalSeries: series,\n props: { types },\n } = useContext(ChartContext);\n\n const serieData = series.find((serie) => serie.name === domainValue);\n const LegendIcon =\n LegendItemsMap[serieData?.pointStyle] ??\n (serieData?.type === 'line' || types === 'scatter' ? LegendItemCircle : LegendItemSquare);\n\n const handleOnClick = useCallback(() => {\n setHiddenSeries((prev) => {\n if (prev.includes(domainValue)) return prev.filter((serie) => serie !== domainValue);\n if (prev.length + 1 !== series.length) return [...prev, domainValue];\n return prev;\n });\n }, [domainValue, series.length, setHiddenSeries]);\n\n return useMemo(\n () => (\n <g\n onClick={handleOnClick}\n key={domainValue}\n className=\"cell\"\n style={hiddenSeries.includes(domainValue) ? { opacity: 0.2, cursor: 'pointer' } : { cursor: 'pointer' }}\n >\n <LegendIcon fill={colorScale(domainValue)} />\n <text x={24} dy=\".32em\" fontWeight=\"600\">\n {domainValue}\n </text>\n </g>\n ),\n\n [LegendIcon, colorScale, domainValue, handleOnClick, hiddenSeries],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIW;AAJlC,mBAAwD;AACxD,uBAAqB;AACrB,0BAA6B;AAE7B,MAAM,iBAAiB,CAAC,UAAU,4CAAC,UAAK,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,IAAI,GAAI,GAAG,OAAO,aAAa,GAAG;AAClG,MAAM,mBAAmB,CAAC,UAAU,4CAAC,YAAO,GAAG,GAAI,GAAG,OAAO;AAC7D,MAAM,mBAAmB,CAAC,UAAU,4CAAC,UAAK,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAK,GAAG,OAAO;AAC1F,MAAM,oBAAoB,CAAC,UACzB,4CAAC,OAAE,WAAU,cACX,sDAAC,UAAK,GAAG,IAAI,GAAG,IAAI,OAAO,IAAI,QAAQ,IAAK,GAAG,OAAO,GACxD;AAGF,MAAM,iBAAiB;AAAA,EACrB,CAAC,sBAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,sBAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,sBAAK,YAAY,UAAU;AAC9B;AAEO,MAAM,aAAa,CAAC,EAAE,YAAY,MAAM;AAC7C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,OAAO,EAAE,MAAM;AAAA,EACjB,QAAI,yBAAW,gCAAY;AAE3B,QAAM,YAAY,OAAO,KAAK,CAAC,UAAU,MAAM,SAAS,WAAW;AACnE,QAAM,aACJ,eAAe,WAAW,gBACzB,WAAW,SAAS,UAAU,UAAU,YAAY,mBAAmB;AAE1E,QAAM,oBAAgB,0BAAY,MAAM;AACtC,oBAAgB,CAAC,SAAS;AACxB,UAAI,KAAK,SAAS,WAAW;AAAG,eAAO,KAAK,OAAO,CAAC,UAAU,UAAU,WAAW;AACnF,UAAI,KAAK,SAAS,MAAM,OAAO;AAAQ,eAAO,CAAC,GAAG,MAAM,WAAW;AACnE,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,aAAa,OAAO,QAAQ,eAAe,CAAC;AAEhD,aAAO;AAAA,IACL,MACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QAET,WAAU;AAAA,QACV,OAAO,aAAa,SAAS,WAAW,IAAI,EAAE,SAAS,KAAK,QAAQ,UAAU,IAAI,EAAE,QAAQ,UAAU;AAAA,QAEtG;AAAA,sDAAC,cAAW,MAAM,WAAW,WAAW,GAAG;AAAA,UAC3C,4CAAC,UAAK,GAAG,IAAI,IAAG,SAAQ,YAAW,OAChC,uBACH;AAAA;AAAA;AAAA,MAPK;AAAA,IAQP;AAAA,IAGF,CAAC,YAAY,YAAY,aAAa,eAAe,YAAY;AAAA,EACnE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,23 +34,19 @@ var import_ChartContext = require("../../ChartContext");
|
|
|
34
34
|
var import_LegendItem = require("./LegendItem");
|
|
35
35
|
const RightLegend = () => {
|
|
36
36
|
const {
|
|
37
|
-
colorScale,
|
|
38
37
|
innerWidth,
|
|
39
38
|
innerHeight,
|
|
40
39
|
rightLabelWidth,
|
|
41
|
-
rightLegend,
|
|
42
40
|
axisRightWidth,
|
|
43
41
|
internalMargin,
|
|
42
|
+
rightLegendHeight,
|
|
44
43
|
setRightLegend,
|
|
45
|
-
|
|
44
|
+
originalSeries: series
|
|
46
45
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
47
46
|
const [yTransform, setYTransform] = (0, import_react.useState)(innerHeight / 2 + internalMargin.top);
|
|
48
|
-
(0, import_react.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setYTransform((prev) => prev - bounds.height / 2);
|
|
52
|
-
}
|
|
53
|
-
}, [rightLegend]);
|
|
47
|
+
(0, import_react.useEffect)(() => {
|
|
48
|
+
setYTransform(innerHeight / 2 + internalMargin.top - rightLegendHeight / 2);
|
|
49
|
+
}, [innerHeight, internalMargin.top, rightLegendHeight]);
|
|
54
50
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
55
51
|
"g",
|
|
56
52
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/graphs/Chart/parts/Legend/RightLegend.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useState,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useState, useEffect } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { LegendItem } from './LegendItem';\n\nexport const RightLegend = () => {\n const {\n innerWidth,\n innerHeight,\n rightLabelWidth,\n axisRightWidth,\n internalMargin,\n rightLegendHeight,\n setRightLegend,\n originalSeries: series,\n } = useContext(ChartContext);\n\n const [yTransform, setYTransform] = useState(innerHeight / 2 + internalMargin.top);\n\n useEffect(() => {\n setYTransform(innerHeight / 2 + internalMargin.top - rightLegendHeight / 2);\n }, [innerHeight, internalMargin.top, rightLegendHeight]);\n\n return (\n <g\n ref={setRightLegend}\n transform={`translate(${innerWidth + internalMargin.left + axisRightWidth + rightLabelWidth},${yTransform})`}\n >\n <rect width=\"20\" height={1} fill=\"transparent\" />\n <g transform={`translate(0,0)`}>\n {series.map((serie, i) => (\n <g className=\"tick\" transform={`translate(30,${i * 30})`} key={serie.name}>\n <LegendItem domainValue={serie.name} />\n </g>\n ))}\n </g>\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuBnB;AAvBJ,mBAAuD;AACvD,0BAA6B;AAC7B,wBAA2B;AAEpB,MAAM,cAAc,MAAM;AAC/B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,EAClB,QAAI,yBAAW,gCAAY;AAE3B,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,cAAc,IAAI,eAAe,GAAG;AAEjF,8BAAU,MAAM;AACd,kBAAc,cAAc,IAAI,eAAe,MAAM,oBAAoB,CAAC;AAAA,EAC5E,GAAG,CAAC,aAAa,eAAe,KAAK,iBAAiB,CAAC;AAEvD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,WAAW,aAAa,aAAa,eAAe,OAAO,iBAAiB,mBAAmB;AAAA,MAE/F;AAAA,oDAAC,UAAK,OAAM,MAAK,QAAQ,GAAG,MAAK,eAAc;AAAA,QAC/C,4CAAC,OAAE,WAAW,kBACX,iBAAO,IAAI,CAAC,OAAO,MAClB,4CAAC,OAAE,WAAU,QAAO,WAAW,gBAAgB,IAAI,OACjD,sDAAC,gCAAW,aAAa,MAAM,MAAM,KADwB,MAAM,IAErE,CACD,GACH;AAAA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,42 +34,45 @@ var import_d3 = require("d3");
|
|
|
34
34
|
var import_ChartContext = require("../../ChartContext");
|
|
35
35
|
var import_LegendItem = require("./LegendItem");
|
|
36
36
|
const TopLegend = () => {
|
|
37
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
colorScale,
|
|
39
|
+
currentData,
|
|
40
|
+
topLegendHeight,
|
|
41
|
+
internalMargin,
|
|
42
|
+
innerWidth,
|
|
43
|
+
setTopLegend,
|
|
44
|
+
width: graphWidth
|
|
45
|
+
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
38
46
|
const ref = (0, import_react.useRef)(null);
|
|
39
|
-
const firstRender = (0, import_react.useRef)(true);
|
|
40
47
|
const [xTransform, setXTransform] = (0, import_react.useState)(innerWidth / 2 + internalMargin.left);
|
|
41
|
-
(0, import_react.
|
|
42
|
-
if (ref.current
|
|
48
|
+
(0, import_react.useEffect)(() => {
|
|
49
|
+
if (ref.current) {
|
|
43
50
|
const cells = (0, import_d3.select)(ref.current).selectAll(".cell");
|
|
44
51
|
const padding = 30;
|
|
45
52
|
let offset = 0;
|
|
46
53
|
let verticalOffset = 0;
|
|
47
|
-
|
|
54
|
+
currentData.forEach((_, i) => {
|
|
48
55
|
if (cells._groups[0][i - 1]) {
|
|
49
56
|
const lastCell = (0, import_d3.select)(cells._groups[0][i - 1]);
|
|
50
57
|
const d3sel = (0, import_d3.select)(cells._groups[0][i]);
|
|
51
|
-
const { width } =
|
|
52
|
-
|
|
58
|
+
const { width: currentCellWidth } = d3sel.node().getBBox();
|
|
59
|
+
const { width: lastCellWidth } = lastCell.node().getBBox();
|
|
60
|
+
if (offset + lastCellWidth + padding + currentCellWidth + 10 > graphWidth) {
|
|
53
61
|
offset = 0;
|
|
54
62
|
verticalOffset += 20;
|
|
55
63
|
} else {
|
|
56
|
-
offset +=
|
|
64
|
+
offset += lastCellWidth + padding;
|
|
57
65
|
}
|
|
58
66
|
d3sel.attr("transform", `translate(${offset}, ${verticalOffset})`);
|
|
59
67
|
}
|
|
60
68
|
});
|
|
61
69
|
const bounds = ref.current.getBoundingClientRect();
|
|
62
|
-
setXTransform(
|
|
63
|
-
firstRender.current = false;
|
|
70
|
+
setXTransform(innerWidth / 2 + internalMargin.left - bounds.width / 2);
|
|
64
71
|
}
|
|
65
|
-
}, [innerWidth]);
|
|
66
|
-
|
|
67
|
-
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { ref, transform: `translate(${xTransform}
|
|
68
|
-
|
|
69
|
-
colorScale.domain().map((domainValue, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_LegendItem.LegendItem, { domainValue }, domainValue))
|
|
70
|
-
] }) }),
|
|
71
|
-
[colorScale, setTopLegend, xTransform, toolbarHeight]
|
|
72
|
+
}, [currentData, graphWidth, innerWidth, internalMargin.left]);
|
|
73
|
+
return (0, import_react.useMemo)(
|
|
74
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { ref, transform: `translate(${xTransform},10)`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { ref: setTopLegend, children: colorScale.domain().map((domainValue) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_LegendItem.LegendItem, { domainValue }, domainValue)) }) }),
|
|
75
|
+
[xTransform, setTopLegend, colorScale]
|
|
72
76
|
);
|
|
73
|
-
return render;
|
|
74
77
|
};
|
|
75
78
|
//# sourceMappingURL=TopLegend.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/graphs/Chart/parts/Legend/TopLegend.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo, useEffect, useRef, useState } from 'react';\n\nimport { select } from 'd3';\nimport { ChartContext } from '../../ChartContext';\nimport { LegendItem } from './LegendItem';\n\nexport const TopLegend = () => {\n const {\n colorScale,\n currentData,\n topLegendHeight,\n internalMargin,\n innerWidth,\n setTopLegend,\n width: graphWidth,\n } = useContext(ChartContext);\n\n const ref = useRef<SVGGElement>(null);\n\n const [xTransform, setXTransform] = useState(innerWidth / 2 + internalMargin.left);\n\n useEffect(() => {\n if (ref.current) {\n const cells = select(ref.current).selectAll('.cell');\n const padding = 30;\n let offset = 0;\n let verticalOffset = 0;\n\n currentData.forEach((_, i) => {\n if (cells._groups[0][i - 1]) {\n const lastCell = select(cells._groups[0][i - 1]);\n const d3sel = select(cells._groups[0][i]);\n const { width: currentCellWidth } = d3sel.node().getBBox();\n\n const { width: lastCellWidth } = lastCell.node().getBBox();\n\n if (offset + lastCellWidth + padding + currentCellWidth + 10 > graphWidth) {\n offset = 0;\n verticalOffset += 20;\n } else {\n offset += lastCellWidth + padding;\n }\n\n d3sel.attr('transform', `translate(${offset}, ${verticalOffset})`);\n }\n });\n const bounds = ref.current.getBoundingClientRect();\n setXTransform(innerWidth / 2 + internalMargin.left - bounds.width / 2);\n }\n }, [currentData, graphWidth, innerWidth, internalMargin.left]);\n return useMemo(\n () => (\n <g ref={ref} transform={`translate(${xTransform},10)`}>\n <g ref={setTopLegend}>\n {colorScale.domain().map((domainValue) => (\n <LegendItem key={domainValue} domainValue={domainValue} />\n ))}\n </g>\n </g>\n ),\n\n [xTransform, setTopLegend, colorScale],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuDX;AAvDZ,mBAAwE;AAExE,gBAAuB;AACvB,0BAA6B;AAC7B,wBAA2B;AAEpB,MAAM,YAAY,MAAM;AAC7B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,QAAI,yBAAW,gCAAY;AAE3B,QAAM,UAAM,qBAAoB,IAAI;AAEpC,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,aAAa,IAAI,eAAe,IAAI;AAEjF,8BAAU,MAAM;AACd,QAAI,IAAI,SAAS;AACf,YAAM,YAAQ,kBAAO,IAAI,OAAO,EAAE,UAAU,OAAO;AACnD,YAAM,UAAU;AAChB,UAAI,SAAS;AACb,UAAI,iBAAiB;AAErB,kBAAY,QAAQ,CAAC,GAAG,MAAM;AAC5B,YAAI,MAAM,QAAQ,GAAG,IAAI,IAAI;AAC3B,gBAAM,eAAW,kBAAO,MAAM,QAAQ,GAAG,IAAI,EAAE;AAC/C,gBAAM,YAAQ,kBAAO,MAAM,QAAQ,GAAG,EAAE;AACxC,gBAAM,EAAE,OAAO,iBAAiB,IAAI,MAAM,KAAK,EAAE,QAAQ;AAEzD,gBAAM,EAAE,OAAO,cAAc,IAAI,SAAS,KAAK,EAAE,QAAQ;AAEzD,cAAI,SAAS,gBAAgB,UAAU,mBAAmB,KAAK,YAAY;AACzE,qBAAS;AACT,8BAAkB;AAAA,UACpB,OAAO;AACL,sBAAU,gBAAgB;AAAA,UAC5B;AAEA,gBAAM,KAAK,aAAa,aAAa,WAAW,iBAAiB;AAAA,QACnE;AAAA,MACF,CAAC;AACD,YAAM,SAAS,IAAI,QAAQ,sBAAsB;AACjD,oBAAc,aAAa,IAAI,eAAe,OAAO,OAAO,QAAQ,CAAC;AAAA,IACvE;AAAA,EACF,GAAG,CAAC,aAAa,YAAY,YAAY,eAAe,IAAI,CAAC;AAC7D,aAAO;AAAA,IACL,MACE,4CAAC,OAAE,KAAU,WAAW,aAAa,kBACnC,sDAAC,OAAE,KAAK,cACL,qBAAW,OAAO,EAAE,IAAI,CAAC,gBACxB,4CAAC,gCAA6B,eAAb,WAAuC,CACzD,GACH,GACF;AAAA,IAGF,CAAC,YAAY,cAAc,UAAU;AAAA,EACvC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,51 +30,74 @@ module.exports = __toCommonJS(Controllers_exports);
|
|
|
30
30
|
var React = __toESM(require("react"));
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
32
|
var import_react = require("react");
|
|
33
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
33
34
|
var import_ChartContext = require("../../ChartContext");
|
|
35
|
+
var import_constants = require("../../../constants");
|
|
36
|
+
const StyledResetter = (0, import_ds_system.styled)("g")`
|
|
37
|
+
cursor: ${({ isDisabled }) => isDisabled ? "not-allowed" : "pointer"};
|
|
38
|
+
opacity: ${({ isDisabled }) => isDisabled ? "0.4" : "1"};
|
|
39
|
+
&focus {
|
|
40
|
+
outline: 2px solid blue;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
34
43
|
const Controllers = () => {
|
|
35
44
|
const {
|
|
36
45
|
props: { xScroll },
|
|
37
46
|
width,
|
|
47
|
+
internalMargin,
|
|
38
48
|
xScale,
|
|
39
49
|
yScale,
|
|
50
|
+
containerRef,
|
|
40
51
|
containerRatio,
|
|
41
52
|
setContainerRatio,
|
|
42
53
|
lastPosition,
|
|
43
54
|
setToolbarRef,
|
|
44
55
|
setXScrollbarPosition
|
|
45
56
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
57
|
+
const isDisabled = (0, import_react.useMemo)(() => containerRatio === 1, [containerRatio]);
|
|
46
58
|
const handleOnClick = (0, import_react.useCallback)(() => {
|
|
47
59
|
setContainerRatio(1);
|
|
48
60
|
setXScrollbarPosition(0);
|
|
49
61
|
lastPosition.current = 0;
|
|
50
62
|
}, [lastPosition, setContainerRatio, setXScrollbarPosition]);
|
|
63
|
+
const handleOnKeyDown = (0, import_react.useCallback)(
|
|
64
|
+
(e) => {
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
if (e.code === "Space") {
|
|
67
|
+
setContainerRatio(1);
|
|
68
|
+
setXScrollbarPosition(0);
|
|
69
|
+
lastPosition.current = 0;
|
|
70
|
+
containerRef.focus();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
[containerRef, lastPosition, setContainerRatio, setXScrollbarPosition]
|
|
74
|
+
);
|
|
51
75
|
if (xScale.bandwidth || yScale.bandwidth)
|
|
52
76
|
return null;
|
|
53
77
|
if (!xScroll)
|
|
54
78
|
return null;
|
|
55
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
56
|
-
|
|
79
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
80
|
+
StyledResetter,
|
|
57
81
|
{
|
|
58
82
|
onClick: handleOnClick,
|
|
59
|
-
|
|
83
|
+
onKeyDown: handleOnKeyDown,
|
|
84
|
+
onBlur: (e) => e.stopPropagation(),
|
|
85
|
+
transform: `translate(${width - import_constants.TOOLBAR.RESET.WIDTH * 2},${internalMargin.top / 2 - import_constants.TOOLBAR.RESET.HEIGHT / 2})`,
|
|
60
86
|
strokeLinecap: "round",
|
|
61
|
-
|
|
62
|
-
strokeOpacity: "1",
|
|
63
|
-
style: { cursor: "pointer", opacity: containerRatio > 1 ? 1 : 0.5 },
|
|
87
|
+
isDisabled,
|
|
64
88
|
ref: setToolbarRef,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
]
|
|
89
|
+
role: "button",
|
|
90
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
91
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
"path",
|
|
93
|
+
{
|
|
94
|
+
d: "M 2.875 7.75 A 5.625 5.625 0 1 1 4.5225 11.7275 L 8.2725 10.7275 L 6.5225 14.9775 L 4.5225 11.7275\n M 0 0 H 17 V 17 H 0 V 0 ",
|
|
95
|
+
fill: "#ffffff",
|
|
96
|
+
stroke: "#000000",
|
|
97
|
+
strokeLinecap: "round",
|
|
98
|
+
strokeWidth: "1"
|
|
99
|
+
}
|
|
100
|
+
)
|
|
78
101
|
}
|
|
79
102
|
);
|
|
80
103
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/graphs/Chart/parts/Scroller/Controllers.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useCallback } from 'react';\nimport { ChartContext } from '../../ChartContext';\n\nexport const Controllers = () => {\n const {\n props: { xScroll },\n width,\n xScale,\n yScale,\n containerRatio,\n setContainerRatio,\n lastPosition,\n setToolbarRef,\n setXScrollbarPosition,\n } = useContext(ChartContext);\n\n const handleOnClick = useCallback(() => {\n setContainerRatio(1);\n setXScrollbarPosition(0);\n lastPosition.current = 0;\n }, [lastPosition, setContainerRatio, setXScrollbarPosition]);\n\n // if is a bar chart we dont give controls\n if (xScale.bandwidth || yScale.bandwidth) return null;\n\n if (!xScroll) return null;\n return (\n <
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useCallback, useMemo } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { ChartContext } from '../../ChartContext';\nimport { TOOLBAR } from '../../../constants';\n\nconst StyledResetter = styled('g')<{ isDisabled: 'boolean' }>`\n cursor: ${({ isDisabled }) => (isDisabled ? 'not-allowed' : 'pointer')};\n opacity: ${({ isDisabled }) => (isDisabled ? '0.4' : '1')};\n &focus {\n outline: 2px solid blue;\n }\n`;\nexport const Controllers = () => {\n const {\n props: { xScroll },\n width,\n internalMargin,\n xScale,\n yScale,\n containerRef,\n containerRatio,\n setContainerRatio,\n lastPosition,\n setToolbarRef,\n setXScrollbarPosition,\n } = useContext(ChartContext);\n\n const isDisabled = useMemo(() => containerRatio === 1, [containerRatio]);\n const handleOnClick = useCallback(() => {\n setContainerRatio(1);\n setXScrollbarPosition(0);\n lastPosition.current = 0;\n }, [lastPosition, setContainerRatio, setXScrollbarPosition]);\n\n const handleOnKeyDown: React.KeyboardEventHandler = useCallback(\n (e) => {\n e.stopPropagation();\n if (e.code === 'Space') {\n setContainerRatio(1);\n setXScrollbarPosition(0);\n lastPosition.current = 0;\n containerRef.focus();\n }\n },\n [containerRef, lastPosition, setContainerRatio, setXScrollbarPosition],\n );\n // if is a bar chart we dont give controls\n if (xScale.bandwidth || yScale.bandwidth) return null;\n\n if (!xScroll) return null;\n return (\n <StyledResetter\n onClick={handleOnClick}\n onKeyDown={handleOnKeyDown}\n onBlur={(e) => e.stopPropagation()}\n transform={`translate(${width - TOOLBAR.RESET.WIDTH * 2},${internalMargin.top / 2 - TOOLBAR.RESET.HEIGHT / 2})`}\n strokeLinecap=\"round\"\n isDisabled={isDisabled}\n ref={setToolbarRef}\n role=\"button\"\n tabIndex={isDisabled ? -1 : 0}\n >\n <path\n d=\"M 2.875 7.75 A 5.625 5.625 0 1 1 4.5225 11.7275 L 8.2725 10.7275 L 6.5225 14.9775 L 4.5225 11.7275\n M 0 0 H 17 V 17 H 0 V 0 \"\n fill=\"#ffffff\"\n stroke=\"#000000\"\n strokeLinecap=\"round\"\n strokeWidth=\"1\"\n ></path>\n </StyledResetter>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADgEjB;AA9DN,mBAAwD;AACxD,uBAAuB;AACvB,0BAA6B;AAC7B,uBAAwB;AAExB,MAAM,qBAAiB,yBAAO,GAAG;AAAA,YACrB,CAAC,EAAE,WAAW,MAAO,aAAa,gBAAgB;AAAA,aACjD,CAAC,EAAE,WAAW,MAAO,aAAa,QAAQ;AAAA;AAAA;AAAA;AAAA;AAKhD,MAAM,cAAc,MAAM;AAC/B,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAE3B,QAAM,iBAAa,sBAAQ,MAAM,mBAAmB,GAAG,CAAC,cAAc,CAAC;AACvE,QAAM,oBAAgB,0BAAY,MAAM;AACtC,sBAAkB,CAAC;AACnB,0BAAsB,CAAC;AACvB,iBAAa,UAAU;AAAA,EACzB,GAAG,CAAC,cAAc,mBAAmB,qBAAqB,CAAC;AAE3D,QAAM,sBAA8C;AAAA,IAClD,CAAC,MAAM;AACL,QAAE,gBAAgB;AAClB,UAAI,EAAE,SAAS,SAAS;AACtB,0BAAkB,CAAC;AACnB,8BAAsB,CAAC;AACvB,qBAAa,UAAU;AACvB,qBAAa,MAAM;AAAA,MACrB;AAAA,IACF;AAAA,IACA,CAAC,cAAc,cAAc,mBAAmB,qBAAqB;AAAA,EACvE;AAEA,MAAI,OAAO,aAAa,OAAO;AAAW,WAAO;AAEjD,MAAI,CAAC;AAAS,WAAO;AACrB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,WAAW;AAAA,MACX,QAAQ,CAAC,MAAM,EAAE,gBAAgB;AAAA,MACjC,WAAW,aAAa,QAAQ,yBAAQ,MAAM,QAAQ,KAAK,eAAe,MAAM,IAAI,yBAAQ,MAAM,SAAS;AAAA,MAC3G,eAAc;AAAA,MACd;AAAA,MACA,KAAK;AAAA,MACL,MAAK;AAAA,MACL,UAAU,aAAa,KAAK;AAAA,MAE5B;AAAA,QAAC;AAAA;AAAA,UACC,GAAE;AAAA,UAEF,MAAK;AAAA,UACL,QAAO;AAAA,UACP,eAAc;AAAA,UACd,aAAY;AAAA;AAAA,MACb;AAAA;AAAA,EACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -44,13 +44,24 @@ const ScrollableContainerX = () => {
|
|
|
44
44
|
containerRatio,
|
|
45
45
|
innerWidth,
|
|
46
46
|
isGrabbed,
|
|
47
|
+
containerRef,
|
|
47
48
|
setXScrollbarPosition,
|
|
48
49
|
setContainerRatio,
|
|
49
50
|
lastPosition,
|
|
50
51
|
innerHeight,
|
|
51
52
|
internalMargin,
|
|
52
|
-
chartId
|
|
53
|
+
chartId,
|
|
54
|
+
isZooming,
|
|
55
|
+
setIsZooming,
|
|
56
|
+
zoomStartingPosition,
|
|
57
|
+
setZoomStartingPosition,
|
|
58
|
+
movingPosition,
|
|
59
|
+
setMovingPosition
|
|
53
60
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
61
|
+
const getRealClientX = (0, import_react.useCallback)(
|
|
62
|
+
(clientX) => clientX - internalMargin.left - containerRef.getBoundingClientRect().left,
|
|
63
|
+
[internalMargin.left]
|
|
64
|
+
);
|
|
54
65
|
const Scrappers = (0, import_react.useMemo)(() => {
|
|
55
66
|
if (scrapper?.type === "horizontal")
|
|
56
67
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Scrapper.Scrapper, {});
|
|
@@ -58,14 +69,11 @@ const ScrollableContainerX = () => {
|
|
|
58
69
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_VerticalScrapper.VerticalScrapper, {});
|
|
59
70
|
return null;
|
|
60
71
|
}, [scrapper?.type]);
|
|
61
|
-
const [isZooming, setIsZooming] = (0, import_react.useState)(false);
|
|
62
|
-
const [startingPosition, setStartingPosition] = (0, import_react.useState)(0);
|
|
63
|
-
const [movingPosition, setMovingPosition] = (0, import_react.useState)(0);
|
|
64
72
|
const handleOnMouseDown = (0, import_react.useCallback)(
|
|
65
|
-
(
|
|
73
|
+
({ clientX }) => {
|
|
66
74
|
if (!isGrabbed && !xScale.bandwidth) {
|
|
67
75
|
setIsZooming(true);
|
|
68
|
-
|
|
76
|
+
setZoomStartingPosition(getRealClientX(clientX));
|
|
69
77
|
setMovingPosition(0);
|
|
70
78
|
}
|
|
71
79
|
},
|
|
@@ -74,22 +82,22 @@ const ScrollableContainerX = () => {
|
|
|
74
82
|
const handleOnMouseMove = (0, import_react.useCallback)(
|
|
75
83
|
({ clientX }) => {
|
|
76
84
|
if (isZooming)
|
|
77
|
-
setMovingPosition(clientX);
|
|
85
|
+
setMovingPosition(getRealClientX(clientX));
|
|
78
86
|
},
|
|
79
87
|
[isZooming]
|
|
80
88
|
);
|
|
81
89
|
const handleOnMouseUp = (0, import_react.useCallback)(
|
|
82
90
|
(e) => {
|
|
83
|
-
const bounds = e.currentTarget.closest("div").getBoundingClientRect();
|
|
84
91
|
if (!isZooming)
|
|
85
92
|
return;
|
|
86
93
|
setIsZooming(false);
|
|
87
|
-
|
|
88
|
-
const
|
|
94
|
+
setMovingPosition(0);
|
|
95
|
+
const endingPosition = getRealClientX(e.clientX);
|
|
96
|
+
const diff = Math.abs(zoomStartingPosition - endingPosition);
|
|
89
97
|
if (diff <= 0)
|
|
90
98
|
return;
|
|
91
99
|
const newRatio = innerWidth / (innerWidth * containerRatio / diff) < 40 ? innerWidth / 40 : innerWidth * containerRatio / diff;
|
|
92
|
-
const newPosition = lastPosition?.current + (
|
|
100
|
+
const newPosition = lastPosition?.current + (zoomStartingPosition > endingPosition ? endingPosition : zoomStartingPosition) / containerRatio;
|
|
93
101
|
if (newPosition > innerWidth - innerWidth / newRatio)
|
|
94
102
|
setXScrollbarPosition(innerWidth - innerWidth / newRatio);
|
|
95
103
|
else
|
|
@@ -99,14 +107,16 @@ const ScrollableContainerX = () => {
|
|
|
99
107
|
e.stopPropagation();
|
|
100
108
|
},
|
|
101
109
|
[
|
|
102
|
-
containerRatio,
|
|
103
|
-
innerWidth,
|
|
104
110
|
isZooming,
|
|
105
|
-
|
|
111
|
+
setIsZooming,
|
|
112
|
+
setMovingPosition,
|
|
113
|
+
getRealClientX,
|
|
114
|
+
zoomStartingPosition,
|
|
115
|
+
innerWidth,
|
|
116
|
+
containerRatio,
|
|
106
117
|
lastPosition,
|
|
107
|
-
setContainerRatio,
|
|
108
118
|
setXScrollbarPosition,
|
|
109
|
-
|
|
119
|
+
setContainerRatio
|
|
110
120
|
]
|
|
111
121
|
);
|
|
112
122
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -126,8 +136,8 @@ const ScrollableContainerX = () => {
|
|
|
126
136
|
isZooming && movingPosition !== 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
137
|
"rect",
|
|
128
138
|
{
|
|
129
|
-
x:
|
|
130
|
-
width: Math.abs(movingPosition -
|
|
139
|
+
x: movingPosition < zoomStartingPosition ? movingPosition : zoomStartingPosition,
|
|
140
|
+
width: Math.abs(movingPosition - zoomStartingPosition),
|
|
131
141
|
height: innerHeight,
|
|
132
142
|
fill: "orange",
|
|
133
143
|
style: { opacity: 0.2 }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/graphs/Chart/parts/Scroller/ScrollableContainerX.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useCallback, useMemo } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { AxisBottom } from '../Axis/AxisBottom';\nimport { SeriesFactory } from '../SeriesFactory';\nimport { ScrollBarX } from './ScrollBarX';\nimport { Scrapper } from '../Scrapper/Scrapper';\nimport { VerticalScrapper } from '../Scrapper/VerticalScrapper';\nexport const ScrollableContainerX = () => {\n const {\n props: { scrapper },\n xScrollbarPosition,\n xScale,\n containerRatio,\n innerWidth,\n isGrabbed,\n containerRef,\n setXScrollbarPosition,\n setContainerRatio,\n lastPosition,\n innerHeight,\n internalMargin,\n chartId,\n isZooming,\n setIsZooming,\n zoomStartingPosition,\n setZoomStartingPosition,\n movingPosition,\n setMovingPosition,\n } = useContext(ChartContext);\n\n const getRealClientX = useCallback(\n (clientX: number) => clientX - internalMargin.left - containerRef.getBoundingClientRect().left,\n [internalMargin.left],\n );\n\n const Scrappers = useMemo(() => {\n if (scrapper?.type === 'horizontal') return <Scrapper />;\n if (scrapper?.type === 'vertical') return <VerticalScrapper />;\n return null;\n }, [scrapper?.type]);\n\n //mouse\n const handleOnMouseDown: React.MouseEventHandler = useCallback(\n ({ clientX }) => {\n if (!isGrabbed && !xScale.bandwidth) {\n setIsZooming(true);\n setZoomStartingPosition(getRealClientX(clientX));\n setMovingPosition(0);\n }\n },\n [isGrabbed, xScale],\n );\n\n const handleOnMouseMove: React.MouseEventHandler = useCallback(\n ({ clientX }) => {\n if (isZooming) setMovingPosition(getRealClientX(clientX));\n },\n [isZooming],\n );\n const handleOnMouseUp: React.MouseEventHandler = useCallback(\n (e) => {\n if (!isZooming) return;\n setIsZooming(false);\n setMovingPosition(0);\n const endingPosition = getRealClientX(e.clientX);\n\n const diff = Math.abs(zoomStartingPosition - endingPosition);\n if (diff <= 0) return;\n const newRatio =\n innerWidth / ((innerWidth * containerRatio) / diff) < 40\n ? innerWidth / 40\n : (innerWidth * containerRatio) / diff;\n const newPosition =\n lastPosition?.current +\n (zoomStartingPosition > endingPosition ? endingPosition : zoomStartingPosition) / containerRatio;\n\n // if (newPosition < 0) setXScrollbarPosition(0);\n // if is bigger thant innerwidth possible we force the end\n if (newPosition > innerWidth - innerWidth / newRatio) setXScrollbarPosition(innerWidth - innerWidth / newRatio);\n else setXScrollbarPosition(newPosition);\n\n setContainerRatio(newRatio);\n lastPosition.current = newPosition;\n e.stopPropagation();\n },\n [\n isZooming,\n setIsZooming,\n setMovingPosition,\n getRealClientX,\n zoomStartingPosition,\n innerWidth,\n containerRatio,\n lastPosition,\n setXScrollbarPosition,\n setContainerRatio,\n ],\n );\n return (\n <g\n className=\"scrollable-container-x\"\n onMouseDown={handleOnMouseDown}\n onMouseMove={handleOnMouseMove}\n onMouseUp={handleOnMouseUp}\n >\n <g mask={`url(#mask-${chartId})`}>\n <g transform={`translate(${-xScrollbarPosition * containerRatio},0)`}>\n <AxisBottom />\n <SeriesFactory />\n {Scrappers}\n </g>\n {isZooming && movingPosition !== 0 ? (\n <rect\n x={movingPosition < zoomStartingPosition ? movingPosition : zoomStartingPosition}\n width={Math.abs(movingPosition - zoomStartingPosition)}\n height={innerHeight}\n fill=\"orange\"\n style={{ opacity: 0.2 }}\n />\n ) : null}\n </g>\n <ScrollBarX />\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADsCyB;AApChD,mBAAwD;AACxD,0BAA6B;AAC7B,wBAA2B;AAC3B,2BAA8B;AAC9B,wBAA2B;AAC3B,sBAAyB;AACzB,8BAAiC;AAC1B,MAAM,uBAAuB,MAAM;AACxC,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAE3B,QAAM,qBAAiB;AAAA,IACrB,CAAC,YAAoB,UAAU,eAAe,OAAO,aAAa,sBAAsB,EAAE;AAAA,IAC1F,CAAC,eAAe,IAAI;AAAA,EACtB;AAEA,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI,UAAU,SAAS;AAAc,aAAO,4CAAC,4BAAS;AACtD,QAAI,UAAU,SAAS;AAAY,aAAO,4CAAC,4CAAiB;AAC5D,WAAO;AAAA,EACT,GAAG,CAAC,UAAU,IAAI,CAAC;AAGnB,QAAM,wBAA6C;AAAA,IACjD,CAAC,EAAE,QAAQ,MAAM;AACf,UAAI,CAAC,aAAa,CAAC,OAAO,WAAW;AACnC,qBAAa,IAAI;AACjB,gCAAwB,eAAe,OAAO,CAAC;AAC/C,0BAAkB,CAAC;AAAA,MACrB;AAAA,IACF;AAAA,IACA,CAAC,WAAW,MAAM;AAAA,EACpB;AAEA,QAAM,wBAA6C;AAAA,IACjD,CAAC,EAAE,QAAQ,MAAM;AACf,UAAI;AAAW,0BAAkB,eAAe,OAAO,CAAC;AAAA,IAC1D;AAAA,IACA,CAAC,SAAS;AAAA,EACZ;AACA,QAAM,sBAA2C;AAAA,IAC/C,CAAC,MAAM;AACL,UAAI,CAAC;AAAW;AAChB,mBAAa,KAAK;AAClB,wBAAkB,CAAC;AACnB,YAAM,iBAAiB,eAAe,EAAE,OAAO;AAE/C,YAAM,OAAO,KAAK,IAAI,uBAAuB,cAAc;AAC3D,UAAI,QAAQ;AAAG;AACf,YAAM,WACJ,cAAe,aAAa,iBAAkB,QAAQ,KAClD,aAAa,KACZ,aAAa,iBAAkB;AACtC,YAAM,cACJ,cAAc,WACb,uBAAuB,iBAAiB,iBAAiB,wBAAwB;AAIpF,UAAI,cAAc,aAAa,aAAa;AAAU,8BAAsB,aAAa,aAAa,QAAQ;AAAA;AACzG,8BAAsB,WAAW;AAEtC,wBAAkB,QAAQ;AAC1B,mBAAa,UAAU;AACvB,QAAE,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,aAAa;AAAA,MACb,aAAa;AAAA,MACb,WAAW;AAAA,MAEX;AAAA,qDAAC,OAAE,MAAM,aAAa,YACpB;AAAA,uDAAC,OAAE,WAAW,aAAa,CAAC,qBAAqB,qBAC/C;AAAA,wDAAC,gCAAW;AAAA,YACZ,4CAAC,sCAAc;AAAA,YACd;AAAA,aACH;AAAA,UACC,aAAa,mBAAmB,IAC/B;AAAA,YAAC;AAAA;AAAA,cACC,GAAG,iBAAiB,uBAAuB,iBAAiB;AAAA,cAC5D,OAAO,KAAK,IAAI,iBAAiB,oBAAoB;AAAA,cACrD,QAAQ;AAAA,cACR,MAAK;AAAA,cACL,OAAO,EAAE,SAAS,IAAI;AAAA;AAAA,UACxB,IACE;AAAA,WACN;AAAA,QACA,4CAAC,gCAAW;AAAA;AAAA;AAAA,EACd;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,7 +30,20 @@ __export(react_desc_prop_types_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
31
31
|
var React = __toESM(require("react"));
|
|
32
32
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
33
|
-
const defaultProps = {
|
|
33
|
+
const defaultProps = {
|
|
34
|
+
series: [
|
|
35
|
+
{
|
|
36
|
+
name: "1",
|
|
37
|
+
data: [0],
|
|
38
|
+
color: "grey-100",
|
|
39
|
+
type: "bar"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
xAxis: {
|
|
43
|
+
cols: ["0"]
|
|
44
|
+
},
|
|
45
|
+
yAxis: {}
|
|
46
|
+
};
|
|
34
47
|
const propTypes = {
|
|
35
48
|
...import_ds_utilities.globalAttributesPropTypes,
|
|
36
49
|
height: import_ds_utilities.PropTypes.number.isRequired.description("height").defaultValue(""),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/graphs/Chart/react-desc-prop-types.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\nimport type { Series, ScaleLinear, ScaleBand } from 'd3';\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'area' | 'point';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export type LinearScale = ScaleLinear<number, number, never>;\n export type BandScale = ScaleBand<string>;\n\n export type Scales = LinearScale | BandScale;\n export interface SeriesT {\n name: string;\n data: Array<number | null | { x: number; y: number }>;\n type: SerieTypeT;\n scale?: string;\n color?: string;\n // line\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export interface ScrapperT {\n type: 'horizontal' | 'vertical';\n color: string;\n tooltipPreference: string;\n }\n\n export interface SerieComponentT {\n serie: InternalSerie;\n }\n\n export interface AxisTickT {\n tickValues: number[] | Date[];\n tickFormat: () => void | string;\n tickCount: number;\n tickRotation: number;\n overwriteTicks: boolean;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n label: string;\n type: AxisTypeT;\n cols?: string[];\n domainPadding: number;\n hideAxis: boolean;\n beginAtZero?: boolean;\n advanced: {\n pointSpacing: {\n type: 'string';\n value: number;\n };\n };\n tick: AxisTickT;\n }\n\n export interface InternalDatum {\n key: string;\n value: number | { x: number; y: number };\n position: number;\n serie: string;\n }\n\n export interface InternalSerie {\n key: string;\n data: InternalDatum[];\n name: string;\n type: DSChartT.SerieTypeT;\n scale?: string | undefined;\n color?: string;\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export type InternalData = InternalSerie[];\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter';\n scrapper: ScrapperT;\n withTrendHighlight: boolean;\n TooltipRenderer: () => JSX.Element;\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAqD;AA2G9C,MAAM,eAAsC,CAAC;
|
|
4
|
+
"sourcesContent": ["import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\nimport type { Series, ScaleLinear, ScaleBand } from 'd3';\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'area' | 'point';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export type LinearScale = ScaleLinear<number, number, never>;\n export type BandScale = ScaleBand<string>;\n\n export type Scales = LinearScale | BandScale;\n export interface SeriesT {\n name: string;\n data: Array<number | null | { x: number; y: number }>;\n type: SerieTypeT;\n scale?: string;\n color?: string;\n // line\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export interface ScrapperT {\n type: 'horizontal' | 'vertical';\n color: string;\n tooltipPreference: string;\n }\n\n export interface SerieComponentT {\n serie: InternalSerie;\n }\n\n export interface AxisTickT {\n tickValues: number[] | Date[];\n tickFormat: () => void | string;\n tickCount: number;\n tickRotation: number;\n overwriteTicks: boolean;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n label: string;\n type: AxisTypeT;\n cols?: string[];\n domainPadding: number;\n hideAxis: boolean;\n beginAtZero?: boolean;\n advanced: {\n pointSpacing: {\n type: 'string';\n value: number;\n };\n };\n tick: AxisTickT;\n }\n\n export interface InternalDatum {\n key: string;\n value: number | { x: number; y: number };\n position: number;\n serie: string;\n }\n\n export interface InternalSerie {\n key: string;\n data: InternalDatum[];\n name: string;\n type: DSChartT.SerieTypeT;\n scale?: string | undefined;\n color?: string;\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export type InternalData = InternalSerie[];\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter';\n scrapper: ScrapperT;\n withTrendHighlight: boolean;\n TooltipRenderer: () => JSX.Element;\n height: number;\n width: number;\n }\n\n export interface DefaultProps {\n yAxis: AxisT;\n xAxis: AxisT;\n series: SeriesT[];\n }\n\n export interface RequiredProps {}\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n\n export type StackedSeriesByGroupT = Series<\n {\n [key: string]: number;\n },\n string\n >[][];\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {\n series: [\n {\n name: '1',\n data: [0],\n color: 'grey-100',\n type: 'bar',\n },\n ],\n xAxis: {\n cols: ['0'],\n },\n yAxis: {},\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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAAqD;AA2G9C,MAAM,eAAsC;AAAA,EACjD,QAAQ;AAAA,IACN;AAAA,MACE,MAAM;AAAA,MACN,MAAM,CAAC,CAAC;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,MAAM,CAAC,GAAG;AAAA,EACZ;AAAA,EACA,OAAO,CAAC;AACV;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,8BAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,8BAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,8BAAU,MAAM;AAAA,IACtB,KAAK,8BAAU;AAAA,IACf,QAAQ,8BAAU;AAAA,IAClB,MAAM,8BAAU;AAAA,IAChB,OAAO,8BAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,8BAAU,QAAQ,8BAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,6 @@ var import_Rect = require("./Rect");
|
|
|
34
34
|
var import_ChartContext = require("../ChartContext");
|
|
35
35
|
const Bars = ({ serie }) => {
|
|
36
36
|
const {
|
|
37
|
-
props: { yAxis, TooltipRenderer },
|
|
38
37
|
innerHeight,
|
|
39
38
|
xScale,
|
|
40
39
|
yScale,
|
|
@@ -43,6 +42,7 @@ const Bars = ({ serie }) => {
|
|
|
43
42
|
colorScale,
|
|
44
43
|
getXValue,
|
|
45
44
|
getYValue,
|
|
45
|
+
isHorizontal,
|
|
46
46
|
chartId
|
|
47
47
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
48
48
|
const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
|
|
@@ -53,7 +53,7 @@ const Bars = ({ serie }) => {
|
|
|
53
53
|
const y = getYValue(bar);
|
|
54
54
|
const width = subGroupScale?.bandwidth();
|
|
55
55
|
const height = y > 0 ? positiveSize - finalYScale(y) : finalYScale(y) - finalYScale(0);
|
|
56
|
-
const transformX = subGroupScale(serie.name) + xScale(x);
|
|
56
|
+
const transformX = isHorizontal ? 0 : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? width / 2 * subGroupScale.domain().length : 0);
|
|
57
57
|
const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);
|
|
58
58
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { id: `${serie.name}-rects`, transform: `translate(${transformX},0)`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
59
|
import_Rect.Rect,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/Bars.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\n\nexport const Bars = ({ serie }) => {\n const {\n innerHeight,\n xScale,\n yScale,\n y2Scale,\n subGroupScale,\n colorScale,\n getXValue,\n getYValue,\n isHorizontal,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n const negativeSize = innerHeight - finalYScale(0);\n const positiveSize = innerHeight - negativeSize;\n\n return (\n <g fill={colorScale(serie.name)} clipPath={`url(#rect-focus-ring-${chartId})`}>\n {serie.data.map((bar, i) => {\n const x = getXValue(bar);\n const y = getYValue(bar);\n\n const width = subGroupScale?.bandwidth();\n const height = y > 0 ? positiveSize - finalYScale(y) : finalYScale(y) - finalYScale(0);\n\n // const transformX = subGroupScale(serie.name) + xScale(x);\n\n // @todo find a way to create bars with linear\n // scale here is something but conflict with bars like {x: 'Monday', y: 10}\n const transformX = isHorizontal\n ? 0\n : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? (width / 2) * subGroupScale.domain().length : 0);\n\n const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);\n\n return (\n <g id={`${serie.name}-rects`} key={bar.key} transform={`translate(${transformX},0)`}>\n <Rect\n name={serie.name}\n xValue={x}\n yValue={y}\n width={width}\n height={height}\n id={bar.key}\n y={transformY}\n isNegative={y < 0}\n datum={bar}\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;AD4CX;AA3CZ,mBAAkC;AAClC,kBAAqB;AACrB,0BAA6B;AAEtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAM;AACjC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,QAAM,eAAe,cAAc,YAAY,CAAC;AAChD,QAAM,eAAe,cAAc;AAEnC,SACE,4CAAC,OAAE,MAAM,WAAW,MAAM,IAAI,GAAG,UAAU,wBAAwB,YAChE,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,UAAM,IAAI,UAAU,GAAG;AACvB,UAAM,IAAI,UAAU,GAAG;AAEvB,UAAM,QAAQ,eAAe,UAAU;AACvC,UAAM,SAAS,IAAI,IAAI,eAAe,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,YAAY,CAAC;AAMrF,UAAM,aAAa,eACf,IACA,cAAc,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,IAAK,QAAQ,IAAK,cAAc,OAAO,EAAE,SAAS;AAEzG,UAAM,aAAa,IAAI,IAAI,YAAY,CAAC,IAAI,SAAS,YAAY,CAAC;AAElE,WACE,4CAAC,OAAE,IAAI,GAAG,MAAM,cAA4B,WAAW,aAAa,iBAClE;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,MAAM;AAAA,QACZ,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,IAAI,IAAI;AAAA,QACR,GAAG;AAAA,QACH,YAAY,IAAI;AAAA,QAChB,OAAO;AAAA;AAAA,IACT,KAXiC,IAAI,GAYvC;AAAA,EAEJ,CAAC,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -136,8 +136,7 @@ const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacit
|
|
|
136
136
|
id,
|
|
137
137
|
width: (pointRadius ?? 3) * 4,
|
|
138
138
|
height: (pointRadius ?? 3) * 4,
|
|
139
|
-
pointRadius,
|
|
140
|
-
style: { transform: `translate(-${pointRadius}px, -${pointRadius}px)` },
|
|
139
|
+
style: { transform: `translate(-${pointRadius ?? 3}px, -${pointRadius ?? 3}px)` },
|
|
141
140
|
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, { data: [{ name, yValue, xValue }] })
|
|
142
141
|
}
|
|
143
142
|
) : null
|