Data and labels for this 3d bar chart have been fetched from a Joomla database.
Note that method rgraph_chart::getDataFromDB may be called statically.
Properties for the chart are not set individually but are provided
by a (ini) file and built by the constructor of the rgraph_options object.
The Bar chart shown here is an example of responsive charts so you can change the size of your browser window and see the effect on them.
This is provided by using option's method "getResponsiveFunction".
<?php
include_once "environment.php";
use phpRGraph\rgraph_chart;
use phpRGraph\rgraph_options;
// rgraph chart
$template = "default.php";
$id = "cvs";
$draw_option = "draw();";
$width = "600";
$height = "400";
$db_config_file = $_SERVER["DOCUMENT_ROOT"] . "/configuration.php";
$sql="Select title, hits From jos_content where state=1 Order By hits Desc Limit 10";
$db_data = rgraph_chart::getDataFromDB($db_config_file, $sql);
$chart = new rgraph_chart("cvs", $db_data[1], "Bar");
$options = new rgraph_options("bar_3d.ini");
$options->set_option("title", "Most Read Articles");
$options->set_option("titleSubtitle", "(today - " . date('l, d.m.Y - H:i') . ")" );
$options->set_option("xaxisLabels", $db_data[0]);
$options->set_tooltip($db_data[1], "#label# <br /> #val# Hits");
$responsive_opt = $options->getResponsiveOption(array(0.4,990,1200,$width,$height));
$options->set_option("responsive", $responsive_opt);
$chart->set_options($options);
$rgraph_json = $chart->toString();
$event_script = "";
$chart_script = "";
include_once ($templates . $template);
?>