Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // content="text/plain; charset=utf-8"
- require_once ('jpgraph/src/jpgraph.php');
- require_once ('jpgraph/src/jpgraph_line.php');
- require_once ('jpgraph/src/jpgraph_scatter.php');
- //data goes here
- $datay1 = array(15,21,24,10,37,29,47);
- // Setup the graph
- $graph = new Graph(1000,800);
- $graph->SetScale("textlin",0,50);
- $graph->title->Set("Military Expendture (% GDP)");
- $graph->SetBox(false);
- $graph->yaxis->HideLine(false);
- $graph->yaxis->HideTicks(false,false);
- $graph->yaxis->HideZeroLabel();
- //get data for x axis
- function xaxislabels()
- {
- //variables
- $serveraddress = "r76frpf2a1.database.windows.net,1433";
- $servername = "militaryexpenditure";
- $username = "militaryexpenditure";
- $password = "Cosmocat17";
- $conn = new PDO ("sqlsrv:server = $serveraddress; Database = $servername", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $data = $conn->prepare("SELECT [Country Name] FROM Expenditure");
- $data->execute();
- $countrydata = array();
- $i = 0;
- while($column = $data->fetch(PDO::FETCH_ASSOC))
- {
- $countrydata[$i++] = $column;
- }
- $graph->xaxis->SetTickLabels->(array($countrydata);
- }
- //labelling axis
- xaxislabels();
- //creating the plot
- $p1 = new LinePlot($datay1);
- $graph->Add($p1);
- //image for markers
- $p1->mark->SetType(MARK_IMG,'sunflower.gif',1.0);
- $p1->SetLegend('pew');
- $p1->SetColor('#CD5C5C');
- $graph->Stroke();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement