...
 
Commits (2)
This diff is collapsed.
<html>
<head>
<title>Misthios Sample</title>
<script src="Chart.js"></script>
<script src="webpage.js"></script>
</head>
<body>
<center>
<h1>Anzahl Konsultationen per Mandant</h1>
<div id="canvas-holder" style="width:100%">
<canvas id="chart-area"></canvas>
</div>
</center>
</body>
</html>
......@@ -2,6 +2,20 @@ logger = Polyglot.import("logger");
coreModelService = Polyglot.import("coreModelService");
const Collectors = Java.type("java.util.stream.Collectors");
<<<<<<< HEAD
const sql =
'SELECT no, CONCAT(k.titel, " ", k.bezeichnung1, " ", k.bezeichnung2) FROM ( SELECT count(*) no, MandantId FROM behandlungen group by MandantId ) AS X LEFT JOIN KONTAKT k on x.MandantId = k.id;';
var stream = coreModelService.executeNativeQuery(sql);
var result = Java.from(stream.toArray());
var _data = [];
var _labels = [];
for (var entry of result) {
var entry = Java.from(entry);
_data.push(entry[0]);
_labels.push(entry[1]);
=======
const sql = "SELECT count(*) , MandantId FROM behandlungen group by MandantId";
var stream = coreModelService.executeNativeQuery(sql);
var result = Java.from(stream.toArray());
......@@ -9,4 +23,21 @@ var result = Java.from(stream.toArray());
for (var ar of result) {
var bla = Java.from(ar)
print(bla[0] + " " + bla[1])
>>>>>>> 3aed852fd7b7336785f1bbaf4b1edfe27ec9ab4c
}
var json = {};
json.labels = _labels;
json.datasets = [];
var set = {};
set.data = _data;
json.datasets.push(set);
var _json = JSON.stringify(json);
var dataParameter = encodeURIComponent(_json);
({
url:
Polyglot.import("bundleSourceLocation") + "index.html?data=" + dataParameter
});
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
window.onload = function() {
var url = new URL(window.location.href);
var uriDataParameter = url.searchParams.get("data");
var dataParameter = JSON.parse(decodeURIComponent(uriDataParameter));
dataParameter.datasets[0].backgroundColor = [];
for (entry in dataParameter.datasets[0].data) {
dataParameter.datasets[0].backgroundColor.push(getRandomColor());
}
console.log(dataParameter);
var ctx = document.getElementById("chart-area").getContext("2d");
var myChart = new Chart(ctx, {
type: "pie",
data: dataParameter
});
};