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

Add top species chart to overview page #580

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion ami/main/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def event_top_taxa(event_pk: int, top_n: int = 10):
)

if top_taxa:
taxa, counts = list(zip(*[(t["name"], t["num_detections"]) for t in top_taxa]))
taxa, counts = list(zip(*[(t["name"], t["num_detections"]) for t in reversed(top_taxa)]))
taxa = [t or "Unknown" for t in taxa]
counts = [c or 0 for c in counts]
else:
Expand Down
2 changes: 2 additions & 0 deletions ami/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def summary_data(self):
if self.occurrences.exists():
plots.append(charts.detections_per_hour(project_pk=self.pk))
plots.append(charts.occurrences_accumulated(project_pk=self.pk))
# print(self.pk)
plots.append(charts.event_top_taxa(event_pk=self.pk))
else:
plots.append(charts.events_per_month(project_pk=self.pk))
# plots.append(charts.captures_per_month(project_pk=self.pk))
Expand Down
1 change: 1 addition & 0 deletions ui/src/data-services/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface SummaryData {
ticktext?: string[]
}
type: any
orientation: 'h' | 'v'
}

export class Project {
Expand Down
7 changes: 6 additions & 1 deletion ui/src/pages/overview/summary/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ export const Summary = ({ project }: { project: Project }) => (
<PlotGrid>
{project.summaryData.map((summary, index) => (
<Box key={index}>
<Plot title={summary.title} data={summary.data} type={summary.type} />
<Plot
title={summary.title}
data={summary.data}
orientation={summary.orientation}
type={summary.type}
/>
</Box>
))}
</PlotGrid>
Expand Down