diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js
index 9e4d19e..f3452e8 100644
--- a/erpnext/accounts/page/financial_analytics/financial_analytics.js
+++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js
@@ -3,7 +3,7 @@
 
 frappe.require("assets/erpnext/js/account_tree_grid.js");
 
-frappe.pages['financial-analytics'].onload = function(wrapper) { 
+frappe.pages['financial-analytics'].onload = function(wrapper) {
 	frappe.ui.make_app_page({
 		parent: wrapper,
 		title: __('Financial Analytics'),
@@ -11,38 +11,38 @@
 	});
 	erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
 	wrapper.appframe.add_module_icon("Accounts")
-	
+
 }
 
 erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
 	filters: [
 		{
-			fieldtype:"Select", label: __("PL or BS"), 
+			fieldtype:"Select", label: __("PL or BS"),
 			options:["Profit and Loss", "Balance Sheet"],
 			filter: function(val, item, opts, me) {
 				if(item._show) return true;
-				
+
 				// pl or bs
-				var out = (val=='Balance Sheet') ? 
+				var out = (val=='Balance Sheet') ?
 					item.report_type=='Balance Sheet' : item.report_type=='Profit and Loss';
 				if(!out) return false;
-				
+
 				return me.apply_zero_filter(val, item, opts, me);
 			}
 		},
 		{
-			fieldtype:"Select", label: __("Company"), 
+			fieldtype:"Select", label: __("Company"),
 			link:"Company", default_value: "Select Company...",
 			filter: function(val, item, opts) {
 				return item.company == val || val == opts.default_value || item._show;
 			}
 		},
-		{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year", 
+		{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year",
 			default_value: "Select Fiscal Year..."},
 		{fieldtype:"Date", label: __("From Date")},
 		{fieldtype:"Label", label: __("To")},
 		{fieldtype:"Date", label: __("To Date")},
-		{fieldtype:"Select", label: __("Range"), 
+		{fieldtype:"Select", label: __("Range"),
 			options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
 		{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
 		{fieldtype:"Button", label: __("Reset Filters")}
@@ -53,27 +53,27 @@
 				formatter: this.check_formatter},
 			{id: "name", name: __("Account"), field: "name", width: 300,
 				formatter: this.tree_formatter},
-			{id: "opening_dr", name: __("Opening (Dr)"), field: "opening_dr", 
+			{id: "opening_dr", name: __("Opening (Dr)"), field: "opening_dr",
 				hidden: true, formatter: this.currency_formatter, balance_type: "Dr"},
-			{id: "opening_cr", name: __("Opening (Cr)"), field: "opening_cr", 
+			{id: "opening_cr", name: __("Opening (Cr)"), field: "opening_cr",
 				hidden: true, formatter: this.currency_formatter, balance_type: "Cr"},
 		];
-		
-		this.make_date_range_columns(true);		
+
+		this.make_date_range_columns(true);
 		this.columns = std_columns.concat(this.columns);
 	},
 	make_date_range_columns: function() {
 		this.columns = [];
-		
+
 		var me = this;
 		var range = this.filter_inputs.range.val();
 		this.from_date = dateutil.user_to_str(this.filter_inputs.from_date.val());
 		this.to_date = dateutil.user_to_str(this.filter_inputs.to_date.val());
 		var date_diff = dateutil.get_diff(this.to_date, this.from_date);
-			
+
 		me.column_map = {};
 		me.last_date = null;
-		
+
 		var add_column = function(date, balance_type) {
 			me.columns.push({
 				id: date + "_" + balance_type.toLowerCase(),
@@ -82,29 +82,29 @@
 				date: date,
 				balance_type: balance_type,
 				formatter: me.currency_formatter,
-				width: 100
+				width: 110
 			});
 		}
-		
+
 		var build_columns = function(condition) {
 			// add column for each date range
 			for(var i=0; i <= date_diff; i++) {
 				var date = dateutil.add_days(me.from_date, i);
 				if(!condition) condition = function() { return true; }
-				
+
 				if(condition(date)) {
 					$.each(["Dr", "Cr"], function(i, v) {
 						add_column(date, v)
 					});
 				}
 				me.last_date = date;
-				
+
 				if(me.columns.length) {
 					me.column_map[date] = me.columns[me.columns.length-1];
 				}
 			}
 		}
-		
+
 		// make columns for all date ranges
 		if(range=='Daily') {
 			build_columns();
@@ -112,7 +112,7 @@
 			build_columns(function(date) {
 				if(!me.last_date) return true;
 				return !(dateutil.get_diff(date, me.from_date) % 7)
-			});		
+			});
 		} else if(range=='Monthly') {
 			build_columns(function(date) {
 				if(!me.last_date) return true;
@@ -122,7 +122,7 @@
 			build_columns(function(date) {
 				if(!me.last_date) return true;
 				return dateutil.str_to_obj(date).getDate()==1 && in_list([0,3,6,9], dateutil.str_to_obj(date).getMonth())
-			});			
+			});
 		} else if(range=='Yearly') {
 			build_columns(function(date) {
 				if(!me.last_date) return true;
@@ -130,21 +130,21 @@
 						return date==v.year_start_date ? true : null;
 					}).length;
 			});
-			
+
 		}
-		
+
 		// set label as last date of period
 		$.each(this.columns, function(i, col) {
 			col.name = me.columns[i+2]
 				? dateutil.str_to_user(dateutil.add_days(me.columns[i+2].date, -1)) + " (" + me.columns[i].balance_type + ")"
 				: dateutil.str_to_user(me.to_date) + " (" + me.columns[i].balance_type + ")";
-		});		
+		});
 	},
 	setup_filters: function() {
 		var me = this;
 		this._super();
 		this.trigger_refresh_on_change(["pl_or_bs"]);
-		
+
 		this.filter_inputs.pl_or_bs
 			.add_options($.map(frappe.report_dump.data["Cost Center"], function(v) {return v.name;}));
 
@@ -160,10 +160,10 @@
 		if(!this.cost_center_by_name) {
 			this.cost_center_by_name = this.make_name_map(frappe.report_dump.data["Cost Center"]);
 		}
-		
-		var cost_center = inList(["Balance Sheet", "Profit and Loss"], this.pl_or_bs) 
+
+		var cost_center = inList(["Balance Sheet", "Profit and Loss"], this.pl_or_bs)
 			? null : this.cost_center_by_name[this.pl_or_bs];
-		
+
 		$.each(frappe.report_dump.data['GL Entry'], function(i, gl) {
 			var filter_by_cost_center = (function() {
 				if(cost_center) {
@@ -192,13 +192,13 @@
 						me.add_balance(col.date, account, gl);
 					}
 
-				} else if(account.report_type=='Balance Sheet' 
+				} else if(account.report_type=='Balance Sheet'
 					&& (posting_date < dateutil.str_to_obj(me.from_date))) {
 						me.add_balance('opening', account, gl);
 				}
 			}
 		});
-		
+
 		// make balances as cumulative
 		if(me.pl_or_bs=='Balance Sheet') {
 			$.each(me.data, function(i, ac) {
@@ -208,18 +208,18 @@
 					$.each(me.columns, function(i, col) {
 						if(col.formatter==me.currency_formatter) {
 							if(col.balance_type=="Dr") {
-								opening = opening + flt(ac[col.date + "_dr"]) - 
+								opening = opening + flt(ac[col.date + "_dr"]) -
 									flt(ac[col.date + "_cr"]);
 								me.set_debit_or_credit(ac, col.date, opening);
 							}
 						}
-					});					
+					});
 				}
 			})
 		}
 		this.update_groups();
 		this.accounts_initialized = true;
-		
+
 		if(!me.is_default("company")) {
 			// show Net Profit / Loss
 			var net_profit = {
@@ -232,7 +232,7 @@
 				report_type: me.pl_or_bs,
 			};
 			me.item_by_name[net_profit.name] = net_profit;
-			
+
 			$.each(me.columns, function(i, col) {
 				if(col.formatter==me.currency_formatter) {
 					if(!net_profit[col.id]) net_profit[col.id] = 0;
@@ -240,12 +240,12 @@
 			});
 
 			$.each(me.data, function(i, ac) {
-				if(!ac.parent_account && me.apply_filter(ac, "company") && 
+				if(!ac.parent_account && me.apply_filter(ac, "company") &&
 						ac.report_type==me.pl_or_bs) {
 					$.each(me.columns, function(i, col) {
 						if(col.formatter==me.currency_formatter && col.balance_type=="Dr") {
-							var bal = net_profit[col.date+"_dr"] - 
-								net_profit[col.date+"_cr"] + 
+							var bal = net_profit[col.date+"_dr"] -
+								net_profit[col.date+"_cr"] +
 								ac[col.date+"_dr"] - ac[col.date+"_cr"];
 							me.set_debit_or_credit(net_profit, col.date, bal);
 						}
@@ -259,7 +259,7 @@
 		}
 	},
 	add_balance: function(field, account, gl) {
-		var bal = flt(account[field+"_dr"]) - flt(account[field+"_cr"]) + 
+		var bal = flt(account[field+"_dr"]) - flt(account[field+"_cr"]) +
 			flt(gl.debit) - flt(gl.credit);
 		this.set_debit_or_credit(account, field, bal);
 	},
@@ -274,63 +274,62 @@
 					var parent_account = me.item_by_name[parent];
 					$.each(me.columns, function(c, col) {
 						if (col.formatter == me.currency_formatter && col.balance_type=="Dr") {
-							var bal = flt(parent_account[col.date+"_dr"]) - 
-								flt(parent_account[col.date+"_cr"]) + 
-								flt(account[col.date+"_dr"]) - 
+							var bal = flt(parent_account[col.date+"_dr"]) -
+								flt(parent_account[col.date+"_cr"]) +
+								flt(account[col.date+"_dr"]) -
 								flt(account[col.date+"_cr"]);
 							me.set_debit_or_credit(parent_account, col.date, bal);
 						}
 					});
 					parent = me.parent_map[parent];
-				}				
+				}
 			}
-		});		
+		});
 	},
 	init_account: function(d) {
 		// set 0 values for all columns
 		this.reset_item_values(d);
-		
+
 		// check for default graphs
 		if(!this.accounts_initialized && !d.parent_account) {
 			d.checked = true;
 		}
-		
+
 	},
 	get_plot_data: function() {
 		var data = [];
 		var me = this;
 		var pl_or_bs = this.pl_or_bs;
 		$.each(this.data, function(i, account) {
-			
-			var show = pl_or_bs == "Balance Sheet" ? 
+
+			var show = pl_or_bs == "Balance Sheet" ?
 				account.report_type=="Balance Sheet" : account.report_type=="Profit and Loss";
 			if (show && account.checked && me.apply_filter(account, "company")) {
 				data.push({
 					label: account.name,
 					data: $.map(me.columns, function(col, idx) {
-						if(col.formatter==me.currency_formatter && !col.hidden && 
+						if(col.formatter==me.currency_formatter && !col.hidden &&
 							col.balance_type=="Dr") {
 								var bal = account[col.date+"_dr"]||account[col.date+"_cr"];
 								if (pl_or_bs != "Balance Sheet") {
-									return [[dateutil.str_to_obj(col.date).getTime(), bal], 
-										[dateutil.user_to_obj(col.date).getTime(), bal]];
+									return [[dateutil.str_to_obj(col.date).getTime(), bal],
+										[dateutil.str_to_obj(col.date).getTime(), bal]];
 								} else {
-									return [[dateutil.user_to_obj(col.date).getTime(), bal]];
-								}							
+									return [[dateutil.str_to_obj(col.date).getTime(), bal]];
+								}
 						}
 					}),
 					points: {show: true},
 					lines: {show: true, fill: true},
 				});
-				
+
 				if(pl_or_bs == "Balance Sheet") {
 					// prepend opening for balance sheet accounts
-					data[data.length-1].data = [[dateutil.str_to_obj(me.from_date).getTime(), 
+					data[data.length-1].data = [[dateutil.str_to_obj(me.from_date).getTime(),
 						account.opening]].concat(data[data.length-1].data);
 				}
 			}
 		});
-	
 		return data;
 	}
-})
\ No newline at end of file
+})
