Vega-lite: {"title" : null} prints out the string null for axis labelling

Created on 2 Oct 2018  路  6Comments  路  Source: vega/vega-lite

need to set title as null otherwise it automatically uses the Data name ("Response" in this case as the axis label), however this then prints out null as part of the axis title.

https://tinyurl.com/ya5ersw7

Bug

Most helpful comment

Here is what should happen (and we will fix it to make it work)

  • Setting the title to null should remove it
  • Setting the title to "" should remove it
  • In a layered chart, setting one title to something and another title to something else should result in "foo, "bar""
  • In a layered chart setting only one title should set the title to that title
  • In a layered chart setting one title to something and the other to "" or null should set the title to the specified title.

All 6 comments

Here is what should happen (and we will fix it to make it work)

  • Setting the title to null should remove it
  • Setting the title to "" should remove it
  • In a layered chart, setting one title to something and another title to something else should result in "foo, "bar""
  • In a layered chart setting only one title should set the title to that title
  • In a layered chart setting one title to something and the other to "" or null should set the title to the specified title.

@chanwutk The problem with the example above is with errorbars. Can you look into this?

Regardless, we should treat null the same "" and when merging titles we should treat them like undefined.

The fix for now is to set the same title twice.

I create a small example to test this:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.0.0-rc5.json",
  "data": {
    "values": [
      {"Dose": 0.5, "Response": 30778},
      {"Dose": 0.5, "Response": 4000},
      {"Dose": 1, "Response": 30814},
      {"Dose": 1, "Response": 50814},
      {"Dose": 10, "Response": 28355},
      {"Dose": 10, "Response": 35355},
      {"Dose": 75, "Response": 40467},
      {"Dose": 75, "Response": 25467}
    ]
  },
  "layer": [
    {
      "mark": "point",
      "encoding": {
        "x": {"field": "Dose", "type": "ordinal", "title": "Axis title"},
        "y": {"field": "Response", "type": "quantitative", "aggregate": "mean"}
      }
    },
    {
      "mark": "line",
      "encoding": {
        "y": {"field": "Response", "type": "quantitative"},
        "x": {"field": "Dose", "type": "ordinal", "title": null}
      }
    }
  ]
}

Result:
visualization

Should composite mark be the one to handle this problem (remove title when title is null)? Or should we handle this in normalize layer?

This should be handled in the legend merging logic.

Was this page helpful?
0 / 5 - 0 ratings