function tripal_feature_cv_chart

1.x tripal_feature.module tripal_feature_cv_chart($chart_id)

Related topics

File

tripal_feature/tripal_feature.module, line 2088
@todo Add file header description

Code

function tripal_feature_cv_chart($chart_id) {

  // we only want the chart to show feature types setup by the admin
  $temp = rtrim(variable_get('tripal_feature_summary_report_mapping', ''));
  $where = '';
  if ($temp) {
    $temp = explode("\n", $temp);
    foreach ($temp as $key => $value) {
      $temp2 = explode("=", $value);
      $feature_type = rtrim($temp2[0]);
      $where .= "CNT.feature_type = '$feature_type' OR \n";
    }
    if ($where) {
      $where = drupal_substr($where, 0, -5); # remove OR from the end
      $where = "($where) AND";
    }
  }

  $organism_id = preg_replace("/^tripal_feature_cv_chart_(\d+)$/", "$1", $chart_id);

  // The CV module will create the JSON array necessary for buillding a
  // pie chart using jgChart and Google Charts.  We have to pass to it
  // a table that contains count information, tell it which column
  // contains the cvterm_id and provide a filter for getting the
  // results we want from the table.
  $options = array(
    count_mview => 'organism_feature_count',
    cvterm_id_column => 'cvterm_id',
    count_column => 'num_features',
    size => '550x200',
    filter => "$where CNT.organism_id = $organism_id",
  );
  return $options;
}