Why is each character displayed on a new line/row?

0đź‘Ť

âś…

The datasets.data is expecting an array to be used, but json_encode is returning a string. In javascript, strings can be iterated per character and have a length just like arrays… so the duck quacked and no error occurred.

You’ll need to use JSON.parse on the echo’d PHP output if you’re going to json_encode and ensure it’s an array before sending it to the graph to be parsed.

Update:

Try this instead.

<?php
$graphdata = array();
while($valor = mysql_fetch_assoc($sql))
{
    extract($valor);
    $graphdata[] = $valor['resposta'];
}

echo '[' . implode(',', $graphdata) . ']';
?>

đź‘Ť:0

Maybe some stray characters from the query results?
Try

$pingresposta.= trim($valor['resposta']);
$pinghorario.= trim($valor['horario']);

Leave a comment