Skip to content

Commit

Permalink
Merge pull request #17 from w33ble/fix/3959
Browse files Browse the repository at this point in the history
Fix point series stacking
  • Loading branch information
stormpython committed Jun 5, 2015
2 parents 398a805 + 43c6e30 commit f035abe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ define(function (require) {
}

PointSeriesChart.prototype._stackMixedValues = function (stackCount) {
var currentStackOffsets = [];
var currentStackOffsets = [0, 0];
var currentStackIndex = 0;

return function (d, y0, y) {
if (currentStackIndex++ % stackCount === 0) {
var firstStack = currentStackIndex % stackCount === 0;
var lastStack = ++currentStackIndex === stackCount;

// if the current stack index has reached the final stack, reset the stack count
if (firstStack) {
currentStackOffsets = [0, 0];
}

if (lastStack) currentStackIndex = 0;

if (y >= 0) {
d.y0 = currentStackOffsets[1];
d.y = y;
currentStackOffsets[1] += y;
} else {
d.y0 = currentStackOffsets[0] + y;
d.y = -y;
d.y0 = currentStackOffsets[0];
currentStackOffsets[0] += y;
}
};
Expand Down
42 changes: 16 additions & 26 deletions test/unit/specs/vislib/visualizations/column_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,31 @@ define(function (require) {
var termsColumns = require('vislib_fixtures/mock_data/terms/_columns');
//var histogramRows = require('vislib_fixtures/mock_data/histogram/_rows');
var stackedSeries = require('vislib_fixtures/mock_data/date_histogram/_stacked_series');
var dataArray = [
series,
seriesPosNeg,
seriesNeg,
termsColumns,
//histogramRows,
stackedSeries
];
var names = [
'series',
'series with positive and negative values',
'series with negative values',
'terms columns',
//'histogram rows',
'stackedSeries'
];
var modes = [
'stacked',
'stacked',
'stacked',
'grouped',
//'percentage',
'stacked'

// tuple, with the format [description, mode, data]
var dataTypesArray = [
['series', 'stacked', series],
['series with positive and negative values', 'stacked', seriesPosNeg],
['series with negative values', 'stacked', seriesNeg],
['terms columns', 'grouped', termsColumns],
// ['histogram rows', 'percentage', histogramRows],
['stackedSeries', 'stacked', stackedSeries],
];

angular.module('ColumnChartFactory', ['kibana']);

dataArray.forEach(function (data, i) {
describe('VisLib Column Chart Test Suite for ' + names[i] + ' Data', function () {
dataTypesArray.forEach(function (dataType, i) {
var name = dataType[0];
var mode = dataType[1];
var data = dataType[2];

describe('VisLib Column Chart Test Suite for ' + name + ' Data', function () {
var vis;
var visLibParams = {
type: 'histogram',
addLegend: true,
addTooltip: true,
mode: modes[i]
mode: mode
};

beforeEach(function () {
Expand Down

0 comments on commit f035abe

Please sign in to comment.