2020-05-05 21:59:32 +02: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-05-05 21:59:32 +02:00
|
|
|
*/
|
|
|
|
|
2020-05-15 12:01:27 +02:00
|
|
|
import { CoreSetup } from 'src/core/public';
|
2020-05-05 21:59:32 +02:00
|
|
|
import { ExpressionsSetup } from 'src/plugins/expressions/public';
|
|
|
|
import { EditorFrameSetup, FormatFactory } from '../types';
|
|
|
|
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
|
2020-07-02 16:02:30 +02:00
|
|
|
import { ChartsPluginSetup } from '../../../../../src/plugins/charts/public';
|
2020-05-05 21:59:32 +02:00
|
|
|
|
|
|
|
export interface PieVisualizationPluginSetupPlugins {
|
|
|
|
editorFrame: EditorFrameSetup;
|
|
|
|
expressions: ExpressionsSetup;
|
|
|
|
formatFactory: Promise<FormatFactory>;
|
2020-07-02 16:02:30 +02:00
|
|
|
charts: ChartsPluginSetup;
|
2020-05-05 21:59:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PieVisualizationPluginStartPlugins {
|
|
|
|
uiActions: UiActionsStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PieVisualization {
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
setup(
|
|
|
|
core: CoreSetup,
|
2020-07-02 16:02:30 +02:00
|
|
|
{ expressions, formatFactory, editorFrame, charts }: PieVisualizationPluginSetupPlugins
|
2020-05-05 21:59:32 +02:00
|
|
|
) {
|
2020-09-29 19:00:29 +02:00
|
|
|
editorFrame.registerVisualization(async () => {
|
2020-11-04 11:27:52 +01:00
|
|
|
const { getPieVisualization, pie, getPieRenderer } = await import('../async_services');
|
|
|
|
const palettes = await charts.palettes.getPalettes();
|
2020-05-05 21:59:32 +02:00
|
|
|
|
2020-09-29 19:00:29 +02:00
|
|
|
expressions.registerFunction(() => pie);
|
2020-05-05 21:59:32 +02:00
|
|
|
|
2020-09-29 19:00:29 +02:00
|
|
|
expressions.registerRenderer(
|
|
|
|
getPieRenderer({
|
|
|
|
formatFactory,
|
|
|
|
chartsThemeService: charts.theme,
|
2020-11-04 11:27:52 +01:00
|
|
|
paletteService: palettes,
|
2020-09-29 19:00:29 +02:00
|
|
|
})
|
|
|
|
);
|
2020-11-04 11:27:52 +01:00
|
|
|
return getPieVisualization({ paletteService: palettes });
|
2020-09-29 19:00:29 +02:00
|
|
|
});
|
2020-05-05 21:59:32 +02:00
|
|
|
}
|
|
|
|
}
|