Data column(s) for axis #0 cannot be of type string error in google chart

后端 未结 5 1482
慢半拍i
慢半拍i 2021-01-05 20:29

I tried to populate google chart datatable in server side using PHP.I got JSON file properply, but the Chart not display in client Application. I got error-Data colu

5条回答
  •  天命终不由人
    2021-01-05 21:01

    To extend on @sajal's accurate answer: Change the last line of your code from:

    echo json_encode($table);
    

    to:

    echo json_encode($table, JSON_NUMERIC_CHECK);
    

    This will tell json_encode to recognize numbers and abstain from wrapping them in quotes (Available since PHP 5.3.3.). http://php.net/manual/en/json.constants.php#constant.json-numeric-check

提交回复
热议问题