@elliemae/ds-dataviz 3.8.0 → 3.9.0-next.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/config/useChart.js +67 -13
- package/dist/cjs/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +14 -8
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +24 -11
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/helpers/index.js +2 -2
- package/dist/cjs/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js +23 -20
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js +20 -30
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js +4 -9
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +28 -14
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/{series/Pie.js → parts/Labels/BottomLabel.js} +20 -12
- package/dist/cjs/graphs/Chart/parts/Labels/BottomLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/Label.js +52 -0
- package/dist/cjs/graphs/Chart/parts/Labels/Label.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +65 -0
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js +67 -0
- package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +28 -30
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +15 -20
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +71 -0
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +32 -25
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +3 -13
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js +50 -16
- package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js +3 -1
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js +7 -5
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +19 -18
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +2 -2
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js +12 -8
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Line.js +5 -3
- package/dist/cjs/graphs/Chart/series/Line.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Points.js +9 -4
- package/dist/cjs/graphs/Chart/series/Points.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/index.js +0 -1
- package/dist/cjs/graphs/Chart/series/index.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChart.js +68 -14
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +14 -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/helpers/index.js +2 -2
- package/dist/esm/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js +24 -21
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js +21 -31
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js +4 -9
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +29 -15
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js +28 -0
- package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/Label.js +26 -0
- package/dist/esm/graphs/Chart/parts/Labels/Label.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +39 -0
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js +41 -0
- package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +28 -30
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +17 -22
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +45 -0
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +33 -26
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +3 -13
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js +51 -17
- package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js +3 -1
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js +7 -5
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +19 -18
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js +2 -2
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js +12 -8
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Line.js +5 -3
- package/dist/esm/graphs/Chart/series/Line.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Points.js +9 -4
- package/dist/esm/graphs/Chart/series/Points.js.map +2 -2
- package/dist/esm/graphs/Chart/series/index.js +0 -1
- package/dist/esm/graphs/Chart/series/index.js.map +2 -2
- package/package.json +8 -8
- package/dist/cjs/graphs/Chart/series/Pie.js.map +0 -7
- package/dist/esm/graphs/Chart/series/Pie.js +0 -20
- package/dist/esm/graphs/Chart/series/Pie.js.map +0 -7
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { ChartContext } from "../../ChartContext";
|
|
5
|
+
import { StyledAxisLabel } from "../../styles";
|
|
6
|
+
const BottomLabel = () => {
|
|
7
|
+
const {
|
|
8
|
+
internalMargin,
|
|
9
|
+
setBottomLabel,
|
|
10
|
+
innerHeight,
|
|
11
|
+
innerWidth,
|
|
12
|
+
props: { xAxis }
|
|
13
|
+
} = useContext(ChartContext);
|
|
14
|
+
return /* @__PURE__ */ jsx("g", {
|
|
15
|
+
ref: setBottomLabel,
|
|
16
|
+
transform: `translate(${innerWidth / 2 + internalMargin.left},${innerHeight + internalMargin.top})`,
|
|
17
|
+
children: /* @__PURE__ */ jsx(StyledAxisLabel, {
|
|
18
|
+
className: "axis-label",
|
|
19
|
+
textAnchor: "middle",
|
|
20
|
+
dy: 35,
|
|
21
|
+
children: xAxis?.label
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
BottomLabel
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=BottomLabel.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Labels/BottomLabel.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { StyledAxisLabel } from '../../styles';\n\nexport const BottomLabel = () => {\n const {\n internalMargin,\n setBottomLabel,\n // leftLegend,\n innerHeight,\n innerWidth,\n props: { xAxis },\n } = useContext(ChartContext);\n\n return (\n <g\n ref={setBottomLabel}\n transform={`translate(${innerWidth / 2 + internalMargin.left},${innerHeight + internalMargin.top})`}\n >\n <StyledAxisLabel className=\"axis-label\" textAnchor=\"middle\" dy={35}>\n {xAxis?.label}\n </StyledAxisLabel>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,kBAA2B;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAEzB,MAAM,cAAc,MAAM;AAC/B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IAEA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,MAAM;AAAA,EACjB,IAAI,WAAW,YAAY;AAE3B,SACE,oBAAC;AAAA,IACC,KAAK;AAAA,IACL,WAAW,aAAa,aAAa,IAAI,eAAe,QAAQ,cAAc,eAAe;AAAA,IAE7F,8BAAC;AAAA,MAAgB,WAAU;AAAA,MAAa,YAAW;AAAA,MAAS,IAAI;AAAA,MAC7D,iBAAO;AAAA,KACV;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
|
+
import { ChartContext } from "../../ChartContext";
|
|
5
|
+
import { RightLabel } from "./RightLabel";
|
|
6
|
+
import { LeftLabel } from "./LeftLabel";
|
|
7
|
+
import { BottomLabel } from "./BottomLabel";
|
|
8
|
+
const Label = () => {
|
|
9
|
+
const {
|
|
10
|
+
props: { xAxis, yAxis, y2Axis }
|
|
11
|
+
} = useContext(ChartContext);
|
|
12
|
+
return useMemo(
|
|
13
|
+
() => /* @__PURE__ */ jsxs("g", {
|
|
14
|
+
children: [
|
|
15
|
+
y2Axis?.label ? /* @__PURE__ */ jsx(RightLabel, {}) : "",
|
|
16
|
+
yAxis?.label ? /* @__PURE__ */ jsx(LeftLabel, {}) : "",
|
|
17
|
+
xAxis?.label ? /* @__PURE__ */ jsx(BottomLabel, {}) : ""
|
|
18
|
+
]
|
|
19
|
+
}),
|
|
20
|
+
[xAxis?.label, y2Axis?.label, yAxis?.label]
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
Label
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=Label.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Labels/Label.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\n\nimport { ChartContext } from '../../ChartContext';\nimport { RightLabel } from './RightLabel';\nimport { LeftLabel } from './LeftLabel';\nimport { BottomLabel } from './BottomLabel';\n\nexport const Label = () => {\n const {\n props: { xAxis, yAxis, y2Axis },\n } = useContext(ChartContext);\n\n return useMemo(\n () => (\n <g>\n {y2Axis?.label ? <RightLabel /> : ''}\n {yAxis?.label ? <LeftLabel /> : ''}\n {xAxis?.label ? <BottomLabel /> : ''}\n </g>\n ),\n [xAxis?.label, y2Axis?.label, yAxis?.label],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,eAAe;AAE3C,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAErB,MAAM,QAAQ,MAAM;AACzB,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,OAAO,OAAO;AAAA,EAChC,IAAI,WAAW,YAAY;AAE3B,SAAO;AAAA,IACL,MACE,qBAAC;AAAA,MACE;AAAA,gBAAQ,QAAQ,oBAAC,cAAW,IAAK;AAAA,QACjC,OAAO,QAAQ,oBAAC,aAAU,IAAK;AAAA,QAC/B,OAAO,QAAQ,oBAAC,eAAY,IAAK;AAAA;AAAA,KACpC;AAAA,IAEF,CAAC,OAAO,OAAO,QAAQ,OAAO,OAAO,KAAK;AAAA,EAC5C;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
|
+
import { ChartContext } from "../../ChartContext";
|
|
5
|
+
import { StyledAxisLabel } from "../../styles";
|
|
6
|
+
const LeftLabel = () => {
|
|
7
|
+
const {
|
|
8
|
+
innerHeight,
|
|
9
|
+
internalMargin,
|
|
10
|
+
setLeftLabel,
|
|
11
|
+
leftLegend,
|
|
12
|
+
props: { yAxis }
|
|
13
|
+
} = useContext(ChartContext);
|
|
14
|
+
const leftMargin = useMemo(
|
|
15
|
+
() => leftLegend?.getBoundingClientRect().width ? leftLegend?.getBoundingClientRect().width + 15 : 8,
|
|
16
|
+
[leftLegend]
|
|
17
|
+
);
|
|
18
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
19
|
+
ref: setLeftLabel,
|
|
20
|
+
transform: `translate(${leftMargin},${innerHeight / 2 + internalMargin.top}) rotate(-90)`,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsx("rect", {
|
|
23
|
+
height: "30",
|
|
24
|
+
width: "1",
|
|
25
|
+
fill: "transparent"
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx(StyledAxisLabel, {
|
|
28
|
+
className: "axis-label",
|
|
29
|
+
textAnchor: "middle",
|
|
30
|
+
dy: 15,
|
|
31
|
+
children: yAxis?.label
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
LeftLabel
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=LeftLabel.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Labels/LeftLabel.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { StyledAxisLabel } from '../../styles';\n\nexport const LeftLabel = () => {\n const {\n innerHeight,\n internalMargin,\n setLeftLabel,\n leftLegend,\n props: { yAxis },\n } = useContext(ChartContext);\n\n const leftMargin = useMemo(\n () => (leftLegend?.getBoundingClientRect().width ? leftLegend?.getBoundingClientRect().width + 15 : 8),\n [leftLegend],\n );\n return (\n <g ref={setLeftLabel} transform={`translate(${leftMargin},${innerHeight / 2 + internalMargin.top}) rotate(-90)`}>\n <rect height=\"30\" width=\"1\" fill=\"transparent\" />\n <StyledAxisLabel className=\"axis-label\" textAnchor=\"middle\" dy={15}>\n {yAxis?.label}\n </StyledAxisLabel>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,eAAe;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAEzB,MAAM,YAAY,MAAM;AAC7B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,MAAM;AAAA,EACjB,IAAI,WAAW,YAAY;AAE3B,QAAM,aAAa;AAAA,IACjB,MAAO,YAAY,sBAAsB,EAAE,QAAQ,YAAY,sBAAsB,EAAE,QAAQ,KAAK;AAAA,IACpG,CAAC,UAAU;AAAA,EACb;AACA,SACE,qBAAC;AAAA,IAAE,KAAK;AAAA,IAAc,WAAW,aAAa,cAAc,cAAc,IAAI,eAAe;AAAA,IAC3F;AAAA,0BAAC;AAAA,QAAK,QAAO;AAAA,QAAK,OAAM;AAAA,QAAI,MAAK;AAAA,OAAc;AAAA,MAC/C,oBAAC;AAAA,QAAgB,WAAU;AAAA,QAAa,YAAW;AAAA,QAAS,IAAI;AAAA,QAC7D,iBAAO;AAAA,OACV;AAAA;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import { StyledAxisLabel } from "../../styles";
|
|
6
|
+
const RightLabel = () => {
|
|
7
|
+
const {
|
|
8
|
+
colorScale,
|
|
9
|
+
innerWidth,
|
|
10
|
+
innerHeight,
|
|
11
|
+
setInnerWidth,
|
|
12
|
+
internalMargin,
|
|
13
|
+
axisRightWidth,
|
|
14
|
+
setRightLabel,
|
|
15
|
+
props: { margin, y2Axis }
|
|
16
|
+
} = useContext(ChartContext);
|
|
17
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
18
|
+
ref: setRightLabel,
|
|
19
|
+
transform: `translate(${innerWidth + internalMargin.left + axisRightWidth?.getBoundingClientRect().width},${innerHeight / 2 + internalMargin.top}) `,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx("rect", {
|
|
22
|
+
width: "20",
|
|
23
|
+
height: 1,
|
|
24
|
+
fill: "transparent"
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ jsx("g", {
|
|
27
|
+
transform: " rotate(90)",
|
|
28
|
+
children: /* @__PURE__ */ jsx(StyledAxisLabel, {
|
|
29
|
+
className: "axis-label",
|
|
30
|
+
textAnchor: "middle",
|
|
31
|
+
dy: "-15",
|
|
32
|
+
children: y2Axis?.label
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
RightLabel
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=RightLabel.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Labels/RightLabel.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect, useRef, useState } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { StyledAxisLabel } from '../../styles';\n\nexport const RightLabel = () => {\n const {\n colorScale,\n innerWidth,\n innerHeight,\n setInnerWidth,\n internalMargin,\n axisRightWidth,\n setRightLabel,\n props: { margin, y2Axis },\n } = useContext(ChartContext);\n\n return (\n <g\n ref={setRightLabel}\n transform={`translate(${innerWidth + internalMargin.left + axisRightWidth?.getBoundingClientRect().width},${\n innerHeight / 2 + internalMargin.top\n }) `}\n >\n <rect width=\"20\" height={1} fill=\"transparent\" />\n <g transform=\" rotate(90)\">\n <StyledAxisLabel className=\"axis-label\" textAnchor=\"middle\" dy=\"-15\">\n {y2Axis?.label}\n </StyledAxisLabel>\n </g>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,kBAA+C;AAC/D,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAEzB,MAAM,aAAa,MAAM;AAC9B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,QAAQ,OAAO;AAAA,EAC1B,IAAI,WAAW,YAAY;AAE3B,SACE,qBAAC;AAAA,IACC,KAAK;AAAA,IACL,WAAW,aAAa,aAAa,eAAe,OAAO,gBAAgB,sBAAsB,EAAE,SACjG,cAAc,IAAI,eAAe;AAAA,IAGnC;AAAA,0BAAC;AAAA,QAAK,OAAM;AAAA,QAAK,QAAQ;AAAA,QAAG,MAAK;AAAA,OAAc;AAAA,MAC/C,oBAAC;AAAA,QAAE,WAAU;AAAA,QACX,8BAAC;AAAA,UAAgB,WAAU;AAAA,UAAa,YAAW;AAAA,UAAS,IAAG;AAAA,UAC5D,kBAAQ;AAAA,SACX;AAAA,OACF;AAAA;AAAA,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,43 +3,53 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext, useMemo, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { selectAll, select } from "d3";
|
|
5
5
|
import { ChartContext } from "../../ChartContext";
|
|
6
|
+
import { LegendItem } from "./LegendItem";
|
|
6
7
|
const BottomLegend = () => {
|
|
7
|
-
const {
|
|
8
|
-
colorScale,
|
|
9
|
-
innerWidth,
|
|
10
|
-
innerHeight,
|
|
11
|
-
internalMargin,
|
|
12
|
-
setBottomLegend,
|
|
13
|
-
props: { height }
|
|
14
|
-
} = useContext(ChartContext);
|
|
8
|
+
const { colorScale, axisBottomHeight, innerWidth, innerHeight, bottomLabel, internalMargin, setBottomLegend } = useContext(ChartContext);
|
|
15
9
|
const ref = useRef(null);
|
|
16
10
|
const firstRender = useRef(true);
|
|
17
11
|
const [xTransform, setXTransform] = useState(innerWidth / 2);
|
|
18
12
|
useEffect(() => {
|
|
19
13
|
if (ref.current && firstRender.current) {
|
|
20
14
|
const cells = selectAll(".cell");
|
|
21
|
-
const padding =
|
|
15
|
+
const padding = 30;
|
|
22
16
|
let offset = 0;
|
|
17
|
+
let verticalOffset = 0;
|
|
23
18
|
cells.each((d, i) => {
|
|
24
19
|
if (cells._groups[0][i - 1]) {
|
|
25
20
|
const lastCell = select(cells._groups[0][i - 1]);
|
|
26
21
|
const d3sel = select(cells._groups[0][i]);
|
|
27
22
|
const { width } = lastCell.node().getBBox();
|
|
28
|
-
offset
|
|
29
|
-
|
|
23
|
+
if (offset + width + padding > innerWidth - innerWidth / 3) {
|
|
24
|
+
offset = 0;
|
|
25
|
+
verticalOffset += 20;
|
|
26
|
+
} else {
|
|
27
|
+
offset += width + padding;
|
|
28
|
+
}
|
|
29
|
+
d3sel.attr("transform", `translate(${offset}, ${verticalOffset})`);
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
const bounds = ref.current.getBoundingClientRect();
|
|
33
33
|
setXTransform((prev) => prev - bounds.width / 2);
|
|
34
34
|
firstRender.current = false;
|
|
35
35
|
}
|
|
36
|
-
}, []);
|
|
37
|
-
const
|
|
36
|
+
}, [innerWidth]);
|
|
37
|
+
const margin = useMemo(() => {
|
|
38
|
+
let counter = 0;
|
|
39
|
+
if (bottomLabel) {
|
|
40
|
+
counter += bottomLabel?.getBoundingClientRect().height + 25;
|
|
41
|
+
}
|
|
42
|
+
if (axisBottomHeight) {
|
|
43
|
+
counter += axisBottomHeight?.getBoundingClientRect().height;
|
|
44
|
+
}
|
|
45
|
+
return counter;
|
|
46
|
+
}, [bottomLabel, axisBottomHeight]);
|
|
47
|
+
return useMemo(
|
|
38
48
|
() => /* @__PURE__ */ jsx("g", {
|
|
39
49
|
ref: setBottomLegend,
|
|
40
50
|
children: /* @__PURE__ */ jsxs("g", {
|
|
41
51
|
ref,
|
|
42
|
-
transform: `translate(${xTransform + internalMargin.left}, ${
|
|
52
|
+
transform: `translate(${xTransform + internalMargin.left}, ${innerHeight + internalMargin.top + margin})`,
|
|
43
53
|
className: "bottom-legend",
|
|
44
54
|
children: [
|
|
45
55
|
/* @__PURE__ */ jsx("rect", {
|
|
@@ -47,26 +57,14 @@ const BottomLegend = () => {
|
|
|
47
57
|
width: 1,
|
|
48
58
|
fill: "transparent"
|
|
49
59
|
}),
|
|
50
|
-
colorScale.domain().map((domainValue, i) => /* @__PURE__ */
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/* @__PURE__ */ jsx("circle", {
|
|
54
|
-
fill: colorScale(domainValue),
|
|
55
|
-
r: 4
|
|
56
|
-
}),
|
|
57
|
-
/* @__PURE__ */ jsx("text", {
|
|
58
|
-
x: 10,
|
|
59
|
-
dy: ".32em",
|
|
60
|
-
children: domainValue
|
|
61
|
-
})
|
|
62
|
-
]
|
|
63
|
-
}))
|
|
60
|
+
colorScale.domain().map((domainValue, i) => /* @__PURE__ */ jsx(LegendItem, {
|
|
61
|
+
domainValue
|
|
62
|
+
}, domainValue))
|
|
64
63
|
]
|
|
65
64
|
})
|
|
66
65
|
}),
|
|
67
|
-
[colorScale,
|
|
66
|
+
[colorScale, innerHeight, internalMargin.left, internalMargin.top, margin, setBottomLegend, xTransform]
|
|
68
67
|
);
|
|
69
|
-
return render;
|
|
70
68
|
};
|
|
71
69
|
export {
|
|
72
70
|
BottomLegend
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/BottomLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useEffect, useRef, useState } from 'react';\nimport { selectAll, select } from 'd3';\nimport { ChartContext } from '../../ChartContext';\n\nexport const BottomLegend = () => {\n const {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,WAAW,QAAQ,gBAAgB;AACxE,SAAS,WAAW,cAAc;AAClC,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useEffect, useRef, useState } from 'react';\nimport { selectAll, select } from 'd3';\nimport { ChartContext } from '../../ChartContext';\nimport { LegendItem } from './LegendItem';\n\nexport const BottomLegend = () => {\n const { colorScale, axisBottomHeight, innerWidth, innerHeight, bottomLabel, internalMargin, setBottomLegend } =\n useContext(ChartContext);\n\n const ref = useRef(null);\n const firstRender = useRef(true);\n\n const [xTransform, setXTransform] = useState(innerWidth / 2);\n useEffect(() => {\n if (ref.current && firstRender.current) {\n const cells = selectAll('.cell');\n const padding = 30;\n let offset = 0;\n let verticalOffset = 0;\n\n cells.each((d, 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\n const { width } = lastCell.node().getBBox();\n if (offset + width + padding > innerWidth - innerWidth / 3) {\n offset = 0;\n verticalOffset += 20;\n } else {\n offset += width + padding;\n }\n\n d3sel.attr('transform', `translate(${offset}, ${verticalOffset})`);\n }\n });\n const bounds = ref.current.getBoundingClientRect();\n setXTransform((prev) => prev - bounds.width / 2);\n firstRender.current = false;\n }\n }, [innerWidth]);\n\n const margin = useMemo(() => {\n let counter = 0;\n if (bottomLabel) {\n counter += bottomLabel?.getBoundingClientRect().height + 25;\n }\n if (axisBottomHeight) {\n counter += axisBottomHeight?.getBoundingClientRect().height;\n }\n return counter;\n }, [bottomLabel, axisBottomHeight]);\n\n return useMemo(\n () => (\n <g ref={setBottomLegend}>\n <g\n ref={ref}\n transform={`translate(${xTransform + internalMargin.left}, ${innerHeight + internalMargin.top + margin})`}\n className=\"bottom-legend\"\n >\n <rect height={40} width={1} fill=\"transparent\" />\n {colorScale.domain().map((domainValue, i) => (\n <LegendItem domainValue={domainValue} key={domainValue} />\n ))}\n </g>\n </g>\n ),\n\n [colorScale, innerHeight, internalMargin.left, internalMargin.top, margin, setBottomLegend, xTransform],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,WAAW,QAAQ,gBAAgB;AACxE,SAAS,WAAW,cAAc;AAClC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,eAAe,MAAM;AAChC,QAAM,EAAE,YAAY,kBAAkB,YAAY,aAAa,aAAa,gBAAgB,gBAAgB,IAC1G,WAAW,YAAY;AAEzB,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,cAAc,OAAO,IAAI;AAE/B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,aAAa,CAAC;AAC3D,YAAU,MAAM;AACd,QAAI,IAAI,WAAW,YAAY,SAAS;AACtC,YAAM,QAAQ,UAAU,OAAO;AAC/B,YAAM,UAAU;AAChB,UAAI,SAAS;AACb,UAAI,iBAAiB;AAErB,YAAM,KAAK,CAAC,GAAG,MAAM;AACnB,YAAI,MAAM,QAAQ,GAAG,IAAI,IAAI;AAC3B,gBAAM,WAAW,OAAO,MAAM,QAAQ,GAAG,IAAI,EAAE;AAC/C,gBAAM,QAAQ,OAAO,MAAM,QAAQ,GAAG,EAAE;AAExC,gBAAM,EAAE,MAAM,IAAI,SAAS,KAAK,EAAE,QAAQ;AAC1C,cAAI,SAAS,QAAQ,UAAU,aAAa,aAAa,GAAG;AAC1D,qBAAS;AACT,8BAAkB;AAAA,UACpB,OAAO;AACL,sBAAU,QAAQ;AAAA,UACpB;AAEA,gBAAM,KAAK,aAAa,aAAa,WAAW,iBAAiB;AAAA,QACnE;AAAA,MACF,CAAC;AACD,YAAM,SAAS,IAAI,QAAQ,sBAAsB;AACjD,oBAAc,CAAC,SAAS,OAAO,OAAO,QAAQ,CAAC;AAC/C,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,QAAM,SAAS,QAAQ,MAAM;AAC3B,QAAI,UAAU;AACd,QAAI,aAAa;AACf,iBAAW,aAAa,sBAAsB,EAAE,SAAS;AAAA,IAC3D;AACA,QAAI,kBAAkB;AACpB,iBAAW,kBAAkB,sBAAsB,EAAE;AAAA,IACvD;AACA,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,gBAAgB,CAAC;AAElC,SAAO;AAAA,IACL,MACE,oBAAC;AAAA,MAAE,KAAK;AAAA,MACN,+BAAC;AAAA,QACC;AAAA,QACA,WAAW,aAAa,aAAa,eAAe,SAAS,cAAc,eAAe,MAAM;AAAA,QAChG,WAAU;AAAA,QAEV;AAAA,8BAAC;AAAA,YAAK,QAAQ;AAAA,YAAI,OAAO;AAAA,YAAG,MAAK;AAAA,WAAc;AAAA,UAC9C,WAAW,OAAO,EAAE,IAAI,CAAC,aAAa,MACrC,oBAAC;AAAA,YAAW;AAAA,aAA+B,WAAa,CACzD;AAAA;AAAA,OACH;AAAA,KACF;AAAA,IAGF,CAAC,YAAY,aAAa,eAAe,MAAM,eAAe,KAAK,QAAQ,iBAAiB,UAAU;AAAA,EACxG;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { jsx
|
|
3
|
-
import { useContext } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useState, useEffect } from "react";
|
|
4
4
|
import { ChartContext } from "../../ChartContext";
|
|
5
|
+
import { LegendItem } from "./LegendItem";
|
|
5
6
|
const LeftLegend = () => {
|
|
6
|
-
const { colorScale, innerHeight, internalMargin,
|
|
7
|
+
const { colorScale, innerHeight, internalMargin, setLeftLegend } = useContext(ChartContext);
|
|
8
|
+
const [yTransform, setYTransform] = useState(innerHeight / 2 + internalMargin.top);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (leftLegend) {
|
|
11
|
+
const bounds = leftLegend.getBoundingClientRect();
|
|
12
|
+
setYTransform((prev) => prev - bounds.height / 2);
|
|
13
|
+
}
|
|
14
|
+
}, [leftLegend]);
|
|
7
15
|
return /* @__PURE__ */ jsx("g", {
|
|
8
|
-
transform: `translate(8,${
|
|
16
|
+
transform: `translate(8,${yTransform})`,
|
|
9
17
|
ref: setLeftLegend,
|
|
10
|
-
children: colorScale.domain().map((domainValue, i) => /* @__PURE__ */
|
|
18
|
+
children: colorScale.domain().map((domainValue, i) => /* @__PURE__ */ jsx("g", {
|
|
11
19
|
className: "tick",
|
|
12
20
|
transform: `translate(0,${i * 20})`,
|
|
13
|
-
children:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
/* @__PURE__ */ jsx("text", {
|
|
19
|
-
x: 10,
|
|
20
|
-
dy: ".32em",
|
|
21
|
-
children: domainValue
|
|
22
|
-
}),
|
|
23
|
-
/* @__PURE__ */ jsx("rect", {
|
|
24
|
-
width: "180",
|
|
25
|
-
height: 1,
|
|
26
|
-
fill: "transparent"
|
|
27
|
-
})
|
|
28
|
-
]
|
|
29
|
-
}))
|
|
21
|
+
children: /* @__PURE__ */ jsx(LegendItem, {
|
|
22
|
+
domainValue
|
|
23
|
+
})
|
|
24
|
+
}, domainValue))
|
|
30
25
|
});
|
|
31
26
|
};
|
|
32
27
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/LeftLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { ChartContext } from '../../ChartContext';\n\nexport const LeftLegend = () => {\n const { colorScale, innerHeight, internalMargin,
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useState, useEffect } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { LegendItem } from './LegendItem';\n\nexport const LeftLegend = () => {\n const { colorScale, innerHeight, internalMargin, setLeftLegend } = useContext(ChartContext);\n\n const [yTransform, setYTransform] = useState(innerHeight / 2 + internalMargin.top);\n\n useEffect(() => {\n if (leftLegend) {\n const bounds = leftLegend.getBoundingClientRect();\n setYTransform((prev) => prev - bounds.height / 2);\n }\n }, [leftLegend]);\n\n return (\n <g transform={`translate(8,${yTransform})`} ref={setLeftLegend}>\n {colorScale.domain().map((domainValue, i) => (\n <g key={domainValue} className=\"tick\" transform={`translate(0,${i * 20})`}>\n <LegendItem domainValue={domainValue} />\n </g>\n ))}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,UAAU,iBAAiB;AACvD,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,aAAa,MAAM;AAC9B,QAAM,EAAE,YAAY,aAAa,gBAAgB,cAAc,IAAI,WAAW,YAAY;AAE1F,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,cAAc,IAAI,eAAe,GAAG;AAEjF,YAAU,MAAM;AACd,QAAI,YAAY;AACd,YAAM,SAAS,WAAW,sBAAsB;AAChD,oBAAc,CAAC,SAAS,OAAO,OAAO,SAAS,CAAC;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SACE,oBAAC;AAAA,IAAE,WAAW,eAAe;AAAA,IAAe,KAAK;AAAA,IAC9C,qBAAW,OAAO,EAAE,IAAI,CAAC,aAAa,MACrC,oBAAC;AAAA,MAAoB,WAAU;AAAA,MAAO,WAAW,eAAe,IAAI;AAAA,MAClE,8BAAC;AAAA,QAAW;AAAA,OAA0B;AAAA,OADhC,WAER,CACD;AAAA,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo, useCallback } from "react";
|
|
4
|
+
import { ChartContext } from "../../ChartContext";
|
|
5
|
+
const LegendItem = ({ domainValue }) => {
|
|
6
|
+
const {
|
|
7
|
+
colorScale,
|
|
8
|
+
setCurrentData,
|
|
9
|
+
props: { data }
|
|
10
|
+
} = useContext(ChartContext);
|
|
11
|
+
const serieData = data.find((serie) => serie.name === domainValue);
|
|
12
|
+
const handleOnClick = useCallback(() => {
|
|
13
|
+
setCurrentData(
|
|
14
|
+
data.map((data2) => {
|
|
15
|
+
if (data2.name === domainValue) {
|
|
16
|
+
return { ...data2, isHidden: !data2.isHidden };
|
|
17
|
+
}
|
|
18
|
+
return data2;
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
}, [data, domainValue, setCurrentData]);
|
|
22
|
+
return useMemo(
|
|
23
|
+
() => /* @__PURE__ */ jsxs("g", {
|
|
24
|
+
onClick: handleOnClick,
|
|
25
|
+
className: "cell",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsx("circle", {
|
|
28
|
+
fill: colorScale(domainValue),
|
|
29
|
+
r: 4
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ jsx("text", {
|
|
32
|
+
x: 10,
|
|
33
|
+
dy: ".32em",
|
|
34
|
+
textDecoration: serieData.isHidden ? "line-through" : "",
|
|
35
|
+
children: domainValue
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
}, domainValue),
|
|
39
|
+
[colorScale, domainValue, handleOnClick, serieData.isHidden]
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
LegendItem
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=LegendItem.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/LegendItem.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useCallback } from 'react';\n\nimport { ChartContext } from '../../ChartContext';\n\nexport const LegendItem = ({ domainValue }) => {\n const {\n colorScale,\n setCurrentData,\n props: { data },\n } = useContext(ChartContext);\n\n const serieData = data.find((serie) => serie.name === domainValue);\n const handleOnClick = useCallback(() => {\n setCurrentData(\n data.map((data) => {\n if (data.name === domainValue) {\n return { ...data, isHidden: !data.isHidden };\n }\n\n return data;\n }),\n );\n }, [data, domainValue, setCurrentData]);\n\n return useMemo(\n () => (\n <g onClick={handleOnClick} key={domainValue} className=\"cell\">\n <circle fill={colorScale(domainValue)} r={4} />\n <text x={10} dy=\".32em\" textDecoration={serieData.isHidden ? 'line-through' : ''}>\n {domainValue}\n </text>\n </g>\n ),\n\n [colorScale, domainValue, handleOnClick, serieData.isHidden],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,mBAAmB;AAExD,SAAS,oBAAoB;AAEtB,MAAM,aAAa,CAAC,EAAE,YAAY,MAAM;AAC7C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,OAAO,EAAE,KAAK;AAAA,EAChB,IAAI,WAAW,YAAY;AAE3B,QAAM,YAAY,KAAK,KAAK,CAAC,UAAU,MAAM,SAAS,WAAW;AACjE,QAAM,gBAAgB,YAAY,MAAM;AACtC;AAAA,MACE,KAAK,IAAI,CAACA,UAAS;AACjB,YAAIA,MAAK,SAAS,aAAa;AAC7B,iBAAO,EAAE,GAAGA,OAAM,UAAU,CAACA,MAAK,SAAS;AAAA,QAC7C;AAEA,eAAOA;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,MAAM,aAAa,cAAc,CAAC;AAEtC,SAAO;AAAA,IACL,MACE,qBAAC;AAAA,MAAE,SAAS;AAAA,MAAiC,WAAU;AAAA,MACrD;AAAA,4BAAC;AAAA,UAAO,MAAM,WAAW,WAAW;AAAA,UAAG,GAAG;AAAA,SAAG;AAAA,QAC7C,oBAAC;AAAA,UAAK,GAAG;AAAA,UAAI,IAAG;AAAA,UAAQ,gBAAgB,UAAU,WAAW,iBAAiB;AAAA,UAC3E;AAAA,SACH;AAAA;AAAA,OAJ8B,WAKhC;AAAA,IAGF,CAAC,YAAY,aAAa,eAAe,UAAU,QAAQ;AAAA,EAC7D;AACF;",
|
|
6
|
+
"names": ["data"]
|
|
7
|
+
}
|
|
@@ -1,40 +1,47 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useContext } from "react";
|
|
3
|
+
import { useContext, useState, useEffect } from "react";
|
|
4
4
|
import { ChartContext } from "../../ChartContext";
|
|
5
|
+
import { LegendItem } from "./LegendItem";
|
|
5
6
|
const RightLegend = () => {
|
|
6
7
|
const {
|
|
8
|
+
props: { y2Axis },
|
|
7
9
|
colorScale,
|
|
8
10
|
innerWidth,
|
|
9
11
|
innerHeight,
|
|
10
|
-
|
|
12
|
+
rightLabel,
|
|
13
|
+
rightLegend,
|
|
14
|
+
axisRightWidth,
|
|
11
15
|
internalMargin,
|
|
12
|
-
setRightLegend
|
|
13
|
-
props: { margin }
|
|
16
|
+
setRightLegend
|
|
14
17
|
} = useContext(ChartContext);
|
|
15
|
-
|
|
18
|
+
const [yTransform, setYTransform] = useState(innerHeight / 2 + internalMargin.top);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (rightLegend) {
|
|
21
|
+
const bounds = rightLegend.getBoundingClientRect();
|
|
22
|
+
setYTransform((prev) => prev - bounds.height / 2);
|
|
23
|
+
}
|
|
24
|
+
}, [rightLegend]);
|
|
25
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
16
26
|
ref: setRightLegend,
|
|
17
|
-
transform: `translate(${innerWidth + internalMargin.left
|
|
18
|
-
children:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/* @__PURE__ */ jsx("
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
children:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
]
|
|
37
|
-
}))
|
|
27
|
+
transform: `translate(${innerWidth + internalMargin.left + (y2Axis ? axisRightWidth?.getBoundingClientRect().width : 0) + (y2Axis?.label ? rightLabel?.getBoundingClientRect().width : 0)},${yTransform})`,
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ jsx("rect", {
|
|
30
|
+
width: "20",
|
|
31
|
+
height: 1,
|
|
32
|
+
fill: "transparent"
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx("g", {
|
|
35
|
+
transform: `translate(0,0)`,
|
|
36
|
+
children: colorScale.domain().map((domainValue, i) => /* @__PURE__ */ jsx("g", {
|
|
37
|
+
className: "tick",
|
|
38
|
+
transform: `translate(30,${i * 20})`,
|
|
39
|
+
children: /* @__PURE__ */ jsx(LegendItem, {
|
|
40
|
+
domainValue
|
|
41
|
+
})
|
|
42
|
+
}, domainValue))
|
|
43
|
+
})
|
|
44
|
+
]
|
|
38
45
|
});
|
|
39
46
|
};
|
|
40
47
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/RightLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext,
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useState, useEffect } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { LegendItem } from './LegendItem';\n\nexport const RightLegend = () => {\n const {\n props: { y2Axis },\n colorScale,\n innerWidth,\n innerHeight,\n rightLabel,\n rightLegend,\n axisRightWidth,\n internalMargin,\n setRightLegend,\n } = useContext(ChartContext);\n\n const [yTransform, setYTransform] = useState(innerHeight / 2 + internalMargin.top);\n\n useEffect(() => {\n if (rightLegend) {\n const bounds = rightLegend.getBoundingClientRect();\n setYTransform((prev) => prev - bounds.height / 2);\n }\n }, [rightLegend]);\n\n return (\n <g\n ref={setRightLegend}\n transform={`translate(${\n innerWidth +\n internalMargin.left +\n (y2Axis ? axisRightWidth?.getBoundingClientRect().width : 0) +\n (y2Axis?.label ? rightLabel?.getBoundingClientRect().width : 0)\n },${yTransform})`}\n >\n <rect width=\"20\" height={1} fill=\"transparent\" />\n <g transform={`translate(0,0)`}>\n {colorScale.domain().map((domainValue, i) => (\n <g className=\"tick\" transform={`translate(30,${i * 20})`} key={domainValue}>\n <LegendItem domainValue={domainValue} />\n </g>\n ))}\n </g>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,UAAU,iBAAiB;AACvD,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,cAAc,MAAM;AAC/B,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,cAAc,IAAI,eAAe,GAAG;AAEjF,YAAU,MAAM;AACd,QAAI,aAAa;AACf,YAAM,SAAS,YAAY,sBAAsB;AACjD,oBAAc,CAAC,SAAS,OAAO,OAAO,SAAS,CAAC;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE,qBAAC;AAAA,IACC,KAAK;AAAA,IACL,WAAW,aACT,aACA,eAAe,QACd,SAAS,gBAAgB,sBAAsB,EAAE,QAAQ,MACzD,QAAQ,QAAQ,YAAY,sBAAsB,EAAE,QAAQ,MAC3D;AAAA,IAEJ;AAAA,0BAAC;AAAA,QAAK,OAAM;AAAA,QAAK,QAAQ;AAAA,QAAG,MAAK;AAAA,OAAc;AAAA,MAC/C,oBAAC;AAAA,QAAE,WAAW;AAAA,QACX,qBAAW,OAAO,EAAE,IAAI,CAAC,aAAa,MACrC,oBAAC;AAAA,UAAE,WAAU;AAAA,UAAO,WAAW,gBAAgB,IAAI;AAAA,UACjD,8BAAC;AAAA,YAAW;AAAA,WAA0B;AAAA,WADuB,WAE/D,CACD;AAAA,OACH;AAAA;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext, useMemo, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { selectAll, select } from "d3";
|
|
5
5
|
import { ChartContext } from "../../ChartContext";
|
|
6
|
+
import { LegendItem } from "./LegendItem";
|
|
6
7
|
const TopLegend = () => {
|
|
7
8
|
const { colorScale, internalMargin, innerWidth, setTopLegend } = useContext(ChartContext);
|
|
8
9
|
const ref = useRef(null);
|
|
@@ -39,19 +40,8 @@ const TopLegend = () => {
|
|
|
39
40
|
width: 1,
|
|
40
41
|
fill: "transparent"
|
|
41
42
|
}),
|
|
42
|
-
colorScale.domain().map((domainValue, i) => /* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
children: [
|
|
45
|
-
/* @__PURE__ */ jsx("circle", {
|
|
46
|
-
fill: colorScale(domainValue),
|
|
47
|
-
r: 4
|
|
48
|
-
}),
|
|
49
|
-
/* @__PURE__ */ jsx("text", {
|
|
50
|
-
x: 10,
|
|
51
|
-
dy: ".32em",
|
|
52
|
-
children: domainValue
|
|
53
|
-
})
|
|
54
|
-
]
|
|
43
|
+
colorScale.domain().map((domainValue, i) => /* @__PURE__ */ jsx(LegendItem, {
|
|
44
|
+
domainValue
|
|
55
45
|
}, domainValue))
|
|
56
46
|
]
|
|
57
47
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/TopLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useEffect, useRef, useState } from 'react';\n\nimport { selectAll, select } from 'd3';\nimport { ChartContext } from '../../ChartContext';\n\nexport const TopLegend = () => {\n const { colorScale, internalMargin, innerWidth, setTopLegend } = useContext(ChartContext);\n\n const ref = useRef(null);\n const firstRender = useRef(true);\n\n const [xTransform, setXTransform] = useState(innerWidth / 2 + internalMargin.left);\n useEffect(() => {\n if (ref.current && firstRender.current) {\n const cells = selectAll('.cell');\n const padding = 40;\n let offset = 0;\n cells.each((d, 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\n const { width } = lastCell.node().getBBox();\n offset += width + padding;\n d3sel.attr('transform', `translate(${offset}, 0)`);\n }\n });\n const bounds = ref.current.getBoundingClientRect();\n setXTransform((prev) => prev - bounds.width / 2);\n firstRender.current = false;\n }\n }, []);\n\n const render = useMemo(\n () => (\n <g ref={ref} transform={`translate(${xTransform},30)`}>\n <g ref={setTopLegend}>\n <rect height={40} width={1} fill=\"transparent\" />\n {colorScale.domain().map((domainValue, i) => (\n <
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,WAAW,QAAQ,gBAAgB;AAExE,SAAS,WAAW,cAAc;AAClC,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useEffect, useRef, useState } from 'react';\n\nimport { selectAll, select } from 'd3';\nimport { ChartContext } from '../../ChartContext';\nimport { LegendItem } from './LegendItem';\n\nexport const TopLegend = () => {\n const { colorScale, internalMargin, innerWidth, setTopLegend } = useContext(ChartContext);\n\n const ref = useRef(null);\n const firstRender = useRef(true);\n\n const [xTransform, setXTransform] = useState(innerWidth / 2 + internalMargin.left);\n\n useEffect(() => {\n if (ref.current && firstRender.current) {\n const cells = selectAll('.cell');\n const padding = 40;\n let offset = 0;\n cells.each((d, 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\n const { width } = lastCell.node().getBBox();\n offset += width + padding;\n d3sel.attr('transform', `translate(${offset}, 0)`);\n }\n });\n const bounds = ref.current.getBoundingClientRect();\n setXTransform((prev) => prev - bounds.width / 2);\n firstRender.current = false;\n }\n }, []);\n\n const render = useMemo(\n () => (\n <g ref={ref} transform={`translate(${xTransform},30)`}>\n <g ref={setTopLegend}>\n <rect height={40} width={1} fill=\"transparent\" />\n {colorScale.domain().map((domainValue, i) => (\n <LegendItem key={domainValue} domainValue={domainValue} />\n ))}\n </g>\n </g>\n ),\n\n [colorScale, setTopLegend, xTransform],\n );\n\n return render;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,SAAS,WAAW,QAAQ,gBAAgB;AAExE,SAAS,WAAW,cAAc;AAClC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,YAAY,gBAAgB,YAAY,aAAa,IAAI,WAAW,YAAY;AAExF,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,cAAc,OAAO,IAAI;AAE/B,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,aAAa,IAAI,eAAe,IAAI;AAEjF,YAAU,MAAM;AACd,QAAI,IAAI,WAAW,YAAY,SAAS;AACtC,YAAM,QAAQ,UAAU,OAAO;AAC/B,YAAM,UAAU;AAChB,UAAI,SAAS;AACb,YAAM,KAAK,CAAC,GAAG,MAAM;AACnB,YAAI,MAAM,QAAQ,GAAG,IAAI,IAAI;AAC3B,gBAAM,WAAW,OAAO,MAAM,QAAQ,GAAG,IAAI,EAAE;AAC/C,gBAAM,QAAQ,OAAO,MAAM,QAAQ,GAAG,EAAE;AAExC,gBAAM,EAAE,MAAM,IAAI,SAAS,KAAK,EAAE,QAAQ;AAC1C,oBAAU,QAAQ;AAClB,gBAAM,KAAK,aAAa,aAAa,YAAY;AAAA,QACnD;AAAA,MACF,CAAC;AACD,YAAM,SAAS,IAAI,QAAQ,sBAAsB;AACjD,oBAAc,CAAC,SAAS,OAAO,OAAO,QAAQ,CAAC;AAC/C,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,SAAS;AAAA,IACb,MACE,oBAAC;AAAA,MAAE;AAAA,MAAU,WAAW,aAAa;AAAA,MACnC,+BAAC;AAAA,QAAE,KAAK;AAAA,QACN;AAAA,8BAAC;AAAA,YAAK,QAAQ;AAAA,YAAI,OAAO;AAAA,YAAG,MAAK;AAAA,WAAc;AAAA,UAC9C,WAAW,OAAO,EAAE,IAAI,CAAC,aAAa,MACrC,oBAAC;AAAA,YAA6B;AAAA,aAAb,WAAuC,CACzD;AAAA;AAAA,OACH;AAAA,KACF;AAAA,IAGF,CAAC,YAAY,cAAc,UAAU;AAAA,EACvC;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|