Skip to content
This repository was archived by the owner on Nov 2, 2022. It is now read-only.

writeReport

Gaelan Lloyd edited this page May 6, 2020 · 2 revisions

/functions/writeReport.php is responsible for drawing a report on the screen.

A report is composed of:

  • Chart
  • Legend
  • Toggleable data table and CSV section

Parameters

writeReport( $reportData, $customTitle, $chartCaption, $sitesAsSeries );

Parameter Description
$reportData An array containing the chart data collected from a previous getData() call (see the example below)
$customTitle (Optional) A string that will override the chart title (which defaults to the site's name for simple reports).
$chartCaption (Optional) A string that will display under the chart title, and above the chart itself, describing what the chart data represents.
$sitesAsSeries (Optional) Set this to TRUE if you want to transpose the sites and metrics data. This will result in a chart showing a single metric with data series for each site in your environment with showData = 1.

Notes

  • Before you can use writeReport(), you must use getData() to get the data from the database.
  • writeReport() must be echoed to the screen to display its output.

Example usage

Here's some example joint getData() and writeReport() operations:

// Get data for metric id 77 for site 1
// Customize the report title and add a caption
$reportData = getData( "77", "1" );
echo writeReport( $reportData, "Average response time", "How long it took operators to respond, on average, to incoming chats." );

// Get data for 5 items for site 1
// Customize the report title
$reportData = getData( "24,26,28,30,32", "1" );
echo writeReport( $reportData, "English site" );

// Get data for metric id 1, for all sites, transpose data, and use alternate site names
// Customize the report title and make it a hyperlink to report 1, and add a caption
$reportData = getData( "1", NULL, TRUE, TRUE );
echo writeReport( $reportData, "<a href=\"/?r=1\">Overall traffic</a>", "The total number of page views to each website.", TRUE );

Learn more

Clone this wiki locally