ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  unable to see my own graph
Posted by gopal on Jun-02-2011 18:04
i installed and configured chart director. i am able to see all examples.

but when i copy same code of particular graph in my case bar chart, then set the require once and created html file

   when i try to load it is not displaying . help me. following is the code

barchart1.PHP file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
require_once("C:\\wamp\\www\\ChartDirector\\lib\\phpchartdir.php");

# The data for the pie chart
$data = array(25, 18, 15, 12, 8, 30, 35);

# The labels for the pie chart
$labels = array("Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities",
    "Production");

# Create a PieChart object of size 360 x 300 pixels
$c = new PieChart(360, 300);

# Set the center of the pie at (180, 140) and the radius to 100 pixels
$c->setPieSize(180, 140, 100);

# Set the pie data and the pie labels
$c->setData($data, $labels);

# Output the chart
header("Content-type: image/jpg");
print($c->makeChart2(JPG));
?>

</body>
</html>





a.html file





<HTML>
<BODY>

<h1>Hello World!</h1>
<p>Hi, this is my first web page with ChartDirector charts.</p>

<IMG  SRC="http://localhost/ChartDirector/phpdemo/barcharta.php">

More HTML elements ......

</BODY>
</HTML>

  Re: unable to see my own graph
Posted by Peter Kwan on Jun-03-2011 04:57
Hi GOPAL,

I can see two errors:

In your "barchart1.PHP", you have added some incorrect HTML lines, like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>


</body>
</html>

Note that a chart is not text/html. It is image/png. You cannot insert HTML into an image. Please remove all HTML lines from your code.

(b) The code require_once("C:\\wamp\\www\\ChartDirector\\lib\\phpchartdir.php"); is incorrect. In PHP syntax, the "\\" is an escape sequence. You need to use "\\\\" if you really mean a backslash character. Instead, I suggest you to use "/", like:

require_once("C:/wamp/www/ChartDirector/lib/phpchartdir.php");


There is also a potential issue in the code:

<IMG  SRC="http://localhost/ChartDirector/phpdemo/barcharta.php">

Instead of using localhost, I suggest you just use:

<IMG  SRC="/ChartDirector/phpdemo/barcharta.php">

Hope this can help.

Regards
Peter Kwan

  after modification still problem persists
Posted by Gopal on Jun-03-2011 13:00
Hello,
  Thanks for help, i modified the code as you said. still problem persists the same.
i am attaching the screen shot of output.
   following is the code for two files with there respective path

1)   C:\\wamp\\www\\ChartDirector\\phpdemo\\barcharta.php


<?php
require_once("C:/wamp/www/ChartDirector/lib/phpchartdir.php");


# The data for the bar chart
$data = array(85, 156, 179.5, 211, 123);

# The labels for the bar chart
$labels = array("Mon", "Tue", "Wed", "Thu", "Fri");

# Create a XYChart object of size 250 x 250 pixels
$c = new XYChart(250, 250);

# Set the plotarea at (30, 20) and of size 200 x 200 pixels
$c->setPlotArea(30, 20, 200, 200);

# Add a bar chart layer using the given data
$c->addBarLayer($data);

# Set the labels on the x axis.
$c->xAxis->setLabels($labels);

# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>



2)C:\\wamp\\www\\ChartDirector\\phpdemo\\a.html


<HTML>
<BODY>

<h1>Hello World!</h1>
<p>Hi, this is my first web page with ChartDirector charts.</p>

<!--<IMG  SRC="http://localhost/ChartDirector/phpdemo/barcharta.php">  -->
<IMG  SRC="/ChartDirector/phpdemo/barcharta.php">

More HTML elements ......

</BODY>
</HTML>

and pl. see the attachment

thanks

  Re: after modification still problem persists
Posted by Peter Kwan on Jun-03-2011 15:22
Hi Gopal,

For some reasons, I cannot see the screen shot attachment.

Note that the forum has a 250 Kbytes limit for file attachment. To attach a file, please use the "Browse ..." button to browse to the file. If you directly enter the file name in the "File to Upload" field, you would need to press the "Send file" button to upload the file.

May be you can try to access the barcharta.php directly and inform me what is the output.

http://www.mydomain.com/ChartDirector\\phpdemo\\barcharta.php

If what you see is some garbage characters, it means there are some additional code in "barcharta.php" that switches the page to HTML (instead of image/png). Please attached the exact "barcharta.php" file so I can verify if there are any hidden extra characters.

If what you see is an empty page, please make sure you have enabled displaying error message in your web server. In your "php.ini", please set error_reporting to E_ALL, and display_errors to 1, then restart your server. Alternatively, you may try to add the following code at the beginning of barcharta.php to enable error message display.

ini_set('display_errors',1);
error_reporting(E_ALL);

Regards
Peter Kwan