# Create a Boxplot with Elastic Index

**URL:** <https://discuss.elastic.co/t/create-a-boxplot-with-elastic-index/366344>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [September 10, 2024, 4:44pm UTC](https://discuss.elastic.co/t/create-a-boxplot-with-elastic-index/366344 "2024-09-10T16:44:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brettmwerner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brettmwerner/32/137471_2.png) [@brettmwerner](https://discuss.elastic.co/u/brettmwerner)\
**Post date:** [September 10, 2024, 4:44pm UTC](https://discuss.elastic.co/t/create-a-boxplot-with-elastic-index/366344/1 "2024-09-10T16:44:54Z")

</div>

I'm trying to use Vega to create a boxplot with my elastic index data. My Vega code is here.

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "height": 400,
  "width": 100
  "title": "Bootstrapped Model Metric Comparisons",
  data: {
    name: boxplot_data
    url: {
      %context%: true
      index: boxplot_data_new
      body: {
        size: 100
        _source: ["Model", "Category", "Metric_Val"]
      }
    }
    # We only need the content of hits.hits array
    format: {property: "hits.hits"}
    "transform":[
    {
      "type":"formula",
      "expr":"datum._source.Category",
      "as":"category"
    },
    {
      "type":"formula",
      "expr":"datum._source.Metric_Val+0",
      "as":"metric_value"
    }
  ]
  }
  
 "mark": {
  "type": "boxplot",
  "extent": 1.5
  }
    
  "encoding": {
    "column": {
      "field": "_source.Category",
      "type": "nominal",
      "title": "Category"},
    "y": {
      "field": "_source.Metric_Val",
      "type": "quantitative",
      "title": "Metric"
    },
    "x": {
      "field": "_source.Model",
      "type": "nominal",
      "title": false,
      "axis": {"labels": false}
    },
    "color": {
      "field": "_source.Model",
      "type": "nominal",
      "title": ""
    }
  }
}

```

My elastic index data looks like this.

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 30,
    "max_score": 1,
    "hits": [
      {
        "_index": "boxplot_data_new",
        "_id": "kYbYyJEB_-YoQLLCVWnv",
        "_score": 1,
        "_source": {
          "Model": "Model 1",
          "Category": "Category 1",
          "Metric_Val": 0
        }
      },
      {
        "_index": "boxplot_data_new",
        "_id": "kobYyJEB_-YoQLLCVWnw",
        "_score": 1,
        "_source": {
          "Model": "Model 1",
          "Category": "Category 1",
          "Metric_Val": 0.25
        }
      },

```

But I'm getting the two errors shown below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/9/d92bf96b5f4079911d396b9d815d6634df171ada.png)

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [September 11, 2024, 4:13pm UTC](https://discuss.elastic.co/t/create-a-boxplot-with-elastic-index/366344/2 "2024-09-11T16:13:55Z")

</div>

Hi @brettmwerner,

Welcome! The `Infinite extent for field <field>` error is normally an indication that the field can't be resolved or found. Can you check and share the output of the Vega datasets screen under the debug tab?

Having a rough guess without seeing the Vega dataset, I would assume that `_source` is not needed in your encoding mappings since you've set the `format` property in your `data` field. But I am going off of [these examples](https://www.elastic.co/search-labs/blog/kibana-vega-building-advanced-visualizations) which are slightly different.

---

<div class="post-metadata">

**Author:** ![brettmwerner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brettmwerner/32/137471_2.png) [@brettmwerner](https://discuss.elastic.co/u/brettmwerner)\
**Post date:** [September 13, 2024, 4:29pm UTC](https://discuss.elastic.co/t/create-a-boxplot-with-elastic-index/366344/3 "2024-09-13T16:29:26Z")

</div>

Thanks I got this fixed by adding the "scale": {"domain": [0,1]} to my "y" encoding. And I suppressed the "Maximum optimization runs(5) reached error" suppressed by adding "config":{  
"kibana": {"hideWarnings": true}  
}.

Thanks for your reply!
