Permalink
Browse files

Need to pass through settings to handle_orders_by_day in dashboard.js

Due to JavaScript variable scoping, the settings variable is only available within the function for document.ready.

By passing it in using a function in this manner, it Fixes the broken graph interface.

Fixes #695.
  • Loading branch information...
1 parent 9e9ec44 commit 85b0adce03b45188a70ddca7165e774f52c18f57 @radar radar committed Oct 12, 2011
Showing with 7 additions and 8 deletions.
  1. +7 −8 dash/app/assets/javascripts/admin/dashboard.js
@@ -21,20 +21,20 @@ function number_with_delimiter(number, delimiter, separator) {
}
}
-function handle_orders_by_day(r){
+function handle_orders_by_day(settings, r){
var new_points = eval(r);
if(new_points[0].length>0){
- orders_by_day_settings.axes.xaxis.min = new_points[0][0][0].replace(/-/g, "/");
- orders_by_day_settings.axes.xaxis.max = new_points[0][new_points[0].length -1][0].replace(/-/g, "/");
+ settings.axes.xaxis.min = new_points[0][0][0].replace(/-/g, "/");
+ settings.axes.xaxis.max = new_points[0][new_points[0].length -1][0].replace(/-/g, "/");
}
- orders_by_day_settings.axes.yaxis.label = jQuery("#orders_by_day_value :selected").val();
+ settings.axes.yaxis.label = jQuery("#orders_by_day_value :selected").val();
jQuery("#order_by_day_title").text(orders + " " + jQuery("#orders_by_day_value :selected").val() + " " + by_day + " (" + jQuery("#orders_by_day_reports :selected").text() + ")");
jQuery('#orders_by_day').empty();
- jQuery.jqplot('orders_by_day', new_points, orders_by_day_settings);
+ jQuery.jqplot('orders_by_day', new_points, settings);
}
@@ -59,7 +59,7 @@ jQuery(document).ready(function(){
axes:{
yaxis:{
label:'Order (Count)',
- labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
+ labelRenderer: jQuery.jqplot.CanvasAxisLabelRenderer,
autoscale:true,
tickOptions:{
formatString:'%d',
@@ -89,7 +89,6 @@ jQuery(document).ready(function(){
}
};
-
jQuery.jqplot('orders_by_day', orders_by_day_points, orders_by_day_settings);
jQuery("div#orders_by_day_options select").change(function(){
@@ -100,7 +99,7 @@ jQuery(document).ready(function(){
type: 'GET',
url: 'admin/overview/get_report_data',
data: ({report: 'orders_by_day', name: report, value: value, authenticity_token: AUTH_TOKEN}),
- success: handle_orders_by_day
+ success: function(r) { handle_orders_by_day(orders_by_day_settings, r) }
});
jQuery.ajax({

0 comments on commit 85b0adc

Please sign in to comment.