Commit 3db3032d authored by Marco Descher's avatar Marco Descher
Browse files

sample wp

parent b45fb103
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,12 +2,32 @@ logger = Polyglot.import("logger");
coreModelService = Polyglot.import("coreModelService");
const Collectors = Java.type("java.util.stream.Collectors");
const sql = "SELECT CONCAT( cast(count(*) as char), ',' , MandantId) FROM BEHANDLUNGEN group by MandantId";
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 = stream.toArray();
print(result);
var result = Java.from(stream.toArray());
for (var ar of result) {
print(ar);
logger.warn(ar);
var _data = [];
var _labels = [];
for (var entry of result) {
var entry = Java.from(entry);
_data.push(entry[0]);
_labels.push(entry[1]);
}
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
});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment