从DC.JS系列图表的维度中过滤空值

时间:2017-04-21 16:12:22

标签: javascript d3.js charts dc.js

我尝试使用具有多个维度的一个数据集中的DC.JS创建多个系列图表

我遇到的问题是每个维度都包含空值

date,value,#transactionLocalServiceperformancedashboard,Averagetimeonpage,Channelbreakdownfortransactions,Numberofuserenquiries,Pageviews,Reasonsforrejectedapplications,UniqueVisitors,"Userswhousetransaction,abandonoruselegacyroutewhenstartinganonlineapplication",Visits
05/02/17,1.2,,Average time on page,,,,,,,
05/02/17,105,For telephone,,Number of transactions phone,,,,,,
05/02/17,110,For post,,Number of transactions face to face,,,Number of incomplete,,Use legacy route,
05/02/17,165,For face to face,,Number of transactions online new transaction,,,,,Use new transaction,
05/02/17,178,,,,,,,Unique visitors,,
05/02/17,198,,,,,,,,,Visits

经过大量的搜索,我找到了这个jsfiddle

function remove_empty_bins(source_group) {
    return {
        all:function () {
            return source_group.all().filter(function(d) {
                return d.value !== "";
            });
        }
    };
};

var coerce_row = function(d){
    // console.log(d.VerifyLocalServiceperformancedashboard)

    return {
        time: d.date,
        field: remove_empty_bins(d.VerifyLocalServiceperformancedashboard),
        count: +d.count,
    };
};

var dataset = data.map(coerce_row);

https://jsfiddle.net/zilnhoj/d8mqpyun/2/

我基本上试图过滤掉每个维度的空值并绘制该维度的图表。

DC.JS是否可以实现,或者我是否需要为每个维度获取单独的csv文件并为每个图表加载它们 - 我将系列图表用于单个维度

0 个答案:

没有答案