making scatter chart for symptoms downloadable
This commit is contained in:
@@ -3,11 +3,15 @@ class SymptomVsSymptomChartViewInitializer {
|
||||
#symptomVsSymptomChartView;
|
||||
#symptomX;
|
||||
#symptomY;
|
||||
#batches;
|
||||
#data;
|
||||
#downloadSymptomVsSymptomChartButton;
|
||||
|
||||
configureSymptomVsSymptomChart(
|
||||
{ symptomSelectXElement, symptomSelectYElement, symptomVsSymptomChartViewElement },
|
||||
{ symptomSelectXElement, symptomSelectYElement, symptomVsSymptomChartViewElement, downloadSymptomVsSymptomChartButton },
|
||||
initializeSelectElement) {
|
||||
|
||||
this.#initializeButton(downloadSymptomVsSymptomChartButton);
|
||||
this.#symptomVsSymptomChartView = new SymptomVsSymptomChartView(symptomVsSymptomChartViewElement);
|
||||
{
|
||||
initializeSelectElement(
|
||||
@@ -37,8 +41,44 @@ class SymptomVsSymptomChartViewInitializer {
|
||||
}
|
||||
|
||||
#loadAndDisplayChart() {
|
||||
if (this.#symptomX != null && this.#symptomY != null) {
|
||||
this.#symptomVsSymptomChartView.loadAndDisplayChart(this.#symptomX, this.#symptomY);
|
||||
UIUtils.disableButton(this.#downloadSymptomVsSymptomChartButton);
|
||||
if (this.#symptomX == null || this.#symptomY == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#symptomVsSymptomChartView
|
||||
.loadAndDisplayChart(this.#symptomX, this.#symptomY)
|
||||
.then(({ labels, data }) => {
|
||||
this.#batches = labels;
|
||||
this.#data = data;
|
||||
UIUtils.enableButton(this.#downloadSymptomVsSymptomChartButton);
|
||||
});
|
||||
}
|
||||
|
||||
#initializeButton(downloadSymptomVsSymptomChartButton) {
|
||||
this.#downloadSymptomVsSymptomChartButton = downloadSymptomVsSymptomChartButton;
|
||||
UIUtils.disableButton(downloadSymptomVsSymptomChartButton);
|
||||
downloadSymptomVsSymptomChartButton.addEventListener(
|
||||
'click',
|
||||
() => this.#downloadSymptomVsSymptomChart())
|
||||
}
|
||||
|
||||
#downloadSymptomVsSymptomChart() {
|
||||
UIUtils.downloadUrlAsFilename(
|
||||
window.URL.createObjectURL(
|
||||
new Blob(
|
||||
[
|
||||
ScatterChart2CsvConverter.convertScatterChart2Csv(
|
||||
{
|
||||
symptomX: this.#symptomX,
|
||||
symptomY: this.#symptomY,
|
||||
batches: this.#batches,
|
||||
data: this.#data
|
||||
}
|
||||
)
|
||||
],
|
||||
{ type: 'text/csv' })),
|
||||
`${this.#symptomX} Vs ${this.#symptomY}`
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user