/**
  * @param tx_caretaker_AbstractNode $node
  * @return bool|string
  */
 function getNodeChart($node)
 {
     $chart = false;
     $range = 24;
     if ($this->piVars['range']) {
         $range = (int) $this->piVars['range'];
     }
     $id = $node->getCaretakerNodeID();
     $result_range = $node->getTestResultRange(time() - 3600 * $range, time());
     $filename = 'typo3temp/caretaker/charts/' . $id . '_' . $range . '.png';
     $base = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     if (is_a($node, 'tx_caretaker_TestNode')) {
         $TestResultRangeChartRenderer = new tx_caretaker_TestResultRangeChartRenderer();
         $TestResultRangeChartRenderer->setTitle($node->getTitle());
         $TestResultRangeChartRenderer->setTestResultRange($result_range);
         $result = $TestResultRangeChartRenderer->getChartImageTag($filename, $base);
         if ($result) {
             $chart = $result;
         } else {
             $chart = 'Graph Error';
         }
     } else {
         if (is_a($node, 'tx_caretaker_AggregatorNode')) {
             $TestResultRangeChartRenderer = new tx_caretaker_AggregatorResultRangeChartRenderer();
             $TestResultRangeChartRenderer->setTitle($node->getTitle());
             $TestResultRangeChartRenderer->setAggregatorResultRange($result_range);
             $result = $TestResultRangeChartRenderer->getChartImageTag($filename, $base);
             if ($result) {
                 $chart = $result;
             } else {
                 $chart = 'Graph Error';
             }
         }
     }
     return $chart;
 }
 public function ajaxGetNodeGraph($params, &$ajaxObj)
 {
     $node_id = t3lib_div::_GP('node');
     $duration = (int) t3lib_div::_GP('duration');
     $date_stop = time();
     $date_start = $date_stop - $duration;
     $node_repository = tx_caretaker_NodeRepository::getInstance();
     if ($node_id && ($node = $node_repository->id2node($node_id, true))) {
         $result_range = $node->getTestResultRange($date_start, $date_stop);
         if ($result_range->count()) {
             $filename = 'typo3temp/caretaker/charts/' . $node_id . '_' . $duration . '.png';
             $base_url = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
             if (is_a($node, 'tx_caretaker_TestNode')) {
                 $TestResultRangeChartRenderer = new tx_caretaker_TestResultRangeChartRenderer();
                 $TestResultRangeChartRenderer->setTitle($node->getTitle());
                 $TestResultRangeChartRenderer->setTestResultRange($result_range);
                 $result = $TestResultRangeChartRenderer->getChartImageTag($filename, $base_url);
                 if ($result) {
                     echo $result;
                 }
             } else {
                 if (is_a($node, 'tx_caretaker_AggregatorNode')) {
                     $AggregatorResultRangeChartRenderer = new tx_caretaker_AggregatorResultRangeChartRenderer();
                     $AggregatorResultRangeChartRenderer->setTitle($node->getTitle());
                     $AggregatorResultRangeChartRenderer->setAggregatorResultRange($result_range);
                     $result = $AggregatorResultRangeChartRenderer->getChartImageTag($filename, $base_url);
                     if ($result) {
                         echo $result;
                     }
                 }
             }
         } else {
             echo 'not enough results';
         }
     } else {
         echo "please give a valid node id";
     }
 }