In this example we will be exploring the Simple Bar Graph using the php-d3-lib.
*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();
*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();