Add a column with data to a table

Hello,

here I am creating a table with data from “runs#data”. “runs#data” has 3 fields.
Now I want to add to the table a forth column and define its titleHead and then body as field4 = field1-field2
How can I do that?
Thanks

Code:

var runs = {}; //  hold the table
runs.data_container = d3.select("div#Runs_Data")
    .classed("row", true);
runs.table = runs.data_container.append("div")
    .classed("col-xs-12", true)
    .append("table")

data = d3.csv.parse(d3.select("runs#data").text.labels = d3.keys(data[0]); 
runs.header = runs.table.append("theaduns.headers = runs.header.append("tr") 
    .selectAll("th")
    .data(runs.labels).enter()
	.append("th")
	.text(function(d){
  		return d;
			})
.attr("data-sortable",true)
.attr("data-field",function(d){
  			return d;
				})

    runs.table.attr({ 
		         "data-sort-name":  runs.labels[0],
         "data-sort-order": "asc",
         "data-striped":    true
           	});

rows = runs.table
               .append("tbody")
               .selectAll("tr")
		.data(data)                           
		.enter()                                 
		.append("tr")

cells = rows.selectAll("td")
            .data(function(row){
              return runs.labels.map(function(d){
                return row[d];
              					    });
           		       })
            .enter()
            .append("td")
            .text(function(d){
              return d;
	                     })

$(runs.table.node()).bootstrapTable()

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.