0

i want to create a matrix like table with no numerical values. 1. i have a database table:

| CODE |  STIL |  SUBSTIL |  PRODUS |
|------|-------|----------|---------|
|  R   | stil1 | substil1 | produs1 |
|  R   | stil1 | substil2 | produs2 |
|  T   | stil1 | substil3 | produs3 |
|  T+  | stil2 | substil4 | produs4 |
|  G   | stil2 | substil4 | produs5 |
|  R   | stil3 | substil5 | produs6 |
|  R   | stil4 | substil6 | produs7 |
  1. from this table i can get a jsonfile:

    var data = [ {"code": "R","stil": "stil1","substil": "substil1","produs": "produs1"}, {"code": "R","stil": "stil1","substil": "substil2","produs": "produs2"}, {"code": "T","stil": "stil1","substil": "substil3","produs": "produs3"}, {"code": "T+","stil": "stil2","substil": "substil4","produs": "produs4"}, {"code": "G","stil": "stil2","substil": "substil4","produs": "produs5"}, {"code": "R","stil": "stil3","substil": "substil5","produs": "produs6"}, {"code": "R","stil": "stil4","substil": "substil6","produs": "produs7"} ];

I want as final result a table like this:

| CODE |            stil1            |  stil2   |   stil3  |   stil4  |
|      | substil1 | substil2 | substil3  | substil4 | substil5 | substil6 |
|------|----------|----------|-----------|----------|----------|----------|
|  R   | produs1  |          |           |          |          |          |
|  R   |          | produs2  |           |          |          |          |
|  R   |          |          |           | produs6  |          |          |
|  R   |          |          |           |          |          | produs7  |
|  T   |          |          |  produs3  |          |          |          |
|  T+  |          |          |           | produs4  |          |          |
|  G   |          |          |           | produs5  |          |          |

I tried using this

http://bost.ocks.org/mike/nest/

http://bl.ocks.org/mbostock/844752

recursively (or iteratively) make a nested html table with d3.js?

Thank you for any hint.

DGA
  • 258
  • 1
  • 14

1 Answers1

0

see Creating a table linked to a csv file, but work from the jsfiddle provided since the data structure is very similar... http://jsfiddle.net/7WQjr/

if your data is coming directly from a request, you can:

d3.json(url, function(data) {
    code from the jsfiddle making the table goes here
})
Community
  • 1
  • 1
rysloan
  • 697
  • 5
  • 15
  • thanks, but is just a simple table. i want to transform in matrix or pivot like, but without calculated value (no count,no sum, just plain text); – DGA Apr 10 '14 at 22:38