From bfb108d7229654e22ca4e58eb9443d28443cd4f7 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Tue, 17 Oct 2017 12:03:02 +0530 Subject: [PATCH] Replace c3 (#11112) * [charts] replace in asset.js * replace in reports --- erpnext/accounts/doctype/asset/asset.js | 39 +++++--------- .../accounts_receivable.py | 52 +++++++++---------- .../report/balance_sheet/balance_sheet.py | 52 ++++++++++--------- .../profit_and_loss_statement.py | 31 +++++------ ...nutes_to_first_response_for_opportunity.js | 22 +++----- .../vehicle_expenses/vehicle_expenses.py | 36 +++++++------ .../production_analytics.js | 21 ++++---- .../course_wise_assessment_report.py | 13 +++-- .../minutes_to_first_response_for_issues.js | 22 +++----- .../support_hour_distribution.py | 18 +++---- 10 files changed, 139 insertions(+), 167 deletions(-) diff --git a/erpnext/accounts/doctype/asset/asset.js b/erpnext/accounts/doctype/asset/asset.js index 7c4eeae93a4..e3afc359b65 100644 --- a/erpnext/accounts/doctype/asset/asset.js +++ b/erpnext/accounts/doctype/asset/asset.js @@ -55,13 +55,13 @@ frappe.ui.form.on('Asset', { }); } - frm.trigger("show_graph"); + frm.trigger("setup_chart"); } }, - show_graph: function(frm) { - var x_intervals = ["x", frm.doc.purchase_date]; - var asset_values = ["Asset Value", frm.doc.gross_purchase_amount]; + setup_chart: function(frm) { + var x_intervals = [frm.doc.purchase_date]; + var asset_values = [frm.doc.gross_purchase_amount]; var last_depreciation_date = frm.doc.purchase_date; if(frm.doc.opening_accumulated_depreciation) { @@ -94,32 +94,21 @@ frappe.ui.form.on('Asset', { last_depreciation_date = frm.doc.disposal_date; } - frm.dashboard.setup_chart({ + frm.dashboard.render_graph({ + title: "Asset Value", data: { - x: 'x', - columns: [x_intervals, asset_values], - regions: { - 'Asset Value': [{'start': last_depreciation_date, 'style':'dashed'}] - } + labels: x_intervals, + datasets: [{ + color: 'green', + values: asset_values, + formatted: asset_values.map(d => d.toFixed(2)) + }] }, - legend: { - show: false - }, - axis: { - x: { - type: 'timeseries', - tick: { - format: "%d-%m-%Y" - } - }, - y: { - min: 0, - padding: {bottom: 10} - } - } + type: 'line' }); }, + item_code: function(frm) { if(frm.doc.item_code) { frappe.call({ diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 9906893254f..56db3928009 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -44,7 +44,7 @@ class ReceivablePayableReport(object): }) columns += [_("Age (Days)") + ":Int:80"] - + self.ageing_col_idx_start = len(columns) if not "range1" in self.filters: @@ -53,7 +53,7 @@ class ReceivablePayableReport(object): self.filters["range2"] = "60" if not "range3" in self.filters: self.filters["range3"] = "90" - + for label in ("0-{range1}".format(range1=self.filters["range1"]), "{range1}-{range2}".format(range1=cint(self.filters["range1"])+ 1, range2=self.filters["range2"]), "{range2}-{range3}".format(range2=cint(self.filters["range2"])+ 1, range3=self.filters["range3"]), @@ -74,14 +74,14 @@ class ReceivablePayableReport(object): }) if args.get("party_type") == "Customer": columns += [ - _("Territory") + ":Link/Territory:80", + _("Territory") + ":Link/Territory:80", _("Customer Group") + ":Link/Customer Group:120" ] if args.get("party_type") == "Supplier": columns += [_("Supplier Type") + ":Link/Supplier Type:80"] - + columns.append(_("Remarks") + "::200") - + return columns def get_data(self, party_naming_by, args): @@ -97,13 +97,13 @@ class ReceivablePayableReport(object): self.filters["company"] = frappe.db.get_single_value('Global Defaults', 'default_company') company_currency = frappe.db.get_value("Company", self.filters.get("company"), "default_currency") - + return_entries = self.get_return_entries(args.get("party_type")) data = [] for gle in self.get_entries_till(self.filters.report_date, args.get("party_type")): if self.is_receivable_or_payable(gle, dr_or_cr, future_vouchers): - outstanding_amount, credit_note_amount = self.get_outstanding_amount(gle, + outstanding_amount, credit_note_amount = self.get_outstanding_amount(gle, self.filters.report_date, dr_or_cr, return_entries, currency_precision) if abs(outstanding_amount) > 0.1/10**currency_precision: row = [gle.posting_date, gle.party] @@ -179,15 +179,15 @@ class ReceivablePayableReport(object): # entries adjusted with future vouchers ((gle.against_voucher_type, gle.against_voucher) in future_vouchers) ) - + def get_return_entries(self, party_type): doctype = "Sales Invoice" if party_type=="Customer" else "Purchase Invoice" - return [d.name for d in frappe.get_all(doctype, filters={"is_return": 1, "docstatus": 1})] + return [d.name for d in frappe.get_all(doctype, filters={"is_return": 1, "docstatus": 1})] def get_outstanding_amount(self, gle, report_date, dr_or_cr, return_entries, currency_precision): payment_amount, credit_note_amount = 0.0, 0.0 reverse_dr_or_cr = "credit" if dr_or_cr=="debit" else "debit" - + for e in self.get_gl_entries_for(gle.party, gle.party_type, gle.voucher_type, gle.voucher_no): if getdate(e.posting_date) <= report_date and e.name!=gle.name: amount = flt(e.get(reverse_dr_or_cr)) - flt(e.get(dr_or_cr)) @@ -195,11 +195,11 @@ class ReceivablePayableReport(object): payment_amount += amount else: credit_note_amount += amount - + outstanding_amount = flt((flt(gle.get(dr_or_cr)) - flt(gle.get(reverse_dr_or_cr)) \ - payment_amount - credit_note_amount), currency_precision) credit_note_amount = flt(credit_note_amount, currency_precision) - + return outstanding_amount, credit_note_amount def get_party_name(self, party_type, party_name): @@ -207,7 +207,7 @@ class ReceivablePayableReport(object): def get_territory(self, party_name): return self.get_party_map("Customer").get(party_name, {}).get("territory") or "" - + def get_customer_group(self, party_name): return self.get_party_map("Customer").get(party_name, {}).get("customer_group") or "" @@ -220,7 +220,7 @@ class ReceivablePayableReport(object): select_fields = "name, customer_name, territory, customer_group" elif party_type == "Supplier": select_fields = "name, supplier_name, supplier_type" - + self.party_map = dict(((r.name, r) for r in frappe.db.sql("select {0} from `tab{1}`" .format(select_fields, party_type), as_dict=True))) @@ -250,8 +250,8 @@ class ReceivablePayableReport(object): else: select_fields = "sum(debit) as debit, sum(credit) as credit" - self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party, - voucher_type, voucher_no, against_voucher_type, against_voucher, + self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party, + voucher_type, voucher_no, against_voucher_type, against_voucher, account_currency, remarks, {0} from `tabGL Entry` where docstatus < 2 and party_type=%s and (party is not null and party != '') {1} @@ -277,13 +277,13 @@ class ReceivablePayableReport(object): if party_type_field=="customer": if self.filters.get("customer_group"): - lft, rgt = frappe.db.get_value("Customer Group", + lft, rgt = frappe.db.get_value("Customer Group", self.filters.get("customer_group"), ["lft", "rgt"]) - - conditions.append("""party in (select name from tabCustomer - where exists(select name from `tabCustomer Group` where lft >= {0} and rgt <= {1} + + conditions.append("""party in (select name from tabCustomer + where exists(select name from `tabCustomer Group` where lft >= {0} and rgt <= {1} and name=tabCustomer.customer_group))""".format(lft, rgt)) - + if self.filters.get("credit_days_based_on"): conditions.append("party in (select name from tabCustomer where credit_days_based_on=%s)") values.append(self.filters.get("credit_days_based_on")) @@ -303,22 +303,22 @@ class ReceivablePayableReport(object): return self.gl_entries_map.get(party, {})\ .get(against_voucher_type, {})\ .get(against_voucher, []) - + def get_chart_data(self, columns, data): ageing_columns = columns[self.ageing_col_idx_start : self.ageing_col_idx_start+4] - + rows = [] for d in data: rows.append(d[self.ageing_col_idx_start : self.ageing_col_idx_start+4]) if rows: rows.insert(0, [[d.get("label")] for d in ageing_columns]) - + return { "data": { - 'rows': rows + 'labels': rows }, - "chart_type": 'pie' + "type": 'percentage' } def execute(filters=None): diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py index 2db4ef8a261..18b07ea5829 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -8,18 +8,18 @@ from frappe.utils import flt, cint from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) def execute(filters=None): - period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, company=filters.company) - asset = get_data(filters.company, "Asset", "Debit", period_list, + asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False, filters=filters, accumulated_values=filters.accumulated_values) - - liability = get_data(filters.company, "Liability", "Credit", period_list, + + liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False, filters=filters, accumulated_values=filters.accumulated_values) - - equity = get_data(filters.company, "Equity", "Credit", period_list, + + equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False, filters=filters, accumulated_values=filters.accumulated_values) @@ -43,17 +43,17 @@ def execute(filters=None): unclosed[period.key] = opening_balance if provisional_profit_loss: provisional_profit_loss[period.key] = provisional_profit_loss[period.key] - opening_balance - + unclosed["total"]=opening_balance data.append(unclosed) - + if provisional_profit_loss: data.append(provisional_profit_loss) if total_credit: - data.append(total_credit) + data.append(total_credit) columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, company=filters.company) - + chart = get_chart_data(filters, columns, asset, liability, equity) return columns, data, message, chart @@ -87,7 +87,7 @@ def get_provisional_profit_loss(asset, liability, equity, period_list, company): total += flt(provisional_profit_loss[period.key]) provisional_profit_loss["total"] = total - + total_row_total += flt(total_row[period.key]) total_row["total"] = total_row_total @@ -98,7 +98,7 @@ def get_provisional_profit_loss(asset, liability, equity, period_list, company): "warn_if_negative": True, "currency": currency }) - + return provisional_profit_loss, total_row def check_opening_balance(asset, liability, equity): @@ -111,17 +111,17 @@ def check_opening_balance(asset, liability, equity): opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision) if equity: opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision) - + opening_balance = flt(opening_balance, float_precision) if opening_balance: return _("Previous Financial Year is not closed"),opening_balance return None,None - + def get_chart_data(filters, columns, asset, liability, equity): - x_intervals = ['x'] + [d.get("label") for d in columns[2:]] - + labels = [d.get("label") for d in columns[2:]] + asset_data, liability_data, equity_data = [], [], [] - + for p in columns[2:]: if asset: asset_data.append(asset[-2].get(p.get("fieldname"))) @@ -129,23 +129,25 @@ def get_chart_data(filters, columns, asset, liability, equity): liability_data.append(liability[-2].get(p.get("fieldname"))) if equity: equity_data.append(equity[-2].get(p.get("fieldname"))) - - columns = [x_intervals] + + datasets = [] if asset_data: - columns.append(["Assets"] + asset_data) + datasets.append({'title':'Assets', 'values': asset_data}) if liability_data: - columns.append(["Liabilities"] + liability_data) + datasets.append({'title':'Liabilities', 'values': liability_data}) if equity_data: - columns.append(["Equity"] + equity_data) + datasets.append({'title':'Equity', 'values': equity_data}) chart = { "data": { - 'x': 'x', - 'columns': columns + 'labels': labels, + 'datasets': datasets } } if not filters.accumulated_values: - chart["chart_type"] = "bar" + chart["type"] = "bar" + else: + chart["type"] = "line" return chart \ No newline at end of file diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py index 6729d672c07..89ee63aa649 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py +++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py @@ -8,15 +8,15 @@ from frappe.utils import flt from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data) def execute(filters=None): - period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.accumulated_values, filters.company) income = get_data(filters.company, "Income", "Credit", period_list, filters = filters, - accumulated_values=filters.accumulated_values, + accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True) - + expense = get_data(filters.company, "Expense", "Debit", period_list, filters=filters, - accumulated_values=filters.accumulated_values, + accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True) net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company) @@ -61,7 +61,7 @@ def get_net_profit_loss(income, expense, period_list, company): def get_chart_data(filters, columns, income, expense, net_profit_loss): - x_intervals = ['x'] + [d.get("label") for d in columns[2:]] + labels = [d.get("label") for d in columns[2:]] income_data, expense_data, net_profit = [], [], [] @@ -73,27 +73,24 @@ def get_chart_data(filters, columns, income, expense, net_profit_loss): if net_profit_loss: net_profit.append(net_profit_loss.get(p.get("fieldname"))) - columns = [x_intervals] + datasets = [] if income_data: - columns.append(["Income"] + income_data) + datasets.append({'title': 'Income', 'values': income_data}) if expense_data: - columns.append(["Expense"] + expense_data) + datasets.append({'title': 'Expense', 'values': expense_data}) if net_profit: - columns.append(["Net Profit/Loss"] + net_profit) + datasets.append({'title': 'Net Profit/Loss', 'values': net_profit}) chart = { "data": { - 'x': 'x', - 'columns': columns, - 'colors': { - 'Income': '#5E64FF', - 'Expense': '#b8c2cc', - 'Net Profit/Loss': '#ff5858' - } + 'labels': labels, + 'datasets': datasets } } if not filters.accumulated_values: - chart["chart_type"] = "bar" + chart["type"] = "bar" + else: + chart["type"] = "line" return chart \ No newline at end of file diff --git a/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js b/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js index d9c4c8b7fc8..cdfdad1eea2 100644 --- a/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js +++ b/erpnext/crm/report/minutes_to_first_response_for_opportunity/minutes_to_first_response_for_opportunity.js @@ -21,23 +21,13 @@ frappe.query_reports["Minutes to First Response for Opportunity"] = { get_chart_data: function (columns, result) { return { data: { - x: 'Date', - columns: [ - ['Date'].concat($.map(result, function (d) { return d[0]; })), - ['Mins to first response'].concat($.map(result, function (d) { return d[1]; })) - ] - // rows: [['Date', 'Mins to first response']].concat(result) + labels: result.map(d => d[0]), + datasets: [{ + title: 'Mins to first response', + values: result.map(d => d[1]) + }] }, - axis: { - x: { - type: 'timeseries', - tick: { - format: frappe.ui.py_date_format - } - } - }, - chart_type: 'line', - + type: 'line', } } } diff --git a/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py b/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py index 63e5f3c0a43..93ea11c6404 100644 --- a/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py +++ b/erpnext/hr/report/vehicle_expenses/vehicle_expenses.py @@ -29,26 +29,26 @@ def get_columns(): def get_log_data(filters): fy = frappe.db.get_value('Fiscal Year', filters.get('fiscal_year'), ['year_start_date', 'year_end_date'], as_dict=True) - data = frappe.db.sql("""select + data = frappe.db.sql("""select vhcl.license_plate as "License", vhcl.make as "Make", vhcl.model as "Model", - vhcl.location as "Location", log.name as "Log", log.odometer as "Odometer", + vhcl.location as "Location", log.name as "Log", log.odometer as "Odometer", log.date as "Date", log.fuel_qty as "Fuel Qty", log.price as "Fuel Price" - from + from `tabVehicle` vhcl,`tabVehicle Log` log - where + where vhcl.license_plate = log.license_plate and log.docstatus = 1 and date between %s and %s order by date""" ,(fy.year_start_date, fy.year_end_date), as_dict=1) dl=list(data) for row in dl: row["Service Expense"]= get_service_expense(row["Log"]) return dl - + def get_service_expense(logname): - expense_amount = frappe.db.sql("""select sum(expense_amount) - from `tabVehicle Log` log,`tabVehicle Service` ser + expense_amount = frappe.db.sql("""select sum(expense_amount) + from `tabVehicle Log` log,`tabVehicle Service` ser where ser.parent=log.name and log.name=%s""",logname) return flt(expense_amount[0][0]) if expense_amount else 0 - + def get_chart_data(data,period_list): fuel_exp_data,service_exp_data,fueldata,servicedata = [],[],[],[] service_exp_data = [] @@ -63,19 +63,25 @@ def get_chart_data(data,period_list): fueldata.append([period.key,total_fuel_exp]) servicedata.append([period.key,total_ser_exp]) - x_intervals = ['x'] + [period.key for period in period_list] + labels = [period.key for period in period_list] fuel_exp_data= [row[1] for row in fueldata] service_exp_data= [row[1] for row in servicedata] - columns = [x_intervals] + datasets = [] if fuel_exp_data: - columns.append(["Fuel Expenses"]+ fuel_exp_data) + datasets.append({ + 'title': 'Fuel Expenses', + 'values': fuel_exp_data + }) if service_exp_data: - columns.append(["Service Expenses"]+ service_exp_data) + datasets.append({ + 'title': 'Service Expenses', + 'values': service_exp_data + }) chart = { "data": { - 'x': 'x', - 'columns': columns + 'labels': labels, + 'datasets': datasets } } - chart["chart_type"] = "line" + chart["type"] = "line" return chart \ No newline at end of file diff --git a/erpnext/manufacturing/page/production_analytics/production_analytics.js b/erpnext/manufacturing/page/production_analytics/production_analytics.js index 1fb1ef22ebe..39168b7206e 100644 --- a/erpnext/manufacturing/page/production_analytics/production_analytics.js +++ b/erpnext/manufacturing/page/production_analytics/production_analytics.js @@ -53,7 +53,7 @@ erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({ this.show_zero_check() this.setup_chart_check(); - + }, init_filter_values: function() { this._super(); @@ -61,12 +61,13 @@ erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({ }, setup_chart: function() { var me = this; - + var chart_data = this.get_chart_data ? this.get_chart_data() : null; - this.chart = new frappe.ui.Chart({ - wrapper: this.chart_area, - data: chart_data + this.chart = new frappe.chart.FrappeChart({ + parent: ".chart", + data: chart_data, + type: 'line' }); }, set_default_values: function() { @@ -95,7 +96,7 @@ erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({ var pending = {name:"Pending", "id":"pending-pos", checked:true}; var completed = {name:"Completed", "id":"completed-pos", - checked:true}; + checked:true}; $.each(frappe.report_dump.data["Production Order"], function(i, d) { var dateobj = frappe.datetime.str_to_obj(d.creation); @@ -109,10 +110,10 @@ erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({ var planned_start_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.planned_start_date)); var aend_date = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.actual_end_date)); var modified = frappe.datetime.user_to_obj(frappe.datetime.str_to_user(d.modified)); - + if (dateobj <= start_period || dateobj <= end_period) { all_open_orders[col.field] = flt(all_open_orders[col.field]) + 1; - + if(d.status=="Completed") { if(aend_date < start_period || modified < start_period) { completed[col.field] = flt(completed[col.field]) + 1; @@ -140,7 +141,7 @@ erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({ }else{ not_started[col.field] = flt(not_started[col.field]) + 1; } - } + } } } }); @@ -151,6 +152,6 @@ erpnext.ProductionAnalytics = frappe.views.GridReportWithPlot.extend({ this.chart_area.toggle(false); } this.data = [all_open_orders, not_started, overdue, pending, completed]; - + } }); diff --git a/erpnext/schools/report/course_wise_assessment_report/course_wise_assessment_report.py b/erpnext/schools/report/course_wise_assessment_report/course_wise_assessment_report.py index 2b407c7987c..9bdf621a611 100644 --- a/erpnext/schools/report/course_wise_assessment_report/course_wise_assessment_report.py +++ b/erpnext/schools/report/course_wise_assessment_report/course_wise_assessment_report.py @@ -172,20 +172,19 @@ def get_column(assessment_criteria, total_maximum_score): def get_chart_data(grades, assessment_criteria_list, kounter): grades = sorted(grades) - chart_data = [] - chart_data.append(["x"] + assessment_criteria_list) + datasets = [] for grade in grades: - tmp = [grade] + tmp = [] for ac in assessment_criteria_list: if grade in kounter[ac]: tmp.append(kounter[ac][grade]) else: tmp.append(0) - chart_data.append(tmp) + datasets.append(tmp) return { "data": { - "x": "x", - "columns": chart_data + "labels": assessment_criteria_list, + "datasets": datasets }, - "chart_type": 'bar', + "type": 'bar', } diff --git a/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js index e84b13ced5a..4cf07fa2987 100644 --- a/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js +++ b/erpnext/support/report/minutes_to_first_response_for_issues/minutes_to_first_response_for_issues.js @@ -18,23 +18,13 @@ frappe.query_reports["Minutes to First Response for Issues"] = { get_chart_data: function(columns, result) { return { data: { - x: 'Date', - columns: [ - ['Date'].concat($.map(result, function(d) { return d[0]; })), - ['Mins to first response'].concat($.map(result, function(d) { return d[1]; })) - ] - // rows: [['Date', 'Mins to first response']].concat(result) + labels: result.map(d => d[0]), + datasets: [{ + title: 'Mins to first response', + values: result.map(d => d[1]) + }] }, - axis: { - x: { - type: 'timeseries', - tick: { - format: frappe.ui.py_date_format - } - } - }, - chart_type: 'line', - + type: 'line', } } } diff --git a/erpnext/support/report/support_hour_distribution/support_hour_distribution.py b/erpnext/support/report/support_hour_distribution/support_hour_distribution.py index e96b7b21044..905ea6a5d92 100644 --- a/erpnext/support/report/support_hour_distribution/support_hour_distribution.py +++ b/erpnext/support/report/support_hour_distribution/support_hour_distribution.py @@ -24,7 +24,7 @@ def execute(filters=None): columns = get_columns() data, timeslot_wise_count = get_data(filters) - chart = get_chartdata(timeslot_wise_count) + chart = get_chart_data(timeslot_wise_count) return columns, data, None, chart def get_data(filters): @@ -75,23 +75,21 @@ def get_columns(): return columns -def get_chartdata(timeslot_wise_count): - x_interval = ['x'] - total_count = ['Total'] +def get_chart_data(timeslot_wise_count): + total_count = [] timeslots = ['12AM - 3AM', '3AM - 6AM', '6AM - 9AM', '9AM - 12PM', '12PM - 3PM', '3PM - 6PM', '6PM - 9PM', '9PM - 12AM'] - x_interval.extend(timeslots) - columns = [x_interval] + datasets = [] for data in timeslots: total_count.append(timeslot_wise_count.get(data, 0)) - columns.append(total_count) + datasets.append({'values': total_count}) chart = { "data": { - 'x': 'x', - 'columns': columns + 'labels': timeslots, + 'datasets': datasets } } - chart["chart_type"] = "line" + chart["type"] = "line" return chart