DC.js Choropleth过滤问题 [英] DC.js Choropleth filtering Issue

查看:137
本文介绍了DC.js Choropleth过滤问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从条形图中过滤我的choropleth图表上的数据。奇怪的是,从随附的条形图中选择条形时,它没有显示正确的值。

I am trying to filter data on my choropleth chart from a bargraph. Strange thing is that it is not showing correct value on selecting a bar from the accompanying bar chart.

这是jsfiddle: https://jsfiddle.net/anmolkoul/jk8LammL/
脚本代码从4794行开始

Here is the jsfiddle: https://jsfiddle.net/anmolkoul/jk8LammL/ The script code begins from line 4794

如果我从条形图中选择WIN004,则它应仅突出显示五个状态,并且工具提示应反映数据值。突出显示了一些不存在WIN004的州。

If i select WIN004 from the bar chart, it should highlight only five states and the tooltip should reflect the values for the data. Some states are highlighted for whom WIN004 does not exist.

我将Choropleth的属性从

I changed the properties of the choropleth from

.colors(d3.scale.quantize().range(["#F90D00", "#F63F00", "#F36F01", "#F09E01", "#EDCB02", "#DDEA03", "#ADE703", "#7EE404", "#50E104", "#24DE05", "#05DB11"]))
.colorDomain([-1, 1])

.colors(d3.scale.linear().range(["green", "white", "red"]))
 .colorDomain([-2, 0, 2])

但是我遇到了很多白人国家,这些国家很难分辨出突出显示的内容。某些变白状态的工具提示显示-0.00:/
这是小提琴 http://jsfiddle.net/anmolkoul/jk8LammL/1/

But i get a lot of white states where its hard to discern what has been highlighted. The tool tip for some white-ed-out states show -0.00 :/ Here is the fiddle http://jsfiddle.net/anmolkoul/jk8LammL/1/

所以我想这可能是我的色彩范围有问题还是我的数据如何获取

So i guess either its a problem with my color range or how my data is getting parsed.

理想情况下,我希望根据RiskIndicator维度的顶部和底部值在.colorDomain中指定数据范围。我的功能无法正常工作。我应该在这里使用d3.max还是riskIndicator.top吗?

I would ideally like to specify the data ranges in the .colorDomain based on the top and bottom values of the riskIndicator dimension. My functions are not working though. Should i use d3.max or riskIndicator.top here?

编辑:
我通过使用min获得了动态色域和最大值,但图形仍未达到预期效果?这可能与地卵圆图有关吗?我进一步以一个实际的地沟波示例为例,将我的数据移植到该示例中,甚至还给了我同样的问题,即错误地表示数据。我虽然可能是数据问题,但是我使用了几个不错的BI工具进行了验证,并且它们的地图正确显示了数据。

I got the color domain dynamic by using the min and max values but still the graph is not performing as expected? Could this be an issue with the geochoropleth chart? I further took a working geochoropleth example and ported my data to it and even that gave me the same issue of representing data incorrectly. I thoughit could be a data problem but i validated using a couple of good BI tools and their map charts displayed data correctly.

这可能是直流电压波形的问题吗?

Could this be an issue with the dc choropleth?

谢谢。
Anmol

Thank you. Anmol

推荐答案

这与该问题的根本原因相同:

This has the same root cause as the issue in this question:

交叉过滤器在dc.js上显示负数而在数据集中没有负数

简而言之,浮点数并不总是会被抵消加减时为零。此伪造的组将确保它们在接近时捕捉到零:

In short, floating point numbers don't always cancel out to zero when added and subtracted. This "fake group" will ensure they snap to zero when they get close:

function snap_to_zero(source_group) {
    return {
        all:function () {
            return source_group.all().map(function(d) {
                return {key: d.key, 
                        value: (Math.abs(d.value)<1e-6) ? 0 : d.value};
            });
        }
    };
}

添加了常见问题解答

这篇关于DC.js Choropleth过滤问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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