View unanswered posts | View active topics It is currently Wed May 29, 2024 6:44 pm



Reply to topic  [ 1 post ] 
Questions: Decimal values and different scaling 
Author Message
New pChart user
New pChart user

Joined: Sat Jun 23, 2012 9:22 am
Posts: 1
Post Questions: Decimal values and different scaling
Hello experts,
I used pChart 2.0 to create some fancy statistics for my guild, playing an MMORPG game. It looks like this:
Image

Now I want two things:
- The "Gilden" Y-Axis should SCALE_START0, the others should SCALE_NORMAL (I only know how to do it for ALL axes)
- The "Ally-RP" Y-Axis should have only ONE decimal value (Just the labels, I dont want to round() the data!)

How do I do that?
Here is the code so far:
Code:
<?php   
//pChart library inclusions */
include("./pChart/class/pData.class.php");
include("./pChart/class/pDraw.class.php");
include("./pChart/class/pImage.class.php");

//Datenarrays vordefinieren
$datum=array();
$glwrp=array();
$grp=array();
$guilds=array();
$nr=0;
//Daten einlesen
$source="./pChart/brrpdata/allyrps.txt";
$daten= @fopen($source, 'r');
  if ($daten==FALSE){//Datei fehlt, hier stimmt was nicht
      exit();}
  else {
        while (!feof($daten)) {
        $zeilen = fgets($daten);
        $inhalt=explode('_',$zeilen);
        $datum[$nr]=$inhalt[0];
        $glwrp[$nr]=$inhalt[1];
        $grp[$nr]=$inhalt[2]/1000;
        $guilds[$nr]=$inhalt[3];
        $nr++;                         
        }
        fclose($daten);}

 
// Create and populate the pData object
$MyData = new pData(); 
$MyData->addPoints($grp,"Ally-RP");
$MyData->addPoints($glwrp,"Ally-LWRP");
$MyData->addPoints($guilds,"Gilden");

//Datum aufdröseln
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "M");
$MyData->addPoints($datum,"Labels");

$MyData->setSerieDescription("Labels","Zeit");
$MyData->setAbscissa("Labels");
$MyData->setSerieOnAxis("Ally-RP",0);
$MyData->setSerieOnAxis("Ally-LWRP",1);
$MyData->setSerieOnAxis("Gilden",2);
$MyData->setAxisColor(0,array("R"=>255,"G"=>160,"B"=>160));
$MyData->setAxisColor(1,array("R"=>190,"G"=>190,"B"=>240));
$MyData->setAxisColor(2,array("R"=>150,"G"=>205,"B"=>150));
$MyData->setAxisPosition(0,AXIS_POSITION_LEFT);
$MyData->setAxisPosition(1,AXIS_POSITION_RIGHT);
$MyData->setAxisPosition(2,AXIS_POSITION_LEFT);
$MyData->setAxisName(0,"Ally-RP (Mill)");
$MyData->setAxisName(1,"Ally-LWRP (K)");
$MyData->setAxisName(2,"Gilden");
$MyData->setSerieWeight("Ally-LWRP",0.5);
$MyData->setSerieWeight("Ally-RP",0.5);
$MyData->setSerieWeight("Gilden",0.5);
$Color1 = array("R"=>200, "G"=>68, "B"=>68);
$Color2 = array("R"=>190, "G"=>190, "B"=>240);
$Color3 = array("R"=>150,"G"=>205,"B"=>150);
$MyData->setPalette("Ally-RP",$Color1);
$MyData->setPalette("Ally-LWRP",$Color2);
$MyData->setPalette("Gilden",$Color3);


//Create the pChart object
$sizex=600;
$sizey=188;
$myPicture = new pImage($sizex,$sizey,$MyData,TRUE);

// Turn off Antialiasing
$myPicture->Antialias = FALSE;

// Draw the background
$Settings = array("R"=>51, "G"=>51, "B"=>51);
$myPicture->drawFilledRectangle(2,2,$sizex-3,$sizey-3,$Settings);   

// Add a border to the picture
$myPicture->drawRoundedRectangle(0,0,$sizex-1,$sizey-1,6,array("R"=>207,"G"=>95,"B"=>86));
$myPicture->drawRoundedRectangle(1,1,$sizex-2,$sizey-2,5,array("R"=>207,"G"=>95,"B"=>86));

// Write the chart title
$myPicture->setFontProperties(array("FontName"=>"./pChart/fonts/Fertigo_PRO.otf","FontSize"=>11));
$myPicture->drawText($sizex/2,5,"Allianz des Blutes - Summierte Reichspunkte",array("FontSize"=>12,"Align"=>TEXT_ALIGN_TOPMIDDLE, "R"=>255,"G"=>255,"B"=>255));

// Set the default font
$myPicture->setFontProperties(array("FontName"=>"./pChart/fonts/pf_arma_five.ttf","FontSize"=>8, "R"=>255,"G"=>255,"B"=>255));

// Define the chart area
$myPicture->setGraphArea(87,30,$sizex-50,$sizey-20);

// Draw the scale
$scaleSettings = array("LabelingMethod"=>LABELING_DIFFERENT , "DrawYLines"=>NONE, "XMargin"=>5,"YMargin"=>5,"Floating"=>TRUE,"Mode"=>SCALE_MODE_FLOATING,"AxisR"=>255,"AxisG"=>255,"AxisB"=>255,"TickR"=>207,"TickG"=>95,"TickB"=>86, "GridR"=>255,"GridG"=>255,"GridB"=>255,"DrawSubTicks"=>FALSE,"CycleBackground"=>TRUE);
$myPicture->drawScale($scaleSettings);

// Write the chart legend
$Size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend($sizex/2-$Size[Width]/2,25,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

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

// Draw the area chart
//$myPicture->drawAreaChart();
 
  // Draw a line and a plot chart on top
$myPicture->drawLineChart();
$myPicture->drawPlotChart(array("PlotBorder"=>TRUE,"PlotSize"=>2,"BorderSize"=>1,"Surrounding"=>-60,"BorderAlpha"=>80));

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


Thanks in advance for any hints!


Sat Jun 23, 2012 9:30 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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