# Vega-lite, create a forecast similar as lens visualization

**URL:** <https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [January 20, 2023, 8:42am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572 "2023-01-20T08:42:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![plus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plus/32/97297_2.png) [@plus](https://discuss.elastic.co/u/plus)\
**Post date:** [January 20, 2023, 8:42am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/1 "2023-01-20T08:42:01Z")

</div>

Hello everyone  
I have a question with vega-lite and I don't know how to follow up. I checked on lens I can see data from last 2 hours and next 4 hours on the same graphic (a forecast job has been launched previously to get that data), for example

 ![Lens - mixed old and forecast values](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c7984b7376089e026b6612da9805f399be44d2d9.png)

but on vega lite if I try to do the same, using the request that is used on Lens, I´m not able to replicate that graphic (lens for aggs use percentiles and I use terms value)

**this is the Lens request**

```auto
{
  "aggs": {
    "0": {
      "date_histogram": {
        "field": "timestamp",
        "fixed_interval": "10m",
        "time_zone": "Europe/Madrid",
        "extended_bounds": {
          "min": 1674194400000,
          "max": 1674223519676
        }
      },
      "aggs": {
        "1": {
          "percentiles": {
            "field": "actual",
            "percents": [
              50
            ]
          }
        },
        "2": {
          "percentiles": {
            "field": "forecast_prediction",
            "percents": [
              50
            ]
          }
        }
      }
    }
  },
  "size": 0,
  "fields": [
    {
      "field": "bucket_influencers.timestamp",
      "format": "date_time"
    },
    {
      "field": "earliest_record_timestamp",
      "format": "date_time"
    },
    {
      "field": "exponential_average_calculation_context.latest_timestamp",
      "format": "date_time"
    },
    {
      "field": "forecast_create_timestamp",
      "format": "date_time"
    },
    {
      "field": "forecast_end_timestamp",
      "format": "date_time"
    },
    {
      "field": "forecast_expiry_timestamp",
      "format": "date_time"
    },
    {
      "field": "forecast_start_timestamp",
      "format": "date_time"
    },
    {
      "field": "last_data_time",
      "format": "date_time"
    },
    {
      "field": "latest_empty_bucket_timestamp",
      "format": "date_time"
    },
    {
      "field": "latest_record_time_stamp",
      "format": "date_time"
    },
    {
      "field": "latest_record_timestamp",
      "format": "date_time"
    },
    {
      "field": "latest_result_time_stamp",
      "format": "date_time"
    },
    {
      "field": "latest_sparse_bucket_timestamp",
      "format": "date_time"
    },
    {
      "field": "log_time",
      "format": "date_time"
    },
    {
      "field": "model_size_stats.log_time",
      "format": "date_time"
    },
    {
      "field": "model_size_stats.timestamp",
      "format": "date_time"
    },
    {
      "field": "timestamp",
      "format": "date_time"
    }
  ],
  "script_fields": {},
  "stored_fields": [
    "*"
  ],
  "runtime_mappings": {},
  "_source": {
    "excludes": []
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "bool": {
            "should": [
              {
                "match_phrase": {
                  "partition_field_value": "hidden text"
                }
              }
            ],
            "minimum_should_match": 1
          }
        },
        {
          "range": {
            "timestamp": {
              "format": "strict_date_optional_time",
              "gte": "2023-01-20T06:00:00.000Z",
              "lte": "2023-01-20T14:05:19.676Z"
            }
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  }
}

```

**This is my current vega lite code** (index field and partition\_field\_value have been modified due to are sensible information)

- As I removed _"%context%": true and "%timefield%": "timestamp"_ under URL, time filter doesn't works and it's defined the datetime under query - bool ...

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": "push notifications",
  "data": {
    "url": {
      "index": ".ml-anomalies-cxx-xxx_xxx_xxx_movil",
      "body": {
        "_source": ["actual", "forecast_prediction", "timestamp"],
        "size": 0,
        "query": {
          "bool": {
            "must": [{"range": {
              "timestamp": {
                "gte": "2023-01-20T00:30:00.000Z",
                "lte": "2023-01-20T20:00:00.000Z",
                "format": "strict_date_optional_time"}
            }}]
          }
        },
        "aggs": {
        "bydate": {
          "date_histogram": {
              "field": "timestamp",
              "fixed_interval": "1m",
              "min_doc_count": 1
            },
            "aggs": { 
              "elvalue": {"terms": {"field": "actual","size": 1}},
              "forecast": {"terms": {"field": "forecast_prediction","size": 1}}
            }
          }
        }
      }
    }, "format": {"property": "aggregations.bydate.buckets"}
  },
  "enconding": {
    "x": {
      "axis": {"format": "hoursminutes"},
      "field": "key",
      "title": "asdf",
      "type": "temporal"
    }
  },
  "transform": [
    {"flatten": ["elvalue.buckets"],"as": ["currentvalue"]},
    {"flatten": ["forecast.buckets"],"as": ["futurvalue"]}
  ],  
  "layer": [
    {
      "mark": {
        "interpolate": "monotone", 
        "opacity": 0.5,
        "tooltip": true,
        "type": "line"
      },
      "encoding": {
        "color": {
           "type": "point", "value": "orange"},
        "y": {
          "field": "futurvalue.key", 
          "type": "quantitative"
        },
        "x": {
          "field": "key", 
          "format": "hoursminutes",
          "title": "sfasdfasdf",
          "type": "temporal"
        },
        "tooltip": [
          {"field":"key", "type": "temporal", "format": "%d/%m/%y %H:%M", "title": "fecha"},
          {"field":"futurvalue.key", "type": "quantitative", "format": ",.2r", "title": "valor forecast"}
        ]
      }
    },
    {
      "mark": {
        "interpolate": "monotone", 
        "opacity": 1,
        "tooltip": true,
        "type": "line"
      },
      "encoding": {
        "color": {
           "type": "point", "value": "black"},
        "y": {
          "field": "currentvalue.key", 
          "type": "quantitative",
          "title": "valores"
        },
        "x": {
          "field": "key", 
          "format": "%d/%m/%y %H:%M",
          "title": "",
          "type": "temporal"
        },
        "tooltip": [
          {"field":"key", "type": "temporal", "format": "%d/%m/%y %H:%M", "title": "fecha"},
          {"field":"currentvalue.key", "type": "quantitative", "format": ",.2r", "title": "valor_actual"}
        ]
      }
    }
  ]
}

```

 ![vega lite graphic, not forecast on x-axis](https://us1.discourse-cdn.com/elastic/original/3X/d/8/d88221c16bc189e7a04ed5ba59789699315ca07a.png)

What I'm doing wrong? or isn't possible to create a graphic with forecast data on vega-lite?  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![plus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plus/32/97297_2.png) [@plus](https://discuss.elastic.co/u/plus)\
**Post date:** [January 20, 2023, 1:33pm UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/2 "2023-01-20T13:33:46Z")

</div>

Hello I would to add more information, as you can see the response of query shows data 3 hours next the current time.  
why if response shows the forecast values, example on **"key\_as\_string": "2023-01-20T16:00:00.000Z",** , these data is not printed on the graphic?

```auto
{
  "took": 32,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 409,
    "max_score": 1,
    "hits": [
      {
        "_index": ".ml-xxxxxxvil",
        "_id": "xxxxxxxx_forecast_kZF7wIUBHKUCZOXpiX77_1674216180000_60_0_-142261168984546803792043607818611473090_26",
        "_score": 1,
        "_source": {
          "forecast_prediction": 194.23115257143547,
          "forecast_id": "kZF7wIUBHKUCZOXpiX77",
          "timestamp": 1674216180000
        }
      },
      {
        "_index": ".xxxxxx_movil",
        "_id": "xxxxxxxxorecast_kZF7wIUBHKUCZOXpiX77_1674216240000_60_0_-142261168984546803792043607818611473090_26",
        "_score": 1,
        "_source": {
          "forecast_prediction": 194.30067612773456,
          "forecast_id": "kZF7wIUBHKUCZOXpiX77",
          "timestamp": 1674216240000
        }
      },
      {
        "_index": ".xxxxxxxxmovil",
        "_id": "rxxxxxxxxxorecast_kZF7wIUBHKUCZOXpiX77_1674216300000_60_0_-142261168984546803792043607818611473090_26",
        "_score": 1,
        "_source": {
          "forecast_prediction": 194.3705109907569,
          "forecast_id": "kZF7wIUBHKUCZOXpiX77",
          "timestamp": 1674216300000
        }
      },
      {
        "_index": ".xxxxxxml_rvia_movil",
        "_id": "rxxxxxxxforecast_kZF7wIUBHKUCZOXpiX77_1674216360000_60_0_-142261168984546803792043607818611473090_26",
        "_score": 1,
        "_source": {
          "forecast_prediction": 194.43923830329265,
          "forecast_id": "kZF7wIUBHKUCZOXpiX77",
          "timestamp": 1674216360000
        }
      }
    ]
  },
  "aggregations": {
    "bydate": {
      "buckets": [
        {
          "key_as_string": "2023-01-20T12:00:00.000Z",
          "key": 1674216000000,
          "doc_count": 31,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 1223,
                "doc_count": 2
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 164.99888903776827,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 608.3046952476328,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T12:10:00.000Z",
          "key": 1674216600000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 8,
            "buckets": [
              {
                "key": 161,
                "doc_count": 1
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 159.83954788767812,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 596.8168512280893,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T12:20:00.000Z",
          "key": 1674217200000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 7,
            "buckets": [
              {
                "key": 222,
                "doc_count": 2
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 153.18075168672294,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 580.6921859353731,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T12:30:00.000Z",
          "key": 1674217800000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 7,
            "buckets": [
              {
                "key": 191,
                "doc_count": 2
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 145.48343529131273,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 567.0365202349564,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T12:40:00.000Z",
          "key": 1674218400000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 8,
            "buckets": [
              {
                "key": 205,
                "doc_count": 2
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 137.2202102610587,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 552.6512883019194,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T12:50:00.000Z",
          "key": 1674219000000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 7,
            "buckets": [
              {
                "key": 185,
                "doc_count": 2
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 128.8304877247488,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 539.1988044604327,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T13:00:00.000Z",
          "key": 1674219600000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 6,
            "buckets": [
              {
                "key": 167,
                "doc_count": 3
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 120.64197367192736,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 520.9446034231962,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T13:10:00.000Z",
          "key": 1674220200000,
          "doc_count": 30,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 20
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 8,
            "buckets": [
              {
                "key": 164,
                "doc_count": 2
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 112.95890595390381,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 19,
            "buckets": [
              {
                "key": 507.99144403662604,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T13:20:00.000Z",
          "key": 1674220800000,
          "doc_count": 13,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 11
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 1,
            "buckets": [
              {
                "key": 146,
                "doc_count": 1
              }
            ]
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 10,
            "buckets": [
              {
                "key": 112.23011188337635,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 10,
            "buckets": [
              {
                "key": 506.7234591587502,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T13:30:00.000Z",
          "key": 1674221400000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 128.7650045336486,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 519.314593173476,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T13:40:00.000Z",
          "key": 1674222000000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 123.82139518074963,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 509.9725080929261,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T13:50:00.000Z",
          "key": 1674222600000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 119.8501076686533,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 502.3113416765282,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T14:00:00.000Z",
          "key": 1674223200000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 116.72710114890398,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 496.0677985400145,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T14:10:00.000Z",
          "key": 1674223800000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 114.57622338643061,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 487.9892786989142,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T14:20:00.000Z",
          "key": 1674224400000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 113.5289721170205,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 483.6799850660867,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T14:30:00.000Z",
          "key": 1674225000000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 113.44854252019219,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 481.0127164962853,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T14:40:00.000Z",
          "key": 1674225600000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 113.79774419133545,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 480.296730108848,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T14:50:00.000Z",
          "key": 1674226200000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 115.18188181279268,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 480.18356329421886,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T15:00:00.000Z",
          "key": 1674226800000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 117.18125657118058,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 481.2100658168749,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T15:10:00.000Z",
          "key": 1674227400000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 119.32010108137749,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 480.94800651482535,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T15:20:00.000Z",
          "key": 1674228000000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 121.12551323481631,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 481.00487322395907,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T15:30:00.000Z",
          "key": 1674228600000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 122.46981650637355,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 481.0449446205719,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T15:40:00.000Z",
          "key": 1674229200000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 123.89502309183081,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 481.1469703144203,
                "doc_count": 1
              }
            ]
          }
        },
        {
          "key_as_string": "2023-01-20T15:50:00.000Z",
          "key": 1674229800000,
          "doc_count": 10,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 10
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 126.01997790680613,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 9,
            "buckets": [
              {
                "key": 485.7819880609802,
                "doc_count": 1
              }
            ]
          }
        },
        {
          **"key_as_string": "2023-01-20T16:00:00.000Z",**
          "key": 1674230400000,
          "doc_count": 5,
          "elfuturelower": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "key": 0,
                "doc_count": 5
              }
            ]
          },
          "elretardervalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          },
          "elfuturvalue": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 4,
            "buckets": [
              {
                "key": 129.4634341686073,
                "doc_count": 1
              }
            ]
          },
          "elfutureupper": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 4,
            "buckets": [
              {
                "key": 487.79840132163906,
                "doc_count": 1
              }
            ]
          }
        }
      ]
    }
  }
}

```

 ![Screenshot 2023-01-20 at 14.22.05](https://us1.discourse-cdn.com/elastic/original/3X/6/b/6b5c569eee0b642ba593d913a70b47df018ed803.png)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![plus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plus/32/97297_2.png) [@plus](https://discuss.elastic.co/u/plus)\
**Post date:** [January 24, 2023, 1:42pm UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/3 "2023-01-24T13:42:54Z")

</div>

Hello, anyone could help me? Thanks

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [January 25, 2023, 10:34am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/4 "2023-01-25T10:34:11Z")

</div>

Hi @plus

welcome to the Kibana community.  
in Lens when a time shift is enabled, there's a response manipulation on top of the raw ES response, what is probably why it's not that easy to reproduce in Vega lite.

---

<div class="post-metadata">

**Author:** ![plus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plus/32/97297_2.png) [@plus](https://discuss.elastic.co/u/plus)\
**Post date:** [January 25, 2023, 11:18am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/5 "2023-01-25T11:18:43Z")

</div>

> [@Marco\_Liberati](#):
>
> in Lens when a time shift is enabled, there's a response manipulation on top of the raw ES response, what is probably why it's not that easy to reproduce in Vega lite.

But could there a way to reproduce in vega lite? Do you know someone whom could help me to deploy it? Thanks

---

<div class="post-metadata">

**Author:** ![plus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plus/32/97297_2.png) [@plus](https://discuss.elastic.co/u/plus)\
**Post date:** [January 31, 2023, 12:11pm UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/6 "2023-01-31T12:11:47Z")

</div>

Good morning @Marco_Liberati do you have any update if is possible to do this forecast visualization with VegaLite?

Thanks.

---

<div class="post-metadata">

**Author:** ![plus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plus/32/97297_2.png) [@plus](https://discuss.elastic.co/u/plus)\
**Post date:** [February 15, 2023, 9:53am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/7 "2023-02-15T09:53:46Z")

</div>

any update? thanks

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [February 15, 2023, 10:05am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/8 "2023-02-15T10:05:12Z")

</div>

Hi @plus

will have a look at this next week as it's not trivial and requires some time to re-align the shifted data in Vega via transforms.

---

<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:** [March 15, 2023, 10:05am UTC](https://discuss.elastic.co/t/vega-lite-create-a-forecast-similar-as-lens-visualization/323572/9 "2023-03-15T10:05:53Z")

</div>

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