@cdc/chart 4.24.5 → 4.24.9

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 (87) hide show
  1. package/dist/cdcchart.js +44197 -38258
  2. package/examples/cases-year.json +13379 -0
  3. package/examples/feature/annotations/index.json +542 -0
  4. package/examples/gallery/bar-chart-vertical/combo-line-chart.json +76 -15
  5. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +5 -5
  6. package/examples/xaxis.json +493 -0
  7. package/index.html +20 -10
  8. package/package.json +5 -4
  9. package/src/CdcChart.tsx +462 -172
  10. package/src/_stories/Chart.Legend.Gradient.tsx +19 -0
  11. package/src/_stories/Chart.stories.tsx +18 -171
  12. package/src/_stories/ChartAnnotation.stories.tsx +32 -0
  13. package/src/_stories/_mock/annotation_category_mock.json +473 -0
  14. package/src/_stories/_mock/annotation_date-linear_mock.json +530 -0
  15. package/{examples/feature/line/line-chart.json → src/_stories/_mock/annotation_date-time_mock.json} +150 -69
  16. package/src/_stories/_mock/legend.gradient_mock.json +236 -0
  17. package/src/_stories/_mock/line_chart_two_points_new_chart.json +128 -0
  18. package/src/_stories/_mock/line_chart_two_points_regression_test.json +127 -0
  19. package/src/_stories/_mock/lollipop.json +171 -0
  20. package/src/components/Annotations/components/AnnotationDraggable.styles.css +31 -0
  21. package/src/components/Annotations/components/AnnotationDraggable.tsx +207 -0
  22. package/src/components/Annotations/components/AnnotationDropdown.styles.css +14 -0
  23. package/src/components/Annotations/components/AnnotationDropdown.tsx +72 -0
  24. package/src/components/Annotations/components/AnnotationList.styles.css +45 -0
  25. package/src/components/Annotations/components/AnnotationList.tsx +42 -0
  26. package/src/components/Annotations/components/findNearestDatum.ts +138 -0
  27. package/src/components/Annotations/components/helpers/index.tsx +46 -0
  28. package/src/components/Annotations/index.tsx +13 -0
  29. package/src/components/AreaChart/components/AreaChart.Stacked.jsx +1 -1
  30. package/src/components/AreaChart/components/AreaChart.jsx +1 -1
  31. package/src/components/Axis/Categorical.Axis.tsx +145 -0
  32. package/src/components/BarChart/components/BarChart.Horizontal.tsx +47 -44
  33. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +0 -1
  34. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +11 -14
  35. package/src/components/BarChart/components/BarChart.Vertical.tsx +67 -30
  36. package/src/components/BarChart/helpers/index.ts +91 -0
  37. package/src/components/BrushChart.tsx +205 -0
  38. package/src/components/EditorPanel/EditorPanel.tsx +1794 -403
  39. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +320 -0
  40. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +282 -18
  41. package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +43 -8
  42. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +4 -4
  43. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +4 -13
  44. package/src/components/EditorPanel/components/Panels/index.tsx +3 -1
  45. package/src/components/EditorPanel/components/panels.scss +4 -0
  46. package/src/components/EditorPanel/editor-panel.scss +35 -3
  47. package/src/components/EditorPanel/{useEditorPermissions.js → useEditorPermissions.ts} +105 -17
  48. package/src/components/Legend/Legend.Component.tsx +185 -194
  49. package/src/components/Legend/Legend.Suppression.tsx +146 -0
  50. package/src/components/Legend/Legend.tsx +21 -5
  51. package/src/components/Legend/helpers/createFormatLabels.tsx +1 -1
  52. package/src/components/Legend/helpers/index.ts +35 -0
  53. package/src/components/LegendWrapper.tsx +26 -0
  54. package/src/components/LineChart/LineChartProps.ts +1 -15
  55. package/src/components/LineChart/components/LineChart.BumpCircle.tsx +103 -0
  56. package/src/components/LineChart/components/LineChart.Circle.tsx +47 -8
  57. package/src/components/LineChart/helpers.ts +72 -14
  58. package/src/components/LineChart/index.tsx +117 -42
  59. package/src/components/LinearChart.jsx +179 -136
  60. package/src/components/LinearChart.tsx +1366 -0
  61. package/src/components/PairedBarChart.jsx +9 -9
  62. package/src/components/PieChart/PieChart.tsx +75 -18
  63. package/src/components/Sankey/index.tsx +89 -30
  64. package/src/components/ScatterPlot/ScatterPlot.jsx +22 -8
  65. package/src/components/Sparkline/components/SparkLine.tsx +2 -2
  66. package/src/components/ZoomBrush.tsx +90 -44
  67. package/src/data/initial-state.js +25 -7
  68. package/src/helpers/handleChartTabbing.ts +8 -0
  69. package/src/helpers/isConvertLineToBarGraph.ts +4 -0
  70. package/src/hooks/{useBarChart.js → useBarChart.ts} +2 -40
  71. package/src/hooks/useColorScale.ts +1 -1
  72. package/src/hooks/useLegendClasses.ts +68 -0
  73. package/src/hooks/useMinMax.ts +12 -7
  74. package/src/hooks/useScales.ts +58 -26
  75. package/src/hooks/useTooltip.tsx +135 -25
  76. package/src/scss/DataTable.scss +2 -1
  77. package/src/scss/main.scss +128 -28
  78. package/src/types/ChartConfig.ts +83 -10
  79. package/src/types/ChartContext.ts +14 -4
  80. package/tests-examples/helpers/testZeroValue.test.ts +30 -0
  81. package/LICENSE +0 -201
  82. package/src/components/BrushHandle.jsx +0 -17
  83. package/src/components/LineChart/index.scss +0 -1
  84. package/src/helpers/filterData.ts +0 -18
  85. package/src/helpers/tests/computeMarginBottom.test.ts +0 -21
  86. package/src/hooks/useLegendClasses.js +0 -31
  87. /package/src/hooks/{useReduceData.js → useReduceData.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import chartGradientConfig from './_mock/legend.gradient_mock.json'
3
+
4
+ import Chart from '../CdcChart'
5
+
6
+ const meta: Meta<typeof Chart> = {
7
+ title: 'Components/Templates/Chart/Legend',
8
+ component: Chart
9
+ }
10
+
11
+ type Story = StoryObj<typeof Chart>
12
+
13
+ export const Legend_gradient: Story = {
14
+ args: {
15
+ config: chartGradientConfig
16
+ }
17
+ }
18
+
19
+ export default meta
@@ -2,6 +2,9 @@ import type { Meta, StoryObj } from '@storybook/react'
2
2
  import SuppressedConfig from './_mock/bar-chart-suppressed.json'
3
3
 
4
4
  import Chart from '../CdcChart'
5
+ import lineChartTwoPointsRegressionTest from './_mock/line_chart_two_points_regression_test.json'
6
+ import lineChartTwoPointsNewChart from './_mock/line_chart_two_points_new_chart.json'
7
+ import lollipop from './_mock/lollipop.json'
5
8
 
6
9
  const meta: Meta<typeof Chart> = {
7
10
  title: 'Components/Templates/Chart',
@@ -10,179 +13,23 @@ const meta: Meta<typeof Chart> = {
10
13
 
11
14
  type Story = StoryObj<typeof Chart>
12
15
 
16
+ export const line_Chart_Two_Points_Regression_Test: Story = {
17
+ args: {
18
+ config: lineChartTwoPointsRegressionTest,
19
+ isEditor: false
20
+ }
21
+ }
22
+ export const line_Chart_Two_Points_New_Chart: Story = {
23
+ args: {
24
+ config: lineChartTwoPointsNewChart,
25
+ isEditor: false
26
+ }
27
+ }
28
+
13
29
  export const Lollipop: Story = {
14
30
  args: {
15
- config: {
16
- type: 'chart',
17
- title: 'Lollipop Style Horizontal Bar Chart - Number of Spills Occurring in the Home',
18
- showTitle: true,
19
- showDownloadMediaButton: false,
20
- theme: 'theme-blue',
21
- animate: true,
22
- fontSize: 'medium',
23
- lineDatapointStyle: 'hover',
24
- barHasBorder: 'false',
25
- isLollipopChart: true,
26
- lollipopShape: 'circle',
27
- lollipopColorStyle: 'two-tone',
28
- visualizationSubType: 'horizontal',
29
- barStyle: '',
30
- roundingStyle: 'standard',
31
- tipRounding: 'top',
32
- isResponsiveTicks: false,
33
- general: { showDownloadButton: false },
34
- padding: { left: 5, right: 5 },
35
- yAxis: {
36
- hideAxis: true,
37
- displayNumbersOnBar: true,
38
- hideLabel: false,
39
- hideTicks: false,
40
- size: '13',
41
- gridLines: false,
42
- enablePadding: false,
43
- min: '',
44
- max: '',
45
- labelColor: '#333',
46
- tickLabelColor: '#333',
47
- tickColor: '#333',
48
- rightHideAxis: true,
49
- rightAxisSize: 50,
50
- rightLabel: '',
51
- rightLabelOffsetSize: 0,
52
- rightAxisLabelColor: '#333',
53
- rightAxisTickLabelColor: '#333',
54
- rightAxisTickColor: '#333',
55
- numTicks: '9',
56
- axisPadding: 0,
57
- tickRotation: 0,
58
- anchors: [],
59
- type: 'chart',
60
- title: 'Lollipop Style Horizontal Bar Chart',
61
- theme: 'theme-blue',
62
- fontSize: 'medium',
63
- lineDatapointStyle: 'hover',
64
- barHasBorder: 'false',
65
- isLollipopChart: false,
66
- lollipopShape: 'circle',
67
- lollipopColorStyle: 'two-tone',
68
- visualizationSubType: 'horizontal',
69
- padding: { left: 5, right: 5 },
70
- yAxis: { size: 50, gridLines: false },
71
- barThickness: 0.35,
72
- height: 260,
73
- xAxis: { type: 'categorical', size: 75, tickRotation: 0, dataKey: 'Vehicle' },
74
- table: { label: 'Data Table', expanded: true, show: true },
75
- legend: { behavior: 'isolate', position: 'right' },
76
- exclusions: { active: false, keys: [] },
77
- palette: 'qualitative-bold',
78
- labels: false,
79
- dataFormat: {},
80
- confidenceKeys: {},
81
- data: [
82
- { Group: 'Combined Total of Group A', Vehicle: '100', Home: '120', Work: '140', Office: '120' },
83
- { Group: 'Combined Total of Group B', Vehicle: '150', Home: '140', Work: '100', Office: '90' },
84
- { Group: 'Combined Total of Group C', Vehicle: '90', Home: '90', Work: '80', Office: '80' },
85
- { Group: 'Combined Total of Group D', Vehicle: '70', Home: '60', Work: '50', Office: '70' }
86
- ],
87
- dataFileName: 'CSV_Source_Example_for_Horizontal_Bar_viz-cdcwp1619811744363.csv',
88
- dataFileSourceType: 'file',
89
- visualizationType: 'Bar',
90
- runtime: {
91
- seriesLabels: { Vehicle: 'Vehicle' },
92
- seriesLabelsAll: ['Vehicle'],
93
- originalXAxis: { type: 'categorical', size: 75, tickRotation: 0, dataKey: 'Vehicle' },
94
- seriesKeys: ['Vehicle'],
95
- xAxis: { size: 50, gridLines: false },
96
- yAxis: { type: 'categorical', size: 75, tickRotation: 0, dataKey: 'Vehicle' },
97
- horizontal: true,
98
- uniqueId: 1651765968212,
99
- editorErrorMessage: ''
100
- },
101
- description: 'Subtext can be added here for options like citing data sources or insight into reading the bar chart.',
102
- series: [{ dataKey: 'Vehicle', type: 'Bar' }],
103
- barHeight: 25,
104
- barPadding: 40,
105
- labelPlacement: 'Below Bar',
106
- label: 'Number of Accidents'
107
- },
108
- boxplot: [],
109
- topAxis: { hasLine: false },
110
- isLegendValue: false,
111
- barThickness: 0.35,
112
- barHeight: 6,
113
- barSpace: 15,
114
- heights: { vertical: 300, horizontal: 170.39999999999998 },
115
- xAxis: {
116
- anchors: [],
117
- type: 'categorical',
118
- showTargetLabel: true,
119
- targetLabel: 'Target',
120
- hideAxis: true,
121
- hideLabel: true,
122
- hideTicks: true,
123
- size: '16',
124
- tickRotation: 0,
125
- min: '',
126
- max: '160',
127
- labelColor: '#333',
128
- tickLabelColor: '#333',
129
- tickColor: '#333',
130
- numTicks: '',
131
- labelOffset: 65,
132
- axisPadding: 0,
133
- target: 0,
134
- maxTickRotation: 0,
135
- dataKey: 'Group'
136
- },
137
- table: { label: 'Data Table', expanded: false, limitHeight: false, height: '', caption: '', showDownloadUrl: false, showDataTableLink: true, indexLabel: 'Group', download: false, showVertical: true, show: true },
138
- orientation: 'horizontal',
139
- color: 'pinkpurple',
140
- columns: {},
141
- legend: {
142
- behavior: 'isolate',
143
- singleRow: false,
144
- colorCode: '',
145
- reverseLabelOrder: false,
146
- description: '',
147
- dynamicLegend: false,
148
- dynamicLegendDefaultText: 'Show All',
149
- dynamicLegendItemLimit: 5,
150
- dynamicLegendItemLimitMessage: 'Dynamic Legend Item Limit Hit.',
151
- dynamicLegendChartMessage: 'Select Options from the Legend',
152
- position: 'right',
153
- hide: true,
154
- label: 'Accident Location'
155
- },
156
- exclusions: { active: false, keys: [] },
157
- palette: 'qualitative-bold',
158
- isPaletteReversed: false,
159
- twoColor: { palette: 'monochrome-1', isPaletteReversed: false },
160
- labels: false,
161
- dataFormat: { commas: false, prefix: '', suffix: '', abbreviated: false, bottomSuffix: '', bottomPrefix: '', bottomAbbreviated: false },
162
- confidenceKeys: {},
163
- visual: { border: true, accent: true, background: true, verticalHoverLine: false, horizontalHoverLine: false },
164
- useLogScale: false,
165
- filterBehavior: 'Filter Change',
166
- highlightedBarValues: [],
167
- series: [{ dataKey: 'Home', type: 'Bar', tooltip: true }],
168
- tooltips: { opacity: 90 },
169
- height: 212,
170
- data: [
171
- { Group: 'Combined Total of Group A', Vehicle: '100', Home: '120', Work: '140', Office: '120' },
172
- { Group: 'Combined Total of Group B', Vehicle: '150', Home: '140', Work: '100', Office: '90' },
173
- { Group: 'Combined Total of Group C', Vehicle: '90', Home: '90', Work: '80', Office: '80' },
174
- { Group: 'Combined Total of Group D', Vehicle: '70', Home: '60', Work: '50', Office: '70' }
175
- ],
176
- dataFileName: 'CSV_Source_Example_for_Horizontal_Bar_viz-cdcwp1619811744363.csv',
177
- dataFileSourceType: 'file',
178
- visualizationType: 'Bar',
179
- description: 'Subtext can be added here for options like citing data sources or insight into reading the bar chart.',
180
- barPadding: 47,
181
- filters: [],
182
- lollipopSize: 'medium',
183
- validated: 4.23,
184
- dynamicMarginTop: 0
185
- }
31
+ config: lollipop,
32
+ isEditor: false
186
33
  }
187
34
  }
188
35
 
@@ -0,0 +1,32 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import annotationConfig from './_mock/annotation_category_mock.json'
3
+ import annotationConfigDateLinear from './_mock/annotation_date-linear_mock.json'
4
+ import annotationConfigDateTime from './_mock/annotation_date-time_mock.json'
5
+ import Chart from '../CdcChart'
6
+
7
+ const meta: Meta<typeof Chart> = {
8
+ title: 'Components/Templates/Chart/Annotation',
9
+ component: Chart
10
+ }
11
+
12
+ type Story = StoryObj<typeof Chart>
13
+
14
+ export const Chart_Annotation_Categorical: Story = {
15
+ args: {
16
+ config: annotationConfig
17
+ }
18
+ }
19
+
20
+ export const Chart_Annotation_Date_Linear: Story = {
21
+ args: {
22
+ config: annotationConfigDateLinear
23
+ }
24
+ }
25
+
26
+ export const Chart_Annotation_Date_Time: Story = {
27
+ args: {
28
+ config: annotationConfigDateTime
29
+ }
30
+ }
31
+
32
+ export default meta