To combine these two scatter charts, template "combine_two.php" is used.
<?php include_once "environment.php"; include_once $utility; // rgraph charts $template = "combine_two.php"; $id = "cvs"; $draw_option = "draw();"; $width = "550"; $height = "400"; $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); // setup chart1 // setup chart1 $chart1 = new rgraph_chart("cvs", null, "Scatter"); $data = $chart1->createScatterData($x_values, $y_values, null, $y_values ); $chart1->set_data($data); $options1 = new rgraph_options("default.ini"); $options1->set_option("marginLeft", 100); $options1->set_option("marginRight", 10); $options1->set_option("xaxisLabels", $options1->xlabelsteps($x_values, 2)); $options1->set_option("xaxisScaleMin", 150); $options1->set_option("xaxisScaleMax", 196); $options1->set_option("yaxisScaleMax", 203); $options1->set_option("yaxisScaleMin", 150); $options1->set_option("yaxisScaleUnitsPost"," cm"); $options1->set_option("yaxisTitle","Body Size"); $options1->set_option("xaxisTitle","Length of Arms in cm"); $options1->set_option("xaxisTitlePos",0.50); $options1->set_option("yaxisTitlePos",0.50); $options1->set_option("backgroundGridAutofit", false); $chart1->set_options($options1); $chart1_json = $chart1->toString(); $event1_script = ""; $chart1_script = ""; // chart2 caculated Regression line $chart2 = new rgraph_chart("cvs", null, "Scatter"); $result = calculate_Regression($x_values, $y_values); $data = $result['values']; $formula = $result['formula']; $chart2->set_data($data); $options2 = new rgraph_options("default.ini"); $options2->set_option("marginLeft", 100); $options2->set_option("marginRight", 10); $options2->set_option("title", "Body Size vs. Length of Arms\n(Regression: $formula)\n\n"); $options2->set_option("xaxisScaleMin", 150); $options2->set_option("xaxisScaleMax", 196); $options2->set_option("yaxisScaleMax", 203); $options2->set_option("yaxisScaleMin", 150); $options2->set_option("yaxisScaleUnitsPost"," cm"); $options2->set_option("line", true); $options2->set_option("lineLinewidth", 1.5); $options2->set_option("backgroundGrid", false); $options2->set_option("xaxis", false); $options2->set_option("yaxis", false); $options2->set_option("yaxisTickmarks",false); $options2->set_option("yaxisLabelsCount", 0); $options2->set_option("backgroundGridAutofit", false); $chart2->set_options($options2); $chart2_json = $chart2->toString(); $event2_script = ""; $chart2_script = ""; include_once ($templates . $template); ?>