|
unable to see my graph |
Posted by GOPAL on Jun-02-2011 18:00 |
|
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 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 |
|