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

Change over time chart #1973

Merged
merged 57 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c44dbd2
init changeovertime chart
lastminutediorama Dec 3, 2024
38499e7
add chart elements
lastminutediorama Dec 4, 2024
c7548af
lint
lastminutediorama Dec 4, 2024
885e31b
add expansion button
lastminutediorama Dec 4, 2024
94d13eb
vert align
lastminutediorama Dec 4, 2024
94478e2
more complete example data
lastminutediorama Dec 4, 2024
e6ee341
add fake data
lastminutediorama Dec 5, 2024
90f72fd
refresh data when dropdowns change
lastminutediorama Dec 5, 2024
f24792b
Merge branch 'main' into change-over-time-chart
lastminutediorama Dec 6, 2024
4276eb3
add expanded change chart component
lastminutediorama Dec 6, 2024
7330a74
fix test
lastminutediorama Dec 6, 2024
a17e4a7
additions to modal
lastminutediorama Dec 6, 2024
01dcd43
refactor use of state service
lastminutediorama Dec 9, 2024
47e87a9
lint
lastminutediorama Dec 9, 2024
d440867
Merge branch 'main' into change-over-time-chart
lastminutediorama Dec 17, 2024
479cff5
scaffold backend call for impacts chart data
lastminutediorama Dec 17, 2024
167746a
connect to backend
lastminutediorama Dec 18, 2024
8175abf
rm some todo comments
lastminutediorama Dec 18, 2024
ad70067
rm unused icon
lastminutediorama Dec 18, 2024
8c6c1e2
improve project selection
lastminutediorama Dec 18, 2024
728b53e
fix some tests
lastminutediorama Dec 19, 2024
3a8519e
fix tests
lastminutediorama Dec 19, 2024
555fdd8
fix tests
lastminutediorama Dec 19, 2024
2a06c8c
ensure selected item matches expanded view
lastminutediorama Dec 19, 2024
3fb30ea
unify selection model
lastminutediorama Dec 19, 2024
8294810
Merge branch 'main' into change-over-time-chart
lastminutediorama Dec 19, 2024
a3b39f3
map to new backend data fields
lastminutediorama Dec 19, 2024
f9490b7
make selections async
lastminutediorama Dec 19, 2024
6598242
recenter map on project area selection
lastminutediorama Dec 20, 2024
b64eb4e
Merge branch 'main' into change-over-time-chart
lastminutediorama Dec 20, 2024
d8ea8e0
Merge branch 'main' into change-over-time-chart
lastminutediorama Dec 20, 2024
265b7bd
refactor to use responsive reportMetrics
lastminutediorama Dec 20, 2024
0cde2e4
use color-slot obj instead of array
lastminutediorama Dec 20, 2024
396e04c
fix tests
lastminutediorama Dec 20, 2024
c9b949d
revert modal width for now
lastminutediorama Dec 20, 2024
cac3e09
clean conversions
lastminutediorama Dec 20, 2024
3983e55
Merge branch 'main' into change-over-time-chart
lastminutediorama Dec 23, 2024
f018958
add distinctUntilChanged for selected slots
lastminutediorama Jan 2, 2025
1d21b63
fix distinct check
lastminutediorama Jan 2, 2025
a052693
add deepEqual instead
lastminutediorama Jan 2, 2025
bedbfc3
use 'All' instead of null for All Project selection
lastminutediorama Jan 2, 2025
c41b67d
Merge branch 'main' into change-over-time-chart
lastminutediorama Jan 3, 2025
ae44915
migrate to sg-expanded-panel
lastminutediorama Jan 3, 2025
6c0cc3c
ws lint
lastminutediorama Jan 3, 2025
089484e
Merge branch 'main' into change-over-time-chart
lastminutediorama Jan 3, 2025
da2972b
revert changes to modal component
lastminutediorama Jan 3, 2025
38f3772
rm old state code
lastminutediorama Jan 6, 2025
30b7dfd
move to template vars
lastminutediorama Jan 6, 2025
b69ba89
simplify chartData calculation
lastminutediorama Jan 6, 2025
8227599
Merge branch 'main' into change-over-time-chart
lastminutediorama Jan 6, 2025
4a07722
move filter
lastminutediorama Jan 7, 2025
8effd84
linter ws
lastminutediorama Jan 7, 2025
7ea8bc1
fix test
lastminutediorama Jan 7, 2025
36e7eac
local linter needed a fix
lastminutediorama Jan 7, 2025
5e9a002
Merge branch 'main' into change-over-time-chart
lastminutediorama Jan 7, 2025
c341455
rm injectable
lastminutediorama Jan 7, 2025
b7d7ca8
Merge branch 'main' into change-over-time-chart
lastminutediorama Jan 7, 2025
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
8 changes: 5 additions & 3 deletions src/interface/package-lock.json

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

1 change: 1 addition & 0 deletions src/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"chartjs-plugin-datalabels": "^2.2.0",
"esri-leaflet": "^3.0.12",
"esri-leaflet-vector": "^4.2.4",
"fast-deep-equal": "^3.1.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, are we using this dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's for the deepEqual in the distinctUntilChanged piece. We also don't have anything similar anywhere else, so I thought we could use this, and later maybe replace some JSON.stringify() comparisons we've got.

"file-saver": "^2.0.5",
"jspdf": "^2.5.2",
"jspdf-autotable": "^3.8.4",
Expand Down
20 changes: 19 additions & 1 deletion src/interface/src/app/services/treatments.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpParams } from '@angular/common/http';
import { environment } from '../../environments/environment';
import { TreatmentPlan, TreatmentSummary } from '@types';

Expand Down Expand Up @@ -106,4 +106,22 @@ export class TreatmentsService {
}
);
}

getTreatmentImpactCharts(
treatmentPlanId: number,
metrics: string[],
projectAreaId: number | null
) {
let variableParams = new HttpParams();
metrics.forEach((m) => {
variableParams = variableParams.append('variables', m);
});
if (projectAreaId) {
variableParams = variableParams.append('project_areas', projectAreaId);
}
return this.http.get(this.baseUrl + treatmentPlanId + '/plot/', {
withCredentials: true,
params: variableParams,
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="chart-heading">Average Change Over Time</div>
<div class="title">Change (%)</div>
<div class="chart">
<canvas
baseChart
[data]="(barChartData$ | async) || undefined"
lastminutediorama marked this conversation as resolved.
Show resolved Hide resolved
[options]="(barChartOptions$ | async) ?? {}"
[legend]="false"
[type]="'bar'"></canvas>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@import 'colors';
@import 'mixins';

:host {
display: flex;
flex-direction: column;
height: 100%;
}

.chart-heading {
@include h5();
width: 100%;
display: flex;
justify-content: center;
height: 60px;
align-items: flex-end;
}

.chart {
height: calc(100% - 140px);
padding-bottom: 20px;
}

canvas {
flex: 1;
max-height: 100%;
}

.title {
padding: 24px 24px 0;
color: $color-text-gray;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DirectImpactsStateService } from '../direct-impacts.state.service';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MockProvider } from 'ng-mocks';
import { ChangeOverTimeChartComponent } from './change-over-time-chart.component';
import { BehaviorSubject } from 'rxjs';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TreatmentsState } from '../treatments.state';
import { TreatedStandsState } from '../treatment-map/treated-stands.state';

describe('ChangeOverTimeChartComponent', () => {
let component: ChangeOverTimeChartComponent;
let fixture: ComponentFixture<ChangeOverTimeChartComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ChangeOverTimeChartComponent, HttpClientTestingModule],
providers: [
TreatedStandsState,
MockProvider(TreatmentsState),
MockProvider(DirectImpactsStateService, {
activeStand$: new BehaviorSubject(null),
}),
],
}).compileComponents();

fixture = TestBed.createComponent(ChangeOverTimeChartComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading
Loading