mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
finally fixing issue with empty array
This commit is contained in:
parent
3cca43fc34
commit
be1ca75a8d
2 changed files with 28 additions and 0 deletions
|
@ -15,6 +15,29 @@ define(function (require) {
|
|||
PointSeriesChart.Super.apply(this, arguments);
|
||||
}
|
||||
|
||||
PointSeriesChart.prototype._stackMixedValues = function (stackCount) {
|
||||
var currentStackOffsets = [];
|
||||
var currentStackIndex = 0;
|
||||
|
||||
return function (d, y0, y) {
|
||||
if (currentStackIndex++ % stackCount === 0) {
|
||||
|
||||
// if the current stack index has reached the final stack, reset the stack count
|
||||
currentStackOffsets = [0, 0];
|
||||
}
|
||||
|
||||
if (y >= 0) {
|
||||
d.y0 = currentStackOffsets[1];
|
||||
d.y = y;
|
||||
currentStackOffsets[1] += y;
|
||||
} else {
|
||||
d.y0 = currentStackOffsets[0] + y;
|
||||
d.y = -y;
|
||||
currentStackOffsets[0] += y;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Stacks chart data values
|
||||
*
|
||||
|
@ -24,8 +47,11 @@ define(function (require) {
|
|||
*/
|
||||
PointSeriesChart.prototype.stackData = function (data) {
|
||||
var self = this;
|
||||
var isHistogram = (this._attr.type === 'histogram' && this._attr.mode === 'stacked');
|
||||
var stack = this._attr.stack;
|
||||
|
||||
if (isHistogram) stack.out(self._stackMixedValues(data.series.length));
|
||||
|
||||
return stack(data.series.map(function (d) {
|
||||
var label = d.label;
|
||||
return d.values.map(function (e, i) {
|
||||
|
|
|
@ -4,6 +4,8 @@ define(function (require) {
|
|||
var $ = require('jquery');
|
||||
var moment = require('moment');
|
||||
|
||||
var DataClass = Private(require('components/vislib/lib/data'));
|
||||
|
||||
var PointSeriesChart = Private(require('components/vislib/visualizations/_point_series_chart'));
|
||||
var TimeMarker = Private(require('components/vislib/visualizations/time_marker'));
|
||||
var errors = require('errors');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue