2020-02-13 13:54:51 +01:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2021-02-04 03:12:39 +01:00
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
|
|
* 2.0.
|
2020-02-13 13:54:51 +01:00
|
|
|
*/
|
|
|
|
|
2020-04-15 12:22:37 +02:00
|
|
|
import { CoreSetup } from 'kibana/public';
|
|
|
|
import { ExpressionsSetup } from '../../../../../src/plugins/expressions/public';
|
2020-03-25 16:16:11 +01:00
|
|
|
import { EditorFrameSetup, FormatFactory } from '../types';
|
2020-02-13 13:54:51 +01:00
|
|
|
|
|
|
|
export interface MetricVisualizationPluginSetupPlugins {
|
|
|
|
expressions: ExpressionsSetup;
|
2020-03-25 16:16:11 +01:00
|
|
|
formatFactory: Promise<FormatFactory>;
|
2020-02-13 13:54:51 +01:00
|
|
|
editorFrame: EditorFrameSetup;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class MetricVisualization {
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
setup(
|
|
|
|
_core: CoreSetup | null,
|
|
|
|
{ expressions, formatFactory, editorFrame }: MetricVisualizationPluginSetupPlugins
|
|
|
|
) {
|
2020-09-29 19:00:29 +02:00
|
|
|
editorFrame.registerVisualization(async () => {
|
|
|
|
const { metricVisualization, metricChart, getMetricChartRenderer } = await import(
|
|
|
|
'../async_services'
|
|
|
|
);
|
2020-02-13 13:54:51 +01:00
|
|
|
|
2020-09-29 19:00:29 +02:00
|
|
|
expressions.registerFunction(() => metricChart);
|
2020-02-13 13:54:51 +01:00
|
|
|
|
2020-09-29 19:00:29 +02:00
|
|
|
expressions.registerRenderer(() => getMetricChartRenderer(formatFactory));
|
|
|
|
return metricVisualization;
|
|
|
|
});
|
2020-02-13 13:54:51 +01:00
|
|
|
}
|
|
|
|
}
|