Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop-down list for customizing primary property for charts #183

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/src/main/resources/underlays/aou_synthetic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ uiConfiguration: >-
}],
"demographicChartConfigs": {
"groupByAttributes": ["gender_concept_id", "race_concept_id", "year_of_birth"],
"primaryPropertyOptions": [
["gender", "sex_at_birth"]
],
"chartConfigs": [{
"title": "Gender",
"primaryProperties": [
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/resources/underlays/sd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ uiConfiguration: >-
}],
"demographicChartConfigs": {
"groupByAttributes": ["gender_concept_id", "race_concept_id", "year_of_birth"],
"primaryPropertyOptions": [
["gender", "sex_at_birth"]
],
"chartConfigs": [{
"title": "Gender",
"primaryProperties": [
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/resources/underlays/synpuf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ uiConfiguration: >-
}],
"demographicChartConfigs": {
"groupByAttributes": ["gender_concept_id", "race_concept_id", "year_of_birth"],
"primaryPropertyOptions": [
["gender", "sex_at_birth"]
],
"chartConfigs": [{
"title": "Gender",
"primaryProperties": [
Expand Down
1 change: 1 addition & 0 deletions ui/src/criteria/concept.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async function renderCriteria(

const demographicChartConfigs = {
additionalSelectedAttributes: ["gender", "race"],
primaryPropertyOptions: [["gender", "sex at birth"]],
groupByAttributes: [
"gender_concept_id",
"race_concept_id",
Expand Down
34 changes: 33 additions & 1 deletion ui/src/overview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import MoreVertIcon from "@mui/icons-material/MoreVert";
import { FormControl, Select, SelectChangeEvent } from "@mui/material";
import Accordion from "@mui/material/Accordion";
import AccordionDetails from "@mui/material/AccordionDetails";
import AccordionSummary from "@mui/material/AccordionSummary";
Expand Down Expand Up @@ -30,7 +31,7 @@ import { useTextInputDialog } from "components/textInputDialog";
import { useSource } from "data/source";
import { useAsyncWithApi } from "errors";
import { useAppDispatch, useCohort, useUnderlay } from "hooks";
import { useCallback, useContext } from "react";
import { useCallback, useContext, useState } from "react";
import { Link as RouterLink, useHistory } from "react-router-dom";
import {
Bar,
Expand Down Expand Up @@ -476,6 +477,29 @@ function StackedBarChart({ chart, tickFormatter }: StackedBarChartProps) {
);
}

type PrimaryPropertyDropDownProps = {
propertyOptions: string[];
};

function PrimaryPropertyDropDown({
propertyOptions,
}: PrimaryPropertyDropDownProps) {
console.log(propertyOptions[0])
const [value, setValue] = useState<string>(propertyOptions[0]);
const handleChange = (event: SelectChangeEvent) => {
setValue(event.target.value as string);
};
return (
<FormControl>
<Select value={value} onChange={handleChange}>
{propertyOptions.map((option, index) => (
<MenuItem key={index} value={option}>{option}</MenuItem>
))}
</Select>
</FormControl>
);
}

type DemographicChartsProps = {
cohort: tanagra.Cohort;
};
Expand Down Expand Up @@ -668,6 +692,14 @@ function DemographicCharts({ cohort }: DemographicChartsProps) {
<Grid item xs={1}>
<Stack>
<Typography variant="h4">{`Total Count: ${demographicState.data?.totalCount.toLocaleString()}`}</Typography>
{underlay.uiConfiguration.demographicChartConfigs.primaryPropertyOptions.map(
(propertyOptions, index) => (
<PrimaryPropertyDropDown
key={index}
propertyOptions={propertyOptions}
/>
)
)}
{demographicState.data?.chartsData.map((chart, index) => {
return (
<StackedBarChart
Expand Down
1 change: 1 addition & 0 deletions ui/src/underlaysSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type UIConfiguration = {

export type DemographicChartConfig = {
additionalSelectedAttributes: string[];
primaryPropertyOptions: string[][]
groupByAttributes: string[];
chartConfigs: ChartProperties[];
};
Expand Down