mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Lens] Set horizontal legend size to auto (#133851)
This commit is contained in:
parent
129e044562
commit
efda0f322a
3 changed files with 45 additions and 9 deletions
|
@ -167,7 +167,7 @@ Object {
|
|||
"legendSize": Array [],
|
||||
"maxLines": Array [],
|
||||
"position": Array [
|
||||
"bottom",
|
||||
"left",
|
||||
],
|
||||
"shouldTruncate": Array [
|
||||
true,
|
||||
|
|
|
@ -72,7 +72,7 @@ describe('#toExpression', () => {
|
|||
expect(
|
||||
xyVisualization.toExpression(
|
||||
{
|
||||
legend: { position: Position.Bottom, isVisible: true },
|
||||
legend: { position: Position.Left, isVisible: true },
|
||||
valueLabels: 'hide',
|
||||
preferredSeriesType: 'bar',
|
||||
fittingFunction: 'Carry',
|
||||
|
@ -371,7 +371,7 @@ describe('#toExpression', () => {
|
|||
it('should set legend size for outside legend', () => {
|
||||
const expression = xyVisualization.toExpression(
|
||||
{
|
||||
legend: { position: Position.Bottom, isVisible: true, legendSize: LegendSize.SMALL },
|
||||
legend: { position: Position.Left, isVisible: true, legendSize: LegendSize.SMALL },
|
||||
valueLabels: 'show',
|
||||
preferredSeriesType: 'bar',
|
||||
layers: [
|
||||
|
@ -394,12 +394,43 @@ describe('#toExpression', () => {
|
|||
).toEqual('small');
|
||||
});
|
||||
|
||||
it('should ignore legend size for insidee legend', () => {
|
||||
it('should use auto legend size for bottom/top legend', () => {
|
||||
const expression = xyVisualization.toExpression(
|
||||
{
|
||||
legend: {
|
||||
position: Position.Bottom,
|
||||
isVisible: true,
|
||||
isInside: false,
|
||||
legendSize: LegendSize.SMALL,
|
||||
},
|
||||
valueLabels: 'show',
|
||||
preferredSeriesType: 'bar',
|
||||
layers: [
|
||||
{
|
||||
layerId: 'first',
|
||||
layerType: layerTypes.DATA,
|
||||
seriesType: 'area',
|
||||
splitAccessor: 'd',
|
||||
xAccessor: 'a',
|
||||
accessors: ['b', 'c'],
|
||||
},
|
||||
],
|
||||
},
|
||||
frame.datasourceLayers,
|
||||
undefined,
|
||||
datasourceExpressionsByLayers
|
||||
) as Ast;
|
||||
expect((expression.chain[0].arguments.legend[0] as Ast).chain[0].arguments.legendSize[0]).toBe(
|
||||
LegendSize.AUTO
|
||||
);
|
||||
});
|
||||
|
||||
it('should ignore legend size for inside legend', () => {
|
||||
const expression = xyVisualization.toExpression(
|
||||
{
|
||||
legend: {
|
||||
position: Position.Left,
|
||||
isVisible: true,
|
||||
isInside: true,
|
||||
legendSize: LegendSize.SMALL,
|
||||
},
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
*/
|
||||
|
||||
import { Ast, AstFunction } from '@kbn/interpreter';
|
||||
import { ScaleType } from '@elastic/charts';
|
||||
import { Position, ScaleType } from '@elastic/charts';
|
||||
import type { PaletteRegistry } from '@kbn/coloring';
|
||||
|
||||
import { EventAnnotationServiceType } from '@kbn/event-annotation-plugin/public';
|
||||
import type { AxisExtentConfig, YConfig, ExtendedYConfig } from '@kbn/expression-xy-plugin/common';
|
||||
import { LegendSize } from '@kbn/visualizations-plugin/public';
|
||||
import {
|
||||
State,
|
||||
XYDataLayerConfig,
|
||||
|
@ -213,10 +214,14 @@ export const buildExpression = (
|
|||
: [],
|
||||
position: !state.legend.isInside ? [state.legend.position] : [],
|
||||
isInside: state.legend.isInside ? [state.legend.isInside] : [],
|
||||
legendSize:
|
||||
!state.legend.isInside && state.legend.legendSize
|
||||
? [state.legend.legendSize]
|
||||
: [],
|
||||
legendSize: state.legend.isInside
|
||||
? []
|
||||
: state.legend.position === Position.Top ||
|
||||
state.legend.position === Position.Bottom
|
||||
? [LegendSize.AUTO]
|
||||
: state.legend.legendSize
|
||||
? [state.legend.legendSize]
|
||||
: [],
|
||||
horizontalAlignment:
|
||||
state.legend.horizontalAlignment && state.legend.isInside
|
||||
? [state.legend.horizontalAlignment]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue