# Vega scatterplot with scripted field

**URL:** https://discuss.elastic.co/t/vega-scatterplot-with-scripted-field/267613
**Category:** Kibana
**Created:** [March 18, 2021, 7:42am UTC](https://discuss.elastic.co/t/vega-scatterplot-with-scripted-field/267613 "2021-03-18T07:42:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shalhevet](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Shalhevet](https://discuss.elastic.co/u/Shalhevet)
#### Post date: [March 18, 2021, 7:42am UTC](https://discuss.elastic.co/t/vega-scatterplot-with-scripted-field/267613/1 "2021-03-18T07:42:45Z")

</div>

Hi,  
I am trying to use a scripted field ("RGBstring") for my visualization but it doesn't work.  
I can't find the reason.  
this is the script:

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "data": {
    "url": {
      "%context%": true,
      "index": "rgb-data*",
      "body": {
        "size": 10000,
        "_source": [
          "Xlocation",
          "Ylocation",
          "rgb.R",
          "rgb.G",
          "rgb.B",
          "group"
        ],
        "script_fields": {
          "RGBstring": {
            "script": {
              "lang": "painless",
              "source": "'rgb('+doc['rgb.R'].value+','+doc['rgb.G'].value+','+doc['rgb.B'].value+')'"
          }
        }
      }
    }
    },
    "format": {"property": "hits.hits"}
  },
  "mark": {"type": "square", "filled": true, "size": 1200},
  "encoding": {
    "x": {
      "field": "_source.Xlocation",
      "type": "quantitative",
      "axis": {"title": "X Location"}
    },
    "y": {
      "field": "_source.Ylocation",
      "type": "quantitative",
      "axis": {"title": "Y Location"}
    },
    "color": {"field": "fields.RGBstring", "scale": null},
    "tooltip": {"field": "_source.group"}
  }
}

```

and after running it I get:  
Internal Server Error

---

<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: [March 22, 2021, 10:48am UTC](https://discuss.elastic.co/t/vega-scatterplot-with-scripted-field/267613/2 "2021-03-22T10:48:39Z")

</div>

Hi, is there any additional information about the error?  
Can you post a screenshot of it?  
Can you check also if the network request was successful and returned correctly the RGBstring field?  
Does it happens if you reduce the size of they query to just a few items?

---

<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 19, 2021, 10:48am UTC](https://discuss.elastic.co/t/vega-scatterplot-with-scripted-field/267613/3 "2021-04-19T10:48:44Z")

</div>

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