You are here

function visitors_chart in Visitors 7.2

Same name and namespace in other branches
  1. 8 visitors.chart.inc \visitors_chart()
  2. 7 visitors.chart.inc \visitors_chart()
  3. 7.0 visitors.chart.inc \visitors_chart()

Draw chart.

@values int array y-axis values @x_array array x-axis params

6 calls to visitors_chart()
chart_visitors_browser in reports/browser.inc
Display browser chart report.
chart_visitors_days_of_month in reports/days_of_month.inc
Display days of month chart report.
chart_visitors_days_of_week in reports/days_of_week.inc
Display days of week chart report.
chart_visitors_hours in reports/hours.inc
Display hours chart report.
chart_visitors_monthly_history in reports/monthly_history.inc
Display monthly history chart report.

... See full list

File

./visitors.chart.inc, line 44

Code

function visitors_chart($values, $x_array = NULL) {
  $width = visitors_get_chart_width();
  $height = visitors_get_chart_height();

  // Dataset definition
  $MyData = new pData();
  $MyData
    ->addPoints($values, 'serie1');
  if ($x_array !== NULL) {
    $MyData
      ->addPoints($x_array, 'serie2');
    $MyData
      ->setAbscissa('serie2');
  }
  $myPicture = new pImage($width, $height, $MyData);
  $myPicture
    ->setFontProperties(array(
    'FontName' => dirname(__FILE__) . '/pChart/fonts/calibri.ttf',
    'FontSize' => 10,
  ));

  /* Draw the scale  */
  $myPicture
    ->setGraphArea(50, 30, $width - 20, $height - 30);
  $myPicture
    ->drawRoundedFilledRectangle(7, 7, $width - 7, $height - 7, 5, array(
    'R' => 245,
    'G' => 245,
    'B' => 240,
  ));
  $myPicture
    ->drawRoundedRectangle(5, 5, $width - 5, $height - 5, 5, array(
    'R' => 230,
    'G' => 230,
    'B' => 230,
  ));
  $myPicture
    ->drawScale(array(
    'Mode' => SCALE_MODE_START0,
    'CycleBackground' => TRUE,
    'DrawSubTicks' => TRUE,
    'GridR' => 200,
    'GridG' => 200,
    'GridB' => 200,
  ));

  /* Turn on shadow computing */
  $myPicture
    ->setShadow(FALSE, array(
    'X' => 1,
    'Y' => 1,
    'R' => 0,
    'G' => 0,
    'B' => 0,
    'Alpha' => 10,
  ));

  /* Draw the chart */
  $settings = array(
    'Gradient' => TRUE,
    'DisplayPos' => LABEL_POS_INSIDE,
    'DisplayValues' => FALSE,
    'DisplayR' => 255,
    'DisplayG' => 255,
    'DisplayB' => 255,
    'DisplayShadow' => TRUE,
    'Surrounding' => 10,
  );
  $myPicture
    ->drawBarChart($settings);

  /* Render the picture (choose the best way) */
  $myPicture
    ->autoOutput();
  exit;
}