Created
February 5, 2020 06:55
-
-
Save gnh1201/f7cd2b2a6fdc222679e7bcf628730e35 to your computer and use it in GitHub Desktop.
jpgraph_stroke.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once ('vendor/_dist/jpgraph/src/jpgraph.php'); | |
| require_once ('vendor/_dist/jpgraph/src/jpgraph_bar.php'); | |
| $id = get_requested_value("id"); | |
| // get extension information | |
| $bind = array( | |
| "id" => $id | |
| ); | |
| $sql = get_bind_to_sqlx("extlist_get_freq_by_id", $bind); | |
| $extension = exec_db_fetch($sql, $bind); | |
| // get similarity frequency items | |
| $bind = array( | |
| "id" => $id, | |
| "freq" => $extension['freq'], | |
| "dt" => $extension['created_on'] | |
| ); | |
| $sql = get_bind_to_sqlx("extlist_get_freq_by_value", $bind); | |
| $rows = exec_db_fetch_all($sql, $bind); | |
| $gdata = array( | |
| array() | |
| ); | |
| $glabels = array(); | |
| foreach($rows as $row) { | |
| $gdata[0][] = $row['_rel_freq']; | |
| $glabels[] = $row['identifier']; | |
| } | |
| // Create the graph. These two calls are always required | |
| $graph = new Graph(640, 320, 'auto'); | |
| $graph->SetScale("textlin"); | |
| $theme_class=new UniversalTheme; | |
| $graph->SetTheme($theme_class); | |
| //$graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135)); | |
| $graph->SetBox(false); | |
| $graph->ygrid->SetFill(false); | |
| $graph->xaxis->SetTickLabels($glabels); | |
| $graph->yaxis->HideLine(false); | |
| $graph->yaxis->HideTicks(false); | |
| // Create the bar plots | |
| $gplots = array(); | |
| foreach($gdata as $gd) { | |
| $gplots[] = new BarPlot($gd); | |
| } | |
| $gplots[0]->setLegend("Compatitive"); | |
| // Create the grouped bar plot | |
| $gbplot = new GroupBarPlot($gplots); | |
| // ...and add it to the graPH | |
| $graph->legend->SetPos(0.0,0.0,'right','top'); | |
| $graph->img->SetTransparent("white"); | |
| $graph->Add($gbplot); | |
| /* | |
| $b1plot->SetColor("white"); | |
| $b1plot->SetFillColor("#cc1111"); | |
| $b2plot->SetColor("white"); | |
| $b2plot->SetFillColor("#11cccc"); | |
| $b3plot->SetColor("white"); | |
| $b3plot->SetFillColor("#1111cc"); | |
| */ | |
| $graph->title->Set(sprintf("Compatitives and %s", $extension['identifier'])); | |
| // Display the graph | |
| $graph->Stroke(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment