Scripted Fields in kibana not working

It's possible to do this with the Time Series Visual Builder

I have used the following data to test against:

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 0,
  "somme": 0
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 0,
  "somme": 0
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 0,
  "somme": 0
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

POST discuss-117661/doc
{
  "@timestamp": "2018-01-30T14:25:04",
  "Return_Code": 1,
  "somme": 1
}

Create a new visualization using the Time Series Visual Builder.

First, select the Panel Options tab and enter the index pattern you would want to use.

Then, back on the Data tab, select use the Filter Ratio Aggregation. For the numerator, we will select the successful documents using Return_Code:1