I am trying to plot dates and values from carto.js ( using the sql API) into highchart.js . this example uses the following data structure [Date.UTC(2013,5,5),0.7638] ,but how can I covert the the data returned after the sql request into this data structure [Date.UTC(2013,5,5),0.7638] ?? Any idea??

1 Answer 1


I'm following the code that you have here. You would need to set a new variable that will store the pairs of values of date and deaths_mis from your CARTO dataset.

In order to do so, I would recommend create a global variable before setting the sql in the code. The new variable stores an empty array that will store the pairs is dataStructure.

    var dataStructure = []
    var sql = cartodb.SQL({ user: 'migrantreport' });
    sql.execute("SELECT date,SUM (deaths_mis) deaths_mis FROM iom_world_deaths_copy GROUP BY date order BY date asc")

Then, when you do the for (i in data.rows) to retrieve teh data of CARTO, I would recommend pushing the values inside the dataStructure array.

for (i in data.rows){

Finally, you can use the dataStructure pairs of values within the Highcart.js parameter data

  series: [{
            type: 'area',
            name: 'Migrant Deaths',

           data: dataStructure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.