From ec39841fb728cd05db021e960899fac4c18620a8 Mon Sep 17 00:00:00 2001 From: Michael Zinsmaier Date: Sat, 6 Dec 2014 16:59:05 +0100 Subject: [PATCH] added a check to curvedLines that tries to detect the usage of old parameters in the main options object --- curvedLines.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/curvedLines.js b/curvedLines.js index 671dff7..b242ea2 100644 --- a/curvedLines.js +++ b/curvedLines.js @@ -87,6 +87,7 @@ ____________________________________________________ * * v1.0.0 API Break marked existing implementation/options as deprecated * v1.1.0 added the new curved line calculations based on hermite splines + * v1.1.1 added a rough parameter check to make sure the new options are used */ (function($) { @@ -120,7 +121,11 @@ ____________________________________________________ var nrPoints = datapoints.points.length / datapoints.pointsize; var EPSILON = 0.005; - if (series.curvedLines.apply == true && series.originSeries === undefined && nrPoints > (1 + EPSILON)) { + //detects missplaced legacy parameters (prior v1.x.x) in the options object + //this can happen if somebody upgrades to v1.x.x without adjusting the parameters or uses old examples + var invalidLegacyOptions = hasInvalidParameters(series.curvedLines); + + if (!invalidLegacyOptions && series.curvedLines.apply == true && series.originSeries === undefined && nrPoints > (1 + EPSILON)) { if (series.lines.fill) { var pointsTop = calculateCurvePoints(datapoints, series.curvedLines, 1); @@ -452,6 +457,17 @@ ____________________________________________________ return result; } + + function hasInvalidParameters(curvedLinesOptions) { + if (typeof curvedLinesOptions.fit != 'undefined' || + typeof curvedLinesOptions.curvePointFactor != 'undefined' || + typeof curvedLinesOptions.fitPointDist != 'undefined') { + throw new Error("CurvedLines detected illegal parameters. The CurvedLines API changed with version 1.0.0 please check the options object."); + return true; + } + return false; + } + }//end init @@ -460,7 +476,7 @@ ____________________________________________________ init : init, options : options, name : 'curvedLines', - version : '1.1.0' + version : '1.1.1' }); })(jQuery);