내가 MySQL의에서 데이터를 가져 오는하고있는 그래프 드루팔 오픈 플래시 차트 2를 사용하는 그래프 (음, 문제가 드루팔 관련이 없습니다 또는 그래프와 차트 모듈)왜 내 SQL 데이터로 인해 차트의 Y 축이 무한대로 이동합니까?
구축을 위해 노력하고있다 데이터 베이스. 나는이 코드를 실행하면
function my_module_charts_graphs_test() {
global $user;
$uname = $user->name;
$sql = "Select total_calorie from health_calorie_consumed where name = '%s'";
$result = db_query($sql,$uname);
while($row = db_fetch_array($result))
{
$data[] = $row[total_calorie];
}
$canvas = charts_graphs_get_graph('open-flash');
$canvas->title = "OpenFlashCharts Chart";
$canvas->type = "bar_3d";
$canvas->y_legend = "Y Legend";
$canvas->colour = '#808000';
$canvas->width = 700;
$canvas->height = 300;
$canvas->y_max=1000;
$canvas->y_min=0;
$canvas->y_step=100;
$canvas->series = array(
'Some Value' => array(923,623,73,92,5,722,643,156,345),
//'Page Views' => array_values($data),
);
$canvas->x_labels = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
// $canvas->x_labels = array_values($data);
$out = $canvas->get_chart();
return $out;
}
, 나는 아래의 그래프를 얻을 : 다음은 데이터를 가져 그래프를 생성하는 기능입니다 그래서
preview-1 http://oi43.tinypic.com/2hcfgqp.jpg
이, 그것은 로컬 선언과 함께 완벽하게 작동 정렬. 하지만 SQL에서 배열을 사용해야합니다. 따라서 나는 주석을 해제하고 $canvas->c_labels
및 $canvas->series
을 변경 : 우리가 볼 수 있듯이
preview-2 http://oi41.tinypic.com/spb42g.jpg
에서, X_AXIS 값이 바로 당과 같습니다
$canvas->x_labels = array_values($data); //$data is array from sql query
'Page Views' => array_values($data)
이제, 놀랍게도, 나는 아래의 그래프를 얻을 쿼리하지만 y_axis는 무한대와 동일한 값을 나타냅니다. 왜 이렇게합니까?
이 이상한 문제에 또 다른 얼굴이 있습니다. 처음에 나는이 방법을 $canvas->series
작동하지 않을 수 있다고 생각하지만, 나는 아래의 코드를 시도하고 완벽하게 작동 :
$array = array(0,0,117,207,130,260,207); //these values are that are fetched from sql
$canvas->series = array(
'some values'=>array_values($array),
);
그래서 "무한대"문제는 SQL 쿼리에서 만 Y 축에 대한 가져온 배열 나타납니다 . 다음은
Array ([0] => 0 [1] => 0 [2] => 117 [3] => 207 [4] => 130 [5] => 260 [6] => 207)
내가 $ canvas-> 시리즈했으나 실패 다른 조합입니다 ...
$test = implode(",",$data); // $data is the array fetched from sql
$abcd = "array(".$test.")"; // array(0,0,117,207,130,260,207)
$canvas->series=>array(
'some value'=>print($abcd), //i tried to print those values in standard format..:p
);
'some values'=>$abcd, // doesn't work..!
: 내 SQL의
print_r($data)
은 다음과 같습니다
'some values'=>$data, // doesn't work.!
나는 운이 없다고 생각할 수있는 모든 것을 시도했다.
작동하지 않았다 ... :(동일한 "무한대"그래프를 보여줍니다 .. !!! 깨끗한 제목을 주셔서 감사합니다. :) – akshaynhegde