Skip to content

Commit

Permalink
Closes #135.
Browse files Browse the repository at this point in the history
Handles when chart cannot be rendered vertically due to too many charts vertically
  • Loading branch information
stormpython committed Jun 20, 2014
1 parent e9a66b1 commit 6f6d72c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/kibana/components/vislib/modules/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,14 @@ define(function (require) {
throw new Error('width: ' + width + '; height:' + height);
}

if (height <= margin.top) {
throw new Error('The container is too small for this chart.');
}

/* Error Handler that prevents a chart from being rendered when
there are too many data points for the width of the container. */
if (width / dataLength <= 4) {
throw new Error('chart too small');
throw new Error('The container is too small for this chart.');
}

// adds the label value to each data point
Expand Down Expand Up @@ -900,6 +904,9 @@ define(function (require) {

return svg;
} catch (error) {
if (error.message === 'The container is too small for this chart.') {
chart.error(error.message);
}
console.error('chart.createHistogram: ' + error);
}
};
Expand Down Expand Up @@ -973,7 +980,7 @@ define(function (require) {
return chart;
};

chart.error = function () {
chart.error = function (message) {
// Removes the legend container
d3.select(elem)
.selectAll('*')
Expand All @@ -995,7 +1002,7 @@ define(function (require) {
.height() / 3 + 'px';
})
.style('line-height', '18px')
.text('The container is too small for this chart.');
.text(message);
return chart;
};

Expand Down

0 comments on commit 6f6d72c

Please sign in to comment.