问题
Can somebody tell me how to highlight only certain coordinates in a NVD3 line graph depending upon some condition like if x axis value is above 100,highlight that coordinate.
please see the image at :http://i.stack.imgur.com/AHJaK.jpg
This question or similar question has been asked , but I see no answers. Thanks in advance.
How to highlight a point on a Simple Line Chart in NVD3?
回答1:
The NVD3 API doesn't allow you do to that, so you have to "hack" it and highlight the data points you're interested in yourself. The general approach is to create the circles for the relevant data points by filtering the data:
var data = d3.select('#chart svg').datum();
d3.select('.nv-groups')
.selectAll("circle.myPoint")
.data(data.filter(function(d) { return d.y > 3000; }))
.enter().append("circle").attr("class", "myPoint")
.attr("cx", function(d) { return chart.xAxis.scale()(d.x); })
.attr("cy", function(d) { return chart.yAxis.scale()(d.y); })
.attr("r", 5);
Incomplete demo for the first series in the data here.
来源:https://stackoverflow.com/questions/30039550/how-to-highlight-only-certain-coordinates-in-nvd3-line-graph