You are here

function QuantChartChartAPI::chart_single in Quant 7

Fill a single datapoint chart with data

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

File

plugins/QuantChartChartAPI.inc, line 282

Class

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

Code

function chart_single() {
  $max = 0;

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

  // Counter to help break the x-axis label
  $period = ceil(count($this->quant->data->data) / 10);

  // Period when to break x-axis
  foreach ($this->quant->data->data as $date => $value) {

    // Only show the X label every calculated period
    if (!$interval) {
      $this
        ->x_label($date);
      $interval = $period;
    }
    $this->chart['#data'][] = $value;
    $max = max($max, $value);
    $interval--;
  }
  $this
    ->y_range(0, $max);
}