Gantt Chart timeline issue with Vega visualization

Hello all,

I'm trying to create a gantt chart using vega but I'm facing issue to get what I want...

Here is my code :

    {

  $schema: https://vega.github.io/schema/vega-lite/v2.json
  title: Gantt test


  data: {
    url: {
      %context%: true
      %timefield%: startime
      index: test*
      body: {
      size: 30
      _source: [
                "startime",
                "endtime",
                "job_name"
            ]
      }
    }
    format: {property: "hits.hits"}
  }
"mark": "bar",
transform: [
        { calculate: "toDate(datum._source['startime'])",  as: "startime"}
        {calculate : "toDate(datum._source['endtime'])",  as: "endtime"}

    ]

"encoding": {
    "y": {
    "sort": {"op": "mean", "field": "startime"},
      "field": "_source.job_name",
      "type": "nominal", 
      "axis": {"title": "job name"}
      },
      
    "x": {
     "timeUnit": "hoursminutes",
     "field": "startime",
     "type": "temporal",
     "axis": {"title": "horaire"}
     }    
    "x2": {
   "timeUnit": "hoursminutes",
      "field": "endtime",
      "type": "temporal"}
  }
}

and here is what I obtain :

It's not so bad but my main issue is that my job starting previous day and ending current day are displayed in the wrong way (see screenshot). I'd like the chart displaying from 19:00 to 05:00 the next day but can't figure out how to do this...
for exemple the job pxmur_q_eod_acc is starting around 22:00 and ending around 00:30 but the visualization is reversing the data...

Any idea would be very welcome,

Thanks in advance,

1 Like

Hi there,

I fixed my issue replacing my time unit as follow :

"x": {
 "timeUnit": "yearmonthdatehoursminutes",
#      "aggregate": "mean",
 "field": "startime",
 "type": "temporal",
 "axis": {format: '%H:00',"title": "horaire"}
 }
 
"x2": {
   "timeUnit": "yearmonthdatehoursminutes",
  "field": "endtime",
  "type": "temporal"},
 "color": {
  "value": "#33ccff"
  }

Now another concern would be to filter the timeline from d-1 to d.

Any idea ?
something like :

{ filter: { field: 'startime', timeUnit: 'yearmonthdatehoursminutes', 
                    range: [{day: 'previous day'},
                           {day: 'current day'}]
                  }
        }

Thanks for your help

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.