Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Aug 2, 2019
1 parent 7c58073 commit c2b2b63
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.

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

67 changes: 63 additions & 4 deletions src/legacy/core_plugins/metric_vis/public/metric_vis_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,67 @@ import { i18n } from '@kbn/i18n';
// @ts-ignore
import { vislibColorMaps } from 'ui/vislib/components/color/colormaps';

export const createMetricVisFn = () => ({
import { ExpressionFunction, KibanaDatatable, Render } from '../../interpreter/types';

// Todo: breaking change. Should contains one value
type name = 'metric' | 'metricVis';

type Context = KibanaDatatable;

interface Arguments {
percentage: boolean;
colorScheme: string;
colorMode: string;
useRanges: boolean;
invertColors: boolean;
showLabels: boolean;
bgFill: string;
subText: string;
colorRange: any[]; // these aren't typed yet
font: any; // these aren't typed yet
metric: any[]; // these aren't typed yet
bucket: any; // these aren't typed yet
}

interface VisParams {
dimensions: DimensionsVisParam;
metric: MetricVisParam;
}

interface DimensionsVisParam {
metrics: any;
bucket?: any;
}

interface MetricVisParam {
percentageMode: Arguments['percentage'];
useRanges: Arguments['useRanges'];
colorSchema: Arguments['colorScheme'];
metricColorMode: Arguments['colorMode'];
colorsRange: Arguments['colorRange'];
labels: {
show: Arguments['showLabels'];
};
invertColors: Arguments['invertColors'];
style: {
bgFill: Arguments['bgFill'];
bgColor: boolean;
labelColor: boolean;
subText: Arguments['subText'];
fontSize: number;
};
}

interface RenderValue {
visType: string;
visData: Context;
visConfig: VisParams;
params: any;
}

type Return = Render<RenderValue>;

export const createMetricVisFn = (): ExpressionFunction<name, Context, Arguments, Return> => ({
name: 'metricVis',
type: 'render',
context: {
Expand Down Expand Up @@ -123,10 +183,9 @@ export const createMetricVisFn = () => ({
}),
},
},
fn(context: any, args: any) {
const dimensions = {
fn(context: Context, args: Arguments) {
const dimensions: DimensionsVisParam = {
metrics: args.metric,
bucket: undefined,
};

if (args.bucket) {
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/metric_vis/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class MetricVisPlugin implements Plugin<void, void> {
) {
__LEGACY.setup();

data.expressions.registerFunction(() => createMetricVisFn());
visualizations.types.VisTypesRegistryProvider.register(() => createMetricVisTypeDefinition());
data.expressions.registerFunction(createMetricVisFn);
visualizations.types.VisTypesRegistryProvider.register(createMetricVisTypeDefinition);
}

public start(core: CoreStart) {
Expand Down

0 comments on commit c2b2b63

Please sign in to comment.