<?php

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

// rgraph chart
$template = "default.php";
$id = "cvs";
$draw_option = "draw()";
$width = "800";
$height = "400";

$chart = new rgraph_chart("cvs", null, "Line");
$csv_data = $chart->getCSVdata ("dax_historic.csv", 1);

$data =  $csv_data[4];
$chart->set_data($data);
 
$options = new rgraph_options("default.ini");
$options->set_option("title", "DAX30 one Year Performance");

$options->set_option("filled", false);
$options->set_option("backgroundGridAutofit",false);
$options->set_option("xaxisTickmarksCount",15);
$options->set_option("yaxisScaleMin", 8000);

$options->set_option("trendline", array(true));
$options->set_option("trendlineLinewidth",array(2));
$options->set_option("trendlineDashed",true);
$options->set_option("trendlineColors",array("#008000"));

$options->set_option("labels", $csv_data[0]);
$options->set_option("scaleDecimals", 2);
$options->set_option("unitsPost", "€ ");
$options->set_tooltip($chart->get_data(), "#label# #val# points");
$options->set_option("xaxisLabelsAngle",35);
$options->set_option("xaxisLabels", $options->xlabelsteps($csv_data[0], 15));
$draw_option .= $options->getResponsiveFunction(array(0.3,990,1200,$width,$height));

$chart->set_options($options);

$rgraph_json = $chart->toString();

$canvas_style = "";
$chart_script = "";
$event_script = "";

include_once ($templates . $template);
?>