Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. [
  2. {
  3. "Label": "External-Partner-Induced",
  4. "Count": 9
  5. },
  6. {
  7. "Label": "Null",
  8. "Count": 1
  9. },
  10. {
  11. "Label": "FCTS-Induced",
  12. "Count": 66
  13. },
  14. {
  15. "Label": "EI-Partner-Induced",
  16. "Count": 78
  17. }
  18. ]
  19.  
  20. function testFunction(fieldNamesUnique) {
  21. data = d3.json('json/dataQualityIssuesCategory.json')
  22. tabulate(data, ['Category', 'Count']);
  23.  
  24. }
  25. function tabulate(data, columns) {
  26. var table = d3.select('#response').append('table')
  27. var thead = table.append('thead')
  28. var tbody = table.append('tbody');
  29.  
  30. // append the header row
  31. thead.append('tr')
  32. .selectAll('th')
  33. .data(columns)
  34. .enter()
  35. .append('th')
  36. .text(function (column) { return column; });
  37.  
  38. // create a row for each object in the data
  39. var rows = tbody.selectAll('tr')
  40. .data(data)
  41. .enter()
  42. .append('tr');
  43.  
  44. // create a cell in each row for each column
  45. var cells = rows.selectAll('td')
  46. .data(function (row) {
  47. return columns.map(function (column) {
  48. return {column: column, value: row[column]};
  49. });
  50. })
  51. .enter()
  52. .append('td')
  53. .text(function (d) { return d.value; });
  54. return table;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement