mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Add test for numeric interval values
This commit is contained in:
parent
5dd01dbe99
commit
8b59958a30
2 changed files with 15 additions and 2 deletions
|
@ -106,8 +106,9 @@ describe('initXAxis', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('reads the interval param from the x agg', function () {
|
||||
it('reads the date interval param from the x agg', function () {
|
||||
chart.aspects.x[0].params.interval = 'P1D';
|
||||
chart.aspects.x[0].params.date = true;
|
||||
initXAxis(chart, table);
|
||||
expect(chart)
|
||||
.to.have.property('xAxisLabel', 'label')
|
||||
|
@ -117,4 +118,15 @@ describe('initXAxis', function () {
|
|||
expect(moment.isDuration(chart.ordered.interval)).to.be(true);
|
||||
expect(chart.ordered.interval.toISOString()).to.eql('P1D');
|
||||
});
|
||||
|
||||
it('reads the numeric interval param from the x agg', function () {
|
||||
chart.aspects.x[0].params.interval = 0.5;
|
||||
initXAxis(chart, table);
|
||||
expect(chart)
|
||||
.to.have.property('xAxisLabel', 'label')
|
||||
.and.have.property('xAxisFormat', chart.aspects.x[0].format)
|
||||
.and.have.property('ordered');
|
||||
|
||||
expect(chart.ordered.interval).to.eql(0.5);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,9 +28,10 @@ export function initXAxis(chart, table) {
|
|||
: uniq(table.rows.map(r => r[accessor]));
|
||||
chart.xAxisFormat = format;
|
||||
chart.xAxisLabel = title;
|
||||
|
||||
if (params.interval) {
|
||||
chart.ordered = {
|
||||
interval: moment.duration(params.interval),
|
||||
interval: params.date ? moment.duration(params.interval) : params.interval,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue