 |
ภาษาไทย Gantt Chart jpgraph เซ็ตยังไงครับข้อมูลจาก db |
|
 |
|
|
 |
 |
|

Code (PHP)
<?php // content="text/plain; charset=utf-8"
require_once ('../src/jpgraph.php');
require_once ('../src/jpgraph_gantt.php');
$graph = new GanttGraph();
$graph->SetShadow();
// Add title and subtitle
$graph->title->Set('ทดสอบ');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,12);
$graph->subtitle->Set('(ทดสอบ)');
$graph->subtitle->SetFont(FF_ANGSA,FS_BOLD,12);
// Show day, week and month scale
$graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH);
// Instead of week number show the date for the first day in the week
// on the week scale
$graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
// Make the week scale font smaller than the default
$graph->scale->week->SetFont(FF_ANGSA);
// Use the short name of the month together with a 2 digit year
// on the month scale
$graph->scale->month->SetStyle(MONTHSTYLE_LONGNAMEYEAR2);
// Format the bar for the first activity
// ($row,$title,$startdate,$enddate)
$activity = new GanttBar(0,'ทดสอบ','2001-12-21','2002-01-18');# ภาษาไทย
// Yellow diagonal line pattern on a red background
$activity->SetPattern(BAND_LDIAG,'black');
$activity->SetFillColor('black');
//$activity->SetFont(FF_ANGSA,FS_BOLD,12);
// Finally add the bar to the graph
$graph->Add($activity);
// ... and display it
$graph->Stroke();
?>
ตรงบันทัดนี้ละครับ จะเซ็ตยังไงตรงบันทัด33 $activity = new GanttBar(0,'ทดสอบ','2001-12-21','2002-01-18');
ใช้ฟ้อน SetFont(FF_ANGSA,FS_BOLD,15); ครับ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-04-24 06:02:37 |
By :
icute |
View :
4611 |
Reply :
14 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวไฟล์ Encode เป็น UTF8 แล้วน่ะครับ >,.<
|
 |
 |
 |
 |
Date :
2010-04-24 06:06:34 |
By :
icute |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$activity->title->SetFont
|
 |
 |
 |
 |
Date :
2010-04-24 08:21:25 |
By :
:) |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โค้ดช่วยแสดง object ที่สามารถ set font ได้ครับ
ส่งตัวแปรที่ประกาศด้วย new อย่างเช่น $graph และ $activity ไปยัง function echoSetFont แบบนี้ครับ
echoSetFont($graph,'$graph');
echoSetFont($activity,'$activity');
function echoSetFont($obj,$name,$fontNumber='FF_USERFONT1'){
foreach($obj as $k=>$o){
if (is_object($o)){
$vars = array_keys(get_object_vars($o));
if (method_exists($o,'SetFont')){
echo $name,'->',$k,'->SetFont('.$fontNumber.')<br/>';
}
echoSetFont($o,$name.'->'.$k,$fontNumber);
}
}
}
จะได้ผลลัพธ์อย่างข้างล่างนี้ครับ
$graph->scale->minute->SetFont(FF_USERFONT1);
$graph->scale->hour->SetFont(FF_USERFONT1);
$graph->scale->day->SetFont(FF_USERFONT1);
$graph->scale->week->SetFont(FF_USERFONT1);
$graph->scale->month->SetFont(FF_USERFONT1);
$graph->scale->year->SetFont(FF_USERFONT1);
$graph->scale->tableTitle->SetFont(FF_USERFONT1);
$graph->scale->actinfo->SetFont(FF_USERFONT1);
$graph->img->SetFont(FF_USERFONT1);
$graph->title->SetFont(FF_USERFONT1);
$graph->subtitle->SetFont(FF_USERFONT1);
$graph->subsubtitle->SetFont(FF_USERFONT1);
$graph->footer->left->SetFont(FF_USERFONT1);
$graph->footer->center->SetFont(FF_USERFONT1);
$graph->footer->right->SetFont(FF_USERFONT1);
$graph->tabtitle->SetFont(FF_USERFONT1);
$graph->legend->SetFont(FF_USERFONT1);
$activity->leftMark->title->SetFont(FF_USERFONT1);
$activity->rightMark->title->SetFont(FF_USERFONT1);
$activity->title->SetFont(FF_USERFONT1);
$activity->caption->SetFont(FF_USERFONT1);
|
 |
 |
 |
 |
Date :
2010-04-24 09:25:49 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองเปลี่ยนกราฟแบบใหม่โดยต้องการคิวรี่จาก db อยากรู้กำหนด array ยังไงอ่าครับ
ผม งง กับ gant มากเลยตอนนี้ jpgraph 3.0

อันนี้ไฟล์ ganttcsimex01.php ครับที่ผมนำมาใช้
Code (PHP)
<?php // content="text/plain; charset=utf-8"
// Gantt example to create CSIM
require_once ('../jpgraph.php');
require_once ('../jpgraph_gantt.php');
include"../../connect.php";
$sql="SELECT * FROM title_project_detail";
$query=mysql_query($sql);
$i=0;
while($res=mysql_fetch_array($query)){
$count++;
$bar1 = new GanttBar($count,"$res[title_operation]","$res[start_date]","$res[end_date]");
$bar1->SetCSIMTarget('#','Go back 1');
$bar1->title->SetCSIMTarget('#','Go back 1 (title)');
$bar1->title->SetFont(FF_ANGSA,FS_BOLD,18);#
$i++;
/*$bar2 = new GanttBar(1,"Activity 2","2002-01-03","2002-01-25");
$bar2->SetCSIMTarget('#','Go back 2');
$bar2->title->SetCSIMTarget('#','Go back 2 (title)');*/
$graph = new GanttGraph(500);
$graph->title->Set("Example with image map");
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);#
$graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
$graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
$graph->scale->week->SetFont(FF_ANGSA);
$graph->Add(array($bar1));
}
// And stroke
$graph->StrokeCSIM();
?>


มันแสดงข้อมูลตัวสุดท้ายออกมาอ่ะครับ ผมต้องการให้แสดงออกมาให้หมด เหมือนกับ dbเลยครับ
|
 |
 |
 |
 |
Date :
2010-04-24 10:24:03 |
By :
icute |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะอย่างนี้ครับ
<?php // content="text/plain; charset=utf-8"
// Gantt example to create CSIM
require_once ('../jpgraph.php');
require_once ('../jpgraph_gantt.php');
include"../../connect.php";
$graph = new GanttGraph(500);
$graph->title->Set("Example with image map");
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);#
$graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK);
$graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
$graph->scale->week->SetFont(FF_ANGSA);
$sql="SELECT * FROM title_project_detail";
$query=mysql_query($sql);
$i=0;
while($res=mysql_fetch_array($query)){
$count++;
$bar1 = new GanttBar($count,"$res[title_operation]","$res[start_date]","$res[end_date]");
$bar1->SetCSIMTarget('#','Go back 1');
$bar1->title->SetCSIMTarget('#','Go back 1 (title)');
$bar1->title->SetFont(FF_ANGSA,FS_BOLD,18);#
$i++;
/*$bar2 = new GanttBar(1,"Activity 2","2002-01-03","2002-01-25");
$bar2->SetCSIMTarget('#','Go back 2');
$bar2->title->SetCSIMTarget('#','Go back 2 (title)');*/
$graph->Add($bar1);
}
// And stroke
$graph->StrokeCSIM();
?>
|
 |
 |
 |
 |
Date :
2010-04-24 10:53:20 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันออกมา 3รูป หัวข้อแรก อ่ะครับ
เอาปีกลองปิดแบบนี้ก้ออกมารูปเดียว แต่ก้ยังเป็นข้อมูล ล่าสุดอยู่ครับ
Code
$i=0;
while($res=mysql_fetch_array($query)){
$count++;
$bar1 = new GanttBar($count,"$res[title_operation]","$res[start_date]","$res[end_date]");
$bar1->SetCSIMTarget('#','Go back 1');
$bar1->title->SetCSIMTarget('#','Go back 1 (title)');
$bar1->title->SetFont(FF_ANGSA,FS_BOLD,18);#
/*$bar2 = new GanttBar(1,"Activity 2","2002-01-03","2002-01-25");
$bar2->SetCSIMTarget('#','Go back 2');
$bar2->title->SetCSIMTarget('#','Go back 2 (title)');*/
$i++;
}
$graph->Add($bar1);
|
 |
 |
 |
 |
Date :
2010-04-24 10:56:09 |
By :
icute |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้ว่าเป็นเพราะอะไรงั้นลองแบบนี้ดูครับ
Code (PHP)
$bars = array();
$i=0;
while($res=mysql_fetch_array($query)){
$count++;
$bar1 = new GanttBar($count,"$res[title_operation]","$res[start_date]","$res[end_date]");
$bar1->SetCSIMTarget('#','Go back 1');
$bar1->title->SetCSIMTarget('#','Go back 1 (title)');
$bar1->title->SetFont(FF_ANGSA,FS_BOLD,18);#
$bars[] = $bar1;
$i++;
}
$graph->Add($bars);
|
 |
 |
 |
 |
Date :
2010-04-24 11:13:00 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วละครับขอบคุณมากลเยครับ 2 กราฟแล้วละที่พี่ช่วยผมมี font ไหนที่ดูดีกว่า Angsa มั้ยครับ แหะๆ

|
 |
 |
 |
 |
Date :
2010-04-24 11:19:35 |
By :
icute |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
http://www.f0nt.com/
ดาวน์โหลด ttf จากที่นี่น่ะครับ
หรือจะเลือก font ที่ใช้ประจำจาก windows ก็ได้ครับ
สร้าง folder c:\myfonts
ใน windows xp คลิกที่กล่อง run (shortcut = Windows+R) พิมพ์ cmd แล้ว enter
จากนั้นพิมพ์ copy c:\windows\fonts\*.ttf c:\myfonts
ก็จะได้ font มาใช้ใน folder c:\myfonts ครับ
|
 |
 |
 |
 |
Date :
2010-04-24 11:28:47 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2010-04-24 11:40:04 |
By :
icute |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมสร้าง folder fonts ในระดับเดียวกับ graph แล้ว แต่มันออกมาเป็นอย่างนี้ครับ

บอกหน่อยได้ใหม?
|
 |
 |
 |
 |
Date :
2010-10-30 17:56:02 |
By :
chansaad |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากรู้ว่าขั้นตอนแรกเราต้องทำยังไงมั่งค่ะ แล้วต้องมี ไฟล์อะไรบ้างค่ะ
|
 |
 |
 |
 |
Date :
2013-04-23 22:13:51 |
By :
kongkang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|