@cdc/chart 4.25.5-1 → 4.25.6-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.
- package/LICENSE +201 -0
- package/dist/cdcchart.js +32053 -27935
- package/index.html +130 -130
- package/package.json +2 -2
- package/src/CdcChartComponent.tsx +66 -26
- package/src/_stories/Chart.stories.tsx +99 -93
- package/src/_stories/ChartPrefixSuffix.stories.tsx +29 -32
- package/src/_stories/_mock/pie_calculated_area.json +417 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +4 -13
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +3 -14
- package/src/components/BarChart/components/BarChart.Vertical.tsx +2 -8
- package/src/components/Brush/BrushChart.tsx +73 -0
- package/src/components/Brush/BrushController..tsx +39 -0
- package/src/components/DeviationBar.jsx +0 -1
- package/src/components/EditorPanel/EditorPanel.tsx +246 -156
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +2 -2
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +3 -2
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +2 -1
- package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +8 -0
- package/src/components/EditorPanel/useEditorPermissions.ts +7 -4
- package/src/components/HoverLine/HoverLine.tsx +74 -0
- package/src/components/Legend/Legend.Suppression.tsx +47 -3
- package/src/components/Legend/helpers/index.ts +1 -1
- package/src/components/LineChart/helpers.ts +7 -7
- package/src/components/LineChart/index.tsx +3 -6
- package/src/components/LinearChart.tsx +108 -72
- package/src/components/PieChart/PieChart.tsx +58 -13
- package/src/data/initial-state.js +8 -5
- package/src/helpers/countNumOfTicks.ts +4 -19
- package/src/helpers/getNewRuntime.ts +35 -0
- package/src/helpers/getPiePercent.ts +22 -0
- package/src/helpers/getTransformedData.ts +22 -0
- package/src/helpers/tests/getNewRuntime.test.ts +82 -0
- package/src/helpers/tests/getPiePercent.test.ts +38 -0
- package/src/hooks/useRightAxis.ts +1 -1
- package/src/hooks/useScales.ts +8 -3
- package/src/hooks/useTooltip.tsx +24 -10
- package/src/scss/main.scss +8 -4
- package/src/store/chart.actions.ts +2 -6
- package/src/store/chart.reducer.ts +23 -23
- package/src/types/ChartConfig.ts +7 -4
- package/src/types/ChartContext.ts +0 -2
- package/src/components/ZoomBrush.tsx +0 -251
|
@@ -1,93 +1,99 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
|
|
3
|
-
import Chart from '../CdcChart'
|
|
4
|
-
import lineChartTwoPointsRegressionTest from './_mock/line_chart_two_points_regression_test.json'
|
|
5
|
-
import lineChartTwoPointsNewChart from './_mock/line_chart_two_points_new_chart.json'
|
|
6
|
-
import lollipop from './_mock/lollipop.json'
|
|
7
|
-
import forestPlot from '../../examples/feature/forest-plot/forest-plot.json'
|
|
8
|
-
import pairedBar from './_mock/paired-bar.json'
|
|
9
|
-
import horizontalBarConfig from './_mock/horizontal_bar.json'
|
|
10
|
-
import barChartLabels from './_mock/barchart_labels.mock.json'
|
|
11
|
-
import pieConfig from './_mock/pie_with_data.json'
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export const
|
|
75
|
-
args: {
|
|
76
|
-
config:
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
|
|
3
|
+
import Chart from '../CdcChart'
|
|
4
|
+
import lineChartTwoPointsRegressionTest from './_mock/line_chart_two_points_regression_test.json'
|
|
5
|
+
import lineChartTwoPointsNewChart from './_mock/line_chart_two_points_new_chart.json'
|
|
6
|
+
import lollipop from './_mock/lollipop.json'
|
|
7
|
+
import forestPlot from '../../examples/feature/forest-plot/forest-plot.json'
|
|
8
|
+
import pairedBar from './_mock/paired-bar.json'
|
|
9
|
+
import horizontalBarConfig from './_mock/horizontal_bar.json'
|
|
10
|
+
import barChartLabels from './_mock/barchart_labels.mock.json'
|
|
11
|
+
import pieConfig from './_mock/pie_with_data.json'
|
|
12
|
+
import pieCalculatedArea from './_mock/pie_calculated_area.json'
|
|
13
|
+
import boxPlotConfig from './_mock/boxplot_multiseries.json'
|
|
14
|
+
import areaChartStacked from './_mock/area_chart_stacked.json'
|
|
15
|
+
import multipleLines from './_mock/short_dates.json'
|
|
16
|
+
import { editConfigKeys } from '../helpers/configHelpers'
|
|
17
|
+
|
|
18
|
+
const meta: Meta<typeof Chart> = {
|
|
19
|
+
title: 'Components/Templates/Chart',
|
|
20
|
+
component: Chart
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<typeof Chart>
|
|
24
|
+
|
|
25
|
+
export const line_Chart_Two_Points_Regression_Test: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
config: lineChartTwoPointsRegressionTest,
|
|
28
|
+
isEditor: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const line_Chart_Two_Points_New_Chart: Story = {
|
|
32
|
+
args: {
|
|
33
|
+
config: lineChartTwoPointsNewChart,
|
|
34
|
+
isEditor: false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const multiple_lines: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
config: editConfigKeys(multipleLines, [{ path: ['tooltips', 'dateDisplayFormat'], value: '%b. %d %Y' }])
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Lollipop: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
config: lollipop,
|
|
47
|
+
isEditor: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Forest_Plot: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
config: forestPlot
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const Horizontal_Bar: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
config: horizontalBarConfig
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const BarChart_Labels: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
config: barChartLabels
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Pie: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
config: pieConfig
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export const Pie_Calculated_Area: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
config: pieCalculatedArea
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const Paired_Bar: Story = {
|
|
81
|
+
args: {
|
|
82
|
+
config: pairedBar
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export const BoxPlot_Multiseries: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
config: boxPlotConfig,
|
|
88
|
+
isEditor: false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const Area_Chart_stacked: Story = {
|
|
93
|
+
args: {
|
|
94
|
+
config: areaChartStacked,
|
|
95
|
+
isEditor: false
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default meta
|
|
@@ -15,49 +15,55 @@ const meta: Meta<typeof Chart> = {
|
|
|
15
15
|
|
|
16
16
|
type Story = StoryObj<typeof Chart>
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const Inline_Label: Story = {
|
|
19
19
|
args: {
|
|
20
20
|
config: editConfigKeys(barConfig, [
|
|
21
|
-
{ path: ['
|
|
22
|
-
{ path: ['dataFormat', 'suffix'], value: ' Somethings per Something' },
|
|
21
|
+
{ path: ['yAxis', 'inlineLabel'], value: ' Somethings per Something' },
|
|
23
22
|
{ path: ['yAxis', 'gridLines'], value: true }
|
|
24
23
|
])
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
export const Top_Suffix_Worst_Case: Story = {
|
|
26
|
+
export const Inline_Label_With_Suffix: Story = {
|
|
29
27
|
args: {
|
|
30
|
-
config: editConfigKeys(
|
|
31
|
-
{ path: ['
|
|
32
|
-
{ path: ['dataFormat', 'suffix'], value: '
|
|
28
|
+
config: editConfigKeys(barConfig, [
|
|
29
|
+
{ path: ['yAxis', 'inlineLabel'], value: ' Somethings per Something' },
|
|
30
|
+
{ path: ['dataFormat', 'suffix'], value: '%' },
|
|
31
|
+
{ path: ['yAxis', 'gridLines'], value: true }
|
|
33
32
|
])
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
export const
|
|
36
|
+
export const Inline_Label_Worst_Case: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
config: editConfigKeys(annotationConfig, [{ path: ['yAxis', 'inlineLabel'], value: ' Somethings per Something' }])
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Inline_Label_With_Options: Story = {
|
|
38
43
|
args: {
|
|
39
44
|
config: editConfigKeys(annotationConfig, [
|
|
40
|
-
{ path: ['
|
|
45
|
+
{ path: ['yAxis', 'inlineLabel'], value: ' units' },
|
|
46
|
+
{ path: ['dataFormat', 'suffix'], value: '' },
|
|
41
47
|
{ path: ['yAxis', 'tickRotation'], value: 45 },
|
|
42
48
|
{ path: ['yAxis', 'tickLabelColor'], value: 'red' }
|
|
43
49
|
])
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
export const
|
|
53
|
+
export const Inline_Label_No_Space: Story = {
|
|
48
54
|
args: {
|
|
49
55
|
config: editConfigKeys(annotationConfig, [
|
|
50
|
-
{ path: ['
|
|
51
|
-
{ path: ['dataFormat', 'suffix'], value: '
|
|
56
|
+
{ path: ['yAxis', 'inlineLabel'], value: 'lbs' },
|
|
57
|
+
{ path: ['dataFormat', 'suffix'], value: '' }
|
|
52
58
|
])
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
export const
|
|
62
|
+
export const Inline_Label_With_Space: Story = {
|
|
57
63
|
args: {
|
|
58
64
|
config: editConfigKeys(annotationConfig, [
|
|
59
|
-
{ path: ['
|
|
60
|
-
{ path: ['dataFormat', 'suffix'], value: '
|
|
65
|
+
{ path: ['yAxis', 'inlineLabel'], value: 'lbs of something' },
|
|
66
|
+
{ path: ['dataFormat', 'suffix'], value: '' }
|
|
61
67
|
])
|
|
62
68
|
}
|
|
63
69
|
}
|
|
@@ -67,15 +73,7 @@ export const Suffix: Story = {
|
|
|
67
73
|
config: annotationConfig
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
args: {
|
|
72
|
-
config: editConfigKeys(annotationConfig, [
|
|
73
|
-
{ path: ['dataFormat', 'onlyShowTopPrefixSuffix'], value: true },
|
|
74
|
-
{ path: ['dataFormat', 'prefix'], value: '$' },
|
|
75
|
-
{ path: ['dataFormat', 'suffix'], value: '' }
|
|
76
|
-
])
|
|
77
|
-
}
|
|
78
|
-
}
|
|
76
|
+
|
|
79
77
|
export const Prefix: Story = {
|
|
80
78
|
args: {
|
|
81
79
|
config: editConfigKeys(areaPrefix, [
|
|
@@ -85,10 +83,10 @@ export const Prefix: Story = {
|
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
export const
|
|
86
|
+
export const Prefix_Suffix_And_Inline_Title: Story = {
|
|
89
87
|
args: {
|
|
90
88
|
config: editConfigKeys(annotationConfig, [
|
|
91
|
-
{ path: ['
|
|
89
|
+
{ path: ['yAxis', 'inlineLabel'], value: 'lbs of something' },
|
|
92
90
|
{ path: ['dataFormat', 'prefix'], value: '$' }
|
|
93
91
|
])
|
|
94
92
|
}
|
|
@@ -102,11 +100,11 @@ export const Horizontal_Bar: Story = {
|
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
export const
|
|
103
|
+
export const Inline_Title_On_Line: Story = {
|
|
106
104
|
args: {
|
|
107
105
|
config: editConfigKeys(barConfig, [
|
|
108
|
-
{ path: ['
|
|
109
|
-
{ path: ['dataFormat', 'suffix'], value: '
|
|
106
|
+
{ path: ['yAxis', 'inlineLabel'], value: 'lbs of something' },
|
|
107
|
+
{ path: ['dataFormat', 'suffix'], value: '' },
|
|
110
108
|
{ path: ['yAxis', 'gridLines'], value: true },
|
|
111
109
|
{ path: ['yAxis', 'labelsAboveGridlines'], value: true },
|
|
112
110
|
{ path: ['yAxis', 'hideAxis'], value: true }
|
|
@@ -128,9 +126,8 @@ export const Values_On_Line_All_Suffix: Story = {
|
|
|
128
126
|
export const Values_on_Line_Top_Suffix_Only_Area_Worst_Case: Story = {
|
|
129
127
|
args: {
|
|
130
128
|
config: editConfigKeys(annotationConfig, [
|
|
131
|
-
{ path: ['
|
|
129
|
+
{ path: ['yAxis', 'inlineLabel'], value: ' of something' },
|
|
132
130
|
{ path: ['dataFormat', 'prefix'], value: 'pre' },
|
|
133
|
-
{ path: ['dataFormat', 'suffix'], value: ' Somethings per Something' },
|
|
134
131
|
{ path: ['yAxis', 'labelsAboveGridlines'], value: true },
|
|
135
132
|
{ path: ['yAxis', 'gridLines'], value: true }
|
|
136
133
|
])
|