Skip to content

Commit b4758cd

Browse files
authored
Merge pull request #1568 from afwillia/PORTALS-3410
PORTALS-3410 - Make plotType customizable
2 parents 43a6b5f + 68ce4f2 commit b4758cd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

apps/portals/standards/src/config/synapseConfigs/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const dataQueryWrapperPlotNavProps: QueryWrapperPlotNavProps = {
5858
'digitalAssessmentDetails',
5959
],
6060
},
61+
initialPlotType: 'BAR',
6162
}
6263

6364
export const dataDetailPageProps: StandaloneQueryWrapperProps = {

packages/synapse-react-client/src/components/QueryWrapperPlotNav/QueryWrapperPlotNav.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ type QueryWrapperPlotNavContentsProps = Pick<
143143
| 'fileNameColumnName'
144144
| 'fileVersionColumnName'
145145
| 'initialLimit'
146+
| 'initialPlotType'
146147
> & {
147148
isFullTextSearchEnabled: boolean
148149
remount: () => void
@@ -168,6 +169,7 @@ function QueryWrapperPlotNavContents(props: QueryWrapperPlotNavContentsProps) {
168169
isFullTextSearchEnabled,
169170
customPlots,
170171
initialLimit,
172+
initialPlotType,
171173
} = props
172174
const queryContext = useQueryContext()
173175
const [showExportMetadata, setShowExportMetadata] = useState(false)
@@ -257,6 +259,7 @@ function QueryWrapperPlotNavContents(props: QueryWrapperPlotNavContentsProps) {
257259
<PlotsContainer
258260
facetsToPlot={facetsToPlot}
259261
customPlots={customPlots}
262+
initialPlotType={initialPlotType}
260263
/>
261264
<RowSetView
262265
tableConfiguration={tableConfiguration}

packages/synapse-react-client/src/components/widgets/facet-nav/PlotsContainer.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type ShowMoreState = 'MORE' | 'LESS' | 'NONE'
2121
export type PlotsContainerProps = {
2222
facetsToPlot?: string[]
2323
customPlots?: QueryWrapperSynapsePlotProps[]
24+
initialPlotType?: PlotType
2425
}
2526
type CustomPlotIdentifier = {
2627
title: string
@@ -89,6 +90,7 @@ const getCombinedNewPlots = (
8990
FacetNavPanelProps,
9091
'applyChangesToFacetFilter' | 'applyChangesToGraphSlice' | 'facetToPlot'
9192
>[] = [],
93+
initialPlotType: PlotType = DEFAULT_PLOT_TYPE,
9294
): UiPlotState[] => [
9395
...customPlots.map((plotProps, index) => ({
9496
plotId: getCustomPlotIdentifier(plotProps),
@@ -98,7 +100,7 @@ const getCombinedNewPlots = (
98100
...facetNavPanelPropsArray.map((facetPlotProps, index) => ({
99101
plotId: facetPlotProps.facetToPlot,
100102
isHidden: index + customPlots.length >= DEFAULT_VISIBLE_PLOTS,
101-
plotType: DEFAULT_PLOT_TYPE,
103+
plotType: initialPlotType,
102104
})),
103105
]
104106

@@ -133,6 +135,7 @@ function PlotsContainer(props: PlotsContainerProps) {
133135
const {
134136
facetsToPlot = DEFAULT_FACETS_TO_PLOT,
135137
customPlots = DEFAULT_CUSTOM_PLOTS,
138+
initialPlotType = DEFAULT_PLOT_TYPE,
136139
} = props
137140
const { queryMetadataQueryOptions } = useQueryContext()
138141
const { data: queryMetadata } = useSuspenseQuery(queryMetadataQueryOptions)
@@ -144,13 +147,14 @@ function PlotsContainer(props: PlotsContainerProps) {
144147
const plotType = plotUiStateArray.find(item =>
145148
plotMatchesDefinition(plotId, item.plotId),
146149
)?.plotType
147-
return plotType ?? 'PIE'
150+
return plotType ?? DEFAULT_PLOT_TYPE
148151
}
149152

150153
useEffect(() => {
151154
const combinedNewPlots = getCombinedNewPlots(
152155
customPlots,
153156
facetNavPanelPropsArray,
157+
initialPlotType,
154158
)
155159

156160
// Update the state with new plots

0 commit comments

Comments
 (0)