I would like to generate a table resembling a matrix without numerical values. 1. Here is an example of my 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 |
Using this table, I can create a JSON file as follows:
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"} ];
This is the expected final table format:
| 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 attempted to achieve this with the help of resources like:
http://bl.ocks.org/mbostock/844752
recursively (or iteratively) make a nested html table with d3.js?
Your assistance in accomplishing this task is greatly appreciated.