Skip to content

Commit

Permalink
Changing default dependency wheel width to be the parent DOM element …
Browse files Browse the repository at this point in the history
…width
  • Loading branch information
Lucas-C committed Apr 24, 2018
1 parent c7a1f4a commit 41569a2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions js/d3.dependencyWheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,21 @@ d3.chart = d3.chart || {};
* @see https://github.com/fzaninotto/DependencyWheel for complete source and license
*/
d3.chart.dependencyWheel = function(options) {

var width = 700;
var margin = 150;
var padding = 0.02;
options = options || {};

function chart(selection) {

if (selection.length > 1) {
throw new Error('dependencyWheel.js chart does not support rendering on several elements');
}

selection.each(function(data) {

var matrix = data.matrix;
var packageNames = data.packageNames;
var width = options.width || this.offsetWidth;
var margin = options.margin || width * 3 / 14;
var padding = options.padding || 0.02;
var radius = width / 2 - margin;

// create the layout
Expand Down Expand Up @@ -152,20 +157,20 @@ d3.chart.dependencyWheel = function(options) {
}

chart.width = function(value) {
if (!arguments.length) return width;
width = value;
if (!arguments.length) return options.width;
options.width = value;
return chart;
};

chart.margin = function(value) {
if (!arguments.length) return margin;
margin = value;
if (!arguments.length) return options.margin;
options.margin = value;
return chart;
};

chart.padding = function(value) {
if (!arguments.length) return padding;
padding = value;
if (!arguments.length) return options.padding;
options.padding = value;
return chart;
};

Expand Down

0 comments on commit 41569a2

Please sign in to comment.