如何将canvasJS生成的数据保存到数据库?

I am new to graphs and I want to create a real time graph that generates random data and save the data on database. I already saw a code in canvasjs that generates random data and create a real time graph. My problem is how to save the data generated in canvasjs to the database. I have a database name randgraph and I want save the y value to data column and x value to id column.. Thanks..

Here is the Javascript code.

window.onload = function () {

var dps = []; // dataPoints
var chart = new CanvasJS.Chart("chartContainer", {
  title :{
    text: "Dynamic Data"
  },
  axisY: {
    includeZero: false
  },      
  data: [{
    type: "line",
    dataPoints: dps
  }]
});

var xVal = 0;
var yVal = 100; 
var updateInterval = 1000;
var dataLength = 20; // number of dataPoints visible at any point

var updateChart = function (count) {

  count = count || 1;

  for (var j = 0; j < count; j++) {
    yVal = yVal +  Math.round(5 + Math.random() *(-5-5)); //generate random number for y value
    dps.push({
      x: xVal,
      y: yVal
    });
    xVal++; 
  }

  if (dps.length > dataLength) {
    dps.shift();
  }

  chart.render();
};

updateChart(dataLength);
setInterval(function(){updateChart()}, updateInterval);

}

Here is the image of the graph as well as full code. CanvasJs. My problem is how to save the generated data into database.