Skip to content

Commit b5a46dd

Browse files
committed
[XY Charts] fix partial histogram endzones annotations (#93091)
1 parent df5e547 commit b5a46dd

6 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/plugins/vis_type_xy/public/plugin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
setDataActions,
1919
setFormatService,
2020
setThemeService,
21-
setTimefilter,
2221
setUISettings,
2322
setDocLinks,
2423
setPalettesService,
@@ -80,7 +79,6 @@ export class VisTypeXyPlugin
8079
public start(core: CoreStart, { data }: VisTypeXyPluginStartDependencies) {
8180
setFormatService(data.fieldFormats);
8281
setDataActions(data.actions);
83-
setTimefilter(data.query.timefilter.timefilter);
8482
setDocLinks(core.docLinks);
8583

8684
return {};

src/plugins/vis_type_xy/public/services.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ export const [getFormatService, setFormatService] = createGetterSetter<
2424
DataPublicPluginStart['fieldFormats']
2525
>('xy data.fieldFormats');
2626

27-
export const [getTimefilter, setTimefilter] = createGetterSetter<
28-
DataPublicPluginStart['query']['timefilter']['timefilter']
29-
>('xy data.query.timefilter.timefilter');
30-
3127
export const [getThemeService, setThemeService] = createGetterSetter<ChartsPluginSetup['theme']>(
3228
'xy charts.theme'
3329
);

src/plugins/vis_type_xy/public/to_ast.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { DateHistogramParams, Dimensions, HistogramParams, VisParams } from './t
1616
import { visName, VisTypeXyExpressionFunctionDefinition } from './xy_vis_fn';
1717
import { XyVisType } from '../common';
1818
import { getEsaggsFn } from './to_ast_esaggs';
19+
import { TimeRangeBounds } from '../../data/common';
1920

2021
export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params) => {
2122
const schemas = getVisSchemas(vis, params);
@@ -42,6 +43,14 @@ export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params
4243
.duration(esValue, esUnit)
4344
.asMilliseconds();
4445
(dimensions.x.params as DateHistogramParams).format = xAgg.buckets.getScaledDateFormat();
46+
const bounds = xAgg.buckets.getBounds() as TimeRangeBounds | undefined;
47+
48+
if (bounds && bounds?.min && bounds?.max) {
49+
(dimensions.x.params as DateHistogramParams).bounds = {
50+
min: bounds.min.valueOf(),
51+
max: bounds.max.valueOf(),
52+
};
53+
}
4554
} else if (xAgg.type.name === BUCKET_TYPES.HISTOGRAM) {
4655
const intervalParam = xAgg.type.paramByName('interval');
4756
const output = { params: {} as any };

src/plugins/vis_type_xy/public/utils/domain.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,20 @@ import { DomainRange } from '@elastic/charts';
1414
import { getAdjustedInterval } from '../../../charts/public';
1515
import { Datatable } from '../../../expressions/public';
1616

17-
import { getTimefilter } from '../services';
1817
import { Aspect, DateHistogramParams, HistogramParams } from '../types';
1918

2019
export const getXDomain = (params: Aspect['params']): DomainRange => {
2120
const minInterval = (params as DateHistogramParams | HistogramParams)?.interval ?? undefined;
21+
const bounds = (params as DateHistogramParams).date
22+
? (params as DateHistogramParams).bounds
23+
: null;
2224

23-
if ((params as DateHistogramParams).date) {
24-
const bounds = getTimefilter().getActiveBounds();
25-
26-
if (bounds) {
27-
return {
28-
min: bounds.min ? bounds.min.valueOf() : undefined,
29-
max: bounds.max ? bounds.max.valueOf() : undefined,
30-
minInterval,
31-
};
32-
}
25+
if (bounds) {
26+
return {
27+
min: bounds.min as number,
28+
max: bounds.max as number,
29+
minInterval,
30+
};
3331
}
3432

3533
return {

test/functional/apps/visualize/_area_chart.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
9696
it('should show correct chart', async function () {
9797
const xAxisLabels = await PageObjects.visChart.getExpectedValue(
9898
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00', '2015-09-23 00:00'],
99-
[
100-
'2015-09-20 00:00',
101-
'2015-09-20 12:00',
102-
'2015-09-21 00:00',
103-
'2015-09-21 12:00',
104-
'2015-09-22 00:00',
105-
'2015-09-22 12:00',
106-
]
99+
['2015-09-19 12:00', '2015-09-20 12:00', '2015-09-21 12:00', '2015-09-22 12:00']
107100
);
108101
const yAxisLabels = await PageObjects.visChart.getExpectedValue(
109102
['0', '200', '400', '600', '800', '1,000', '1,200', '1,400', '1,600'],

test/functional/apps/visualize/_point_series_options.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
269269
it('should show round labels in default timezone', async function () {
270270
const expectedLabels = await PageObjects.visChart.getExpectedValue(
271271
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00'],
272-
['2015-09-20 00:00', '2015-09-20 18:00', '2015-09-21 12:00', '2015-09-22 06:00']
272+
['2015-09-19 12:00', '2015-09-20 12:00', '2015-09-21 12:00', '2015-09-22 12:00']
273273
);
274274
await initChart();
275275
const labels = await PageObjects.visChart.getXAxisLabels();
@@ -279,7 +279,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
279279
it('should show round labels in different timezone', async function () {
280280
const expectedLabels = await PageObjects.visChart.getExpectedValue(
281281
['2015-09-20 00:00', '2015-09-21 00:00', '2015-09-22 00:00'],
282-
['2015-09-19 18:00', '2015-09-20 12:00', '2015-09-21 06:00', '2015-09-22 00:00']
282+
[
283+
'2015-09-19 12:00',
284+
'2015-09-20 06:00',
285+
'2015-09-21 00:00',
286+
'2015-09-21 18:00',
287+
'2015-09-22 12:00',
288+
]
283289
);
284290

285291
await kibanaServer.uiSettings.update({ 'dateFormat:tz': 'America/Phoenix' });

0 commit comments

Comments
 (0)