Skip to content

Commit

Permalink
date_histogram bucket type as default
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Aug 12, 2023
1 parent 1d25ca7 commit 1cbc90a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,19 @@ interface XYLayerConfig {

export class XYDataLayer implements ChartLayer<XYDataLayerConfig> {
private column: ChartColumn[];
constructor(private layerConfig: XYLayerConfig) {
private layerConfig: XYLayerConfig;
constructor(layerConfig: XYLayerConfig) {
this.column = layerConfig.data.map((dataItem) => new FormulaColumn(dataItem));
this.layerConfig = {
...layerConfig,
options: {
...layerConfig.options,
buckets: {
type: 'date_histogram',
...layerConfig.options?.buckets,
},
},
};
}

getName(): string | undefined {
Expand Down
1 change: 0 additions & 1 deletion x-pack/examples/embedded_lens_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const App = (props: {
],
options: {
seriesType: 'bar_stacked',
buckets: { type: 'date_histogram' },
},
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { TimeRange } from '@kbn/es-query';
import { FormattedMessage } from '@kbn/i18n-react';
import type { XYLayerOptions, XYVisualOptions } from '@kbn/lens-embeddable-utils';
import type { XYVisualOptions } from '@kbn/lens-embeddable-utils';
import { UseLensAttributesXYLayerConfig } from '../../../../../hooks/use_lens_attributes';
import { buildCombinedHostsFilter } from '../../../../../utils/filters/build';
import { LensChart, type LensChartProps, HostMetricsExplanationContent } from '../../../../lens';
Expand All @@ -25,12 +25,6 @@ interface MetricChartConfig extends Pick<LensChartProps, 'id' | 'title' | 'overr
toolTip: string;
}

const XY_LAYER_OPTIONS: XYLayerOptions = {
buckets: {
type: 'date_histogram',
},
};

const PERCENT_LEFT_AXIS: Pick<MetricChartConfig, 'overrides'>['overrides'] = {
axisLeft: {
domain: {
Expand Down Expand Up @@ -68,7 +62,6 @@ const CHARTS_IN_ORDER: Array<
{
data: [hostLensFormulas.cpuUsage],
layerType: 'data',
options: XY_LAYER_OPTIONS,
},
],
dataViewOrigin: 'metrics',
Expand All @@ -85,7 +78,6 @@ const CHARTS_IN_ORDER: Array<
{
data: [hostLensFormulas.memoryUsage],
layerType: 'data',
options: XY_LAYER_OPTIONS,
},
],
dataViewOrigin: 'metrics',
Expand All @@ -102,7 +94,6 @@ const CHARTS_IN_ORDER: Array<
{
data: [hostLensFormulas.normalizedLoad1m],
layerType: 'data',
options: XY_LAYER_OPTIONS,
},
{
data: [
Expand Down Expand Up @@ -132,7 +123,6 @@ const CHARTS_IN_ORDER: Array<
{
data: [hostLensFormulas.logRate],
layerType: 'data',
options: XY_LAYER_OPTIONS,
},
],
dataViewOrigin: 'logs',
Expand Down Expand Up @@ -164,7 +154,6 @@ const CHARTS_IN_ORDER: Array<
layerType: 'data',
options: {
seriesType: 'area',
...XY_LAYER_OPTIONS,
},
},
],
Expand Down Expand Up @@ -205,7 +194,6 @@ const CHARTS_IN_ORDER: Array<
layerType: 'data',
options: {
seriesType: 'area',
...XY_LAYER_OPTIONS,
},
},
],
Expand Down Expand Up @@ -238,7 +226,6 @@ const CHARTS_IN_ORDER: Array<
layerType: 'data',
options: {
seriesType: 'area',
...XY_LAYER_OPTIONS,
},
},
],
Expand Down Expand Up @@ -271,7 +258,6 @@ const CHARTS_IN_ORDER: Array<
layerType: 'data',
options: {
seriesType: 'area',
...XY_LAYER_OPTIONS,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import { Popover } from '../../table/popover';

const DEFAULT_BREAKDOWN_SIZE = 20;
const XY_LAYER_OPTIONS: XYLayerOptions = {
buckets: {
type: 'date_histogram',
},
breakdown: {
type: 'top_values',
field: 'host.name',
Expand Down

0 comments on commit 1cbc90a

Please sign in to comment.