【问题标题】:How can i remove empty bars from dc.js row chart, whenever the dimension is null or empty, there appears an empty bar on row chart如何从 dc.js 行图中删除空条,每当维度为空或为空时,行图上都会出现一个空条
【发布时间】:2017-06-16 11:12:44
【问题描述】:

如何从 dc.js 行图中删除空条,只要维度为空或为空,行图上就会出现一个空条。

【问题讨论】:

  • “维度为空或为空”是什么意思?你能发布一些代码和示例数据吗? (小提琴会更好。)我猜 key 函数对某些值的计算结果为空白/未定义/空。您可以使用假组删除它们,但我认为这表明需要更好地清理数据。

标签: javascript dc.js


【解决方案1】:

你必须使用假组

const remove_empty_bins = (source_group) => {
    return {
        all: () => {
            return source_group.all().filter(function(d) {
                // here your condition
                return d.key !== null && d.key !== '' && d.value !== 0; // etc. 
            });
        }
    };
}

let myFilteredGroup = remove_empty_bins(myGroup);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多