Welcome Guest Search | Active Topics |

php to jqChart
dreamfalcon
#1 Posted : Wednesday, May 21, 2014 4:54:31 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/21/2014(UTC)
Posts: 2

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

I'm trying to send a array of objects from PHP to jqChart using JSON.

$data = array();
foreach ($kpis_values as $time => $value) {
$object = new stdClass();
$object->dateTime = $time;
$object->value = $value;
$data[]=$object;
}
$response->dataSource=$data;
return json_encode($response, JSON_FORCE_OBJECT);
...

After passing to JavaScript I get this:

{
"0":{"dateTime":"2014-05-15","value":"99.851"},
"1":{"dateTime":"2014-05-16","value":"99.830"},
"2":{"dateTime":"2014-05-17","value":"99.784"}
}


not exactly what jqChart needs;

[
{"date":"12/20/2012","value":30},
{"date":"12/21/2012","value":50},
{"date":"12/22/2012","value":45}
]

Could anyone help me?
Thanks
dreamfalcon
#2 Posted : Wednesday, May 21, 2014 6:11:08 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/21/2014(UTC)
Posts: 2

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
The problem was in JSON_FORCE_OBJECT :)
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.075 seconds.