Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Use actual edge weights for x-axis #232
Browse files Browse the repository at this point in the history
Via changing the domain from [0, 1] to [0, max * 1.1].

Setting [max * 1.1] as the top of the domain also should mean that
all the values in the histogram are contained within the span of the
x-axis (unlike before, where the max was getting pushed to the right
of the x-axis).
  • Loading branch information
fedarko committed Aug 8, 2017
1 parent e47a514 commit f29fd81
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions viewer/js/xdot2cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,6 @@ function openEdgeFilteringDialog() {
// note could probably find this inline to simplify computation time
var max = d3.max(COMPONENT_EDGE_WEIGHTS);
//console.log(COMPONENT_EDGE_WEIGHTS);
var data = COMPONENT_EDGE_WEIGHTS.map(function(x) { return x / max; });
var margin = {top: 10, right: 30, bottom: 30, left: 30};
//for (var i = 0; i < COMPONENT_EDGE_WEIGHTS.length; i++) {
// console.log(COMPONENT_EDGE_WEIGHTS[i] + "->" + data[i]);
Expand All @@ -2446,12 +2445,12 @@ function openEdgeFilteringDialog() {
var height = +chartSvg.attr("height") - margin.top - margin.bottom;
var g = chartSvg.append("g")
.attr("transform","translate(" + margin.left + "," + margin.top + ")");
var x = d3.scaleLinear().rangeRound([0, width]);
var x = d3.scaleLinear().domain([0, max * 1.1]).rangeRound([0, width]);
// TODO make this user-selectable
var BIN_COUNT = 20;
var bins = d3.histogram()
.domain(x.domain())
.thresholds(x.ticks(BIN_COUNT))(data);
.thresholds(x.ticks(BIN_COUNT))(COMPONENT_EDGE_WEIGHTS);
var y = d3.scaleLinear()
.domain([0, d3.max(bins, function(b) { return b.length; })])
.range([height, 0]);
Expand All @@ -2478,9 +2477,8 @@ function openEdgeFilteringDialog() {
g.append("g")
.attr("class", "axis axis--y")
.call(yAxis);
// TODO: make BIN_COUNT configurable; fix x-axis scale to show actual
// multiplicities; ensure that there's space between every bar;
// add axis labels
// TODO: make BIN_COUNT configurable; ensure that there's space between
// every bar; add axis labels
}

/* Hides edges below a minimum edge weight (multiplicity or bundle size,
Expand Down

0 comments on commit f29fd81

Please sign in to comment.