Skip to content

Commit

Permalink
feat: Integrate API into swipes by organization pie chart
Browse files Browse the repository at this point in the history
  • Loading branch information
bshankar committed Sep 20, 2024
1 parent 668b58c commit 90a45bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Chart from 'chart.js/auto';
import { CHART_COLOURS } from '../../config';
import messages from './messages';

export const SwipesByOrganisation = () => {
export const SwipesByOrganisation = ( { contributionsByOrganization = [] } ) => {
const chartRef = useRef(null);
const chartInstance = useRef(null);

Expand All @@ -21,16 +21,10 @@ export const SwipesByOrganisation = () => {
chartInstance.current = new Chart(context, {
type: 'doughnut',
data: {
labels: [
'American Red Cross',
'Arizona State University',
'HOT',
'Médecins Sans Frontières',
'Others',
],
labels: contributionsByOrganization.map(c => c.organizationName),
datasets: [
{
data: [35, 25, 20, 15, 5],
data: contributionsByOrganization.map(c => c.totalcontributions),
backgroundColor: [
CHART_COLOURS.red, // Orange for American Red Cross
CHART_COLOURS.orange, // Yellow for Arizona State University
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/partnersMapswipeStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const PartnersMapswipeStats = () => {

<div className="mt3 flex items-center justify-between">
<SwipesByProjectType areaSwipedByProjectType={data?.areaSwipedByProjectType} />
<SwipesByOrganisation />
<SwipesByOrganisation contributionsByOrganization={data?.contributionsByorganizationName} />
</div>

<div className="mt3">
Expand Down

0 comments on commit 90a45bc

Please sign in to comment.