<?php

require_once "../../ScatterPlot.class.php";
$graph = new Graph(300, 280);
$graph->title->set('Linked ScatterPlot');
$graph->title->setFont(new TuffyItalic(14));
$graph->shadow->setSize(4);
$y = array(1, 10, 7, 8, 5, 4, 2, 4);
$x = array(0.5, 0.5, 1.5, 4, 3, 5, 2, 2);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new Color(235, 235, 235));
$plot->mark->setSize(15);
$plot->mark->setFill(new RadialGradient(new LightGreen(), new DarkGreen()));
$plot->link(TRUE);
$plot->setColor(new DarkGreen());
$plot->setSpace(6, 6, 6, 0);
$plot->setPadding(25, NULL, 40, 20);
$graph->add($plot);
$graph->draw();
Example #2
0
    $plot->mark->setSize(make_num('prv_mark', 10));
    $plot->mark->setFill(make_color('prv_markcolor', 'F0F0F0'));
    $plot->setThickness(make_num('prv_thick', 5));
    $plot->setYAxis(PLOT_LEFT);
    $plot->setYMin($min);
    $plot->setYMax($max);
    $grp->add($plot);
}
if ($val_ytd) {
    $xkeys = array();
    foreach ($val_ytd as $k => $v) {
        $xkeys[$k] = $k + 0.5;
    }
    //for ($i=0;isset($val_ytd[$i]);$i++) $xkeys[$i]=$i+.5;
    $plot = new ScatterPlot(array_values($val_ytd), array_values($xkeys));
    $plot->link(TRUE, make_color('ytd_color', '40FFFF'));
    $plot->mark->setSize(make_num('ytd_mark', 10));
    $plot->mark->setFill(make_color('ytd_markcolor', 'F0F0F0'));
    $plot->setThickness(make_num('ytd_thick', 5));
    $plot->setYAxis(PLOT_LEFT);
    $plot->setYMin($min);
    $plot->setYMax($max);
    $grp->add($plot);
}
$grp->axis->bottom->setLabelText(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
$grp->axis->left->label->setCallbackFunction('FmtAmount');
set_font($grp->axis->bottom->label, 'x_font');
set_font($grp->axis->left->label, 'y_font');
set_font($grp->axis->right->label, 'y_font');
$graph->border->hide();
$grp->setBackgroundColor(make_color('bg_color', 'FFFFFF'));
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.82, 0.1);
$group->legend->setAlign(LEGEND_CENTER, LEGEND_MIDDLE);
function getCircle($size)
{
    $center = 0;
    $x = array();
    $y = array();
    for ($i = 0; $i <= 20; $i++) {
        $rad = $i / 20 * 2 * M_PI;
        $x[] = $center + cos($rad) * $size;
        $y[] = $center + sin($rad) * $size;
    }
    return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue());
$plot->mark->setFill(new DarkPink());
$plot->mark->setType(MARK_CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', LEGEND_MARK);
$group->add($plot);
list($x, $y) = getCircle(5);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkGreen());
$plot->mark->setFill(new DarkOrange());
$plot->mark->setType(MARK_SQUARE, 4);
$group->legend->add($plot, 'Circle #2', LEGEND_MARK);
$group->add($plot);
$graph->add($group);
$graph->draw();
<?php

require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Linked ScatterPlot');
$y = array(1, 10, 3, -4, 1, 4, 8, 7);
$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray());
$plot->setPadding(NULL, NULL, 40, 20);
$plot->link(TRUE, new DarkBlue());
$graph->add($plot);
$graph->draw();