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

Validating the Vega-Lite schema created by hvega #14

Open
DougBurke opened this issue Mar 11, 2019 · 2 comments
Open

Validating the Vega-Lite schema created by hvega #14

DougBurke opened this issue Mar 11, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@DougBurke
Copy link
Owner

I've noticed, when viewing the output of hvega in the Vega-Lite editor that there are times we create invalid data. For instance, the following made-up example

vlShow (toVegaLite [ description "test"
                   , dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []
                   , (encoding . position X [PName "Horsepower", PmType Quantitative,
                                             PScale [SReverse True]]
                               . position Y [PName "Miles_per_Gallon", PmType Quantitative]) []
                   , mark Circle []
                   ])

creates

{
  "mark": "circle",
  "data": {
    "url": "https://vega.github.io/vega-datasets/data/cars.json",
    "format": {"type": "json"}
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "encoding": {
    "x": {
      "field": "Horsepower",
      "scale": {"reverse": true},
      "type": "quantitative"
    },
    "y": {"field": "Miles_per_Gallon", "type": "quantitative"}
  },
  "description": "test"
}

and the Vega-Lite editor doesn't like the use of reverse, even though it does display the X axis in reverse.

visualization

@DougBurke DougBurke added the enhancement New feature or request label Mar 11, 2019
@DougBurke
Copy link
Owner Author

In this particular case it's because SReverse leads to the creation of a Vega, rather than Vega-Lite, property (reverse). If you change

PScale [SReverse True]

to

PSort [Descending]

then the JSON passes the validator.

That's not to say we could do with more tests of this.

DougBurke added a commit that referenced this issue Jun 24, 2019
SReverse adds a Vega, rather than Vega-Lite, property (see #14). To
reverse an axis in Vega-Lite use `PSort [Descending]`.
DougBurke added a commit that referenced this issue Jun 25, 2019
This is part of #14 (validating the output against the Vega-Lite schema).
@DougBurke
Copy link
Owner Author

There are now tests, which generate a Vega-Lite schema and then compare it to an on-disk version (a "golden" file in the tasty vernacular). These can then be compared against the Vega-Lite schema as a check (and not all pass, particularly the examples using a custom projection).

It's not really sufficient, but is a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant