Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:48:24+00:00 2026-06-07T23:48:24+00:00

I’m using JpGraph to make a Gantt chart for a convention. I found this

  • 0

I’m using JpGraph to make a Gantt chart for a convention. I found this example at the bottom of the page and I’m trying to alter it to what I need displayed. I was able to set the leftMark to the side of the bar that I want the text to appear. However, the text is not within the bar. I tried to change the alignment to "left, top" but I get either an error $bar->leftMark->title->SetTextAlign('left','top');

Fatal error: Call to undefined method Text::SetTextAlign() in
C:\xampp\htdocs\ganttChart\chart.php on line 82

or no effect on the graph.

Please see my example of what I was able to do with the graph: example.

Questions:

  1. What classes, includes, or code an I missing in order to complete this task?

  2. Do you know of an example that I can follow that has the same effect that I am looking for, described in the paragraph and example above?

PHP Code:

<?php // content="text/plain; charset=utf-8"
// Gantt hour example
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_gantt.php');
require_once ('jpgraph/src/jpgraph_canvas.php');
require_once ('jpgraph/src/jpgraph_canvtools.php');
require_once ('jpgraph/src/jpgraph_text.inc.php');


// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
$graph = new GanttGraph();
$graph->SetMarginColor('blue:1.7');
$graph->SetColor('white');

$graph->SetBackgroundGradient('navy','white',GRAD_HOR,BGRAD_MARGIN);
$graph->scale->hour->SetBackgroundColor('lightyellow:1.5');
$graph->scale->hour->SetFont(FF_FONT1);
$graph->scale->day->SetBackgroundColor('lightyellow:1.5');
$graph->scale->day->SetFont(FF_FONT1,FS_BOLD);

$graph->title->Set("Example of hours in scale");
$graph->title->SetColor('white');
$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);

$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR);

$graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
$graph->scale->week->SetFont(FF_FONT1);
$graph->scale->hour->SetIntervall(1);

$graph->scale->hour->SetStyle(HOURSTYLE_HM24);
$graph->scale->day->SetStyle(DAYSTYLE_SHORTDAYDATE3);

$data = array(
    array(0,"Room 1", "2001-01-26 04:30","2001-01-26 14:00"),
    array(0,"Room 1", "2001-01-26 15:30","2001-01-26 19:00"),
    array(1,"Room 2", "2001-01-26 10:00","2001-01-26 18:00"),
    array(2,"Room 3", "2001-01-26","2001-01-27 10:00")
);


for($i=0; $i<count($data); ++$i) {

    $bar = new GanttBar(
    $data[$i][0],
    $data[$i][3],
    $data[$i][2],
    $data[$i][3],
    "",100);

    if( count($data[$i])>4 )
    $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6] );
    $bar->SetPattern(BAND_RDIAG,"yellow");
    $bar->SetFillColor("red");
    //$bar->SetTextAlign('left');

    $bar->leftMark->Show();    
    //$bar->rightMark->title->Set("Events name");
    $bar->leftMark->title->Set("Events name");
    //$bar->rightMark->SetType(MARK_FILLEDCIRCLE);
    //$bar->rightMark->SetWidth(10);
    //$bar->rightMark->SetColor("red");
    //$bar->rightMark->SetFillColor("red");
    //$bar->leftMark->title->SetTextAlign('left');
    $bar->leftMark->title->Center(50,150,75);
    $bar->leftMark->title->SetFont(FF_ARIAL,FS_BOLD,12);
    $bar->leftMark->title->SetColor("black");
    $bar->leftMark->title->SetAlign('left','top');
    $graph->Add($bar);
}


$graph->Stroke();



?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:48:27+00:00Added an answer on June 7, 2026 at 11:48 pm

    I figured this out see my example and code below:Example

    code:

    <?php // content="text/plain; charset=utf-8"
    // Gantt hour example
    require_once ('jpgraph/src/jpgraph.php');
    require_once ('jpgraph/src/jpgraph_gantt.php');
    require_once ('jpgraph/src/jpgraph_canvas.php');
    require_once ('jpgraph/src/jpgraph_canvtools.php');
    require_once ('jpgraph/src/jpgraph_text.inc.php');
    
    
    // Report simple running errors
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
    
    // Reporting E_NOTICE can be good too (to report uninitialized
    // variables or catch variable name misspellings ...)
    error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
    
    // Report all errors except E_NOTICE
    // This is the default value set in php.ini
    error_reporting(E_ALL ^ E_NOTICE);
    
    // Report all PHP errors (see changelog)
    error_reporting(E_ALL);
    
    // Report all PHP errors
    error_reporting(-1);
    
    
    
    // Same as error_reporting(E_ALL);
    ini_set('error_reporting', E_ALL);
    $graph = new GanttGraph();
    $graph->SetMarginColor('blue:1.7');
    $graph->SetColor('white');
    
    $graph->SetBackgroundGradient('navy','white',GRAD_HOR,BGRAD_MARGIN);
    $graph->scale->hour->SetBackgroundColor('lightyellow:1.5');
    $graph->scale->hour->SetFont(FF_FONT1);
    $graph->scale->day->SetBackgroundColor('lightgreen:1.5');
    $graph->scale->day->SetFont(FF_FONT1,FS_BOLD);
    
    $graph->title->Set("Example of hours in scale");
    $graph->title->SetColor('white');
    $graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
    
    $graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR);
    
    $graph->scale->week->SetStyle(WEEKSTYLE_FIRSTDAY);
    $graph->scale->week->SetFont(FF_FONT1);
    $graph->scale->hour->SetIntervall(1);
    
    $graph->scale->hour->SetStyle(HOURSTYLE_HMAMPM);
    $graph->scale->hour->grid->SetColor('lightgray');
    $graph->scale->day->SetStyle(DAYSTYLE_SHORTDAYDATE3);
    
    
    $data = array(
        array(0,"Room 1", "2001-01-26 02:30","2001-01-26 14:00:00","Sonic"),
        array(0,"Room 1", "2001-01-26 15:30","2001-01-26 19:00","SailorMoon"),
        array(1,"Room 2", "2001-01-26 10:00","2001-01-26 18:00","Gundam Wing"),
        array(2,"Room 3", "2001-01-26","2001-01-26 10:00","No appologies")
    );
    
    
    for($i=0; $i<count($data); ++$i) {
    
    $txt = new Text();
    $txt->SetScalePos($data[$i][2],$data[$i][0]);
    $txt->SetMargin(50);
    $txt->SetFont(FF_VERDANA,FS_BOLD,12);
    $txt->SetAlign('left','center');
    $txt->Set($data[$i][4]);
    $txt->SetParagraphAlign('left');
    //$txt->SetWordWrap(10);
    $txt->SetBox('lightyellow');
    $txt->SetShadow();
    $graph->Add($txt); 
    
    
        $bar = new GanttBar(
        $data[$i][0],
        $data[$i][1],
        $data[$i][2],
        $data[$i][3],
        $data[$i][4],100);
    
        if( count($data[$i])>4 )
        $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6] );
        $bar->title->SetFont(FF_VERDANA,FS_BOLD,12);
        $bar->SetPattern(BAND_RDIAG,"yellow");
        $bar->SetFillColor("red");
        $graph->Add($bar);
    }
    
    $graph->Stroke();
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.