Vega-lite: x2 title ignored when titles of both x and x2 are specified

Created on 14 May 2018  路  3Comments  路  Source: vega/vega-lite

x2 axis title in stacked bar is hidden when x has title

{
  "mark": "bar",
  "encoding": {
    "y": {
      "field": "question",
      "type": "nominal"
    },
    "x": {
      "field": "percentage_start",
      "type": "quantitative",
      "title": "percentage_start" //<----  change chart view (intentionally)

    },
    "color": {
      "field": "type",
      "type": "nominal"
    },
    "x2": {
      "field": "percentage_end",
      "type": "quantitative",
       "title": "percentage_end" //<----  do not change chart view (expected that both titles would show)


    }
  },
  "data": {
    "values": [
      {
        "question": "Question 3",
        "percentage_start": 10,
        "percentage_end": 50,
        "type": "Agree"
      },
      {
        "question": "Question 3",
        "percentage_start": 50,
        "percentage_end": 70,
        "type": "Strongly agree"
      }
    ]
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v2.4.1.json"
}

export 1
without title
export

live demo https://iliatimofeev.github.io/sharer/testreport/#diverging_stacked_bar_chart

Area - Visual Encoding

Most helpful comment

in case of titles on both x scales that behavior seems unexpected.

Good point.

All 3 comments

I think this is actually intended behavior. You are manually setting the title for X and that overrides implicit titles. X2 belongs to X so we don't treat them separately.

Sound logical but in case of titles on both x scales that behavior seems unexpected.

in case of titles on both x scales that behavior seems unexpected.

Good point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paintdog picture paintdog  路  4Comments

kanitw picture kanitw  路  3Comments

learnwithratnesh picture learnwithratnesh  路  4Comments

infai-feineis picture infai-feineis  路  3Comments

domoritz picture domoritz  路  4Comments