@elliemae/ds-dataviz 3.8.1 → 3.9.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/graphs/Chart/Chart.js.map +2 -2
- package/dist/cjs/graphs/Chart/ChartContext.js +3 -1
- package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useChart.js +86 -33
- package/dist/cjs/graphs/Chart/config/useChart.js.map +3 -3
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js +103 -0
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +25 -15
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +43 -17
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/helpers/index.js +9 -13
- package/dist/cjs/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js +1 -1
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js +17 -25
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js +33 -38
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js +6 -11
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +65 -16
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js +17 -68
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.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 +61 -0
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js +65 -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 +14 -19
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +100 -0
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +31 -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 +39 -17
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +29 -28
- 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/Scroller/ScrollableContainerX.js +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +57 -41
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js +1 -12
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js +29 -27
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js +85 -0
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js +77 -0
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Line.js +23 -19
- package/dist/cjs/graphs/Chart/series/Line.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Point.js +88 -18
- package/dist/cjs/graphs/Chart/series/Point.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Points.js +23 -27
- package/dist/cjs/graphs/Chart/series/Points.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js +105 -8
- package/dist/cjs/graphs/Chart/series/Rect.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/StackedBar.js +23 -30
- package/dist/cjs/graphs/Chart/series/StackedBar.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/cjs/graphs/Chart/styles.js +5 -20
- package/dist/cjs/graphs/Chart/styles.js.map +2 -2
- package/dist/cjs/graphs/constants.js +20 -0
- package/dist/cjs/graphs/constants.js.map +2 -2
- package/dist/esm/graphs/Chart/Chart.js.map +2 -2
- package/dist/esm/graphs/Chart/ChartContext.js +3 -1
- package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChart.js +87 -34
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useInternalMargins.js +77 -0
- package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +26 -16
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useScales.js +44 -18
- package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/index.js +10 -14
- package/dist/esm/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ActivePoint.js +1 -1
- package/dist/esm/graphs/Chart/parts/ActivePoint.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js +18 -26
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js +34 -39
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js +6 -11
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +66 -17
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js +18 -69
- package/dist/esm/graphs/Chart/parts/FocusableRegion.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 +35 -0
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js +39 -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 +16 -21
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +74 -0
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +32 -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 +39 -17
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +29 -28
- 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/Scroller/ScrollableContainerX.js +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js +58 -42
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/esm/graphs/Chart/react-desc-prop-types.js +1 -12
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js +30 -28
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalBars.js +59 -0
- package/dist/esm/graphs/Chart/series/HorizontalBars.js.map +7 -0
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js +51 -0
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Line.js +25 -21
- package/dist/esm/graphs/Chart/series/Line.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Point.js +89 -19
- package/dist/esm/graphs/Chart/series/Point.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Points.js +24 -28
- package/dist/esm/graphs/Chart/series/Points.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js +106 -9
- package/dist/esm/graphs/Chart/series/Rect.js.map +2 -2
- package/dist/esm/graphs/Chart/series/StackedBar.js +24 -31
- package/dist/esm/graphs/Chart/series/StackedBar.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/dist/esm/graphs/Chart/styles.js +5 -20
- package/dist/esm/graphs/Chart/styles.js.map +2 -2
- package/dist/esm/graphs/constants.js +20 -0
- package/dist/esm/graphs/constants.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/graphs/Chart/Chart.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\n\nimport { ChartContainer } from './parts/ChartContainer';\n// import { SeriesFactory } from './parts/SeriesFactory';\n// import { ActivePoint } from './parts/ActivePoint';\n\nimport { ChartContext } from './ChartContext';\nimport { useChart } from './config/useChart';\nimport type { DSChartT } from './react-desc-prop-types';\n\nimport { Axes } from './parts/Axis/Axes';\nexport const Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAEA,4BAA+B;AAI/B,0BAA6B;AAC7B,sBAAyB;AAGzB,kBAAqB;AACd,MAAM,QAA6C,CAAC,UAAU;AACnE,QAAM,UAAM,0BAAS,KAAK;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\n\nimport { ChartContainer } from './parts/ChartContainer';\n// import { SeriesFactory } from './parts/SeriesFactory';\n// import { ActivePoint } from './parts/ActivePoint';\n\nimport { ChartContext } from './ChartContext';\nimport { useChart } from './config/useChart';\nimport type { DSChartT } from './react-desc-prop-types';\n\nimport { Axes } from './parts/Axis/Axes';\nexport const Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n return (\n <ChartContext.Provider value={ctx}>\n <ChartContainer>\n <Axes />\n </ChartContainer>\n </ChartContext.Provider>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAEA,4BAA+B;AAI/B,0BAA6B;AAC7B,sBAAyB;AAGzB,kBAAqB;AACd,MAAM,QAA6C,CAAC,UAAU;AACnE,QAAM,UAAM,0BAAS,KAAK;AAC1B,SACE,4CAAC,iCAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,IAC5B,sDAAC;AAAA,MACC,sDAAC,oBAAK;AAAA,KACR;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,7 +48,9 @@ const defaultContext = {
|
|
|
48
48
|
},
|
|
49
49
|
containerRef: (0, import_react.createRef)(),
|
|
50
50
|
groups: [],
|
|
51
|
-
colorScale: (0, import_d3.scaleOrdinal)()
|
|
51
|
+
colorScale: (0, import_d3.scaleOrdinal)(),
|
|
52
|
+
setLeftAxisRef: () => {
|
|
53
|
+
}
|
|
52
54
|
};
|
|
53
55
|
const ChartContext = (0, import_react.createContext)(defaultContext);
|
|
54
56
|
//# sourceMappingURL=ChartContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/graphs/Chart/ChartContext.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { createContext, createRef } from 'react';\nimport { ScaleLinear, ScaleBand, scaleLinear, scaleBand, scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { defaultProps, DSChartT } from './react-desc-prop-types';\n\ninterface ContextT {\n props:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,gBAA2F;AAC3F,mCAAuC;
|
|
4
|
+
"sourcesContent": ["import { createContext, createRef } from 'react';\nimport { ScaleLinear, ScaleBand, scaleLinear, scaleBand, scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { defaultProps, DSChartT } from './react-desc-prop-types';\n\ninterface ContextT {\n props: DSChartT.Props;\n xScale: ScaleLinear<number, number, never> | ScaleBand<string>;\n yScale: ScaleLinear<number, number, never> | ScaleBand<string>;\n innerHeight: number;\n innerWidth: number;\n activePoint: string;\n setActivePoint: React.Dispatch<React.SetStateAction<string>>;\n activeSerie: string;\n setActiveSerie: React.Dispatch<React.SetStateAction<string>>;\n containerRef: React.RefObject<HTMLDivElement>;\n groups: string[];\n subGroupScale?: ScaleBand<string> | null;\n colorScale: ScaleOrdinal<string, unknown, never>;\n setLeftAxisRef: React.Dispatch<React.SetStateAction<Element | undefined>>;\n axisLeftRef: Element;\n}\n\nconst defaultContext: ContextT = {\n props: defaultProps,\n xScale: scaleBand(),\n yScale: scaleLinear(),\n innerHeight: 0,\n innerWidth: 0,\n activePoint: '',\n setActivePoint: () => {},\n activeSerie: '',\n setActiveSerie: () => {},\n scrapperPosY: '',\n setScrapperPosY: () => {},\n containerRef: createRef<HTMLDivElement>(),\n groups: [],\n colorScale: scaleOrdinal(),\n setLeftAxisRef: () => {},\n};\n\nexport const ChartContext = createContext(defaultContext);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,gBAA2F;AAC3F,mCAAuC;AAoBvC,MAAM,iBAA2B;AAAA,EAC/B,OAAO;AAAA,EACP,YAAQ,qBAAU;AAAA,EAClB,YAAQ,uBAAY;AAAA,EACpB,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,cAAc;AAAA,EACd,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,kBAAc,wBAA0B;AAAA,EACxC,QAAQ,CAAC;AAAA,EACT,gBAAY,wBAAa;AAAA,EACzB,gBAAgB,MAAM;AAAA,EAAC;AACzB;AAEO,MAAM,mBAAe,4BAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,37 +29,45 @@ __export(useChart_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(useChart_exports);
|
|
30
30
|
var React = __toESM(require("react"));
|
|
31
31
|
var import_react = require("react");
|
|
32
|
+
var import_uuid = require("uuid");
|
|
32
33
|
var import_useScales = require("./useScales");
|
|
33
34
|
var import_helpers = require("../helpers");
|
|
35
|
+
var import_useInternalMargins = require("./useInternalMargins");
|
|
34
36
|
const useChart = (props) => {
|
|
35
|
-
const { series, yAxis, width, height, groups: groupsStacked } = props;
|
|
37
|
+
const { series, yAxis, xAxis, width, height, groups: groupsStacked } = props;
|
|
36
38
|
const containerRef = (0, import_react.useRef)(null);
|
|
37
39
|
const svgRef = (0, import_react.useRef)(null);
|
|
38
40
|
const [isGrabbed, setIsGrabbed] = (0, import_react.useState)(false);
|
|
39
41
|
const [startPosition, setStartPosition] = (0, import_react.useState)(0);
|
|
40
|
-
const [activePoint, setActivePoint] = (0, import_react.useState)(
|
|
42
|
+
const [activePoint, setActivePoint] = (0, import_react.useState)(null);
|
|
41
43
|
const [activeSerie, setActiveSerie] = (0, import_react.useState)("");
|
|
42
44
|
const [scrapperPosY, setScrapperPosY] = (0, import_react.useState)("");
|
|
43
45
|
const [scrapperPosX, setScrapperPosX] = (0, import_react.useState)("");
|
|
44
46
|
const [xScrollbarPosition, setXScrollbarPosition] = (0, import_react.useState)(0);
|
|
45
47
|
const [isScrollbarVisible, setIsScrollbarVisible] = (0, import_react.useState)(false);
|
|
46
48
|
const oldLastPosition = (0, import_react.useRef)(0);
|
|
47
|
-
const [
|
|
48
|
-
const [
|
|
49
|
-
const [
|
|
50
|
-
const [leftLegend, setLeftLegend] = (0, import_react.useState)(
|
|
51
|
-
const [rightLegend, setRightLegend] = (0, import_react.useState)(
|
|
52
|
-
const [topLegend, setTopLegend] = (0, import_react.useState)(
|
|
53
|
-
const [bottomLegend, setBottomLegend] = (0, import_react.useState)(
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
const [axisLeftRef, setAxisLeftRef] = (0, import_react.useState)();
|
|
50
|
+
const [axisBottomRef, setAxisBottomRef] = (0, import_react.useState)();
|
|
51
|
+
const [axisRightRef, setAxisRightRef] = (0, import_react.useState)();
|
|
52
|
+
const [leftLegend, setLeftLegend] = (0, import_react.useState)();
|
|
53
|
+
const [rightLegend, setRightLegend] = (0, import_react.useState)();
|
|
54
|
+
const [topLegend, setTopLegend] = (0, import_react.useState)();
|
|
55
|
+
const [bottomLegend, setBottomLegend] = (0, import_react.useState)();
|
|
56
|
+
const [rightLabel, setRightLabel] = (0, import_react.useState)();
|
|
57
|
+
const [leftLabel, setLeftLabel] = (0, import_react.useState)();
|
|
58
|
+
const [bottomLabel, setBottomLabel] = (0, import_react.useState)();
|
|
59
|
+
const { axisBottomHeight, axisRightWidth, bottomLabelHeight, internalMargin, leftLegendWidth, rightLabelWidth } = (0, import_useInternalMargins.useInternalMargins)({
|
|
60
|
+
axisLeftRef,
|
|
61
|
+
axisBottomRef,
|
|
62
|
+
axisRightRef,
|
|
63
|
+
leftLabel,
|
|
64
|
+
leftLegend,
|
|
65
|
+
rightLegend,
|
|
66
|
+
topLegend,
|
|
67
|
+
bottomLegend,
|
|
68
|
+
rightLabel,
|
|
69
|
+
bottomLabel
|
|
70
|
+
});
|
|
63
71
|
const innerWidth = (0, import_react.useMemo)(
|
|
64
72
|
() => width - internalMargin.left - internalMargin.right,
|
|
65
73
|
[internalMargin.left, internalMargin.right, width]
|
|
@@ -68,10 +76,7 @@ const useChart = (props) => {
|
|
|
68
76
|
() => height - internalMargin.top - internalMargin.bottom,
|
|
69
77
|
[internalMargin.top, internalMargin.bottom, height]
|
|
70
78
|
);
|
|
71
|
-
const
|
|
72
|
-
const stackedData = (0, import_react.useMemo)(() => (0, import_helpers.stackData)(groupsStacked, series), [groupsStacked, series]);
|
|
73
|
-
const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? 1;
|
|
74
|
-
const currentData = (0, import_react.useMemo)(
|
|
79
|
+
const [currentData, setCurrentData] = (0, import_react.useState)(
|
|
75
80
|
() => series.map((d, i) => ({
|
|
76
81
|
...d,
|
|
77
82
|
originalData: d,
|
|
@@ -80,9 +85,15 @@ const useChart = (props) => {
|
|
|
80
85
|
key: `${d.name}-${i}-${index}`,
|
|
81
86
|
value,
|
|
82
87
|
position: index
|
|
83
|
-
}))
|
|
84
|
-
}))
|
|
85
|
-
|
|
88
|
+
})).filter((datum) => datum.value !== null)
|
|
89
|
+
}))
|
|
90
|
+
);
|
|
91
|
+
const stackedData = (0, import_react.useMemo)(() => (0, import_helpers.stackData)(groupsStacked, currentData), [groupsStacked, currentData]);
|
|
92
|
+
const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? 1;
|
|
93
|
+
const groups = (0, import_react.useMemo)(() => currentData.map((serie) => serie.name), [currentData]);
|
|
94
|
+
const visibleGroups = (0, import_react.useMemo)(
|
|
95
|
+
() => currentData.filter((serie) => !serie.isHidden).map((serie) => serie.name),
|
|
96
|
+
[currentData]
|
|
86
97
|
);
|
|
87
98
|
const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = (0, import_useScales.useScales)({
|
|
88
99
|
props,
|
|
@@ -93,12 +104,23 @@ const useChart = (props) => {
|
|
|
93
104
|
currentData,
|
|
94
105
|
containerRatio
|
|
95
106
|
});
|
|
107
|
+
const isHorizontal = (0, import_react.useMemo)(() => !!yScale.bandwidth, [yScale]);
|
|
108
|
+
const getXValue = (0, import_react.useCallback)(
|
|
109
|
+
(datum) => !isHorizontal ? xAxis?.cols?.[datum.position] ?? datum.value.x ?? datum.position : datum.value.x ?? datum.value,
|
|
110
|
+
[isHorizontal, xAxis?.cols]
|
|
111
|
+
);
|
|
112
|
+
const getYValue = (0, import_react.useCallback)(
|
|
113
|
+
(datum) => !isHorizontal ? datum.value?.y ?? datum.value : yAxis?.cols?.[datum.position] ?? datum.value.x ?? datum.position,
|
|
114
|
+
[isHorizontal, yAxis?.cols]
|
|
115
|
+
);
|
|
116
|
+
const chartId = (0, import_react.useMemo)(() => (0, import_uuid.v4)(), []);
|
|
96
117
|
return (0, import_react.useMemo)(
|
|
97
118
|
() => ({
|
|
98
119
|
props: { ...props, data: currentData },
|
|
99
120
|
innerHeight,
|
|
100
121
|
innerWidth,
|
|
101
122
|
groups,
|
|
123
|
+
visibleGroups,
|
|
102
124
|
colorScale,
|
|
103
125
|
stackedData,
|
|
104
126
|
subGroupScale,
|
|
@@ -127,15 +149,30 @@ const useChart = (props) => {
|
|
|
127
149
|
oldLastPosition,
|
|
128
150
|
containerRatio,
|
|
129
151
|
internalMargin,
|
|
130
|
-
|
|
152
|
+
axisLeftRef,
|
|
153
|
+
leftLegendWidth,
|
|
131
154
|
leftLegend,
|
|
132
|
-
|
|
155
|
+
setAxisLeftRef,
|
|
133
156
|
setLeftLegend,
|
|
134
157
|
setRightLegend,
|
|
158
|
+
rightLegend,
|
|
135
159
|
setTopLegend,
|
|
136
160
|
setBottomLegend,
|
|
137
|
-
|
|
138
|
-
|
|
161
|
+
setAxisBottomRef,
|
|
162
|
+
axisBottomHeight,
|
|
163
|
+
setAxisRightRef,
|
|
164
|
+
setRightLabel,
|
|
165
|
+
setBottomLabel,
|
|
166
|
+
bottomLabelHeight,
|
|
167
|
+
rightLabelWidth,
|
|
168
|
+
axisRightWidth,
|
|
169
|
+
getXValue,
|
|
170
|
+
getYValue,
|
|
171
|
+
isHorizontal,
|
|
172
|
+
setCurrentData,
|
|
173
|
+
setLeftLabel,
|
|
174
|
+
leftLabel,
|
|
175
|
+
chartId
|
|
139
176
|
}),
|
|
140
177
|
[
|
|
141
178
|
props,
|
|
@@ -143,6 +180,7 @@ const useChart = (props) => {
|
|
|
143
180
|
innerHeight,
|
|
144
181
|
innerWidth,
|
|
145
182
|
groups,
|
|
183
|
+
visibleGroups,
|
|
146
184
|
colorScale,
|
|
147
185
|
stackedData,
|
|
148
186
|
subGroupScale,
|
|
@@ -161,20 +199,35 @@ const useChart = (props) => {
|
|
|
161
199
|
setIsGrabbed,
|
|
162
200
|
startPosition,
|
|
163
201
|
setStartPosition,
|
|
202
|
+
rightLabelWidth,
|
|
203
|
+
rightLegend,
|
|
204
|
+
bottomLabelHeight,
|
|
164
205
|
isScrollbarVisible,
|
|
165
206
|
setIsScrollbarVisible,
|
|
166
207
|
oldLastPosition,
|
|
167
208
|
containerRatio,
|
|
168
209
|
internalMargin,
|
|
169
|
-
|
|
210
|
+
axisBottomHeight,
|
|
211
|
+
axisLeftRef,
|
|
212
|
+
leftLegendWidth,
|
|
170
213
|
leftLegend,
|
|
171
|
-
|
|
214
|
+
setAxisLeftRef,
|
|
172
215
|
setLeftLegend,
|
|
173
216
|
setRightLegend,
|
|
174
217
|
setTopLegend,
|
|
175
218
|
setBottomLegend,
|
|
176
|
-
|
|
177
|
-
|
|
219
|
+
setAxisBottomRef,
|
|
220
|
+
setAxisRightRef,
|
|
221
|
+
setRightLabel,
|
|
222
|
+
setBottomLabel,
|
|
223
|
+
getXValue,
|
|
224
|
+
getYValue,
|
|
225
|
+
isHorizontal,
|
|
226
|
+
setCurrentData,
|
|
227
|
+
axisRightWidth,
|
|
228
|
+
setLeftLabel,
|
|
229
|
+
leftLabel,
|
|
230
|
+
chartId
|
|
178
231
|
]
|
|
179
232
|
);
|
|
180
233
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/config/useChart.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-nested-callbacks */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useState, useRef,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-nested-callbacks */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useState, useRef, useCallback } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\n// import { useValidateTypescriptPropTypes } from '@elliemae/ds-utilities';\nimport type { DSChartT } from '../react-desc-prop-types';\n// import { propTypes } from '../react-desc-prop-types';\nimport { useScales } from './useScales';\nimport { stackData } from '../helpers';\nimport { useInternalMargins } from './useInternalMargins';\nexport const useChart = (props: DSChartT.Props) => {\n // useValidateTypescriptPropTypes(props, propTypes);\n\n const { series, yAxis, xAxis, width, height, groups: groupsStacked } = props;\n\n const containerRef = useRef(null);\n const svgRef = useRef(null);\n\n const [isGrabbed, setIsGrabbed] = useState(false);\n const [startPosition, setStartPosition] = useState(0);\n\n const [activePoint, setActivePoint] = useState(null);\n const [activeSerie, setActiveSerie] = useState('');\n const [scrapperPosY, setScrapperPosY] = useState('');\n const [scrapperPosX, setScrapperPosX] = useState('');\n const [xScrollbarPosition, setXScrollbarPosition] = useState(0);\n const [isScrollbarVisible, setIsScrollbarVisible] = useState(false);\n const oldLastPosition = useRef(0);\n\n const [axisLeftRef, setAxisLeftRef] = useState<Element>();\n const [axisBottomRef, setAxisBottomRef] = useState<Element>();\n const [axisRightRef, setAxisRightRef] = useState<Element>();\n\n const [leftLegend, setLeftLegend] = useState<Element>();\n const [rightLegend, setRightLegend] = useState<Element>();\n const [topLegend, setTopLegend] = useState<Element>();\n const [bottomLegend, setBottomLegend] = useState<Element>();\n\n const [rightLabel, setRightLabel] = useState<Element>();\n const [leftLabel, setLeftLabel] = useState<Element>();\n const [bottomLabel, setBottomLabel] = useState<Element>();\n\n const { axisBottomHeight, axisRightWidth, bottomLabelHeight, internalMargin, leftLegendWidth, rightLabelWidth } =\n useInternalMargins({\n axisLeftRef,\n axisBottomRef,\n axisRightRef,\n leftLabel,\n leftLegend,\n rightLegend,\n topLegend,\n bottomLegend,\n rightLabel,\n bottomLabel,\n });\n const innerWidth = useMemo(\n () => width - internalMargin.left - internalMargin.right,\n [internalMargin.left, internalMargin.right, width],\n );\n const innerHeight = useMemo(\n () => height - internalMargin.top - internalMargin.bottom,\n [internalMargin.top, internalMargin.bottom, height],\n );\n\n const [currentData, setCurrentData] = useState(() =>\n series.map((d, i) => ({\n ...d,\n originalData: d,\n key: `${d.name}-${i}`,\n data: d.data\n .map((value, index) => ({\n key: `${d.name}-${i}-${index}`,\n value,\n position: index,\n }))\n .filter((datum) => datum.value !== null),\n })),\n );\n const stackedData = useMemo(() => stackData(groupsStacked, currentData), [groupsStacked, currentData]);\n // @TODO we need to create a logic to get this from both axis\n const containerRatio = (props?.xAxis.advanced?.pointSpacing?.value as number) ?? 1;\n\n const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);\n\n const visibleGroups = useMemo(\n () => currentData.filter((serie) => !serie.isHidden).map((serie) => serie.name),\n [currentData],\n );\n\n const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = useScales({\n props,\n innerHeight,\n innerWidth,\n groups,\n stackedData,\n currentData,\n containerRatio,\n });\n\n const isHorizontal = useMemo(() => !!yScale.bandwidth, [yScale]);\n\n const getXValue = useCallback(\n (datum) =>\n !isHorizontal ? xAxis?.cols?.[datum.position] ?? datum.value.x ?? datum.position : datum.value.x ?? datum.value,\n [isHorizontal, xAxis?.cols],\n );\n\n const getYValue = useCallback(\n (datum) =>\n !isHorizontal ? datum.value?.y ?? datum.value : yAxis?.cols?.[datum.position] ?? datum.value.x ?? datum.position,\n [isHorizontal, yAxis?.cols],\n );\n\n const chartId = useMemo(() => uuidv4(), []);\n\n return useMemo(\n () => ({\n props: { ...props, data: currentData },\n innerHeight,\n innerWidth,\n // @todo change this to series and visible series\n groups,\n visibleGroups,\n colorScale,\n stackedData,\n subGroupScale,\n svgRef,\n xScale,\n yScale,\n y2Scale,\n containerRef,\n getBandwidth,\n scrapperPosY,\n setScrapperPosY,\n scrapperPosX,\n setScrapperPosX,\n activePoint,\n setActivePoint,\n activeSerie,\n setActiveSerie,\n xScrollbarPosition,\n setXScrollbarPosition,\n isGrabbed,\n setIsGrabbed,\n startPosition,\n setStartPosition,\n isScrollbarVisible,\n setIsScrollbarVisible,\n oldLastPosition,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n setAxisLeftRef,\n setLeftLegend,\n setRightLegend,\n rightLegend,\n setTopLegend,\n setBottomLegend,\n setAxisBottomRef,\n axisBottomHeight,\n setAxisRightRef,\n setRightLabel,\n setBottomLabel,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n setCurrentData,\n setLeftLabel,\n leftLabel,\n chartId,\n }),\n [\n props,\n currentData,\n innerHeight,\n innerWidth,\n groups,\n visibleGroups,\n colorScale,\n stackedData,\n subGroupScale,\n scrapperPosX,\n setScrapperPosX,\n xScale,\n yScale,\n y2Scale,\n getBandwidth,\n scrapperPosY,\n activePoint,\n activeSerie,\n xScrollbarPosition,\n setXScrollbarPosition,\n isGrabbed,\n setIsGrabbed,\n startPosition,\n setStartPosition,\n rightLabelWidth,\n rightLegend,\n bottomLabelHeight,\n isScrollbarVisible,\n setIsScrollbarVisible,\n oldLastPosition,\n containerRatio,\n internalMargin,\n axisBottomHeight,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n setAxisLeftRef,\n setLeftLegend,\n setRightLegend,\n setTopLegend,\n setBottomLegend,\n setAxisBottomRef,\n setAxisRightRef,\n setRightLabel,\n setBottomLabel,\n getXValue,\n getYValue,\n isHorizontal,\n setCurrentData,\n axisRightWidth,\n setLeftLabel,\n leftLabel,\n chartId,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAuD;AACvD,kBAA6B;AAI7B,uBAA0B;AAC1B,qBAA0B;AAC1B,gCAAmC;AAC5B,MAAM,WAAW,CAAC,UAA0B;AAGjD,QAAM,EAAE,QAAQ,OAAO,OAAO,OAAO,QAAQ,QAAQ,cAAc,IAAI;AAEvE,QAAM,mBAAe,qBAAO,IAAI;AAChC,QAAM,aAAS,qBAAO,IAAI;AAE1B,QAAM,CAAC,WAAW,YAAY,QA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AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["uuidv4"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var useInternalMargins_exports = {};
|
|
26
|
+
__export(useInternalMargins_exports, {
|
|
27
|
+
useInternalMargins: () => useInternalMargins
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useInternalMargins_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
const useInternalMargins = ({
|
|
33
|
+
axisLeftRef,
|
|
34
|
+
axisBottomRef,
|
|
35
|
+
axisRightRef,
|
|
36
|
+
leftLabel,
|
|
37
|
+
leftLegend,
|
|
38
|
+
rightLegend,
|
|
39
|
+
topLegend,
|
|
40
|
+
bottomLegend,
|
|
41
|
+
rightLabel,
|
|
42
|
+
bottomLabel
|
|
43
|
+
}) => {
|
|
44
|
+
const axisLeftWidth = (0, import_react.useMemo)(() => axisLeftRef?.getBoundingClientRect()?.width || 0, [axisLeftRef]);
|
|
45
|
+
const axisBottomHeight = (0, import_react.useMemo)(() => axisBottomRef?.getBoundingClientRect()?.height || 0, [axisBottomRef]);
|
|
46
|
+
const axisRightWidth = (0, import_react.useMemo)(() => axisRightRef?.getBoundingClientRect()?.width || 0, [axisRightRef]);
|
|
47
|
+
const bottomLabelHeight = (0, import_react.useMemo)(() => bottomLabel?.getBoundingClientRect()?.height || 0, [bottomLabel]);
|
|
48
|
+
const rightLabelWidth = (0, import_react.useMemo)(() => rightLabel?.getBoundingClientRect()?.width || 0, [rightLabel]);
|
|
49
|
+
const leftLabelWidth = (0, import_react.useMemo)(() => leftLabel?.getBoundingClientRect()?.width || 0, [leftLabel]);
|
|
50
|
+
const topLegendHeight = (0, import_react.useMemo)(() => topLegend?.getBoundingClientRect()?.height || 0, [topLegend]);
|
|
51
|
+
const bottomLegendHeight = (0, import_react.useMemo)(() => bottomLegend?.getBoundingClientRect()?.height || 0, [bottomLegend]);
|
|
52
|
+
const rightLegendWidth = (0, import_react.useMemo)(() => rightLegend?.getBoundingClientRect()?.width || 0, [rightLegend]);
|
|
53
|
+
const leftLegendWidth = (0, import_react.useMemo)(() => leftLegend?.getBoundingClientRect()?.width || 0, [leftLegend]);
|
|
54
|
+
const internalMargin = (0, import_react.useMemo)(
|
|
55
|
+
() => ({
|
|
56
|
+
bottom: 10 + axisBottomHeight + bottomLegendHeight + bottomLabelHeight,
|
|
57
|
+
top: 10 + topLegendHeight,
|
|
58
|
+
right: 10 + rightLabelWidth + axisRightWidth + rightLegendWidth,
|
|
59
|
+
left: 10 + axisLeftWidth + leftLabelWidth + leftLegendWidth
|
|
60
|
+
}),
|
|
61
|
+
[
|
|
62
|
+
axisBottomHeight,
|
|
63
|
+
bottomLegendHeight,
|
|
64
|
+
bottomLabelHeight,
|
|
65
|
+
topLegendHeight,
|
|
66
|
+
rightLabelWidth,
|
|
67
|
+
axisRightWidth,
|
|
68
|
+
rightLegendWidth,
|
|
69
|
+
axisLeftWidth,
|
|
70
|
+
leftLabelWidth,
|
|
71
|
+
leftLegendWidth
|
|
72
|
+
]
|
|
73
|
+
);
|
|
74
|
+
return (0, import_react.useMemo)(
|
|
75
|
+
() => ({
|
|
76
|
+
internalMargin,
|
|
77
|
+
leftLegendWidth,
|
|
78
|
+
axisBottomHeight,
|
|
79
|
+
bottomLegendHeight,
|
|
80
|
+
bottomLabelHeight,
|
|
81
|
+
topLegendHeight,
|
|
82
|
+
rightLabelWidth,
|
|
83
|
+
axisRightWidth,
|
|
84
|
+
rightLegendWidth,
|
|
85
|
+
axisLeftWidth,
|
|
86
|
+
leftLabelWidth
|
|
87
|
+
}),
|
|
88
|
+
[
|
|
89
|
+
axisBottomHeight,
|
|
90
|
+
axisLeftWidth,
|
|
91
|
+
axisRightWidth,
|
|
92
|
+
bottomLabelHeight,
|
|
93
|
+
bottomLegendHeight,
|
|
94
|
+
internalMargin,
|
|
95
|
+
leftLabelWidth,
|
|
96
|
+
leftLegendWidth,
|
|
97
|
+
rightLabelWidth,
|
|
98
|
+
rightLegendWidth,
|
|
99
|
+
topLegendHeight
|
|
100
|
+
]
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=useInternalMargins.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/graphs/Chart/config/useInternalMargins.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo } from 'react';\n\ninterface UseInternalMarginsT {\n axisLeftRef?: Element;\n axisBottomRef?: Element;\n axisRightRef?: Element;\n leftLegend?: Element;\n leftLabel?: Element;\n rightLegend?: Element;\n topLegend?: Element;\n bottomLegend?: Element;\n rightLabel?: Element;\n bottomLabel?: Element;\n}\nexport const useInternalMargins = ({\n axisLeftRef,\n axisBottomRef,\n axisRightRef,\n leftLabel,\n leftLegend,\n rightLegend,\n topLegend,\n bottomLegend,\n rightLabel,\n bottomLabel,\n}: UseInternalMarginsT) => {\n // Axis\n const axisLeftWidth = useMemo(() => axisLeftRef?.getBoundingClientRect()?.width || 0, [axisLeftRef]);\n const axisBottomHeight = useMemo(() => axisBottomRef?.getBoundingClientRect()?.height || 0, [axisBottomRef]);\n const axisRightWidth = useMemo(() => axisRightRef?.getBoundingClientRect()?.width || 0, [axisRightRef]);\n\n // Labels\n const bottomLabelHeight = useMemo(() => bottomLabel?.getBoundingClientRect()?.height || 0, [bottomLabel]);\n const rightLabelWidth = useMemo(() => rightLabel?.getBoundingClientRect()?.width || 0, [rightLabel]);\n const leftLabelWidth = useMemo(() => leftLabel?.getBoundingClientRect()?.width || 0, [leftLabel]);\n\n // Legends\n const topLegendHeight = useMemo(() => topLegend?.getBoundingClientRect()?.height || 0, [topLegend]);\n const bottomLegendHeight = useMemo(() => bottomLegend?.getBoundingClientRect()?.height || 0, [bottomLegend]);\n const rightLegendWidth = useMemo(() => rightLegend?.getBoundingClientRect()?.width || 0, [rightLegend]);\n const leftLegendWidth = useMemo(() => leftLegend?.getBoundingClientRect()?.width || 0, [leftLegend]);\n // @todo create a useInternalMargin\n const internalMargin = useMemo(\n () => ({\n bottom: 10 + axisBottomHeight + bottomLegendHeight + bottomLabelHeight,\n top: 10 + topLegendHeight,\n right: 10 + rightLabelWidth + axisRightWidth + rightLegendWidth,\n left: 10 + axisLeftWidth + leftLabelWidth + leftLegendWidth,\n }),\n\n [\n axisBottomHeight,\n bottomLegendHeight,\n bottomLabelHeight,\n topLegendHeight,\n rightLabelWidth,\n axisRightWidth,\n rightLegendWidth,\n axisLeftWidth,\n leftLabelWidth,\n leftLegendWidth,\n ],\n );\n\n return useMemo(\n () => ({\n internalMargin,\n leftLegendWidth,\n axisBottomHeight,\n bottomLegendHeight,\n bottomLabelHeight,\n topLegendHeight,\n rightLabelWidth,\n axisRightWidth,\n rightLegendWidth,\n axisLeftWidth,\n leftLabelWidth,\n }),\n [\n axisBottomHeight,\n axisLeftWidth,\n axisRightWidth,\n bottomLabelHeight,\n bottomLegendHeight,\n internalMargin,\n leftLabelWidth,\n leftLegendWidth,\n rightLabelWidth,\n rightLegendWidth,\n topLegendHeight,\n ],\n );\n};\n\n// const [axisLeftRef, setAxisLeftRef] = useState<Element>();\n// const [axisBottomRef, setAxisBottomRef] = useState<Element>();\n// const [axisRightRef, setAxisRightRef] = useState<Element>();\n\n// const [leftLegend, setLeftLegend] = useState<Element>();\n// const [rightLegend, setRightLegend] = useState<Element>();\n// const [topLegend, setTopLegend] = useState<Element>();\n// const [bottomLegend, setBottomLegend] = useState<Element>();\n\n// const [rightLabel, setRightLabel] = useState<Element>();\n// const [leftLabel, setLeftLabel] = useState<Element>();\n// const [bottomLabel, setBottomLabel] = useState<Element>();\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAwB;AAcjB,MA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;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -43,25 +43,29 @@ const useKeyboardNavigation = () => {
|
|
|
43
43
|
activePoint,
|
|
44
44
|
setActivePoint,
|
|
45
45
|
containerRef,
|
|
46
|
-
|
|
46
|
+
visibleGroups,
|
|
47
47
|
yScale,
|
|
48
48
|
xScale,
|
|
49
49
|
setXScrollbarPosition,
|
|
50
50
|
containerRatio,
|
|
51
51
|
xScrollbarPosition,
|
|
52
52
|
innerWidth,
|
|
53
|
+
getXValue,
|
|
53
54
|
props: { data, xAxis }
|
|
54
55
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
55
|
-
const [currentFocusedDataset, setCurrentFocusedDataset] = (0, import_react.useState)(
|
|
56
|
+
const [currentFocusedDataset, setCurrentFocusedDataset] = (0, import_react.useState)(visibleGroups[0]);
|
|
57
|
+
(0, import_react.useEffect)(() => {
|
|
58
|
+
setCurrentFocusedDataset(visibleGroups[0]);
|
|
59
|
+
}, [visibleGroups]);
|
|
56
60
|
const currentGroup = (0, import_react.useMemo)(() => data.find((d) => d.name === currentFocusedDataset), [currentFocusedDataset, data]);
|
|
57
61
|
const currentItemIndex = (0, import_react.useMemo)(
|
|
58
|
-
() => currentGroup.data.findIndex((opt) => opt.key === activePoint),
|
|
62
|
+
() => currentGroup.data.findIndex((opt) => opt.key === activePoint?.key),
|
|
59
63
|
[activePoint, currentGroup]
|
|
60
64
|
);
|
|
61
65
|
const handleOnFocus = (0, import_react.useCallback)(
|
|
62
66
|
(e) => {
|
|
63
67
|
if (containerRef?.current === e.target) {
|
|
64
|
-
setActivePoint(currentGroup.data[0]
|
|
68
|
+
setActivePoint(currentGroup.data[0]);
|
|
65
69
|
setXScrollbarPosition(0);
|
|
66
70
|
}
|
|
67
71
|
},
|
|
@@ -70,7 +74,7 @@ const useKeyboardNavigation = () => {
|
|
|
70
74
|
const handleOnBlur = (0, import_react.useCallback)(() => {
|
|
71
75
|
setTimeout(() => {
|
|
72
76
|
if (!containerRef?.current?.contains(document.activeElement) || containerRef?.current === document.activeElement) {
|
|
73
|
-
setActivePoint(
|
|
77
|
+
setActivePoint(null);
|
|
74
78
|
}
|
|
75
79
|
});
|
|
76
80
|
}, [containerRef, setActivePoint]);
|
|
@@ -81,14 +85,20 @@ const useKeyboardNavigation = () => {
|
|
|
81
85
|
currentItemIndex,
|
|
82
86
|
step
|
|
83
87
|
);
|
|
84
|
-
setActivePoint(currentGroup.data[newValue]
|
|
88
|
+
setActivePoint(currentGroup.data[newValue]);
|
|
85
89
|
if (containerRatio > 1) {
|
|
86
|
-
const xValue = xScale(
|
|
90
|
+
const xValue = xScale(getXValue(currentGroup.data[newValue]));
|
|
91
|
+
const barWidth = innerWidth / containerRatio;
|
|
87
92
|
const total = innerWidth * containerRatio;
|
|
88
93
|
if (total <= xValue) {
|
|
89
94
|
setXScrollbarPosition((total - innerWidth) / containerRatio);
|
|
90
95
|
} else if (xValue > xScrollbarPosition * containerRatio + innerWidth)
|
|
91
|
-
setXScrollbarPosition((prev) =>
|
|
96
|
+
setXScrollbarPosition((prev) => {
|
|
97
|
+
const nextPosition = prev + (xValue / containerRatio - prev);
|
|
98
|
+
if (nextPosition + barWidth > innerWidth)
|
|
99
|
+
return innerWidth - barWidth;
|
|
100
|
+
return nextPosition;
|
|
101
|
+
});
|
|
92
102
|
else if (xValue < xScrollbarPosition * containerRatio)
|
|
93
103
|
setXScrollbarPosition(xValue / containerRatio);
|
|
94
104
|
}
|
|
@@ -97,10 +107,10 @@ const useKeyboardNavigation = () => {
|
|
|
97
107
|
containerRatio,
|
|
98
108
|
currentGroup.data,
|
|
99
109
|
currentItemIndex,
|
|
110
|
+
getXValue,
|
|
100
111
|
innerWidth,
|
|
101
112
|
setActivePoint,
|
|
102
113
|
setXScrollbarPosition,
|
|
103
|
-
xAxis.cols,
|
|
104
114
|
xScale,
|
|
105
115
|
xScrollbarPosition
|
|
106
116
|
]
|
|
@@ -109,16 +119,16 @@ const useKeyboardNavigation = () => {
|
|
|
109
119
|
(step) => {
|
|
110
120
|
setCurrentFocusedDataset((prev) => {
|
|
111
121
|
const nextGroup = findInCircularList(
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
visibleGroups,
|
|
123
|
+
visibleGroups.findIndex((item) => item === prev),
|
|
114
124
|
step
|
|
115
125
|
);
|
|
116
|
-
const nextGroupData = data.find((d) => d.name ===
|
|
117
|
-
setActivePoint(nextGroupData.data[currentItemIndex].
|
|
118
|
-
return
|
|
126
|
+
const nextGroupData = data.find((d) => d.name === visibleGroups[nextGroup]);
|
|
127
|
+
setActivePoint(nextGroupData.data[currentItemIndex] ?? nextGroupData.data[0]);
|
|
128
|
+
return visibleGroups[nextGroup];
|
|
119
129
|
});
|
|
120
130
|
},
|
|
121
|
-
[currentItemIndex, data, setActivePoint,
|
|
131
|
+
[currentItemIndex, data, setActivePoint, visibleGroups]
|
|
122
132
|
);
|
|
123
133
|
const onInputKeyDown = (0, import_react.useCallback)(
|
|
124
134
|
(e) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/config/useKeyboardNavigation.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useMemo, useState } from 'react';\nimport { ChartContext } from '../ChartContext';\n\nexport const findInCircularList = (\n list,\n from: number,\n //criteria: (item) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n if (list[i]) return i;\n }\n return from; // return same item\n};\n\nexport const useKeyboardNavigation = () => {\n const {\n activePoint,\n setActivePoint,\n containerRef,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport { ChartContext } from '../ChartContext';\n\nexport const findInCircularList = (\n list,\n from: number,\n //criteria: (item) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n if (list[i]) return i;\n }\n return from; // return same item\n};\n\nexport const useKeyboardNavigation = () => {\n const {\n activePoint,\n setActivePoint,\n containerRef,\n visibleGroups,\n yScale,\n xScale,\n setXScrollbarPosition,\n containerRatio,\n xScrollbarPosition,\n innerWidth,\n getXValue,\n props: { data, xAxis },\n } = useContext(ChartContext);\n\n const [currentFocusedDataset, setCurrentFocusedDataset] = useState(visibleGroups[0]);\n\n useEffect(() => {\n setCurrentFocusedDataset(visibleGroups[0]);\n }, [visibleGroups]);\n\n const currentGroup = useMemo(() => data.find((d) => d.name === currentFocusedDataset), [currentFocusedDataset, data]);\n\n const currentItemIndex = useMemo(\n () => currentGroup.data.findIndex((opt) => opt.key === activePoint?.key),\n [activePoint, currentGroup],\n );\n\n const handleOnFocus: React.FocusEventHandler<HTMLDivElement> = useCallback(\n (e) => {\n if (containerRef?.current === e.target) {\n setActivePoint(currentGroup.data[0]);\n setXScrollbarPosition(0);\n }\n },\n [containerRef, currentGroup.data, setActivePoint, setXScrollbarPosition],\n );\n\n const handleOnBlur: React.FocusEventHandler<HTMLInputElement> = useCallback(() => {\n setTimeout(() => {\n if (\n !containerRef?.current?.contains(document.activeElement) ||\n containerRef?.current === document.activeElement\n ) {\n setActivePoint(null);\n }\n });\n }, [containerRef, setActivePoint]);\n\n const navigateSerie = useCallback(\n (step: number) => {\n const newValue = findInCircularList(\n currentGroup.data.map((d) => d.value.toString()),\n currentItemIndex,\n step,\n );\n setActivePoint(currentGroup.data[newValue]);\n if (containerRatio > 1) {\n const xValue = xScale(getXValue(currentGroup.data[newValue]));\n const barWidth = innerWidth / containerRatio;\n const total = innerWidth * containerRatio;\n if (total <= xValue) {\n // to go from the first to last\n setXScrollbarPosition((total - innerWidth) / containerRatio);\n } else if (xValue > xScrollbarPosition * containerRatio + innerWidth)\n // if is not visible we move the scroll to the next best position\n setXScrollbarPosition((prev) => {\n const nextPosition = prev + (xValue / containerRatio - prev);\n if (nextPosition + barWidth > innerWidth) return innerWidth - barWidth;\n return nextPosition;\n });\n // move backwards\n else if (xValue < xScrollbarPosition * containerRatio) setXScrollbarPosition(xValue / containerRatio);\n }\n },\n [\n containerRatio,\n currentGroup.data,\n currentItemIndex,\n getXValue,\n innerWidth,\n setActivePoint,\n setXScrollbarPosition,\n xScale,\n xScrollbarPosition,\n ],\n );\n\n const changeSerie = useCallback(\n (step: number) => {\n setCurrentFocusedDataset((prev) => {\n const nextGroup = findInCircularList(\n visibleGroups,\n visibleGroups.findIndex((item) => item === prev),\n step,\n );\n const nextGroupData = data.find((d) => d.name === visibleGroups[nextGroup]);\n setActivePoint(nextGroupData.data[currentItemIndex] ?? nextGroupData.data[0]);\n return visibleGroups[nextGroup];\n });\n },\n [currentItemIndex, data, setActivePoint, visibleGroups],\n );\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n if (e.code !== 'Tab') {\n e.preventDefault();\n }\n if (['ArrowLeft', 'ArrowRight'].includes(e.code)) {\n if (yScale.bandwidth) changeSerie(e.code === 'ArrowLeft' ? -1 : 1);\n else navigateSerie(e.code === 'ArrowLeft' ? -1 : 1);\n }\n\n if (['ArrowDown', 'ArrowUp'].includes(e.code)) {\n if (yScale.bandwidth) navigateSerie(e.code === 'ArrowDown' ? -1 : 1);\n else changeSerie(e.code === 'ArrowDown' ? -1 : 1);\n }\n },\n [changeSerie, navigateSerie, yScale.bandwidth],\n );\n\n return useMemo(\n () => ({ onInputKeyDown, handleOnBlur, handleOnFocus }),\n [handleOnBlur, handleOnFocus, onInputKeyDown],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAsE;AACtE,0BAA6B;AAEtB,MAAM,qBAAqB,CAChC,MACA,MAEA,OAAO,MAEI;AACX,WACM,KAAK,OAAO,OAAO,KAAK,UAAU,KAAK,QAC3C,MAAM,QAAQ,OAAO,IACrB,KAAK,IAAI,OAAO,KAAK,UAAU,KAAK,QACpC;AACA,QAAI,KAAK;AAAI,aAAO;AAAA,EACtB;AACA,SAAO;AACT;AAEO,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,MAAM,MAAM;AAAA,EACvB,QAAI,yBAAW,gCAAY;AAE3B,QAAM,CAAC,uBAAuB,wBAAwB,QAAI,uBAAS,cAAc,EAAE;AAEnF,8BAAU,MAAM;AACd,6BAAyB,cAAc,EAAE;AAAA,EAC3C,GAAG,CA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