-
Notifications
You must be signed in to change notification settings - Fork 81
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
base: master
Are you sure you want to change the base?
Conversation
|
||
function toggleSize() { | ||
$scope.showSize = !$scope.showSize; | ||
refreshGraph(); |
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.
@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?
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 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.
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.
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': '=' |
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 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) { |
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.
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
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.
@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) .
Well done @styfle, this would change my life. |
This project is actively maintained so more likely to get a size feature to land. ### Related - anvaka/npmgraph.an#27 - npmgraph/npmgraph#132
Fixes #25
Size disabled (default)
Size enabled