You are here

function d3_examples_bar in d3.js 7

Generates a random example bar graph.

Return value

string HTML for the page content.

1 string reference to 'd3_examples_bar'
d3_examples_menu in modules/d3_examples/d3_examples.module
Implements hook_menu().

File

modules/d3_examples/d3_examples.module, line 150
D3 Example module file.

Code

function d3_examples_bar() {

  // Temporary data until I get randomization working.
  $chart = array(
    'id' => 'visualization',
    'type' => 'barchart',
    'legend' => array(
      'Development',
      'QA',
      'Strategy',
      'Design',
    ),
    'rows' => array(
      array(
        '2010 - (Data only available after 3rd quarter)',
      ),
      array(
        '1st Quarter 2011',
      ),
      array(
        '2nd Quarter 2011',
      ),
      array(
        '3rd Quarter 2011',
      ),
      array(
        '4th Quarter 2011',
      ),
      array(
        '1st Quarter 2012',
      ),
    ),
  );
  for ($i = 0; $i < count($chart['rows']); $i++) {
    for ($j = 0; $j < 4; $j++) {
      array_push($chart['rows'][$i], rand(1, 70) * rand(1, 70));
    }
  }
  return d3_draw($chart);
}