@elliemae/ds-dataviz 3.9.0 → 3.10.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/Chart.js +1 -4
- package/dist/cjs/graphs/Chart/Chart.js.map +2 -2
- package/dist/cjs/graphs/Chart/ChartContext.js +1 -4
- package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useChart.js +26 -22
- package/dist/cjs/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useGetters.js +90 -0
- package/dist/cjs/graphs/Chart/config/useGetters.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js +1 -1
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +1 -1
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +42 -13
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +67 -41
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/helpers/colorPallet.js +1 -1
- package/dist/cjs/graphs/Chart/helpers/colorPallet.js.map +1 -1
- package/dist/cjs/graphs/Chart/helpers/index.js +4 -4
- package/dist/cjs/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/helpers/useUniqueData.js +124 -0
- package/dist/cjs/graphs/Chart/helpers/useUniqueData.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/useVirtualizedSeries.js +42 -11
- package/dist/cjs/graphs/Chart/helpers/useVirtualizedSeries.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/Axes.js +13 -2
- package/dist/cjs/graphs/Chart/parts/Axis/Axes.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js +72 -23
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js +36 -16
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js +10 -8
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +60 -60
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ClipPaths.js +85 -0
- package/dist/cjs/graphs/Chart/parts/ClipPaths.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/BottomLabel.js +2 -2
- package/dist/cjs/graphs/Chart/parts/Labels/BottomLabel.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +7 -14
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +4 -4
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +1 -1
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js +6 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js +2 -77
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +3 -3
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +3 -3
- package/dist/cjs/graphs/Chart/parts/Scroller/BlurMask.js +112 -0
- package/dist/cjs/graphs/Chart/parts/Scroller/BlurMask.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js +4 -7
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarY.js +114 -0
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarY.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +14 -29
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerY.js +84 -0
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerY.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +4 -9
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Area.js +1 -3
- package/dist/cjs/graphs/Chart/series/Area.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js +4 -24
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/StackedBar.js +3 -2
- package/dist/cjs/graphs/Chart/series/StackedBar.js.map +2 -2
- package/dist/cjs/graphs/Chart/styles.js +12 -11
- package/dist/cjs/graphs/Chart/styles.js.map +2 -2
- package/dist/cjs/graphs/constants.js +6 -5
- package/dist/cjs/graphs/constants.js.map +2 -2
- package/dist/esm/graphs/Chart/Chart.js +1 -4
- package/dist/esm/graphs/Chart/Chart.js.map +2 -2
- package/dist/esm/graphs/Chart/ChartContext.js +1 -4
- package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChart.js +27 -23
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useGetters.js +64 -0
- package/dist/esm/graphs/Chart/config/useGetters.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useInternalMargins.js +1 -1
- package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +1 -1
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +42 -13
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useScales.js +67 -41
- package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/colorPallet.js +1 -1
- package/dist/esm/graphs/Chart/helpers/colorPallet.js.map +1 -1
- package/dist/esm/graphs/Chart/helpers/index.js +4 -4
- package/dist/esm/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/useUniqueData.js +98 -0
- package/dist/esm/graphs/Chart/helpers/useUniqueData.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/useVirtualizedSeries.js +42 -11
- package/dist/esm/graphs/Chart/helpers/useVirtualizedSeries.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/Axes.js +13 -2
- package/dist/esm/graphs/Chart/parts/Axis/Axes.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js +72 -23
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js +36 -16
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js +10 -8
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +60 -60
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ClipPaths.js +59 -0
- package/dist/esm/graphs/Chart/parts/ClipPaths.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +8 -15
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +5 -5
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +1 -1
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js +6 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js +3 -78
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +3 -3
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +3 -3
- package/dist/esm/graphs/Chart/parts/Scroller/BlurMask.js +86 -0
- package/dist/esm/graphs/Chart/parts/Scroller/BlurMask.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js +4 -7
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarY.js +88 -0
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarY.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +14 -29
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerY.js +58 -0
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerY.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js +5 -10
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Area.js +1 -3
- package/dist/esm/graphs/Chart/series/Area.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalBars.js +4 -24
- package/dist/esm/graphs/Chart/series/HorizontalBars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/StackedBar.js +3 -2
- package/dist/esm/graphs/Chart/series/StackedBar.js.map +2 -2
- package/dist/esm/graphs/Chart/styles.js +13 -12
- package/dist/esm/graphs/Chart/styles.js.map +2 -2
- package/dist/esm/graphs/constants.js +7 -6
- package/dist/esm/graphs/constants.js.map +2 -2
- package/package.json +8 -8
- package/dist/cjs/graphs/Chart/Pie.js +0 -49
- package/dist/cjs/graphs/Chart/Pie.js.map +0 -7
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js +0 -83
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js.map +0 -7
- package/dist/esm/graphs/Chart/Pie.js +0 -23
- package/dist/esm/graphs/Chart/Pie.js.map +0 -7
- package/dist/esm/graphs/Chart/parts/ActivePoint.js +0 -57
- package/dist/esm/graphs/Chart/parts/ActivePoint.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/StackedBar.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext } from 'react';\n\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { getStackedData, getStackedIndex } from '../helpers';\n\nexport const StackedBar = ({ serie }) => {\n const {\n props: { groups },\n xScale,\n yScale,\n stackedData,\n subGroupScale,\n colorScale,\n chartId,\n getXValue,\n } = useContext(ChartContext);\n\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const stackIndex = getStackedIndex(groups, serie.name);\n return (\n <g clipPath={`url(#rect-focus-ring-${chartId})`}>\n {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAkC;AAElC,kBAAqB;AACrB,0BAA6B;AAC7B,qBAAgD;AAEzC,MAAM,aAAa,CAAC,EAAE,MAAM,MAAM;AACvC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAE3B,QAAM,6BAAyB,+BAAe,aAAa,KAAK;AAChE,QAAM,iBAAa,gCAAgB,QAAQ,MAAM,IAAI;AACrD,SACE,4CAAC;AAAA,IAAE,UAAU,wBAAwB;AAAA,IAClC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext } from 'react';\n\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { getStackedData, getStackedIndex } from '../helpers';\n\nexport const StackedBar = ({ serie }) => {\n const {\n props: { groups },\n xScale,\n yScale,\n stackedData,\n subGroupScale,\n colorScale,\n chartId,\n getXValue,\n } = useContext(ChartContext);\n\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const stackIndex = getStackedIndex(groups, serie.name);\n return (\n <g clipPath={`url(#rect-focus-ring-${chartId})`}>\n {serie.data.map((bar, i) => {\n const sequence = serieWithStackedValues[bar.position];\n const isFloorStack = sequence[0] === 0;\n\n const xValue = getXValue(bar);\n const yValue = sequence[0] - sequence[1];\n const width = subGroupScale?.bandwidth();\n const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 1 : 0);\n const transformX = xScale(xValue) + subGroupScale(`stacked-data-${stackIndex}`);\n const transformY = yScale(sequence[1]);\n\n return (\n <g key={serie.data[i].key} fill={colorScale(serie.name)} transform={`translate(${transformX},0)`}>\n <Rect\n width={width}\n height={height}\n xValue={xValue}\n yValue={yValue}\n y={transformY}\n id={serie.data[i].key}\n name={serie.name}\n />\n </g>\n );\n })}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAkC;AAElC,kBAAqB;AACrB,0BAA6B;AAC7B,qBAAgD;AAEzC,MAAM,aAAa,CAAC,EAAE,MAAM,MAAM;AACvC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAE3B,QAAM,6BAAyB,+BAAe,aAAa,KAAK;AAChE,QAAM,iBAAa,gCAAgB,QAAQ,MAAM,IAAI;AACrD,SACE,4CAAC;AAAA,IAAE,UAAU,wBAAwB;AAAA,IAClC,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,YAAM,WAAW,uBAAuB,IAAI;AAC5C,YAAM,eAAe,SAAS,OAAO;AAErC,YAAM,SAAS,UAAU,GAAG;AAC5B,YAAM,SAAS,SAAS,KAAK,SAAS;AACtC,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,SAAS,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAChF,YAAM,aAAa,OAAO,MAAM,IAAI,cAAc,gBAAgB,YAAY;AAC9E,YAAM,aAAa,OAAO,SAAS,EAAE;AAErC,aACE,4CAAC;AAAA,QAA0B,MAAM,WAAW,MAAM,IAAI;AAAA,QAAG,WAAW,aAAa;AAAA,QAC/E,sDAAC;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAG;AAAA,UACH,IAAI,MAAM,KAAK,GAAG;AAAA,UAClB,MAAM,MAAM;AAAA,SACd;AAAA,SATM,MAAM,KAAK,GAAG,GAUtB;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -49,7 +49,7 @@ const StyledSVGWrapper = import_ds_system.styled.div`
|
|
|
49
49
|
cursor: ${({ isGrabbed }) => isGrabbed ? "grabbing" : "default"};
|
|
50
50
|
|
|
51
51
|
.domain {
|
|
52
|
-
stroke-width:
|
|
52
|
+
stroke-width: 1px;
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
55
55
|
const StyledAxis = (0, import_ds_system.styled)("g")`
|
|
@@ -57,19 +57,20 @@ const StyledAxis = (0, import_ds_system.styled)("g")`
|
|
|
57
57
|
fill: #635f5d;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
text.axis-label {
|
|
61
|
-
/* font-size: 2.5em; */
|
|
62
|
-
}
|
|
63
|
-
|
|
64
60
|
.tick text {
|
|
65
|
-
${({
|
|
61
|
+
${({ tickColor }) => tickColor ? `fill: ${import_colorPallet.COLOR_PALLET[tickColor] ?? tickColor}` : ""}
|
|
66
62
|
}
|
|
67
63
|
.tick line {
|
|
68
|
-
${({
|
|
64
|
+
${({ tickColor }) => tickColor ? `stroke: ${import_colorPallet.COLOR_PALLET[tickColor] ?? tickColor}` : ""}
|
|
69
65
|
}
|
|
66
|
+
|
|
70
67
|
line {
|
|
71
68
|
stroke: #c0c0bb;
|
|
72
69
|
}
|
|
70
|
+
|
|
71
|
+
.domain {
|
|
72
|
+
${({ axisColor }) => axisColor ? `stroke: ${import_colorPallet.COLOR_PALLET[axisColor] ?? axisColor}` : ""}
|
|
73
|
+
}
|
|
73
74
|
`;
|
|
74
75
|
const StyledAxisLabel = (0, import_ds_system.styled)("text")`
|
|
75
76
|
font-size: 13px;
|
|
@@ -79,10 +80,10 @@ const StyledGrid = (0, import_ds_system.styled)("g")`
|
|
|
79
80
|
line {
|
|
80
81
|
stroke: #c0c0bb;
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
|
|
84
|
+
.domain {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
86
87
|
`;
|
|
87
88
|
const StyleFocusableRegion = (0, import_ds_system.styled)("div")`
|
|
88
89
|
width: ${({ s }) => s * 2}px;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/graphs/Chart/styles.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { COLOR_PALLET } from './helpers/colorPallet';\nexport const StyledSVGWrapper = styled.div`\n :focus {\n outline: none;\n }\n :focus-within {\n outline: none;\n }\n\n cursor: ${({ isGrabbed }) => (isGrabbed ? 'grabbing' : 'default')};\n\n .domain {\n stroke-width:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAC5B,yBAA6B;
|
|
4
|
+
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { COLOR_PALLET } from './helpers/colorPallet';\n\ninterface StyledAxisT {\n axisColor: string;\n tickColor: string;\n}\nexport const StyledSVGWrapper = styled.div`\n :focus {\n outline: none;\n }\n :focus-within {\n outline: none;\n }\n\n cursor: ${({ isGrabbed }) => (isGrabbed ? 'grabbing' : 'default')};\n\n .domain {\n stroke-width: 1px;\n }\n`;\n\nexport const StyledAxis = styled('g')<StyledAxisT>`\n text {\n fill: #635f5d;\n }\n\n .tick text {\n ${({ tickColor }) => (tickColor ? `fill: ${COLOR_PALLET[tickColor] ?? tickColor}` : '')}\n }\n .tick line {\n ${({ tickColor }) => (tickColor ? `stroke: ${COLOR_PALLET[tickColor] ?? tickColor}` : '')}\n }\n\n line {\n stroke: #c0c0bb;\n }\n\n .domain {\n ${({ axisColor }) => (axisColor ? `stroke: ${COLOR_PALLET[axisColor] ?? axisColor}` : '')}\n }\n`;\n\nexport const StyledAxisLabel = styled('text')`\n font-size: 13px;\n font-weight: 600;\n`;\n\nexport const StyledGrid = styled('g')`\n line {\n stroke: #c0c0bb;\n }\n\n .domain {\n display: none;\n }\n`;\n\nexport const StyleFocusableRegion = styled('div')<{ s: number }>`\n width: ${({ s }) => s * 2 ?? '1'}px;\n height: ${({ s }) => s * 2 ?? '1'}px;\n :focus {\n outline: none;\n }\n`;\n\nexport const StyledLine = styled('path')`\n fill: none;\n stroke-width: ${({ isActiveLine }) => (isActiveLine ? 5 : 3)};\n stroke-linejoin: round;\n`;\nexport const StyledArea = styled('path')`\n stroke-width: ${({ isActiveLine }) => (isActiveLine ? 5 : 3)};\n stroke-linejoin: round;\n opacity: 0.2;\n`;\n\nexport const StyledTooltipContainer = styled.div`\n max-width: 350px;\n background-color: white;\n`;\n\nexport const StyledMouseOverDetectionBox = styled.div`\n position: absolute;\n top: -15px;\n right: -15px;\n width: calc(100% + 30px);\n height: calc(100% + 30px);\n z-index: -1;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAC5B,yBAA6B;AAMtB,MAAM,mBAAmB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAQ3B,CAAC,EAAE,UAAU,MAAO,YAAY,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAOlD,MAAM,iBAAa,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAM9B,CAAC,EAAE,UAAU,MAAO,YAAY,SAAS,gCAAa,cAAc,cAAc;AAAA;AAAA;AAAA,MAGlF,CAAC,EAAE,UAAU,MAAO,YAAY,WAAW,gCAAa,cAAc,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQpF,CAAC,EAAE,UAAU,MAAO,YAAY,WAAW,gCAAa,cAAc,cAAc;AAAA;AAAA;AAInF,MAAM,sBAAkB,yBAAO,MAAM;AAAA;AAAA;AAAA;AAKrC,MAAM,iBAAa,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAU7B,MAAM,2BAAuB,yBAAO,KAAK;AAAA,WACrC,CAAC,EAAE,EAAE,MAAM,IAAI;AAAA,YACd,CAAC,EAAE,EAAE,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAMpB,MAAM,iBAAa,yBAAO,MAAM;AAAA;AAAA,kBAErB,CAAC,EAAE,aAAa,MAAO,eAAe,IAAI;AAAA;AAAA;AAGrD,MAAM,iBAAa,yBAAO,MAAM;AAAA,kBACrB,CAAC,EAAE,aAAa,MAAO,eAAe,IAAI;AAAA;AAAA;AAAA;AAKrD,MAAM,yBAAyB,wBAAO;AAAA;AAAA;AAAA;AAKtC,MAAM,8BAA8B,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,17 +26,18 @@ var constants_exports = {};
|
|
|
26
26
|
__export(constants_exports, {
|
|
27
27
|
FOCUS_RING: () => FOCUS_RING,
|
|
28
28
|
LINE: () => LINE,
|
|
29
|
+
SCALE_TYPES: () => SCALE_TYPES,
|
|
29
30
|
SCRAPPER: () => SCRAPPER,
|
|
30
|
-
TICK_FORMATS: () => TICK_FORMATS,
|
|
31
31
|
curveStyleMap: () => curveStyleMap
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(constants_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_d3 = require("d3");
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const SCALE_TYPES = {
|
|
37
|
+
LINEAR: "linear",
|
|
38
|
+
BAND: "band",
|
|
39
|
+
LOG: "log",
|
|
40
|
+
TIME: "time"
|
|
40
41
|
};
|
|
41
42
|
const FOCUS_RING = {
|
|
42
43
|
COLOR: "#335cad",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/graphs/constants.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
4
|
+
"sourcesContent": ["import { curveLinear, curveMonotoneX } from 'd3';\n\nexport const SCALE_TYPES = {\n LINEAR: 'linear',\n BAND: 'band',\n LOG: 'log',\n TIME: 'time',\n};\n\nexport const FOCUS_RING = {\n COLOR: '#335cad',\n STROKE_WIDTH: 2,\n OFFSET: 4,\n};\n\nexport const SCRAPPER = {\n TYPE_HORIZONTAL: 'horizontal',\n TYPE_VERTICAL: 'vertical',\n};\n\nexport const LINE = {\n POINT_STYLE: {\n CIRCLE: 'CIRCLE',\n SQUARE: 'SQUARE',\n DIAMOND: 'DIAMOND',\n },\n DEFAULT_POINT_RADIUS: 4,\n DASH_STYLE: {\n SHORTDOT: 'SHORTDOT',\n SHORTDASHDOT: 'SHORTDASHDOT',\n DASH: 'DASH',\n SHORTDASH: 'SHORTDASH',\n },\n DASH_STYLE_VALUES: {\n SHORTDOT: [2, 2],\n SHORTDASHDOT: [6, 2, 2, 2],\n DASH: [8, 6],\n SHORTDASH: [6, 2],\n },\n CURVE_STYLE: {\n LINEAR: 'LINEAR',\n SPLINE: 'SPLINE',\n },\n};\n\nexport const curveStyleMap = {\n [LINE.CURVE_STYLE.LINEAR]: curveLinear,\n [LINE.CURVE_STYLE.SPLINE]: curveMonotoneX,\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,gBAA4C;AAErC,MAAM,cAAc;AAAA,EACzB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR;AAEO,MAAM,aAAa;AAAA,EACxB,OAAO;AAAA,EACP,cAAc;AAAA,EACd,QAAQ;AACV;AAEO,MAAM,WAAW;AAAA,EACtB,iBAAiB;AAAA,EACjB,eAAe;AACjB;AAEO,MAAM,OAAO;AAAA,EAClB,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,sBAAsB;AAAA,EACtB,YAAY;AAAA,IACV,UAAU;AAAA,IACV,cAAc;AAAA,IACd,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,mBAAmB;AAAA,IACjB,UAAU,CAAC,GAAG,CAAC;AAAA,IACf,cAAc,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,IACzB,MAAM,CAAC,GAAG,CAAC;AAAA,IACX,WAAW,CAAC,GAAG,CAAC;AAAA,EAClB;AAAA,EACA,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,gBAAgB;AAAA,EAC3B,CAAC,KAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,KAAK,YAAY,SAAS;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,14 +3,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { ChartContainer } from "./parts/ChartContainer";
|
|
4
4
|
import { ChartContext } from "./ChartContext";
|
|
5
5
|
import { useChart } from "./config/useChart";
|
|
6
|
-
import { Axes } from "./parts/Axis/Axes";
|
|
7
6
|
const Chart = (props) => {
|
|
8
7
|
const ctx = useChart(props);
|
|
9
8
|
return /* @__PURE__ */ jsx(ChartContext.Provider, {
|
|
10
9
|
value: ctx,
|
|
11
|
-
children: /* @__PURE__ */ jsx(ChartContainer, {
|
|
12
|
-
children: /* @__PURE__ */ jsx(Axes, {})
|
|
13
|
-
})
|
|
10
|
+
children: /* @__PURE__ */ jsx(ChartContainer, {})
|
|
14
11
|
});
|
|
15
12
|
};
|
|
16
13
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/Chart.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { ChartContainer } from './parts/ChartContainer';\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 </ChartContext.Provider>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAIlB,MAAM,QAA6C,CAAC,UAAU;AACnE,QAAM,MAAM,SAAS,KAAK;AAC1B,SACE,oBAAC,aAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,IAC5B,8BAAC,kBAAe;AAAA,GAClB;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,12 +8,9 @@ const defaultContext = {
|
|
|
8
8
|
yScale: scaleLinear(),
|
|
9
9
|
innerHeight: 0,
|
|
10
10
|
innerWidth: 0,
|
|
11
|
-
activePoint:
|
|
11
|
+
activePoint: null,
|
|
12
12
|
setActivePoint: () => {
|
|
13
13
|
},
|
|
14
|
-
activeSerie: "",
|
|
15
|
-
setActiveSerie: () => {
|
|
16
|
-
},
|
|
17
14
|
scrapperPosY: "",
|
|
18
15
|
setScrapperPosY: () => {
|
|
19
16
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/ChartContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { ScaleLinear, ScaleBand, scaleLinear, scaleBand, scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { defaultProps, DSChartT } from './react-desc-prop-types';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;AACzC,SAAiC,aAAa,WAAW,oBAAkC;AAC3F,SAAS,oBAA8B;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { ScaleLinear, ScaleBand, scaleLinear, scaleBand, scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { defaultProps, DSChartT } from './react-desc-prop-types';\ninterface ContextT {\n props: DSChartT.Props;\n currentData: DSChartT.InternalData;\n xScale: ScaleLinear<number, number, never> | ScaleBand<string>;\n yScale: ScaleLinear<number, number, never> | ScaleBand<string>;\n y2Scale: ScaleLinear<number, number, never>;\n innerHeight: number;\n innerWidth: number;\n activePoint: DSChartT.InternalDatum | null;\n containerRef: React.RefObject<HTMLDivElement>;\n groups: string[];\n subGroupScale?: ScaleBand<string> | null;\n colorScale: ScaleOrdinal<string, unknown, string>;\n axisLeftRef: SVGGElement | null;\n scrapperPosY: string;\n scrapperPosX: string;\n xScrollbarPosition: number;\n isGrabbed: boolean;\n startPosition: number;\n isScrollbarVisible: boolean;\n oldLastPosition: React.MutableRefObject<number>;\n containerRatio: number;\n internalMargin: {\n bottom: number;\n top: number;\n right: number;\n left: number;\n };\n leftLegendWidth: number;\n leftLegend: SVGGElement;\n rightLegend: SVGGElement;\n axisBottomHeight: number;\n bottomLabelHeight: number;\n rightLabelWidth: number;\n axisRightWidth: number;\n isHorizontal: boolean;\n leftLabel: SVGGElement;\n chartId: string;\n hiddenSeries: string[];\n stackedData: DSChartT.StackedSeriesByGroupT;\n setActivePoint: React.Dispatch<React.SetStateAction<DSChartT.InternalDatum | null>>;\n setLeftAxisRef: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n getBandwidth: () => number;\n setScrapperPosY: React.Dispatch<React.SetStateAction<string>>;\n setScrapperPosX: React.Dispatch<React.SetStateAction<string>>;\n setXScrollbarPosition: React.Dispatch<React.SetStateAction<number>>;\n setIsGrabbed: React.Dispatch<React.SetStateAction<boolean>>;\n setStartPosition: React.Dispatch<React.SetStateAction<number>>;\n setIsScrollbarVisible: React.Dispatch<React.SetStateAction<boolean>>;\n setAxisLeftRef: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setLeftLegend: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setRightLegend: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setTopLegend: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setBottomLegend: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setAxisBottomRef: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setLeftLabel: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setAxisRightRef: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setRightLabel: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n setBottomLabel: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\n getXValue: (datum: DSChartT.InternalDatum) => string | number | Date;\n getYValue: (datum: DSChartT.InternalDatum) => string | number | Date;\n setHiddenSeries: React.Dispatch<React.SetStateAction<string[]>>;\n getXScaleValue: (datum: DSChartT.InternalDatum) => number | undefined;\n getYScaleValue: (datum: DSChartT.InternalDatum) => number | undefined;\n}\nconst defaultContext: ContextT = {\n props: defaultProps,\n xScale: scaleBand(),\n yScale: scaleLinear(),\n innerHeight: 0,\n innerWidth: 0,\n activePoint: null,\n setActivePoint: () => {},\n scrapperPosY: '',\n setScrapperPosY: () => {},\n containerRef: createRef<HTMLDivElement>(),\n groups: [],\n colorScale: scaleOrdinal(),\n setLeftAxisRef: () => {},\n};\nexport const ChartContext = createContext(defaultContext);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;AACzC,SAAiC,aAAa,WAAW,oBAAkC;AAC3F,SAAS,oBAA8B;AAkEvC,MAAM,iBAA2B;AAAA,EAC/B,OAAO;AAAA,EACP,QAAQ,UAAU;AAAA,EAClB,QAAQ,YAAY;AAAA,EACpB,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,cAAc;AAAA,EACd,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,cAAc,UAA0B;AAAA,EACxC,QAAQ,CAAC;AAAA,EACT,YAAY,aAAa;AAAA,EACzB,gBAAgB,MAAM;AAAA,EAAC;AACzB;AACO,MAAM,eAAe,cAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo, useState, useRef
|
|
2
|
+
import { useMemo, useState, useRef } from "react";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
4
|
import { useScales } from "./useScales";
|
|
5
5
|
import { stackData } from "../helpers";
|
|
6
6
|
import { useInternalMargins } from "./useInternalMargins";
|
|
7
|
+
import { useGetters } from "./useGetters";
|
|
7
8
|
const useChart = (props) => {
|
|
8
9
|
const { series, yAxis, xAxis, width, height, groups: groupsStacked } = props;
|
|
9
10
|
const containerRef = useRef(null);
|
|
@@ -17,16 +18,16 @@ const useChart = (props) => {
|
|
|
17
18
|
const [xScrollbarPosition, setXScrollbarPosition] = useState(0);
|
|
18
19
|
const [isScrollbarVisible, setIsScrollbarVisible] = useState(false);
|
|
19
20
|
const oldLastPosition = useRef(0);
|
|
20
|
-
const [axisLeftRef, setAxisLeftRef] = useState();
|
|
21
|
-
const [axisBottomRef, setAxisBottomRef] = useState();
|
|
22
|
-
const [axisRightRef, setAxisRightRef] = useState();
|
|
23
|
-
const [leftLegend, setLeftLegend] = useState();
|
|
24
|
-
const [rightLegend, setRightLegend] = useState();
|
|
25
|
-
const [topLegend, setTopLegend] = useState();
|
|
26
|
-
const [bottomLegend, setBottomLegend] = useState();
|
|
27
|
-
const [rightLabel, setRightLabel] = useState();
|
|
28
|
-
const [leftLabel, setLeftLabel] = useState();
|
|
29
|
-
const [bottomLabel, setBottomLabel] = useState();
|
|
21
|
+
const [axisLeftRef, setAxisLeftRef] = useState(null);
|
|
22
|
+
const [axisBottomRef, setAxisBottomRef] = useState(null);
|
|
23
|
+
const [axisRightRef, setAxisRightRef] = useState(null);
|
|
24
|
+
const [leftLegend, setLeftLegend] = useState(null);
|
|
25
|
+
const [rightLegend, setRightLegend] = useState(null);
|
|
26
|
+
const [topLegend, setTopLegend] = useState(null);
|
|
27
|
+
const [bottomLegend, setBottomLegend] = useState(null);
|
|
28
|
+
const [rightLabel, setRightLabel] = useState(null);
|
|
29
|
+
const [leftLabel, setLeftLabel] = useState(null);
|
|
30
|
+
const [bottomLabel, setBottomLabel] = useState(null);
|
|
30
31
|
const { axisBottomHeight, axisRightWidth, bottomLabelHeight, internalMargin, leftLegendWidth, rightLabelWidth } = useInternalMargins({
|
|
31
32
|
axisLeftRef,
|
|
32
33
|
axisBottomRef,
|
|
@@ -57,12 +58,12 @@ const useChart = (props) => {
|
|
|
57
58
|
value,
|
|
58
59
|
position: index,
|
|
59
60
|
serie: d.name
|
|
60
|
-
})).filter((datum) => datum.value !== null)
|
|
61
|
+
})).filter((datum) => datum.value !== null && datum.value !== void 0)
|
|
61
62
|
})),
|
|
62
63
|
[hiddenSeries, series]
|
|
63
64
|
);
|
|
64
65
|
const stackedData = useMemo(() => stackData(groupsStacked, currentData), [groupsStacked, currentData]);
|
|
65
|
-
const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? 1;
|
|
66
|
+
const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1;
|
|
66
67
|
const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);
|
|
67
68
|
const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = useScales({
|
|
68
69
|
props,
|
|
@@ -74,18 +75,17 @@ const useChart = (props) => {
|
|
|
74
75
|
containerRatio
|
|
75
76
|
});
|
|
76
77
|
const isHorizontal = useMemo(() => !!yScale.bandwidth, [yScale]);
|
|
77
|
-
const getXValue =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
78
|
+
const { getXValue, getYValue, getXScaleValue, getYScaleValue } = useGetters({
|
|
79
|
+
xAxis,
|
|
80
|
+
yAxis,
|
|
81
|
+
isHorizontal,
|
|
82
|
+
xScale,
|
|
83
|
+
yScale
|
|
84
|
+
});
|
|
85
85
|
const chartId = useMemo(() => uuidv4(), []);
|
|
86
86
|
return useMemo(
|
|
87
87
|
() => ({
|
|
88
|
-
props
|
|
88
|
+
props,
|
|
89
89
|
innerHeight,
|
|
90
90
|
innerWidth,
|
|
91
91
|
groups,
|
|
@@ -132,6 +132,8 @@ const useChart = (props) => {
|
|
|
132
132
|
setAxisRightRef,
|
|
133
133
|
setRightLabel,
|
|
134
134
|
setBottomLabel,
|
|
135
|
+
getXScaleValue,
|
|
136
|
+
getYScaleValue,
|
|
135
137
|
bottomLabelHeight,
|
|
136
138
|
rightLabelWidth,
|
|
137
139
|
axisRightWidth,
|
|
@@ -197,7 +199,9 @@ const useChart = (props) => {
|
|
|
197
199
|
leftLabel,
|
|
198
200
|
chartId,
|
|
199
201
|
hiddenSeries,
|
|
200
|
-
setHiddenSeries
|
|
202
|
+
setHiddenSeries,
|
|
203
|
+
getXScaleValue,
|
|
204
|
+
getYScaleValue
|
|
201
205
|
]
|
|
202
206
|
);
|
|
203
207
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useChart.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-nested-callbacks */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useState, useRef
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,UAAU,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-nested-callbacks */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useState, useRef } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport { ScaleBand } from 'd3';\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';\nimport { useGetters } from './useGetters';\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<SVGGElement | null>(null);\n const [axisBottomRef, setAxisBottomRef] = useState<SVGGElement | null>(null);\n const [axisRightRef, setAxisRightRef] = useState<SVGGElement | null>(null);\n\n const [leftLegend, setLeftLegend] = useState<SVGGElement | null>(null);\n const [rightLegend, setRightLegend] = useState<SVGGElement | null>(null);\n const [topLegend, setTopLegend] = useState<SVGGElement | null>(null);\n const [bottomLegend, setBottomLegend] = useState<SVGGElement | null>(null);\n\n const [rightLabel, setRightLabel] = useState<SVGGElement | null>(null);\n const [leftLabel, setLeftLabel] = useState<SVGGElement | null>(null);\n const [bottomLabel, setBottomLabel] = useState<SVGGElement | null>(null);\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 [hiddenSeries, setHiddenSeries] = useState<string[]>([]);\n\n const currentData = useMemo(\n () =>\n series\n .filter((serie) => !hiddenSeries.includes(serie.name))\n .map((d, i) => ({\n ...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 serie: d.name,\n }))\n .filter((datum) => datum.value !== null && datum.value !== undefined),\n })),\n [hiddenSeries, series],\n );\n\n const stackedData = useMemo(() => stackData(groupsStacked, currentData), [groupsStacked, currentData]);\n\n // @TODO we need to create a logic to get this from both axis\n const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1;\n\n const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);\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 as ScaleBand<string>).bandwidth, [yScale]);\n\n const { getXValue, getYValue, getXScaleValue, getYScaleValue } = useGetters({\n xAxis,\n yAxis,\n isHorizontal,\n xScale,\n yScale,\n });\n const chartId = useMemo(() => uuidv4(), []);\n\n return useMemo(\n () => ({\n props,\n innerHeight,\n innerWidth,\n groups,\n currentData,\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 getXScaleValue,\n getYScaleValue,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n setLeftLabel,\n leftLabel,\n chartId,\n hiddenSeries,\n setHiddenSeries,\n }),\n [\n props,\n currentData,\n innerHeight,\n innerWidth,\n groups,\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 axisRightWidth,\n setLeftLabel,\n leftLabel,\n chartId,\n hiddenSeries,\n setHiddenSeries,\n getXScaleValue,\n getYScaleValue,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "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IACA;AAAA,EACF,CAAC;AACD,QAAM,UAAU,QAAQ,MAAM,OAAO,GAAG,CAAC,CAAC;AAE1C,SAAO;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,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,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,IACA;AAAA,MACE;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,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
const useGetters = ({ xAxis, isHorizontal, yAxis, xScale, yScale }) => {
|
|
4
|
+
const getXValue = useCallback(
|
|
5
|
+
(datum) => {
|
|
6
|
+
if (!isHorizontal) {
|
|
7
|
+
if (xAxis?.cols?.[datum.position]) {
|
|
8
|
+
return xAxis?.cols?.[datum.position];
|
|
9
|
+
}
|
|
10
|
+
if (typeof datum.value === "object")
|
|
11
|
+
return datum.value?.x;
|
|
12
|
+
return datum.position.toString();
|
|
13
|
+
}
|
|
14
|
+
if (typeof datum.value === "number") {
|
|
15
|
+
return datum.value;
|
|
16
|
+
}
|
|
17
|
+
return datum.value?.x;
|
|
18
|
+
},
|
|
19
|
+
[isHorizontal, xAxis?.cols]
|
|
20
|
+
);
|
|
21
|
+
const getYValue = useCallback(
|
|
22
|
+
(datum) => {
|
|
23
|
+
if (!isHorizontal) {
|
|
24
|
+
if (typeof datum.value === "number") {
|
|
25
|
+
return datum.value;
|
|
26
|
+
}
|
|
27
|
+
return datum.value?.y;
|
|
28
|
+
}
|
|
29
|
+
if (yAxis?.cols?.[datum.position]) {
|
|
30
|
+
return yAxis?.cols?.[datum.position];
|
|
31
|
+
}
|
|
32
|
+
if (typeof datum.value === "object")
|
|
33
|
+
return datum.value?.y;
|
|
34
|
+
return datum.position.toString();
|
|
35
|
+
},
|
|
36
|
+
[isHorizontal, yAxis?.cols]
|
|
37
|
+
);
|
|
38
|
+
const getXScaleValue = useCallback(
|
|
39
|
+
(datum) => {
|
|
40
|
+
if (xAxis.type === "linear") {
|
|
41
|
+
return xScale(getXValue(datum));
|
|
42
|
+
}
|
|
43
|
+
return xScale(getXValue(datum));
|
|
44
|
+
},
|
|
45
|
+
[getXValue, xAxis.type, xScale]
|
|
46
|
+
);
|
|
47
|
+
const getYScaleValue = useCallback(
|
|
48
|
+
(datum) => {
|
|
49
|
+
if (yAxis.type === "band") {
|
|
50
|
+
return yScale(getYValue(datum));
|
|
51
|
+
}
|
|
52
|
+
return yScale(getYValue(datum));
|
|
53
|
+
},
|
|
54
|
+
[getYValue, yAxis.type, yScale]
|
|
55
|
+
);
|
|
56
|
+
return useMemo(
|
|
57
|
+
() => ({ getYValue, getXValue, getXScaleValue, getYScaleValue }),
|
|
58
|
+
[getYValue, getXValue, getXScaleValue, getYScaleValue]
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
useGetters
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=useGetters.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useGetters.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useMemo } from 'react';\nimport { ScaleBand, ScaleLinear } from 'd3';\nimport { DSChartT } from '../react-desc-prop-types';\n\ninterface UseGettersT {\n xAxis: DSChartT.AxisT;\n yAxis: DSChartT.AxisT;\n isHorizontal: boolean;\n xScale: DSChartT.Scales;\n yScale: DSChartT.Scales;\n}\nexport const useGetters = ({ xAxis, isHorizontal, yAxis, xScale, yScale }: UseGettersT) => {\n const getXValue = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (!isHorizontal) {\n if (xAxis?.cols?.[datum.position]) {\n return xAxis?.cols?.[datum.position];\n }\n if (typeof datum.value === 'object') return datum.value?.x;\n return datum.position.toString();\n }\n if (typeof datum.value === 'number') {\n return datum.value;\n }\n return datum.value?.x;\n },\n [isHorizontal, xAxis?.cols],\n );\n\n const getYValue = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (!isHorizontal) {\n if (typeof datum.value === 'number') {\n return datum.value;\n }\n return datum.value?.y;\n }\n if (yAxis?.cols?.[datum.position]) {\n return yAxis?.cols?.[datum.position];\n }\n if (typeof datum.value === 'object') return datum.value?.y;\n return datum.position.toString();\n },\n [isHorizontal, yAxis?.cols],\n );\n\n const getXScaleValue = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (xAxis.type === 'linear') {\n return (xScale as ScaleLinear<number, number, never>)(getXValue(datum) as number);\n }\n return (xScale as ScaleBand<string>)(getXValue(datum) as string);\n },\n [getXValue, xAxis.type, xScale],\n );\n\n const getYScaleValue = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (yAxis.type === 'band') {\n return (yScale as ScaleBand<string>)(getYValue(datum) as string);\n }\n return (yScale as ScaleLinear<number, number, never>)(getYValue(datum) as number);\n },\n [getYValue, yAxis.type, yScale],\n );\n\n return useMemo(\n () => ({ getYValue, getXValue, getXScaleValue, getYScaleValue }),\n [getYValue, getXValue, getXScaleValue, getYScaleValue],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,aAAa,eAAe;AAW9B,MAAM,aAAa,CAAC,EAAE,OAAO,cAAc,OAAO,QAAQ,OAAO,MAAmB;AACzF,QAAM,YAAY;AAAA,IAChB,CAAC,UAAkC;AACjC,UAAI,CAAC,cAAc;AACjB,YAAI,OAAO,OAAO,MAAM,WAAW;AACjC,iBAAO,OAAO,OAAO,MAAM;AAAA,QAC7B;AACA,YAAI,OAAO,MAAM,UAAU;AAAU,iBAAO,MAAM,OAAO;AACzD,eAAO,MAAM,SAAS,SAAS;AAAA,MACjC;AACA,UAAI,OAAO,MAAM,UAAU,UAAU;AACnC,eAAO,MAAM;AAAA,MACf;AACA,aAAO,MAAM,OAAO;AAAA,IACtB;AAAA,IACA,CAAC,cAAc,OAAO,IAAI;AAAA,EAC5B;AAEA,QAAM,YAAY;AAAA,IAChB,CAAC,UAAkC;AACjC,UAAI,CAAC,cAAc;AACjB,YAAI,OAAO,MAAM,UAAU,UAAU;AACnC,iBAAO,MAAM;AAAA,QACf;AACA,eAAO,MAAM,OAAO;AAAA,MACtB;AACA,UAAI,OAAO,OAAO,MAAM,WAAW;AACjC,eAAO,OAAO,OAAO,MAAM;AAAA,MAC7B;AACA,UAAI,OAAO,MAAM,UAAU;AAAU,eAAO,MAAM,OAAO;AACzD,aAAO,MAAM,SAAS,SAAS;AAAA,IACjC;AAAA,IACA,CAAC,cAAc,OAAO,IAAI;AAAA,EAC5B;AAEA,QAAM,iBAAiB;AAAA,IACrB,CAAC,UAAkC;AACjC,UAAI,MAAM,SAAS,UAAU;AAC3B,eAAQ,OAA8C,UAAU,KAAK,CAAW;AAAA,MAClF;AACA,aAAQ,OAA6B,UAAU,KAAK,CAAW;AAAA,IACjE;AAAA,IACA,CAAC,WAAW,MAAM,MAAM,MAAM;AAAA,EAChC;AAEA,QAAM,iBAAiB;AAAA,IACrB,CAAC,UAAkC;AACjC,UAAI,MAAM,SAAS,QAAQ;AACzB,eAAQ,OAA6B,UAAU,KAAK,CAAW;AAAA,MACjE;AACA,aAAQ,OAA8C,UAAU,KAAK,CAAW;AAAA,IAClF;AAAA,IACA,CAAC,WAAW,MAAM,MAAM,MAAM;AAAA,EAChC;AAEA,SAAO;AAAA,IACL,OAAO,EAAE,WAAW,WAAW,gBAAgB,eAAe;AAAA,IAC9D,CAAC,WAAW,WAAW,gBAAgB,cAAc;AAAA,EACvD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -26,7 +26,7 @@ const useInternalMargins = ({
|
|
|
26
26
|
() => ({
|
|
27
27
|
bottom: 10 + axisBottomHeight + bottomLegendHeight + bottomLabelHeight,
|
|
28
28
|
top: 10 + topLegendHeight,
|
|
29
|
-
right:
|
|
29
|
+
right: 15 + rightLabelWidth + axisRightWidth + rightLegendWidth,
|
|
30
30
|
left: 10 + axisLeftWidth + leftLabelWidth + leftLegendWidth
|
|
31
31
|
}),
|
|
32
32
|
[
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useInternalMargins.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo } from 'react';\n\ninterface UseInternalMarginsT {\n axisLeftRef
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo } from 'react';\n\ninterface UseInternalMarginsT {\n axisLeftRef: SVGGElement | null;\n axisBottomRef: SVGGElement | null;\n axisRightRef: SVGGElement | null;\n leftLegend: SVGGElement | null;\n leftLabel: SVGGElement | null;\n rightLegend: SVGGElement | null;\n topLegend: SVGGElement | null;\n bottomLegend: SVGGElement | null;\n rightLabel: SVGGElement | null;\n bottomLabel: SVGGElement | null;\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\n const internalMargin = useMemo(\n () => ({\n bottom: 10 + axisBottomHeight + bottomLegendHeight + bottomLabelHeight,\n top: 10 + topLegendHeight,\n right: 15 + 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"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,eAAe;AAcjB,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA2B;AAEzB,QAAM,gBAAgB,QAAQ,MAAM,aAAa,sBAAsB,GAAG,SAAS,GAAG,CAAC,WAAW,CAAC;AACnG,QAAM,mBAAmB,QAAQ,MAAM,eAAe,sBAAsB,GAAG,UAAU,GAAG,CAAC,aAAa,CAAC;AAC3G,QAAM,iBAAiB,QAAQ,MAAM,cAAc,sBAAsB,GAAG,SAAS,GAAG,CAAC,YAAY,CAAC;AAGtG,QAAM,oBAAoB,QAAQ,MAAM,aAAa,sBAAsB,GAAG,UAAU,GAAG,CAAC,WAAW,CAAC;AACxG,QAAM,kBAAkB,QAAQ,MAAM,YAAY,sBAAsB,GAAG,SAAS,GAAG,CAAC,UAAU,CAAC;AACnG,QAAM,iBAAiB,QAAQ,MAAM,WAAW,sBAAsB,GAAG,SAAS,GAAG,CAAC,SAAS,CAAC;AAGhG,QAAM,kBAAkB,QAAQ,MAAM,WAAW,sBAAsB,GAAG,UAAU,GAAG,CAAC,SAAS,CAAC;AAClG,QAAM,qBAAqB,QAAQ,MAAM,cAAc,sBAAsB,GAAG,UAAU,GAAG,CAAC,YAAY,CAAC;AAC3G,QAAM,mBAAmB,QAAQ,MAAM,aAAa,sBAAsB,GAAG,SAAS,GAAG,CAAC,WAAW,CAAC;AACtG,QAAM,kBAAkB,QAAQ,MAAM,YAAY,sBAAsB,GAAG,SAAS,GAAG,CAAC,UAAU,CAAC;AAEnG,QAAM,iBAAiB;AAAA,IACrB,OAAO;AAAA,MACL,QAAQ,KAAK,mBAAmB,qBAAqB;AAAA,MACrD,KAAK,KAAK;AAAA,MACV,OAAO,KAAK,kBAAkB,iBAAiB;AAAA,MAC/C,MAAM,KAAK,gBAAgB,iBAAiB;AAAA,IAC9C;AAAA,IAEA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useCallback, useContext, useMemo } from "react";
|
|
3
3
|
import { ChartContext } from "../ChartContext";
|
|
4
|
+
import { FOCUS_RING } from "../../constants";
|
|
4
5
|
const findInCircularList = (list, from, step = 1) => {
|
|
5
6
|
for (let i = (from + step + list.length) % list.length; i !== from && from > -1; i = (i + step + list.length) % list.length) {
|
|
6
7
|
if (list[i])
|
|
@@ -14,15 +15,20 @@ const useKeyboardNavigation = () => {
|
|
|
14
15
|
setActivePoint,
|
|
15
16
|
containerRef,
|
|
16
17
|
yScale,
|
|
17
|
-
xScale,
|
|
18
18
|
setXScrollbarPosition,
|
|
19
19
|
containerRatio,
|
|
20
20
|
xScrollbarPosition,
|
|
21
21
|
innerWidth,
|
|
22
|
-
|
|
22
|
+
innerHeight,
|
|
23
|
+
getYValue,
|
|
24
|
+
getXScaleValue,
|
|
25
|
+
getYScaleValue,
|
|
23
26
|
groups,
|
|
24
|
-
currentData: data
|
|
27
|
+
currentData: data,
|
|
28
|
+
props: { xAxis, yAxis }
|
|
25
29
|
} = useContext(ChartContext);
|
|
30
|
+
const xScroll = xAxis.advanced?.pointSpacing?.value > 1;
|
|
31
|
+
const yScroll = yAxis.advanced?.pointSpacing?.value > 1;
|
|
26
32
|
const currentSerie = useMemo(
|
|
27
33
|
() => data.find((d) => d.name === activePoint?.serie) ?? data[0],
|
|
28
34
|
[activePoint?.serie, data]
|
|
@@ -55,8 +61,10 @@ const useKeyboardNavigation = () => {
|
|
|
55
61
|
step
|
|
56
62
|
);
|
|
57
63
|
setActivePoint(currentSerie?.data[newValue]);
|
|
58
|
-
if (
|
|
59
|
-
const xValue =
|
|
64
|
+
if (xScroll) {
|
|
65
|
+
const xValue = getXScaleValue(currentSerie?.data[newValue]);
|
|
66
|
+
if (xValue === void 0)
|
|
67
|
+
return;
|
|
60
68
|
const barWidth = innerWidth / containerRatio;
|
|
61
69
|
const total = innerWidth * containerRatio;
|
|
62
70
|
if (total <= xValue) {
|
|
@@ -69,19 +77,40 @@ const useKeyboardNavigation = () => {
|
|
|
69
77
|
return nextPosition;
|
|
70
78
|
});
|
|
71
79
|
else if (xValue < xScrollbarPosition * containerRatio)
|
|
72
|
-
setXScrollbarPosition(xValue / containerRatio);
|
|
80
|
+
setXScrollbarPosition(xValue / containerRatio - FOCUS_RING.STROKE_WIDTH);
|
|
81
|
+
}
|
|
82
|
+
if (yScroll) {
|
|
83
|
+
const yValue = getYScaleValue(currentSerie?.data[newValue]);
|
|
84
|
+
if (yValue === void 0)
|
|
85
|
+
return;
|
|
86
|
+
const barWidth = innerHeight / containerRatio;
|
|
87
|
+
const total = innerHeight * containerRatio;
|
|
88
|
+
if (total <= yValue) {
|
|
89
|
+
setXScrollbarPosition((total - innerHeight) / containerRatio);
|
|
90
|
+
} else if (yValue > xScrollbarPosition * containerRatio + innerHeight)
|
|
91
|
+
setXScrollbarPosition((prev) => {
|
|
92
|
+
const nextPosition = prev + (yValue / containerRatio - prev);
|
|
93
|
+
if (nextPosition + barWidth > innerHeight)
|
|
94
|
+
return innerHeight - barWidth;
|
|
95
|
+
return nextPosition;
|
|
96
|
+
});
|
|
97
|
+
else if (yValue < xScrollbarPosition * containerRatio)
|
|
98
|
+
setXScrollbarPosition(yValue / containerRatio - FOCUS_RING.STROKE_WIDTH);
|
|
73
99
|
}
|
|
74
100
|
},
|
|
75
101
|
[
|
|
76
|
-
containerRatio,
|
|
77
102
|
currentSerie?.data,
|
|
78
103
|
currentActiveItemIndex,
|
|
79
|
-
getXValue,
|
|
80
|
-
innerWidth,
|
|
81
104
|
setActivePoint,
|
|
105
|
+
xScroll,
|
|
106
|
+
yScroll,
|
|
107
|
+
getXScaleValue,
|
|
108
|
+
innerWidth,
|
|
109
|
+
containerRatio,
|
|
110
|
+
xScrollbarPosition,
|
|
82
111
|
setXScrollbarPosition,
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
getYScaleValue,
|
|
113
|
+
innerHeight
|
|
85
114
|
]
|
|
86
115
|
);
|
|
87
116
|
const changeSerie = useCallback(
|
|
@@ -94,7 +123,7 @@ const useKeyboardNavigation = () => {
|
|
|
94
123
|
);
|
|
95
124
|
return d.name === groups[nextSerieIndex];
|
|
96
125
|
});
|
|
97
|
-
setActivePoint(nextSerie?.data[currentActiveItemIndex]
|
|
126
|
+
setActivePoint(nextSerie?.data[currentActiveItemIndex] || nextSerie?.data?.[0] || null);
|
|
98
127
|
},
|
|
99
128
|
[data, setActivePoint, currentActiveItemIndex, groups, currentSerie.name]
|
|
100
129
|
);
|
|
@@ -111,7 +140,7 @@ const useKeyboardNavigation = () => {
|
|
|
111
140
|
}
|
|
112
141
|
if (["ArrowDown", "ArrowUp"].includes(e.code)) {
|
|
113
142
|
if (yScale.bandwidth)
|
|
114
|
-
navigateSerie(e.code === "ArrowDown" ?
|
|
143
|
+
navigateSerie(e.code === "ArrowDown" ? 1 : -1);
|
|
115
144
|
else
|
|
116
145
|
changeSerie(e.code === "ArrowDown" ? -1 : 1);
|
|
117
146
|
}
|