Allows users to show/hide lines by clicking on the legend
{ "elements": [ { "type": "line", "values": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], "text": "line 1", "id": 1, "colour": "#ff0000", "key-on-click": "toggle-visibility" }, { "type": "line", "values": [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ], "text": "line 2", "id": 2, "colour": "#00ff00", "key-on-click": "toggle-visibility" }, { "type": "line", "values": [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ], "id": 1, "colour": "#0000ff", "key-on-click": "toggle-visibility" } ], "legend": { "visible": true } }
$chart = new open_flash_chart(); $line_dot = new line(); $line_dot->set_values( array(0,1,2,3,4,5,6,7,8,9,10)); $line_dot->set_text( "line 1" ); $line_dot->set_group_id( 1 ); $line_dot->set_colour( '#ff0000' ); $line_dot->set_key_on_click( "toggle-visibility" ); $chart->add_element( $line_dot ); $line_dot = new line(); $line_dot->set_values( array(5,5,5,5,5,5,5,5,5,5,5)); $line_dot->set_text( "line 2" ); $line_dot->set_group_id( 2 ); $line_dot->set_colour( '#00ff00' ); $line_dot->set_key_on_click( "toggle-visibility" ); $chart->add_element( $line_dot ); $line_dot = new line(); $line_dot->set_values( array(10,9,8,7,6,5,4,3,2,1,0)); $line_dot->set_group_id( 1 ); $line_dot->set_colour( '#0000ff' ); $line_dot->set_key_on_click( "toggle-visibility" ); $chart->add_element( $line_dot ); $legend = new legend(); $legend->set_visible(true); $chart->set_legend( $legend ); echo $chart->toPrettyString();