Skip to content

Commit

Permalink
update aggs-based
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdaemon committed May 6, 2022
1 parent bf828cb commit 8c28bbc
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 28 deletions.
10 changes: 2 additions & 8 deletions src/plugins/vis_types/heatmap/public/to_ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
* Side Public License, v 1.
*/

import {
VisToExpressionAst,
getVisSchemas,
SchemaConfig,
LegendSizeToPixels,
} from '@kbn/visualizations-plugin/public';
import { VisToExpressionAst, getVisSchemas, SchemaConfig } from '@kbn/visualizations-plugin/public';
import { buildExpression, buildExpressionFunction } from '@kbn/expressions-plugin/public';
import { DEFAULT_LEGEND_SIZE } from '@kbn/visualizations-plugin/public';
import { getStopsWithColorsFromRanges, getStopsWithColorsFromColorsNumber } from './utils/palette';
import type { HeatmapVisParams } from './types';
import { getEsaggsFn } from './to_ast_esaggs';
Expand All @@ -26,7 +20,7 @@ const prepareLegend = (params: HeatmapVisParams) => {
position: params.legendPosition,
shouldTruncate: params.truncateLegend ?? true,
maxLines: params.maxLegendLines ?? 1,
legendSize: LegendSizeToPixels[params.legendSize ?? DEFAULT_LEGEND_SIZE],
legendSize: params.legendSize,
});

return buildExpression([legend]);
Expand Down

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

2 changes: 2 additions & 0 deletions src/plugins/vis_types/pie/public/sample_vis.test.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { LegendDisplay } from '@kbn/expression-partition-vis-plugin/common';
import { LegendSize } from '@kbn/visualizations-plugin/common';

export const samplePieVis = {
type: {
Expand Down Expand Up @@ -142,6 +143,7 @@ export const samplePieVis = {
addTooltip: true,
legendDisplay: LegendDisplay.SHOW,
legendPosition: 'right',
legendSize: LegendSize.LARGE,
isDonut: true,
labels: {
show: true,
Expand Down
10 changes: 2 additions & 8 deletions src/plugins/vis_types/pie/public/to_ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
*/

import type { PaletteOutput } from '@kbn/coloring';
import {
getVisSchemas,
VisToExpressionAst,
SchemaConfig,
DEFAULT_LEGEND_SIZE,
LegendSizeToPixels,
} from '@kbn/visualizations-plugin/public';
import { getVisSchemas, VisToExpressionAst, SchemaConfig } from '@kbn/visualizations-plugin/public';
import { buildExpression, buildExpressionFunction } from '@kbn/expressions-plugin/public';
import {
PIE_VIS_EXPRESSION_NAME,
Expand Down Expand Up @@ -71,7 +65,7 @@ export const toExpressionAst: VisToExpressionAst<PartitionVisParams> = async (vi
nestedLegend: vis.params?.nestedLegend ?? false,
truncateLegend: vis.params.truncateLegend,
maxLegendLines: vis.params.maxLegendLines,
legendSize: LegendSizeToPixels[vis.params?.legendSize ?? DEFAULT_LEGEND_SIZE],
legendSize: vis.params?.legendSize,
distinctColors: vis.params?.distinctColors,
isDonut: vis.params.isDonut ?? false,
emptySizeRatio: vis.params.emptySizeRatio,
Expand Down

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

22 changes: 18 additions & 4 deletions src/plugins/vis_types/xy/public/expression_functions/xy_vis_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import type {
Datatable,
Render,
} from '@kbn/expressions-plugin/common';
import { prepareLogTable, Dimension } from '@kbn/visualizations-plugin/public';
import {
prepareLogTable,
Dimension,
DEFAULT_LEGEND_SIZE,
LegendSize,
} from '@kbn/visualizations-plugin/public';
import type { ChartType } from '../../common';
import type { VisParams, XYVisConfig } from '../types';

Expand Down Expand Up @@ -73,10 +78,19 @@ export const visTypeXyVisFn = (): VisTypeXyExpressionFunctionDefinition => ({
}),
},
legendSize: {
types: ['number'],
help: i18n.translate('visTypeXy.function.args.args.legendSize.help', {
defaultMessage: 'Specifies the legend size in pixels.',
types: ['string'],
default: DEFAULT_LEGEND_SIZE,
help: i18n.translate('expressionHeatmap.function.args.legendSize.help', {
defaultMessage: 'Specifies the legend size.',
}),
options: [
LegendSize.AUTO,
LegendSize.SMALL,
LegendSize.MEDIUM,
LegendSize.LARGE,
LegendSize.EXTRA_LARGE,
],
strict: true,
},
addLegend: {
types: ['boolean'],
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/vis_types/xy/public/sample_vis.test.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { LegendSize } from '@kbn/visualizations-plugin/common';

export const sampleAreaVis = {
type: {
name: 'area',
Expand Down Expand Up @@ -282,6 +285,7 @@ export const sampleAreaVis = {
addTooltip: true,
addLegend: true,
legendPosition: 'top',
legendSize: LegendSize.SMALL,
times: [],
addTimeMarker: false,
truncateLegend: true,
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/vis_types/xy/public/to_ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
getVisSchemas,
DateHistogramParams,
HistogramParams,
DEFAULT_LEGEND_SIZE,
LegendSizeToPixels,
} from '@kbn/visualizations-plugin/public';
import { buildExpression, buildExpressionFunction } from '@kbn/expressions-plugin/public';
import { BUCKET_TYPES } from '@kbn/data-plugin/public';
Expand Down Expand Up @@ -212,7 +210,7 @@ export const toExpressionAst: VisToExpressionAst<VisParams> = async (vis, params
addTimeMarker: vis.params.addTimeMarker,
truncateLegend: vis.params.truncateLegend,
maxLegendLines: vis.params.maxLegendLines,
legendSize: LegendSizeToPixels[vis.params.legendSize ?? DEFAULT_LEGEND_SIZE],
legendSize: vis.params.legendSize,
addLegend: vis.params.addLegend,
addTooltip: vis.params.addTooltip,
legendPosition: vis.params.legendPosition,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_types/xy/public/types/param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export interface XYVisConfig {
addTimeMarker: boolean;
truncateLegend: boolean;
maxLegendLines: number;
legendSize?: number;
legendSize?: LegendSize;
orderBucketsBySum?: boolean;
labels: ExpressionValueLabel;
thresholdLine: ExpressionValueThresholdLine;
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/vis_types/xy/public/vis_component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import {
useActiveCursor,
} from '@kbn/charts-plugin/public';
import { Datatable, IInterpreterRenderHandlers } from '@kbn/expressions-plugin/public';
import type { PersistedState } from '@kbn/visualizations-plugin/public';
import {
DEFAULT_LEGEND_SIZE,
LegendSizeToPixels,
PersistedState,
} from '@kbn/visualizations-plugin/public';
import { VisParams } from './types';
import {
getAdjustedDomain,
Expand Down Expand Up @@ -361,7 +365,7 @@ const VisComponent = (props: VisComponentProps) => {
tooltip: { visible: syncTooltips, placement: Placement.Right },
}}
legendPosition={legendPosition}
legendSize={visParams.legendSize}
legendSize={LegendSizeToPixels[visParams.legendSize ?? DEFAULT_LEGEND_SIZE]}
xDomain={xDomain}
adjustedXDomain={adjustedXDomain}
legendColorPicker={legendColorPicker}
Expand Down

0 comments on commit 8c28bbc

Please sign in to comment.