function _AdvisingScreen::draw_pie_chart_box

4.x _AdvisingScreen.php _AdvisingScreen::draw_pie_chart_box($title, $top_value, $bottom_value, $pal)
5.x _AdvisingScreen.php _AdvisingScreen::draw_pie_chart_box($title, $top_value, $bottom_value, $pal = "", $back_col = "", $fore_col = "", $extra = "")

This function is used to draw an individual pie chart box. It accepts values of top/bottom in order to come up with a percentage.

Parameters

string $title:

float $top_value:

  • The top part of a ratio. Ex: for 1/2, $top_value = 1.

float $bottom_value:

  • The bottom part of a ratio. For 1/2, $bottom_value = 2.
  • Do not let this equal zero. If it does, the calculation for the pie chart will never be evaluated.

string $pal:

  • Which palette to use for the pie chart. If set, fore_col will be ignored in the argument list.
  • Acceptable values:
    • core
    • major
    • cumulative
    • student

string $back_col:

  • If $pal is left blank, the value here will be used for the "back" or "unfinished" color.

string $fore_col:

  • If $pal is left blank, the value here will be used for the "foreground" or "progress" color.

Return value

string

2 calls to _AdvisingScreen::draw_pie_chart_box()
_AdvisingScreen::draw_progress_boxes in classes/_AdvisingScreen.php
This function calls drawPieChart to construct the student's 3 progress pie charts.
_AdvisingScreen::z__old__draw_progress_boxes in classes/_AdvisingScreen.php
This function calls drawPieChart to construct the student's 3 progress pie charts.

File

classes/_AdvisingScreen.php, line 1531

Class

_AdvisingScreen

Code

function draw_pie_chart_box($title, $top_value, $bottom_value, $pal = "", $back_col = "", $fore_col = "", $extra = "") 
 {
  $rtn = "";

  $val = 0;

  if ($bottom_value > 0) {
    $val = round(($top_value / $bottom_value) * 100);
  }
  if ($val > 100) {
    $val = 100;
  }

  $leftval = 100 - $val;

  if ($back_col == "") {
    $back_col = "660000";
  }
  if ($fore_col == "") {
    $fore_col = "FFCC33";
  }

  if ($pal == "major") {
    $fore_col = "93D18B";
  }

  if ($pal == "cumulative") {
    $fore_col = "5B63A5";
  }

  // Remove # from colors, if needed.
  $fore_col = str_replace("#", "", $fore_col);
  $back_col = str_replace("#", "", $back_col);


  $vval = $val;
  if ($vval < 1) {
    $vval = 1;
  }

  // Create a graph using our built-in pchart api:		
  // First, establish a token to we know the script is being called from US:
  if (!isset($_SESSION ["fp_pie_chart_token"])) {
    $_SESSION ["fp_pie_chart_token"] = md5(fp_token());
  }
  //old Google API url: $pie_chart_url = "https://chart.googleapis.com/chart?cht=p&chd=t:$vval,$leftval&chs=75x75&chco=$fore_col|$back_col&chp=91.1";
  $pie_chart_url = base_path() . "/inc/pchart/fp_pie_chart.php?progress=$vval&unfinished=$leftval&unfinished_col=$back_col&progress_col=$fore_col&token=" . $_SESSION ["fp_pie_chart_token"];


  $rtn .= "<table border='0' width='100%'  height='100' class='elevenpt blueBorder' cellpadding='0' cellspacing='0' >
 						<tr>
  							<td class='blueTitle' align='center' height='20'>
    				" . fp_render_square_line($title) . "
  							</td>
 						</tr>
 						<tr>
 							<td>
 								<table border='0'>
 								<td> 									
 									<img src='$pie_chart_url'>
 								</td>
 								<td class='elevenpt'>
 								    <span style='color: blue;'>$val% " . t("Complete") . "</span><br>
 								    ( <span style='color: blue;'>$top_value</span>
 									 / <span style='color: gray;'>$bottom_value " . t("hours") . "</span> )
 									 $extra";

  $rtn .= "
								</td>
								</table>
 							</td>
 						</tr>
 					</table>
				";

  return $rtn;
}