0

For my diagramm I would like set additional data in highcharts. This answer is a good example for a way:

Set Additional Data to highcharts series

But how must I write this for JSON.parse sources?

series : [{
yAxis: 0,
name : 'Server-TPS',
data : JSON.parse(data.tps)
},
{
yAxis: 1,
name : 'Spieler-Anzahl',
data : JSON.parse(data.playercount)
}]

I would like add a JSON.parse(data.playername) for the specific time after the playercount in the toolbar.

The diagramm: http://redstoneworld.de/mc-status/diagramm/graph.php

After the mysql-search I push the data in a $json_encode:

array_push($array_playercount, array(strtotime($row['timestamp']) * 1000, $row['playercount']));
array_push($array_tps, array(strtotime($row['timestamp']) * 1000, $row['tps']));
array_push($array_playerlist, array(strtotime($row['timestamp']) * 1000, $row['playerlist']);



$json['playercount'] = json_encode($array_playercount, JSON_NUMERIC_CHECK);
$json['tps'] = json_encode($array_tps, JSON_NUMERIC_CHECK);
$json['playerlist'] = json_encode($array_playerlist, JSON_NUMERIC_CHECK);


echo json_encode($json, JSON_NUMERIC_CHECK);

Thanks for any help.

~ Robert

  • You need to use an associative array to define an object with additional properties like in the linked topic - read how to do it here https://stackoverflow.com/questions/3281354/create-json-object-the-correct-way – morganfree May 24 '17 at 10:48
  • How I can't write: data : [{ y: JSON.parse(data.playercount) }], – RedstoneFuture May 31 '17 at 18:12
  • Write JSON.parse part in javascript on the client and send your variable from the php as the json. Then you can use that variable in jSON.parse. Or another way - make an ajax request for the data to your server. – morganfree Jun 02 '17 at 11:21

0 Answers0