简体   繁体   English

dc.js添加动态列

[英]dc.js add dynamic columns

I want to show value in datatable for that i have put line of code 我想在数据表中显示值,因为我已经放置了一行代码

// Bar chart For pricing
    var collectionRateValue = ndx.dimension(function (d) {
        return d3.time.month(d.dd);
    }); 

    var collectionRateValueGroup_adj = collectionRateValue.group().reduceSum(function(d) {
        return d.pay_amt;
    });
    var collectionRateValueGroup_payment = collectionRateValue.group().reduceSum(function(d) {
        return d.ar_balance;
    });
    var collectionRateValueGroup_ar_bal = collectionRateValue.group().reduceSum(function(d) {
        return d.charge_amt;
    });    
    var collectionRateValueGroup_payment_line = collectionRateValue.group().reduceSum(function(d) {
        return d.pay_amt;
    });

This is code for showing data 这是用于显示数据的代码

dc.dataTable("#dc-data-table")
    .dimension(collectionService)  
    .group(function (d) {
        return d3.time.format(d.month_year_dos);
    })
    .size(10)
    .columns([
        function (d){
            return d.month_year_dos;
        },
        function (d){
            return d.ar_balance;
        },
        function (d){
            return d.pay_amt;
        },
        function (d){
            return "d.date";
        },
    ])

This is how I want to show my data table. 这就是我要显示数据表的方式。

在此处输入图片说明

Table header will come dynamically 表头将动态变化

I have find a lot but i didn't get how data will shown in row format? 我发现了很多东西,但是我不知道数据如何以行格式显示?

It seems like you want to flip the rows of your table for columns. 似乎您想将表格的行翻转为列。 You will probably want to do that directly with D3. 您可能会想直接用D3做到这一点。

The example at http://www.d3noob.org/2013/02/add-html-table-to-your-d3js-graph.html should show to use D3 to render a table. http://www.d3noob.org/2013/02/add-html-table-to-your-d3js-graph.html上的示例应显示使用D3渲染表。 you will want to adapt this to render in a different order however... 您将需要对此进行调整以以不同的顺序进行渲染...

Start simple and try to render one of the rows in your table - perhaps the adjustments row - by appending a td for each value in the crossfilter group. 从简单开始,尝试通过为crossfilter组中的每个值附加一个td来呈现表中的行之一(也许是调整行)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM