Need help understanding a script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • orfiyus
    New Member
    • Jul 2007
    • 36

    #1

    Need help understanding a script

    Hi

    I am working on a script that that creates charts. So I decided to follow this tutorial using the chart director api. I more or less understand everything going on I just cant seem to find where they get the numbers from for the y-axis. Wut this tutorial script does is it output data into a multi line chart. All I need to is the thing I said about the y-axis. If someone can take a look for me that would be great.

    Thanks

    Heres the script. Its short so Im putting the whole thing.

    [CODE=php]
    <?php
    require_once("p hpchartdir.php" );
    //Arrays to hold the data to be graphed in the chart
    $data0 = array(42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56,
    60, 70, 76, 63, 67, 75, 64, 51);
    $data1 = array(50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58,
    59, 73, 77, 84, 82, 80, 84, 98);
    $data2 = array(36, 28, 25, 33, 38, 20, 22, 30, 25, 33, 30, 24, 28, 15, 21, 26, 46,
    42, 48, 45, 43, 52, 64, 60, 70);
    $data3 = array(37, 29, 26, 34, 39, 21, 23, 31, 26, 34, 31, 25, 29, 16, 22, 27, 47,
    43, 49, 46, 44, 53, 65, 61, 71);

    // The labels for the line chart on the x-axis (as of right now).
    $labels = array("00000", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
    "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24");

    //Creates the the background for the chart. with specified number of pixels as well as specified colors.
    //And a rounded frame.
    $c = new XYChart(600, 300, 0xeeeeff, 0x000000, 1);
    $c->setRoundedFram e();

    //Draws the picture inside the light blue background.
    $c->setPlotArea(55 , 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);

    //Creates a legend box at the top describing what color
    //represents what server.
    $legendObj = $c->addLegend(50 , 30, false, "arialbd.tt f", 9);
    $legendObj->setBackground( Transparent);

    //Adds title box at the top of the chart.
    $textBoxObj = $c->addTitle("Appl ication Server Throughput55555 ", "timesbi.tt f", 15);
    $textBoxObj->setBackground( 0xccccff, 0x000000, glassEffect());

    //Add a title to the y axis
    $c->yAxis->setTitle("MByt es per hour5555555");

    // Sets the labels on the x-axis
    $c->xAxis->setLabels($lab els);

    //Outputs the labels to the x-axis
    //The argument is the number that it skips
    //if the argument is 3 it skips every 3 e.g. 3,6,9....etc.
    $c->xAxis->setLabelStep(4 );

    //Add a title to the x axis
    $c->xAxis->setTitle("X-axis");

    //Add a line layer to the chart
    $layer = $c->addLineLayer2( );

    //Set the default line width to 2 pixels
    $layer->setLineWidth(2 );

    //outputs the information from the data arrays
    $layer->addDataSet($da ta0, 0xff0000, "Server #1");
    $layer->addDataSet($da ta1, 0x008800, "Server #2");
    $layer->addDataSet($da ta2, $c->dashLineColor( 0x3333ff, DashLine), "Server #3");
    $layer->addDataSet($da ta3, 0xFFFF00, "Server#4") ;

    //output the entire chart.
    header("Content-type: image/png");
    print($c->makeChart2(PNG ));
    ?>
    [/CODE]
    Last edited by pbmods; Sep 20 '07, 11:14 PM. Reason: Changed [CODE] to [CODE=php].
  • orfiyus
    New Member
    • Jul 2007
    • 36

    #2
    NM I got it. Thanks. It seems just posting something helps me think of a way to find the answer. Mods can delete this thread.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, Orfiyus.

      Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

      Comment

      Working...