area chart should render even with single data point (#12057)

* removing constrain for at least 2 data points

* cleaning up
This commit is contained in:
Peter Pisljar 2017-06-02 15:39:36 +02:00 committed by GitHub
parent fb40168305
commit 7801483f7e
5 changed files with 1 additions and 64 deletions

View file

@ -21,7 +21,6 @@ import {
PieContainsAllZeros,
InvalidLogScaleValues,
StackedBarChartConfig,
NotEnoughData,
NoResults,
KbnError
} from 'ui/errors';
@ -49,7 +48,6 @@ describe('ui/errors', () => {
new PieContainsAllZeros(),
new InvalidLogScaleValues(),
new StackedBarChartConfig('err'),
new NotEnoughData('nodata'),
new NoResults()
];

View file

@ -262,17 +262,6 @@ export class StackedBarChartConfig extends VislibError {
}
}
/**
* error thrown when user tries to render an chart with less
* than the required number of data points
* @param {String} message - the message to provide with the error
*/
export class NotEnoughData extends VislibError {
constructor(message) {
super(message);
}
}
export class NoResults extends VislibError {
constructor() {
super('No results found');

View file

@ -3,8 +3,6 @@ import expect from 'expect.js';
import ngMock from 'ng_mock';
import _ from 'lodash';
import woahLotsOfVariables from 'fixtures/vislib/mock_data/date_histogram/_series';
import notQuiteEnoughVariables from 'fixtures/vislib/mock_data/not_enough_data/_one_point';
import $ from 'jquery';
import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
import 'ui/persisted_state';
@ -42,42 +40,6 @@ _.forOwn(dataTypesArray, function (dataType, dataTypeName) {
vis.destroy();
});
describe('checkIfEnoughData method throws an error when not enough data', function () {
beforeEach(function () {
ngMock.inject(function () {
vis.render(notQuiteEnoughVariables, persistedState);
});
});
it('should throw a Not Enough Data Error', function () {
vis.handler.charts.forEach(function (chart) {
chart.series.forEach(function (series) {
expect(function () {
series.checkIfEnoughData();
}).to.throwError();
});
});
});
});
describe('checkIfEnoughData method should not throw an error when enough data', function () {
beforeEach(function () {
ngMock.inject(function () {
vis.render(woahLotsOfVariables, persistedState);
});
});
it('should not throw a Not Enough Data Error', function () {
vis.handler.charts.forEach(function (chart) {
chart.series.forEach(function (series) {
expect(function () {
series.checkIfEnoughData();
}).to.not.throwError();
});
});
});
});
describe('stackData method', function () {
let stackedData;
let isStacked;

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import { InvalidLogScaleValues, NotEnoughData } from 'ui/errors';
import { InvalidLogScaleValues } from 'ui/errors';
export function VislibVisualizationsPointSeriesProvider() {
@ -88,17 +88,6 @@ export function VislibVisualizationsPointSeriesProvider() {
const click = events.addClickEvent();
return element.call(click);
}
checkIfEnoughData() {
const message = 'Area charts require more than one data point. Try adding ' +
'an X-Axis Aggregation';
const notEnoughData = this.chartData.values.length < 2;
if (notEnoughData) {
throw new NotEnoughData(message);
}
}
}
return PointSeries;

View file

@ -58,7 +58,6 @@ export function VislibVisualizationsAreaChartProvider(Private) {
};
}
this.checkIfEnoughData();
}
addPath(svg, data) {