Vega-lite: Changes uncovered by Altair 4

Created on 28 Nov 2019  路  16Comments  路  Source: vega/vega-lite

In https://github.com/altair-viz/altair/pull/1818 I begun the process of making Altair wrappers for Vega-Lite 4.0.0-beta.12. This introduced a couple test failures in examples due to properties that are no longer allowed by the schema.

To add back

  • [x] https://altair-viz.github.io/gallery/ridgeline_plot.html fails because bounds is no longer an allowed property of TopLevelUnitSpec.

    • Ham: this one we should add back.
  • [x] Any charts that use width or height in the view configuration break, because they are no longer allowed properties of ViewConfig

    • Ham: this one we should add back, perhaps as deprecated configs.

Need to decide whether we want to add these back

This is the extent of the issues that came up in a first pass!

Bug P1

All 16 comments

I'm adding bounds and config.view.width/height back in https://github.com/vega/vega-lite/pull/5624.

However, I don't think we should do columns as it's much better to specify: alt.Facet('Series', columns=2).

For rangeStep, width.step is also a much better syntax, so I slightly prefer not to add it back.

Thanks!

:)

One question: currently altair's default theme uses config.width/config.height. Would you prefer me to change that to config.continuousWidth/continuousHeight in V4, to move away from deprecated configs?

Yes, please. :)

Changing scale.rangeStep to width.step in Altair version 4.0.1 caused this for me:

Error: Unrecognized signal name: "x_step"
    at Object.error (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-util/build/vega-util.js:22:11)
    at Scope$1.prototype$1.getSignal (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:3342:16)
    at /home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:84:65
    at Array.forEach (<anonymous>)
    at parseExpression (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:82:17)
    at Scope$1.prototype$1.parseLambdas (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:3360:15)
    at parseSpec (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:2972:11)
    at parseMark (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:2136:13)
    at parseAxis (/home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:2934:12)
    at /home/eharkins/miniconda2/envs/altairtest2/lib/vega-cli/node_modules/vega-parser/build/vega-parser.js:2960:44

@eharkins Can you send us the Vega-Lite spec?

@domoritz Here it is with width.step (as output by chart.save(format="json")):

{
  "config": {
    "view": {
      "continuousWidth": 400,
      "continuousHeight": 300
    }
  },
  "layer": [
    {
      "data": {
        "name": "data-b5d82698a6af51f8073087a9d6f6c082"
      },
      "mark": "rect",
      "encoding": {
        "x": {
          "type": "ordinal",
          "field": "x"
        }
      }
    },
    {
      "data": {
        "name": "data-bc8e995691956dedcd24653f7761f783"
      },
      "mark": "tick",
      "encoding": {
        "x": {
          "type": "ordinal",
          "field": "position"
        }
      },
      "width": {
        "step": 3
      }
    }
  ],
  "$schema": "https://vega.github.io/schema/vega-lite/v4.0.2.json",
  "datasets": {
    "data-b5d82698a6af51f8073087a9d6f6c082": [
      {
        "0": 0
      }
    ],
    "data-bc8e995691956dedcd24653f7761f783": [
      {
        "position": 0
      }
    ]
  }
}

Can you create a minimal example that shows the issue?

Yes @domoritz I'll try stripping things down until it's as bare of an altair chart as possible that still gets the error with width.step. Thanks for your response!

@domoritz I updated the above spec to a minimal example. I'm almost positive that it's because I added width.step to one sub layer of the chart and then added it to another chart in altair using + in python. If I move width.step to the top level LayerChart resulting from the +, the error goes away.

So maybe it's just a matter of adding a helpful message for width.step like this one for chart.background:

ValueError: Objects with "background" attribute cannot be used within LayerChart. Consider defining the background attribute in the LayerChart object instead.

I don't get an error in the Vega editor try me. Could it be that the issue is fixed in the latest VL version?

Yes it could be. It seems like Altair 4.0.1 is using VegaLite 4.0.2 and there have been subsequent releases of VegaLite so perhaps one of those contains a fix for this.

The current release of Altair uses Vega-Lite 4.0.2, so it's possible that errors you see in Altair output won't reproduce in the Vega editor (which I believe is at 4.4 at the moment)

Was this page helpful?
0 / 5 - 0 ratings