# How to combine multi timelines in one vega graph using layers

**URL:** <https://discuss.elastic.co/t/how-to-combine-multi-timelines-in-one-vega-graph-using-layers/266932>\
**Category:** Kibana\
**Created:** [March 11, 2021, 11:19am UTC](https://discuss.elastic.co/t/how-to-combine-multi-timelines-in-one-vega-graph-using-layers/266932 "2021-03-11T11:19:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bab/32/86201_2.png) [@bab](https://discuss.elastic.co/u/bab)\
**Post date:** [March 11, 2021, 11:19am UTC](https://discuss.elastic.co/t/how-to-combine-multi-timelines-in-one-vega-graph-using-layers/266932/1 "2021-03-11T11:19:07Z")

</div>

hi experts, am trying to combine multi time lines Vega graphic to one but i'm stock, can anyone check my code, where i missed.

```
{
  $schema: https://vega.github.io/schema/vega-lite/v2.json
  data: {
    url: {
      %context%: true
      %timefield%: Date
      index: index_tev_test
      body: {
        size: 4000
        _source: [
          Date,
          Basis,
          FT1,
          FT2
        ]
      }
    }
    format: {
      property: hits.hits
    }
  }
  mark: {
    type: line
    point: true
  }
  encoding: {
    x: {
      field: _source.Date
      type: nominal
      sort: 0
      axis: {
        title: Date
      }
    }
    order: {
      field: Date
    }
  }
  layer: [
    {
      mark: line
      encoding: {
        y: {
          field: _source.Basis
          type: nominal
          axis: {
            title: Basis
          }
        }
        color: {
          value: red
        }
      }
    }
    {
      mark: line
      encoding: {
        y: {
          field: _source.FT1
          type: nominal
          axis: {
            title: FT1
          }
        }
        color: {
          value: blue
        }
      }
    }
    {
      mark: line
      encoding: {
        y: {
          field: _source.FT2
          type: nominal
          axis: {
            title: FT2
          }
        }
        color: {
          value: green
        }
      }
    }
  ]
}

```

the result for the above code is:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/1/a1ec4872a6f73356be2da1d5b336bef62e2494aa.png)

---

<div class="post-metadata">

**Author:** ![nickofthyme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickofthyme/32/60032_2.png) [@nickofthyme](https://discuss.elastic.co/u/nickofthyme)\
**Post date:** [March 31, 2021, 9:30pm UTC](https://discuss.elastic.co/t/how-to-combine-multi-timelines-in-one-vega-graph-using-layers/266932/2 "2021-03-31T21:30:37Z")

</div>

There seems to be something wrong with your `x` encoding as the value is `undefined`. Could be that the `type` as a date should be [`temporal`](https://vega.github.io/vega-lite/docs/type.html#temporal) not [`nominal`](https://vega.github.io/vega-lite/docs/type.html#nominal).

Could you provide a demo on the Vega Editor, like [this](https://vega.github.io/editor/#/url/vega-lite/N4KABGBEAkDODGALApgWwIaQFxUQFzwAdYsB6UgN2QHN0A6agSz0QFcAjOxge1IRQyUa6ALQAbZskoBWOgCtY3AHaQANOCgATZAgBOjQnh4qckAMp5u8ANZhC++DrDcAZmGlgAKsiRgAwtyohOhKjE7cVLpejKjIYADuzIhgAIKR6NQ6dGoakJroeJg4wJCsumLYWgXofJY2sHTwsBSQAL7qEJBi6ACeyLqVANoaEKAQ41AYutaVXYxKyDkTnchK8Nya89SVY8udAB47kC5hYpqz+XiLqlB4PYSLpldB3LroFe0jy5A9RyfIZ1m9kYjjUt3ujygAEdWCEjIUjFQ2h09lB1mJXn9TudTLAeqh2NwKjdIHcHrMlIF5u82l8IK0vp8JrsJpApjNTLpWGJrnSoKt1pslNtinzOr9isdsUCHNcoBlqLphFdZrEQsixVBYIwAF6QkoUd6sSEAJiZqMg6Mxkv+gNx+MJHz5DImLrAAF0QK0gA), using a sample raw dataset with `values`, something like...

```auto
{
  data: {"name": "table", "values": [12, 23, 47, 6, 52, 19]}
}

```

Then I can take a closer look.

---

<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:** [April 28, 2021, 9:30pm UTC](https://discuss.elastic.co/t/how-to-combine-multi-timelines-in-one-vega-graph-using-layers/266932/3 "2021-04-28T21:30:55Z")

</div>

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