-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I thought that |
||
}, | ||
|
||
compile: function(tElement, tAttrs, transclude) { | ||
|
@@ -48,7 +49,7 @@ function graphViewer() { | |
highlightNodesFromRequest(request); | ||
}); | ||
|
||
var graphUI = require('./graphUI')(renderer.svgRoot); | ||
var graphUI = require('./graphUI')(renderer.svgRoot, scope.showSize); | ||
|
||
renderer.node(graphUI.node).placeNode(graphUI.placeNode); | ||
renderer.link(graphUI.link).placeLink(graphUI.placeLink); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,15 @@ var getLocation = require('../getLocation.js'); | |
var createGraphBuilder = require('../graphBuilder'); | ||
|
||
module.exports = function($scope, $routeParams, $http, $location) { | ||
var applyToScope = require('../applyToScope')($scope); | ||
|
||
// TODO: Remove root, it's no longer valid | ||
$scope.root = $routeParams.pkgId; | ||
$scope.showProgress = true; | ||
$scope.switchMode = switchMode; | ||
$scope.showSize = false; | ||
$scope.toggleSize = toggleSize; | ||
|
||
var graphBuilder = createGraphBuilder($routeParams.pkgId, $routeParams.version, $http, applyToScope(progressChanged)); | ||
$scope.graph = graphBuilder.graph; | ||
|
||
graphBuilder.start | ||
.then(applyToScope(graphLoaded)) | ||
.catch(applyToScope(errorOccured)); | ||
refreshGraph(); | ||
|
||
function progressChanged(queueLength) { | ||
$scope.progress = queueLength; | ||
|
@@ -54,4 +50,20 @@ module.exports = function($scope, $routeParams, $http, $location) { | |
var path = getLocation($routeParams, /* is2d = */ false); | ||
$location.path(path); | ||
} | ||
|
||
function toggleSize() { | ||
$scope.showSize = !$scope.showSize; | ||
refreshGraph(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( How can I make this There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
} | ||
|
||
function refreshGraph() { | ||
var applyToScope = require('../applyToScope')($scope); | ||
var graphBuilder = createGraphBuilder($routeParams.pkgId, $routeParams.version, $http, applyToScope(progressChanged)); | ||
|
||
$scope.graph = graphBuilder.graph; | ||
|
||
graphBuilder.start | ||
.then(applyToScope(graphLoaded)) | ||
.catch(applyToScope(errorOccured)); | ||
} | ||
}; |
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 theregistry.npmjs.cf
and I don't see it thereThere 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) .