Skip to content

Instantly share code, notes, and snippets.

@viccherubini
Created August 5, 2010 22:52
Show Gist options
  • Select an option

  • Save viccherubini/510539 to your computer and use it in GitHub Desktop.

Select an option

Save viccherubini/510539 to your computer and use it in GitHub Desktop.
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_line.php');
$data1 = array(
'2010-06-15' => 10454,
'2010-06-16' => 12321,
'2010-06-17' => 8956,
'2010-06-18' => 2365,
'2010-06-19' => 7854,
'2010-06-20' => 4877,
'2010-06-21' => 14566,
'2010-06-22' => 7856
);
$data2 = array(
'2010-06-23' => 10566,
'2010-06-24' => 11899,
'2010-06-25' => 5600,
'2010-06-26' => 7856,
'2010-06-27' => 8999,
'2010-06-28' => 9875,
'2010-06-29' => 12458,
'2010-06-30' => 11789
);
$data = array_merge($data1, $data2);
$graph = new Graph(1200, 480);
$graph->SetScale('intint');
$graph->img->SetMargin(60,60,40,80);
$graph->SetMargin(60,60,40,80);
$graph->SetMarginColor('lightblue@0.5');
$graph->title->Set("Baseline Variable: Cart Engagements");
$graph->title->SetFont(FF_TREBUCHE, FS_NORMAL, 18);
$p1 = new LinePlot(array_values($data));
$tickLabels = array_merge(array_keys($data1), array_keys($data2));
$graph->ygrid->Show(true);
$graph->ygrid->SetColor('lightgray@0.8');
$graph->yaxis->SetFont(FF_TREBUCHE, FS_BOLD, 8);
$graph->yaxis->HideZeroLabel(true);
$graph->xgrid->Show(true);
$graph->xgrid->SetColor('lightgray@0.8');
$graph->xaxis->SetTickLabels($tickLabels);
$graph->xaxis->SetFont(FF_TREBUCHE,FS_BOLD, 8);
$graph->xaxis->SetWeight(2);
$graph->xaxis->SetLabelAngle(0);
$p1->AddArea(0, 8, LP_AREA_FILLED, 'red@0.75', LP_AREA_BORDER);
$p1->AddArea(8, 16, LP_AREA_FILLED, 'green@0.75', LP_AREA_BORDER);
$p1->SetColor('darkgreen');
$p1->SetStepStyle(false);
$p1->SetWeight(2);
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("darkgreen@0.5");
$p1->mark->SetColor('darkgreen@0.5');
$p1->mark->SetWidth(3);
$p1->value->Show();
$p1->value->SetFont(FF_ARIAL, FS_ITALIC, 8);
$p1->value->SetColor('black');
$p1->value->SetFormat('%d');
$p1->value->SetMargin(20);
$p1->value->SetAlign('center', '');
$graph->Add($p1);
$graph->Stroke();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment