Welcome to the Dual Scale Bar Graph Example

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

Dual Scale Bar Graph 1 (Autosized)

Dual Scale Bar Graph 1 PHP Code

*renders graph into element with id="graph"

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

        $data = array(
            'data_file'=>'dual_scale_data.tsv',
            'dimensions'=>array(
                'height'=>500,
                'width'=>950
            ),
            'render_element'=>array(
                'value'=>'graph',
                'type'=>'id'
            ),
            'axis_data'=>array(
                'xAxis' =>[
                   'label' => 'Testing 1',
                   'key' => 'testing1'
                ],
                'yAxis' =>[
                    'label' => 'Testing 2',
                    'key' => 'testing2'
                ],
                'y2Axis' =>[
                    'label' => 'Num',
                    'key' => 'num'
                ],
            ),
            'file_type'=>'tsv',
            'autosize'=>true
        );

        $graph = new PhpD3\Draw('dual_scale_bar_graph',$data);
        $graph_render = $graph->render();

        echo $graph_render;
        


Dual Scale Bar Graph 2

Dual Scale Bar Graph 2 PHP Code

*renders graph into element with id="graph_2"

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

        $data = array(
            'data_file'=>'dual_scale_data.tsv',
            'dimensions'=>array(
                'height'=>500,
                'width'=>950
            ),
            'render_element'=>array(
                'value'=>'graph_2',
                'type'=>'id'
            ),
            'axis_data'=>array(
                'xAxis' =>[
                   'label' => 'Testing 1',
                   'key' => 'testing1'
                ],
                'yAxis' =>[
                    'label' => 'Testing 2',
                    'key' => 'testing2'
                ],
                'y2Axis' =>[
                    'label' => 'Num',
                    'key' => 'num'
                ],
            ),
            'file_type'=>'tsv',
        );

        $graph = new PhpD3\Draw('dual_scale_bar_graph',$data);
        $graph_render = $graph->render();

        echo $graph_render;