dc.js Scatter Plot和elasticY行为

问题描述 投票:1回答:1

如果触发重绘事件,elasticY(true)是否应使Scatter Plot重新计算y轴范围?

我使用了Scatter Brushing示例来演示。每个图表都添加了以下属性:

.yAxisPadding('5%')  // Allow the max values to be brushed
.elasticY(true)      // Allow the chart to recalculate the Y axis range

这是一个jsFiddle的例子。

我想通过刷左侧散点图,在图表中间选择一对点,将导致右散点图重新计算其Y轴范围。但这似乎并不正确。这是一个错误还是我错过了什么?

javascript d3.js dc.js crossfilter
1个回答
1
投票

elasticXelasticY一样,dc.js正在查看所有垃圾箱,无论它们是否为空。

您可能会认为它忠实地显示所有数据,只是发生了一些数据为零。 :-)

要删除这些零,请使用FAQ中的remove_empty_bins

    function remove_empty_bins(source_group) {
        return {
            all: function () {
                return source_group.all().filter(function(d) {
                    //return Math.abs(d.value) > 0.00001; // if using floating-point numbers
                    return d.value !== 0; // if integers only
                });
            }
        };
    }
    chart1
        .group(remove_empty_bins(group1))
    chart2
        .group(remove_empty_bins(group2))

Fork of your fiddle.

请注意,散点图joins the data in a naive way不能提供非常好的动画过渡。我通常建议只使用.transitionDuration(0)关闭散点图的过渡,因为它们没用。

© www.soinside.com 2019 - 2024. All rights reserved.