Login Register Wishes Forum About
Language Reference » Dataset functions » setAxisDisplay
Help topics
Latest updates
1998d  replaceImageMapTitle
1998d  replaceImageMapValues
1998d  createFunctionSerie
1998d  setAbsicssaPosition
1998d  negateValues
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
setAxisDisplay - Define the way to show values on one Y Axis

This function allows you to set the kind of data to display on the Y Axis. Depending on the type choosen, data will be computed in different ways. Values on this axis are automatically computed by the scaling algorithm.

By default all new series are binded to the default axis with an ID of 0. You can bind a serie to another axis using the setSerieOnAxis function.

Calling this function

Where :

AxisID is the ID of the axis we want to name.
Mode is the kind of data that will be displayed.
Format is the way to display in the associated mode.

Valid Mode possible values are :

AXIS_FORMAT_DEFAULT to display raw data.
AXIS_FORMAT_TIME to convert to time (HH:MM:SS).
AXIS_FORMAT_DATE to convert to date (D/M/Y).
AXIS_FORMAT_METRIC to convert to metric values (1k).
AXIS_FORMAT_CURRENCY to convert to curencies (1.200).
AXIS_FORMAT_CUSTOM to use a custom callback.

Depending on the choosen Mode, you can specify a custom format using the Format parameter. Valid formats are :

For AXIS_FORMAT_TIME values you may provide a PHP date format. (like "H:i:s")
For AXIS_FORMAT_DATE values you may provide a PHP date format. (like "d/m/y")
For AXIS_FORMAT_CURENCY values you may provide a currency. (like $ or )
For AXIS_FORMAT_CUSTOM values you must provide a function name. (see example)

Sample script #1

 /* Create the pData object */
 $MyData = new pData(); 

 /* The default ordinate axis will use metric conversion of the values */
 /* The second ordinate axis will use time with a custom display mask */

Sample script #2

 $MyData = new pData();  

 /* Prepare some nice data & axis config */
 $MyData->setAxisName(0,"$ Incomes");

 /* Define the graph area and do some makeup */
 $myPicture = new pImage(700,230,$MyData);
 $myPicture->drawText(60,35,"2k9 Average Incomes",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMLEFT));

 /* Compute and draw the scale */

 /* Build the chart */

 /* Write the legend */

Sample script #3

 /* pChart library inclusions */ 

 /* Create and populate the pData object */ 
 $MyData = new pData();   
 $MyData->setAxisName(0,"Maximum distance"); 

 /* Create the abscissa serie */ 
 $MyData->setSerieDescription("Timestamp","Sampled Dates"); 

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

 /* Draw the background */ 
 $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);

 /* Overlay with a gradient */ 
 $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
 /* Add a border to the picture */ 
 /* Write the picture title */  
 $myPicture->drawText(10,13,"drawScale() - draw the X-Y scales",array("R"=>255,"G"=>255,"B"=>255));
 /* Set the default font */ 
 /* Draw the scale */ 
 /* Write the chart title */ 
 $myPicture->drawText(350,55,"My chart title",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
 /* Render the picture (choose the best way) */ 

 function YAxisFormat($Value) { return(round($Value/1000,2)."k"); } 
 function XAxisFormat($Value) { return((($Value-1230768000)/(60*60*24))." day"); }
Last updated on 12/03/2009 
by Jean-Damien 
Linked resources
Community comments
Message from kfmfe04 on 16/04/2011
If you use AXIS_FORMAT_TIME in conjunction with MySQL, make sure that you convert your dates and datetimes to timestamp by using the MySQL function UNIX_TIMESTAMP(). Without this conversion, pChart will misinterpret your input.
In other words, you need an integer timestamp, not the a datetime string.
For example, for "2011-04-16 21:13:30", you do not want the datetime string. Instead, you want SELECT("2011-04-16 21:13:30") or 1302959610 fed into pChart.
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 409 users have registered. This page has been rendered in 0,01 seconds. Wiki revision 1.37.