feat: set chart for Appointment Analytics
diff --git a/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.js b/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.js
index 6494ef2..e4a9a46 100644
--- a/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.js
+++ b/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.js
@@ -69,5 +69,62 @@
default: 'Monthly',
reqd: 1
}
- ]
+ ],
+ after_datatable_render: function(datatable_obj) {
+ $(datatable_obj.wrapper).find(".dt-row-0").find('input[type=checkbox]').click();
+ },
+ get_datatable_options(options) {
+ return Object.assign(options, {
+ checkboxColumn: true,
+ events: {
+ onCheckRow: function(data) {
+ row_name = data[2].content;
+ length = data.length;
+
+ row_values = data.slice(3,length-1).map(function (column) {
+ return column.content;
+ })
+
+
+ entry = {
+ 'name': row_name,
+ 'values': row_values
+ }
+
+ let raw_data = frappe.query_report.chart.data;
+ let new_datasets = raw_data.datasets;
+
+ let found = false;
+
+ for(let i=0; i < new_datasets.length;i++) {
+ if (new_datasets[i].name == row_name) {
+ found = true;
+ new_datasets.splice(i,1);
+ break;
+ }
+ }
+
+ if (!found) {
+ new_datasets.push(entry);
+ }
+
+ let new_data = {
+ labels: raw_data.labels,
+ datasets: new_datasets
+ }
+
+ setTimeout(() => {
+ frappe.query_report.chart.update(new_data)
+ }, 500)
+
+
+ setTimeout(() => {
+ frappe.query_report.chart.draw(true);
+ }, 1000)
+
+ frappe.query_report.raw_chart_data = new_data;
+ },
+ }
+ })
+ },
};
diff --git a/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py b/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py
index 627c388..15ad48c 100644
--- a/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py
+++ b/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py
@@ -22,7 +22,6 @@
self.get_data()
self.get_chart_data()
- self.chart = ''
return self.columns, self.data, None, self.chart
def get_period_date_ranges(self):
@@ -105,9 +104,6 @@
self.get_appointments_based_on_medical_department()
self.get_rows()
- def get_chart_data(self):
- pass
-
def get_period(self, appointment_date):
if self.filters.range == 'Weekly':
period = 'Week ' + str(appointment_date.isocalendar()[1]) + ' ' + str(appointment_date.year)
@@ -180,4 +176,15 @@
elif self.filters.tree_type == 'Medical Department':
self.appointment_periodic_data.setdefault(d.department, frappe._dict()).setdefault(period, 0.0)
- self.appointment_periodic_data[d.department][period] += 1
\ No newline at end of file
+ self.appointment_periodic_data[d.department][period] += 1
+
+ def get_chart_data(self):
+ length = len(self.columns)
+ labels = [d.get("label") for d in self.columns[3:length - 1]]
+ self.chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': []
+ },
+ "type": "line"
+ }
\ No newline at end of file