Ernest Park - 2010-02-01

Hi -

Working in Drupal with OFC2 - I want to do the following -

Change a bar within a series of bars - either color, data, or properties. The most important thing to do is to be able to display a bar of a different color within a series, where the color change indicates a condition in that series.

Ideally, this would be an associative array like

           | apples | pears | plums | cannons |
jan     |       1      |            |              |                  |
feb     |               |     7     |              |                  |
mar   |                |            |              |       10      |

I would like to display this as three different colored bars, but if I do it the OFC way, then I have the "space" for 4 possible bars in any charted period.

I would prefer to show only one item per period, since each period will have only one item, but never the same. Therefore, I want to distinguish it with a color change, but avoid making it look each month like it is one element of a set.

Here is another example I saw -

Again, I am using Drupal if that makes a difference.

The code as displayed is as follows


include '../php-ofc-library/open-flash-chart.php';

$data = array();

// add random height bars:
for( $i=0; $i<9; $i++ )
  $data = rand(2,9);
// make the last bar a different colour:
$bar = new bar_value(5);
$bar->set_colour( '#900000' );
$bar->set_tooltip( 'Hello<br>#val#' );
$data = $bar;

$title = new title( date("D M d Y") );

$bar = new bar_3d();
$bar->set_values( $data );
$bar->colour = '#D54C78';

$x_axis = new x_axis();
$x_axis->set_3d( 5 );
$x_axis->colour = '#909090';
$x_axis->set_labels( array(1,2,3,4,5,6,7,8,9,10) );

$chart = new open_flash_chart(); // in Drupal - I call new open_flash_chart_api();
$chart->set_title( $title );
$chart->add_element( $bar );
$chart->set_x_axis( $x_axis );

echo $chart->toPrettyString();


Where is the documentation for the bar_value method?

I am doing this in Drupal, so I end up making small changes to call the charts - I noted one above.