Contents
Login Register Wishes Forum About
Language Reference » Dataset functions » addRandomValues
Help topics
Latest updates
2054d  replaceImageMapTitle
2054d  replaceImageMapValues
2054d  createFunctionSerie
2054d  setAbsicssaPosition
2054d  negateValues
Toolbox
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
addRandomValues - Create a randomized serie

This function allow you to populate your data series with random values. You can manage multiple data series in a single pData object. It is possible to set extra parameters with the $Option array. To learn more about this please read the Format array guide.

Calling this function
addRandomValues($SerieName="Serie1",$Option="");
Where :

SerieName is the name of the serie where you want to add random points.
Option is an array containing some extra parameters.

If SerieName isn‘t provided, the points will be added to Serie1.

Customisation array - Extra parameters

It is possible to give extra parameters to the randomizer engine. If nothing is provided, 20 integers between 0 and 100 will be added to the selected serie.

The number of values to add can be set with Values.
The min value can be set with Min.
The max value can be set with Max.
If you want float values, you can set withFloat to TRUE.

Sample script #1

 /* Add a 20 random integers between 0-100 in Serie1 */
 $myData->addRandomValues();

 /* Add a 10 random integers between 0-100 in Serie2 */
 $randomOptions = array("Values"=>10);
 $myData->addRandomValues("Serie2",$randomOptions);

 /* Add a 100 random floats between 10-20 in Serie3 */
 $randomOptions = array("Values"=>100,"Min"=>10,"Max"=>20,"withFloat"=>TRUE);
 $myData->addRandomValues("Serie3",$randomOptions);

This will populate Serie1, Serie2, Serie3 with random values.

Sample script #2


 include("class/pData.class.php");
 include("class/pDraw.class.php");
 include("class/pImage.class.php");

 $MyData = new pData();  
 $MyData->addRandomValues("Probe 1",array("Values"=>50,"Min"=>0,"Max"=>4));
 $MyData->addRandomValues("Probe 2",array("Values"=>50,"Min"=>6,"Max"=>10));
 $MyData->addRandomValues("Probe 3",array("Values"=>50,"Min"=>12,"Max"=>16));
 $MyData->addRandomValues("Probe 4",array("Values"=>50,"Min"=>18,"Max"=>22));
 $MyData->setAxisName(0,"Probes");

 $myPicture = new pImage(700,230,$MyData);
 $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>180,"StartG"=>193,"StartB"=>91,"EndR"=>120,"EndG"=>137,"EndB"=>72,"Alpha"=>100));
 $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,array("StartR"=>180,"StartG"=>193,"StartB"=>91,"EndR"=>120,"EndG"=>137,"EndB"=>72,"Alpha"=>20));
 $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>100));
 $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
 
 $myPicture->setFontProperties(array("FontName"=>"fonts/Silkscreen.ttf","FontSize"=>6));
 $myPicture->drawText(10,13,"addRandomValues() :: assess your scales",array("R"=>255,"G"=>255,"B"=>255));

 $myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>11));
 $myPicture->setGraphArea(50,60,670,190);
 $myPicture->drawFilledRectangle(50,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
 $myPicture->drawScale(array("LabelSkip"=>3,"DrawSubTicks"=>TRUE));

 $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
 $myPicture->drawText(50,52,"Magnetic noise",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMLEFT));

 $myPicture->setFontProperties(array("FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
 $myPicture->drawSplineChart();
 $myPicture->setShadow(FALSE);

 $myPicture->drawLegend(475,50,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

 $myPicture->Render("addrandomvalues.png");
Last updated on 12/14/2010 
by Jean-Damien 
Linked resources
Community comments
  No comments have been posted yet.
© 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.