/** * reports_quick_graph() - Show a quick graph of data. * * @param string Graph title * @param int First query resource ID * @param int Second query resource ID * @param string The bar colors */ function reports_quick_graph($title, $sql1, $sql2, $bar_colors) { $result1 = db_query($sql1); $result2 = db_query($sql2); if ($result1 && $result2 && db_numrows($result2) > 0) { $assoc_open = util_result_columns_to_assoc($result1); $assoc_all = util_result_columns_to_assoc($result2); while (list($key, $val) = each($assoc_all)) { $titles[] = $key; $all[] = $val; if ($assoc_open[$key]) { $open[] = $assoc_open[$key]; } else { $open[] = 0; } } /* for ($i=0; $i<db_numrows($result1); $i++) { echo "$titles[$i]=>$opened[$i]/$all[$i]<br />"; } */ $scale = graph_calculate_scale(array($opened, $all), 400); $props["scale"] = $scale; $props["cellspacing"] = 5; $props = hv_graph_defaults($props); start_graph($props, $titles); horizontal_multisection_graph($titles, array($open, $all), $bar_colors, $props); end_graph(); print '<p /><br />'; print '<table cellspacing="0" border="0"><tr align="center"><td width="15%">' . _('Key') . ':</td><td width="5%">(</td><td width="35%" style="background-color:' . $bar_colors[0] . '">' . _('Open') . '</td>' . '<td width="5%">/</td><td width="35%" style="background-color:' . $bar_colors[1] . '">' . _('All') . ' </td><td width="5%">)</td></tr></table>'; print '<p />'; // GraphResult($result,$title); } else { echo "<h2>" . _('No data found to report') . "</h2>"; } }
function html_graph($names, $values, $bars, $vals, $dvalues = 0, $dbars = 0) { // set the error level on entry and exit so as not to interfear with anyone elses error checking. $er = error_reporting(1); // set the values that the user didn't $vals = hv_graph_defaults($vals); $html_graph_string = start_graph($vals, $names); if ($vals['type'] == 0) { $html_graph_string .= horizontal_graph($names, $values, $bars, $vals); } elseif ($vals['type'] == 1) { $html_graph_string .= vertical_graph($names, $values, $bars, $vals); } elseif ($vals['type'] == 2) { $html_graph_string .= double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars); } elseif ($vals['type'] == 3) { $html_graph_string .= double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars); } $html_graph_string .= end_graph(); // Set the error level back to where it was. error_reporting($er); return $html_graph_string; }
$nr = 2349; $oms = 'percentage HAVO/VWO geslaagden op totaal aantal geslaagden'; $graph = false; $eindjaar = false; $cols = array('val10', 'val11'); $scale = 100; $table_row = get_data_cols($cbs, $regio, $nr, $oms, $graph, $cols, $rand, $eindjaar, $scale, $cbs2, $regio2); echo $table_row; $bron[] = getsource(1687); $nr = 1687; $oms = 'achterstandsleerlingen (4-12 jaar)'; $col = 'val3'; $eindjaar = false; $table_row = get_data_abs($cbs, $nr, $oms, $regio, $cbs2, $regio2, $col, $eindjaar); echo $table_row; $rand = start_graph(); $nr = 1687; $oms = 'percentage achterstandsleerlingen op totaal aantal basisschoolleerlingen'; $graph = true; $eindjaar = false; $cols = array('val3', 'val7'); $scale = 100; $table_row = get_data_cols($cbs, $regio, $nr, $oms, $graph, $cols, $rand, $eindjaar, $scale, $cbs2, $regio2); echo $table_row; echo "</tbody>"; echo "</table>"; include 'source.php'; $graph_title = 'percentage achterstandsleerlingen'; $graph_type = 'single_bar_graph'; $xml_file = date("Ymd") . $rand; show_graph($graph_title, $graph_type, $rand, $xml_file, $cbs, $cbs2, $regio, $regio2);