-
diff --git a/src/main/webapp/js/overview.js b/src/main/webapp/js/overview.js
deleted file mode 100644
index 9b048d4..0000000
--- a/src/main/webapp/js/overview.js
+++ /dev/null
@@ -1,58 +0,0 @@
-$.ajax({
- url: 'week_overview',
- dataType: 'json'
-}).done(function (results) {
- new Chart(document.getElementById("overview_chart"), {
- type: 'line',
- data: {
- labels: results.labels,
- datasets: [{
- label: "Warenanzahl",
- data: results.count,
- fill: true,
- backgroundColor: 'rgba(113, 114, 231, 0.7)',
- lineTension: 0
- }, {
- label: "Einnahmen in €",
- data: results.revenue,
- fill: true,
- backgroundColor: 'rgba(104, 216, 154, 0.8)',
- lineTension: 0
- }]
- },
- options: {
- responsive: true,
- title: {
- display: false,
- text: 'Übersicht'
- },
- legend: {
- display: false
- },
- tooltips: {
- mode: 'index',
- intersect: false
- },
- hover: {
- mode: 'nearest',
- intersect: true
- },
- elements: {
- point: {
- radius: 0
- }
- },
- scales: {
- xAxes: [{
- display: true,
- gridLines: {
- display: false
- }
- }],
- yAxes: [{
- display: true
- }]
- }
- }
- });
-});
\ No newline at end of file
diff --git a/src/main/webapp/js/shopping_times.js b/src/main/webapp/js/shopping_times.js
index 97655fd..6a745b1 100644
--- a/src/main/webapp/js/shopping_times.js
+++ b/src/main/webapp/js/shopping_times.js
@@ -1,6 +1,6 @@
let shopping_result;
-let shopping_chart = new Chart(document.getElementById("shoping_times_chart"), {
+let shopping_chart = new Chart(document.getElementById("shopping_times_chart"), {
type: 'bar',
data: {
labels: [1, 2, 3, 4, 5],
@@ -61,45 +61,29 @@ $.ajax({
});
function updateDays() {
- let e = document.getElementById("day");
- let value = e.options[e.selectedIndex].text;
- shopping_chart.data.labels = shopping_result.labels;
- shopping_chart.data.datasets[0].data = shopping_result[value];
+ if(typeof shopping_result["Montag"] !== 'undefined') {
+ let e = document.getElementById("day");
+ let value = e.options[e.selectedIndex].text;
+ shopping_chart.data.labels = shopping_result.labels;
+ shopping_chart.data.datasets[0].data = shopping_result[value];
- let color = shopping_result[value].map(x => 'rgba(143, 170, 220, 0.9)');
+ let max = Math.max.apply(null, shopping_result[value]);
+ let min = Math.min.apply(null, shopping_result[value]);
+ let array = [];
+ shopping_result[value].map(function (value) {
+ if(value == max)
+ value = 'rgba(129, 199, 132, 1)';
+ else if(value == min) {
+ value = 'rgba(239, 154, 154, 1)';
+ }
+ else {
+ value = 'rgba(143, 170, 220, 0.9)';
+ }
+ array.push(value);
+ });
+ shopping_chart.data.datasets[0].backgroundColor = array;
- console.log("max");
- argMax(shopping_result[value]).slice().forEach(function (item) {
- console.log(item);
- color[item] = 'green';
- });
- /*console.log("min");
- argMin(shopping_result[value]).forEach(function(item) {
- console.log(item);
- color[item] = 'red';
- });*/
+ shopping_chart.update();
+ }
- shopping_chart.data.datasets[0].backgroundColor = color;
-
- shopping_chart.update();
-}
-
-function argMax(array) {
- let result = [];
- console.log(Math.max.apply(null, array));
- array.forEach(function(item) {
- console.log(item);
- if(item == Math.max.apply(null, array)) {
- console.log(true);
- result.push(array.indexOf(item));
- }
- });
- console.log(result);
- return result;
-}
-
-function argMin(array) {
- let arr = array.slice().sort();
- console.log(arr[0]);
- return arr
}
\ No newline at end of file
diff --git a/src/main/webapp/js/week_overview.js b/src/main/webapp/js/week_overview.js
new file mode 100644
index 0000000..1cb0046
--- /dev/null
+++ b/src/main/webapp/js/week_overview.js
@@ -0,0 +1,65 @@
+let week_overview = new Chart(document.getElementById("overview_chart"), {
+ type: 'line',
+ data: {
+ labels: [0, 0, 0, 0, 0],
+ datasets: [{
+ label: "Warenanzahl",
+ data: [0, 0, 0, 0, 0],
+ fill: true,
+ backgroundColor: 'rgba(113, 114, 231, 0.7)',
+ lineTension: 0
+ }, {
+ label: "Einnahmen in €",
+ data: [0, 0, 0, 0, 0],
+ fill: true,
+ backgroundColor: 'rgba(104, 216, 154, 0.8)',
+ lineTension: 0
+ }]
+ },
+ options: {
+ responsive: true,
+ title: {
+ display: false,
+ text: 'Übersicht'
+ },
+ legend: {
+ display: false
+ },
+ tooltips: {
+ mode: 'index',
+ intersect: false
+ },
+ hover: {
+ mode: 'nearest',
+ intersect: true
+ },
+ elements: {
+ point: {
+ radius: 0
+ }
+ },
+ scales: {
+ xAxes: [{
+ display: true,
+ gridLines: {
+ display: false
+ }
+ }],
+ yAxes: [{
+ display: true
+ }]
+ }
+ }
+});
+
+$.ajax({
+ url: 'week_overview',
+ dataType: 'json'
+}).done(function (results) {
+ week_overview.data.labels = results.labels;
+ week_overview.data.datasets[0].data = results.count;
+ week_overview.data.datasets[1].data = results.revenue;
+
+ week_overview.update();
+
+});
\ No newline at end of file