function AdvisingScreen::draw_pie_chart_box

6.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

1 call 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.

File

classes/AdvisingScreen.php, line 1799

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_url() . "/libraries/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='pie-chart-individual-table pie-chart-individual-table-" . fp_get_machine_readable(strtolower($title)) . "' cellpadding='0' cellspacing='0' >
            <tr class='pie-chart-title-tr'>
                <td class='pie-chart-box-title-td' align='center' height='20'>
            " . fp_render_section_title($title, 'pie-chart-box-section') . "
                </td>
            </tr>
            <tr class='pie-chart-inner-table-tr'>
              <td class='pie-chart-inner-table-td'>
                <table border='0' class='pie-chart-chart-table'>
                <td class='pie-visualization'>                  
                  <img src='$pie_chart_url'>
                </td>
                <td class='pie-values'>
                    <div class='pie-val-percent'>
                      <span class='pie-val-percent-complete'>$val% <span class='pie-v-cap'>" . t("Complete") . "</span></span>
                    </div>
                    <div class='pie-val-top-bottom'>
                        ( <span class='pie-val-top-val'>$top_value</span>
                      / <span class='pie-val-bottom-val'>$bottom_value <span class='pie-v-cap'>" . t("hours") . "</span></span> )
                    </div>
                   $extra";

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

  return $rtn;
}