vendredi 30 octobre 2015

JavaScript parse Error

I am Using laravel 5.1 PHP framework, I am using a sign chart from a javaScrpt, But when i Send data from controller with ' (single cote) but JavaScript Parse as some undefined value $data_B_Temp = "{x : new Date('".$piecesTime[$dataLength]."'), y :".$pieces[$dataLength]."}";

this variable will make a graph point input as

$(function () {

var chart = new CanvasJS.Chart("TempChart",
{


  axisX:{
    title: "time",
    gridThickness: 2,
    interval:1,
    intervalType: "hour",
    valueFormatString: "hh TT K",
    labelAngle: -10
  },
  axisY:{
    title: "distance"
  },
  data: [
  {
    type: "line",
   dataPoints:[{{$data_B_Temp }}]

  }
  ]
});

$("#TempChart").CanvasJSChart(chart.render());

});`

But the javascript executes as

`dataPoints:[{x : new Date('2015-10-30 18:16:08'), y :38.5}]`

i'm confused &#039 is coming?, how to solve it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire