diff --git a/index.html b/index.html index 2b7a104..bbe8a2c 100644 --- a/index.html +++ b/index.html @@ -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 @@ -70,25 +86,41 @@ _labels[j] = _elements[j]; _html += '' + _elements[j] + ''; - if(!_singlerow) { + if(_values > 0) { _html += '' + _elements[j+1] + ''; } + if(_values > 1) { + _html += '' + _elements[j+2] + ''; + } } 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 += '' + _elements[j] + ''; - if(!_singlerow) { + if(_values > 0) { _html += '' + _elements[j+1] + ''; } + if(_values > 1) { + _html += '' + _elements[j+2] + ''; + } } } @@ -154,8 +186,8 @@ _rbdout += ''; $("#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); } @@ -240,7 +272,7 @@

RankFlow

the logarithm checkbox for better display.

You can either use data that is merely a collection of ranked items (tab separated single columns, example) - or combinations of items and a value (tab separated list of two columns, example).

+ or combinations of items and one or two values (tab separated list of two or three columns, example).

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) diff --git a/vis.js b/vis.js index cd82fd5..f7cd33a 100644 --- a/vis.js +++ b/vis.js @@ -1,4 +1,4 @@ -function startVis(_valname,_w,_h) { +function startVis(_sizevaluename, _colourvaluename,_w,_h) { // variables to modify c_width = parseInt(_w); @@ -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; @@ -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;