@cdc/chart 4.25.1 → 4.25.2-25
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 +40297 -40036
- package/examples/feature/tests-non-numerics/example-combo-bar-nonnumeric.json +396 -230
- package/examples/private/line-issue.json +497 -0
- package/index.html +6 -3
- package/package.json +2 -2
- package/src/CdcChartComponent.tsx +113 -105
- package/src/ConfigContext.tsx +6 -1
- package/src/_stories/Chart.DynamicSeries.stories.tsx +16 -1
- package/src/_stories/Chart.Filters.stories.tsx +19 -0
- package/src/components/Axis/Categorical.Axis.tsx +1 -1
- package/src/components/BarChart/components/BarChart.Vertical.tsx +3 -5
- package/src/components/BarChart/components/BarChart.jsx +24 -4
- package/src/components/BarChart/components/context.tsx +1 -0
- package/src/components/BrushChart.tsx +44 -24
- package/src/components/DeviationBar.jsx +2 -2
- package/src/components/EditorPanel/EditorPanel.tsx +2 -2
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +3 -1
- package/src/components/EditorPanel/helpers/updateFieldRankByValue.ts +6 -1
- package/src/components/Legend/helpers/index.ts +10 -4
- package/src/components/LineChart/components/LineChart.Circle.tsx +17 -9
- package/src/components/LineChart/index.tsx +2 -2
- package/src/components/LinearChart.tsx +12 -12
- package/src/components/ZoomBrush.tsx +1 -1
- package/src/helpers/getColorScale.ts +5 -9
- package/src/helpers/isConvertLineToBarGraph.ts +10 -3
- package/src/hooks/useBarChart.ts +12 -4
- package/src/hooks/useMinMax.ts +7 -8
- package/src/hooks/useScales.ts +10 -0
- package/src/hooks/useTooltip.tsx +12 -1
- package/src/scss/main.scss +1 -1
- package/src/store/chart.actions.ts +40 -0
- package/src/store/chart.reducer.ts +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import ChartActions from './chart.actions'
|
|
2
|
+
import defaults from '../data/initial-state.js'
|
|
3
|
+
import { ChartConfig, type ViewportSize } from '../types/ChartConfig'
|
|
4
|
+
import { DimensionsType } from '@cdc/core/types/Dimensions'
|
|
5
|
+
import _ from 'lodash'
|
|
6
|
+
|
|
7
|
+
export const getInitialState = (configObj: ChartConfig) => {
|
|
8
|
+
return {
|
|
9
|
+
isLoading: true,
|
|
10
|
+
config: defaults,
|
|
11
|
+
stateData: _.cloneDeep(configObj?.data) || [],
|
|
12
|
+
colorScale: null,
|
|
13
|
+
excludedData: undefined,
|
|
14
|
+
filteredData: undefined,
|
|
15
|
+
seriesHighlight:
|
|
16
|
+
configObj && configObj?.legend?.seriesHighlight?.length ? [...configObj?.legend?.seriesHighlight] : [],
|
|
17
|
+
currentViewport: 'lg',
|
|
18
|
+
dimensions: [0, 0],
|
|
19
|
+
container: null,
|
|
20
|
+
coveLoadedEventRan: false,
|
|
21
|
+
isDraggingAnnotation: false,
|
|
22
|
+
imageId: `cove-${Math.random().toString(16).slice(-4)}`,
|
|
23
|
+
brushConfig: {
|
|
24
|
+
data: [],
|
|
25
|
+
isActive: false,
|
|
26
|
+
isBrushing: false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type State = {
|
|
32
|
+
isLoading: boolean
|
|
33
|
+
config: ChartConfig
|
|
34
|
+
stateData: object[]
|
|
35
|
+
colorScale: Function
|
|
36
|
+
excludedData: object[]
|
|
37
|
+
filteredData: object[]
|
|
38
|
+
seriesHighlight: string[]
|
|
39
|
+
currentViewport: ViewportSize
|
|
40
|
+
dimensions: DimensionsType
|
|
41
|
+
container: HTMLElement | null
|
|
42
|
+
coveLoadedEventRan: boolean
|
|
43
|
+
isDraggingAnnotation: boolean
|
|
44
|
+
imageId: string
|
|
45
|
+
brushConfig: {
|
|
46
|
+
data: object[]
|
|
47
|
+
isActive: boolean
|
|
48
|
+
isBrushing: boolean
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const reducer = (state: State, action: ChartActions) => {
|
|
53
|
+
switch (action.type) {
|
|
54
|
+
case 'SET_LOADING':
|
|
55
|
+
return { ...state, isLoading: action.payload }
|
|
56
|
+
case 'SET_CONFIG':
|
|
57
|
+
return { ...state, config: action.payload }
|
|
58
|
+
case 'UPDATE_CONFIG':
|
|
59
|
+
return { ...state, config: action.payload }
|
|
60
|
+
case 'SET_COLOR_SCALE':
|
|
61
|
+
return { ...state, colorScale: action.payload }
|
|
62
|
+
case 'SET_STATE_DATA':
|
|
63
|
+
return { ...state, stateData: action.payload }
|
|
64
|
+
case 'SET_EXCLUDED_DATA':
|
|
65
|
+
return { ...state, excludedData: action.payload }
|
|
66
|
+
case 'SET_FILTERED_DATA':
|
|
67
|
+
return { ...state, filteredData: action.payload }
|
|
68
|
+
case 'SET_SERIES_HIGHLIGHT':
|
|
69
|
+
return { ...state, seriesHighlight: action.payload }
|
|
70
|
+
case 'SET_VIEWPORT':
|
|
71
|
+
return { ...state, currentViewport: action.payload }
|
|
72
|
+
case 'SET_DIMENSIONS':
|
|
73
|
+
return { ...state, dimensions: action.payload }
|
|
74
|
+
case 'SET_CONTAINER':
|
|
75
|
+
return { ...state, container: action.payload }
|
|
76
|
+
case 'SET_LOADED_EVENT':
|
|
77
|
+
return { ...state, coveLoadedEventRan: action.payload }
|
|
78
|
+
case 'SET_DRAG_ANNOTATIONS':
|
|
79
|
+
return { ...state, isDraggingAnnotation: action.payload }
|
|
80
|
+
case 'SET_BRUSH_CONFIG':
|
|
81
|
+
return { ...state, brushConfig: action.payload }
|
|
82
|
+
}
|
|
83
|
+
}
|