Permalink
Browse files

Adding support for chart/circle highlighting

  • Loading branch information...
1 parent 2d996d2 commit f170580bea93406cb30391b79f049d4437b35ed6 @matthewhudson matthewhudson committed Apr 12, 2013
Showing with 20 additions and 3 deletions.
  1. +3 −0 sixpack/static/js/chart.js
  2. +17 −3 sixpack/static/js/experiment.js
@@ -134,10 +134,13 @@ $(function () {
my.drawCircle = function (data, color) {
color = color || "#9d5012";
+ var id = my.experiment + "-line-" + _.indexOf(my.colors, color);
my.svg.selectAll("dot")
.data(data)
.enter()
.append("circle")
+ .attr("class", "circle")
+ .attr("id", id)
.attr("r", 5)
.attr("cx", function(d) { return my.xScale(d.date); })
.attr("cy", function(d) { return my.yScale(d.close); })
@@ -49,12 +49,26 @@ $(function () {
$(this).addClass('highlight');
var line = d3.select("#" + alt_name);
- line.attr('class', line.attr('class') + " line-hover")
- line.attr('class', line.attr('class') + " line-hover");
+ var id = line.attr('id');
+ if (line.attr('class') === 'circle') {
+ line.attr('r', 7);
+ } else {
+ line.attr('class', line.attr('class') + " line-hover");
+ }
},
function () {
$(this).removeClass('highlight');
- d3.select('#' + $(this).attr('class')).attr('class', 'line');
+
+ var alt_name = $(this).attr('class');
+ if (!alt_name) return;
+
+ var line = d3.select('#' + alt_name);
+
+ if (line.attr('class') === 'circle') {
+ line.attr('r', 5);
+ } else {
+ line.attr('class', 'line');
+ }
}
);

0 comments on commit f170580

Please sign in to comment.