-
Notifications
You must be signed in to change notification settings - Fork 3
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
Improve chart visualization #873
base: dev
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
@@ -161,6 +163,17 @@ export class GetRankedImpactTableDto extends BaseImpactTableDto { | |||
@IsUUID(4) | |||
scenarioId?: string; | |||
|
|||
@ApiPropertyOptional({ | |||
description: | |||
'Optional property for groupBy region and chart view to choose level of admin regions to show', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the msg is not correct as the grouping depends on the selected entity, so its not tied to 'admin-regions'
I would say something like:
"Select the depth of the tree for grouping elements, defaults to...."
@Type(() => Number) | ||
@IsNumber() | ||
@Min(1) | ||
@Max(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the minimum should be 0, as discussed. If a user wants to select 6 countries and see a 4 ranked still at country level, that depth should equal 0
Also, I wouldn't set a fixed max limit. Even tho the current limit makes sense, I think its a better idea to not set a max limit and just uncollapse the tree as much as it can be uncollapsed.
i.e, users sends a 5 value but we have a maximum depth of 3, just send back a 3 level deep tree
@IsNumber() | ||
@Min(1) | ||
@Max(3) | ||
level?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be more consistent with other endpoints, I would name this parameter as
depth
// If chart is requested for regions and specific level is received, we get only the requested level from admin regions trees of the response | ||
|
||
if ( | ||
rankedImpactTableDto.groupBy === 'region' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following https://github.com/Vizzuality/landgriffon/pull/873/files#r1109319576, I still dont get why this is somehow tied to regions.
Does not make sense to apply this behaviour to any other entity that is a tree structure?
impactTableRows: ImpactTableRows[], | ||
level: number, | ||
): ImpactTableRows[] { | ||
if (level === 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 0, in order to uncollapse the whole thing
if (level === 1) { | ||
return impactTableRows; | ||
} | ||
if (level < 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not necessary, because:
- first level should be 0, which is a valid value
- there should be a default behaviour to default to
return impactTableRows; | ||
}, | ||
[], | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice :)
However, maybe we should try to use immutability, thoughts?
const sourcingLocations: SourcingLocation[] = []; | ||
|
||
for (const municipality of municipalities) { | ||
const i: number = municipalities.indexOf(municipality); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a super lightweight improvement, but If you realise, for each element on municipalities, you are running through municipalities again to find the index.
You could either get the index in the for of loop, or use a native array method that can provide you the index as one of the parameters in its callback
response.body.impactTable[0].others.aggregatedValues[0].value, | ||
).toBe(2000); | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, very clean, creating preconditions just once etc...
|
||
dataSource = testApplication.get<DataSource>(DataSource); | ||
|
||
({ jwtToken } = await setupTestUser(testApplication)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool, I had no idea you could assign a value like this
81763b1
to
f876633
Compare
e072d47
to
0740fd3
Compare
debfccb
to
6d94cb7
Compare
efb5a2f
to
d526d80
Compare
de3dfa6
to
a40b9e8
Compare
2fff34a
to
8a3eb61
Compare
Update. Chart visualization implemented in 2 ways:
In order to use optional parameter FE changes are needed (add parameter to request)
Tests added.
General description
Please write a description. If the PR is hard to understand, provide a quick explanation of the code.
Designs
Link to the related design prototypes (if applicable)
Testing instructions
Provide minimal instructions on how to test this PR.
Checklist before merging