Permalink
Browse files

Updates graph view to resize on window resize

  • Loading branch information...
1 parent c679235 commit 756b6e58f111b7290ea57f37163a325e9d36563b @sagemintblue sagemintblue committed Apr 3, 2013
Showing with 10 additions and 13 deletions.
  1. +10 −13 common/src/main/resources/web/js/ambrose/view/graph.js
View
23 common/src/main/resources/web/js/ambrose/view/graph.js
@@ -44,19 +44,18 @@ define(['jquery', 'd3', '../core', './core'], function(
var self = this;
this.workflow = workflow;
this.container = container = $(container);
-
- // define default params and override with user supplied params
- var params = this.params = $.extend(true, {
- dimensions: {
- padding: 20,
- },
- }, View.Theme, params);
-
+ this.params = $.extend(true, {}, View.Theme, params);
this.resetView();
+ // ensure we resize appropriately
+ $(window).resize(function() {
+ self.resetView();
+ self.handleJobsLoaded();
+ });
+
// bind event workflow handlers
- workflow.on('jobsLoaded', function(event, jobs) {
- self.handleJobsLoaded(jobs);
+ workflow.on('jobsLoaded', function() {
+ self.handleJobsLoaded();
});
workflow.on('jobStarted jobProgress jobCompleted jobFailed', function(event, job) {
self.handleJobsUpdated([job], 350);
@@ -72,7 +71,6 @@ define(['jquery', 'd3', '../core', './core'], function(
var dim = this.dimensions = {};
var width = dim.width = container.width();
var height = dim.height = container.height();
- var padding = this.params.dimensions.padding;
// create canvas and supporting d3 objects
this.svg = d3.select(container.empty().get(0))
@@ -85,14 +83,13 @@ define(['jquery', 'd3', '../core', './core'], function(
this.projection = function(d) { return [xs(d.x), ys(d.y)]; };
},
- handleJobsLoaded: function(jobs) {
+ handleJobsLoaded: function() {
// compute node x,y coords
var graph = this.workflow.graph;
var groups = graph.topologicalGroups;
var groupCount = groups.length;
var groupDelta = 1 / groupCount;
var groupOffset = groupDelta / 2;
- // var edges = this.edges = [];
$.each(groups, function(i, group) {
var x = i * groupDelta + groupOffset;
var nodeCount = group.length;

0 comments on commit 756b6e5

Please sign in to comment.