How to put filter inside Vega visualization scatter plot

hi,
I want to present the plots for documents with "group"==a, and I only want to present documents with the latest date of the time range applied by the dashboard.
How can I do this?
here is my script:

{
  $schema: https://vega.github.io/schema/vega-lite/v2.json

  data: {
    data: table
    url: {
      %context%: true
      %timefield%: Time
      index: data*
      body: {
        size: 10000
        _source: ["X", "Y","group"]
      }
    }
    format: {property: "hits.hits"}
  }
  mark: {type: "square", filled: true, size: 800 }
encoding: {
    x: {
      field: "_source.X"
      type: quantitative
      axis: {title: "X"}
    }
    y: {
      field: "_source.Y"
      type: quantitative
      axis: {title: "Y"}
    }  
}
}

the %context%: true and %timefield%: Time part defines that the ES query used, will be augmented with the filters and query applied to the query bar and the time range used.
If you for example type a search on the query bar like: group : "A" this will filter out all documents with that specific group value also on your vega visualization.
If you need the top X values sorted by the latest date, you can apply a sort operation on the vega ES query on the timefield, something like "sort" : [{ "@timestamp" : {"order" : "desc"}}],

thanks!
but then how do I choose only the top 1 result?

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