mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Lens] [TSVB] Fixes the brushing of the last bucket for timeseries visualizations (#112068)
* Enable allowBrushingLastHistogramBucket for timeseries visualizations * Cleanup
This commit is contained in:
parent
fa1e9a6aee
commit
8f70030386
4 changed files with 55 additions and 1 deletions
|
@ -141,6 +141,7 @@ export const TimeSeries = ({
|
|||
debugState={window._echDebugStateFlag ?? false}
|
||||
showLegend={legend}
|
||||
showLegendExtra={true}
|
||||
allowBrushingLastHistogramBucket={true}
|
||||
legendPosition={legendPosition}
|
||||
onBrushEnd={onBrushEndListener}
|
||||
onElementClick={(args) => handleElementClick(args)}
|
||||
|
|
|
@ -5,6 +5,7 @@ exports[`xy_expression XYChart component it renders area 1`] = `
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
@ -228,6 +229,7 @@ exports[`xy_expression XYChart component it renders bar 1`] = `
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
@ -465,6 +467,7 @@ exports[`xy_expression XYChart component it renders horizontal bar 1`] = `
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
@ -702,6 +705,7 @@ exports[`xy_expression XYChart component it renders line 1`] = `
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
@ -925,6 +929,7 @@ exports[`xy_expression XYChart component it renders stacked area 1`] = `
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
@ -1156,6 +1161,7 @@ exports[`xy_expression XYChart component it renders stacked bar 1`] = `
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
@ -1401,6 +1407,7 @@ exports[`xy_expression XYChart component it renders stacked horizontal bar 1`] =
|
|||
renderer="canvas"
|
||||
>
|
||||
<Connect(SpecInstance)
|
||||
allowBrushingLastHistogramBucket={false}
|
||||
baseTheme={Object {}}
|
||||
debugState={false}
|
||||
legendAction={
|
||||
|
|
|
@ -974,7 +974,6 @@ describe('xy_expression', () => {
|
|||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.find(Settings).first().prop('onBrushEnd')!({ x: [1585757732783, 1585758880838] });
|
||||
|
||||
expect(onSelectRange).toHaveBeenCalledWith({
|
||||
|
@ -1075,6 +1074,22 @@ describe('xy_expression', () => {
|
|||
expect(wrapper.find(Settings).first().prop('onBrushEnd')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('allowBrushingLastHistogramBucket is true for date histogram data', () => {
|
||||
const { args } = sampleArgs();
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<XYChart
|
||||
{...defaultProps}
|
||||
data={dateHistogramData}
|
||||
args={{
|
||||
...args,
|
||||
layers: [dateHistogramLayer],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find(Settings).at(0).prop('allowBrushingLastHistogramBucket')).toEqual(true);
|
||||
});
|
||||
|
||||
test('onElementClick returns correct context data', () => {
|
||||
const geometry: GeometryValue = { x: 5, y: 1, accessor: 'y1', mark: null, datum: {} };
|
||||
const series = {
|
||||
|
@ -1335,6 +1350,36 @@ describe('xy_expression', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('allowBrushingLastHistogramBucket should be fakse for ordinal data', () => {
|
||||
const { args, data } = sampleArgs();
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<XYChart
|
||||
{...defaultProps}
|
||||
data={data}
|
||||
args={{
|
||||
...args,
|
||||
layers: [
|
||||
{
|
||||
layerId: 'first',
|
||||
layerType: layerTypes.DATA,
|
||||
seriesType: 'line',
|
||||
xAccessor: 'd',
|
||||
accessors: ['a', 'b'],
|
||||
columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}',
|
||||
xScaleType: 'ordinal',
|
||||
yScaleType: 'linear',
|
||||
isHistogram: false,
|
||||
palette: mockPaletteOutput,
|
||||
},
|
||||
],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(wrapper.find(Settings).at(0).prop('allowBrushingLastHistogramBucket')).toEqual(false);
|
||||
});
|
||||
|
||||
test('onElementClick is not triggering event on non-interactive mode', () => {
|
||||
const { args, data } = sampleArgs();
|
||||
|
||||
|
|
|
@ -516,6 +516,7 @@ export function XYChart({
|
|||
boundary: document.getElementById('app-fixed-viewport') ?? undefined,
|
||||
headerFormatter: (d) => safeXAccessorLabelRenderer(d.value),
|
||||
}}
|
||||
allowBrushingLastHistogramBucket={Boolean(isTimeViz)}
|
||||
rotation={shouldRotate ? 90 : 0}
|
||||
xDomain={xDomain}
|
||||
onBrushEnd={interactive ? brushHandler : undefined}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue