View unanswered posts | View active topics It is currently Thu May 16, 2024 1:31 am



Reply to topic  [ 2 posts ] 
newbie, two things unclear 
Author Message
New pChart user
New pChart user

Joined: Wed Jan 11, 2012 3:26 am
Posts: 1
Post newbie, two things unclear
Hello,

pchart is great but still have to learn a lot. Would be great if you could help me answer the following two questions:
my first attempt at drawing a line chart is failing. I have roughly 300 data points I'd like to graph, yet the line is just totally straight.

Image

the data looks like this

Code:
array(480) { [0]=> string(7) "6084.89" [1]=> string(7) "6081.43" [2]=> string(7) "6081.43" [3]=> string(7) "6077.99" [4]=> string(7) "6073.75" [5]=> string(7) "6071.47" [6]=> string(7) "6076.69" [7]=> string(7) "6074.46" [8]=> string(6) "6074.3" [9]=> string(7) "6077.87" [10]=> string(7) "6077.87" [11]=> string(7) "6085.47" [12]=> string(7) "6076.69" [13]=> string(6) "6077.6" [14]=> string(7) "6076.69" [15]=> string(7) "6076.69" [16]=> string(7) "6084.25" [17]=> string(7) "6085.38" [18]=> string(7) "6086.25" [19]=> string(7) "6083.47" [20]=> string(7) "6083.47" [21]=> string(7) "6090.83" [22]=> string(7) "6090.02" [23]=> string(7) "6090.46" [24]=> string(7) "6090.46" [25]=> string(7) "6092.32" [26]=> string(6) "6099.6" [27]=> string(7) "6097.74" [28]=> string(7) "6085.24" [29]=> string(7) "6103.51" [30]=> string(7) "6100.09" [31]=> string(7) "6100.09" [32]=> string(7) "6101.99" [33]=> string(7) "6101.99" [34]=> string(7) "6093.44" [35]=> string(7) "6103.51" [36]=> string(7) "6088.91" [37]=> string(7) "6092.72" [38]=> string(7) "6088.91" [39]=> string(7) "6088.62" [40]=> string(7) "6088.62" [41]=> string(7) "6100.09" [42]=> string(7) "6089.32" [43]=> string(7) "6100.09" [44]=> string(7) "6091.53" [45]=> string(7) "6100.09" [46]=> string(7) "6091.53" [47]=> string(7) "6090.15" [48]=> string(7) "6089.14" [49]=> string(7) "6089.78" [50]=> string(7) "6091.53" [51]=> string(7) "6088.65" etc


is the range between these values too large, ie the difference too small?

also, how do i adjust how many points are drawn on the X axis? does it downsample the amount of points automatically, or can i adjust that? is this related to the number of labels on the x-scale?

looking forward to hear from you,
thanks!

bernhard

code is based entirely on the drawLineChart.simple example.


Wed Jan 11, 2012 3:35 am
Profile
Regular pChart user
Regular pChart user

Joined: Mon Dec 19, 2011 12:19 am
Posts: 14
Post Re: newbie, two things unclear
Please poste your code, with this i have a "good graph".
Maybe problem is YMargin
Code:
<?php   
/* CAT:Line chart */

/* pChart library inclusions */
include("../class/pData.class.php");
include("../class/pDraw.class.php");
include("../class/pImage.class.php");

/* Create and populate the pData object */
$MyData = new pData(); 
$MyData->addPoints(array(6084.89,6081.43,6081.43,6077.99,6073.75,6071.47),"Probe 1");
$MyData->setAxisName(0,"Temperatures");
$MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun"),"Labels");
$MyData->setSerieDescription("Labels","Months");
$MyData->setAbscissa("Labels");


/* Create the pChart object */
$myPicture = new pImage(600,80,$MyData);

/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;

/* Add a border to the picture */
$myPicture->drawRectangle(0,0,599,79,array("R"=>0,"G"=>0,"B"=>0));

/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));

/* Define the chart area */
$myPicture->setGraphArea(40,8,590,64);

/* Draw the scale */
$scaleSettings = array("XMargin"=>0,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
$myPicture->drawScale($scaleSettings);

/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;

/* Draw the line chart */
$myPicture->drawLineChart();

/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawLineChart.simple.png");
?>


Attachments:
ex.png
ex.png [ 3.8 KiB | Viewed 4450 times ]
Thu Jan 12, 2012 10:18 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron