protected function _createVisitsGraph()
 {
     // load pChart graphic library
     $this->_loadLibs();
     // définition des données à afficher
     $dataSet = new pData();
     // need config, to know which data user wants to display : visits, unique visitors, pageviews
     $sefConfig = Sh404sefFactory::getConfig();
     $dataTypeString = str_replace('ga:', '', $sefConfig->analyticsDashboardDataType);
     // get data from response
     $data = array();
     $maxY = 0;
     foreach ($this->_rawData['visits'] as $entry) {
         $data[] = $entry->{$dataTypeString};
         if ($entry->{$dataTypeString} > $maxY) {
             $maxY = $entry->{$dataTypeString};
         }
     }
     // format dates
     $dates = Sh404sefHelperAnalytics::formatAbciseDates($this->_rawData['visits'], $this->_options);
     $dataSet->AddPoint($data, $dataTypeString);
     $dataSet->AddPoint($dates, "dates");
     $dataSet->addSerie($dataTypeString);
     $dataSet->SetAbsciseLabelSerie("dates");
     $label = JText::_('COM_SH404SEF_ANALYTICS_DATA_' . strtoupper($dataTypeString));
     $dataSet->SetSerieName($label, $dataTypeString);
     // Initialise the graph
     $w = $this->_options['cpWidth'];
     $w = empty($w) ? 400 : intval($w - 40);
     $h = 225;
     $centreX = intval(0.5 * $w);
     $centreY = intval(0.5 * $h);
     $chart = new pChart($w, $h);
     $fontSize = 8;
     // calculate left margin based on max value to display
     $leftMargin = 20 + $fontSize + 20 + $fontSize * strlen($maxY);
     $bottomMargin = 5 + $fontSize * 6;
     switch ($this->_options['groupBy']) {
         case 'ga:year,ga:month,ga:week,ga:day':
             $YAxisName = JText::_('Day');
             break;
             // date string represents a week number
         // date string represents a week number
         case 'ga:year,ga:month,ga:week':
             $YAxisName = JText::_('Week');
             break;
         case 'ga:year,ga:month':
             $YAxisName = JText::_('Month');
             break;
     }
     $dataSet->SetYAxisName($label . JText::_('COM_SH404SEF_ANALYTICS_REPORT_PER_LABEL') . $YAxisName);
     $chart->setFontProperties($this->_baseChartPath . DS . 'Fonts/arial.ttf', $fontSize);
     $chart->setGraphArea($leftMargin, 30, $w - 20, $h - $bottomMargin);
     $chart->drawFilledRoundedRectangle(7, 7, $w - 7, $h - 7, 5, 240, 240, 240);
     $chart->drawRoundedRectangle(5, 5, $w - 5, $h - 5, 5, 230, 230, 230);
     $chart->drawGraphArea(255, 255, 255, TRUE);
     $d = $dataSet->GetData();
     if (!empty($d)) {
         $chart->drawScale($d, $dataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 60, 0, false);
         $chart->drawGrid(4, TRUE, 230, 230, 230, 50);
         // Draw the 0 line
         $chart->setFontProperties($this->_baseChartPath . DS . 'Fonts/arial.ttf', $fontSize);
         $chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
         // Draw the line graph
         $chart->drawLineGraph($d, $dataSet->GetDataDescription());
         $chart->drawPlotGraph($d, $dataSet->GetDataDescription(), 3, 2, 255, 255, 255);
     }
     // create a temporary file for
     $user =& JFactory::getUser();
     // make sure the root tmp dir exists
     $rootDir = 'tmp' . DS . 'sh404sef_analytics';
     Sh404sefHelperFiles::createDirAndIndex(JPATH_ROOT . DS . $rootDir);
     // file name is per user
     $basePath = $rootDir . DS . md5('useless_' . $user->id . '_hashing') . DS;
     // create path and make sure there's an index.html file in it
     Sh404sefHelperFiles::createDirAndIndex(JPATH_ROOT . DS . $basePath);
     $imageFileName = Sh404sefHelperAnalytics::createTempFile($basePath, $this->_options['report'] . '.' . $this->_options['accountId'] . '.visits.' . $dataTypeString);
     $chart->Render(JPATH_ROOT . DS . $imageFileName);
     // need cleaning up, so let's remove all report files for that user older than an hour or so
     Sh404sefHelperAnalytics::cleanReportsImageFiles(JPATH_ROOT . DS . $basePath, $age = 4000);
     return JURI::root() . $imageFileName;
 }