A bubble chart is a type of chart that displays three dimensions
of data. Here in this sample the third dimension is the market share
of a product.
This charts 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";
$draw_option = "draw();";
$width = "650";
$height = "350";
// scatter data
$data = array(
array(1,12200,'red','15% market share'),
array(2,60000,'blue','33% market share'),
array(3,32000,'purple','42% market share'),
array(4,24400,'blue','20% market share'),
);
// data for bubbles
$bubble_data = array(15,33,42,20);
$chart = new rgraph_chart("cvs", $data, "Scatter");
$options = new rgraph_options("default.ini");
$options->set_option("bubbleData", $bubble_data);
$options->set_option("bubbleWidth", 80);
$options->set_option("bubbleMax", max($bubble_data));
$options->set_option("marginLeft", 100);
$options->set_option("title","Industry Market Share Study\n");
$options->set_option("xaxisScaleMax", 5);
$options->set_option("yaxisScaleMax", 70000);
$options->set_option("xaxisLabels", array('1','2','3','4'));
$options->set_option("xaxisTitle", "Product Number");
$options->set_option("yaxisTitle", "Revenue");
$options->set_option("yaxisTitlePos", 0.25);
$options->set_option("yaxisScaleUnitsPost"," €");
$options->set_option("tooltipsHotspot",15);
$options->set_option("tooltipsEvent", "onclick");
$draw_option .= $options->getResponsiveFunction(array(0.3,990,1200, $width, $height));
$chart->set_options($options);
$rgraph_json = $chart->toString();
$chart_script = "";
$event_script = "";
include_once ($templates . $template);
?>