# Empty Gantt chart

**URL:** <https://discuss.elastic.co/t/empty-gantt-chart/185011>\
**Category:** Kibana\
**Created:** [June 10, 2019, 3:35pm UTC](https://discuss.elastic.co/t/empty-gantt-chart/185011 "2019-06-10T15:35:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clamorforchange](https://avatars.discourse-cdn.com/v4/letter/c/6a8cbe/32.png) [@clamorforchange](https://discuss.elastic.co/u/clamorforchange)\
**Post date:** [June 10, 2019, 3:35pm UTC](https://discuss.elastic.co/t/empty-gantt-chart/185011/1 "2019-06-10T15:35:43Z")

</div>

Hi everyone, I'm trying to create a Gantt chart from log files that I'm pushing to Elasticsearch via curl. Very similar to this [Gantt Visualization Using Vega](https://discuss.elastic.co/t/gantt-visualization-using-vega/136532)

I'm trying this out on an example entry with a start, an end and a name, however my chart simply stays empty and I don't know what to do.

This is the data block:

```
{
  "_index": "test-index_new_2",
  "_type": "doc",
  "_id": "5Z23QWsBYZIERLZf-_Wv",
  "_version": 1,
  "_score": 1,
  "_source": {
    "name": "second_event",
    "duration_start": "2018-05-20T12:00:00",
    "duration_end": "2018-05-22T12:00:00"
  }

```

And this is my Vega json:

```
{
  $schema: https://vega.github.io/schema/vega-lite/v2.json
  data: {
    url: {        
      %context%: true
      %timefield%: duration_start
      index: test-index_new_2
      body: {
      }
    }
    format: {property: "hits.hits"}
  }
"transform": [
    {"calculate": "datum._source.duration_start", "as": "start"},
    {"calculate": "datum._source.duration_end", "as": "end"}
  ],
"mark": "bar",
"encoding": {
  "y": {"field": "_source.name", "type": "nominal"},
  "x": {"field": "start", "type": "temporal"},
  "x2": {"field": "end", "type": "temporal"}
 }

```

}

This is the result:

 ![04%20PM](https://us1.discourse-cdn.com/elastic/original/3X/8/8/88946a7bb6fe29e161fef96b13a58e7e4f0c7684.png)

If anyone has an idea of what I'm doing wrong, please let me know! Thank you!

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [June 27, 2019, 9:52am UTC](https://discuss.elastic.co/t/empty-gantt-chart/185011/2 "2019-06-27T09:52:28Z")

</div>

Hey @clamorforchange I think you are missing the toDate function, to convert the date string to a date.

```auto
 "transform": [
    {
      "calculate": "toDate(datum._source.duration_start)",
      "as": "start"
    },
    {
      "calculate": "toDate(datum._source.duration_end)",
      "as": "end"
    }
  ],

```

I've just tested with it with two static values and it works:

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "description": "A simple bar chart with ranged data (aka Gantt Chart).",
  "data": {
    "values": [
      {
        "_index": "test-index_new_2",
        "_type": "doc",
        "_id": "5Z23QWsBYZIERLZf-_Wv",
        "_version": 1,
        "_score": 1,
        "_source": {
          "name": "second_event",
          "duration_start": "2018-05-20T12:00:00",
          "duration_end": "2018-05-22T12:00:00"
        }
      },
      {
        "_index": "test-index_new_2",
        "_type": "doc",
        "_id": "5Z23QWsBYZIERLZf-_Wv",
        "_version": 1,
        "_score": 1,
        "_source": {
          "name": "first_event",
          "duration_start": "2018-05-12T12:00:00",
          "duration_end": "2018-05-15T12:00:00"
        }
      }
    ]
  },
  "transform": [
    {
      "calculate": "toDate(datum._source.duration_start)",
      "as": "start"
    },
    {
      "calculate": "toDate(datum._source.duration_end)",
      "as": "end"
    }
  ],
  "mark": "bar",
  "encoding": {
    "y": {
      "field": "_source.name",
      "type": "ordinal"
    },
    "x": {
      "field": "start",
      "type": "temporal"
    },
    "x2": {
      "field": "end"
    }
  }
}

```

You can also omit the `type` option for the `x2` as it's the same type of the `x`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 25, 2019, 9:52am UTC](https://discuss.elastic.co/t/empty-gantt-chart/185011/3 "2019-07-25T09:52:29Z")

</div>

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