From dc972cd7eab7966a339bc92f97bbad2fe9d53da9 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Fri, 27 Jun 2014 10:42:29 +0200 Subject: [PATCH] If data is missing in one of the columns, newer versions of C3 will break in an unexpected place, which makes it hard to debug. This patch catches the error early so as to ease debugging. --- c3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/c3.js b/c3.js index dca10f5..172dc7e 100644 --- a/c3.js +++ b/c3.js @@ -1552,6 +1552,8 @@ for (i = 1; i < rows.length; i++) { new_row = {}; for (j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) + throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); new_row[keys[j]] = rows[i][j]; } new_rows.push(new_row); @@ -1566,6 +1568,8 @@ if (isUndefined(new_rows[j - 1])) { new_rows[j - 1] = {}; } + if (isUndefined(columns[i][j])) + throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); new_rows[j - 1][key] = columns[i][j]; } }