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

Make node radius respect the package size #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

styfle
Copy link

@styfle styfle commented Jul 21, 2018

Fixes #25

Size disabled (default)

toggle-size-off

Size enabled

toggle-size-on


function toggleSize() {
$scope.showSize = !$scope.showSize;
refreshGraph();
Copy link
Author

Choose a reason for hiding this comment

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

@anvaka I have no idea how to use Angular and it seems like there is some wrapper (an) around Angular that makes this even more mysterious.

How can I make this toggleSize() function refresh/re-render the graph?

Copy link
Owner

Choose a reason for hiding this comment

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

I don't remember most of it as well :). I think you could use approach similar to node highlighting. Check the graphViewer.js and graphUI.js files.

Copy link
Author

@styfle styfle Jul 24, 2018

Choose a reason for hiding this comment

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

Now that I think about it, I think I want to make this part of the url, because I would like to link directly to this page from https://packagephobia.com

Actually, I already have a link but I would like the link to enable this feature which is why I need it in the URL.

Thoughts?

@@ -12,7 +12,8 @@ function graphViewer() {
'source': '=',
'nodeSelected': '=',
'root': '=',
'mode': '='
'mode': '=',
'showSize': '='
Copy link
Author

Choose a reason for hiding this comment

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

I thought that showSize was going to show up from the parent $scope but this didn't work. Any ideas?


function getNodeRadius(node) {
var radius = defaultRadius;
if (showSize && node.data && node.data.dist && node.data.dist.unpackedSize) {
Copy link
Owner

Choose a reason for hiding this comment

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

Just curious - where does unpackedSize come from? I tried to explore a random package from the registry.npmjs.cf and I don't see it there

Copy link
Author

@styfle styfle Jul 24, 2018

Choose a reason for hiding this comment

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

@anvaka I think this was introduced in the last 4 months or so, so only packages published since then will have this information populated. I asked the npm team if there are plans to backfill.

I originally planned to make a HTTP request to my tool, Package Phobia, which will work for any arbitrary package, but I realized that I would need to submit a PR to the other repo (which would take more time and I'm lazy 😄)

I fallback to the 5px radius if the size was not found (this was the previous size used) .

@jaydenseric
Copy link

Well done @styfle, this would change my life.

styfle added a commit to styfle/packagephobia that referenced this pull request Apr 15, 2024
This project is actively maintained so more likely to get a size feature
to land.

### Related
- anvaka/npmgraph.an#27
- npmgraph/npmgraph#132
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: The size of the node should respect the size of the package
3 participants