You are here

function QuantChartChartAPI::chart_multiple in Quant 7

Fill a multiple datapoint chart with data

1 call to QuantChartChartAPI::chart_multiple()
QuantChartChartAPI::build in plugins/QuantChartChartAPI.inc
Implements parent::build().

File

plugins/QuantChartChartAPI.inc, line 304

Class

QuantChartChartAPI
QuantChart plugin class to generate charts using chart.module (Chart API)

Code

function chart_multiple() {
  $max = 0;

  // Determine the highest available value on y-axis
  $interval = 0;

  // Counter to help break the x-axis label
  $x = FALSE;

  // Only register the x-axis labels once
  foreach ($this->quant->data->data as $type => $values) {

    // Set type as a legend
    $this->chart['#legends'][] = $type;

    // Period when to break x-axis
    $period = ceil(count($this->quant->data->data[$type]) / 10);
    foreach ($values as $date => $value) {
      $this->chart['#data'][$type][] = $value;
      $max = max($max, $value);
      if (!$x) {

        // Only set x-axis labels once
        if (!$interval) {
          $this
            ->x_label($date);
          $interval = $period;
        }
        $interval--;
      }
    }
    $x = TRUE;

    // x-axis labels have been set
  }
  $this
    ->y_range(0, $max);
}