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

feat: add hover and clusters to peers map #1444

Merged
merged 14 commits into from
Apr 28, 2020

Conversation

rafaelramalho19
Copy link
Contributor

Notes

  • I wasn't sure what information to place in the popover, so I just used the country and id for now. If you find any more relevant information I should place, please say so 🙏

  • I couldn't find a way to properly make a reducer work with createAsyncResourceBundle, the documentation seemed a bit lacking and I had some really hard time trying to figure out what happened. After reading through the source code I found out that createAsyncResourceBundle actually creates a reducer function to handle all the async mechanism mutations, so I extended it. You can see this in src/bundles/peers.js#13
    If someone could help me find a better way, I would be very much appreciated 😄

  • Added some transitions to smoothen the interaction with several popovers, as you can see here:

ezgif com-video-to-gif

Questions

  1. I believe that most of the times the peers will be too close to each other (at least on the map scale) and hovering through them can be weird/glitchy. Should we change the map scale or add buttons to zoom?

  2. Should we scroll the list to the hoverable peer when it's out of view?

  3. Should we show the popover when we also hover an element from the list?

PS: Sorry for the long merge request description 😅

@jessicaschilling
Copy link
Contributor

jessicaschilling commented Apr 18, 2020

This is awesome! My thoughts on your questions but @hacdias and @lidel should weigh in too 😊

  1. Zoom buttons would be really cool
  2. So would scrolling
  3. If we have zoom buttons, and we scroll through the list to a region that's out of view on the map, the popover might not be in view. That might be OK, but soliciting others' opinions? (Flying through the map feels too unwieldy?)

@hacdias
Copy link
Member

hacdias commented Apr 18, 2020

I love this and I agree with @jessicaschilling about scrolling.

@lidel
Copy link
Member

lidel commented Apr 20, 2020

@rafaelramalho19 I really like the idea of map popover!

May be a bit more useful if popover for a standalone peer includes its full multiaddr (ok to keep the shortened PeerID).. and maybe latency too?

In other words, instead of "12D3..y8PK"
something like: "/ip4/13.40.98/tcp/4001/p2p/12D3..y8PK (130ms)"

FYSA multiaddr prefix is already displayed on hover at connection column, if you want to reuse the data source.


Answering questions:

(1) Should we change the map scale or add buttons to zoom?

Adding zoom would not fully solve the problem, because no matter how much you zoom, you will always end up with situation when there is more than one person from a big city, and they all are assigned the same coordinate on the map (geoip resolution we use is limited to the "city" level).

I don't think we should add zoom in this PR (it could be something for the future / separate PR). Instead, we should make the map smarter if there is more than one peer in specific area (eg. within the size of the dot itself).

Loose idea: merge those dots into a single (bigger?) one and show a popover with a peer count for the area. Could still have a list of merged peers below the count.

This would make it easy to hover mouse on parts of the USA, see how many of my peers are from NYC, Tokio. Right now it gets messy when there are many peers (some people tweak settings and run webui with 5000 peers or more!), no way to tell how much bigger US is than EU, especially when viewport is small (could be 10x more peers, but both look the same):

100

As for (2) and (3):
Should we scroll the list to the hoverable peer when it's out of view?
Should we show the popover when we also hover an element from the list?

I think those are great improvements for UX, but should be implemented together: if one works, user will expect it working the other way around.

(I suspect it may be easier to implement without zoom controls, as there is no need to account for edge cases when zoomed in and hovering something outside of map viewport)

ps. long PR descriptions with visuals like the one you made here are great, they ensure everyone is on the same page, keep doing it! ❤️

@rafaelramalho19
Copy link
Contributor Author

Good suggestion @lidel, I will merge the dots into a bigger one and share the result here.

I'm actually having problems with paning and zooming with d3 + our react setup, so your suggestion actually helps me a lot 😄

@jessicaschilling
Copy link
Contributor

+1 to everything @lidel said. Thanks both for thinking through this in such detail 😊

@jessicaschilling
Copy link
Contributor

Following up on the bi-weekly call to add a reference to the NY Times coronavirus map illustrating relative size of dots with numbers attached to them. This is overkill for our case, but could be useful inspiration: https://www.nytimes.com/interactive/2020/us/coronavirus-us-cases.html

@rafaelramalho19 rafaelramalho19 requested a review from lidel April 21, 2020 17:31
@rafaelramalho19
Copy link
Contributor Author

New update:

  • Grouped the peers in a range of 8 dots together, so they look like this now:
    image

  • Added labels to indicate how many peers there are per dot type.
    image

  • The hovering effect now contains a +X label indicating that there are more than 5 peers in a circle
    image

  • The hover effect updates all peers in a circle:
    Screen-Recording-2020-04-21-at-18 35 42

@jessicaschilling @hacdias @lidel what you think of this approach?

@jessicaschilling
Copy link
Contributor

This is so cool 😊

A few cosmetic suggestions, assuming @lidel @hacdias are OK with this approach:

  • Could the key please go underneath the map as a whole? Otherwise it looks like we have a bunch of peers in Antarctica. We should probably precede the row with the word "Key:", too.
  • In the hover, the latency is a little higher up than the peerID. Also, can the latency figure please be in gray, to differentiate it from the rest of the peerID?
  • In the hover, if the "+X" label is to indicate the total number of peers "contained in a circle", we should be more explicit that's the total. Assuming that the top 5 we are seeing in the hover are the top 5 in the list as sorted by the user's sort choice (latency in your video), one suggestion might be:
    • In the area where you currently have "+X", instead a header in the same teal uppercase as the table sort headers: "Top X by {sort choice}"
    • At the bottom of the list of 5, justified right, if there are more than 5: "Plus XXX more peers"

Thanks!


const unique = new Set(allCoord.map(JSON.stringify))
return Array.from(unique).map(JSON.parse)
return peers.reduce((previous, { peerId, coordinates }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self: Missing tests once UI and UX is reviewed

@rafaelramalho19
Copy link
Contributor Author

This is so cool 😊

A few cosmetic suggestions, assuming @lidel @hacdias are OK with this approach:

  • Could the key please go underneath the map as a whole? Otherwise it looks like we have a bunch of peers in Antarctica. We should probably precede the row with the word "Key:", too.

  • In the hover, the latency is a little higher up than the peerID. Also, can the latency figure please be in gray, to differentiate it from the rest of the peerID?

  • In the hover, if the "+X" label is to indicate the total number of peers "contained in a circle", we should be more explicit that's the total. Assuming that the top 5 we are seeing in the hover are the top 5 in the list as sorted by the user's sort choice (latency in your video), one suggestion might be:

    • In the area where you currently have "+X", instead a header in the same teal uppercase as the table sort headers: "Top X by {sort choice}"
    • At the bottom of the list of 5, justified right, if there are more than 5: "Plus XXX more peers"

Thanks!

Thanks for the suggestions Jessica,

Relative to the last point, I didn't sort the elements in the hover with the same logic as in the table because that added an extra layer of overhead and complexion.
However, If it's something you really see improving the experience, I can do it 😄 .

Now, about the other points you referred, could you please revise them?

  • Key under the map:

image

  • Latency grayed & Plus XXX more peers:
    image

@jessicaschilling
Copy link
Contributor

This is great! I'd like to get @lidel's blessing but I think this is enough to send out into the world. Ideally we should sort the contents of the hover boxes, but I'll let @lidel weigh in on whether that's worth the effort at this stage.

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

I really, really like it @rafaelramalho19! 👌 😍

Took it for a spin and found some small bugs. Also, wrote some thoughts how we can optimize clustering logic for regular users who will have under 300 peers (see below).


UI bugs / nits

  1. Contents of the hover box will look better if we sort them by multiaddr
    (those are just strings, just sort them in lexicographical order, that is all)

  2. For some reason I get horizontal scrollbar in Firefox, may be related to the other issue (3):

    horizont-2020-04-23--14-13-26

  3. I believe we have a regression in responsiveness – when I resize window the map does not scale, it starts overlaping the menu:

    resize-bug-Screenshot_2020-04-23 Peers - IPFS

@rafaelramalho19
Copy link
Contributor Author

I really, really like it @rafaelramalho19! 👌 😍

Took it for a spin and found some small bugs. Also, wrote some thoughts how we can optimize clustering logic for regular users who will have under 300 peers (see below).

  1. For some reason I get horizontal scrollbar in Firefox, may be related to the other issue (3):

    horizont-2020-04-23--14-13-26

  2. I believe we have a regression in responsiveness – when I resize window the map does not scale, it starts overlaping the menu:

    resize-bug-Screenshot_2020-04-23 Peers - IPFS

Those were some issues I found at the start of the development, so I was thinking about opening a new merge request after this one to fix them. But since you already referred it, I'll put it in this MR 😄

@rafaelramalho19
Copy link
Contributor Author

Thanks for the suggestions @lidel, here's how it looks so far:
Screen Recording 2020-04-23 at 18 35 34 (1)

  • Also added a transition when new peers appear to smoothen the experience 🚀

I would love to work again on this later and improve responsiveness (mobile needs a lot of love in the map)

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thanks! Made another pass:

  • Some peers have no latency info, in those cases we should either hide (ms) or show (???ms):
    no-latency-china-2020-04-23--22-54-22

    • There should be some whitespace between the flag and the address, ideally the same amount as in the beer list below the map.
    • Would it be possible to reuse multiaddr formatter from the Status screen? It has grayed out protocol sections making it super easy to look at:

      2020-04-24--03-58-13

  • For some time I had this weird bug where menu randomly stopped working. Finally figured it out – svg is getting over the menu, hijacking clicks in Firefox. Perhaps tweaking z-index will be enough to fix this?

    overlay-on-menu-2020-04-24--02-56-44

  • Smaller suggestions below

Comment on lines 104 to 109
<div className='relative flex justify-end pt2 pb4'>
<div className='f6 p2 no-select flex items-center'>
<span className='f6 charcoal-muted pr3'>{t('index')}: </span>
<i className='mapDotExplanation mr1' style={{ width: getDotsSize(1) * 2, height: getDotsSize(1) * 2, backgroundColor: getDotsColor(1) }}></i>1-10 {t('peers')}
<i className='mapDotExplanation ml3 mr1' style={{ width: getDotsSize(50) * 2, height: getDotsSize(50) * 2, backgroundColor: getDotsColor(50) }}></i> 10-100 {t('peers')}
<i className='mapDotExplanation ml3 mr1' style={{ width: getDotsSize(110) * 2, height: getDotsSize(110) * 2, backgroundColor: getDotsColor(110) }}></i>100+ {t('peers')}
Copy link
Member

@lidel lidel Apr 24, 2020

Choose a reason for hiding this comment

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

2020-04-24--03-04-25

i18n nit: having "Peers" multiple times may look bad in languages where the world is really long.

I believe it will be safer to simplify this to something like:

2020-04-24--03-05-21

This will also enable us to add one more level, if we want.
(eg. 1-10, 10-50, 50-100, 100+)

@rafaelramalho19
Copy link
Contributor Author

Thanks! Made another pass:

  • Some peers have no latency info, in those cases we should either hide (ms) or show (???ms):
    no-latency-china-2020-04-23--22-54-22

    • There should be some whitespace between the flag and the address, ideally the same amount as in the beer list below the map.
    • Would it be possible to reuse multiaddr formatter from the Status screen? It has grayed out protocol sections making it super easy to look at:

      2020-04-24--03-58-13

  • For some time I had this weird bug where menu randomly stopped working. Finally figured it out – svg is getting over the menu, hijacking clicks in Firefox. Perhaps tweaking z-index will be enough to fix this?

    overlay-on-menu-2020-04-24--02-56-44

  • Smaller suggestions below

Thanks for the review @lidel!

The flag actually has empty space in MacOS, so that's why I never saw that happen 😢
I've added padding to the flag so it doesn't happen, here are examples:

MacOS flag:
image

Windows flag:
image

I was able to fix the scrollbar issue, but I needed to get a bit creative and actually get the popover to align down instead of up. If you see this as a UX problem (CC @jessicaschilling), I'll try a more overhead solution (passing the popover as a portal element, and setting the top and left according to the body/html position, while calculating the size of the svg and subtracting offsets)

Nice suggestion on the Status component, didn't see it 👍

@rafaelramalho19 rafaelramalho19 requested a review from lidel April 24, 2020 11:53
@jessicaschilling
Copy link
Contributor

I don't think the popover facing down is a big problem. If there are a ton of peers in Patagonia, it might overlap with the top of the main peer table, but that feels like a bit of an edge case for this release.

Copy link
Member

@hacdias hacdias left a comment

Choose a reason for hiding this comment

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

On the UX/UI side, I love it and I approve it. I didn't check the whole code though. But, the parts I checked, looked good for me.

@lidel lidel mentioned this pull request Apr 27, 2020
22 tasks
@lidel
Copy link
Member

lidel commented Apr 27, 2020

@rafaelramalho19 mind resolving the conflict? (rebase is also fine)

@lidel lidel requested review from alanshaw and hugomrdias April 27, 2020 14:57
@lidel
Copy link
Member

lidel commented Apr 27, 2020

@hugomrdias @alanshaw does any of you have bandwidth to take a look at React-specific parts and give @rafaelramalho19 some feedback?

@rafaelramalho19
Copy link
Contributor Author

@lidel Everything's ready for merge now, just waiting on your final approval 🎉

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Fantastic contribution @rafaelramalho19, let's ship it!

tenor

@lidel lidel changed the title Feat/add hover to peers map feat: add hover and clusters to peers map Apr 28, 2020
@lidel lidel merged commit 8111aa4 into ipfs:master Apr 28, 2020
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.

5 participants