Data for
this line chart is built by php-RGraph's utility function "getDataviaFormula".
This function takes a formula as input and calculates y-values based
on provided start x-value, x-steps (intervals) and a maximum x-value. The number of
iterations is limited to 500 per default (but may be increased by
using a higher value by adding a parameter after maximum x-values). The calculation
finishes when either maximum of x-values or maximum of iteration is reached.
<?php
include_once "environment.php";
use phpRGraph\rgraph_chart;
use phpRGraph\rgraph_options;
include_once $utility;
$template = "default.php";
$draw_option = "trace2({frames: 60});";
$width = "800";
$height = "350";
$data = getDataviaFormula("y=2*e^-(0.2 * x)*sin(x * 2*pi)", 0.1, 0, 20);
$chart = new rgraph_chart("cvs", $data['y_values'], "Line");
$options = new rgraph_options("default.ini");
$options->set_option("title", "A Line Chart with calculated Data via Formula: y = 2*e^-(0.2*x)*sin(x * 2*pi)");
$options->set_option("titleY",20);
$options->set_option("yaxisScaleMax", 2.0);
$options->set_option("yaxisScaleDecimals",3);
$options->set_option("xaxisPosition", "center");
$options->set_option("outofbounds", true);
$labels = $data['x_values'];
$options->set_option("xaxisLabels", $labels);
$options->set_option("xaxisTickmarksCount", 10);
$options->set_option("backgroundGridAutofit", false);
$options->set_tooltip($data['y_values'], "x=#label# value=#val# ");
$labels = $options->xlabelsteps($data['x_values'],10);
$options->set_option("xaxisLabels", $labels);
$chart->set_options($options);
$rgraph_json = $chart->toString();
$chart_script = "";
$event_script = "";
include_once ($templates . $template);
?>