Unable to parse data to line graph

I am trying to use the following graph using Plotly.js library. I see that the json function fetches json from a particular url. However I am dynamically computing the data and storing it in a php array, how do I pass the php array as data in the following code :

Plotly.d3.json(val, function(rows){
var trace = {
  type: 'scatter',                    // set the chart type
  mode: 'lines',                      // connect points with lines
  x: rows.map(function(row){          // set the x-data
    return row['TIME'];
  y: rows.map(function(row){          // set the x-data
    return row['CURRENTR'];
  line: {                             // set the width of the line.
    width: 1

var layout = {
  yaxis: {title: "Wind Speed"},       // set the y axis title
  xaxis: {
    showgrid: false,                  // remove the x-axis grid lines
    tickformat: "%B, %Y"              // customize the date format to "month, day"
  margin: {                           // update the left, bottom, right, top margin
    l: 40, b: bottom, r: 10, t: 20

Plotly.plot(document.getElementById('wind-speed'), [trace], layout, {showLink: false});

Here instead of Plotly.d3.json(val, function(rows)){ I have a php array as following :

   $data = array();
$data['x'] = {10,20,30,40,50};
$data['y'] = {10,30,40,60,70};

How do I pass this $data[] in the above function to plot the graph