Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion x-pack/plugins/lens/public/xy_visualization/state_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { SeriesType, visualizationTypes } from './types';
import { SeriesType, visualizationTypes, LayerConfig, YConfig } from './types';

export function isHorizontalSeries(seriesType: SeriesType) {
return seriesType === 'bar_horizontal' || seriesType === 'bar_horizontal_stacked';
Expand All @@ -24,3 +24,12 @@ export function getIconForSeries(type: SeriesType): EuiIconType {

return (definition.icon as EuiIconType) || 'empty';
}

export const getSeriesColor = (layer: LayerConfig, accessor: string) => {
if (layer.splitAccessor) {
return null;
}
return (
layer?.yConfig?.find((yConfig: YConfig) => yConfig.forAccessor === accessor)?.color || null
);
};
3 changes: 2 additions & 1 deletion x-pack/plugins/lens/public/xy_visualization/to_expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ export const buildExpression = (
function: 'lens_xy_yConfig',
arguments: {
forAccessor: [yConfig.forAccessor],
axisMode: [yConfig.axisMode],
axisMode: yConfig.axisMode ? [yConfig.axisMode] : [],
color: yConfig.color ? [yConfig.color] : [],
},
},
],
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/lens/public/xy_visualization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const yAxisConfig: ExpressionFunctionDefinition<
options: ['auto', 'left', 'right'],
help: 'The axis mode of the metric',
},
color: {
types: ['string'],
help: 'The color of the series',
},
},
fn: function fn(input: unknown, args: YConfig) {
return {
Expand Down Expand Up @@ -195,6 +199,7 @@ export type YAxisMode = 'auto' | 'left' | 'right';
export interface YConfig {
forAccessor: string;
axisMode?: YAxisMode;
color?: string;
}

export interface LayerConfig {
Expand Down
Loading