Closed Fresheyeball closed 9 years ago
I believe this is the rendering most consistent with the spec (and most useful):
|---|---|
| 1 | 2 |
|---|---|
| 3 | 4 |
|---|---|
The top-level array is, as always, rendered as the rows of the table. Because the elements have no JCursor
(or an empty / identity JCursor
), there is no table header.
The two leaf values have the same length and schema, so the arrays are detected as tuples and rendered horizontally instead of vertically.
Thus yielding the above rendering, which I think is the most useful way to render this data (though am open to feedback, of course).
Interestingly, this rendering choice would also make a rectangular matrix render as a rectangular matrix, which seems correct.
What about 3d matrix?
[
[[1,2], [3,4]],
[[5,6], [7,8]]
]
Generally it could be n-dimensional array, probably it makes sense to transform it and render as
{
"0": [[1,2], [3,4]],
"1": [[5,6], [7,8]]
}
So, is the idea here that no JField
s equals no header at all?
What do you think about separator levels?
|---|---|
| 1 | 5 |
|---|---| <- level 1 separator
| 2 | 6 |
|===|===| <- level 0 separator
| 3 | 7 |
|---|---| <- level 1 separator
| 4 | 8 |
|---|---|
@kanterov I like that idea. It also suggest to me it's possible to simplify the problem by rendering objects and arrays the same (using the array index as the label for the array element), and then to post-process the resulting table and deleting headers which can be implied from their spatial positions. Since you can only visualize 2 dimensions on a screen, this would imply higher-level array dimensions would still be labeled with array indexes.
This seems to result in nested tables. @Fresheyeball I like separator levels, albeit that should probably be a styling decision, which means we need nesting information to propagate to TableStyle.
I don't think this needs nested tables, just css classes in the dom to facilitate styling. It also makes the treating of array indexes as labels redundant.
Ok so other thing, if an array is at the top level, are we saying it should be rendered horizontally? Because I could see the largest collection being at the top level, which might result in unusable formatting, (consider a table with 10,000 columns and few rows). That said, the inverse is also possible. Perhaps the vertical vs horizontal display of top level collections should be a setting?
[
[[1,2], [3,4]],
[[5,6], [7,8]]
]
as
|---|---|
| 1 | 5 |
|---|---|
| 2 | 6 |
|===|===|
| 3 | 7 |
|---|---|
| 4 | 8 |
|---|---|
vs
|---|---||---|---|
| 1 | 2 || 3 | 4 |
|---|---||---|---|
| 5 | 6 || 7 | 8 |
|---|---||---|---|
The following is technically valid json
I'd like some guidance on handling this case (thanks StrongCheck).