Cool - got it to work. Fairly easy. But I am having trouble with the location of the title of the graph. Here is the code I use to produce the attached image. Note how far away the title is from the bar chart. I have tried all sorts of chart size - and it doesn't seem to help.

Any ideas?

<?php
$chart = array(
      '#chart_id' => 'chart_poll_result',
      '#title' => chart_title(t('Poll Results'), '228900', 15),
      '#type' => CHART_TYPE_BAR_H,
      '#size' => chart_size(600, 300),
      '#bar_size' => chart_bar_size(15, 10),
      '#grid_lines' => chart_grid_lines(20, 20, 1, 5),
      '#adjust_resolution' => TRUE,
      '#chart_fill' => chart_fill('c', 'eeeeee'),
    );

$sql = "SELECT count(table.data) as count, table.data as label FROM table where nid='XX' and nid = table.nid group by table.data";

$results = db_query($sql);
while ($result = db_fetch_array($results)){
       $chart['#data'][]        = $result['count'];
       $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_label(t(strip_tags($result['label'])));
     }  
$chart['#data_colors'][] = '228900';
echo chart_render($chart);
?>
CommentFileSizeAuthor
title.JPG9.89 KBAnonymous (not verified)

Comments

tjholowaychuk’s picture

Hmm seems a little weird, can you post the resulting URI to the image, then I can tweak the size and view the resulting image really quickly and see if i can help

Anonymous’s picture

tjholowaychuk’s picture

if you change '#size' => chart_size(600, 300),

to '#size' => chart_size(600, 100), or something lower it does not decrease the height?

Anonymous’s picture

Status: Active » Closed (fixed)

This is truly embarassing - I swear I tried that! Anyway - thanks - that was exactly the problem. Closed.

Pierre.Vriens’s picture

Title: title location and graph size » How to use chart_size to influence chart title location
Issue summary: View changes

Adapting title to link to this issue from the Chart HowTos docu ...