 
     .on "mouseout", (d) ->
               if !clickStatus[d]
-                d3.select(this).attr("opacity", "0")
+                d3.select("rect#rect#{data.ind[d]}").attr("opacity", "0")
 
     .on "click", (d) ->
               console.log("Click: #{data.ind[d]} (#{d})")
               clickStatus[d] = 1 - clickStatus[d]
-              d3.select(this).attr("opacity", clickStatus[d])
+              d3.select("rect#rect#{data.ind[d]}").attr("opacity", clickStatus[d])
               if clickStatus[d]
                 curcolor = histColors.shift()
                 histColors.push(curcolor)
 
-                d3.select(this).attr("fill", curcolor)
+                d3.select("rect#rect#{data.ind[d]}").attr("fill", curcolor)
 
                 grp4BkgdHist.append("path")
                       .datum(data.counts[d])

    text += "#{q*100}"
  text += " percentiles for each of #{data.ind.length} distributions.\n"

  d3.select("div#legend").append("p")
    .text(text)

  d3.select("div#legend").append("p")

                 .attr("fill", "purple")
                 .attr("stroke", "none")
                 .attr("opacity", "0")
                 .attr("pointer-events", "none")

  # vertical rectangles representing each array
  longRectGrp = svg.append("g").attr("id", "longRect")

  longRect = indRectGrp.selectAll("empty")
                 .data(indindex)
                 .enter()
                 .append("rect")
                 .attr("x", (d) -> xScale(d) - recWidth/2)
                 .attr("y", pad.top)
                 .attr("width", recWidth)
                 .attr("height", h - pad.top - pad.bottom)
                 .attr("fill", "purple")
                 .attr("stroke", "none")
                 .attr("opacity", "0")

  # label quantiles on right
  rightAxis = svg.append("g").attr("id", "rightAxis")
