refactoring

This commit is contained in:
frankknoll
2023-11-09 09:42:50 +01:00
parent 46e3f4c22d
commit f1262e8ab6

View File

@@ -12,56 +12,52 @@ class SymptomVsSymptomChartView {
if (this.#chart != null) { if (this.#chart != null) {
this.#chart.destroy(); this.#chart.destroy();
} }
// FK-TODO: fetch multiple files: https://stackoverflow.com/a/31711496 or https://stackoverflow.com/a/53892713 // FK-TODO: move PrrByVaccineProvider.getPrrByVaccine() calls out of this function
PrrByVaccineProvider.getPrrByVaccine(symptomX) Promise
.then( .all([symptomX, symptomY].map(symptom => PrrByVaccineProvider.getPrrByVaccine(symptom)))
prrByLotX => { .then(([prrByLotX, prrByLotY]) => {
PrrByVaccineProvider.getPrrByVaccine(symptomY) const chartData = SymptomVsSymptomChartDataProvider.getChartData({ prrByLotX, prrByLotY });
.then( const data = {
prrByLotY => { datasets: [{
const chartData = SymptomVsSymptomChartDataProvider.getChartData({ prrByLotX, prrByLotY }); labels: chartData.labels,
const data = { data: chartData.data,
datasets: [{ backgroundColor: 'rgb(0, 0, 255)'
labels: chartData.labels, }],
data: chartData.data, };
backgroundColor: 'rgb(0, 0, 255)' const config = {
}], type: 'scatter',
}; data: data,
const config = { options: {
type: 'scatter', scales: {
data: data, x: {
options: { type: 'linear',
scales: { position: 'bottom'
x: { }
type: 'linear', },
position: 'bottom' plugins: {
} legend: {
}, display: false
plugins: { },
legend: { tooltip: {
display: false callbacks: {
}, label: function (context) {
tooltip: { return 'Batch: ' + context.dataset.labels[context.dataIndex];
callbacks: {
label: function (context) {
return 'Batch: ' + context.dataset.labels[context.dataIndex];
}
}
}
}
} }
}; }
this.#chart = new Chart( }
this.#canvas, }
// { }
// type: 'bar', };
// plugins: [ChartDataLabels], this.#chart = new Chart(
// data: this.#getData(ADRDescr), this.#canvas,
// options: this.#getOptions() // {
// } // type: 'bar',
config); // plugins: [ChartDataLabels],
}); // data: this.#getData(ADRDescr),
}); // options: this.#getOptions()
// }
config);
});
} }
setData(histoDescr) { setData(histoDescr) {