You may use method "rgraph::createScatterData" to
create the data for scatter charts.
<?php
include_once "environment.php";
use phpRGraph\rgraph_chart;
use phpRGraph\rgraph_options;
// rgraph chart
$template = "default.php";
$draw_option = "draw();";
$width = "550";
$height = "400";
$chart = new rgraph_chart("cvs", null, "Scatter");
$x_values = array(156,157,159,160,161,162,165,170,170,173,173,177,
177,178,184,188,188,188,188,188,194,196,200);
$y_values = array(162,160,162,155,162,170,166,170,167,185,176,173,
176,178,180,188,187,182,181,192,193,184,186);
$data = $chart->createScatterData($x_values, $y_values);
$chart->set_data($data);
$options = new rgraph_options("default.ini");
$options->set_option("marginLeft", 100);
$options->set_option("marginRight", 10);
$options->set_option("title","Body Size versus Length of Arms");
$options->set_option("xaxisLabels", $options->xlabelsteps($x_values, 2));
$options->set_option("xaxisScaleMin", 150);
$options->set_option("xaxisScaleMax", 196);
$options->set_option("yaxisScaleMax", 203);
$options->set_option("yaxisScaleMin", 150);
$options->set_option("yaxisScaleUnitsPost"," cm");
$options->set_option("yaxisTitle","Body Size");
$options->set_option("xaxisTitle","Length of Arms in cm");
$options->set_option("xaxisTitlePos",0.50);
$options->set_option("yaxisTitlePos",0.50);
$options->set_option("trendline", true);
$options->set_option("trendlineColor", "red");
$options->set_option("trendlineClipping", false);
$chart->set_options($options);
$rgraph_json = $chart->toString();
$event_script = "";
$chart_script = "";
include_once ($templates . $template);
?>