discoveryjs / discovery

A framework for rapid data (JSON) analysis, shareable serverless reports and dashboards
https://discoveryjs.github.io/discovery/
MIT License
336 stars 6 forks source link

Tree view doesn't work with properties containing object #11

Closed obenjiro closed 3 months ago

obenjiro commented 5 years ago

Data

[{ id: 1, a: { id: 3, val: 1 }}, { id: 2, b: [{ id: 4, val: 1 }]}]

View

{
    view: 'tree',
    children: 'a or b',
    item: [
        'text:id', 'struct'
    ],
    expanded: 100
}

Actual Result

2019-02-21 12 54 36

Expected To see object with id 3 in tree

obenjiro commented 5 years ago

Workaround that I have found. At least for now

{
    view: 'tree',
    data: '',
    children: '$r: (a or b) + []; $r.[size() > 1]',
    item: [
        'text:id', 'struct'
    ],
    expanded: 100
}
2019-02-21 13 19 57
lahmatiy commented 4 years ago

One more workaround (a or b or []) + []

lahmatiy commented 3 months ago

A solution from 2024: a or b | is array ?:? [$] (or the full form: a or b | is array ? $ : ($ ? [$] : undefined)) More solutions:

obenjiro commented 3 months ago

Thanks, I think that will be enough for now.