Info: Open Flash Chart 2 is out. Version 1.x and these pages will
never disappear and the charts will continue working forever, but further
development on 1.x has stopped. Take a look at version 2 here
Open Flash Chart 2.
Gallery - Bar Chart Links
Add links to the graph.
Method: add()
$bar->add_link( integer $data, string $link )
I guess you have used the:
$bar->data[] = 10;
$bar->data[] = 20;
style of adding data to your bar charts. The add() method allows you to add a bar and a URL link for that
bar. In this example we are using a javascript link, but you can also use normal
"http://teethgrinder.co.uk/open-flash-chart/" style links. So replacing the two lines above with:
will create the same bar chart, but when you click on the first bar, a javascript pop-up will show 'Hello World'. Clicking on the
second bar will cause the browser to navigate to that URL.
There is a know bug, grouped bar charts (like these) do not always recieve the click event properly. So please
don't use these with links until I fix the bug.
for( $i=0; $i<9; $i++ ) { // add a bar (of randome height) and a URL link $bar->add_link( rand(2,9), "javascript:alert('Kittens: Bar $i')" ); }
$g = new graph(); $g->title( 'Bar Chart', '{font-size: 26px;}' );
$g->data_sets[] = $bar;
// $g->set_x_labels( array( 'January','February','March','April','May','June','July','August','September' ) ); // set the X axis to show every 2nd label: $g->set_x_label_style( 10, '#9933CC', 0, 2 ); // and tick every second value: $g->set_x_axis_steps( 2 ); //