public function parseData(array &$a_data)
 {
     parent::parseData($a_data);
     $fill = $this->getFill();
     if ($fill["color"] != "") {
         $a_data[count($a_data) - 1]->color = ilChart::renderColor($fill["color"], "0.5");
     }
 }
 /**
  * Get gap analysis html
  *
  * @param
  * @return
  */
 function getGapAnalysisHTML($a_user_id = 0, $a_skills = null)
 {
     global $ilUser, $lng;
     //		$this->setTabs("list_skills");
     if ($a_user_id == 0) {
         $user_id = $ilUser->getId();
     } else {
         $user_id = $a_user_id;
     }
     $skills = array();
     if ($this->getProfileId() > 0) {
         $profile = new ilSkillProfile($this->getProfileId());
         $this->profile_levels = $profile->getSkillLevels();
         foreach ($this->profile_levels as $l) {
             $skills[] = array("base_skill_id" => $l["base_skill_id"], "tref_id" => $l["tref_id"], "level_id" => $l["level_id"]);
         }
     } else {
         if (is_array($a_skills)) {
             $skills = $a_skills;
         }
     }
     // get actual levels for gap analysis
     $this->actual_levels = array();
     include_once "./Services/Skill/classes/class.ilBasicSkill.php";
     foreach ($skills as $sk) {
         $bs = new ilBasicSkill($sk["base_skill_id"]);
         if ($this->gap_mode == "max_per_type") {
             $max = $bs->getMaxLevelPerType($sk["tref_id"], $this->gap_mode_type, $user_id);
             $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
         } else {
             if ($this->gap_mode == "max_per_object") {
                 $max = $bs->getMaxLevelPerObject($sk["tref_id"], $this->gap_mode_obj_id, $user_id);
                 $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
             }
         }
     }
     $incl_self_eval = false;
     if (count($this->getGapAnalysisSelfEvalLevels() > 0)) {
         $incl_self_eval = true;
         $self_vals = $this->getGapAnalysisSelfEvalLevels();
     }
     // output spider stuff
     if (count($skills) >= 3) {
         $max_cnt = 0;
         $leg_labels = array();
         //var_dump($this->profile_levels);
         //foreach ($this->profile_levels as $k => $l)
         // write target, actual and self counter to skill array
         foreach ($skills as $k => $l) {
             //$bs = new ilBasicSkill($l["base_skill_id"]);
             $bs = new ilBasicSkill($l["base_skill_id"]);
             $leg_labels[] = $bs->getTitle();
             $levels = $bs->getLevelData();
             $cnt = 0;
             foreach ($levels as $lv) {
                 $cnt++;
                 if ($l["level_id"] == $lv["id"]) {
                     $skills[$k]["target_cnt"] = $cnt;
                 }
                 if ($this->actual_levels[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
                     $skills[$k]["actual_cnt"] = $cnt;
                 }
                 if ($incl_self_eval) {
                     if ($self_vals[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
                         $skills[$k]["self_cnt"] = $cnt;
                     }
                 }
                 $max_cnt = max($max_cnt, $cnt);
             }
         }
         //			$leg_labels = array("AAAAA", "BBBBB", "CCCCC");
         //var_dump($this->profile_levels);
         //var_dump($this->actual_levels);
         include_once "./Services/Chart/classes/class.ilChart.php";
         $chart = new ilChart("gap_chart", 600, 300);
         $chart->setYAxisMax($max_cnt);
         $chart->setLegLabels($leg_labels);
         // target level
         $cd = new ilChartData("spider");
         $cd->setLabel($lng->txt("skmg_target_level"));
         $cd->setFill("true", "#A0A0A0");
         // other users
         $cd2 = new ilChartData("spider");
         if ($this->gap_cat_title != "") {
             $cd2->setLabel($this->gap_cat_title);
         } else {
             if ($this->gap_mode == "max_per_type") {
                 $cd2->setLabel($lng->txt("objs_" . $this->gap_mode_type));
             } else {
                 if ($this->gap_mode == "max_per_object") {
                     $cd2->setLabel(ilObject::_lookupTitle($this->gap_mode_obj_id));
                 }
             }
         }
         $cd2->setFill("true", "#8080FF");
         // self evaluation
         if ($incl_self_eval) {
             $cd3 = new ilChartData("spider");
             $cd3->setLabel($lng->txt("skmg_self_evaluation"));
             $cd3->setFill("true", "#FF8080");
         }
         // fill in data
         $cnt = 0;
         foreach ($skills as $pl) {
             $cd->addPoint($cnt, (int) $pl["target_cnt"]);
             $cd2->addPoint($cnt, (int) $pl["actual_cnt"]);
             if ($incl_self_eval) {
                 $cd3->addPoint($cnt, (int) $pl["self_cnt"]);
             }
             $cnt++;
         }
         // add data to chart
         if ($this->getProfileId() > 0) {
             $chart->addData($cd);
         }
         $chart->addData($cd2);
         if ($incl_self_eval && count($this->getGapAnalysisSelfEvalLevels()) > 0) {
             $chart->addData($cd3);
         }
         $lg = new ilChartLegend();
         $chart->setLegend($lg);
         $chart_html = $chart->getHTML();
     }
     $stree = new ilSkillTree();
     $html = "";
     foreach ($skills as $s) {
         $path = $stree->getSkillTreePath($s["base_skill_id"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         $html .= $this->getSkillHTML($s["base_skill_id"], $user_id, false, $s["tref_id"]);
     }
     // list skills
     //		include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
     //		$sktab = new ilPersonalSkillTableGUI($this, "listSkills");
     return $chart_html . $html;
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstdly", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $max_value = 0;
     foreach ($this->getData() as $object) {
         if (in_array($object["obj_id"], $a_graph_items)) {
             $series = new ilChartData("lines");
             $series->setLabel(ilObject::_lookupTitle($object["obj_id"]));
             for ($loop = 0; $loop < 24; $loop++) {
                 $value = (int) $object["graph"]["hour" . $loop];
                 $max_value = max($max_value, $value);
                 if ($this->filter["measure"] != "spent_seconds") {
                     $value = $this->anonymizeValue($value, true);
                 }
                 $series->addPoint($loop, $value);
             }
             $chart->addData($series);
         }
     }
     $value_ticks = $this->buildValueScale($max_value, $this->filter["measure"] != "spent_seconds", $this->filter["measure"] == "spent_seconds");
     $labels = array();
     for ($loop = 0; $loop < 24; $loop++) {
         $labels[$loop] = str_pad($loop, 2, "0", STR_PAD_LEFT);
     }
     $chart->setTicks($labels, $value_ticks, true);
     return $chart->getHTML();
 }
 /**
  * Build chart for active sessions
  * 
  * @param array $a_data
  * @param string $a_title
  * @param int $a_scale
  * @param array $a_measure
  * @return string 
  */
 protected function getChart($a_data, $a_title, $a_scale = self::SCALE_DAY, $a_measure = null)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstacc", 700, 500);
     $chart->setYAxisToInteger(true);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     if (!$a_measure) {
         $a_measure = array("min", "avg", "max");
     } else {
         if (!is_array($a_measure)) {
             $a_measure = array($a_measure);
         }
     }
     $colors_map = array("min" => "#00cc00", "avg" => "#0000cc", "max" => "#cc00cc");
     $colors = $act_line = array();
     foreach ($a_measure as $measure) {
         $act_line[$measure] = new ilChartData("lines");
         $act_line[$measure]->setLineSteps(true);
         $act_line[$measure]->setLabel($lng->txt("trac_session_active_" . $measure));
         $colors[] = $colors_map[$measure];
     }
     if ($a_scale != self::SCALE_PERIODIC_WEEK) {
         $max_line = new ilChartData("lines");
         $max_line->setLabel($lng->txt("session_max_count"));
         $colors[] = "#cc0000";
     }
     $chart->setColors($colors);
     $chart_data = $this->adaptDataToScale($a_scale, $a_data, 700);
     unset($a_data);
     $scale = ceil(sizeof($chart_data) / 5);
     $labels = array();
     foreach ($chart_data as $idx => $item) {
         $date = $item["slot_begin"];
         if ($a_scale == self::SCALE_PERIODIC_WEEK || !($idx % ceil($scale))) {
             switch ($a_scale) {
                 case self::SCALE_DAY:
                     $labels[$date] = date("H:i", $date);
                     break;
                 case self::SCALE_WEEK:
                     $labels[$date] = date("d.m. H", $date) . "h";
                     break;
                 case self::SCALE_MONTH:
                     $labels[$date] = date("d.m.", $date);
                     break;
                 case self::SCALE_YEAR:
                     $labels[$date] = date("Y-m", $date);
                     break;
                 case self::SCALE_PERIODIC_WEEK:
                     $day = substr($date, 0, 1);
                     $hour = substr($date, 1, 2);
                     $min = substr($date, 3, 2);
                     // build ascending scale from day values
                     $day_value = ($day - 1) * 60 * 60 * 24;
                     $date = $day_value + $hour * 60 * 60 + $min * 60;
                     // 6-hour interval labels
                     if ($hour != $old_hour && $hour && $hour % 6 == 0) {
                         $labels[$date] = $hour;
                         $old_hour = $hour;
                     }
                     // day label
                     if ($day != $old_day) {
                         $labels[$date] = ilCalendarUtil::_numericDayToString($day, false);
                         $old_day = $day;
                     }
                     break;
             }
         }
         foreach ($a_measure as $measure) {
             $value = (int) $item["active_" . $measure];
             $act_line[$measure]->addPoint($date, $value);
         }
         if ($a_scale != self::SCALE_PERIODIC_WEEK) {
             $max_line->addPoint($date, (int) $item["max_sessions"]);
         }
     }
     foreach ($act_line as $line) {
         $chart->addData($line);
     }
     if ($a_scale != self::SCALE_PERIODIC_WEEK) {
         $chart->addData($max_line);
     }
     $chart->setTicks($labels, null, true);
     return $chart->getHTML();
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objsttp", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $types = array();
     foreach ($this->getData() as $id => $item) {
         $types[$id] = $item["title"];
     }
     foreach (array_values($this->getMonthsYear(null, true)) as $idx => $caption) {
         $labels[$idx + 1] = $caption;
     }
     $chart->setTicks($labels, false, true);
     foreach ($this->getData() as $type => $object) {
         if (in_array($type, $a_graph_items)) {
             $series = new ilChartData("lines");
             $series->setLabel($types[$type]);
             foreach (array_keys($this->getMonthsYear()) as $idx => $month) {
                 $series->addPoint($idx + 1, (int) $object["month_" . $month]);
             }
             $chart->addData($series);
         }
     }
     return $chart->getHTML();
 }
 protected function renderChart($a_id, $a_variables)
 {
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart($a_id, 700, 400);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $chart->setYAxisToInteger(true);
     $data = new ilChartData("bars");
     $data->setLabel($this->lng->txt("users_answered"));
     $data->setBarOptions(0.5, "center");
     $max = 5;
     if (sizeof($a_variables) <= $max) {
         if ($a_variables) {
             $labels = array();
             foreach ($a_variables as $idx => $points) {
                 $data->addPoint($idx, $points["selected"]);
                 $labels[$idx] = $idx + 1 . ". " . ilUtil::prepareFormOutput($points["title"]);
             }
             $chart->addData($data);
             $chart->setTicks($labels, false, true);
         }
         return "<div style=\"margin:10px\">" . $chart->getHTML() . "</div>";
     } else {
         $chart_legend = array();
         $labels = array();
         foreach ($a_variables as $idx => $points) {
             $data->addPoint($idx, $points["selected"]);
             $labels[$idx] = $idx + 1 . ".";
             $chart_legend[$idx + 1] = ilUtil::prepareFormOutput($points["title"]);
         }
         $chart->addData($data);
         $chart->setTicks($labels, false, true);
         $legend = "<table>";
         foreach ($chart_legend as $number => $caption) {
             $legend .= "<tr valign=\"top\"><td>" . $number . ".</td><td>" . $caption . "</td></tr>";
         }
         $legend .= "</table>";
         return "<div style=\"margin:10px\"><table><tr valign=\"bottom\"><td>" . $chart->getHTML() . "</td><td class=\"small\" style=\"padding-left:15px\">" . $legend . "</td></tr></table></div>";
     }
 }
 protected function renderChart($a_id, $a_values)
 {
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart($a_id, 700, 400);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $data = new ilChartData("bars");
     $data->setLabel($this->lng->txt("users_answered"));
     $data->setBarOptions(0.1, "center");
     if ($a_values) {
         $labels = array();
         foreach ($a_values as $idx => $answer) {
             $data->addPoint($answer["value"], $answer["selected"]);
             $labels[$answer["value"]] = $answer["value"];
         }
         $chart->addData($data);
         $chart->setTicks($labels, false, true);
     }
     return "<div style=\"margin:10px\">" . $chart->getHTML() . "</div>";
 }
 function getGraph(array $a_graph_items)
 {
     global $lng;
     include_once "Services/Chart/classes/class.ilChart.php";
     $chart = new ilChart("objstacc", 700, 500);
     $legend = new ilChartLegend();
     $chart->setLegend($legend);
     $max_value = 0;
     foreach ($this->getData() as $object) {
         if (in_array($object["obj_id"], $a_graph_items)) {
             $series = new ilChartData("lines");
             $series->setLabel(ilObject::_lookupTitle($object["obj_id"]));
             if (strpos($this->filter["yearmonth"], "-") === false) {
                 foreach (array_keys($this->getMonthsYear($this->filter["yearmonth"])) as $idx => $num) {
                     $value = (int) $object["month_" . $num];
                     $max_value = max($max_value, $value);
                     if ($this->filter["measure"] != "spent_seconds") {
                         $value = $this->anonymizeValue($value, true);
                     }
                     $series->addPoint($idx, $value);
                 }
             } else {
                 for ($loop = 1; $loop < 32; $loop++) {
                     $value = (int) $object["day_" . $loop];
                     $max_value = max($max_value, $value);
                     if ($this->filter["measure"] != "spent_seconds") {
                         $value = $this->anonymizeValue($value, true);
                     }
                     $series->addPoint($loop, $value);
                 }
             }
             $chart->addData($series);
         }
     }
     $value_ticks = $this->buildValueScale($max_value, $this->filter["measure"] != "spent_seconds", $this->filter["measure"] == "spent_seconds");
     $labels = array();
     if (strpos($this->filter["yearmonth"], "-") === false) {
         foreach (array_values($this->getMonthsYear($this->filter["yearmonth"], true)) as $idx => $caption) {
             $labels[$idx] = $caption;
         }
     } else {
         for ($loop = 1; $loop < 32; $loop++) {
             $labels[$loop] = $loop . ".";
         }
     }
     $chart->setTicks($labels, $value_ticks, true);
     return $chart->getHTML();
 }