1

I have this code

    {
  "data": {"name": "dataset"},
  "mark": {
    "type": "bar",
    "cornerRadius": 5
  },
  "encoding": {
    "y": {
      "field": "Space_CON",
      "type": "ordinal",
      "axis": {"title": "Space"}
    },
    "yOffset": {"field": "Typ"},
    "color": {"field": "Typ"},
    "x": {
      "field": "start_n",
      "type": "quantitative",
      "axis": {"title": "Hour"}
    },
    "x2": {"field": "end_n"}
  }
}

I want insert two vertical red lines coresponding with X axe values 7 and 17 how I can do this ? i tried something with layers but still faild on erors

can anybody helps me ?

Sample data:

sample data

Expected result: expected result

Davide Bacci
  • 16,647
  • 3
  • 10
  • 36
milenjao
  • 93
  • 5
  • 18

1 Answers1

1

I can't use your sample data as it is an image. I will use the example I pointed you to last time to illustrate how to do this and you should be able to follow along. Please mark your last question as solved.

enter image description here

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart with ranged data (aka Gantt Chart).",
  "width":500,
  "data": {
    "values": [
      {"task": "A", "start": 1, "end": 3},
      {"task": "B", "start": 3, "end": 8},
      {"task": "C", "start": 8, "end": 10}
    ]
  },
  "layer": [
    {
      "mark": "bar",
      "encoding": {
        "y": {"field": "task", "type": "ordinal"},
        "x": {"field": "start", "type": "quantitative"},
        "x2": {"field": "end"}
      }
    },
    {
      "mark": "rule",
      "encoding": {
        "x": {"datum": 3, "type": "quantitative"},
        "stroke": {"value": "red"}
      }
    },
    {
      "mark": "rule",
      "encoding": {
        "x": {"datum": 7, "type": "quantitative"},
        "stroke": {"value": "red"}
      }
    }
  ]
}
Davide Bacci
  • 16,647
  • 3
  • 10
  • 36