use Amenadiel\JpGraph\Plot; $month = array("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"); // Create some datapoints $steps = 100; for ($i = 0; $i < $steps; ++$i) { $databarx[] = sprintf("198%d %s", floor($i / 12), $month[$i % 12]); $datay[$i] = log(pow($i, $i / 10) + 1) * sin($i / 15) + 35; if ($i % 6 == 0 && $i < $steps - 6) { $databary[] = abs(25 * sin($i) + 5); } else { $databary[] = 0; } } // new Graph\Graph with a background image and drop shadow $graph = new Graph\Graph(450, 300); $graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME); $graph->SetShadow(); // Use text X-scale so we can text labels on the X-axis $graph->SetScale("textlin"); // Y2-axis is linear $graph->SetY2Scale("lin"); // Color the two Y-axis to make them easier to associate // to the corresponding plot (we keep the axis black though) $graph->yaxis->SetColor("black", "red"); $graph->y2axis->SetColor("black", "orange"); // Set title and subtitle $graph->title->Set("Combined bar and line plot"); $graph->subtitle->Set("100 data points, X-Scale: 'text'"); // Use built in font (don't need TTF support) $graph->title->SetFont(FF_FONT1, FS_BOLD); // Make the margin around the plot a little bit bigger then default
// content="text/plain; charset=utf-8" require_once '../../vendor/autoload.php'; use Amenadiel\JpGraph\Graph; use Amenadiel\JpGraph\Plot; // Some data $ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7); // Create the graph. These two calls are always required $graph = new Graph\Graph(350, 250); $graph->SetScale("textlin"); $graph->SetMargin(40, 40, 50, 50); // Setup the grid and plotarea box $graph->ygrid->SetLineStyle('dashed'); $graph->ygrid->setColor('darkgray'); $graph->SetBox(true); // Steup graph titles $graph->title->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->title->Set('Using background image'); $graph->subtitle->SetFont(FF_COURIER, FS_BOLD, 11); $graph->subtitle->Set('"BGIMG_COPY"'); $graph->subtitle->SetColor('darkred'); // Add background with 25% mix $graph->SetBackgroundImage('heat1.jpg', BGIMG_COPY); $graph->SetBackgroundImageMix(25); // Create the linear plot $lineplot = new Plot\LinePlot($ydata); $lineplot->SetColor("blue"); // Add the plot to the graph $graph->Add($lineplot); // Display the graph $graph->Stroke();
$datay1 = array(140, 110, 50, 60); $datay2 = array(35, 90, 190, 190); $datay3 = array(20, 60, 70, 140); // Create the basic graph $graph = new Graph\Graph(450, 250, 'auto'); $graph->SetScale("textlin"); $graph->img->SetMargin(40, 80, 30, 40); // Adjust the position of the legend box $graph->legend->Pos(0.02, 0.15); // Adjust the color for theshadow of the legend $graph->legend->SetShadow('darkgray@0.5'); $graph->legend->SetFillColor('lightblue@0.3'); // Get localised version of the month names $graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth()); // Set a nice summer (in Stockholm) image $graph->SetBackgroundImage('stship.jpg', BGIMG_COPY); // Set axis titles and fonts $graph->xaxis->title->Set('Year 2002'); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetColor('white'); $graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetColor('white'); $graph->yaxis->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->SetColor('white'); //$graph->ygrid->Show(false); $graph->ygrid->SetColor('white@0.5'); // Setup graph title $graph->title->Set('Using alpha blending with a background'); // Some extra margin (from the top) $graph->title->SetMargin(3); $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);