Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XY] Add minTimeBarInterval arg #128726

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ export const xyVisFunction: ExpressionFunctionDefinition<
defaultMessage: 'Show values in legend',
}),
},
xAxisInterval: {
VladLasitsa marked this conversation as resolved.
Show resolved Hide resolved
types: ['string'],
help: i18n.translate('expressionXY.xyVis.interval.help', {
defaultMessage: 'Specifies the interval for x-axis',
}),
},
ariaLabel: {
types: ['string'],
help: i18n.translate('expressionXY.xyVis.ariaLabel.help', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export interface XYArgs {
hideEndzones?: boolean;
valuesInLegend?: boolean;
ariaLabel?: string;
xAxisInterval?: string;
}

export interface AnnotationLayerArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { XYChartProps } from '../../common';
import { getFilteredLayers } from './layers';
import { isDataLayer } from './visualization';

export function calculateMinInterval({ args: { layers }, data }: XYChartProps) {
export function calculateMinInterval({ args: { layers, xAxisInterval }, data }: XYChartProps) {
const filteredLayers = getFilteredLayers(layers, data);
if (filteredLayers.length === 0) return;
const isTimeViz = filteredLayers.every((l) => isDataLayer(l) && l.xScaleType === 'time');
Expand All @@ -20,6 +20,9 @@ export function calculateMinInterval({ args: { layers }, data }: XYChartProps) {
);

if (!xColumn) return;
if (xAxisInterval) {
return search.aggs.parseInterval(xAxisInterval)?.as('milliseconds');
}
if (!isTimeViz) {
const histogramInterval = search.aggs.getNumberHistogramIntervalByDatatableColumn(xColumn);
if (typeof histogramInterval === 'number') {
Expand Down