/**
  * @return array|string
  */
 public function getReportGraph()
 {
     $arrReturn = array();
     //collect data
     $arrPages = $this->getTopPages();
     $arrGraphData = array();
     $arrPlots = array();
     $arrLabels = array();
     $intCount = 1;
     foreach ($arrPages as $arrOnePage) {
         $arrGraphData[] = $arrOnePage["anzahl"];
         $arrLabels[] = $intCount;
         if ($intCount <= 6) {
             $arrPlots[$arrOnePage["name"]] = array();
         }
         if ($intCount++ >= 9) {
             break;
         }
     }
     if (count($arrGraphData) > 1) {
         //generate a bar-chart
         $objGraph = class_graph_factory::getGraphInstance();
         $objGraph->setArrXAxisTickLabels($arrLabels);
         $objGraph->addBarChartSet($arrGraphData, $this->objTexts->getLang("top_seiten_titel", "stats"));
         $objGraph->setStrXAxisTitle($this->objTexts->getLang("top_seiten_titel", "stats"));
         $objGraph->setStrYAxisTitle($this->objTexts->getLang("commons_hits_header", "stats"));
         $objGraph->setBitRenderLegend(false);
         $arrReturn[] = $objGraph->renderGraph();
         //--- XY-Plot -----------------------------------------------------------------------------------
         //calc number of plots
         $arrTickLabels = array();
         $intGlobalEnd = $this->intDateEnd;
         $intGlobalStart = $this->intDateStart;
         $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
         $intCount = 0;
         while ($this->intDateStart <= $intGlobalEnd) {
             $arrPagesData = $this->getTopPages();
             //init plot array for this period
             $arrTickLabels[] = date("d.m.", $this->intDateStart);
             foreach ($arrPlots as $strPage => &$arrOnePlot) {
                 $arrOnePlot[$intCount] = 0;
                 foreach ($arrPagesData as $arrOnePage) {
                     if ($arrOnePage["name"] == $strPage) {
                         $arrOnePlot[$intCount] += $arrOnePage["anzahl"];
                     }
                 }
             }
             //increase start & end-date
             $this->intDateStart = $this->intDateEnd;
             $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
             $intCount++;
         }
         //create graph
         if ($intCount > 1) {
             $objGraph = class_graph_factory::getGraphInstance();
             $objGraph->setArrXAxisTickLabels($arrTickLabels);
             foreach ($arrPlots as $arrPlotName => $arrPlotData) {
                 $objGraph->addLinePlot($arrPlotData, $arrPlotName);
             }
             $arrReturn[] = $objGraph->renderGraph();
         }
         //reset global dates
         $this->intDateEnd = $intGlobalEnd;
         $this->intDateStart = $intGlobalStart;
         return $arrReturn;
     } else {
         return "";
     }
 }
 /**
  * @return mixed|string
  */
 public function getReportGraph()
 {
     //collect data
     $arrPages = $this->getTopQueries();
     $arrGraphData = array();
     $arrLabels = array();
     $intCount = 1;
     foreach ($arrPages as $intHits) {
         $arrGraphData[$intCount] = $intHits;
         $arrLabels[] = $intCount;
         if ($intCount++ >= 8) {
             break;
         }
     }
     //generate a bar-chart
     if (count($arrGraphData) > 1) {
         $objGraph = class_graph_factory::getGraphInstance();
         $objGraph->setArrXAxisTickLabels($arrLabels);
         $objGraph->addBarChartSet($arrGraphData, $this->objTexts->getLang("top_query_titel", "stats"));
         $objGraph->setStrXAxisTitle($this->objTexts->getLang("top_query_titel", "stats"));
         $objGraph->setStrYAxisTitle($this->objTexts->getLang("top_query_gewicht", "stats"));
         return $objGraph->renderGraph();
     } else {
         return "";
     }
 }
 /**
  * @return array|string
  */
 public function getReportGraph()
 {
     $arrReturn = array();
     //collect data
     $arrQueries = $this->getTopQueries();
     $arrGraphData = array();
     $arrLabels = array();
     $intCount = 1;
     foreach ($arrQueries as $arrOneQuery) {
         $arrGraphData[] = $arrOneQuery["hits"];
         $arrLabels[] = $arrOneQuery["search_log_query"];
         if ($intCount++ >= 9) {
             break;
         }
     }
     if (count($arrGraphData) > 1) {
         //generate a bar-chart
         $objGraph = class_graph_factory::getGraphInstance();
         $objGraph->setArrXAxisTickLabels($arrLabels);
         $objGraph->addBarChartSet($arrGraphData, "");
         $objGraph->setStrXAxisTitle($this->objLang->getLang("header_query", "search"));
         $objGraph->setStrYAxisTitle($this->objLang->getLang("header_amount", "search"));
         $objGraph->setBitRenderLegend(false);
         $objGraph->setIntXAxisAngle(20);
         $arrReturn[] = $objGraph->renderGraph();
         return $arrReturn;
     } else {
         return "";
     }
 }
 /**
  * @return array
  */
 public function getReportGraph()
 {
     $arrReturn = array();
     $arrTickLabels = array();
     $intGlobalEnd = $this->intDateEnd;
     $intGlobalStart = $this->intDateStart;
     $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
     $intCount = 0;
     $arrTotalHits = array();
     $arrUniqueHits = array();
     while ($this->intDateStart <= $intGlobalEnd) {
         $arrTotalHits[$intCount] = $this->getTotalHitsInInterval();
         $arrUniqueHits[$intCount] = $this->getTotalUniqueHitsInInterval();
         $arrTickLabels[$intCount] = date("d.m.", $this->intDateStart);
         //increase start & end-date
         $this->intDateStart = $this->intDateEnd;
         $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
         $intCount++;
     }
     //create graph
     if ($intCount > 1) {
         $objGraph = class_graph_factory::getGraphInstance();
         $objGraph->setArrXAxisTickLabels($arrTickLabels);
         $objGraph->addLinePlot($arrTotalHits, $this->objLang->getLang("packageservertopqueries_total", "packageserver"));
         $objGraph->addLinePlot($arrUniqueHits, $this->objLang->getLang("packageservertopqueries_unique", "packageserver"));
         $objGraph->setIntWidth(815);
         $objGraph->renderGraph();
         $arrReturn[] = $objGraph->renderGraph();
     }
     //reset global dates
     $this->intDateEnd = $intGlobalEnd;
     $this->intDateStart = $intGlobalStart;
     return $arrReturn;
 }
 public function testCharts()
 {
     srand((double) microtime() * 1000000);
     //--- system kernel -------------------------------------------------------------------------------------
     echo "\tcreating a few charts...\n";
     //JS-Imports for minimal system setup
     echo "<script type=\"text/javascript\">KAJONA_WEBPATH = '" . _webpath_ . "'; KAJONA_BROWSER_CACHEBUSTER = '" . class_module_system_setting::getConfigValue("_system_browser_cachebuster_") . "';</script>\n";
     echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _webpath_ . class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/admin/scripts/jquery/jquery.min.js\"></script>";
     echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _webpath_ . class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/system/scripts/loader.js\"></script>";
     echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _webpath_ . class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/admin/scripts/kajona.js\"></script>";
     echo "<script language=\"javascript\" type=\"text/javascript\" src=\"" . _webpath_ . class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/admin/scripts/jqueryui/jquery-ui.custom.min.js\"></script>";
     //jqPlot
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/jquery.jqplot.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.logAxisRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.barRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.categoryAxisRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.canvasTextRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.canvasAxisTickRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.canvasAxisLabelRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.pointLabels.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.highlighter.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.cursor.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.enhancedLegendRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.dateAxisRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.pieRenderer.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/jqplot/plugins/jqplot.canvasOverlay.js\"></script>";
     echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . _webpath_ . class_resourceloader::getInstance()->getCorePathForModule("module_jqplot") . "/module_jqplot/admin/scripts/js/jqplot/jquery.jqplot.css\"></link>";
     echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . _webpath_ . class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/admin/scripts/jqueryui/css/smoothness/jquery-ui.custom.css\"></link>";
     //custom
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/custom/jquery.jqplot.custom_helper.js\"></script>";
     //        echo "<script language=\"javascript\" type=\"text/javascript\" src=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/custom/jqPlotTest.js\"></script>";
     //        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\""._webpath_.class_resourceloader::getInstance()->getCorePathForModule("module_jqplot")."/module_jqplot/admin/scripts/js/custom/jquery.jqplot.custom.css\"></link>";
     //test-Divs
     //create div where the chart is being put
     //        echo "<div id=\"ResizeDIV\" style=\"width:700px; height:500px;\">
     //                <div id=\"ChartDIV\" style=\"width:100%; height:100%;\"></div>
     //            </div>";
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->addLinePlot(array(8.112, 1, 2, 4), null);
     $objGraph->addLinePlot(array(1, 2, 3, 4), null);
     $objGraph->addLinePlot(array(4, 7, 1, 2), null);
     $objGraph->addLinePlot(array(4, 3, 2, 1), null);
     $objGraph->addLinePlot(array(-5, 3, -2, 1), null);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setIntXAxisAngle(-20);
     $objGraph->setStrXAxisTitle("XXX");
     $objGraph->setStrYAxisTitle("YYY");
     $objGraph->setStrBackgroundColor("#F0F0F0");
     $objGraph->setStrGraphTitle("My First Line Chart");
     $objGraph->setIntHeight(500);
     $objGraph->setIntWidth(700);
     $objGraph->setStrFontColor("#FF0000");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4"));
     $objGraph->setStrFont("Open Sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->addLinePlot(array(8.112, 1, 2, 4), null);
     $objGraph->addLinePlot(array(1, 2, 3, 4), null);
     $objGraph->addLinePlot(array(4, 7, 1, 2), null);
     $objGraph->addLinePlot(array(4, 3, 2, 1), null);
     $objGraph->addLinePlot(array(-5, 3, -2, 1), null);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setIntXAxisAngle(-20);
     $objGraph->setStrXAxisTitle("XXX");
     $objGraph->setStrYAxisTitle("YYY");
     $objGraph->setStrBackgroundColor("#F0F0F0");
     $objGraph->setStrGraphTitle("My First Line Chart 2");
     $objGraph->setIntHeight(500);
     $objGraph->setIntWidth(700);
     $objGraph->setStrFontColor("#FF0000");
     $objGraph->setStrFont("Open Sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Bar Chart");
     $objGraph->addBarChartSet(array(1, 4, 3, 6), "serie 111111111111111");
     $objGraph->addBarChartSet(array(3, 3, 6, 2), "serie 2");
     $objGraph->addBarChartSet(array(4, 4, 8, 6), "serie 3");
     $objGraph->addBarChartSet(array(10, 7, 3, 3), "serie 4");
     $objGraph->addBarChartSet(array(6, 7, 3, 20), "serie 5");
     $objGraph->addBarChartSet(array(9, 2, 3, 40), "serie 9");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4"));
     $objGraph->setIntXAxisAngle(-20);
     $objGraph->setIntHeight(350);
     $objGraph->setIntWidth(300);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFontColor("#FF0000");
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("One Bar Chart (In this case each bar has a differetn color)");
     $objGraph->addBarChartSet(array(9, 2, 3, 40), "serie 9");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4"));
     $objGraph->setIntXAxisAngle(-20);
     $objGraph->setIntHeight(350);
     $objGraph->setIntWidth(300);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFontColor("#FF0000");
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Mixed Chart");
     $objGraph->setStrXAxisTitle("My new X-Axis");
     $objGraph->setStrYAxisTitle("My new Y-Axis");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 3", true);
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 4");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 5");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 6");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 7");
     $objGraph->addLinePlot(array(8, 1, 2, 4), "serie 8");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 9");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 10");
     $objGraph->addLinePlot(array(1, 2, 3, 4), "serie 11");
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Mixed stacked Chart");
     $objGraph->setStrXAxisTitle("My new X-Axis");
     $objGraph->setStrYAxisTitle("My new Y-Axis");
     $objGraph->addStackedBarChartSet(array(4, 2, 3, 4), "serie 3");
     $objGraph->addStackedBarChartSet(array(1, 3, 3, 4), "serie 4");
     $objGraph->addStackedBarChartSet(array(1, 2, 2, 3), "serie 5");
     $objGraph->addStackedBarChartSet(array(2, 2, 3, 1), "serie 6");
     $objGraph->addStackedBarChartSet(array(1, 2, 3, 4), "serie 7");
     $objGraph->addLinePlot(array(8, 1, 2, 4), "serie 8");
     $objGraph->addLinePlot(array(1, 2, 3, 4), "serie 9");
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Bar Chart");
     $objGraph->setStrXAxisTitle("My new X-Axis");
     $objGraph->setStrYAxisTitle("My new Y-Axis");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 9");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 10");
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Horizontal Bar Chart");
     $objGraph->setStrXAxisTitle("My new X-Axis");
     $objGraph->setStrYAxisTitle("My new Y-Axis");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 9");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 10");
     $objGraph->setBarHorizontal(true);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     if (method_exists($objGraph, "setHideXAxis")) {
         $objGraph->setHideXAxis(true);
     }
     if (method_exists($objGraph, "setHideYAxis")) {
         $objGraph->setHideYAxis(true);
     }
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Horizontal Bar Chart with labels");
     $objGraph->setStrXAxisTitle("My new X-Axis");
     $objGraph->setStrYAxisTitle("My new Y-Axis");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 9");
     $objGraph->addBarChartSet(array(1, 2, 3, 4), "serie 10");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4"));
     $objGraph->setBarHorizontal(true);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->addLinePlot(array(1, 2, 7, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 0, 6, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), "serie 1");
     $objGraph->addLinePlot(array(1, 2, 7, 0, 0, 0, 2, 0, 0, 0, 5, 0, 3, 0, 0, 5, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), "serie 2");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", "v32", "v33", "v34", "v35", "v36", "v37", "v38", "v39", "v40"));
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrXAxisTitle("XXX");
     $objGraph->setStrYAxisTitle("YYY");
     $objGraph->setStrGraphTitle("My First Line Chart");
     $objGraph->setIntHeight(500);
     $objGraph->setIntWidth(700);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     //create a stacked bar chart
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrXAxisTitle("x-axis");
     $objGraph->setStrYAxisTitle("y-axis");
     $objGraph->setStrGraphTitle("Test Stacked Bar Chart");
     $objGraph->addStackedBarChartSet(array(0, -5, 7, 8, 4, 12, 1, 1, 1, 3, 4, 5, 6), "serie 1");
     $objGraph->addStackedBarChartSet(array(3, -4, 6, 2, 5, 2, 2, 2, 2, 3, 4, 5, 6), "serie 2");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13"));
     $objGraph->setIntXAxisAngle(-20);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     //create a stacked bar chart
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrXAxisTitle("x-axis");
     $objGraph->setStrYAxisTitle("y-axis");
     $objGraph->setStrGraphTitle("Test Stacked Horizontal Bar Chart");
     $objGraph->addStackedBarChartSet(array(8, -5, 7, 8, 4, 12, 1, 1, 1, 3, 4, 5, 6), "serie 1");
     $objGraph->addStackedBarChartSet(array(3, 0, 6, 2, 5, 2, 2, 2, 2, 3, 4, 5, 6), "serie 2");
     $objGraph->addStackedBarChartSet(array(3, -4, 6, 2, 5, 2, 2, 2, 2, 3, 4, 5, 6), "serie 3");
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13"), 5);
     $objGraph->setIntXAxisAngle(-20);
     $objGraph->setStrFont("open sans");
     $objGraph->setBarHorizontal(true);
     echo $objGraph->renderGraph();
     //create pie chart
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Pie Chart");
     $objGraph->createPieChart(array(231.23524234234, 20.2342344, 30, 40), array("val 1", "val 2", "val 3", "val 4"));
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     //create pie chart
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Pie Chart");
     $objGraph->createPieChart(array(231, 20, 30, 40, 2, 3, 4, 5), array("val 1", "val 2", "val 3", "val 4", "v5", "v6", "v7", "v8"));
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     //create pie chart
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Pie Chart 2");
     $objGraph->createPieChart(array(1), array("val 1"));
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("A Horizontal Bar Chart with labels");
     $objGraph->setStrXAxisTitle("My new X-Axis");
     $objGraph->setStrYAxisTitle("My new Y-Axis");
     $objGraph->addBarChartSet(array(2, 4, 6, 3.3), "serie 9", true);
     $objGraph->addBarChartSet(array(5, 1, 3, 4), "serie 10", true);
     $objGraph->addBarChartSet(array(4, 7, 1, 2), "serie 11", true);
     $objGraph->setArrXAxisTickLabels(array("v1", "v2", "v3", "v4"));
     $objGraph->setBarHorizontal(true);
     $objGraph->setBitRenderLegend(true);
     $objGraph->setStrFont("open sans");
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->addLinePlot(array(0, 0, 0, 0, 0, 0, 0.5), null);
     $objGraph->setIntHeight(500);
     $objGraph->setIntWidth(700);
     $objGraph->setArrXAxisTickLabels(array("23", "24", "25", "26", "27", "28", "29"));
     echo $objGraph->renderGraph();
     $objGraph = class_graph_factory::getGraphInstance(class_graph_factory::$STR_TYPE_JQPLOT);
     $objGraph->setStrGraphTitle("An empty chart");
     $objGraph->addBarChartSet(array(), "legend");
     $objGraph->setIntHeight(500);
     $objGraph->setIntWidth(700);
     echo $objGraph->renderGraph();
 }
 /**
  * This method is called, when the widget should generate it's content.
  * Return the complete content using the methods provided by the base class.
  * Do NOT use the toolkit right here! 
  *
  * @return string
  */
 public function getWidgetOutput()
 {
     $strReturn = "";
     if (!class_module_system_module::getModuleByName("stats")->rightView()) {
         return $this->getLang("commons_error_permissions");
     }
     $objStatsCommon = new class_stats_report_common(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     //check wich infos to produce
     if ($this->getFieldValue("current") == "checked") {
         $strReturn .= $this->getLang("stats_online") . $objStatsCommon->getNumberOfCurrentUsers();
         $strReturn .= $this->widgetSeparator();
     }
     if ($this->getFieldValue("chart") == "checked") {
         //load the last view days
         $objDate = new class_date();
         $objDate->setIntHour(0);
         $objDate->setIntMin(0);
         $objDate->setIntSec(0);
         $arrHits = array();
         $arrLabels = array();
         for ($intI = 0; $intI < 7; $intI++) {
             $objEndDate = clone $objDate;
             $objEndDate->setNextDay();
             $objStatsCommon->setStartDate($objDate->getTimeInOldStyle());
             $objStatsCommon->setEndDate($objEndDate->getTimeInOldStyle());
             $arrHits[] = $objStatsCommon->getHits();
             $arrLabels[] = $objDate->getIntDay();
             $objDate->setPreviousDay();
         }
         $arrHits = array_reverse($arrHits);
         $arrLabels = array_reverse($arrLabels);
         $strReturn .= $this->widgetText($this->getLang("stats_hits"));
         $objChart = class_graph_factory::getGraphInstance();
         $objChart->setArrXAxisTickLabels($arrLabels);
         $objChart->addLinePlot($arrHits, "");
         $objChart->setBitRenderLegend(false);
         $objChart->setIntHeight(220);
         $objChart->setIntWidth(300);
         $objChart->setStrXAxisTitle("");
         $objChart->setStrYAxisTitle("");
         $strReturn .= $objChart->renderGraph();
     }
     if ($this->getFieldValue("day") == "checked") {
         //current day:
         //pass date to commons-object
         $objDate = new class_date();
         $objDate->setIntHour(0);
         $objDate->setIntMin(0);
         $objDate->setIntSec(0);
         $strReturn .= $this->widgetText(dateToString($objDate, false));
         $objStatsCommon->setStartDate($objDate->getTimeInOldStyle());
         $objDate->setNextDay();
         $objStatsCommon->setEndDate($objDate->getTimeInOldStyle());
         $strReturn .= $this->widgetText($this->getLang("stats_hits") . " " . $objStatsCommon->getHits());
         $strReturn .= $this->widgetText($this->getLang("stats_visitors") . " " . $objStatsCommon->getVisitors());
         $strReturn .= $this->widgetSeparator();
     }
     if ($this->getFieldValue("last") == "checked") {
         $strReturn .= $this->widgetText($this->getLang("stats_ip") . " " . $this->getLang("stats_page"));
         $intMaxRecords = $this->getFieldValue("nrLast");
         if (!is_numeric($intMaxRecords) || $intMaxRecords > 15) {
             $intMaxRecords = 15;
         }
         $arrRecordsets = class_carrier::getInstance()->getObjDB()->getPArray("SELECT * FROM " . _dbprefix_ . "stats_data ORDER BY stats_date DESC ", array(), 0, $intMaxRecords - 1);
         foreach ($arrRecordsets as $arrOneRecord) {
             $strReturn .= $this->widgetText($arrOneRecord["stats_ip"] . " " . $arrOneRecord["stats_page"]);
         }
     }
     return $strReturn;
 }
 /**
  * @return array
  */
 public function getReportGraph()
 {
     $arrReturn = array();
     //--- PIE-GRAPH ---------------------------------------------------------------------------------
     $arrData = $this->getTopBrowser();
     $intSum = 0;
     foreach ($arrData as $arrOneStat) {
         $intSum += $arrOneStat;
     }
     $arrKeyValues = array();
     //max 6 entries
     $intCount = 0;
     $floatPercentageSum = 0;
     $arrValues = array();
     $arrLabels = array();
     foreach ($arrData as $strName => $arrOneBrowser) {
         if (++$intCount <= 6) {
             $floatPercentage = $arrOneBrowser / $intSum * 100;
             $floatPercentageSum += $floatPercentage;
             $arrKeyValues[$strName] = $floatPercentage;
             $arrValues[] = $floatPercentage;
             $arrLabels[] = $strName;
         } else {
             break;
         }
     }
     //add "others" part?
     if ($floatPercentageSum < 99) {
         $arrKeyValues["others"] = 100 - $floatPercentageSum;
         $arrLabels[] = "others";
         $arrValues[] = 100 - $floatPercentageSum;
     }
     if (count($arrKeyValues) > 0) {
         $objGraph = class_graph_factory::getGraphInstance();
         $objGraph->createPieChart($arrValues, $arrLabels);
         $arrReturn[] = $objGraph->renderGraph();
     }
     //--- XY-Plot -----------------------------------------------------------------------------------
     //calc number of plots
     $arrPlots = array();
     $arrTickLabels = array();
     foreach ($arrKeyValues as $strBrowser => $arrData) {
         if ($strBrowser != "others") {
             $arrPlots[$strBrowser] = array();
         }
     }
     $intGlobalEnd = $this->intDateEnd;
     $intGlobalStart = $this->intDateStart;
     $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
     $intCount = 0;
     while ($this->intDateStart <= $intGlobalEnd) {
         $arrBrowserData = $this->getTopBrowser();
         //init plot array for this period
         $arrTickLabels[$intCount] = date("d.m.", $this->intDateStart);
         foreach ($arrPlots as $strBrowser => &$arrOnePlot) {
             $arrOnePlot[$intCount] = 0;
             if (key_exists($strBrowser, $arrBrowserData)) {
                 $arrOnePlot[$intCount] = (int) $arrBrowserData[$strBrowser];
             }
         }
         //increase start & end-date
         $this->intDateStart = $this->intDateEnd;
         $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
         $intCount++;
     }
     //create graph
     if (count($arrTickLabels) > 1 && count($arrPlots) > 0) {
         $objGraph = class_graph_factory::getGraphInstance();
         $objGraph->setArrXAxisTickLabels($arrTickLabels);
         foreach ($arrPlots as $arrPlotName => $arrPlotData) {
             $objGraph->addLinePlot($arrPlotData, $arrPlotName);
         }
         $arrReturn[] = $objGraph->renderGraph();
     }
     //reset global dates
     $this->intDateEnd = $intGlobalEnd;
     $this->intDateStart = $intGlobalStart;
     return $arrReturn;
 }
 /**
  * @return array|string
  */
 public function getReportGraph()
 {
     //load datasets, reloading after 30 days to limit memory consumption
     $arrHits = array();
     $arrUser = array();
     $arrTickLabels = array();
     //create tick labels
     $intCount = 0;
     $intDBStart = $this->intDateStart;
     $intDBEnd = $intDBStart + $this->intInterval * 24 * 60 * 60;
     while ($intDBStart <= $this->intDateEnd) {
         $arrTickLabels[$intCount] = date("d.m.", $intDBStart);
         $arrHits[$intCount] = $this->getHitsForOnePeriod($intDBStart, $intDBEnd);
         $arrUser[$intCount] = $this->getVisitorsForOnePeriod($intDBStart, $intDBEnd);
         $intDBStart = $intDBEnd;
         $intDBEnd = $intDBStart + $this->intInterval * 24 * 60 * 60;
         $this->objDB->flushQueryCache();
         $intCount++;
     }
     //create a graph ->line-graph
     if ($intCount > 1) {
         $objChart1 = class_graph_factory::getGraphInstance();
         $objChart1->setStrGraphTitle($this->objTexts->getLang("graph_hitsPerDay", "stats"));
         $objChart1->setStrXAxisTitle($this->objTexts->getLang("graph_date", "stats"));
         $objChart1->setStrYAxisTitle($this->objTexts->getLang("graph_hits", "stats"));
         $objChart1->setIntWidth(715);
         $objChart1->setIntHeight(200);
         $objChart1->setArrXAxisTickLabels($arrTickLabels);
         $objChart1->addLinePlot($arrHits, "Hits");
         $objChart1->setBitRenderLegend(false);
         $objChart2 = class_graph_factory::getGraphInstance();
         $objChart2->setStrGraphTitle($this->objTexts->getLang("graph_visitorsPerDay", "stats"));
         $objChart2->setStrXAxisTitle($this->objTexts->getLang("graph_date", "stats"));
         $objChart2->setStrYAxisTitle($this->objTexts->getLang("graph_visitors", "stats"));
         $objChart2->setIntWidth(715);
         $objChart2->setIntHeight(200);
         $objChart2->setArrXAxisTickLabels($arrTickLabels);
         $objChart2->addLinePlot($arrUser, "Visitors/Day");
         $objChart2->setBitRenderLegend(false);
         $this->objDB->flushQueryCache();
         return array($objChart1->renderGraph(), $objChart2->renderGraph());
     } else {
         return "";
     }
 }
 /**
  * @return array
  */
 public function getReportGraph()
 {
     $arrReturn = array();
     $arrData = $this->getTopCountries();
     $intSum = 0;
     foreach ($arrData as $arrOneStat) {
         $intSum += $arrOneStat;
     }
     $arrKeyValues = array();
     //max 6 entries
     $intCount = 0;
     $floatPercentageSum = 0;
     $arrValues = array();
     $arrLabels = array();
     foreach ($arrData as $strName => $intOneSystem) {
         if (++$intCount <= 6) {
             $floatPercentage = $intOneSystem / $intSum * 100;
             $floatPercentageSum += $floatPercentage;
             $arrKeyValues[$strName] = $floatPercentage;
             $arrValues[] = $floatPercentage;
             $arrLabels[] = $strName;
         } else {
             break;
         }
     }
     //add "others" part?
     if ($floatPercentageSum < 99) {
         $arrKeyValues["others"] = 100 - $floatPercentageSum;
         $arrLabels[] = "others";
         $arrValues[] = 100 - $floatPercentageSum;
     }
     $objGraph = class_graph_factory::getGraphInstance();
     $objGraph->createPieChart($arrValues, $arrLabels);
     $arrReturn[] = $objGraph->renderGraph();
     return $arrReturn;
 }
 /**
  * @return array
  */
 public function getReportGraph()
 {
     $arrReturn = array();
     //generate a graph showing dls per interval
     //--- XY-Plot -----------------------------------------------------------------------------------
     //calc number of plots
     $arrPlots = array();
     $intCount = 1;
     $arrDownloads = $this->getLogbookData();
     if (count($arrDownloads) > 0) {
         foreach ($arrDownloads as $arrOneDownload) {
             if ($intCount++ <= 4) {
                 $arrPlots[$arrOneDownload["downloads_log_file"]] = array();
             } else {
                 break;
             }
         }
         $arrTickLabels = array();
         $intGlobalEnd = $this->intDateEnd;
         $intGlobalStart = $this->intDateStart;
         $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
         $intCount = 0;
         while ($this->intDateStart <= $intGlobalEnd) {
             $arrDownloads = $this->getLogbookData();
             //init plot array for this period
             $arrTickLabels[$intCount] = date("d.m.", $this->intDateStart);
             foreach ($arrPlots as $strFile => &$arrOnePlot) {
                 $arrOnePlot[$intCount] = 0;
                 foreach ($arrDownloads as $arrOneDownload) {
                     if ($arrOneDownload["downloads_log_file"] == $strFile) {
                         $arrOnePlot[$intCount] += $arrOneDownload["amount"];
                     }
                 }
             }
             //increase start & end-date
             $this->intDateStart = $this->intDateEnd;
             $this->intDateEnd = $this->intDateStart + 60 * 60 * 24 * $this->intInterval;
             $intCount++;
         }
         //create graph
         if ($intCount > 1) {
             $objGraph = class_graph_factory::getGraphInstance();
             $objGraph->setArrXAxisTickLabels($arrTickLabels);
             foreach ($arrPlots as $arrPlotName => $arrPlotData) {
                 $objGraph->addLinePlot($arrPlotData, $arrPlotName);
             }
             $objGraph->renderGraph();
             $arrReturn[] = $objGraph->renderGraph();
         }
         //reset global dates
         $this->intDateEnd = $intGlobalEnd;
         $this->intDateStart = $intGlobalStart;
     }
     return $arrReturn;
 }