score:1
Based on your data:
var data = {
"items": [
{
"tableName": "incidents",
"count": 20000,
"columnNames": [
"id",
"subject",
"category"
],
"rows": [
[
"61",
"Test",
null
],
[
"65",
"TEST 2",
null
],
[
"67",
"TEST 3",
"not null"
]
]
}
]
}
function tabulate(data, columns) {
var table = d3.select('body').append('table')
var thead = table.append('thead')
var tbody = table.append('tbody');
// append the header row
thead.append('tr')
.selectAll('th')
.data(columns).enter()
.append('th')
.text(function (column) { return column; });
// create a row for each object in the data
var rows = tbody.selectAll('tr')
.data(data.items[0].rows)
.enter()
.append('tr');
// create a cell in each row for each column
var cells = rows.selectAll('td')
.data(function (row,i) {return row; })
.enter()
.append('td')
.text(function (d) { return d; });
return table;
}
// render the table(s)
tabulate(data, data.items[0].columnNames); // data, columns table
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"></script>
Source: stackoverflow.com
Related Query
- convert a nested JSON file to a table using D3
- How can I navigate JSON nested file using d3.js?
- convert multilevel nested array using into json using javascript
- Importing local json file using d3.json does not work
- Convert flat JSON file to hierarchical json data like flare.json [d3 example file]
- Bundle layout using d3.js and given json file structure
- 404 Error while trying access JSON file using D3 Framework
- Using D3.js with a javascript object instead of an external JSON file
- Using D3 to access nested JSON data
- Sum of nested JSON array using D3 .rollup
- How do I access values in a d3 json file with nested array objects
- How to loop through JSON file using jQuery
- How to show nested JSON value in table header & row
- Creating a D3 Line Graph with Points using 2 Level Nested JSON
- convert a flat json file to tree structure in javascript
- how to update data form file json using d3.js (zoomable circle pack)
- How to fetch data from json file to draw a dynamic graph by using d3.js
- Using dc.js on nested JSON to create bar chart
- Using External json file for creating bubble chart using d3js
- How to iterate over data in JSON file using D3 javascript
- Displaying a JSON file as a map using D3js v4
- How do you call data from nested JSON array using d3?
- trying to get MySQL data into nested json file for d3?
- Create table using D3.js based on (hidden) JSON data
- How to convert Data table to tree json format dynamically?
- How to change json file in d3.js and update chart using select options
- Unable to load json file in html using d3.js
- Creating multiple lines using json file with coordinates in d3.js
- Using variables to access nested json keys in d3
- flattened json file using javascript / coffee with d3.json
More Query from same tag
- D3: Issue with links not disappearing on removal
- d3-sankey-diagram align links by type
- Updating d3js Datamap with dynamic data
- Turn string to array name in D3 Javascript
- D3: How can I cause the stroke of an SVG path generated with D3 to be clipped to the interior of the same path?
- Basic JSON Formatting for C3.js when data loaded via URL using Rails
- Align x-axis with zero scale d3 bar chart
- d3: line chart x-axis -- How to have tickValues with same padding?
- How to change the orientation of an svg text
- D3js reverse number order on spider/radar chart, from bigger to smaller number
- json file not loading frim Visual Studio 2013
- NVD3: How to get values from tooltip or legend instead of labels?
- D3 arcs on (inverted) stereographic projection not displaying as required
- cannot clear d3.js div on dropdown change
- How to update the existing nodes attributes of a d3js tree, based on an input value from a search box?
- How to retain line colors in D3
- How to wrap a heatmap on a spiral (seasonal spiral) - d3?
- Set origin on d3 graph
- Find the max value in a column in d3.js
- Handling JSON data with no identifiers
- how can i prevent d3.behavior.zoom().on("zoom", redraw) from being used when i mousedrag on my nodes?
- D3 - move y-axis labels above line
- d3 js exit animation not working properly
- Javascript sorting for a SunburstR Graph
- d3 geo animation does not stop
- Difficulty accessing json file with d3 and flask
- d3-force - Nodes are dragged away from links, ticks not run
- d3 equivalent for Ruby on Rails?
- Problems fitting a map in a container
- Coloring hexbin series with d3js