/** * A report showing a chart of incoming records per week. */ public static function records_by_week_chart($auth, $args, $tabalias, $options, $path) { iform_load_helpers(array('report_helper')); $args = array_merge(array('report_name' => 'library/weeks/filterable_records_by_week'), $args); $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('id' => 'records-by-week-chart', 'width' => 900, 'height' => 500, 'chartType' => 'line', 'yValues' => array('processed', 'total'), 'xLabels' => 'week', 'legendOptions' => array('show' => true), 'seriesOptions' => array(array('label' => 'Processed by verifiers', 'color' => '#00FF00'), array('label' => 'All records', 'color' => '#FF9900')), 'axesOptions' => array('yaxis' => array('min' => 0, 'tickOptions' => array('formatString' => '%d')), 'xaxis' => array('label' => 'Weeks ago'))), $options); return report_helper::report_chart($reportOptions); }
/** * Outputs a chart that loads the content of a report or Indicia table. * @param array $options Refer to report_helper::report_chart documentation. * @deprecated Use report_helper::report_chart. */ public static function report_chart($options) { require_once 'report_helper.php'; return report_helper::report_chart($options); }
/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { require_once drupal_get_path('module', 'iform') . '/client_helpers/report_helper.php'; require_once drupal_get_path('module', 'iform') . '/client_helpers/map_helper.php'; $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']); $chartOptions = iform_report_get_report_options($args, $auth); $chartOptions = array_merge($chartOptions, array('id' => 'chart-div', 'width' => $args['width'], 'height' => $args['height'], 'chartType' => $args['chart_type'], 'yValues' => explode(',', $args['y_values']))); $xLabels = trim($args['x_labels']); if (empty($xLabels)) { $chartOptions['xValues'] = explode(',', $args['x_values']); } else { $chartOptions['xLabels'] = explode(',', $args['x_labels']); } // advanced options $rendererOptions = trim($args['renderer_options']); if (!empty($rendererOptions)) { $chartOptions['rendererOptions'] = json_decode($rendererOptions, true); } $legendOptions = trim($args['legend_options']); if (!empty($legendOptions)) { $chartOptions['legendOptions'] = json_decode($legendOptions, true); } $seriesOptions = trim($args['series_options']); if (!empty($seriesOptions)) { $chartOptions['seriesOptions'] = json_decode($seriesOptions, true); } $axesOptions = trim($args['axes_options']); if (!empty($axesOptions)) { $chartOptions['axesOptions'] = json_decode($axesOptions, true); } // now the chart itself $r .= '<br/>' . report_helper::report_chart($chartOptions); return $r; }
protected static function get_control_reportchartparams($auth, $args, $tabalias, $options) { if (!isset($options['yValues']) || !isset($options['dataSource']) || !isset($options['chartType'])) { $r = '<h4>Please fill in the following options for the chart parameters control: yValues, dataSource, chartType</h4>'; return $r; } iform_load_helpers(array('report_helper')); $sharing = empty($args['sharing']) ? 'reporting' : $args['sharing']; $args['report_name'] = ''; $options = array_merge(iform_report_get_report_options($args, $auth), $options, array('reportGroup' => 'dynamic', 'paramsOnly' => true, 'sharing' => $sharing, 'paramsFormButtonCaption' => lang::get('Filter'), 'yValues' => explode(',', $options['yValues']), 'readAuth' => $auth['read'], 'dataSource' => $options['dataSource'])); $r = '<br/>' . report_helper::report_chart($options); return $r; }
private static function _build_taxon_groups_report($args, $readAuth, $output, $type) { $r = self::filter_toolbar(array('my_records', 'year'), $readAuth); $reportPerUser = !empty($_GET['my_records']); $reportOptions = array('readAuth' => $readAuth, 'dataSource' => "library/taxon_groups/filterable_{$type}_counts", 'caching' => true, 'cachePerUser' => $reportPerUser, 'cachetimeout' => $reportPerUser ? self::FAST_CACHE_REFRESH : self::SLOW_CACHE_REFRESH); self::check_filters($reportOptions); if (!empty($args['min_rank_sort_order_for_species'])) { $reportOptions['extraParams'] = array('min_taxon_rank_sort_order' => $args['min_rank_sort_order_for_species']); } if ($output === 'pie_chart') { $data = report_helper::get_report_data($reportOptions); // Get the taxon groups used in the master checklist $groups = report_helper::get_report_data(array('dataSource' => '/library/taxon_groups/taxon_groups_used_in_checklist', 'readAuth' => $readAuth, 'extraParams' => array('taxon_list_id' => variable_get('iform_master_checklist_id', 0)), 'caching' => true, 'cachePerUser' => false, 'cachetimeout' => self::SLOW_CACHE_REFRESH)); // make an easy lookup $groupIds = array(); foreach ($groups as $group) { $groupIds[$group['id']] = $group['title']; } // roll categories into 'other' if too many and process to remove unofficial groups $totalOther = 0; $processedData = array(); foreach ($data as $row) { if (count($processedData) >= 10 || !array_key_exists($row['id'], $groupIds)) { $totalOther += $row['count']; } else { $processedData[] = $row; } } if ($totalOther > 0) { $processedData[] = array('taxon_group' => lang::get('other'), 'count' => $totalOther); } $reportOptions['dataSource'] = 'static'; $reportOptions += array('staticData' => $processedData, 'chartType' => 'pie', 'seriesColors' => array('#ccebc5', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#8dd3c7', '#bc80bd', '#d9d9d9'), 'height' => '500', 'yValues' => 'count', 'xLabels' => 'taxon_group', 'autoParamsForm' => false, 'axesOptions' => array('yaxis' => array('min' => 0, 'tickOptions' => array('formatString' => '%d'))), 'legendOptions' => array('show' => true), 'rendererOptions' => array('sliceMargin' => 3)); $r .= report_helper::report_chart($reportOptions); } else { $reportOptions += array('downloadLink' => true); $r .= report_helper::report_grid($reportOptions); } return $r; }
/** * Outputs a pie chart for the proportion of each taxon group being recorded. * * @param array $auth Authorisation tokens. * @param array $args Form arguments (the settings on the form edit tab). * @param string $tabalias The alias of the tab this is being loaded onto. * @param array $options The options passed to this control using @option=value settings in the form structure. * Options supported are those which can be passed to the report_helper::report_chart method, for example set @limit * to control how many taxa to display, set @width and @height to control the dimensions. Set @title=... to * include a heading in the output * @param string $path The page reload path, in case it is required for the building of links. * @return string HTML to insert into the page for the location map. JavaScript is added to the variables in helper_base. * * @link http://www.biodiverseit.co.uk/indicia/dev/docs/classes/report_helper.html#method_report_chart API docs for report_helper::report_chart */ public static function groups_pie($auth, $args, $tabalias, $options, $path) { iform_load_helpers(array('report_helper')); $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('dataSource' => 'library/taxon_groups/filterable_group_counts', 'id' => 'groups-pie', 'width' => 340, 'height' => 340, 'chartType' => 'pie', 'yValues' => array('count'), 'xValues' => 'taxon_group', 'rendererOptions' => array('sliceMargin' => 4, 'showDataLabels' => true, 'dataLabelThreshold' => 2, 'dataLabels' => 'label', 'dataLabelPositionFactor' => 1), 'autoParamsForm' => false, 'caching' => true, 'cachePerUser' => false), $options); $r = self::output_title($options); $r .= report_helper::report_chart($reportOptions); return $r; }
/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { iform_load_helpers(array('report_helper', 'map_helper')); $auth = report_helper::get_read_auth($args['website_id'], $args['password']); $chartOptions = iform_report_get_report_options($args, $auth); $chartOptions = array_merge($chartOptions, array('id' => 'chart-div', 'width' => $args['width'], 'height' => $args['height'], 'chartType' => $args['chart_type'], 'yValues' => explode(',', $args['y_values']), 'output' => $args['output'])); $xLabels = trim($args['x_labels']); if (empty($xLabels)) { $chartOptions['xValues'] = explode(',', $args['x_values']); } else { $chartOptions['xLabels'] = explode(',', $args['x_labels']); } // advanced options if (!empty($args['renderer_options'])) { $rendererOptions = trim($args['renderer_options']); $chartOptions['rendererOptions'] = json_decode($rendererOptions, true); } if (!empty($args['legend_options'])) { $legendOptions = trim($args['legend_options']); $chartOptions['legendOptions'] = json_decode($legendOptions, true); } if (!empty($args['axes_options'])) { $seriesOptions = trim($args['series_options']); $chartOptions['seriesOptions'] = json_decode($seriesOptions, true); } if (!empty($args['series_options'])) { $axesOptions = trim($args['axes_options']); $chartOptions['axesOptions'] = json_decode($axesOptions, true); } //User has elected for parameters form only if ($args['output'] === 'form') { $chartOptions['paramsOnly'] = true; } else { if (isset($chartOptions['paramsOnly'])) { unset($chartOptions['paramsOnly']); } } //User has elected for parameters form only or //both the chart and parameters form together if ($args['output'] === 'form' || $args['output'] === 'default') { $chartOptions['completeParamsForm'] = true; } else { if (isset($chartOptions['completeParamsForm'])) { unset($chartOptions['completeParamsForm']); } } //User has elected for the chart only if ($args['output'] === 'output') { $chartOptions['autoParamsForm'] = false; } $r = '<br/>' . report_helper::report_chart($chartOptions); return $r; }
/** * Outputs a pie chart for the proportion of each taxon group being recorded. * * @param array $auth Authorisation tokens. * @param array $args Form arguments (the settings on the form edit tab). * @param string $tabalias The alias of the tab this is being loaded onto. * @param array $options The options passed to this control using @option=value settings in the form structure. * Options supported are those which can be passed to the report_helper::report_chart method, for example set @limit * to control how many taxa to display, set @width and @height to control the dimensions. * @param string $path The page reload path, in case it is required for the building of links. * @return string HTML to insert into the page for the location map. JavaScript is added to the variables in helper_base. * * @link http://www.biodiverseit.co.uk/indicia/dev/docs/classes/report_helper.html#method_report_chart API docs for report_helper::report_chart */ public static function groups_pie($auth, $args, $tabalias, $options, $path) { iform_load_helpers(array('report_helper')); $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('dataSource' => 'library/taxon_groups/group_counts_for_event', 'id' => 'groups-pie', 'width' => 340, 'height' => 340, 'chartType' => 'pie', 'yValues' => array('count'), 'xValues' => 'taxon_group', 'rendererOptions' => array('sliceMargin' => 4, 'showDataLabels' => true, 'dataLabelThreshold' => 2, 'dataLabels' => 'label', 'dataLabelPositionFactor' => 1)), $options); return report_helper::report_chart($reportOptions); }