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 option to provide custom labels to tooltip and use legend labels for the tooltip value; COUNTRY=rbd #1286

Conversation

gislawill
Copy link
Collaborator

Description

This address Feature Request #1280 with 3 updates:

  1. Allowing <PopupContent /> (the body of the tooltip) to print one simple string rather than always {label}: {data}
    1. If the data provided is falsy (null, false, ""), we now just show {label}
    2. Current type definitions only allow null as a valid input for this use case
  2. Allowing an optional data_label field in the layer definition that proceeds the layer's data value on the tooltip
  3. Allowing an optional display_source field in the layer definition that uses the matching legend's label view on the tooltip

How to test the feature:

  • When running rbd instance, enable the Conflict Analysis > ACLED Conflict Index > ACLED Conflict Index for the Sahel layer
  • Click on an admin region to open the tooltip

Test your changes with

  • REACT_APP_COUNTRY=rbd yarn start
  • REACT_APP_COUNTRY=cambodia yarn start
  • REACT_APP_COUNTRY=mozambique yarn start
  • Add / update necessary tests?
  • Add / update outdated documentation?

Screenshot/video of feature:

Screenshot 2024-06-26 at 2 23 11 PM

@gislawill
Copy link
Collaborator Author

gislawill commented Jun 26, 2024

Fixing this bug that occurs when multiple layers are selected
Screenshot 2024-06-26 at 4 18 30 PM

…o-display-labels-instead-of-values-in-the-tooltip
Copy link

github-actions bot commented Jun 26, 2024

Build succeeded and deployed at https://prism-1286.surge.sh
(hash 63e43de deployed at 2024-06-27T16:49:35)

@gislawill gislawill changed the title Adding option to provide custom labels to tooltip and use legend labels for the tooltip value Feature Request # 1280: Adding option to provide custom labels to tooltip and use legend labels for the tooltip value Jun 26, 2024
@gislawill gislawill marked this pull request as ready for review June 26, 2024 23:46
@gislawill
Copy link
Collaborator Author

Fixing this bug that occurs when multiple layers are selected Screenshot 2024-06-26 at 4 18 30 PM

This has been fixed

@@ -129,5 +129,6 @@
"Phase classification": "Classification de la phase",
"Population in phase 3 to 5": "Population en phase 3 à 5",
"Days since last rain": "Les jours depuis la dernière pluie",
"Admin Level": "Niveau Administratif"
"Admin Level": "Niveau Administratif",
"Classification": "Classification"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I acknowledge this is incredibly unnecessary, it's just coverage for coverage's sake — but it demonstrates that there's coverage to everyone who doesn't already know that "Classification" = "Classification"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup I think it's the right approach

@ericboucher
Copy link
Collaborator

ericboucher commented Jun 27, 2024

@gislawill quick ask, in general I prefer to keep the titles shorter and explicit (ready to be merged). The link to issue is handled separately already:
Screenshot 2024-06-27 at 10 00 39 AM

I went ahead and updated the title for this PR

@ericboucher ericboucher changed the title Feature Request # 1280: Adding option to provide custom labels to tooltip and use legend labels for the tooltip value Add option to provide custom labels to tooltip and use legend labels for the tooltip value Jun 27, 2024
@ericboucher ericboucher changed the title Add option to provide custom labels to tooltip and use legend labels for the tooltip value Add option to provide custom labels to tooltip and use legend labels for the tooltip value; COUNTRY=rbd Jun 27, 2024
…o-display-labels-instead-of-values-in-the-tooltip
@@ -168,6 +168,10 @@ const PopupContent = ({
return true;
})
.map(([key, value]) => {
// If the data is undefined, null, or an empty string, we don't want to show the key/value pair
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you explicit the use-case for this? Note that we already have the reverse case where we hide the key using the do_not_display prefix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This allows us to pass a single string to PopupContent to display rather then always displaying a label: data. That's necessary to render the layer name on it's own line without following with : {data}. I'll update the comment to make that clearer — "we don't want to show the key/value pair" doesn't mean much 😅
Screenshot 2024-06-27 at 9 36 32 AM

Comment on lines +165 to +167
...(!useCustomLabel ? possibleAdminLevelData : {}),
...featureInfoPropsData,
...(useCustomLabel ? possibleAdminLevelData : {}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is that change expected for CH where the adminLevel ends up at the bottom?

Before:
Screenshot 2024-06-27 at 3 01 56 PM

After:
Screenshot 2024-06-27 at 3 02 01 PM

Copy link
Collaborator Author

@gislawill gislawill Jun 27, 2024

Choose a reason for hiding this comment

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

Good catch, I wouldn't consider this expected. I'm not certain that I know where we'd prefer "Admin Level" to go in the tooltip order.

@wadhwamatic, for tooltips showing the "IFPRI / ACLED Conflict Analysis - 2023" layer, do you have a preference for where the Admin Level is displayed?

Mali, Tombouctou, Tombouctou
IFPRI / ACLED Conflict Analysis - 2023
Admin Level: 2 (this is where it was rendered prior to this change)
Classification: High
Deadliness score: 84
Deadliness rank: 47
Danger score: 34
Danger rank: 16
Diffusion score: 2
Diffusion rank: 65
Fragmentation score: 4
Fragmentation rank: 6
Admin Level: 2 (this is where it's currently rendered with this change)

Copy link
Member

Choose a reason for hiding this comment

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

@gislawill - we can keep admin level at the bottom. In the issue I'll write up today, we should also address the need for this. It's not always necessary to display it.

@ericboucher
Copy link
Collaborator

ericboucher commented Jun 27, 2024

The code changes look good overall. I am a bit worried however that the tooltip logic is getting a bit complicated and might get hard to maintain / use properly (from a product standpoint) cc @wadhwamatic

@wadhwamatic
Copy link
Member

wadhwamatic commented Jun 27, 2024

The code changes look good overall. I am a bit worried however that the tooltip logic is getting a bit complicated and might get hard to maintain / use properly (from a product standpoint) cc @wadhwamatic

@ericboucher - yes, agreed. We've got a lot of configuration options happening. As I worked with it, it's pretty straightforward to use, but for someone new to it, there's a learning curve. Documentation is needed (I can contribute to that from the user perspective), but I also think renaming / simplifying things is key. @gislawill and I touched on this yesterday. We'll create a separate issue for it

wadhwamatic and others added 2 commits June 27, 2024 09:14
@wadhwamatic wadhwamatic requested a review from ericboucher June 28, 2024 16:00
@wadhwamatic
Copy link
Member

@ericboucher and @gislawill - here's a new issue to start getting ideas together on the next iteration of the tooltip: #1292

@wadhwamatic wadhwamatic merged commit 358b75b into master Jun 28, 2024
6 checks passed
@wadhwamatic wadhwamatic deleted the 1280-feature-request-use-a-config-option-to-display-labels-instead-of-values-in-the-tooltip branch June 28, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Use a config option to display labels instead of values in the tooltip
3 participants