@elliemae/ds-dataviz 3.13.0-next.3 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
  2. package/dist/cjs/graphs/Chart/config/useChart.js +55 -10
  3. package/dist/cjs/graphs/Chart/config/useChart.js.map +2 -2
  4. package/dist/cjs/graphs/Chart/config/useInternalMargins.js +48 -19
  5. package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +3 -3
  6. package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +89 -7
  7. package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
  8. package/dist/cjs/graphs/Chart/config/useScales.js +25 -12
  9. package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
  10. package/dist/cjs/graphs/Chart/config/useValidateProps.js +37 -0
  11. package/dist/cjs/graphs/Chart/config/useValidateProps.js.map +7 -0
  12. package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
  13. package/dist/cjs/graphs/Chart/parts/ChartContainer.js +28 -10
  14. package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
  15. package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +5 -5
  16. package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
  17. package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +43 -43
  18. package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
  19. package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +12 -8
  20. package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
  21. package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +4 -10
  22. package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
  23. package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +5 -9
  24. package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
  25. package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +21 -18
  26. package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
  27. package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js +42 -19
  28. package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
  29. package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +28 -18
  30. package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
  31. package/dist/cjs/graphs/Chart/react-desc-prop-types.js +14 -1
  32. package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
  33. package/dist/cjs/graphs/Chart/series/Bars.js +2 -2
  34. package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
  35. package/dist/cjs/graphs/Chart/series/Point.js +1 -2
  36. package/dist/cjs/graphs/Chart/series/Point.js.map +2 -2
  37. package/dist/cjs/graphs/Chart/series/Rect.js +2 -2
  38. package/dist/cjs/graphs/Chart/series/Rect.js.map +1 -1
  39. package/dist/cjs/graphs/Chart/series/StackedBar.js +1 -1
  40. package/dist/cjs/graphs/Chart/series/StackedBar.js.map +1 -1
  41. package/dist/cjs/graphs/constants.js +7 -0
  42. package/dist/cjs/graphs/constants.js.map +2 -2
  43. package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
  44. package/dist/esm/graphs/Chart/config/useChart.js +55 -10
  45. package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
  46. package/dist/esm/graphs/Chart/config/useInternalMargins.js +49 -20
  47. package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +2 -2
  48. package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +90 -8
  49. package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
  50. package/dist/esm/graphs/Chart/config/useScales.js +25 -12
  51. package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
  52. package/dist/esm/graphs/Chart/config/useValidateProps.js +11 -0
  53. package/dist/esm/graphs/Chart/config/useValidateProps.js.map +7 -0
  54. package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
  55. package/dist/esm/graphs/Chart/parts/ChartContainer.js +28 -10
  56. package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
  57. package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +5 -5
  58. package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
  59. package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +44 -44
  60. package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
  61. package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +13 -9
  62. package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
  63. package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +4 -10
  64. package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
  65. package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +6 -10
  66. package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
  67. package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +23 -20
  68. package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
  69. package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js +44 -21
  70. package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
  71. package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +29 -19
  72. package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
  73. package/dist/esm/graphs/Chart/react-desc-prop-types.js +14 -1
  74. package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
  75. package/dist/esm/graphs/Chart/series/Bars.js +2 -2
  76. package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
  77. package/dist/esm/graphs/Chart/series/Point.js +1 -2
  78. package/dist/esm/graphs/Chart/series/Point.js.map +2 -2
  79. package/dist/esm/graphs/Chart/series/Rect.js +2 -2
  80. package/dist/esm/graphs/Chart/series/Rect.js.map +1 -1
  81. package/dist/esm/graphs/Chart/series/StackedBar.js +1 -1
  82. package/dist/esm/graphs/Chart/series/StackedBar.js.map +1 -1
  83. package/dist/esm/graphs/constants.js +7 -0
  84. package/dist/esm/graphs/constants.js.map +2 -2
  85. package/package.json +4 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/graphs/Chart/series/Point.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useContext, useCallback, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING, SCRAPPER, LINE } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { TrendHighlight } from '../parts/TrendHighlight';\nimport { DataVizDataTestIds } from '../DataTestIds';\nexport const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity, datum }) => {\n const {\n activePoint,\n scrapperPosY,\n scrapperPosX,\n setActivePoint,\n props: { scrapper, TooltipRenderer, withTrendHighlight },\n } = useContext(ChartContext);\n const isFocused = useMemo(() => {\n if (activePoint?.key === id) {\n return true;\n }\n if (scrapper?.type === SCRAPPER.TYPE_HORIZONTAL) {\n return y === scrapperPosY;\n }\n if (scrapper?.type === SCRAPPER.TYPE_VERTICAL) {\n return x === scrapperPosX;\n }\n return false;\n }, [activePoint, id, scrapper, y, scrapperPosY, x, scrapperPosX]);\n\n const point = useMemo(() => {\n if (LINE.POINT_STYLE.DIAMOND === pointStyle) {\n const squareEdge = pointRadius * 2;\n\n return (\n <g transform=\"rotate(45)\">\n {isFocused ? (\n <rect\n x={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n y={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n width={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n height={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n fill=\"none\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect x={-pointRadius} y={-pointRadius} id={`${id}-mark`} width={squareEdge} height={squareEdge}></rect>\n </g>\n );\n }\n if (LINE.POINT_STYLE.SQUARE === pointStyle) {\n const squareEdge = pointRadius * 2;\n\n return (\n <g>\n {isFocused ? (\n <rect\n x={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n y={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n width={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n height={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n fill=\"none\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect x={-pointRadius} y={-pointRadius} id={`${id}-mark`} width={squareEdge} height={squareEdge}></rect>\n </g>\n );\n }\n\n return (\n <g>\n {isFocused ? (\n <g>\n <circle\n r={(pointRadius ?? LINE.DEFAULT_POINT_RADIUS) + FOCUS_RING.STROKE_WIDTH}\n fill=\"none\"\n // data-z-index=\"99\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></circle>\n </g>\n ) : null}\n <circle\n id={`${id}-mark`}\n r={pointRadius ?? (isFocused ? LINE.DEFAULT_POINT_RADIUS : 0)}\n opacity={opacity}\n ></circle>\n </g>\n );\n }, [id, isFocused, opacity, pointRadius, pointStyle]);\n\n const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n return (\n <>\n <g\n data-testid={DataVizDataTestIds.POINT}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n transform={`translate(${x},${y})`}\n >\n {point}\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n width={(pointRadius ?? 3) * 4}\n height={(pointRadius ?? 3) * 4}\n pointRadius={pointRadius}\n style={{ transform: `translate(-${pointRadius}px, -${pointRadius}px)` }}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : null}\n </g>\n {isFocused && withTrendHighlight ? <TrendHighlight currentDatum={datum} /> : null}\n </>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADgCf;AAhCR,mBAAwD;AACxD,0BAA6B;AAC7B,uBAA2C;AAC3C,6BAAgC;AAChC,4BAA+B;AAC/B,yBAAmC;AAC5B,MAAM,QAAQ,CAAC,EAAE,GAAG,GAAG,QAAQ,QAAQ,MAAM,YAAY,aAAa,IAAI,SAAS,MAAM,MAAM;AACpG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,UAAU,iBAAiB,mBAAmB;AAAA,EACzD,QAAI,yBAAW,gCAAY;AAC3B,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI,aAAa,QAAQ,IAAI;AAC3B,aAAO;AAAA,IACT;AACA,QAAI,UAAU,SAAS,0BAAS,iBAAiB;AAC/C,aAAO,MAAM;AAAA,IACf;AACA,QAAI,UAAU,SAAS,0BAAS,eAAe;AAC7C,aAAO,MAAM;AAAA,IACf;AACA,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,IAAI,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAEhE,QAAM,YAAQ,sBAAQ,MAAM;AAC1B,QAAI,sBAAK,YAAY,YAAY,YAAY;AAC3C,YAAM,aAAa,cAAc;AAEjC,aACE,6CAAC,OAAE,WAAU,cACV;AAAA,oBACC;AAAA,UAAC;AAAA;AAAA,YACC,GAAG,CAAC,cAAc,4BAAW;AAAA,YAC7B,GAAG,CAAC,cAAc,4BAAW;AAAA,Y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ACzC,QAAI,CAAC;AAAU,qBAAe,KAAK;AAAA,EACrC,GAAG,CAAC,OAAO,UAAU,cAAc,CAAC;AAEpC,QAAM,yBAAqB,0BAAY,MAAM;AAC3C,QAAI,CAAC;AAAU,qBAAe,IAAI;AAAA,EACpC,GAAG,CAAC,UAAU,cAAc,CAAC;AAC7B,SACE,4EACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,eAAa,sCAAmB;AAAA,QAChC,cAAc;AAAA,QACd,cAAc;AAAA,QACd,WAAW,aAAa,KAAK;AAAA,QAE5B;AAAA;AAAA,UACA,aAAa,QAAQ,MAAM,kBAC1B;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,QAAQ,eAAe,KAAK;AAAA,cAC5B,SAAS,eAAe,KAAK;AAAA,cAC7B;AAAA,cACA,OAAO,EAAE,WAAW,cAAc,mBAAmB,iBAAiB;AAAA,cACtE,SAAS,4CAAC,mBAAgB,MAAM,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC,GAAG;AAAA;AAAA,UAC9D,IACE;AAAA;AAAA;AAAA,IACN;AAAA,IACC,aAAa,qBAAqB,4CAAC,wCAAe,cAAc,OAAO,IAAK;AAAA,KAC/E;AAEJ;",
4
+ "sourcesContent": ["import React, { useContext, useCallback, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING, SCRAPPER, LINE } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { TrendHighlight } from '../parts/TrendHighlight';\nimport { DataVizDataTestIds } from '../DataTestIds';\nexport const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity, datum }) => {\n const {\n activePoint,\n scrapperPosY,\n scrapperPosX,\n setActivePoint,\n props: { scrapper, TooltipRenderer, withTrendHighlight },\n } = useContext(ChartContext);\n const isFocused = useMemo(() => {\n if (activePoint?.key === id) {\n return true;\n }\n if (scrapper?.type === SCRAPPER.TYPE_HORIZONTAL) {\n return y === scrapperPosY;\n }\n if (scrapper?.type === SCRAPPER.TYPE_VERTICAL) {\n return x === scrapperPosX;\n }\n return false;\n }, [activePoint, id, scrapper, y, scrapperPosY, x, scrapperPosX]);\n\n const point = useMemo(() => {\n if (LINE.POINT_STYLE.DIAMOND === pointStyle) {\n const squareEdge = pointRadius * 2;\n\n return (\n <g transform=\"rotate(45)\">\n {isFocused ? (\n <rect\n x={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n y={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n width={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n height={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n fill=\"none\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect x={-pointRadius} y={-pointRadius} id={`${id}-mark`} width={squareEdge} height={squareEdge}></rect>\n </g>\n );\n }\n if (LINE.POINT_STYLE.SQUARE === pointStyle) {\n const squareEdge = pointRadius * 2;\n\n return (\n <g>\n {isFocused ? (\n <rect\n x={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n y={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n width={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n height={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n fill=\"none\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect x={-pointRadius} y={-pointRadius} id={`${id}-mark`} width={squareEdge} height={squareEdge}></rect>\n </g>\n );\n }\n\n return (\n <g>\n {isFocused ? (\n <g>\n <circle\n r={(pointRadius ?? LINE.DEFAULT_POINT_RADIUS) + FOCUS_RING.STROKE_WIDTH}\n fill=\"none\"\n // data-z-index=\"99\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></circle>\n </g>\n ) : null}\n <circle\n id={`${id}-mark`}\n r={pointRadius ?? (isFocused ? LINE.DEFAULT_POINT_RADIUS : 0)}\n opacity={opacity}\n ></circle>\n </g>\n );\n }, [id, isFocused, opacity, pointRadius, pointStyle]);\n\n const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n return (\n <>\n <g\n data-testid={DataVizDataTestIds.POINT}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n transform={`translate(${x},${y})`}\n >\n {point}\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n width={(pointRadius ?? 3) * 4}\n height={(pointRadius ?? 3) * 4}\n style={{ transform: `translate(-${pointRadius ?? 3}px, -${pointRadius ?? 3}px)` }}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : null}\n </g>\n {isFocused && withTrendHighlight ? <TrendHighlight currentDatum={datum} /> : null}\n </>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADgCf;AAhCR,mBAAwD;AACxD,0BAA6B;AAC7B,uBAA2C;AAC3C,6BAAgC;AAChC,4BAA+B;AAC/B,yBAAmC;AAC5B,MAAM,QAAQ,CAAC,EAAE,GAAG,GAAG,QAAQ,QAAQ,MAAM,YAAY,aAAa,IAAI,SAAS,MAAM,MAAM;AACpG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,UAAU,iBAAiB,mBAAmB;AAAA,EACzD,QAAI,yBAAW,gCAAY;AAC3B,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI,aAAa,QAAQ,IAAI;AAC3B,aAAO;AAAA,IACT;AACA,QAAI,UAAU,SAAS,0BAAS,iBAAiB;AAC/C,aAAO,MAAM;AAAA,IACf;AACA,QAAI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  chartId,
123
123
  transform,
124
+ handleMouseEnter,
125
+ handleOnMouseLeave,
124
126
  isHorizontal,
125
127
  x,
126
128
  y,
127
129
  width,
128
130
  height,
129
- handleMouseEnter,
130
- handleOnMouseLeave,
131
131
  activePoint?.key,
132
132
  id,
133
133
  TooltipRenderer,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/graphs/Chart/series/Rect.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useMemo, useContext, useCallback } from 'react';\n\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { DataVizDataTestIds } from '../DataTestIds';\n\nexport const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id, xValue, yValue, datum }) => {\n const {\n activePoint,\n isGrabbed,\n chartId,\n isHorizontal,\n innerWidth,\n yScale,\n innerHeight,\n setActivePoint,\n props: { TooltipRenderer, scrapper },\n } = useContext(ChartContext);\n const isFocused = activePoint?.key === id;\n const animation = useMemo(() => {\n if (isGrabbed) return null;\n if (isHorizontal) return <animate attributeName=\"x\" from={-innerWidth} to={x} dur=\"0.4s\" fill=\"both\" />;\n if (isNegative) return <animate attributeName=\"y\" from={yScale(0)} to={-y} dur=\"0.40s\" fill=\"both\" />;\n return <animate attributeName=\"y\" from={-innerHeight - y} to={-y} dur=\"0.40s\" fill=\"both\" />;\n }, [innerHeight, innerWidth, isGrabbed, isHorizontal, isNegative, x, y, yScale]);\n\n const clipPathSign = useMemo(() => {\n // @todo horizontal clip paths\n if (isHorizontal) return '';\n if (isNegative) return `url(#rects-negative-${chartId})`;\n return `url(#rects-positive-${chartId})`;\n }, [chartId, isHorizontal, isNegative]);\n\n const transform = useMemo(() => {\n if (isHorizontal) return ``;\n return `scale(1,-1) translate(0,${-height})`;\n }, [height, isHorizontal]);\n\n const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n\n return useMemo(\n () => (\n <g clipPath={clipPathSign}>\n <g\n id={isFocused ? `data-focused-${chartId}` : ''}\n transform={transform}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n data-testid={DataVizDataTestIds.BAR}\n >\n {isFocused ? (\n <rect\n x={(isHorizontal ? x : 0) - FOCUS_RING.STROKE_WIDTH}\n y={(!isHorizontal ? -y : 0) - FOCUS_RING.STROKE_WIDTH}\n width={width + FOCUS_RING.OFFSET}\n height={height + FOCUS_RING.OFFSET}\n fill=\"none\"\n rx=\"1\"\n ry=\"1\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect width={width} height={height} y={-y} x={x}>\n {/* {animation} */}\n </rect>\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n y={y}\n x={x}\n width={width}\n height={height}\n transform={transform}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : (\n ''\n )}\n </g>\n </g>\n ),\n [\n clipPathSign,\n isFocused,\n chartId,\n transform,\n isHorizontal,\n x,\n y,\n width,\n height,\n handleMouseEnter,\n handleOnMouseLeave,\n activePoint?.key,\n id,\n TooltipRenderer,\n name,\n yValue,\n xValue,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
4
+ "sourcesContent": ["import React, { useMemo, useContext, useCallback } from 'react';\n\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { DataVizDataTestIds } from '../DataTestIds';\n\nexport const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id, xValue, yValue, datum }) => {\n const {\n activePoint,\n isGrabbed,\n chartId,\n isHorizontal,\n innerWidth,\n yScale,\n innerHeight,\n setActivePoint,\n props: { TooltipRenderer, scrapper },\n } = useContext(ChartContext);\n const isFocused = activePoint?.key === id;\n const animation = useMemo(() => {\n if (isGrabbed) return null;\n if (isHorizontal) return <animate attributeName=\"x\" from={-innerWidth} to={x} dur=\"0.4s\" fill=\"both\" />;\n if (isNegative) return <animate attributeName=\"y\" from={yScale(0)} to={-y} dur=\"0.40s\" fill=\"both\" />;\n return <animate attributeName=\"y\" from={-innerHeight - y} to={-y} dur=\"0.40s\" fill=\"both\" />;\n }, [innerHeight, innerWidth, isGrabbed, isHorizontal, isNegative, x, y, yScale]);\n\n const clipPathSign = useMemo(() => {\n // @todo horizontal clip paths\n if (isHorizontal) return '';\n if (isNegative) return `url(#rects-negative-${chartId})`;\n return `url(#rects-positive-${chartId})`;\n }, [chartId, isHorizontal, isNegative]);\n\n const transform = useMemo(() => {\n if (isHorizontal) return ``;\n return `scale(1,-1) translate(0,${-height})`;\n }, [height, isHorizontal]);\n\n const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n\n return useMemo(\n () => (\n <g clipPath={clipPathSign}>\n <g\n id={isFocused ? `data-focused-${chartId}` : ''}\n transform={transform}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n data-testid={DataVizDataTestIds.BAR}\n >\n {isFocused ? (\n <rect\n x={(isHorizontal ? x : 0) - FOCUS_RING.STROKE_WIDTH}\n y={(!isHorizontal ? -y : 0) - FOCUS_RING.STROKE_WIDTH}\n width={width + FOCUS_RING.OFFSET}\n height={height + FOCUS_RING.OFFSET}\n fill=\"none\"\n rx=\"1\"\n ry=\"1\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect width={width} height={height} y={-y} x={x}>\n {/* {animation} */}\n </rect>\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n y={y}\n x={x}\n width={width}\n height={height}\n transform={transform}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : (\n ''\n )}\n </g>\n </g>\n ),\n [\n clipPathSign,\n isFocused,\n chartId,\n transform,\n handleMouseEnter,\n handleOnMouseLeave,\n isHorizontal,\n x,\n y,\n width,\n height,\n activePoint?.key,\n id,\n TooltipRenderer,\n name,\n yValue,\n xValue,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADsBM;AAtB7B,mBAAwD;AAExD,0BAA6B;AAC7B,uBAA2B;AAC3B,6BAAgC;AAChC,yBAAmC;AAE5B,MAAM,OAAO,CAAC,EAAE,MAAM,OAAO,QAAQ,aAAa,OAAO,IAAI,MAAM,IAAI,MAAM,IAAI,QAAQ,QAAQ,MAAM,MAAM;AAClH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,iBAAiB,SAAS;AAAA,EACrC,QAAI,yBAAW,gCAAY;AAC3B,QAAM,YAAY,aAAa,QAAQ;AACvC,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI;AAAW,aAAO;AACtB,QAAI;AAAc,aAAO,4CAAC,aAAQ,eAAc,KAAI,MAAM,CAAC,YAAY,IAAI,GAAG,KAAI,QAAO,MAAK,QAAO;AACrG,QAAI;AAAY,aAAO,4CAAC,aAAQ,eAAc,KAAI,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,KAAI,SAAQ,MAAK,QAAO;AACnG,WAAO,4CAAC,aAAQ,eAAc,KAAI,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,KAAI,SAAQ,MAAK,QAAO;AAAA,EAC5F,GAAG,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;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,SAAS,4CAAC,mBAAgB,MAAM,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC,GAAG;AAAA;AAAA,UAC9D,IAEA;AAAA;AAAA;AAAA,IAEJ,GACF;AAAA,IAEF;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;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -52,7 +52,7 @@ const StackedBar = ({ serie }) => {
52
52
  const xValue = getXValue(bar);
53
53
  const yValue = sequence[1] - sequence[0];
54
54
  const width = subGroupScale?.bandwidth();
55
- const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 2 : 0);
55
+ const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 1 : 0);
56
56
  const transformX = xScale(xValue) + subGroupScale(`stacked-data-${stackIndex}`);
57
57
  const transformY = yScale(sequence[1]) + (sequence[0] < 0 ? 2 : 0);
58
58
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { fill: colorScale(serie.name), transform: `translate(${transformX},0)`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -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 {serie.data.map((bar, i) => {\n const sequence = serieWithStackedValues[bar.position];\n const isFloorStack = sequence[0] === 0;\n\n const xValue = getXValue(bar);\n\n const yValue = sequence[1] - sequence[0];\n const width = subGroupScale?.bandwidth();\n const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 2 : 0);\n const transformX = xScale(xValue) + subGroupScale(`stacked-data-${stackIndex}`);\n const transformY = yScale(sequence[1]) + (sequence[0] < 0 ? 2 : 0);\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 datum={bar}\n />\n </g>\n );\n })}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
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\n const yValue = sequence[1] - sequence[0];\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]) + (sequence[0] < 0 ? 2 : 0);\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 datum={bar}\n />\n </g>\n );\n })}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADqCX;AApCZ,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,OAAE,UAAU,wBAAwB,YAClC,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,UAAM,WAAW,uBAAuB,IAAI;AAC5C,UAAM,eAAe,SAAS,OAAO;AAErC,UAAM,SAAS,UAAU,GAAG;AAE5B,UAAM,SAAS,SAAS,KAAK,SAAS;AACtC,UAAM,QAAQ,eAAe,UAAU;AACvC,UAAM,SAAS,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAChF,UAAM,aAAa,OAAO,MAAM,IAAI,cAAc,gBAAgB,YAAY;AAC9E,UAAM,aAAa,OAAO,SAAS,EAAE,KAAK,SAAS,KAAK,IAAI,IAAI;AAEhE,WACE,4CAAC,OAA0B,MAAM,WAAW,MAAM,IAAI,GAAG,WAAW,aAAa,iBAC/E;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,QACH,IAAI,MAAM,KAAK,GAAG;AAAA,QAClB,MAAM,MAAM;AAAA,QACZ,OAAO;AAAA;AAAA,IACT,KAVM,MAAM,KAAK,GAAG,GAWtB;AAAA,EAEJ,CAAC,GACH;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -28,6 +28,7 @@ __export(constants_exports, {
28
28
  LINE: () => LINE,
29
29
  SCALE_TYPES: () => SCALE_TYPES,
30
30
  SCRAPPER: () => SCRAPPER,
31
+ TOOLBAR: () => TOOLBAR,
31
32
  curveStyleMap: () => curveStyleMap
32
33
  });
33
34
  module.exports = __toCommonJS(constants_exports);
@@ -76,4 +77,10 @@ const curveStyleMap = {
76
77
  [LINE.CURVE_STYLE.LINEAR]: import_d3.curveLinear,
77
78
  [LINE.CURVE_STYLE.SPLINE]: import_d3.curveMonotoneX
78
79
  };
80
+ const TOOLBAR = {
81
+ RESET: {
82
+ HEIGHT: 21,
83
+ WIDTH: 21
84
+ }
85
+ };
79
86
  //# sourceMappingURL=constants.js.map
@@ -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 { 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;",
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\nexport const TOOLBAR = {\n RESET: {\n HEIGHT: 21,\n WIDTH: 21,\n },\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;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;AAEO,MAAM,UAAU;AAAA,EACrB,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
@@ -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 type React from 'react';\nimport { createContext, createRef } from 'react';\nimport type { ScaleLinear, ScaleBand, ScaleOrdinal } from 'd3';\nimport { scaleLinear, scaleBand, scaleOrdinal } from 'd3';\nimport type { DSChartT } from './react-desc-prop-types';\nimport { defaultProps } 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 lastPosition: 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;ACCvB,SAAS,eAAe,iBAAiB;AAEzC,SAAS,aAAa,WAAW,oBAAoB;AAErD,SAAS,oBAAoB;AAkE7B,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;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\nimport { createContext, createRef } from 'react';\nimport type { ScaleLinear, ScaleBand, ScaleOrdinal } from 'd3';\nimport { scaleLinear, scaleBand, scaleOrdinal } from 'd3';\nimport type { DSChartT } from './react-desc-prop-types';\nimport { defaultProps } from './react-desc-prop-types';\ninterface ContextT {\n props: DSChartT.Props;\n originalSeries: DSChartT.SeriesT;\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 lastPosition: React.MutableRefObject<number>;\n containerRatio: number;\n internalMargin: {\n bottom: number;\n top: number;\n right: number;\n left: number;\n };\n toolbarHeight: number;\n leftLegendHeight: number;\n rightLegendHeight: number;\n leftLabelHeight: number;\n leftLegendWidth: number;\n leftLegend: SVGGElement;\n bottomLegend: 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 width: number;\n height: number;\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 setContainerRatio: React.Dispatch<React.SetStateAction<number>>;\n setToolbarRef: React.Dispatch<React.SetStateAction<SVGGElement | null>>;\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;ACCvB,SAAS,eAAe,iBAAiB;AAEzC,SAAS,aAAa,WAAW,oBAAoB;AAErD,SAAS,oBAAoB;AA4E7B,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
  }
@@ -2,20 +2,22 @@ import * as React from "react";
2
2
  import { useMemo, useState, useEffect, useRef } from "react";
3
3
  import { uid } from "uid";
4
4
  import { debounce } from "lodash";
5
+ import { defaultProps, propTypes } from "../react-desc-prop-types";
5
6
  import { useScales } from "./useScales";
6
7
  import { stackData } from "../helpers";
7
8
  import { useInternalMargins } from "./useInternalMargins";
8
9
  import { useGetters } from "./useGetters";
9
10
  import ResizeObserver from "resize-observer-polyfill";
11
+ import { useValidateProps } from "./useValidateProps";
10
12
  const useResizeObserver = (ref) => {
11
- const [dimensions, setDimensions] = useState(null);
13
+ const [dimensions, setDimensions] = useState(0);
12
14
  useEffect(() => {
13
15
  if (ref) {
14
16
  const observeTarget = ref;
15
17
  const resizeObserver = new ResizeObserver(
16
18
  debounce((entries) => {
17
19
  entries.forEach((entry) => {
18
- setDimensions(entry.contentRect);
20
+ setDimensions(Math.ceil(entry.contentRect.width));
19
21
  });
20
22
  }, 200)
21
23
  );
@@ -28,14 +30,24 @@ const useResizeObserver = (ref) => {
28
30
  return dimensions;
29
31
  };
30
32
  const useChart = (props) => {
33
+ useValidateProps(props, propTypes);
31
34
  const { series, yAxis, xAxis, width: userWidth, height: userHeight, groups: groupsStacked } = props;
35
+ const originalSeries = useMemo(() => {
36
+ if (series.length === 0) {
37
+ return defaultProps.series;
38
+ }
39
+ return series;
40
+ }, [series]);
32
41
  const [containerRef, setContainerRef] = useState(null);
33
42
  const svgRef = useRef(null);
34
- const dimensions = useResizeObserver(containerRef);
35
- const width = useMemo(() => userWidth ?? dimensions?.width ?? 0, [dimensions, userWidth]);
43
+ const dimensionWidth = useResizeObserver(containerRef);
44
+ const width = useMemo(() => userWidth ?? dimensionWidth ?? 0, [dimensionWidth, userWidth]);
36
45
  const height = useMemo(() => userHeight ?? 500, [userHeight]);
37
46
  const [isGrabbed, setIsGrabbed] = useState(false);
38
47
  const [startPosition, setStartPosition] = useState(0);
48
+ const [isZooming, setIsZooming] = useState(false);
49
+ const [zoomStartingPosition, setZoomStartingPosition] = useState(0);
50
+ const [movingPosition, setMovingPosition] = useState(0);
39
51
  const [activePoint, setActivePoint] = useState(null);
40
52
  const [activeSerie, setActiveSerie] = useState("");
41
53
  const [scrapperPosY, setScrapperPosY] = useState("");
@@ -64,7 +76,14 @@ const useChart = (props) => {
64
76
  bottomLabelHeight,
65
77
  internalMargin,
66
78
  leftLegendWidth,
67
- rightLabelWidth
79
+ rightLabelWidth,
80
+ leftLabelHeight,
81
+ rightLegendHeight,
82
+ bottomLegendWidth,
83
+ leftLabelWidth,
84
+ axisLeftWidth,
85
+ topLegendHeight,
86
+ leftLegendHeight
68
87
  } = useInternalMargins({
69
88
  axisLeftRef,
70
89
  axisBottomRef,
@@ -88,7 +107,7 @@ const useChart = (props) => {
88
107
  );
89
108
  const [hiddenSeries, setHiddenSeries] = useState([]);
90
109
  const currentData = useMemo(
91
- () => series.filter((serie) => !hiddenSeries.includes(serie.name)).map((d, i) => ({
110
+ () => originalSeries.filter((serie) => !hiddenSeries.includes(serie.name)).map((d, i) => ({
92
111
  ...d,
93
112
  key: `${d.name}-${i}`,
94
113
  data: d.data.map((value, index) => ({
@@ -99,12 +118,13 @@ const useChart = (props) => {
99
118
  scale: d.scale
100
119
  })).filter((datum) => datum.value !== null && datum.value !== void 0)
101
120
  })),
102
- [hiddenSeries, series]
121
+ [hiddenSeries, originalSeries]
103
122
  );
104
123
  const stackedData = useMemo(() => stackData(groupsStacked, currentData), [groupsStacked, currentData]);
105
124
  const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);
106
125
  const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = useScales({
107
126
  props,
127
+ originalSeries,
108
128
  innerHeight,
109
129
  innerWidth,
110
130
  groups,
@@ -125,6 +145,13 @@ const useChart = (props) => {
125
145
  return useMemo(
126
146
  () => ({
127
147
  props,
148
+ originalSeries,
149
+ isZooming,
150
+ setIsZooming,
151
+ zoomStartingPosition,
152
+ setZoomStartingPosition,
153
+ setMovingPosition,
154
+ movingPosition,
128
155
  innerHeight,
129
156
  innerWidth,
130
157
  groups,
@@ -189,10 +216,22 @@ const useChart = (props) => {
189
216
  width,
190
217
  setContainerRatio,
191
218
  toolbarHeight,
192
- setToolbarRef
219
+ setToolbarRef,
220
+ leftLabelHeight,
221
+ rightLegendHeight,
222
+ bottomLegendWidth,
223
+ bottomLegend,
224
+ leftLabelWidth,
225
+ axisLeftWidth,
226
+ topLegendHeight,
227
+ leftLegendHeight
193
228
  }),
194
229
  [
195
230
  props,
231
+ originalSeries,
232
+ isZooming,
233
+ zoomStartingPosition,
234
+ movingPosition,
196
235
  innerHeight,
197
236
  innerWidth,
198
237
  groups,
@@ -233,9 +272,15 @@ const useChart = (props) => {
233
272
  hiddenSeries,
234
273
  height,
235
274
  width,
236
- setContainerRatio,
237
275
  toolbarHeight,
238
- setToolbarRef
276
+ leftLabelHeight,
277
+ rightLegendHeight,
278
+ bottomLegendWidth,
279
+ bottomLegend,
280
+ leftLabelWidth,
281
+ axisLeftWidth,
282
+ topLegendHeight,
283
+ leftLegendHeight
239
284
  ]
240
285
  );
241
286
  };
@@ -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, useEffect, useRef } from 'react';\nimport { uid } from 'uid';\nimport { debounce } from 'lodash';\nimport type { ScaleBand } from 'd3';\n// import { useResizeObserver } 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';\nimport ResizeObserver from 'resize-observer-polyfill';\n\ntype ResizeObserverConstructorEntries = Parameters<ConstructorParameters<typeof ResizeObserver>[0]>[0];\ntype DimensionT = ResizeObserverConstructorEntries[0]['contentRect'] | null;\n\nconst useResizeObserver = (ref: HTMLElement | null | undefined) => {\n const [dimensions, setDimensions] = useState<DimensionT>(null);\n useEffect(() => {\n if (ref) {\n const observeTarget = ref;\n const resizeObserver = new ResizeObserver(\n debounce((entries: ResizeObserverConstructorEntries) => {\n entries.forEach((entry) => {\n setDimensions(entry.contentRect);\n });\n }, 200),\n );\n resizeObserver.observe(observeTarget);\n\n return () => {\n resizeObserver.unobserve(observeTarget);\n };\n }\n }, [ref]);\n return dimensions;\n};\n\nexport const useChart = (props: DSChartT.Props) => {\n // useValidateTypescriptPropTypes(props, propTypes);\n\n const { series, yAxis, xAxis, width: userWidth, height: userHeight, groups: groupsStacked } = props;\n\n const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null);\n const svgRef = useRef(null);\n\n const dimensions = useResizeObserver(containerRef);\n const width = useMemo(() => userWidth ?? dimensions?.width ?? 0, [dimensions, userWidth]);\n\n const height = useMemo(() => userHeight ?? 500, [userHeight]);\n\n // useResizeObserver(({ width: newWidth, height: newHeight }) => {\n // setResizeWidth(newWidth);\n // }, containerRef?.parentElement);\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 [containerRatio, setContainerRatio] = useState(\n props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1,\n );\n\n const lastPosition = 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 [toolbarRef, setToolbarRef] = useState<SVGGElement | null>(null);\n\n const {\n toolbarHeight,\n axisBottomHeight,\n axisRightWidth,\n bottomLabelHeight,\n internalMargin,\n leftLegendWidth,\n rightLabelWidth,\n } = useInternalMargins({\n axisLeftRef,\n axisBottomRef,\n axisRightRef,\n leftLabel,\n leftLegend,\n rightLegend,\n topLegend,\n bottomLegend,\n rightLabel,\n bottomLabel,\n toolbarRef,\n });\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 scale: d.scale,\n }))\n .filter((datum) => datum.value !== null && datum.value !== undefined), // basically converting from DSChartT.SeriesT to DSChartT.InternalData...\n })) as DSChartT.InternalData,\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 y2Scale,\n });\n const chartId = useMemo(() => uid(6), []);\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 setContainerRef,\n startPosition,\n setStartPosition,\n isScrollbarVisible,\n setIsScrollbarVisible,\n lastPosition,\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 height,\n width,\n setContainerRatio,\n toolbarHeight,\n setToolbarRef,\n }),\n [\n props,\n innerHeight,\n innerWidth,\n groups,\n currentData,\n colorScale,\n stackedData,\n subGroupScale,\n xScale,\n yScale,\n y2Scale,\n containerRef,\n getBandwidth,\n scrapperPosY,\n scrapperPosX,\n activePoint,\n activeSerie,\n xScrollbarPosition,\n isGrabbed,\n startPosition,\n isScrollbarVisible,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n rightLegend,\n axisBottomHeight,\n getXScaleValue,\n getYScaleValue,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n leftLabel,\n chartId,\n hiddenSeries,\n height,\n width,\n setContainerRatio,\n toolbarHeight,\n setToolbarRef,\n ],\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,UAAU,WAAW,cAAc;AACrD,SAAS,WAAW;AACpB,SAAS,gBAAgB;AAKzB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,OAAO,oBAAoB;AAK3B,MAAM,oBAAoB,CAAC,QAAwC;AACjE,QAAM,CAAC,YAAY,aAAa,IAAI,SAAqB,IAAI;AAC7D,YAAU,MAAM;AACd,QAAI,KAAK;AACP,YAAM,gBAAgB;AACtB,YAAM,iBAAiB,IAAI;AAAA,QACzB,SAAS,CAAC,YAA8C;AACtD,kBAAQ,QAAQ,CAAC,UAAU;AACzB,0BAAc,MAAM,WAAW;AAAA,UACjC,CAAC;AAAA,QACH,GAAG,GAAG;AAAA,MACR;AACA,qBAAe,QAAQ,aAAa;AAEpC,aAAO,MAAM;AACX,uBAAe,UAAU,aAAa;AAAA,MACxC;AAAA,IACF;AAAA,EACF,GAAG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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,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,IACF;AAAA,EACF;AACF;",
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, useEffect, useRef } from 'react';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-utilities';\nimport { uid } from 'uid';\nimport { debounce } from 'lodash';\nimport type { ScaleBand } from 'd3';\nimport type { DSChartT } from '../react-desc-prop-types';\nimport { defaultProps, propTypes } from '../react-desc-prop-types';\nimport { useScales } from './useScales';\nimport { stackData } from '../helpers';\nimport { useInternalMargins } from './useInternalMargins';\nimport { useGetters } from './useGetters';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport { useValidateProps } from './useValidateProps';\ntype ResizeObserverConstructorEntries = Parameters<ConstructorParameters<typeof ResizeObserver>[0]>[0];\n\nconst useResizeObserver = (ref: HTMLElement | null | undefined) => {\n const [dimensions, setDimensions] = useState<number>(0);\n\n useEffect(() => {\n if (ref) {\n const observeTarget = ref;\n const resizeObserver = new ResizeObserver(\n debounce((entries: ResizeObserverConstructorEntries) => {\n entries.forEach((entry) => {\n setDimensions(Math.ceil(entry.contentRect.width));\n });\n }, 200),\n );\n resizeObserver.observe(observeTarget);\n\n return () => {\n resizeObserver.unobserve(observeTarget);\n };\n }\n }, [ref]);\n return dimensions;\n};\n\nexport const useChart = (props: DSChartT.Props) => {\n useValidateProps(props, propTypes);\n\n // const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n const { series, yAxis, xAxis, width: userWidth, height: userHeight, groups: groupsStacked } = props;\n\n const originalSeries = useMemo(() => {\n if (series.length === 0) {\n return defaultProps.series;\n }\n return series;\n }, [series]);\n const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null);\n const svgRef = useRef(null);\n\n const dimensionWidth = useResizeObserver(containerRef);\n const width = useMemo(() => userWidth ?? dimensionWidth ?? 0, [dimensionWidth, userWidth]);\n\n const height = useMemo(() => userHeight ?? 500, [userHeight]);\n\n const [isGrabbed, setIsGrabbed] = useState(false);\n const [startPosition, setStartPosition] = useState(0);\n\n // zoom\n\n const [isZooming, setIsZooming] = useState(false);\n const [zoomStartingPosition, setZoomStartingPosition] = useState(0);\n const [movingPosition, setMovingPosition] = useState(0);\n\n //\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 [containerRatio, setContainerRatio] = useState(\n props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1,\n );\n\n const lastPosition = 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 [toolbarRef, setToolbarRef] = useState<SVGGElement | null>(null);\n\n const {\n toolbarHeight,\n axisBottomHeight,\n axisRightWidth,\n bottomLabelHeight,\n internalMargin,\n leftLegendWidth,\n rightLabelWidth,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n leftLegendHeight,\n } = useInternalMargins({\n axisLeftRef,\n axisBottomRef,\n axisRightRef,\n leftLabel,\n leftLegend,\n rightLegend,\n topLegend,\n bottomLegend,\n rightLabel,\n bottomLabel,\n toolbarRef,\n });\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 originalSeries\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 scale: d.scale,\n }))\n .filter((datum) => datum.value !== null && datum.value !== undefined), // basically converting from DSChartT.SeriesT to DSChartT.InternalData...\n })) as DSChartT.InternalData,\n [hiddenSeries, originalSeries],\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 originalSeries,\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 y2Scale,\n });\n const chartId = useMemo(() => uid(6), []);\n\n return useMemo(\n () => ({\n props,\n originalSeries,\n isZooming,\n setIsZooming,\n zoomStartingPosition,\n setZoomStartingPosition,\n setMovingPosition,\n movingPosition,\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 setContainerRef,\n startPosition,\n setStartPosition,\n isScrollbarVisible,\n setIsScrollbarVisible,\n lastPosition,\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 height,\n width,\n setContainerRatio,\n toolbarHeight,\n setToolbarRef,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n bottomLegend,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n leftLegendHeight,\n }),\n [\n props,\n originalSeries,\n isZooming,\n zoomStartingPosition,\n movingPosition,\n innerHeight,\n innerWidth,\n groups,\n currentData,\n colorScale,\n stackedData,\n subGroupScale,\n xScale,\n yScale,\n y2Scale,\n containerRef,\n getBandwidth,\n scrapperPosY,\n scrapperPosX,\n activePoint,\n activeSerie,\n xScrollbarPosition,\n isGrabbed,\n startPosition,\n isScrollbarVisible,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n rightLegend,\n axisBottomHeight,\n getXScaleValue,\n getYScaleValue,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n leftLabel,\n chartId,\n hiddenSeries,\n height,\n width,\n toolbarHeight,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n bottomLegend,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n leftLegendHeight,\n ],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,UAAU,WAAW,cAAc;AAErD,SAAS,WAAW;AACpB,SAAS,gBAAgB;AAGzB,SAAS,cAAc,iBAAiB;AACxC,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,OAAO,oBAAoB;AAC3B,SAAS,wBAAwB;AAGjC,MAAM,oBAAoB,CAAC,QAAwC;AACjE,QAAM,CAAC,YAAY,aAAa,IAAI,SAAiB,CAAC;AAEtD,YAAU,MAAM;AACd,QAAI,KAAK;AACP,YAAM,gBAAgB;AACtB,YAAM,iBAAiB,I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AAW;AAAA,IAC1E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,UAAU,QAAQ,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;AAExC,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,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,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,26 @@
1
1
  import * as React from "react";
2
- import { useMemo } from "react";
3
- const getElementWidthCeiled = (element, offset = 0) => element?.getBoundingClientRect()?.width ? Math.ceil(element?.getBoundingClientRect()?.width + offset) : 0;
4
- const getElementHeightCeiled = (element, offset = 0) => element?.getBoundingClientRect()?.height ? Math.ceil(element?.getBoundingClientRect()?.height + offset) : 0;
2
+ import { useMemo, useEffect, useState } from "react";
3
+ import ResizeObserver from "resize-observer-polyfill";
4
+ const useResizeObserver = (ref, { offsetHeight = 0, offsetWidth = 0 } = { offsetHeight: 0, offsetWidth: 0 }) => {
5
+ const [width, setWidth] = useState(0);
6
+ const [height, setHeight] = useState(0);
7
+ useEffect(() => {
8
+ if (ref) {
9
+ const observeTarget = ref;
10
+ const resizeObserver = new ResizeObserver((entries) => {
11
+ entries.forEach((entry) => {
12
+ setWidth(Math.ceil(entry.contentRect.width + offsetWidth));
13
+ setHeight(Math.ceil(entry.contentRect.height + offsetHeight));
14
+ });
15
+ });
16
+ resizeObserver.observe(observeTarget);
17
+ return () => {
18
+ resizeObserver.unobserve(observeTarget);
19
+ };
20
+ }
21
+ }, [offsetHeight, offsetWidth, ref]);
22
+ return { width, height };
23
+ };
5
24
  const useInternalMargins = ({
6
25
  axisLeftRef,
7
26
  axisBottomRef,
@@ -15,23 +34,25 @@ const useInternalMargins = ({
15
34
  bottomLabel,
16
35
  toolbarRef
17
36
  }) => {
18
- const axisLeftWidth = useMemo(() => getElementWidthCeiled(axisLeftRef), [axisLeftRef]);
19
- const axisBottomHeight = useMemo(() => getElementHeightCeiled(axisBottomRef, 20), [axisBottomRef]);
20
- const axisRightWidth = useMemo(() => getElementWidthCeiled(axisRightRef), [axisRightRef]);
21
- const bottomLabelHeight = useMemo(() => getElementHeightCeiled(bottomLabel, 10), [bottomLabel]);
22
- const rightLabelWidth = useMemo(() => getElementWidthCeiled(rightLabel), [rightLabel]);
23
- const leftLabelWidth = useMemo(() => getElementWidthCeiled(leftLabel), [leftLabel]);
24
- const topLegendHeight = useMemo(() => getElementHeightCeiled(topLegend), [topLegend]);
25
- const bottomLegendHeight = useMemo(() => getElementHeightCeiled(bottomLegend), [bottomLegend]);
26
- const rightLegendWidth = useMemo(() => getElementWidthCeiled(rightLegend), [rightLegend]);
27
- const leftLegendWidth = useMemo(() => getElementWidthCeiled(leftLegend), [leftLegend]);
28
- const toolbarHeight = useMemo(() => getElementHeightCeiled(toolbarRef), [toolbarRef]);
37
+ const { height: toolbarHeight } = useResizeObserver(toolbarRef, { offsetHeight: 10 });
38
+ const { width: axisRightWidth } = useResizeObserver(axisRightRef);
39
+ const { height: axisBottomHeight } = useResizeObserver(axisBottomRef, { offsetHeight: 20 });
40
+ const { width: axisLeftWidth } = useResizeObserver(axisLeftRef, { offsetWidth: 10 });
41
+ const { height: bottomLabelHeight } = useResizeObserver(bottomLabel, { offsetHeight: 10 });
42
+ const { width: rightLabelWidth } = useResizeObserver(rightLabel);
43
+ const { width: leftLabelWidth, height: leftLabelHeight } = useResizeObserver(leftLabel);
44
+ const { height: topLegendHeight } = useResizeObserver(topLegend, { offsetHeight: 20 });
45
+ const { height: bottomLegendHeight, width: bottomLegendWidth } = useResizeObserver(bottomLegend, {
46
+ offsetHeight: 10
47
+ });
48
+ const { width: rightLegendWidth, height: rightLegendHeight } = useResizeObserver(rightLegend);
49
+ const { width: leftLegendWidth, height: leftLegendHeight } = useResizeObserver(leftLegend, { offsetWidth: 20 });
29
50
  const internalMargin = useMemo(
30
51
  () => ({
31
- bottom: 10 + axisBottomHeight + bottomLegendHeight + bottomLabelHeight,
32
- top: 10 + topLegendHeight + toolbarHeight,
33
- right: 15 + rightLabelWidth + axisRightWidth + rightLegendWidth,
34
- left: 10 + axisLeftWidth + leftLabelWidth + leftLegendWidth
52
+ bottom: axisBottomHeight + bottomLegendHeight + bottomLabelHeight || 10,
53
+ top: Math.max(topLegendHeight, toolbarHeight) || 10,
54
+ right: rightLabelWidth + axisRightWidth + rightLegendWidth || 10,
55
+ left: axisLeftWidth + leftLabelWidth + leftLegendWidth || 10
35
56
  }),
36
57
  [
37
58
  axisBottomHeight,
@@ -50,6 +71,7 @@ const useInternalMargins = ({
50
71
  return useMemo(
51
72
  () => ({
52
73
  internalMargin,
74
+ leftLegendHeight,
53
75
  leftLegendWidth,
54
76
  axisBottomHeight,
55
77
  bottomLegendHeight,
@@ -60,11 +82,15 @@ const useInternalMargins = ({
60
82
  rightLegendWidth,
61
83
  axisLeftWidth,
62
84
  leftLabelWidth,
63
- toolbarHeight
85
+ toolbarHeight,
86
+ leftLabelHeight,
87
+ rightLegendHeight,
88
+ bottomLegendWidth
64
89
  }),
65
90
  [
66
91
  axisBottomHeight,
67
92
  toolbarHeight,
93
+ leftLegendHeight,
68
94
  axisLeftWidth,
69
95
  axisRightWidth,
70
96
  bottomLabelHeight,
@@ -74,7 +100,10 @@ const useInternalMargins = ({
74
100
  leftLegendWidth,
75
101
  rightLabelWidth,
76
102
  rightLegendWidth,
77
- topLegendHeight
103
+ topLegendHeight,
104
+ leftLabelHeight,
105
+ rightLegendHeight,
106
+ bottomLegendWidth
78
107
  ]
79
108
  );
80
109
  };
@@ -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: 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 toolbarRef: SVGGElement | null;\n}\n\nconst getElementWidthCeiled = (element: SVGGElement | null, offset = 0) =>\n element?.getBoundingClientRect()?.width ? Math.ceil(element?.getBoundingClientRect()?.width + offset) : 0;\n\nconst getElementHeightCeiled = (element: SVGGElement | null, offset = 0) =>\n element?.getBoundingClientRect()?.height ? Math.ceil(element?.getBoundingClientRect()?.height + offset) : 0;\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 toolbarRef,\n}: UseInternalMarginsT) => {\n // We get the measurements of the elements that are outside of the chart\n // We ceil those numbers to avoid having double datatype on the variables\n // So that the use memos don't retrigger to often because of the dependency\n\n // Axis\n const axisLeftWidth = useMemo(() => getElementWidthCeiled(axisLeftRef), [axisLeftRef]);\n const axisBottomHeight = useMemo(() => getElementHeightCeiled(axisBottomRef, 20), [axisBottomRef]);\n const axisRightWidth = useMemo(() => getElementWidthCeiled(axisRightRef), [axisRightRef]);\n\n // Labels\n const bottomLabelHeight = useMemo(() => getElementHeightCeiled(bottomLabel, 10), [bottomLabel]);\n const rightLabelWidth = useMemo(() => getElementWidthCeiled(rightLabel), [rightLabel]);\n const leftLabelWidth = useMemo(() => getElementWidthCeiled(leftLabel), [leftLabel]);\n // Legends\n const topLegendHeight = useMemo(() => getElementHeightCeiled(topLegend), [topLegend]);\n const bottomLegendHeight = useMemo(() => getElementHeightCeiled(bottomLegend), [bottomLegend]);\n const rightLegendWidth = useMemo(() => getElementWidthCeiled(rightLegend), [rightLegend]);\n const leftLegendWidth = useMemo(() => getElementWidthCeiled(leftLegend), [leftLegend]);\n\n const toolbarHeight = useMemo(() => getElementHeightCeiled(toolbarRef), [toolbarRef]);\n\n const internalMargin = useMemo(\n () => ({\n bottom: 10 + axisBottomHeight + bottomLegendHeight + bottomLabelHeight,\n top: 10 + topLegendHeight + toolbarHeight,\n right: 15 + rightLabelWidth + axisRightWidth + rightLegendWidth,\n left: 10 + axisLeftWidth + leftLabelWidth + leftLegendWidth,\n }),\n\n [\n axisBottomHeight,\n bottomLegendHeight,\n bottomLabelHeight,\n topLegendHeight,\n toolbarHeight,\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 toolbarHeight,\n }),\n [\n axisBottomHeight,\n toolbarHeight,\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
- "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,eAAe;AAgBxB,MAAM,wBAAwB,CAAC,SAA6B,SAAS,MACnE,SAAS,sBAAsB,GAAG,QAAQ,KAAK,KAAK,SAAS,sBAAsB,GAAG,QAAQ,MAAM,IAAI;AAE1G,MAAM,yBAAyB,CAAC,SAA6B,SAAS,MACpE,SAAS,sBAAsB,GAAG,SAAS,KAAK,KAAK,S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AA,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;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,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,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useEffect, useState } from 'react';\nimport ResizeObserver from 'resize-observer-polyfill';\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 toolbarRef: SVGGElement | null;\n}\n\ntype ResizeObserverConstructorEntries = Parameters<ConstructorParameters<typeof ResizeObserver>[0]>[0];\n\nconst useResizeObserver = (\n ref: SVGGElement | null,\n { offsetHeight = 0, offsetWidth = 0 } = { offsetHeight: 0, offsetWidth: 0 },\n) => {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n\n useEffect(() => {\n if (ref) {\n const observeTarget = ref;\n const resizeObserver = new ResizeObserver((entries: ResizeObserverConstructorEntries) => {\n entries.forEach((entry) => {\n setWidth(Math.ceil(entry.contentRect.width + offsetWidth));\n setHeight(Math.ceil(entry.contentRect.height + offsetHeight));\n });\n });\n\n resizeObserver.observe(observeTarget);\n\n return () => {\n resizeObserver.unobserve(observeTarget);\n };\n }\n }, [offsetHeight, offsetWidth, ref]);\n return { width, height };\n};\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 toolbarRef,\n}: UseInternalMarginsT) => {\n // Toolbar\n const { height: toolbarHeight } = useResizeObserver(toolbarRef, { offsetHeight: 10 });\n\n // Axis\n const { width: axisRightWidth } = useResizeObserver(axisRightRef);\n const { height: axisBottomHeight } = useResizeObserver(axisBottomRef, { offsetHeight: 20 });\n const { width: axisLeftWidth } = useResizeObserver(axisLeftRef, { offsetWidth: 10 });\n\n // Labels\n const { height: bottomLabelHeight } = useResizeObserver(bottomLabel, { offsetHeight: 10 });\n const { width: rightLabelWidth } = useResizeObserver(rightLabel);\n const { width: leftLabelWidth, height: leftLabelHeight } = useResizeObserver(leftLabel);\n\n // Legends\n const { height: topLegendHeight } = useResizeObserver(topLegend, { offsetHeight: 20 });\n const { height: bottomLegendHeight, width: bottomLegendWidth } = useResizeObserver(bottomLegend, {\n offsetHeight: 10,\n });\n const { width: rightLegendWidth, height: rightLegendHeight } = useResizeObserver(rightLegend);\n const { width: leftLegendWidth, height: leftLegendHeight } = useResizeObserver(leftLegend, { offsetWidth: 20 });\n\n const internalMargin = useMemo(\n () => ({\n bottom: axisBottomHeight + bottomLegendHeight + bottomLabelHeight || 10,\n top: Math.max(topLegendHeight, toolbarHeight) || 10,\n right: rightLabelWidth + axisRightWidth + rightLegendWidth || 10,\n left: axisLeftWidth + leftLabelWidth + leftLegendWidth || 10,\n }),\n\n [\n axisBottomHeight,\n bottomLegendHeight,\n bottomLabelHeight,\n topLegendHeight,\n toolbarHeight,\n rightLabelWidth,\n axisRightWidth,\n rightLegendWidth,\n axisLeftWidth,\n leftLabelWidth,\n leftLegendWidth,\n ],\n );\n\n return useMemo(\n () => ({\n internalMargin,\n leftLegendHeight,\n leftLegendWidth,\n axisBottomHeight,\n bottomLegendHeight,\n bottomLabelHeight,\n topLegendHeight,\n rightLabelWidth,\n axisRightWidth,\n rightLegendWidth,\n axisLeftWidth,\n leftLabelWidth,\n toolbarHeight,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n }),\n [\n axisBottomHeight,\n toolbarHeight,\n leftLegendHeight,\n axisLeftWidth,\n axisRightWidth,\n bottomLabelHeight,\n bottomLegendHeight,\n internalMargin,\n leftLabelWidth,\n leftLegendWidth,\n rightLabelWidth,\n rightLegendWidth,\n topLegendHeight,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n ],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,SAAS,WAAW,gBAAgB;AAC7C,OAAO,oBAAoB;AAkB3B,MAAM,oBAAoB,CACxB,KACA,EAAE,eAAe,GAAG,cAAc,EAAE,IAAI,EAAE,cAAc,GAAG,aAAa,EAAE,MACvE;AACH,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAiB,CAAC;AAC5C,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAiB,CAAC;AAE9C,YAAU,MAAM;AACd,QAAI,KAAK;AACP,YAAM,gBAAgB;AACtB,YAAM,iBAAiB,IAAI,eAAe,CAAC,YAA8C;AACvF,gBAAQ,QAAQ,CAAC,UAAU;AACzB,mBAAS,KAAK,KAAK,MAAM,YAAY,QAAQ,WAAW,CAAC;AACzD,oBAAU,KAAK,KAAK,MAAM,YAAY,SAAS,YAAY,CAAC;AAAA,QAC9D,CAAC;AAAA,MACH,CAAC;AAED,qBAAe,QAAQ,aAAa;AAEpC,aAAO,MAAM;AACX,uBAAe,UAAU,aAAa;AAAA,MACxC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,aAAa,GAAG,CAAC;AACnC,SAAO,EAAE,OAAO,OAAO;AACzB;AAEO,MAA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