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 = "450";
$height = "300";
$chart = new rgraph_chart("cvs", null, "Meter");
$chart->set_min(0);
$chart->set_max($max);
$chart->set_value(0);
$options = new rgraph_options("meter.ini");
$options->set_option("title", "Your Download Speed");
$options->set_option("labelsValueTextUnitsPost", " Mbps");
$options->set_option("labelsValueText", true);
$chart->set_options($options);
$rgraph_json = $chart->toString();
$event_script = $chart->getEventScript("meter_event.js");
$chart_script = "";
include_once ($templates . $template);
?>