You are here: Re: Creating Gantt Chart in PHP « PHP Programming Language « IT news, forums, messages
Re: Creating Gantt Chart in PHP

Posted by Jerry Stuckle on 11/07/06 18:06

Kuna wrote:
>>You forgot three important parts here:
>>
>> 1. What do you expect to get?
>> 2. What do you get? (No output because of the errors?)
>> 3. Exactly what errors are you getting?
>>
>>Also, have you checked the data you got from the database to ensure it
>>is right (reasonable values, correct type, etc.)?
>
>
> Thanks for replying me and I am really sorry I forgot to post the error
> message. But now I am able to get into some solutions but the problem
> is that still I am getting an error. I have populated the database with
> all fields. I am again posting the new code and this is the erro
> message I am getting. So please help me its urgent and important for
> me. I will be grateful to you.
>
> <?php
> // Gantt dyaminc from MySQL example
> include ("C:/Program
> Files/xampp/htdocs/Graph/jpgraph-1.20.5/src/jpgraph.php");
> include ("C:/Program
> Files/xampp/htdocs/Graph/jpgraph-1.20.5/src/jpgraph_gantt.php");
> include ("C:/Program
> Files/xampp/htdocs/Graph/jpgraph-1.20.5/src/jpgraph_date.php");
>
> $host="localhost";
> $user="root";
> $password="";
> $db="zend";
>
> mysql_connect($host,$user,$password) or die("Could not connect: " .
> mysql_error());
> mysql_select_db($db) or die("Could not select database: " .
> mysql_error());
>
> $tasks = mysql_query("SELECT
> task_position,
> task_type_value,
> task_name,
> start_date,
> end_date,
> DATE_FORMAT(start_date, '%e/%m') as fstart_date,
> DATE_FORMAT(end_date, '%e/%m') as fend_date,
> CONCAT((end_date - start_date), ' ','days') as duration
> FROM tasks, task_type
> WHERE tasks.task_type_id=task_type.task_type_id");
>
> if ($row = mysql_fetch_array($tasks)) {
> do {
> $position[] = $row["task_position"];
> $type[] = $row["task_type_value"];
> $name[] = $row["task_name"];
> $start_date[] = $row["start_date"];
> $end_date[] = $row["end_date"];
> $fstart_date[] = $row["fstart_date"];
> $fend_date[] = $row["fend_date"];
> $duration[] = $row["duration"];
> }while($row = mysql_fetch_array($tasks));
> }
> $lines = mysql_num_rows($tasks);
> error_reporting(E_ALL);
> $graph = new GanttGraph(800,640);
> $graph->SetFrame(true,'white',.1);
> $graph->SetMarginColor('white:1.7');
> //$graph->SetShadow();
> $graph->SetColor('white');
> //$graph->SetBackgroundGradient('darkblue','white',GRAD_HOR,BGRAD_MARGIN);
>
> //$graph->title->SetColor('white');
> $graph->title->Set("SimpleGantt");
> $graph->title->SetFont(FF_ARIAL,FS_BOLD,16);
>
> $graph->ShowHeaders(GANTT_HDAY | GANTT_HWEEK | GANTT_HMONTH);
> $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
> $graph->scale->week->SetFont(FF_ARIAL, FS_NORMAL, 8);
> $graph->scale->month->SetStyle(MONTHSTYLE_SHORTNAMEYEAR2);
> $graph->scale->month->SetFont(FF_ARIAL, FS_BOLD, 8);
>
> $graph->scale->actinfo->SetColTitles (array('ID','Tasks',
> 'Duration','Start','End'),array(0,0));
> $graph->scale->actinfo->SetFont(FF_ARIAL, FS_ITALIC, 8);
>
> for($i=0; $i< $lines; ++$i) {
> $activity = new GanttBar ($position[$i], array($position[$i],
> $name[$i], $duration[$i],$fstart_date[$i],$fend_date[$i]),
> $start_date[$i], $end_date[$i]);
> // $activity = array($position[$i], $type[$i], $name[$i],
> $start_date[$i], $end_date[$i]);
> $activity ->SetPattern(BAND_RDIAG,"yellow");
> $activity ->SetFillColor("red");
> $activity->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
> $graph->Add($activity);
> // $graph->CreateSimple($activity);
> }
> $graph->Stroke();
> ?>
>
> Here is the Error Message :-
> "Cannot autoscale Gantt chart. No dated activities exist.
> [GetBarMinMax() start >= n]"
>
> I will be waiting for your reply :)
>
> Thanks and Regards,
> Kuna
>

OK, I'm not familiar with this specific package, but I looked at the
documentation.

The first thing which comes to mind is are your start and end dates in
the correct format? Have you tried echoing them to the screen to see
what's in them? According to the doc, they should be in the format
'2006-11-07' as a string. That's the default date format for MySQL in
my system, but yours may be different.

Also, I don't like your line:

$activity = new GanttBar ($position[$i], array($position[$i],
$name[$i], $duration[$i],$fstart_date[$i],$fend_date[$i]),
$start_date[$i], $end_date[$i]);

The second parameter according to the doc should be a text label; you're
passing it an array. That may be causing problems. But since you are
getting a chart with hardcoded data, it should be OK.

I'd recommend echoing all of your parameters to the screen to see if
they are really what you expect.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация