From c2dd8800b0f280d12a5ed3c7745add72cc19a4e7 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Tue, 18 Dec 2012 15:59:44 +0200 Subject: [PATCH] Dynamic range part 1. --- .../js/src/graphical_slider_tool/graph.js | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js index 05ff88e0f0..6dbac2aea8 100644 --- a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js +++ b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js @@ -27,8 +27,8 @@ define('Graph', ['logme'], function (logme) { } // Configure some settings for the graph. - setGraphAxes(); setGraphXRange(); + setGraphAxes(); // Get the user defined functions. If there aren't any, don't do // anything else. @@ -135,15 +135,29 @@ define('Graph', ['logme'], function (logme) { function setGraphXRange() { var xRangeStr, xRangeBlobs, tempNum; - xrange = { - 'start': 0, - 'end': 10, - 'step': 0.1 - }; + xrange = {}; + + if ($.isPlainObject(config.plot.xrange) === false) { + logme('ERROR: Expected config.plot.xrange to be an object. It is not.'); + logme('config.plot.xrange = ', config.plot.xrange); + + return false; + } + + if (typeof config.plot.xrange.min !== 'string') { + logme('ERROR: Expected config.plot.xrange.min to be a string. It is not.'); + logme('config.plot.xrange.min = ', config.plot.xrange.min); + + return false; + } + + if (typeof config.plot.xrange.max !== 'string') { + logme('ERROR: Expected config.plot.xrange.max to be a string. It is not.'); + logme('config.plot.xrange.max = ', config.plot.xrange.max); + + return false; + } - // The 'xrange' is a string containing two floating point numbers - // separated by a comma. The first number is the starting - // x-coordinate , the second number is the ending x-coordinate if (typeof config.plot['xrange'] === 'string') { xRangeStr = config.plot['xrange']; xRangeBlobs = xRangeStr.split(','); @@ -193,6 +207,8 @@ define('Graph', ['logme'], function (logme) { } else { logme('ERROR: num_points is not a string.'); } + + return true; } function createFunctions() {