vega-lite-api icon indicating copy to clipboard operation
vega-lite-api copied to clipboard

Confused by the predicate in `vl.color().condition()`

Open mhkeller opened this issue 11 months ago • 0 comments

The docs for vl.color().condition() say:

A field definition or one or more value definition(s) with a parameter predicate.

I'm trying to replicate the point_invalid_color using Vega Lite API and based on the language in the doc I would have thought I would do:

vl.color().condition(
  'datum[\'IMDB Rating\'] === null || datum[\'Rotten Tomatoes Rating\'] === null',
  '#aaa'
)

That compiles to:

"color": {
  "condition": [
    "datum['IMDB Rating'] === null || datum['Rotten Tomatoes Rating'] === null"
    "#aaa"
  ]
}

I have to do this instead:

vl.color().condition({
  test: 'datum[\'IMDB Rating\'] === null || datum[\'Rotten Tomatoes Rating\'] === null',
  value: '#aaa'
})

Is this the desired API? If so, I would expect the docs to describe an object with keys of test and value.

mhkeller avatar Aug 02 '23 01:08 mhkeller