Skip to content

Commit

Permalink
Fix issue speced#89
Browse files Browse the repository at this point in the history
  • Loading branch information
almossawi committed Jul 17, 2014
1 parent 078206f commit cdc3b21
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions js/metrics-graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ charts.line = function(args) {
if(args.linked) {
var v = d[args.x_accessor];
var formatter = d3.time.format('%Y-%m-%d');

return 'line' + d['line_id'] + '-color ' + 'roll_' + formatter(v);
}
else {
Expand All @@ -766,12 +767,17 @@ charts.line = function(args) {
g.selectAll('.rollover-rects')
.data(args.data[0]).enter()
.append('rect')
.attr('class', function(d) {
.attr('class', function(d, i) {
if(args.linked) {
var v = d[args.x_accessor];
var formatter = d3.time.format('%Y-%m-%d');

return 'line' + line_id + '-color ' + 'roll_' + formatter(v);

//only format when y-axis is date
var id = (typeof v === 'number')
? i
: formatter(v);

return 'line' + line_id + '-color ' + 'roll_' + id;
}
else {
return 'line' + line_id + '-color';
Expand Down Expand Up @@ -850,8 +856,13 @@ charts.line = function(args) {
var v = d[args.x_accessor];
var formatter = d3.time.format('%Y-%m-%d');

//only format when y-axis is date
var id = (typeof v === 'number')
? i
: formatter(v);

//trigger mouseover on matching line in .linked charts
d3.selectAll('.line' + d['line_id'] + '-color.roll_' + formatter(v))
d3.selectAll('.line' + d['line_id'] + '-color.roll_' + id)
.each(function(d, i) {
d3.select(this).on('mouseover')(d,i);
})
Expand Down Expand Up @@ -916,7 +927,12 @@ charts.line = function(args) {
var v = d[args.x_accessor];
var formatter = d3.time.format('%Y-%m-%d');

d3.selectAll('.roll_' + formatter(v))
//only format when y-axis is date
var id = (typeof v === 'number')
? i
: formatter(v);

d3.selectAll('.roll_' + id)
.each(function(d, i){
d3.select(this).on('mouseout')(d);
});
Expand Down

0 comments on commit cdc3b21

Please sign in to comment.