diff --git a/src/components/area.js b/src/components/area.js index 0cd3bde..ffeedaf 100644 --- a/src/components/area.js +++ b/src/components/area.js @@ -154,7 +154,7 @@ function(array, config, obj, fn, string, d3util, mixins, dataFns) { dataConfig = area.data(); // Return early if there's no data. - if (!dataConfig || !dataConfig.data) { + if (!dataConfig || !dataConfig.data || !dataConfig.data.length) { return area; } diff --git a/test/unit/components/area.spec.js b/test/unit/components/area.spec.js index 15d1578..4fabd24 100644 --- a/test/unit/components/area.spec.js +++ b/test/unit/components/area.spec.js @@ -312,6 +312,23 @@ function(area, dc) { expect(exceptionThrown).toBe(false); }); + it('dies gracefully if data is set but empty', function() { + var exceptionThrown = false; + dataCollection = dc.create(); + dataCollection.add({ + id: 'foo', + data: [] + }); + testArea = area(); + testArea.data(dataCollection); + try { + testArea.render(selection); + } catch (e) { + exceptionThrown = true; + } + expect(exceptionThrown).toBe(false); + }); + }); describe('root()', function() {