From 12cf47d63e65ba08236df1808e0dfae5ff329250 Mon Sep 17 00:00:00 2001 From: Lauris Date: Sun, 23 Mar 2014 22:21:50 +0200 Subject: [PATCH 1/3] fix: throw errors instead of alerts --- c3.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/c3.js b/c3.js index 1ed3478..26bec6c 100644 --- a/c3.js +++ b/c3.js @@ -991,8 +991,7 @@ // check "x" is defined if timeseries if (isTimeSeries && xs.length === 0) { - window.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'); - return []; + throw new Error('data.x or data.xs must be specified when axis.x.type == "timeseries"'); } // save x for update data by load @@ -1880,8 +1879,7 @@ selectChart = d3.select(__bindto); if (selectChart.empty()) { - window.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); - return; + throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); } else { selectChart.html(""); } From 1f093dd8212624e052c5300774a1f7bcc4667bcd Mon Sep 17 00:00:00 2001 From: Lauris Date: Sun, 23 Mar 2014 22:34:10 +0200 Subject: [PATCH 2/3] fix: regex replaces everything that is not alphanum, - or _ --- c3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c3.js b/c3.js index 26bec6c..9c199ab 100644 --- a/c3.js +++ b/c3.js @@ -3198,7 +3198,7 @@ /*-- Event Handling --*/ function getTargetSelectorSuffix(targetId) { - return targetId ? '-' + targetId.replace(/\./g, '\\.') : ''; + return targetId ? '-' + targetId.replace(/([^a-zA-Z0-9-_])/g, '-') : ''; } function getTargetSelector(targetId) { return '.target' + getTargetSelectorSuffix(targetId); From 16a1e6d5d5e585862fa405ea747f622c640047ac Mon Sep 17 00:00:00 2001 From: Lauris Date: Sun, 23 Mar 2014 22:45:42 +0200 Subject: [PATCH 3/3] fix: fallback to __bindto's id attribute when it is not a string --- c3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c3.js b/c3.js index 9c199ab..8b5de13 100644 --- a/c3.js +++ b/c3.js @@ -177,7 +177,7 @@ /*-- Set Variables --*/ - var clipId = __bindto.replace('#', '') + '-clip', + var clipId = (typeof __bindto === "string" ? __bindto.replace('#', '') : __bindto.id) + '-clip', clipPath = getClipPath(clipId); var isTimeSeries = (__axis_x_type === 'timeseries'),