Skip to content

Commit 6f6d72c

Browse files
committed
Closes #135.
Handles when chart cannot be rendered vertically due to too many charts vertically
1 parent e9a66b1 commit 6f6d72c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/kibana/components/vislib/modules/histogram.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,14 @@ define(function (require) {
433433
throw new Error('width: ' + width + '; height:' + height);
434434
}
435435

436+
if (height <= margin.top) {
437+
throw new Error('The container is too small for this chart.');
438+
}
439+
436440
/* Error Handler that prevents a chart from being rendered when
437441
there are too many data points for the width of the container. */
438442
if (width / dataLength <= 4) {
439-
throw new Error('chart too small');
443+
throw new Error('The container is too small for this chart.');
440444
}
441445

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

901905
return svg;
902906
} catch (error) {
907+
if (error.message === 'The container is too small for this chart.') {
908+
chart.error(error.message);
909+
}
903910
console.error('chart.createHistogram: ' + error);
904911
}
905912
};
@@ -973,7 +980,7 @@ define(function (require) {
973980
return chart;
974981
};
975982

976-
chart.error = function () {
983+
chart.error = function (message) {
977984
// Removes the legend container
978985
d3.select(elem)
979986
.selectAll('*')
@@ -995,7 +1002,7 @@ define(function (require) {
9951002
.height() / 3 + 'px';
9961003
})
9971004
.style('line-height', '18px')
998-
.text('The container is too small for this chart.');
1005+
.text(message);
9991006
return chart;
10001007
};
10011008

0 commit comments

Comments
 (0)