D3 X-value Mouseover - Function Returns Nan
So I am trying to adapt M Bostock's x-value mouseover example to my own graph, the main difference being that I have multiple series instead of his one. For the moment I'm just try
Solution 1:
You're passing in a function definition into your y_main
scale:
circles.attr('transform', 'translate(' +
x_main(c[0]) + ',' +
y_main(function (d) {return d.values[c[1]].value;}) + ')'
);
selection.attr
can take a string value or a callback function but this is trying mixing both of those. You're passing in a string and as the string is constructed it tries to scale the function itself as a value, which will return NaN.
The function version should look like this (returning the entire transform value):
circles.attr('transform', function(d) {
return'translate(' +
x_main(c[0]) + ',' +
y_main(d.values[c[1]].value) + ')';
});
Post a Comment for "D3 X-value Mouseover - Function Returns Nan"