Plotting the result of nested aggregations in kibana

I have an index which has nested data types.
when I am running this query

{
  "size":0,
  "aggs": {
    "tenant": {
      "nested": {
        "path": "custom_details.tenantname"
      },
      "aggs": {
        "count1": {
          "terms": {
            "field": "custom_details.tenantname.value.keyword"
          }
        }
      }
    }
  }
}

I am getting the aggregation results as this:

{
  "took" : 9,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 6,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "tenant" : {
      "doc_count" : 18,
      "count1" : {
        "doc_count_error_upper_bound" : 0,
        "sum_other_doc_count" : 0,
        "buckets" : [
          {
            "key" : "fis",
            "doc_count" : 3
          },
          {
            "key" : "abc",
            "doc_count" : 2
          },
          {
            "key" : "mno",
            "doc_count" : 2
          },
          {
            "key" : "123",
            "doc_count" : 2
          },
          {
            "key" : "btw",
            "doc_count" : 2
          },
          {
            "key" : "iqr",
            "doc_count" : 2
          },
          {
            "key" : "rms",
            "doc_count" : 2
          },
          {
            "key" : "pqr",
            "doc_count" : 1
          },
          {
            "key" : "xyz",
            "doc_count" : 1
          },
          {
            "key" : "acb",
            "doc_count" : 1
          }
        ]
      }
    }
  }
}

I would like to plot these aggregated results as a pie chart in kibana. But I am unable to select the custom_details.tenantname.value.keyword field as it is a nested type field.

I am new to Elasticsearch and kibana. Any help in plotting the aggregation result will be very helpful.
PS: Is there a way to give the query and get plot as output?

Unfortunately it's not possible to use the pie chart for this - but you should be able to get it to work using vega: Vega | Kibana Guide [7.15] | Elastic

It basically allows you to use your existing query, then define a vega spec to render the chart. This is an example of a pie chart in vega, you should be able to combine it with your query: Pie chart in vega