From 1ee19e4167f72dd73ed1bc35dd58b60b4c51f012 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sat, 15 Dec 2018 15:36:09 +0530 Subject: [PATCH] Analytics report graph fix --- .../purchase_analytics/purchase_analytics.js | 17 ++++++++++++++--- .../report/sales_analytics/sales_analytics.js | 19 +++++++++++++++---- .../report/sales_analytics/sales_analytics.py | 6 +++++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/erpnext/buying/report/purchase_analytics/purchase_analytics.js b/erpnext/buying/report/purchase_analytics/purchase_analytics.js index b55046e065..e17973c337 100644 --- a/erpnext/buying/report/purchase_analytics/purchase_analytics.js +++ b/erpnext/buying/report/purchase_analytics/purchase_analytics.js @@ -77,9 +77,20 @@ frappe.query_reports["Purchase Analytics"] = { events: { onCheckRow: function(data) { row_name = data[2].content; - row_values = data.slice(5).map(function (column) { - return column.content; - }) + length = data.length; + + var tree_type = frappe.query_report.filters[0].value; + + if(tree_type == "Supplier" || tree_type == "Item") { + row_values = data.slice(4,length-1).map(function (column) { + return column.content; + }) + } + else { + row_values = data.slice(3,length-1).map(function (column) { + return column.content; + }) + } entry = { 'name':row_name, diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.js b/erpnext/selling/report/sales_analytics/sales_analytics.js index 0df425d1cd..fbe045bf35 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.js +++ b/erpnext/selling/report/sales_analytics/sales_analytics.js @@ -76,10 +76,21 @@ frappe.query_reports["Sales Analytics"] = { events: { onCheckRow: function(data) { row_name = data[2].content; - length = data.length - row_values = data.slice(4,length-1).map(function (column) { - return column.content; - }) + length = data.length; + + var tree_type = frappe.query_report.filters[0].value; + + if(tree_type == "Customer" || tree_type == "Item") { + row_values = data.slice(4,length-1).map(function (column) { + return column.content; + }) + } + else { + row_values = data.slice(3,length-1).map(function (column) { + return column.content; + }) + } + entry = { 'name':row_name, 'values':row_values diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py index 9cc6c404a6..c078a08249 100644 --- a/erpnext/selling/report/sales_analytics/sales_analytics.py +++ b/erpnext/selling/report/sales_analytics/sales_analytics.py @@ -276,7 +276,11 @@ class Analytics(object): def get_chart_data(self): length = len(self.columns) - labels = [d.get("label") for d in self.columns[2:length-1]] + + if self.filters.tree_type in ["Customer", "Supplier", "Item"]: + labels = [d.get("label") for d in self.columns[2:length-1]] + else: + labels = [d.get("label") for d in self.columns[1:length-1]] self.chart = { "data": { 'labels': labels,