Plot array stored in elasticsearch

i have data store in elasticsearch like this:

[
    {
        "ts":"2023-1-1",
        "kpi": [
            {
                "name": "kpi-1",
                "data":{
                    "x": [0,1,3,6],
                    "y": [12,45,78,100]
                }

            },
            {
                "name": "kpi-2",
                "data":{
                    "x": [0.1,1.6,3.7,6.9],
                    "y": [100,415,178,200]
                }
            }
        ]
    },
    {
        "ts":"2023-1-2",
        "kpi": [
            {
                "name": "kpi-1",
                "data":{
                    "x": [0.2,1.5,3.8,6.7],
                    "y": [12,5,7,10]
                }

            },
            {
                "name": "kpi-2",
                "data":{
                    "x": [3,6,7,9],
                    "y": [0.3,4.5,1.8,2]
                }
            }
        ]
    }
]

i would like to build a dashboard like this. it allows users to select from dropdown to filter based on ts and name and plot an array of x and y as scatter chart.

i cannot figure out the query and plotting. please help . thanks.