Skip to content

Commit

Permalink
Merge pull request #330 from code4romania/bulk-318/#7-line-graph
Browse files Browse the repository at this point in the history
fix [#318-#7]: fix dashboard graph not showing entire Y Axis
  • Loading branch information
luciatugui authored Jul 26, 2024
2 parents 926def9 + 4acc9e1 commit a3c8336
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
15 changes: 10 additions & 5 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"react-select": "^5.8.0",
"react-select-async-paginate": "0.7.4",
"react-toastify": "^10.0.5",
"recharts": "^2.12.7",
"recharts": "^2.13.0-alpha.4",
"use-query-params": "^2.2.1",
"yup": "^1.4.0"
},
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/components/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import {
} from 'recharts';
import { LINE_CHART_OPTIONS } from '../common/constants/line-chart-options';

export interface InitialDataSet {
name: string;
active: string;
archived: string;
}

export interface DataSet {
name: string;
active: number;
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/services/volunteer/volunteer.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AgeRangeEnum } from '../../common/enums/age-range.enum';
import { AxiosResponseHeaders } from 'axios';
import { formatEndDateISO9075, formatStartDateISO9075 } from '../../common/utils/utils';
import { IVolunteerStatistics } from '../../common/interfaces/volunteer-statistics.interface';
import { DataSet } from '../../components/LineChart';
import { DataSet, InitialDataSet } from '../../components/LineChart';
import { PieChartOption } from '../../common/constants/pie-chart-options';
import { LineChartOption } from '../../common/constants/line-chart-options';

Expand Down Expand Up @@ -127,8 +127,12 @@ export const getVolunteerStatistics = async (): Promise<IVolunteerStatistics> =>
};

export const getVolunteerLineChart = async (interval: LineChartOption): Promise<DataSet[]> => {
return API.get('/dashboard/volunteer-status-timeseries', { params: { interval } }).then(
(res) => res.data,
return API.get('/dashboard/volunteer-status-timeseries', { params: { interval } }).then((res) =>
res.data.map((item: InitialDataSet) => ({
...item,
active: Number(item.active),
archived: Number(item.archived),
})),
);
};

Expand Down

0 comments on commit a3c8336

Please sign in to comment.