From 153e5d63052617ce20096d1d2b05570745fec8b8 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 29 Nov 2023 13:53:05 +0100 Subject: [PATCH] better graphs --- web/pages/demo/controller.php | 50 ++++++++++- web/pages/smart/controller.php | 1 - web/pages/smart/search.html.php | 120 +++++++++----------------- web/templates/partials/graph.html.php | 73 ++++++++++++++++ 4 files changed, 159 insertions(+), 85 deletions(-) create mode 100644 web/templates/partials/graph.html.php diff --git a/web/pages/demo/controller.php b/web/pages/demo/controller.php index 5a2c221..62947ce 100644 --- a/web/pages/demo/controller.php +++ b/web/pages/demo/controller.php @@ -17,9 +17,53 @@ class Demo extends Page{ function test() { - $u = new User(); - $u->load('Chris','firstname'); - var_dump($u->data); + $graph1 = partial('graph.html.php', [ + 'id' => 'graph1', + 'title' => 'Graph 1', + 'legend' => ['Geschwindigkeit', 'Fehler', 'Verweigerungen', 'Zeit', 'Geschwindigkeit', 'Punkte', 'Platz'], + 'xaxis' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], + 'seriesdata' => [ + ['name' => 'Geschwindigkeit', 'type'=>'line','stack'=>'Total', 'data' => [120, 132, 101, 134, 90, 230, 210]], + ['name' => 'Fehler', 'type'=>'line','stack'=>'Total', 'data' => [220, 182, 191, 234, 290, 330, 310]], + ['name' => 'Verweigerungen', 'type'=>'line','stack'=>'Total', 'data' => [150, 232, 201, 154, 190, 330, 410]], + ['name' => 'Zeit', 'type'=>'line','stack'=>'Total', 'data' => [320, 332, 301, 334, 390, 330, 320]], + ['name' => 'Punkte', 'type'=>'line','stack'=>'Total', 'data' => [820, 932, 901, 934, 1290, 1330, 1320]], + ['name' => 'Platz', 'type'=>'line','stack'=>'Total', 'data' => [820, 932, 901, 934, 1290, 1330, 1320]] + ], + ]); + + $graph2 = partial('graph.html.php', [ + 'id' => 'graph2', + 'title' => 'Punkte', + 'xaxis' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], + 'seriesdata' => [ + ['name' => 'Punkte', 'type'=>'line','stack'=>'Total', 'data' => [820, 932, 901, 934, 1290, 1330, 1320]], + ], + ]); + + $graph3 = partial('graph.html.php', [ + 'id' => 'graph3', + 'title' => 'Graph 3', + 'legend' => ['Punkte'], + 'xaxis' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], + 'seriesdata' => [ + ['name' => 'Punkte', 'type'=>'line','stack'=>'Total', 'data' => [820, 932, 901, 934, 1290, 1330, 1320]], + ], + ]); + + return '
+
+
+ '.$graph1.' +
+
+ '.$graph2.' +
+
+ '.$graph3.' +
+
+
'; } function index() diff --git a/web/pages/smart/controller.php b/web/pages/smart/controller.php index 1ff66b6..a22b708 100644 --- a/web/pages/smart/controller.php +++ b/web/pages/smart/controller.php @@ -57,7 +57,6 @@ class Smart extends Page { $this->set('results_dogs', $results); $this->set('dogs', $dogs); - $this->set('query', $query); $this->set('template', 'search.html.php'); } diff --git a/web/pages/smart/search.html.php b/web/pages/smart/search.html.php index 6435d7b..db847c7 100644 --- a/web/pages/smart/search.html.php +++ b/web/pages/smart/search.html.php @@ -37,8 +37,7 @@ - 0) : ?> -
-
+
+ 0) : ?> +
+ 'graph1'.$dog, + 'title' => 'Fehler und Verweigerungen', + 'xaxis' => $sdata['dates'], + 'seriesdata' => [ + ['name' => 'Fehler', 'type' => 'line', 'stack' => 'Total', 'data' => $sdata['errors']], + ['name' => 'Verweigerungen', 'type' => 'line', 'stack' => 'Total', 'data' => $sdata['refusals']], + ], + ]); + ?> +
- -
- +
diff --git a/web/templates/partials/graph.html.php b/web/templates/partials/graph.html.php new file mode 100644 index 0000000..65d2640 --- /dev/null +++ b/web/templates/partials/graph.html.php @@ -0,0 +1,73 @@ + 'graph1', + 'title' => 'Graph 1', + 'gclass' => '', // classes for the graph div + 'legend' => ['Geschwindigkeit', 'Fehler', 'Verweigerungen', 'Zeit', 'Geschwindigkeit', 'Punkte', 'Platz'], + 'xaxis' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], + 'seriesdata' => [ + ['name' => 'Geschwindigkeit', 'type'=>'line','stack'=>'Total', 'data' => [120, 132, 101, 134, 90, 230, 210]], + ['name' => 'Fehler', 'type'=>'line','stack'=>'Total', 'data' => [220, 182, 191, 234, 290, 330, 310]], + ['name' => 'Verweigerungen', 'type'=>'line','stack'=>'Total', 'data' => [150, 232, 201, 154, 190, 330, 410]], + ['name' => 'Zeit', 'type'=>'line','stack'=>'Total', 'data' => [320, 332, 301, 334, 390, 330, 320]], + ['name' => 'Punkte', 'type'=>'line','stack'=>'Total', 'data' => [820, 932, 901, 934, 1290, 1330, 1320]], + ['name' => 'Platz', 'type'=>'line','stack'=>'Total', 'data' => [820, 932, 901, 934, 1290, 1330, 1320]] + ], + ]) + */ + +?> + +
+ + \ No newline at end of file