This chart shows a measurement for downloads. It uses template "demo_meter.php". This template adds two buttons to trigger the measurement by calling a small javascript which issues a download request, calculates the timings and posts the result.
The event script (see variable $event_script), which adds an events listener, catches the post and updates the meter chart. Code of the javascript ("demo.js") is stored in RGraph's javascript library.
<?php

include_once "environment.php";
use phpRGraph\rgraph_chart;
use phpRGraph\rgraph_options;

$template = "demo_meter.php";
$id = "cvs";
$draw_option = "draw();";
$width = "350";
$height = "350";
 
$chart = new rgraph_chart("cvs", null, "Gauge");
$chart->set_min(0);
$chart->set_max($max);
$chart->set_value(0);

$options = new rgraph_options("gauge.ini");
$options->set_option("titleTop", "Your Download Speed");
$options->set_option("labelsValueUnitsPost", " Mbps");
$options->set_option("radius",140);
$options->set_option("max",$max);
$draw_option .= $options->getResponsiveFunction(array(0.3,990,1200, $width, $height));

$chart->set_options($options);
$rgraph_json = $chart->toString();

$event_script =  $chart->getEventScript("meter_event.js");
$chart_script = "";

include_once ($templates . $template);
?>