I have been trying to create graphs with pchart library in my drupal 7 site. I have installed and configured pchart properly and when I try to test it with an example provided by pcahrt itself am getting a really gibberish output as shown below..
�PNG IHDR���R� IDATx��w�\�}��O���^�WH���\cp��+
'!���M�&N����ɛ8yc'��$؉���
�� !PE]��f�����ǕF�٢�jˬt�}��)��g�ܹ��s��������f!�X�0�������jZ�m�@Q�RG�������TӲm_����������Е$$$$$$��K�4t� iVBW�������f%t� iV�Օ�H$r��!x��7?�p������K��'V���7�@,���_~��,>]<����^{�-[�y晧�~���t�3��5Qn:��O��y)����&�|A�ҫ�-NN|��g�t�e���2m�nN�#g�wގ#!!!!]����a������zzz���/��59e�ī�������6ؾ}�1Tf�������۷�߸��F���X�<�wy�m��������455}�[ߚ\u%�7��-n�x�pg(xv9~�ۗ_~�;c����1p�>C0�sA�輡"!!!!M��i�iz͚5p�b@{{;I�(��������w�ܹ{��O}�S,�V�V�zOO�Ν;ð��,�SN��4������[�u�]w��?ݹs'�0�v��җ�TYÔ=:�˹)��ttt���ݻw�w�}�emܸq���������ʪh�����sKK��Dfv��TU�09q6�NYp�( ��ǟ|��|��|����XUݜ2�ʪ<<�q��o��u�4mwtt466���n���y������r�{��tkk˶m�6n����bcgo%l��8�lq��لz��]��]ד��u�r3ٙc����s6gm�ry��p��8��s������)��9q�ڵg�y��y��j�b��bŊ�'oz�s�i��="" 7ܰcǎ�d��m�p(�j��j�����k="" u朮g���o������?e+���,{����="{�|�,|�����N�e���?44t�}�M���" �u~r��%�7�="" v����]9�r��g���="">XY�1ض�u�ַ�zˋ��fYv���9ˎO�#�y��?������������Ӏ������4+�}�������f%t� iVBW�������f%t� iVBW�������f%tҀ������4+��$$$$$$�Y �����s��^bĈ#F�q���4^;� F�1bĈk�q��h#F�1b�5�$�.��r&bĈ#F�qCy!$��JEĈ#F�1�J嵐F�A�1bĈ�2c��H4�#F�1���{ּtv��%�1bĈ#F\�hMbĈ#F�x6���h#F�1b�5�\����f2p�vXu�2��?�ή���#��N�??r[����;3�;ڟ���E�K� bĈ#��3��h�S��Ap6��ތ�j��83 ��=��rO�eb�#�P�h��rO��9�J��{�1bĈ/1�ӛ;�5�k�t�����k6����|�����*+15'�qe���mM������:ǤTUq��O#F��%�P��4�?L�<�wy�m��������455}�[ߚ\u
This is very lengthy and am only a piece of the output.
When I put
<img src="sites/all/libraries/pChart2.1.3/examples/example.basic.php" />
line on my page, am not getting anything, just an empty page with title.
Am getting that gibberish when I include the example.basic.php file on my page.
below is my example.basic.php code,
<?php
/* CAT:Misc */
//I have installed libraries module. and the contents of pChart are present in /sites/all/libraries/pChart2.1.3
$name = "pChart2.1.3";
if ($path = libraries_get_path($name)) {
include($path.'/class/pData.class.php');
include($path.'/class/pDraw.class.php');
include($path.'/class/pImage.class.php');
}
/* Include all the classes
include("../class/pDraw.class.php");
include("../class/pImage.class.php");
include("../class/pData.class.php"); */
/* Create your dataset object */
$myData = new pData();
/* Add data in your dataset */
$myData->addPoints(array(1,3,4,3,5));
/* Create a pChart object and associate your dataset */
$myPicture = new pImage(700,230,$myData);
/* Choose a nice font */
$myPicture->setFontProperties(array("FontName"=>$path.'/fonts/Forgotte.ttf',"FontSize"=>11));
/* Define the boundaries of the graph area */
$myPicture->setGraphArea(60,40,670,190);
/* Draw the scale, keep everything automatic */
$myPicture->drawScale();
/* Draw the scale, keep everything automatic */
$myPicture->drawSplineChart();
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.basic.png");
?>
FYI, I have experimented with rendering the picture such as,
$myPicture->autoOutput();
$myPicture->Stroke();
$myPicture->render();
But, all of these give the same result..! So how can I make it work..??
/////////////// ADDED image.png code /////////////////////////////////////////////////////////////////////////////////////
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" version="XHTML+RDFa 1.0" dir="ltr"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:og="http://ogp.me/ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:sioct="http://rdfs.org/sioc/types#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<head profile="http://www.w3.org/1999/xhtml/vocab">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta about="/d7/?q=node/2" property="sioc:num_replies" content="0" datatype="xsd:integer" />
<link rel="shortcut icon" href="http://localhost/d7/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<meta content="test" about="/d7/?q=node/2" property="dc:title" />
<link rel="shortlink" href="/d7/?q=node/2" />
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
<link rel="canonical" href="/d7/?q=node/2" />
<title>test | project</title>
<style type="text/css" media="all">@import url("http://localhost/d7/modules/system/system.base.css?lzusma");
@import url("http://localhost/d7/modules/system/system.menus.css?lzusma");
@import url("http://localhost/d7/modules/system/system.messages.css?lzusma");
@import url("http://localhost/d7/modules/system/system.theme.css?lzusma");</style>
<style type="text/css" media="all">@import url("http://localhost/d7/modules/comment/comment.css?lzusma");
@import url("http://localhost/d7/sites/all/modules/date/date_api/date.css?lzusma");
@import url("http://localhost/d7/sites/all/modules/date/date_popup/themes/datepicker.1.7.css?lzusma");
@import url("http://localhost/d7/modules/field/theme/field.css?lzusma");
@import url("http://localhost/d7/modules/node/node.css?lzusma");
@import url("http://localhost/d7/modules/search/search.css?lzusma");
@import url("http://localhost/d7/modules/user/user.css?lzusma");</style>
<style type="text/css" media="all">@import url("http://localhost/d7/themes/bartik/css/layout.css?lzusma");
@import url("http://localhost/d7/themes/bartik/css/style.css?lzusma");
@import url("http://localhost/d7/themes/bartik/css/colors.css?lzusma");</style>
<style type="text/css" media="print">@import url("http://localhost/d7/themes/bartik/css/print.css?lzusma");</style>
<!--[if lte IE 7]>
<link type="text/css" rel="stylesheet" href="http://localhost/d7/themes/bartik/css/ie.css?lzusma" media="all" />
<![endif]-->
<!--[if IE 6]>
<link type="text/css" rel="stylesheet" href="http://localhost/d7/themes/bartik/css/ie6.css?lzusma" media="all" />
<![endif]-->
<script type="text/javascript" src="http://localhost/d7/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://localhost/d7/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://localhost/d7/misc/drupal.js?lzusma"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, {"basePath":"\/d7\/","pathPrefix":"","ajaxPageState":{"theme":"bartik","theme_token":"QE-jd8WcXtpZ1dRuiSRy-AooAlkyyPIGI7vF2twO1Js","js":{"misc\/jquery.js":1,"misc\/jquery.once.js":1,"misc\/drupal.js":1},"css":{"modules\/system\/system.base.css":1,"modules\/system\/system.menus.css":1,"modules\/system\/system.messages.css":1,"modules\/system\/system.theme.css":1,"modules\/comment\/comment.css":1,"sites\/all\/modules\/date\/date_api\/date.css":1,"sites\/all\/modules\/date\/date_popup\/themes\/datepicker.1.7.css":1,"modules\/field\/theme\/field.css":1,"modules\/node\/node.css":1,"modules\/search\/search.css":1,"modules\/user\/user.css":1,"themes\/bartik\/css\/layout.css":1,"themes\/bartik\/css\/style.css":1,"themes\/bartik\/css\/colors.css":1,"themes\/bartik\/css\/print.css":1,"themes\/bartik\/css\/ie.css":1,"themes\/bartik\/css\/ie6.css":1}}});
//--><!]]>
</script>
</head>
<body class="html not-front not-logged-in one-sidebar sidebar-first page-node page-node- page-node-2 node-type-article" >
<div id="skip-link">
<a href="#main-content" class="element-invisible element-focusable">Skip to main content</a>
</div>
<div id="page-wrapper"><div id="page">
<div id="header" class="without-secondary-menu"><div class="section clearfix">
<a href="/d7/" title="Home" rel="home" id="logo">
<img src="http://localhost/d7/themes/bartik/logo.png" alt="Home" />
</a>
<div id="name-and-slogan">
<div id="site-name">
<strong>
<a href="/d7/" title="Home" rel="home"><span>project</span></a>
</strong>
</div>
</div> <!-- /#name-and-slogan -->
<div id="main-menu" class="navigation">
<h2 class="element-invisible">Main menu</h2><ul id="main-menu-links" class="links clearfix"><li class="menu-218 first last"><a href="/d7/">Home</a></li>
</ul> </div> <!-- /#main-menu -->
</div></div> <!-- /.section, /#header -->
<div id="main-wrapper" class="clearfix"><div id="main" class="clearfix">
<div id="breadcrumb"><h2 class="element-invisible">You are here</h2><div class="breadcrumb"><a href="/d7/">Home</a></div></div>
<div id="sidebar-first" class="column sidebar"><div class="section">
<div class="region region-sidebar-first">
<div id="block-user-login" class="block block-user">
<h2>User login</h2>
<div class="content">
<form action="/d7/?q=node/2&destination=node/2" method="post" id="user-login-form" accept-charset="UTF-8"><div><div class="form-item form-type-textfield form-item-name">
<label for="edit-name">Username <span class="form-required" title="This field is required.">*</span></label>
<input type="text" id="edit-name" name="name" value="" size="15" maxlength="60" class="form-text required" />
</div>
<div class="form-item form-type-password form-item-pass">
<label for="edit-pass">Password <span class="form-required" title="This field is required.">*</span></label>
<input type="password" id="edit-pass" name="pass" size="15" maxlength="60" class="form-text required" />
</div>
<div class="item-list"><ul><li class="first"><a href="/d7/?q=user/register" title="Create a new user account.">Create new account</a></li>
<li class="last"><a href="/d7/?q=user/password" title="Request new password via e-mail.">Request new password</a></li>
</ul></div><input type="hidden" name="form_build_id" value="form-1CLdTDBqbmne6F7FjhizZLAe-9XZmCIa__KHgtmPeP8" />
<input type="hidden" name="form_id" value="user_login_block" />
<div class="form-actions form-wrapper" id="edit-actions"><input type="submit" id="edit-submit" name="op" value="Log in" class="form-submit" /></div></div></form> </div>
</div>
</div>
</div></div> <!-- /.section, /#sidebar-first -->
<div id="content" class="column"><div class="section">
<a id="main-content"></a>
<h1 class="title" id="page-title">
test </h1>
<div class="tabs">
</div>
<div class="region region-content">
<div id="block-system-main" class="block block-system">
<div class="content">
<div id="node-2" class="node node-article node-promoted node-full clearfix" about="/d7/?q=node/2" typeof="sioc:Item foaf:Document">
<div class="meta submitted">
<span property="dc:date dc:created" content="2012-02-24T00:32:36+05:30" datatype="xsd:dateTime" rel="sioc:has_creator">Submitted by <span class="username" xml:lang="" about="/d7/?q=user/1" typeof="sioc:UserAccount" property="foaf:name">akshaynhegde</span> on Fri, 02/24/2012 - 00:32</span> </div>
<div class="content clearfix">
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded">HELLoo
Next part is a gibberish code.. hence I cant paste it so here is the pic of that gibberish code..
After the gibberish there is some more code.. as below,
<img src="/sites/all/libraries/pChart2.1.3/examples/example.basic.php" /></div></div></div> </div>
<div class="link-wrapper">
<ul class="links inline"><li class="comment_forbidden first last"><span><a href="/d7/?q=user/login&destination=node/2%23comment-form">Log in</a> or <a href="/d7/?q=user/register&destination=node/2%23comment-form">register</a> to post comments</span></li>
</ul> </div>
</div>
</div>
</div>
</div>
</div></div> <!-- /.section, /#content -->
</div></div> <!-- /#main, /#main-wrapper -->
<div id="footer-wrapper"><div class="section">
<div id="footer" class="clearfix">
<div class="region region-footer">
<div id="block-system-powered-by" class="block block-system">
<div class="content">
<span>Powered by <a href="http://drupal.org">Drupal</a></span> </div>
</div>
</div>
</div> <!-- /#footer -->
</div></div> <!-- /.section, /#footer-wrapper -->
</div></div> <!-- /#page, /#page-wrapper -->
</body>
</html>