Search code examples
javascriptd3.jsparallel-coordinates

D3 brushes: accessing absolute values from axis


I'm having some trouble finding a way to get the absolute values from a brushed axis in the parcoords code from syntagmatic, rather than the local position and size of the strum.

So far I figured out a way to get the latter (i.e. the y-location (d.y.animVal.value, upper position of strum) and height (d.height.animVal.value, length of strum)), but not the corresponding values from the mapped data.

Currently, my approach relies on the following function, placed in one of the example html files:

function getBrushData() {
  var myElementd3 = d3.selectAll("rect.extent"); //gets any strum
  myElementd3[0].forEach(function(d,i) { 
    if ( d.height.animVal.value !== 0 ) {  //adds the strum data to array if brush exists
      cursor=cursor+1;
      myArray[cursor] = "" + d.__data__ + ", " + d.y.animVal.value + ", " + d.height.animVal.value;
    }
  });
  return myArray, cursor;
}

I guess I could somehow convert the y and height values based on absolute min/max values of the axis, but even those, I can't find a way to access automatically.

So my question: is there any simple way to automatically get the absolute values from the strum's extremities, instead of the local ones? Thanks for any help!


Solution

  • To get the corresponding brush range max/min values from the brush extents, you can use the brushExtents() function passing no parameters.

    parcoords.brushExtents() This will return an array of all the axis' that are brushed and their associated max/min values.