How to combine multi timelines in one vega graph using layers

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:

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 not nominal.

Could you provide a demo on the Vega Editor, like this, using a sample raw dataset with values, something like...

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

Then I can take a closer look.

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