@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.
- package/dist/cdcchart.js +44197 -38258
- package/examples/cases-year.json +13379 -0
- package/examples/feature/annotations/index.json +542 -0
- package/examples/gallery/bar-chart-vertical/combo-line-chart.json +76 -15
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +5 -5
- package/examples/xaxis.json +493 -0
- package/index.html +20 -10
- package/package.json +5 -4
- package/src/CdcChart.tsx +462 -172
- package/src/_stories/Chart.Legend.Gradient.tsx +19 -0
- package/src/_stories/Chart.stories.tsx +18 -171
- package/src/_stories/ChartAnnotation.stories.tsx +32 -0
- package/src/_stories/_mock/annotation_category_mock.json +473 -0
- package/src/_stories/_mock/annotation_date-linear_mock.json +530 -0
- package/{examples/feature/line/line-chart.json → src/_stories/_mock/annotation_date-time_mock.json} +150 -69
- package/src/_stories/_mock/legend.gradient_mock.json +236 -0
- package/src/_stories/_mock/line_chart_two_points_new_chart.json +128 -0
- package/src/_stories/_mock/line_chart_two_points_regression_test.json +127 -0
- package/src/_stories/_mock/lollipop.json +171 -0
- package/src/components/Annotations/components/AnnotationDraggable.styles.css +31 -0
- package/src/components/Annotations/components/AnnotationDraggable.tsx +207 -0
- package/src/components/Annotations/components/AnnotationDropdown.styles.css +14 -0
- package/src/components/Annotations/components/AnnotationDropdown.tsx +72 -0
- package/src/components/Annotations/components/AnnotationList.styles.css +45 -0
- package/src/components/Annotations/components/AnnotationList.tsx +42 -0
- package/src/components/Annotations/components/findNearestDatum.ts +138 -0
- package/src/components/Annotations/components/helpers/index.tsx +46 -0
- package/src/components/Annotations/index.tsx +13 -0
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +1 -1
- package/src/components/AreaChart/components/AreaChart.jsx +1 -1
- package/src/components/Axis/Categorical.Axis.tsx +145 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +47 -44
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +0 -1
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +11 -14
- package/src/components/BarChart/components/BarChart.Vertical.tsx +67 -30
- package/src/components/BarChart/helpers/index.ts +91 -0
- package/src/components/BrushChart.tsx +205 -0
- package/src/components/EditorPanel/EditorPanel.tsx +1794 -403
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +320 -0
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +282 -18
- package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +43 -8
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +4 -4
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +4 -13
- package/src/components/EditorPanel/components/Panels/index.tsx +3 -1
- package/src/components/EditorPanel/components/panels.scss +4 -0
- package/src/components/EditorPanel/editor-panel.scss +35 -3
- package/src/components/EditorPanel/{useEditorPermissions.js → useEditorPermissions.ts} +105 -17
- package/src/components/Legend/Legend.Component.tsx +185 -194
- package/src/components/Legend/Legend.Suppression.tsx +146 -0
- package/src/components/Legend/Legend.tsx +21 -5
- package/src/components/Legend/helpers/createFormatLabels.tsx +1 -1
- package/src/components/Legend/helpers/index.ts +35 -0
- package/src/components/LegendWrapper.tsx +26 -0
- package/src/components/LineChart/LineChartProps.ts +1 -15
- package/src/components/LineChart/components/LineChart.BumpCircle.tsx +103 -0
- package/src/components/LineChart/components/LineChart.Circle.tsx +47 -8
- package/src/components/LineChart/helpers.ts +72 -14
- package/src/components/LineChart/index.tsx +117 -42
- package/src/components/LinearChart.jsx +179 -136
- package/src/components/LinearChart.tsx +1366 -0
- package/src/components/PairedBarChart.jsx +9 -9
- package/src/components/PieChart/PieChart.tsx +75 -18
- package/src/components/Sankey/index.tsx +89 -30
- package/src/components/ScatterPlot/ScatterPlot.jsx +22 -8
- package/src/components/Sparkline/components/SparkLine.tsx +2 -2
- package/src/components/ZoomBrush.tsx +90 -44
- package/src/data/initial-state.js +25 -7
- package/src/helpers/handleChartTabbing.ts +8 -0
- package/src/helpers/isConvertLineToBarGraph.ts +4 -0
- package/src/hooks/{useBarChart.js → useBarChart.ts} +2 -40
- package/src/hooks/useColorScale.ts +1 -1
- package/src/hooks/useLegendClasses.ts +68 -0
- package/src/hooks/useMinMax.ts +12 -7
- package/src/hooks/useScales.ts +58 -26
- package/src/hooks/useTooltip.tsx +135 -25
- package/src/scss/DataTable.scss +2 -1
- package/src/scss/main.scss +128 -28
- package/src/types/ChartConfig.ts +83 -10
- package/src/types/ChartContext.ts +14 -4
- package/tests-examples/helpers/testZeroValue.test.ts +30 -0
- package/LICENSE +0 -201
- package/src/components/BrushHandle.jsx +0 -17
- package/src/components/LineChart/index.scss +0 -1
- package/src/helpers/filterData.ts +0 -18
- package/src/helpers/tests/computeMarginBottom.test.ts +0 -21
- package/src/hooks/useLegendClasses.js +0 -31
- /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
|
-
|
|
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
|