Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 51 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,33 @@
var _h = $("#vis_height").val();

var _labels = {};
var _valname = "uservariable";
var _it = 2;

var _rbo_p = parseFloat($("#vis_alpha").val());

var _tmpelements = _rows[1].split("\t")
_singlerow = (isNaN(parseInt(_tmpelements[1]))) ? true:false;
if(_singlerow == true) {

var _values = 0;
var _tmpelements = _rows[1].split("\t");

if (isNaN(parseInt(_tmpelements[1]))) {
_values = 0;
_makelog = false;
_it = 1;
} else if (isNaN(parseInt(_tmpelements[2]))) {
_values = 1;
} else {
_values = 2;
}

var _it = _values + 1;

var _valnames = [];
if (_values > 0) {
var _tmpelements = _rows[0].split("\t")
if (_values >= 1) {
_valnames [0] = _tmpelements[1];
}
if (_values >= 2) {
_valnames [1] = _tmpelements[2];
}
}

var _rbo_p = parseFloat($("#vis_alpha").val());


// HTML table output
Expand All @@ -70,25 +86,41 @@
_labels[j] = _elements[j];

_html += '<th>' + _elements[j] + '</th>';
if(!_singlerow) {
if(_values > 0) {
_html += '<th>' + _elements[j+1] + '</th>';
}
if(_values > 1) {
_html += '<th>' + _elements[j+2] + '</th>';
}

} else {

var _tmp = {};
var _tmpvalue = ($("#vis_ranksize").is(":checked")) ? _rows.length-i:1;
_tmp[_valname] = (_singlerow) ? _tmpvalue:parseInt(_elements[j+1]);
if(_makelog == true) {
var _newvalname = "log(uservariable)";
_tmp[_newvalname] = Math.round(Math.log(parseInt(_elements[j+1])) * 10);
if (_values == 0) {
_tmp["value"] = ($("#vis_ranksize").is(":checked")) ? _rows.length-i:1;
}
if (_values > 0) {
_tmp[_valnames[0]] = parseInt(_elements[j+1]);
if (_makelog == true) {
_tmp["log("+ _valnames[0] + ")"] = Math.round(Math.log(parseInt(_elements[j+1])) * 10);
}
}
if (_values > 1) {
_tmp[_valnames[1]] = parseInt(_elements[j+2]);
if (_makelog == true) {
_tmp["log("+ _valnames[1] + ")"] = Math.round(Math.log(parseInt(_elements[j+2])) * 10);
}
}

_data[_labels[j]][_elements[j]] = _tmp;

_html += '<td>' + _elements[j] + '</td>';
if(!_singlerow) {
if(_values > 0) {
_html += '<td>' + _elements[j+1] + '</td>';
}
if(_values > 1) {
_html += '<td>' + _elements[j+2] + '</td>';
}
}
}

Expand Down Expand Up @@ -154,8 +186,8 @@
_rbdout += '</tr></table>';
$("#vis_rbd").html(_rbdout);

var _startval = (_makelog) ? _newvalname:_valname;
startVis(_startval,_w,_h);
var _startval = (_makelog) ? "log("+ _valnames[0] + ")":_valnames[0];
startVis(_startval, _valnames[1],_w,_h);
}


Expand Down Expand Up @@ -240,7 +272,7 @@ <h1>RankFlow</h1>
the logarithm checkbox for better display.</p>

<p>You can either use data that is merely a collection of ranked items (tab separated single columns, <a href="http://thepoliticsofsystems.net/permafiles/syria_ranks_noval.xlsx">example</a>)
or combinations of items and a value (tab separated list of two columns, <a href="http://thepoliticsofsystems.net/permafiles/syria_ranks.xlsx">example</a>).</p>
or combinations of items and one or two values (tab separated list of two or three columns, <a href="http://thepoliticsofsystems.net/permafiles/syria_ranks.xlsx">example</a>).</p>

<p>This tool also calculates the Rank-Biased Distance (RBD) metric to quantify changes from one slice to the next. The higher the RBD value, the more change. The "RBD p" parameter (value is between 0.01 and 0.99) below allows to determine how
"top-weighed" the calculation should be. With a small p, changes at the top of the lists are weighed more strongly, with p approaching 1 all changes are treated the same. Calculations are based on William Webber, Alistair Moffat, and Justin Zobel (2010)
Expand Down
12 changes: 6 additions & 6 deletions vis.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function startVis(_valname,_w,_h) {
function startVis(_sizevaluename, _colourvaluename,_w,_h) {

// variables to modify
c_width = parseInt(_w);
Expand All @@ -18,8 +18,8 @@ function startVis(_valname,_w,_h) {

// do not modify
_topalign = false;
_colorMetric = _valname;
_mainVar = _valname;
_colorMetric = _colourvaluename;
_mainVar = _sizevaluename;
_slicecount = 0;
_bottomspacing = 5;
_topspacing = 15;
Expand Down Expand Up @@ -47,14 +47,14 @@ function startVis(_valname,_w,_h) {
}


createInterface(_valname);
createInterface(_mainVar);

_pf = 0; // pixelfactor
_cf = 0; // colorfactor

calculateFactors(_valname);
calculateFactors(_mainVar);

_barspacing = Math.round((c_width - (_slicecount * _barwidth)) / (_slicecount - 1)) - _rightspacing;
_barspacing = Math.round((c_width - _rightspacing) / _slicecount);

_slices = new Object;
_lines = new Object;
Expand Down