refactoring

This commit is contained in:
frankknoll
2023-11-09 10:55:16 +01:00
parent a61615406b
commit 15786071c8

View File

@@ -28,12 +28,18 @@ class SymptomVsSymptomChartView {
if (this.#chart != null) { if (this.#chart != null) {
this.#chart.destroy(); this.#chart.destroy();
} }
const config = { this.#chart =
new Chart(
this.#canvas,
this.#getConfig(symptomX, symptomY, labels, data));
}
#getConfig(symptomX, symptomY, labels, data) {
return {
type: 'scatter', type: 'scatter',
data: this.#getData(labels, data), data: this.#getData(labels, data),
options: this.#getOptions(symptomX, symptomY) options: this.#getOptions(symptomX, symptomY)
}; };
this.#chart = new Chart(this.#canvas, config);
} }
#getData(labels, data) { #getData(labels, data) {
@@ -55,16 +61,10 @@ class SymptomVsSymptomChartView {
x: { x: {
type: 'linear', type: 'linear',
position: 'bottom', position: 'bottom',
title: { title: this.#getAxisTitle(symptomX)
display: true,
text: 'PRR ratio of Batch for ' + symptomX
}
}, },
y: { y: {
title: { title: this.#getAxisTitle(symptomY)
display: true,
text: 'PRR ratio of Batch for ' + symptomY
}
} }
}, },
plugins: { plugins: {
@@ -81,4 +81,11 @@ class SymptomVsSymptomChartView {
} }
}; };
} }
#getAxisTitle(symptom) {
return {
display: true,
text: 'PRR ratio of Batch for ' + symptom
}
}
} }