@cdc/chart 4.24.4 → 4.24.5

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 (33) hide show
  1. package/dist/cdcchart.js +32130 -31726
  2. package/index.html +7 -7
  3. package/package.json +2 -2
  4. package/src/CdcChart.tsx +17 -13
  5. package/src/_stories/Chart.stories.tsx +8 -0
  6. package/src/_stories/_mock/bar-chart-suppressed.json +474 -0
  7. package/src/components/AreaChart/components/AreaChart.jsx +2 -2
  8. package/src/components/BarChart/components/BarChart.Horizontal.tsx +52 -47
  9. package/src/components/BarChart/components/BarChart.Vertical.tsx +77 -92
  10. package/src/components/DeviationBar.jsx +4 -2
  11. package/src/components/EditorPanel/EditorPanel.tsx +289 -601
  12. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +19 -2
  13. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +4 -5
  14. package/src/components/EditorPanel/useEditorPermissions.js +4 -1
  15. package/src/components/Legend/Legend.Component.tsx +62 -10
  16. package/src/components/LineChart/LineChartProps.ts +13 -6
  17. package/src/components/LineChart/components/LineChart.Circle.tsx +22 -11
  18. package/src/components/LineChart/helpers.ts +134 -10
  19. package/src/components/LineChart/index.tsx +69 -42
  20. package/src/components/LinearChart.jsx +155 -139
  21. package/src/components/ZoomBrush.tsx +40 -21
  22. package/src/data/initial-state.js +4 -4
  23. package/src/hooks/useBarChart.js +47 -22
  24. package/src/hooks/useMinMax.ts +21 -2
  25. package/src/hooks/useScales.ts +23 -23
  26. package/src/hooks/useTooltip.tsx +11 -11
  27. package/src/scss/main.scss +56 -6
  28. package/src/types/ChartConfig.ts +3 -13
  29. package/src/types/ChartContext.ts +4 -0
  30. package/src/_stories/ChartLine.preliminary.tsx +0 -19
  31. package/src/_stories/ChartSuppress.stories.tsx +0 -19
  32. package/src/_stories/_mock/suppress_mock.json +0 -911
  33. package/src/helpers/computeMarginBottom.ts +0 -56
@@ -1,56 +0,0 @@
1
- import { ChartConfig } from '../types/ChartConfig'
2
- import { Legend } from '@cdc/core/types/Legend'
3
-
4
- export const computeMarginBottom = (config: ChartConfig, legend: Legend, currentViewport: string): string | number => {
5
- const isLegendBottom = legend.position === 'bottom' || ['sm', 'xs', 'xxs'].includes(currentViewport)
6
- const isHorizontal = config.orientation === 'horizontal'
7
- const tickRotation = Number(config.xAxis.tickRotation) > 0 ? Number(config.xAxis.tickRotation) : 0
8
- const isBrush = config?.brush?.active
9
- const offset = 20
10
- const brushHeight = config?.brush?.height
11
- let bottom = 0
12
- if (!isLegendBottom && isHorizontal && !config.yAxis.label) {
13
- bottom = Number(config.xAxis.labelOffset)
14
- }
15
- if (!isLegendBottom && isHorizontal && config.yAxis.label && !config.isResponsiveTicks) {
16
- bottom = Number(config.runtime.xAxis.size) + Number(config.xAxis.labelOffset)
17
- }
18
- if (!isLegendBottom && isHorizontal && config.yAxis.label && config.isResponsiveTicks) {
19
- bottom = config.dynamicMarginTop + offset
20
- }
21
- if (!isLegendBottom && isHorizontal && !config.yAxis.label && config.isResponsiveTicks) {
22
- bottom = config.dynamicMarginTop ? config.dynamicMarginTop - offset : Number(config.xAxis.labelOffset) - offset
23
- }
24
- if (!isLegendBottom && isHorizontal && config.yAxis.label && config.isResponsiveTicks) {
25
- bottom = config.dynamicMarginTop ? config.dynamicMarginTop + offset : Number(config.xAxis.labelOffset)
26
- }
27
-
28
- if (!isHorizontal && !isLegendBottom && config.xAxis.label && tickRotation && !config.isResponsiveTicks) {
29
- bottom = isBrush ? brushHeight + config.xAxis.tickWidthMax + -config.xAxis.size + config.xAxis.labelOffset + offset : config.xAxis.tickWidthMax + offset + -config.xAxis.size + config.xAxis.labelOffset
30
- }
31
- if (!isHorizontal && !isLegendBottom && !config.xAxis.label && tickRotation && !config.isResponsiveTicks) {
32
- }
33
- if (!isHorizontal && !isLegendBottom && !config.xAxis.label && tickRotation && !config.dynamicMarginTop && !config.isResponsiveTicks) {
34
- bottom = isBrush ? config.xAxis.tickWidthMax + brushHeight + offset + -config.xAxis.size : 0
35
- }
36
-
37
- if (!isHorizontal && !isLegendBottom && config.xAxis.label && !tickRotation && !config.isResponsiveTicks) {
38
- bottom = isBrush ? brushHeight + -config.xAxis.size + config.xAxis.labelOffset + offset : -config.xAxis.size + config.xAxis.labelOffset + offset
39
- }
40
- if (!isHorizontal && !isLegendBottom && config.xAxis.label && config.dynamicMarginTop && config.isResponsiveTicks) {
41
- bottom = isBrush ? brushHeight + config.xAxis.labelOffset + -config.xAxis.size + config.xAxis.tickWidthMax : config.dynamicMarginTop + -config.xAxis.size + offset
42
- }
43
- if (!isHorizontal && !isLegendBottom && !config.xAxis.label && config.dynamicMarginTop && config.isResponsiveTicks) {
44
- bottom = isBrush ? brushHeight + config.xAxis.labelOffset + -config.xAxis.size + config.xAxis.tickWidthMax : config.dynamicMarginTop + -config.xAxis.size - offset
45
- }
46
- if (!isHorizontal && !isLegendBottom && config.xAxis.label && !config.dynamicMarginTop && config.isResponsiveTicks) {
47
- bottom = isBrush ? brushHeight + config.xAxis.labelOffset + -config.xAxis.size + 25 : config.xAxis.labelOffset + -config.xAxis.size + offset
48
- }
49
- if (!isHorizontal && !isLegendBottom && !config.xAxis.label && !config.dynamicMarginTop && config.isResponsiveTicks) {
50
- bottom = -config.xAxis.size + offset + config.xAxis.labelOffset
51
- }
52
- if (!isHorizontal && !isLegendBottom && !config.xAxis.label && !tickRotation && !config.dynamicMarginTop && !config.isResponsiveTicks) {
53
- bottom = isBrush ? brushHeight + -config.xAxis.size + config.xAxis.labelOffset : 0
54
- }
55
- return `${bottom}px`
56
- }