               clickStatus[d] = 1 - clickStatus[d]
               svg.select("rect##{d}").attr("opacity", clickStatus[d])
               if clickStatus[d]
+                curcolor = histColors.shift()
+                histColors.push(curcolor)
+
                 d3.select(this).attr("opacity", "0")
+                svg.select("rect##{d}").attr("fill", curcolor)
+
                 lowsvg.append("path")
                       .datum(data.counts[d])
                       .attr("d", histline)
                       .attr("id", d)
                       .attr("fill", "none")
-                      .attr("stroke", "blue")
+                      .attr("stroke", curcolor)
                       .attr("stroke-width", "2")
               else
                 lowsvg.select("path##{d}").remove()

       .attr("width", 2)
       .attr("id", d)
       .attr("height", yScale(data.quant[0][d]) - yScale(data.quant[nQuant-1][d]))
       .attr("fill", "blue")
       .attr("opacity", 0)

  # vertical rectangles representing each array
  indRectGrp = svg.append("g")


  indRect
    .on("mouseover", (d) ->
              d3.select(this)
                 .attr("opacity", "1")
              d3.select("#histline")
                 .datum(data.counts[d])
                 .attr("d", histline)
