feat: set chart for Appointment Analytics
This commit is contained in:
parent
85aab34421
commit
5a92b3fc99
@ -69,5 +69,62 @@ frappe.query_reports['Patient Appointment Analytics'] = {
|
||||
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;
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
};
|
||||
|
@ -22,7 +22,6 @@ class Analytics(object):
|
||||
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 @@ class Analytics(object):
|
||||
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 @@ class Analytics(object):
|
||||
|
||||
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
|
||||
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"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user