@elliemae/ds-dataviz 3.8.1 → 3.9.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/cjs/graphs/Chart/Chart.js.map +2 -2
  2. package/dist/cjs/graphs/Chart/ChartContext.js +3 -1
  3. package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
  4. package/dist/cjs/graphs/Chart/config/useChart.js +86 -33
  5. package/dist/cjs/graphs/Chart/config/useChart.js.map +3 -3
  6. package/dist/cjs/graphs/Chart/config/useInternalMargins.js +103 -0
  7. package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +7 -0
  8. package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +25 -15
  9. package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
  10. package/dist/cjs/graphs/Chart/config/useScales.js +43 -17
  11. package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
  12. package/dist/cjs/graphs/Chart/helpers/index.js +9 -13
  13. package/dist/cjs/graphs/Chart/helpers/index.js.map +2 -2
  14. package/dist/cjs/graphs/Chart/parts/ActivePoint.js +1 -1
  15. package/dist/cjs/graphs/Chart/parts/ActivePoint.js.map +2 -2
  16. package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js +17 -25
  17. package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
  18. package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js +33 -38
  19. package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
  20. package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js +6 -11
  21. package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
  22. package/dist/cjs/graphs/Chart/parts/ChartContainer.js +65 -16
  23. package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
  24. package/dist/cjs/graphs/Chart/parts/FocusableRegion.js +17 -68
  25. package/dist/cjs/graphs/Chart/parts/FocusableRegion.js.map +2 -2
  26. package/dist/cjs/graphs/Chart/{series/Pie.js → parts/Labels/BottomLabel.js} +20 -12
  27. package/dist/cjs/graphs/Chart/parts/Labels/BottomLabel.js.map +7 -0
  28. package/dist/cjs/graphs/Chart/parts/Labels/Label.js +52 -0
  29. package/dist/cjs/graphs/Chart/parts/Labels/Label.js.map +7 -0
  30. package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +61 -0
  31. package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
  32. package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js +65 -0
  33. package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js.map +7 -0
  34. package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +28 -30
  35. package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
  36. package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +14 -19
  37. package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
  38. package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +100 -0
  39. package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
  40. package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +31 -25
  41. package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
  42. package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +3 -13
  43. package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
  44. package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js +50 -16
  45. package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
  46. package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js +3 -1
  47. package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
  48. package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js +39 -17
  49. package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
  50. package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +29 -28
  51. package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
  52. package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
  53. package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +2 -2
  54. package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
  55. package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +57 -41
  56. package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +2 -2
  57. package/dist/cjs/graphs/Chart/react-desc-prop-types.js +1 -12
  58. package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
  59. package/dist/cjs/graphs/Chart/series/Bars.js +29 -27
  60. package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
  61. package/dist/cjs/graphs/Chart/series/HorizontalBars.js +85 -0
  62. package/dist/cjs/graphs/Chart/series/HorizontalBars.js.map +7 -0
  63. package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js +77 -0
  64. package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js.map +7 -0
  65. package/dist/cjs/graphs/Chart/series/Line.js +23 -19
  66. package/dist/cjs/graphs/Chart/series/Line.js.map +2 -2
  67. package/dist/cjs/graphs/Chart/series/Point.js +88 -18
  68. package/dist/cjs/graphs/Chart/series/Point.js.map +2 -2
  69. package/dist/cjs/graphs/Chart/series/Points.js +23 -27
  70. package/dist/cjs/graphs/Chart/series/Points.js.map +2 -2
  71. package/dist/cjs/graphs/Chart/series/Rect.js +105 -8
  72. package/dist/cjs/graphs/Chart/series/Rect.js.map +2 -2
  73. package/dist/cjs/graphs/Chart/series/StackedBar.js +23 -30
  74. package/dist/cjs/graphs/Chart/series/StackedBar.js.map +2 -2
  75. package/dist/cjs/graphs/Chart/series/index.js +0 -1
  76. package/dist/cjs/graphs/Chart/series/index.js.map +2 -2
  77. package/dist/cjs/graphs/Chart/styles.js +5 -20
  78. package/dist/cjs/graphs/Chart/styles.js.map +2 -2
  79. package/dist/cjs/graphs/constants.js +20 -0
  80. package/dist/cjs/graphs/constants.js.map +2 -2
  81. package/dist/esm/graphs/Chart/Chart.js.map +2 -2
  82. package/dist/esm/graphs/Chart/ChartContext.js +3 -1
  83. package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
  84. package/dist/esm/graphs/Chart/config/useChart.js +87 -34
  85. package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
  86. package/dist/esm/graphs/Chart/config/useInternalMargins.js +77 -0
  87. package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +7 -0
  88. package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +26 -16
  89. package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
  90. package/dist/esm/graphs/Chart/config/useScales.js +44 -18
  91. package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
  92. package/dist/esm/graphs/Chart/helpers/index.js +10 -14
  93. package/dist/esm/graphs/Chart/helpers/index.js.map +2 -2
  94. package/dist/esm/graphs/Chart/parts/ActivePoint.js +1 -1
  95. package/dist/esm/graphs/Chart/parts/ActivePoint.js.map +2 -2
  96. package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js +18 -26
  97. package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
  98. package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js +34 -39
  99. package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
  100. package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js +6 -11
  101. package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
  102. package/dist/esm/graphs/Chart/parts/ChartContainer.js +66 -17
  103. package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
  104. package/dist/esm/graphs/Chart/parts/FocusableRegion.js +18 -69
  105. package/dist/esm/graphs/Chart/parts/FocusableRegion.js.map +2 -2
  106. package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js +28 -0
  107. package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js.map +7 -0
  108. package/dist/esm/graphs/Chart/parts/Labels/Label.js +26 -0
  109. package/dist/esm/graphs/Chart/parts/Labels/Label.js.map +7 -0
  110. package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +35 -0
  111. package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
  112. package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js +39 -0
  113. package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js.map +7 -0
  114. package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +28 -30
  115. package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
  116. package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +16 -21
  117. package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
  118. package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +74 -0
  119. package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
  120. package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +32 -26
  121. package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
  122. package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +3 -13
  123. package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
  124. package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js +51 -17
  125. package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
  126. package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js +3 -1
  127. package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
  128. package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js +39 -17
  129. package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
  130. package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +29 -28
  131. package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
  132. package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
  133. package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +2 -2
  134. package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
  135. package/dist/esm/graphs/Chart/parts/SeriesFactory.js +58 -42
  136. package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +2 -2
  137. package/dist/esm/graphs/Chart/react-desc-prop-types.js +1 -12
  138. package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
  139. package/dist/esm/graphs/Chart/series/Bars.js +30 -28
  140. package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
  141. package/dist/esm/graphs/Chart/series/HorizontalBars.js +59 -0
  142. package/dist/esm/graphs/Chart/series/HorizontalBars.js.map +7 -0
  143. package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js +51 -0
  144. package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js.map +7 -0
  145. package/dist/esm/graphs/Chart/series/Line.js +25 -21
  146. package/dist/esm/graphs/Chart/series/Line.js.map +2 -2
  147. package/dist/esm/graphs/Chart/series/Point.js +89 -19
  148. package/dist/esm/graphs/Chart/series/Point.js.map +2 -2
  149. package/dist/esm/graphs/Chart/series/Points.js +24 -28
  150. package/dist/esm/graphs/Chart/series/Points.js.map +2 -2
  151. package/dist/esm/graphs/Chart/series/Rect.js +106 -9
  152. package/dist/esm/graphs/Chart/series/Rect.js.map +2 -2
  153. package/dist/esm/graphs/Chart/series/StackedBar.js +24 -31
  154. package/dist/esm/graphs/Chart/series/StackedBar.js.map +2 -2
  155. package/dist/esm/graphs/Chart/series/index.js +0 -1
  156. package/dist/esm/graphs/Chart/series/index.js.map +2 -2
  157. package/dist/esm/graphs/Chart/styles.js +5 -20
  158. package/dist/esm/graphs/Chart/styles.js.map +2 -2
  159. package/dist/esm/graphs/constants.js +20 -0
  160. package/dist/esm/graphs/constants.js.map +2 -2
  161. package/package.json +8 -8
  162. package/dist/cjs/graphs/Chart/series/Pie.js.map +0 -7
  163. package/dist/esm/graphs/Chart/series/Pie.js +0 -20
  164. package/dist/esm/graphs/Chart/series/Pie.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/SeriesFactory.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { Line, Points, Bars, StackedBar, Area } from '../series';\nimport { getStackedIndex } from '../helpers';\nimport { throttle } from 'lodash';\nexport const SeriesFactory = () => {\n const {\n props: { data, xAxis, groups, types },\n xScrollbarPosition,\n innerWidth,\n xScale,\n containerRatio,\n } = useContext(ChartContext);\n\n return (\n <g className=\"content\">\n {\n data.map((serie) => {\n const serieProps = {\n key: serie.key,\n // @todo fix this for both axis make a hook useVirtualize\n serie: {\n ...serie,\n data:\n containerRatio > 1\n ? serie.data.filter((datum) => {\n const xScaleValue = xScale(xAxis.cols ? xAxis.cols[datum.position] : datum.value.x);\n return (\n xScaleValue > xScrollbarPosition * (containerRatio ?? 1) - 20 * containerRatio &&\n xScaleValue < xScrollbarPosition * (containerRatio ?? 1) + innerWidth + 20 * containerRatio\n );\n })\n : serie.data,\n },\n };\n if (serie.type === 'bar' && groups && getStackedIndex(groups, serie.name) > -1) {\n return <StackedBar {...serieProps} />;\n }\n if (serie.type === 'bar') {\n return <Bars {...serieProps} />;\n }\n if ((types === 'scatter' && !serie.type) || serie.type === 'point') {\n return <Points {...serieProps} />;\n }\n if (serie.type === 'line') {\n return <Line {...serieProps} />;\n }\n if (serie.type === 'area') {\n return <Area {...serieProps} />;\n }\n return <></>;\n }) as JSX.Element[]\n }\n </g>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,SAAgB,kBAA2B;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,MAAM,QAAQ,MAAM,YAAY,YAAY;AACrD,SAAS,uBAAuB;AAEzB,MAAM,gBAAgB,MAAM;AACjC,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM,OAAO,QAAQ,MAAM;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,SACE,oBAAC;AAAA,IAAE,WAAU;AAAA,IAET,eAAK,IAAI,CAAC,UAAU;AAClB,YAAM,aAAa;AAAA,QACjB,KAAK,MAAM;AAAA,QAEX,OAAO;AAAA,UACL,GAAG;AAAA,UACH,MACE,iBAAiB,IACb,MAAM,KAAK,OAAO,CAAC,UAAU;AAC3B,kBAAM,cAAc,OAAO,MAAM,OAAO,MAAM,KAAK,MAAM,YAAY,MAAM,MAAM,CAAC;AAClF,mBACE,cAAc,sBAAsB,kBAAkB,KAAK,KAAK,kBAChE,cAAc,sBAAsB,kBAAkB,KAAK,aAAa,KAAK;AAAA,UAEjF,CAAC,IACD,MAAM;AAAA,QACd;AAAA,MACF;AACA,UAAI,MAAM,SAAS,SAAS,UAAU,gBAAgB,QAAQ,MAAM,IAAI,IAAI,IAAI;AAC9E,eAAO,oBAAC;AAAA,UAAY,GAAG;AAAA,SAAY;AAAA,MACrC;AACA,UAAI,MAAM,SAAS,OAAO;AACxB,eAAO,oBAAC;AAAA,UAAM,GAAG;AAAA,SAAY;AAAA,MAC/B;AACA,UAAK,UAAU,aAAa,CAAC,MAAM,QAAS,MAAM,SAAS,SAAS;AAClE,eAAO,oBAAC;AAAA,UAAQ,GAAG;AAAA,SAAY;AAAA,MACjC;AACA,UAAI,MAAM,SAAS,QAAQ;AACzB,eAAO,oBAAC;AAAA,UAAM,GAAG;AAAA,SAAY;AAAA,MAC/B;AACA,UAAI,MAAM,SAAS,QAAQ;AACzB,eAAO,oBAAC;AAAA,UAAM,GAAG;AAAA,SAAY;AAAA,MAC/B;AACA,aAAO,gCAAE;AAAA,IACX,CAAC;AAAA,GAEL;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { Line, Points, Bars, StackedBar, Area } from '../series';\nimport { getStackedIndex } from '../helpers';\nimport { HorizontalBars } from '../series/HorizontalBars';\nimport { HorizontalStackedBars } from '../series/HorizontalStackedBars';\nexport const SeriesFactory = () => {\n const {\n props: { data, xAxis, groups, types },\n xScrollbarPosition,\n innerWidth,\n xScale,\n containerRatio,\n isHorizontal,\n } = useContext(ChartContext);\n\n return useMemo(\n () => (\n <g className=\"content\">\n {\n data\n .filter((serie) => !serie.isHidden)\n .map((serie) => {\n const serieProps = {\n key: serie.key,\n // @todo fix this for both axis make a hook useVirtualize\n serie: {\n ...serie,\n data:\n containerRatio > 1\n ? serie.data.filter((datum) => {\n const xScaleValue = xScale(xAxis.cols ? xAxis.cols[datum.position] : datum.value.x);\n return (\n xScaleValue > xScrollbarPosition * (containerRatio ?? 1) - 40 * containerRatio &&\n xScaleValue < xScrollbarPosition * (containerRatio ?? 1) + innerWidth + 40 * containerRatio\n );\n })\n : serie.data,\n },\n };\n if (serie.type === 'bar' && groups && getStackedIndex(groups, serie.name) > -1 && isHorizontal) {\n return <HorizontalStackedBars {...serieProps} />;\n }\n if (serie.type === 'bar' && groups && getStackedIndex(groups, serie.name) > -1) {\n return <StackedBar {...serieProps} />;\n }\n if (serie.type === 'bar' && isHorizontal) {\n return <HorizontalBars {...serieProps} />;\n }\n if (serie.type === 'bar') {\n return <Bars {...serieProps} />;\n }\n if ((types === 'scatter' && !serie.type) || serie.type === 'point') {\n return <Points {...serieProps} />;\n }\n if (serie.type === 'line') {\n return <Line {...serieProps} />;\n }\n if (serie.type === 'area') {\n return <Area {...serieProps} />;\n }\n return <></>;\n }) as JSX.Element[]\n }\n </g>\n ),\n [containerRatio, data, groups, innerWidth, isHorizontal, types, xAxis.cols, xScale, xScrollbarPosition],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,SAAgB,YAAY,eAAe;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,MAAM,QAAQ,MAAM,YAAY,YAAY;AACrD,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAC/B,MAAM,gBAAgB,MAAM;AACjC,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM,OAAO,QAAQ,MAAM;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,SAAO;AAAA,IACL,MACE,oBAAC;AAAA,MAAE,WAAU;AAAA,MAET,eACG,OAAO,CAAC,UAAU,CAAC,MAAM,QAAQ,EACjC,IAAI,CAAC,UAAU;AACd,cAAM,aAAa;AAAA,UACjB,KAAK,MAAM;AAAA,UAEX,OAAO;AAAA,YACL,GAAG;AAAA,YACH,MACE,iBAAiB,IACb,MAAM,KAAK,OAAO,CAAC,UAAU;AAC3B,oBAAM,cAAc,OAAO,MAAM,OAAO,MAAM,KAAK,MAAM,YAAY,MAAM,MAAM,CAAC;AAClF,qBACE,cAAc,sBAAsB,kBAAkB,KAAK,KAAK,kBAChE,cAAc,sBAAsB,kBAAkB,KAAK,aAAa,KAAK;AAAA,YAEjF,CAAC,IACD,MAAM;AAAA,UACd;AAAA,QACF;AACA,YAAI,MAAM,SAAS,SAAS,UAAU,gBAAgB,QAAQ,MAAM,IAAI,IAAI,MAAM,cAAc;AAC9F,iBAAO,oBAAC;AAAA,YAAuB,GAAG;AAAA,WAAY;AAAA,QAChD;AACA,YAAI,MAAM,SAAS,SAAS,UAAU,gBAAgB,QAAQ,MAAM,IAAI,IAAI,IAAI;AAC9E,iBAAO,oBAAC;AAAA,YAAY,GAAG;AAAA,WAAY;AAAA,QACrC;AACA,YAAI,MAAM,SAAS,SAAS,cAAc;AACxC,iBAAO,oBAAC;AAAA,YAAgB,GAAG;AAAA,WAAY;AAAA,QACzC;AACA,YAAI,MAAM,SAAS,OAAO;AACxB,iBAAO,oBAAC;AAAA,YAAM,GAAG;AAAA,WAAY;AAAA,QAC/B;AACA,YAAK,UAAU,aAAa,CAAC,MAAM,QAAS,MAAM,SAAS,SAAS;AAClE,iBAAO,oBAAC;AAAA,YAAQ,GAAG;AAAA,WAAY;AAAA,QACjC;AACA,YAAI,MAAM,SAAS,QAAQ;AACzB,iBAAO,oBAAC;AAAA,YAAM,GAAG;AAAA,WAAY;AAAA,QAC/B;AACA,YAAI,MAAM,SAAS,QAAQ;AACzB,iBAAO,oBAAC;AAAA,YAAM,GAAG;AAAA,WAAY;AAAA,QAC/B;AACA,eAAO,gCAAE;AAAA,MACX,CAAC;AAAA,KAEP;AAAA,IAEF,CAAC,gBAAgB,MAAM,QAAQ,YAAY,cAAc,OAAO,MAAM,MAAM,QAAQ,kBAAkB;AAAA,EACxG;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,17 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-utilities";
3
- const defaultProps = {
4
- yAxis: {
5
- showGrid: true,
6
- color: "black",
7
- type: "linear"
8
- },
9
- xAxis: {
10
- showGrid: true,
11
- color: "black",
12
- type: "band"
13
- }
14
- };
3
+ const defaultProps = {};
15
4
  const propTypes = {
16
5
  ...globalAttributesPropTypes,
17
6
  height: PropTypes.number.isRequired.description("height").defaultValue(""),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/react-desc-prop-types.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\n\ntype MarginT = {\n top: number;\n left: number;\n right: number;\n bottom: number;\n};\n\nexport declare namespace DSPieT {\n export interface SeriesT {\n name: string;\n data: number;\n color: string;\n }\n export interface Props {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n }\n}\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'stackedBar' | 'spline';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export interface SeriesT {\n name: string;\n data: number[] | { x: number; y: number }[];\n type: SerieTypeT;\n scale?: string;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n type: AxisTypeT;\n cols?: number[] | string[] | Date[];\n padding?: number;\n beginAtZero?: boolean;\n }\n\n export interface InternalData {\n key: string;\n group: string;\n type: DSChartT.SerieTypeT;\n scale?: string;\n color: string;\n values: {\n key: string;\n value: number;\n position: number;\n }[];\n }\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter' | 'pie';\n }\n\n export interface DefaultProps {\n yAxis: AxisT;\n xAxis: AxisT;\n }\n\n export interface RequiredProps {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n }\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {\n yAxis: {\n showGrid: true,\n color: 'black',\n type: 'linear',\n },\n xAxis: {\n showGrid: true,\n color: 'black',\n type: 'band',\n },\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,2BAA2B,iBAAiB;AA6E9C,MAAM,eAAsC;AAAA,EACjD,OAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA,OAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO;AAAA,IACP,MAAM;AAAA,EACR;AACF;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,UAAU;AAAA,IACf,QAAQ,UAAU;AAAA,IAClB,MAAM,UAAU;AAAA,IAChB,OAAO,UAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\n\ntype MarginT = {\n top: number;\n left: number;\n right: number;\n bottom: number;\n};\n\nexport declare namespace DSPieT {\n export interface SeriesT {\n name: string;\n data: number;\n color: string;\n }\n export interface Props {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n }\n}\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'stackedBar' | 'spline';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export interface SeriesT {\n name: string;\n data: number[] | { x: number; y: number }[];\n type: SerieTypeT;\n scale?: string;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n type: AxisTypeT;\n cols?: number[] | string[] | Date[];\n //padding?: number;\n domainPadding: number;\n hideAxis: boolean;\n beginAtZero?: boolean;\n tickValues: number[] | string[] | Date[];\n tickFormat: () => void | string;\n tickCount: number;\n overwriteTicks: boolean;\n }\n\n export interface InternalData {\n key: string;\n group: string;\n type: DSChartT.SerieTypeT;\n scale?: string;\n color: string;\n values: {\n key: string;\n value: number;\n position: number;\n }[];\n }\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter';\n }\n\n export interface DefaultProps {}\n\n export interface RequiredProps {\n series: SeriesT[];\n height: number;\n width: number;\n margin: MarginT;\n yAxis: AxisT;\n xAxis: AxisT;\n }\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,2BAA2B,iBAAiB;AAkF9C,MAAM,eAAsC,CAAC;AAE7C,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,UAAU;AAAA,IACf,QAAQ,UAAU;AAAA,IAClB,MAAM,UAAU;AAAA,IAChB,OAAO,UAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
6
6
  "names": []
7
7
  }
@@ -1,45 +1,47 @@
1
1
  import * as React from "react";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { jsx } from "react/jsx-runtime";
3
3
  import { useContext } from "react";
4
4
  import { Rect } from "./Rect";
5
5
  import { ChartContext } from "../ChartContext";
6
- import { FocusableRegion } from "../parts/FocusableRegion";
7
6
  const Bars = ({ serie }) => {
8
7
  const {
9
- props: { xAxis, yAxis, TooltipRenderer },
8
+ props: { yAxis, TooltipRenderer },
10
9
  innerHeight,
11
10
  xScale,
12
11
  yScale,
12
+ y2Scale,
13
13
  subGroupScale,
14
- colorScale
14
+ colorScale,
15
+ getXValue,
16
+ getYValue,
17
+ chartId
15
18
  } = useContext(ChartContext);
16
- const isHorizontal = !!yScale.bandwidth;
19
+ const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
20
+ const negativeSize = innerHeight - finalYScale(0);
21
+ const positiveSize = innerHeight - negativeSize;
17
22
  return /* @__PURE__ */ jsx("g", {
18
23
  fill: colorScale(serie.name),
24
+ clipPath: `url(#rect-focus-ring-${chartId})`,
19
25
  children: serie.data.map((bar, i) => {
20
- const width = isHorizontal ? xScale(bar.value) : subGroupScale?.bandwidth();
21
- const height = isHorizontal ? subGroupScale?.bandwidth() : innerHeight - yScale(bar.value.y ?? bar.value);
22
- const x = !isHorizontal ? xAxis?.cols?.[i] ?? bar.value.x ?? i : bar.value.x ?? bar.value;
23
- const y = !isHorizontal ? bar.value.y ?? bar.value : yAxis?.cols?.[i] ?? bar.value.x ?? i;
24
- const transformX = isHorizontal ? 0 : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? width / 2 * subGroupScale.domain().length : 0);
25
- const transformY = isHorizontal ? subGroupScale(serie.name) + yScale(yAxis?.cols?.[i] ?? i) : yScale(y);
26
- return /* @__PURE__ */ jsxs("g", {
27
- transform: `translate(${transformX},${transformY})`,
28
- children: [
29
- /* @__PURE__ */ jsx(Rect, {
30
- width,
31
- height,
32
- id: bar.key
33
- }),
34
- TooltipRenderer && /* @__PURE__ */ jsx(FocusableRegion, {
35
- id: bar.key,
36
- width,
37
- height,
38
- content: /* @__PURE__ */ jsx(TooltipRenderer, {
39
- data: [{ name: serie.name, yValue: y, xValue: x }]
40
- })
41
- })
42
- ]
26
+ const x = getXValue(bar);
27
+ const y = getYValue(bar);
28
+ const width = subGroupScale?.bandwidth();
29
+ const height = y > 0 ? positiveSize - finalYScale(y) : finalYScale(y) - finalYScale(0);
30
+ const transformX = subGroupScale(serie.name) + xScale(x);
31
+ const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);
32
+ return /* @__PURE__ */ jsx("g", {
33
+ id: `${serie.name}-rects`,
34
+ transform: `translate(${transformX},0)`,
35
+ children: /* @__PURE__ */ jsx(Rect, {
36
+ name: serie.name,
37
+ xValue: x,
38
+ yValue: y,
39
+ width,
40
+ height,
41
+ id: bar.key,
42
+ y: transformY,
43
+ isNegative: y < 0
44
+ })
43
45
  }, bar.key);
44
46
  })
45
47
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Bars.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport { ScaleBand } from 'd3';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { DSChartT } from '../react-desc-prop-types';\nimport { FocusableRegion } from '../parts/FocusableRegion';\ninterface BarsT {\n serie: DSChartT.InternalData;\n}\nexport const Bars = ({ serie }: BarsT) => {\n const {\n props: { xAxis, yAxis, TooltipRenderer },\n innerHeight,\n xScale,\n yScale,\n subGroupScale,\n colorScale,\n } = useContext(ChartContext);\n\n const isHorizontal = !!(yScale as ScaleBand<string>).bandwidth;\n return (\n <g fill={colorScale(serie.name)}>\n {serie.data.map((bar, i) => {\n const width = isHorizontal ? xScale(bar.value) : subGroupScale?.bandwidth();\n const height = isHorizontal ? subGroupScale?.bandwidth() : innerHeight - yScale(bar.value.y ?? bar.value);\n\n const x = !isHorizontal ? xAxis?.cols?.[i] ?? bar.value.x ?? i : bar.value.x ?? bar.value;\n const y = !isHorizontal ? bar.value.y ?? bar.value : yAxis?.cols?.[i] ?? bar.value.x ?? i;\n\n const transformX = isHorizontal\n ? 0\n : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? (width / 2) * subGroupScale.domain().length : 0);\n const transformY = isHorizontal ? subGroupScale(serie.name) + yScale(yAxis?.cols?.[i] ?? i) : yScale(y);\n\n return (\n <g key={bar.key} transform={`translate(${transformX},${transformY})`}>\n <Rect width={width} height={height} id={bar.key} />\n {TooltipRenderer && (\n <FocusableRegion\n id={bar.key}\n width={width}\n height={height}\n content={<TooltipRenderer data={[{ name: serie.name, yValue: y, xValue: x }]} />}\n />\n )}\n </g>\n );\n })}\n </g>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,kBAAkB;AAElC,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAE7B,SAAS,uBAAuB;AAIzB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAa;AACxC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,OAAO,gBAAgB;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,eAAe,CAAC,CAAE,OAA6B;AACrD,SACE,oBAAC;AAAA,IAAE,MAAM,WAAW,MAAM,IAAI;AAAA,IAC3B,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,YAAM,QAAQ,eAAe,OAAO,IAAI,KAAK,IAAI,eAAe,UAAU;AAC1E,YAAM,SAAS,eAAe,eAAe,UAAU,IAAI,cAAc,OAAO,IAAI,MAAM,KAAK,IAAI,KAAK;AAExG,YAAM,IAAI,CAAC,eAAe,OAAO,OAAO,MAAM,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI;AACpF,YAAM,IAAI,CAAC,eAAe,IAAI,MAAM,KAAK,IAAI,QAAQ,OAAO,OAAO,MAAM,IAAI,MAAM,KAAK;AAExF,YAAM,aAAa,eACf,IACA,cAAc,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,IAAK,QAAQ,IAAK,cAAc,OAAO,EAAE,SAAS;AACzG,YAAM,aAAa,eAAe,cAAc,MAAM,IAAI,IAAI,OAAO,OAAO,OAAO,MAAM,CAAC,IAAI,OAAO,CAAC;AAEtG,aACE,qBAAC;AAAA,QAAgB,WAAW,aAAa,cAAc;AAAA,QACrD;AAAA,8BAAC;AAAA,YAAK;AAAA,YAAc;AAAA,YAAgB,IAAI,IAAI;AAAA,WAAK;AAAA,UAChD,mBACC,oBAAC;AAAA,YACC,IAAI,IAAI;AAAA,YACR;AAAA,YACA;AAAA,YACA,SAAS,oBAAC;AAAA,cAAgB,MAAM,CAAC,EAAE,MAAM,MAAM,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC;AAAA,aAAG;AAAA,WAChF;AAAA;AAAA,SARI,IAAI,GAUZ;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext, useMemo } from 'react';\nimport { ScaleBand } from 'd3';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { DSChartT } from '../react-desc-prop-types';\nimport { FocusableRegion } from '../parts/FocusableRegion';\ninterface BarsT {\n serie: DSChartT.InternalData;\n}\nexport const Bars = ({ serie }: BarsT) => {\n const {\n props: { yAxis, TooltipRenderer },\n innerHeight,\n xScale,\n yScale,\n y2Scale,\n subGroupScale,\n colorScale,\n getXValue,\n getYValue,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n const negativeSize = innerHeight - finalYScale(0);\n const positiveSize = innerHeight - negativeSize;\n\n return (\n <g fill={colorScale(serie.name)} clipPath={`url(#rect-focus-ring-${chartId})`}>\n {serie.data.map((bar, i) => {\n const x = getXValue(bar);\n const y = getYValue(bar);\n\n const width = subGroupScale?.bandwidth();\n const height = y > 0 ? positiveSize - finalYScale(y) : finalYScale(y) - finalYScale(0);\n\n const transformX = subGroupScale(serie.name) + xScale(x);\n\n // @todo find a way to create bars with linear\n // scale here is something but conflict with bars like {x: 'Monday', y: 10}\n // const transformX = isHorizontal\n // ? 0\n // : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? (width / 2) * subGroupScale.domain().length : 0);\n\n const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);\n\n return (\n <g id={`${serie.name}-rects`} key={bar.key} transform={`translate(${transformX},0)`}>\n <Rect\n name={serie.name}\n xValue={x}\n yValue={y}\n width={width}\n height={height}\n id={bar.key}\n y={transformY}\n isNegative={y < 0}\n />\n {/* {TooltipRenderer && (\n <FocusableRegion\n transform={`scale(1,-1) translate(0,${-height})`}\n y={-transformY}\n id={bar.key}\n width={width}\n height={height}\n content={<TooltipRenderer data={[{ name: serie.name, yValue: y, xValue: x }]} />}\n />\n )} */}\n </g>\n );\n })}\n </g>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,kBAA2B;AAE3C,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAMtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAa;AACxC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,gBAAgB;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,QAAM,eAAe,cAAc,YAAY,CAAC;AAChD,QAAM,eAAe,cAAc;AAEnC,SACE,oBAAC;AAAA,IAAE,MAAM,WAAW,MAAM,IAAI;AAAA,IAAG,UAAU,wBAAwB;AAAA,IAChE,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,YAAM,IAAI,UAAU,GAAG;AACvB,YAAM,IAAI,UAAU,GAAG;AAEvB,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,SAAS,IAAI,IAAI,eAAe,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,YAAY,CAAC;AAErF,YAAM,aAAa,cAAc,MAAM,IAAI,IAAI,OAAO,CAAC;AAQvD,YAAM,aAAa,IAAI,IAAI,YAAY,CAAC,IAAI,SAAS,YAAY,CAAC;AAElE,aACE,oBAAC;AAAA,QAAE,IAAI,GAAG,MAAM;AAAA,QAA4B,WAAW,aAAa;AAAA,QAClE,8BAAC;AAAA,UACC,MAAM,MAAM;AAAA,UACZ,QAAQ;AAAA,UACR,QAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,IAAI,IAAI;AAAA,UACR,GAAG;AAAA,UACH,YAAY,IAAI;AAAA,SAClB;AAAA,SAViC,IAAI,GAqBvC;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,59 @@
1
+ import * as React from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useContext, useMemo } from "react";
4
+ import { Rect } from "./Rect";
5
+ import { ChartContext } from "../ChartContext";
6
+ const HorizontalBars = ({ serie }) => {
7
+ const {
8
+ props: { yAxis },
9
+ xScale,
10
+ yScale,
11
+ y2Scale,
12
+ subGroupScale,
13
+ colorScale,
14
+ getXValue,
15
+ getYValue,
16
+ chartId
17
+ } = useContext(ChartContext);
18
+ const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
19
+ return useMemo(
20
+ () => /* @__PURE__ */ jsx("g", {
21
+ fill: colorScale(serie.name),
22
+ clipPath: `url(#rect-focus-ring-${chartId})`,
23
+ children: serie.data.map((bar, i) => {
24
+ const x = getXValue(bar);
25
+ const y = getYValue(bar);
26
+ const width = xScale(x);
27
+ const height = subGroupScale?.bandwidth();
28
+ const transformY = subGroupScale(serie.name) + finalYScale(yAxis?.cols?.[i] ?? i);
29
+ return /* @__PURE__ */ jsx("g", {
30
+ transform: `translate(0,${transformY})`,
31
+ children: /* @__PURE__ */ jsx(Rect, {
32
+ width,
33
+ height,
34
+ id: bar.key,
35
+ x: 0,
36
+ xValue: x,
37
+ yValue: y
38
+ })
39
+ }, bar.key);
40
+ })
41
+ }),
42
+ [
43
+ chartId,
44
+ colorScale,
45
+ finalYScale,
46
+ getXValue,
47
+ getYValue,
48
+ serie.data,
49
+ serie.name,
50
+ subGroupScale,
51
+ xScale,
52
+ yAxis?.cols
53
+ ]
54
+ );
55
+ };
56
+ export {
57
+ HorizontalBars
58
+ };
59
+ //# sourceMappingURL=HorizontalBars.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/HorizontalBars.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext, useMemo } from 'react';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { DSChartT } from '../react-desc-prop-types';\ninterface BarsT {\n serie: DSChartT.InternalData;\n}\nexport const HorizontalBars = ({ serie }: BarsT) => {\n const {\n props: { yAxis },\n xScale,\n yScale,\n y2Scale,\n subGroupScale,\n colorScale,\n getXValue,\n getYValue,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n return useMemo(\n () => (\n <g fill={colorScale(serie.name)} clipPath={`url(#rect-focus-ring-${chartId})`}>\n {serie.data.map((bar, i) => {\n const x = getXValue(bar);\n const y = getYValue(bar);\n\n const width = xScale(x);\n const height = subGroupScale?.bandwidth();\n\n const transformY = subGroupScale(serie.name) + finalYScale(yAxis?.cols?.[i] ?? i);\n\n return (\n <g key={bar.key} transform={`translate(0,${transformY})`}>\n <Rect width={width} height={height} id={bar.key} x={0} xValue={x} yValue={y} />\n </g>\n );\n })}\n </g>\n ),\n [\n chartId,\n colorScale,\n finalYScale,\n getXValue,\n getYValue,\n serie.data,\n serie.name,\n subGroupScale,\n xScale,\n yAxis?.cols,\n ],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,YAAY,eAAe;AAC3C,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAKtB,MAAM,iBAAiB,CAAC,EAAE,MAAM,MAAa;AAClD,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,SAAO;AAAA,IACL,MACE,oBAAC;AAAA,MAAE,MAAM,WAAW,MAAM,IAAI;AAAA,MAAG,UAAU,wBAAwB;AAAA,MAChE,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,cAAM,IAAI,UAAU,GAAG;AACvB,cAAM,IAAI,UAAU,GAAG;AAEvB,cAAM,QAAQ,OAAO,CAAC;AACtB,cAAM,SAAS,eAAe,UAAU;AAExC,cAAM,aAAa,cAAc,MAAM,IAAI,IAAI,YAAY,OAAO,OAAO,MAAM,CAAC;AAEhF,eACE,oBAAC;AAAA,UAAgB,WAAW,eAAe;AAAA,UACzC,8BAAC;AAAA,YAAK;AAAA,YAAc;AAAA,YAAgB,IAAI,IAAI;AAAA,YAAK,GAAG;AAAA,YAAG,QAAQ;AAAA,YAAG,QAAQ;AAAA,WAAG;AAAA,WADvE,IAAI,GAEZ;AAAA,MAEJ,CAAC;AAAA,KACH;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ import * as React from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useContext } from "react";
4
+ import { Rect } from "./Rect";
5
+ import { ChartContext } from "../ChartContext";
6
+ import { getStackedData, getStackedIndex } from "../helpers";
7
+ const HorizontalStackedBars = ({ serie }) => {
8
+ const {
9
+ props: { yAxis, groups },
10
+ xScale,
11
+ yScale,
12
+ stackedData,
13
+ subGroupScale,
14
+ colorScale,
15
+ chartId,
16
+ getYValue
17
+ } = useContext(ChartContext);
18
+ const serieWithStackedValues = getStackedData(stackedData, serie);
19
+ const stackIndex = getStackedIndex(groups, serie.name);
20
+ return /* @__PURE__ */ jsx("g", {
21
+ children: serieWithStackedValues.map((sequence, i) => {
22
+ const isFloorStack = sequence[0] === 0;
23
+ const xValue = sequence[1] - sequence[0];
24
+ const yValue = getYValue(serie.data[i]);
25
+ const width = xScale(sequence[1]) - xScale(sequence[0]) - (!isFloorStack ? 1 : 0);
26
+ const height = subGroupScale?.bandwidth();
27
+ const transformX = xScale(sequence[0]) + (!isFloorStack ? 1 : 0);
28
+ const transformY = subGroupScale(`stacked-data-${stackIndex}`) + yScale(yAxis?.cols?.[i]);
29
+ return /* @__PURE__ */ jsx("g", {
30
+ clipPath: `url(#rect-focus-ring-${chartId})`,
31
+ children: /* @__PURE__ */ jsx("g", {
32
+ fill: colorScale(serie.name),
33
+ transform: `translate(0, ${transformY})`,
34
+ children: /* @__PURE__ */ jsx(Rect, {
35
+ width,
36
+ height,
37
+ x: transformX,
38
+ xValue,
39
+ yValue,
40
+ id: serie.data[i].key,
41
+ name: serie.name
42
+ })
43
+ })
44
+ }, serie.data[i].key);
45
+ })
46
+ });
47
+ };
48
+ export {
49
+ HorizontalStackedBars
50
+ };
51
+ //# sourceMappingURL=HorizontalStackedBars.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/HorizontalStackedBars.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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 HorizontalStackedBars = ({ serie }) => {\n const {\n props: { yAxis, groups },\n xScale,\n yScale,\n stackedData,\n subGroupScale,\n colorScale,\n chartId,\n getYValue,\n } = useContext(ChartContext);\n\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const stackIndex = getStackedIndex(groups, serie.name);\n return (\n <g>\n {serieWithStackedValues.map((sequence, i) => {\n const isFloorStack = sequence[0] === 0;\n const xValue = sequence[1] - sequence[0];\n const yValue = getYValue(serie.data[i]);\n\n const width = xScale(sequence[1]) - xScale(sequence[0]) - (!isFloorStack ? 1 : 0);\n\n const height = subGroupScale?.bandwidth();\n\n const transformX = xScale(sequence[0]) + (!isFloorStack ? 1 : 0);\n const transformY = subGroupScale(`stacked-data-${stackIndex}`) + yScale(yAxis?.cols?.[i]);\n\n return (\n <g key={serie.data[i].key} clipPath={`url(#rect-focus-ring-${chartId})`}>\n <g fill={colorScale(serie.name)} transform={`translate(0, ${transformY})`}>\n <Rect\n width={width}\n height={height}\n x={transformX}\n xValue={xValue}\n yValue={yValue}\n id={serie.data[i].key}\n name={serie.name}\n />\n </g>\n </g>\n );\n })}\n </g>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,kBAAkB;AAElC,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,uBAAuB;AAEzC,MAAM,wBAAwB,CAAC,EAAE,MAAM,MAAM;AAClD,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,OAAO;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,yBAAyB,eAAe,aAAa,KAAK;AAChE,QAAM,aAAa,gBAAgB,QAAQ,MAAM,IAAI;AACrD,SACE,oBAAC;AAAA,IACE,iCAAuB,IAAI,CAAC,UAAU,MAAM;AAC3C,YAAM,eAAe,SAAS,OAAO;AACrC,YAAM,SAAS,SAAS,KAAK,SAAS;AACtC,YAAM,SAAS,UAAU,MAAM,KAAK,EAAE;AAEtC,YAAM,QAAQ,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAE/E,YAAM,SAAS,eAAe,UAAU;AAExC,YAAM,aAAa,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAC9D,YAAM,aAAa,cAAc,gBAAgB,YAAY,IAAI,OAAO,OAAO,OAAO,EAAE;AAExF,aACE,oBAAC;AAAA,QAA0B,UAAU,wBAAwB;AAAA,QAC3D,8BAAC;AAAA,UAAE,MAAM,WAAW,MAAM,IAAI;AAAA,UAAG,WAAW,gBAAgB;AAAA,UAC1D,8BAAC;AAAA,YACC;AAAA,YACA;AAAA,YACA,GAAG;AAAA,YACH;AAAA,YACA;AAAA,YACA,IAAI,MAAM,KAAK,GAAG;AAAA,YAClB,MAAM,MAAM;AAAA,WACd;AAAA,SACF;AAAA,SAXM,MAAM,KAAK,GAAG,GAYtB;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
6
+ "names": []
7
+ }
@@ -1,34 +1,38 @@
1
1
  import * as React from "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useContext, useMemo } from "react";
4
- import { line, curveNatural, curveLinear } from "d3";
5
- import { StyledLine } from "../styles";
3
+ import { useContext, useEffect, useMemo, useRef } from "react";
4
+ import { line, curveNatural, curveLinear, select } from "d3";
6
5
  import { Points } from "./Points";
7
6
  import { ChartContext } from "../ChartContext";
8
7
  const Line = ({ serie }) => {
9
- const {
10
- props: { xAxis },
11
- xScale,
12
- yScale,
13
- y2Scale,
14
- colorScale
15
- } = useContext(ChartContext);
16
- const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
17
- const lineTypeMap = {
18
- line: curveLinear,
19
- spline: curveNatural
20
- };
8
+ const { xScale, yScale, y2Scale, colorScale, getXValue, getYValue } = useContext(ChartContext);
9
+ const ref = useRef(null);
10
+ const firstRender = useRef(true);
11
+ const finalYScale = useMemo(() => serie.scale === "y2" ? y2Scale : yScale, [serie.scale, y2Scale, yScale]);
12
+ const lineTypeMap = useMemo(
13
+ () => ({
14
+ line: curveLinear,
15
+ spline: curveNatural
16
+ }),
17
+ []
18
+ );
21
19
  const lineD3 = useMemo(
22
- () => line().x((d) => xScale(d.value.x ?? xAxis?.cols?.[d.position] ?? d.position)).y((d) => finalYScale(d.value.y ?? d.value)).curve(lineTypeMap[serie.type] ?? curveLinear)(serie.data),
23
- [lineTypeMap, serie.type, serie.data, xScale, xAxis?.cols, finalYScale]
20
+ () => line().x((d) => xScale(getXValue(d))).y((d) => finalYScale(getYValue(d))).curve(lineTypeMap[serie.type] ?? curveLinear),
21
+ [finalYScale, getXValue, getYValue, lineTypeMap, serie.type, xScale]
24
22
  );
25
- const xTranslate = (xScale?.bandwidth?.() ?? 0) / 2;
23
+ useEffect(() => {
24
+ if (!ref.current)
25
+ return;
26
+ const groupContent = select(ref?.current);
27
+ groupContent.selectAll("*").remove();
28
+ const path = groupContent.append("path").datum(serie.data).attr("fill", "none").attr("stroke", colorScale(serie.name)).attr("stroke-linejoin", "round").attr("stroke-linecap", "round").attr("stroke-width", 2).attr("d", lineD3);
29
+ }, [colorScale, finalYScale, getXValue, getYValue, lineD3, lineTypeMap, serie, xScale]);
30
+ const xTranslate = useMemo(() => (xScale?.bandwidth?.() ?? 0) / 2, [xScale]);
26
31
  return /* @__PURE__ */ jsxs("g", {
27
32
  transform: `translate(${xTranslate}, 0)`,
28
33
  children: [
29
- /* @__PURE__ */ jsx(StyledLine, {
30
- d: lineD3,
31
- stroke: colorScale(serie.name)
34
+ /* @__PURE__ */ jsx("g", {
35
+ ref
32
36
  }),
33
37
  /* @__PURE__ */ jsx(Points, {
34
38
  serie
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Line.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useState } from 'react';\nimport { line, curveNatural, curveLinear } from 'd3';\nimport { StyledLine } from '../styles';\nimport { Points } from './Points';\nimport { ChartContext } from '../ChartContext';\n\nexport const Line = ({ serie }) => {\n const {\n props: { xAxis },\n xScale,\n yScale,\n y2Scale,\n colorScale,\n // activeSerie,\n // setActiveSerie,\n } = useContext(ChartContext);\n\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n const lineTypeMap = {\n line: curveLinear,\n spline: curveNatural,\n };\n\n const lineD3 = useMemo(\n () =>\n line()\n .x((d) => xScale(d.value.x ?? xAxis?.cols?.[d.position] ?? d.position))\n .y((d) => finalYScale(d.value.y ?? d.value))\n .curve(lineTypeMap[serie.type] ?? curveLinear)(serie.data),\n [lineTypeMap, serie.type, serie.data, xScale, xAxis?.cols, finalYScale],\n );\n\n // we need to center the points and lines when\n // using them in a band axis context\n const xTranslate = (xScale?.bandwidth?.() ?? 0) / 2;\n\n return (\n <g\n transform={`translate(${xTranslate}, 0)`}\n // onMouseEnter={() => setActiveSerie(serie.key)}\n // onMouseLeave={() => setActiveSerie('')}\n >\n <StyledLine d={lineD3} stroke={colorScale(serie.name)} />\n <Points serie={serie} />\n </g>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,eAAyB;AACrD,SAAS,MAAM,cAAc,mBAAmB;AAChD,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAEtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAM;AACjC,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAGF,IAAI,WAAW,YAAY;AAE3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AACrD,QAAM,cAAc;AAAA,IAClB,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AAEA,QAAM,SAAS;AAAA,IACb,MACE,KAAK,EACF,EAAE,CAAC,MAAM,OAAO,EAAE,MAAM,KAAK,OAAO,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EACrE,EAAE,CAAC,MAAM,YAAY,EAAE,MAAM,KAAK,EAAE,KAAK,CAAC,EAC1C,MAAM,YAAY,MAAM,SAAS,WAAW,EAAE,MAAM,IAAI;AAAA,IAC7D,CAAC,aAAa,MAAM,MAAM,MAAM,MAAM,QAAQ,OAAO,MAAM,WAAW;AAAA,EACxE;AAIA,QAAM,cAAc,QAAQ,YAAY,KAAK,KAAK;AAElD,SACE,qBAAC;AAAA,IACC,WAAW,aAAa;AAAA,IAIxB;AAAA,0BAAC;AAAA,QAAW,GAAG;AAAA,QAAQ,QAAQ,WAAW,MAAM,IAAI;AAAA,OAAG;AAAA,MACvD,oBAAC;AAAA,QAAO;AAAA,OAAc;AAAA;AAAA,GACxB;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect, useMemo, useRef } from 'react';\nimport { line, curveNatural, easeLinear, transition, curveLinear, select } from 'd3';\nimport { Points } from './Points';\nimport { ChartContext } from '../ChartContext';\n\nexport const Line = ({ serie }) => {\n const { xScale, yScale, y2Scale, colorScale, getXValue, getYValue } = useContext(ChartContext);\n\n const ref = useRef<React.SVGProps<SVGGElement> | SVGGElement>(null);\n const firstRender = useRef(true);\n\n const finalYScale = useMemo(() => (serie.scale === 'y2' ? y2Scale : yScale), [serie.scale, y2Scale, yScale]);\n const lineTypeMap = useMemo(\n () => ({\n line: curveLinear,\n spline: curveNatural,\n }),\n [],\n );\n\n const lineD3 = useMemo(\n () =>\n line()\n .x((d) => xScale(getXValue(d)))\n .y((d) => finalYScale(getYValue(d)))\n .curve(lineTypeMap[serie.type] ?? curveLinear),\n [finalYScale, getXValue, getYValue, lineTypeMap, serie.type, xScale],\n );\n\n useEffect(() => {\n if (!ref.current) return;\n\n const groupContent = select(ref?.current);\n\n groupContent.selectAll('*').remove();\n const path = groupContent\n .append('path')\n .datum(serie.data)\n .attr('fill', 'none')\n .attr('stroke', colorScale(serie.name))\n .attr('stroke-linejoin', 'round')\n .attr('stroke-linecap', 'round')\n .attr('stroke-width', 2)\n .attr('d', lineD3);\n\n // const pathLength = path.node()?.getTotalLength();\n\n // if (firstRender?.current) {\n // const transitionPath = transition().ease(easeLinear).duration(800);\n\n // path\n // .attr('stroke-dashoffset', pathLength)\n // .attr('stroke-dasharray', pathLength)\n // .transition(transitionPath)\n // .attr('stroke-dashoffset', 0);\n\n // firstRender.current = false;\n // }\n }, [colorScale, finalYScale, getXValue, getYValue, lineD3, lineTypeMap, serie, xScale]);\n\n // we need to center the points and lines when\n // using them in a band axis context\n const xTranslate = useMemo(() => (xScale?.bandwidth?.() ?? 0) / 2, [xScale]);\n\n return (\n <g transform={`translate(${xTranslate}, 0)`}>\n <g ref={ref}></g>\n\n <Points serie={serie} />\n </g>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,WAAW,SAAS,cAAc;AAC9D,SAAS,MAAM,cAAsC,aAAa,cAAc;AAChF,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAEtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAM;AACjC,QAAM,EAAE,QAAQ,QAAQ,SAAS,YAAY,WAAW,UAAU,IAAI,WAAW,YAAY;AAE7F,QAAM,MAAM,OAAkD,IAAI;AAClE,QAAM,cAAc,OAAO,IAAI;AAE/B,QAAM,cAAc,QAAQ,MAAO,MAAM,UAAU,OAAO,UAAU,QAAS,CAAC,MAAM,OAAO,SAAS,MAAM,CAAC;AAC3G,QAAM,cAAc;AAAA,IAClB,OAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,SAAS;AAAA,IACb,MACE,KAAK,EACF,EAAE,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC,CAAC,EAC7B,EAAE,CAAC,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,EAClC,MAAM,YAAY,MAAM,SAAS,WAAW;AAAA,IACjD,CAAC,aAAa,WAAW,WAAW,aAAa,MAAM,MAAM,MAAM;AAAA,EACrE;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,IAAI;AAAS;AAElB,UAAM,eAAe,OAAO,KAAK,OAAO;AAExC,iBAAa,UAAU,GAAG,EAAE,OAAO;AACnC,UAAM,OAAO,aACV,OAAO,MAAM,EACb,MAAM,MAAM,IAAI,EAChB,KAAK,QAAQ,MAAM,EACnB,KAAK,UAAU,WAAW,MAAM,IAAI,CAAC,EACrC,KAAK,mBAAmB,OAAO,EAC/B,KAAK,kBAAkB,OAAO,EAC9B,KAAK,gBAAgB,CAAC,EACtB,KAAK,KAAK,MAAM;AAAA,EAerB,GAAG,CAAC,YAAY,aAAa,WAAW,WAAW,QAAQ,aAAa,OAAO,MAAM,CAAC;AAItF,QAAM,aAAa,QAAQ,OAAO,QAAQ,YAAY,KAAK,KAAK,GAAG,CAAC,MAAM,CAAC;AAE3E,SACE,qBAAC;AAAA,IAAE,WAAW,aAAa;AAAA,IACzB;AAAA,0BAAC;AAAA,QAAE;AAAA,OAAU;AAAA,MAEb,oBAAC;AAAA,QAAO;AAAA,OAAc;AAAA;AAAA,GACxB;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,39 +1,109 @@
1
1
  import * as React from "react";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useContext, useMemo } from "react";
4
- import { StyledPoint } from "../styles";
5
4
  import { ChartContext } from "../ChartContext";
6
- const Point = ({ x, y, pointRadius, id, opacity }) => {
5
+ import { FOCUS_RING, SCRAPPER, LINE } from "../../constants";
6
+ import { FocusableRegion } from "../parts/FocusableRegion";
7
+ const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity }) => {
7
8
  const {
8
9
  activePoint,
9
- setActivePoint,
10
10
  scrapperPosY,
11
11
  scrapperPosX,
12
- props: { xAxis, scrapper }
12
+ props: { scrapper, TooltipRenderer }
13
13
  } = useContext(ChartContext);
14
14
  const isFocused = useMemo(() => {
15
- if (activePoint === id) {
15
+ if (activePoint?.key === id) {
16
16
  return true;
17
17
  }
18
- if (scrapper?.type === "horizontal") {
18
+ if (scrapper?.type === SCRAPPER.TYPE_HORIZONTAL) {
19
19
  return y === scrapperPosY;
20
20
  }
21
- if (scrapper?.type === "vertical") {
21
+ if (scrapper?.type === SCRAPPER.TYPE_VERTICAL) {
22
22
  return x === scrapperPosX;
23
23
  }
24
24
  return false;
25
25
  }, [activePoint, id, scrapper, y, scrapperPosY, x, scrapperPosX]);
26
- return useMemo(
27
- () => /* @__PURE__ */ jsx("g", {
28
- children: /* @__PURE__ */ jsx(StyledPoint, {
29
- id: `${id}-mark`,
30
- isFocused,
31
- r: pointRadius,
32
- opacity
33
- })
34
- }),
35
- [id, isFocused, opacity, pointRadius]
36
- );
26
+ const point = useMemo(() => {
27
+ if (LINE.POINT_STYLE.DIAMOND === pointStyle) {
28
+ const squareEdge = pointRadius * 2;
29
+ return /* @__PURE__ */ jsxs("g", {
30
+ transform: "rotate(45)",
31
+ children: [
32
+ isFocused ? /* @__PURE__ */ jsx("rect", {
33
+ x: -pointRadius - FOCUS_RING.STROKE_WIDTH,
34
+ y: -pointRadius - FOCUS_RING.STROKE_WIDTH,
35
+ width: squareEdge + FOCUS_RING.STROKE_WIDTH * 2,
36
+ height: squareEdge + FOCUS_RING.STROKE_WIDTH * 2,
37
+ fill: "none",
38
+ stroke: FOCUS_RING.COLOR,
39
+ strokeWidth: FOCUS_RING.STROKE_WIDTH
40
+ }) : null,
41
+ /* @__PURE__ */ jsx("rect", {
42
+ x: -pointRadius,
43
+ y: -pointRadius,
44
+ id: `${id}-mark`,
45
+ width: squareEdge,
46
+ height: squareEdge
47
+ })
48
+ ]
49
+ });
50
+ }
51
+ if (LINE.POINT_STYLE.SQUARE === pointStyle) {
52
+ const squareEdge = pointRadius * 2;
53
+ return /* @__PURE__ */ jsxs("g", {
54
+ children: [
55
+ isFocused ? /* @__PURE__ */ jsx("rect", {
56
+ x: -pointRadius - FOCUS_RING.STROKE_WIDTH,
57
+ y: -pointRadius - FOCUS_RING.STROKE_WIDTH,
58
+ width: squareEdge + FOCUS_RING.STROKE_WIDTH * 2,
59
+ height: squareEdge + FOCUS_RING.STROKE_WIDTH * 2,
60
+ fill: "none",
61
+ stroke: FOCUS_RING.COLOR,
62
+ strokeWidth: FOCUS_RING.STROKE_WIDTH
63
+ }) : null,
64
+ /* @__PURE__ */ jsx("rect", {
65
+ x: -pointRadius,
66
+ y: -pointRadius,
67
+ id: `${id}-mark`,
68
+ width: squareEdge,
69
+ height: squareEdge
70
+ })
71
+ ]
72
+ });
73
+ }
74
+ return /* @__PURE__ */ jsxs("g", {
75
+ children: [
76
+ isFocused ? /* @__PURE__ */ jsx("g", {
77
+ children: /* @__PURE__ */ jsx("circle", {
78
+ r: (pointRadius ?? LINE.DEFAULT_POINT_RADIUS) + FOCUS_RING.STROKE_WIDTH,
79
+ fill: "none",
80
+ stroke: FOCUS_RING.COLOR,
81
+ strokeWidth: FOCUS_RING.STROKE_WIDTH
82
+ })
83
+ }) : null,
84
+ /* @__PURE__ */ jsx("circle", {
85
+ id: `${id}-mark`,
86
+ r: pointRadius ?? (isFocused ? LINE.DEFAULT_POINT_RADIUS : 0),
87
+ opacity
88
+ })
89
+ ]
90
+ });
91
+ }, [id, isFocused, opacity, pointRadius, pointStyle]);
92
+ return /* @__PURE__ */ jsxs("g", {
93
+ children: [
94
+ point,
95
+ activePoint?.key === id && TooltipRenderer ? /* @__PURE__ */ jsx(FocusableRegion, {
96
+ id,
97
+ width: pointRadius * 2,
98
+ height: pointRadius * 2,
99
+ pointRadius,
100
+ style: { transform: `translate(-${pointRadius}px, -${pointRadius}px)` },
101
+ content: /* @__PURE__ */ jsx(TooltipRenderer, {
102
+ data: [{ name, yValue, xValue }]
103
+ })
104
+ }) : ""
105
+ ]
106
+ });
37
107
  };
38
108
  export {
39
109
  Point
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Point.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { StyledPoint } from '../styles';\nimport { ChartContext } from '../ChartContext';\n\nexport const Point = ({ x, y, pointRadius, id, opacity }) => {\n const {\n activePoint,\n setActivePoint,\n scrapperPosY,\n scrapperPosX,\n props: { xAxis, scrapper },\n } = useContext(ChartContext);\n const isFocused = useMemo(() => {\n if (activePoint === id) {\n return true;\n }\n if (scrapper?.type === 'horizontal') {\n return y === scrapperPosY;\n }\n if (scrapper?.type === 'vertical') {\n return x === scrapperPosX;\n }\n return false;\n }, [activePoint, id, scrapper, y, scrapperPosY, x, scrapperPosX]);\n\n return useMemo(\n () => (\n <g>\n <StyledPoint id={`${id}-mark`} isFocused={isFocused} r={pointRadius} opacity={opacity}></StyledPoint>\n </g>\n ),\n [id, isFocused, opacity, pointRadius],\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,eAAe;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAEtB,MAAM,QAAQ,CAAC,EAAE,GAAG,GAAG,aAAa,IAAI,QAAQ,MAAM;AAC3D,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,OAAO,SAAS;AAAA,EAC3B,IAAI,WAAW,YAAY;AAC3B,QAAM,YAAY,QAAQ,MAAM;AAC9B,QAAI,gBAAgB,IAAI;AACtB,aAAO;AAAA,IACT;AACA,QAAI,UAAU,SAAS,cAAc;AACnC,aAAO,MAAM;AAAA,IACf;AACA,QAAI,UAAU,SAAS,YAAY;AACjC,aAAO,MAAM;AAAA,IACf;AACA,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,IAAI,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAEhE,SAAO;AAAA,IACL,MACE,oBAAC;AAAA,MACC,8BAAC;AAAA,QAAY,IAAI,GAAG;AAAA,QAAW;AAAA,QAAsB,GAAG;AAAA,QAAa;AAAA,OAAkB;AAAA,KACzF;AAAA,IAEF,CAAC,IAAI,WAAW,SAAS,WAAW;AAAA,EACtC;AACF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING, SCRAPPER, LINE } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nexport const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity }) => {\n const {\n activePoint,\n scrapperPosY,\n scrapperPosX,\n props: { scrapper, TooltipRenderer },\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 return (\n <g>\n {point}\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n width={pointRadius * 2}\n height={pointRadius * 2}\n pointRadius={pointRadius}\n style={{ transform: `translate(-${pointRadius}px, -${pointRadius}px)` }}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : (\n ''\n )}\n </g>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,eAAe;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,YAAY,UAAU,YAAY;AAC3C,SAAS,uBAAuB;AACzB,MAAM,QAAQ,CAAC,EAAE,GAAG,GAAG,QAAQ,QAAQ,MAAM,YAAY,aAAa,IAAI,QAAQ,MAAM;AAC7F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,UAAU,gBAAgB;AAAA,EACrC,IAAI,WAAW,YAAY;AAC3B,QAAM,YAAY,QAAQ,MAAM;AAC9B,QAAI,aAAa,QAAQ,IAAI;AAC3B,aAAO;AAAA,IACT;AACA,QAAI,UAAU,SAAS,SAAS,iBAAiB;AAC/C,aAAO,MAAM;AAAA,IACf;AACA,QAAI,UAAU,SAAS,SAAS,eAAe;AAC7C,aAAO,MAAM;AAAA,IACf;AACA,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,IAAI,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAEhE,QAAM,QAAQ,QAAQ,MAAM;AAC1B,QAAI,KAAK,YAAY,YAAY,YAAY;AAC3C,YAAM,aAAa,cAAc;AAEjC,aACE,qBAAC;AAAA,QAAE,WAAU;AAAA,QACV;AAAA,sBACC,oBAAC;AAAA,YACC,GAAG,CAAC,cAAc,WAAW;AAAA,YAC7B,GAAG,CAAC,cAAc,WAAW;AAAA,YAC7B,OAAO,aAAa,WAAW,eAAe;AAAA,YAC9C,QAAQ,aAAa,WAAW,eAAe;AAAA,YAC/C,MAAK;AAAA,YACL,QAAQ,WAAW;AAAA,YACnB,aAAa,WAAW;AAAA,WACzB,IACC;AAAA,UACJ,oBAAC;AAAA,YAAK,GAAG,CAAC;AAAA,YAAa,GAAG,CAAC;AAAA,YAAa,IAAI,GAAG;AAAA,YAAW,OAAO;AAAA,YAAY,QAAQ;AAAA,WAAY;AAAA;AAAA,OACnG;AAAA,IAEJ;AACA,QAAI,KAAK,YAAY,WAAW,YAAY;AAC1C,YAAM,aAAa,cAAc;AAEjC,aACE,qBAAC;AAAA,QACE;AAAA,sBACC,oBAAC;AAAA,YACC,GAAG,CAAC,cAAc,WAAW;AAAA,YAC7B,GAAG,CAAC,cAAc,WAAW;AAAA,YAC7B,OAAO,aAAa,WAAW,eAAe;AAAA,YAC9C,QAAQ,aAAa,WAAW,eAAe;AAAA,YAC/C,MAAK;AAAA,YACL,QAAQ,WAAW;AAAA,YACnB,aAAa,WAAW;AAAA,WACzB,IACC;AAAA,UACJ,oBAAC;AAAA,YAAK,GAAG,CAAC;AAAA,YAAa,GAAG,CAAC;AAAA,YAAa,IAAI,GAAG;AAAA,YAAW,OAAO;AAAA,YAAY,QAAQ;AAAA,WAAY;AAAA;AAAA,OACnG;AAAA,IAEJ;AAEA,WACE,qBAAC;AAAA,MACE;AAAA,oBACC,oBAAC;AAAA,UACC,8BAAC;AAAA,YACC,IAAI,eAAe,KAAK,wBAAwB,WAAW;AAAA,YAC3D,MAAK;AAAA,YAEL,QAAQ,WAAW;AAAA,YACnB,aAAa,WAAW;AAAA,WACzB;AAAA,SACH,IACE;AAAA,QACJ,oBAAC;AAAA,UACC,IAAI,GAAG;AAAA,UACP,GAAG,gBAAgB,YAAY,KAAK,uBAAuB;AAAA,UAC3D;AAAA,SACD;AAAA;AAAA,KACH;AAAA,EAEJ,GAAG,CAAC,IAAI,WAAW,SAAS,aAAa,UAAU,CAAC;AAEpD,SACE,qBAAC;AAAA,IACE;AAAA;AAAA,MACA,aAAa,QAAQ,MAAM,kBAC1B,oBAAC;AAAA,QACC;AAAA,QACA,OAAO,cAAc;AAAA,QACrB,QAAQ,cAAc;AAAA,QACtB;AAAA,QACA,OAAO,EAAE,WAAW,cAAc,mBAAmB,iBAAiB;AAAA,QACtE,SAAS,oBAAC;AAAA,UAAgB,MAAM,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC;AAAA,SAAG;AAAA,OAC9D,IAEA;AAAA;AAAA,GAEJ;AAEJ;",
6
6
  "names": []
7
7
  }