Welcome to the Simple Bar Graph Example

In this example we will be exploring the Simple Bar Graph using the php-d3-lib.

Bar Graph 1 (Autosized)

Bar Graph 1 PHP Code

*renders graph into element with id="graph"

    // if not included already, include the autoloader
    include('../PhpD3/autoloader.php');

    $data = array(
        'data_file'=>'graph_data.tsv',
        'dimensions'=>array(
            'height'=>500,
            'width'=>960
        ),
        'render_element'=>array(
            'value'=>'graph',
            'type'=>'id'
        ),
        'axis_data'=>array(
            'x_axis_label'=>'letter',
            'y_axis_label'=>'frequency',
        ),
        'file_type'=>'tsv',
        'autosize'=>true
    );

    $chart = new PhpD3\Draw('simple_bar_graph',$data);
    $chart_render = $chart->render();
    


Bar Graph 2

Bar Graph 2 PHP Code

*renders graph into element with id="graph_2"

    // if not included already, include the autoloader
    include('../PhpD3/autoloader.php');

    $data = array(
        'data_file'=>'graph_data.tsv',
        'dimensions'=>array(
            'height'=>500,
            'width'=>960
        ),
        'render_element'=>array(
            'value'=>'graph_2',
            'type'=>'id'
        ),
        'axis_data'=>array(
            'x_axis_label'=>'letter',
            'y_axis_label'=>'frequency',
        ),
        'file_type'=>'tsv',
    );

    $chart = new PhpD3\Draw('simple_bar_graph',$data);
    $chart_render = $chart->render();