Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't sort by subobject field #3727

Closed
iliatimofeev opened this issue May 9, 2018 · 4 comments
Closed

Can't sort by subobject field #3727

iliatimofeev opened this issue May 9, 2018 · 4 comments
Assignees

Comments

@iliatimofeev
Copy link

Can't sort by field stored in properties of geojson object.
Vega-light processes fields with dot in name but not in "sort field definition object"

Simplified example to reproduce situation :

{
    "$schema": "https://vega.github.io/schema/vega-lite/v2.4.1.json",
    "data": {
        "values": [
            {"name": "a0", "a": {"i": 0}}, 
            {"name": "a1", "a": {"i": 1}},
            {"name": "a2", "a": {"i": 2}}
        ]
    },
    "mark": "bar",
    "encoding": {
        "x": {"field": "a.i", "type": "quantitative"},
        "y": {"field": "name", "type": "ordinal",
            "sort": {
                "order": "descending",
                "op": "sum",
                "field": "a.i"//  "a\\.i" will work
            }
        }
    }
}

this example on bl.ocks.org

@domoritz
Copy link
Member

domoritz commented May 9, 2018

Thank you for the issue report! I'm going to look into it.

@domoritz
Copy link
Member

domoritz commented May 9, 2018

Vega-Lite should use the flattened field but I am surprised that the small example doesn't work because the data does contain both the flattened and the nested data.

screen shot 2018-05-09 at 12 59 59

@domoritz
Copy link
Member

domoritz commented May 9, 2018

Here is another problematic example to consider. What if we use a field that is not used anywhere else. We need to automatically flatten it.

{
    "$schema": "https://vega.github.io/schema/vega-lite/v2.4.1.json",
    "data": {
        "values": [
            {"name": "a0", "a": {"i": 0}, "b": 2}, 
            {"name": "a1", "a": {"i": 1}, "b": 3},
            {"name": "a2", "a": {"i": 2}, "b": 1}
        ]
    },
    "mark": "bar",
    "encoding": {
        "x": {"field": "b", "type": "quantitative"},
        "y": {"field": "name", "type": "ordinal",
            "sort": {
                "order": "descending",
                "op": "sum",
                "field": "a.i"
            }
        }
    }
}

@domoritz
Copy link
Member

domoritz commented May 9, 2018

@iliatimofeev Can you check whether #3728 fixes the problem in your larger example?

domoritz added a commit that referenced this issue May 10, 2018
domoritz added a commit that referenced this issue May 10, 2018
domoritz added a commit that referenced this issue May 18, 2018
domoritz added a commit that referenced this issue May 18, 2018
domoritz added a commit that referenced this issue May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants