Chartjs-ChartJS passing data dynamically, then passing data into variables

0๐Ÿ‘

โœ…

I wanted to post the answer that I came up, and it is working well, and gives the ability to add some different options to the function later on.

function line() {

    let labels = []
    let data = []



    $.getJSON("http://localhost:3000/data/issflightplan/VehicleType/count/", function (inData) {

        let aggregationName = []

        for (aggName in inData.aggregations) {
            console.log(aggName)
            for( bucket in inData.aggregations[aggName].buckets) {
                labels.push(inData.aggregations[aggName].buckets[bucket].key)
                data.push(inData.aggregations[aggName].buckets[bucket].doc_count)

            }
        }

Leave a comment