starting to add sliders to charts

This commit is contained in:
frankknoll
2023-01-29 21:30:27 +01:00
parent 81d91b6368
commit aed3ec8298
3 changed files with 14 additions and 4 deletions

View File

@@ -25,15 +25,16 @@ class HistogramView {
#displayHistograms(histoDescrs) { #displayHistograms(histoDescrs) {
this.#uiContainer.appendChild(document.createTextNode(histoDescrs.batchcode)); this.#uiContainer.appendChild(document.createTextNode(histoDescrs.batchcode));
for (const histoDescr of histoDescrs.histograms) { for (const histoDescr of histoDescrs.histograms) {
this.#uiContainer.appendChild(this.#createHistogram(histoDescr).canvas); this.#displayHistogram(histoDescr);
} }
} }
#createHistogram(histoDescr) { #displayHistogram(histoDescr) {
// FK-TODO: brauchen Slider wie bei intensivstationen // FK-TODO: brauchen Slider wie bei intensivstationen
const canvas = document.createElement("canvas"); const canvas = UIUtils.createCanvas();
this.#uiContainer.appendChild(canvas);
const { 'keys': symptoms, 'values': frequencies } = Utils.getKeysAlignedWithValues(histoDescr.histogram); const { 'keys': symptoms, 'values': frequencies } = Utils.getKeysAlignedWithValues(histoDescr.histogram);
return new Chart( new Chart(
canvas, canvas,
{ {
type: 'bar', type: 'bar',

View File

@@ -4,6 +4,10 @@ class UIUtils {
return document.getElementById(templateId).content.firstElementChild.cloneNode(true); return document.getElementById(templateId).content.firstElementChild.cloneNode(true);
} }
static createCanvas() {
return UIUtils.instantiateTemplate('template-canvas');
}
static createChartViewElementWithHeading(heading) { static createChartViewElementWithHeading(heading) {
const chartViewElement = UIUtils.instantiateTemplate('template-ChartView'); const chartViewElement = UIUtils.instantiateTemplate('template-ChartView');
chartViewElement.querySelector(".heading").textContent = heading; chartViewElement.querySelector(".heading").textContent = heading;

View File

@@ -13,6 +13,7 @@
type="text/javascript"></script> type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.2.0/dist/chart.umd.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js@4.2.0/dist/chart.umd.min.js"></script>
<script src="./Utils.js"></script> <script src="./Utils.js"></script>
<script src="./UIUtils.js"></script>
<script src="./batchCodeTable.js"></script> <script src="./batchCodeTable.js"></script>
<script src="./HistogramView.js"></script> <script src="./HistogramView.js"></script>
<script> <script>
@@ -172,6 +173,10 @@
<a href="https://vaers.hhs.gov/data/datasets.html" target="_blank">Vaccine Adverse Event Reporting System <a href="https://vaers.hhs.gov/data/datasets.html" target="_blank">Vaccine Adverse Event Reporting System
(VAERS)</a> (VAERS)</a>
</p> </p>
<template id="template-canvas">
<canvas></canvas>
</template>
</body> </body>
</html> </html>