如何仅突出显示NVD3折线图中的某些坐标? [英] How to highlight only certain coordinates in NVD3 line graph?

查看:81
本文介绍了如何仅突出显示NVD3折线图中的某些坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何突出显示NVD3折线图中的某些坐标,具体取决于某些条件
,如果x轴值大于100,则突出显示该坐标。

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.

请参阅以下图片: http://i.stack.imgur.com/ AHJaK.jpg

此问题或类似问题已被提出,但我看不到任何答案。
提前致谢。

This question or similar question has been asked , but I see no answers. Thanks in advance.

如何在NVD3中突出显示简单折线图上的点?

推荐答案

NVD3 API不允许您这样做,因此您必须破解它并突出显示您自己感兴趣的数据点。一般方法是通过过滤数据为相关数据点创建圆圈:

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.

这篇关于如何仅突出显示NVD3折线图中的某些坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆