This commit is contained in:
parent
b528e66dd5
commit
3c3e63f975
6 changed files with 27 additions and 27 deletions
|
@ -18,7 +18,6 @@ import {
|
||||||
setDataActions,
|
setDataActions,
|
||||||
setFormatService,
|
setFormatService,
|
||||||
setThemeService,
|
setThemeService,
|
||||||
setTimefilter,
|
|
||||||
setUISettings,
|
setUISettings,
|
||||||
setDocLinks,
|
setDocLinks,
|
||||||
setPalettesService,
|
setPalettesService,
|
||||||
|
@ -80,7 +79,6 @@ export class VisTypeXyPlugin
|
||||||
public start(core: CoreStart, { data }: VisTypeXyPluginStartDependencies) {
|
public start(core: CoreStart, { data }: VisTypeXyPluginStartDependencies) {
|
||||||
setFormatService(data.fieldFormats);
|
setFormatService(data.fieldFormats);
|
||||||
setDataActions(data.actions);
|
setDataActions(data.actions);
|
||||||
setTimefilter(data.query.timefilter.timefilter);
|
|
||||||
setDocLinks(core.docLinks);
|
setDocLinks(core.docLinks);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -24,10 +24,6 @@ export const [getFormatService, setFormatService] = createGetterSetter<
|
||||||
DataPublicPluginStart['fieldFormats']
|
DataPublicPluginStart['fieldFormats']
|
||||||
>('xy data.fieldFormats');
|
>('xy data.fieldFormats');
|
||||||
|
|
||||||
export const [getTimefilter, setTimefilter] = createGetterSetter<
|
|
||||||
DataPublicPluginStart['query']['timefilter']['timefilter']
|
|
||||||
>('xy data.query.timefilter.timefilter');
|
|
||||||
|
|
||||||
export const [getThemeService, setThemeService] = createGetterSetter<ChartsPluginSetup['theme']>(
|
export const [getThemeService, setThemeService] = createGetterSetter<ChartsPluginSetup['theme']>(
|
||||||
'xy charts.theme'
|
'xy charts.theme'
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { DateHistogramParams, Dimensions, HistogramParams, VisParams } from './t
|
||||||
import { visName, VisTypeXyExpressionFunctionDefinition } from './xy_vis_fn';
|
import { visName, VisTypeXyExpressionFunctionDefinition } from './xy_vis_fn';
|
||||||
import { XyVisType } from '../common';
|
import { XyVisType } from '../common';
|
||||||
import { getEsaggsFn } from './to_ast_esaggs';
|
import { getEsaggsFn } from './to_ast_esaggs';
|
||||||
|
import { TimeRangeBounds } from '../../data/common';
|
||||||
|
|
||||||
export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params) => {
|
export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params) => {
|
||||||
const schemas = getVisSchemas(vis, params);
|
const schemas = getVisSchemas(vis, params);
|
||||||
|
@ -42,6 +43,14 @@ export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params
|
||||||
.duration(esValue, esUnit)
|
.duration(esValue, esUnit)
|
||||||
.asMilliseconds();
|
.asMilliseconds();
|
||||||
(dimensions.x.params as DateHistogramParams).format = xAgg.buckets.getScaledDateFormat();
|
(dimensions.x.params as DateHistogramParams).format = xAgg.buckets.getScaledDateFormat();
|
||||||
|
const bounds = xAgg.buckets.getBounds() as TimeRangeBounds | undefined;
|
||||||
|
|
||||||
|
if (bounds && bounds?.min && bounds?.max) {
|
||||||
|
(dimensions.x.params as DateHistogramParams).bounds = {
|
||||||
|
min: bounds.min.valueOf(),
|
||||||
|
max: bounds.max.valueOf(),
|
||||||
|
};
|
||||||
|
}
|
||||||
} else if (xAgg.type.name === BUCKET_TYPES.HISTOGRAM) {
|
} else if (xAgg.type.name === BUCKET_TYPES.HISTOGRAM) {
|
||||||
const intervalParam = xAgg.type.paramByName('interval');
|
const intervalParam = xAgg.type.paramByName('interval');
|
||||||
const output = { params: {} as any };
|
const output = { params: {} as any };
|
||||||
|
|
|
@ -14,22 +14,20 @@ import { DomainRange } from '@elastic/charts';
|
||||||
import { getAdjustedInterval } from '../../../charts/public';
|
import { getAdjustedInterval } from '../../../charts/public';
|
||||||
import { Datatable } from '../../../expressions/public';
|
import { Datatable } from '../../../expressions/public';
|
||||||
|
|
||||||
import { getTimefilter } from '../services';
|
|
||||||
import { Aspect, DateHistogramParams, HistogramParams } from '../types';
|
import { Aspect, DateHistogramParams, HistogramParams } from '../types';
|
||||||
|
|
||||||
export const getXDomain = (params: Aspect['params']): DomainRange => {
|
export const getXDomain = (params: Aspect['params']): DomainRange => {
|
||||||
const minInterval = (params as DateHistogramParams | HistogramParams)?.interval ?? undefined;
|
const minInterval = (params as DateHistogramParams | HistogramParams)?.interval ?? undefined;
|
||||||
|
const bounds = (params as DateHistogramParams).date
|
||||||
|
? (params as DateHistogramParams).bounds
|
||||||
|
: null;
|
||||||
|
|
||||||
if ((params as DateHistogramParams).date) {
|
if (bounds) {
|
||||||
const bounds = getTimefilter().getActiveBounds();
|
return {
|
||||||
|
min: bounds.min as number,
|
||||||
if (bounds) {
|
max: bounds.max as number,
|
||||||
return {
|
minInterval,
|
||||||
min: bounds.min ? bounds.min.valueOf() : undefined,
|
};
|
||||||
max: bounds.max ? bounds.max.valueOf() : undefined,
|
|
||||||
minInterval,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -96,14 +96,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
it('should show correct chart', async function () {
|
it('should show correct chart', async function () {
|
||||||
const xAxisLabels = await PageObjects.visChart.getExpectedValue(
|
const xAxisLabels = await PageObjects.visChart.getExpectedValue(
|
||||||
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00', '2015-09-23 00:00'],
|
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00', '2015-09-23 00:00'],
|
||||||
[
|
['2015-09-19 12:00', '2015-09-20 12:00', '2015-09-21 12:00', '2015-09-22 12:00']
|
||||||
'2015-09-20 00:00',
|
|
||||||
'2015-09-20 12:00',
|
|
||||||
'2015-09-21 00:00',
|
|
||||||
'2015-09-21 12:00',
|
|
||||||
'2015-09-22 00:00',
|
|
||||||
'2015-09-22 12:00',
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
const yAxisLabels = await PageObjects.visChart.getExpectedValue(
|
const yAxisLabels = await PageObjects.visChart.getExpectedValue(
|
||||||
['0', '200', '400', '600', '800', '1,000', '1,200', '1,400', '1,600'],
|
['0', '200', '400', '600', '800', '1,000', '1,200', '1,400', '1,600'],
|
||||||
|
|
|
@ -269,7 +269,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
it('should show round labels in default timezone', async function () {
|
it('should show round labels in default timezone', async function () {
|
||||||
const expectedLabels = await PageObjects.visChart.getExpectedValue(
|
const expectedLabels = await PageObjects.visChart.getExpectedValue(
|
||||||
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00'],
|
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00'],
|
||||||
['2015-09-20 00:00', '2015-09-20 18:00', '2015-09-21 12:00', '2015-09-22 06:00']
|
['2015-09-19 12:00', '2015-09-20 12:00', '2015-09-21 12:00', '2015-09-22 12:00']
|
||||||
);
|
);
|
||||||
await initChart();
|
await initChart();
|
||||||
const labels = await PageObjects.visChart.getXAxisLabels();
|
const labels = await PageObjects.visChart.getXAxisLabels();
|
||||||
|
@ -279,7 +279,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
it('should show round labels in different timezone', async function () {
|
it('should show round labels in different timezone', async function () {
|
||||||
const expectedLabels = await PageObjects.visChart.getExpectedValue(
|
const expectedLabels = await PageObjects.visChart.getExpectedValue(
|
||||||
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00'],
|
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00'],
|
||||||
['2015-09-19 18:00', '2015-09-20 12:00', '2015-09-21 06:00', '2015-09-22 00:00']
|
[
|
||||||
|
'2015-09-19 12:00',
|
||||||
|
'2015-09-20 06:00',
|
||||||
|
'2015-09-21 00:00',
|
||||||
|
'2015-09-21 18:00',
|
||||||
|
'2015-09-22 12:00',
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'America/Phoenix' });
|
await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'America/Phoenix' });
|
||||||
|
|
Loading…
Reference in a new issue