Skip to content

Commit

Permalink
Move chart type enum to visualization utils
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Oct 18, 2024
1 parent 8ee27c8 commit 56fb6e0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 40 deletions.
1 change: 1 addition & 0 deletions packages/kbn-visualization-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export { getTimeZone } from './src/get_timezone';
export { getLensAttributesFromSuggestion } from './src/get_lens_attributes';
export { TooltipWrapper } from './src/tooltip_wrapper';
export { useDebouncedValue } from './src/debounced_value';
export { ChartType } from './src/types';
13 changes: 13 additions & 0 deletions packages/kbn-visualization-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ export interface Suggestion<T = unknown, V = unknown> {
changeType: TableChangeType;
keptLayerIds: string[];
}

export enum ChartType {
XY = 'XY',
Bar = 'Bar',
Line = 'Line',
Area = 'Area',
Donut = 'Donut',
Heatmap = 'Heat map',
Treemap = 'Treemap',
Tagcloud = 'Tag cloud',
Waffle = 'Waffle',
Table = 'Table',
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type { AggregateQuery, TimeRange } from '@kbn/es-query';
import { getAggregateQueryMode, isOfAggregateQueryType } from '@kbn/es-query';
import { i18n } from '@kbn/i18n';
import { getLensAttributesFromSuggestion } from '@kbn/visualization-utils';
import type { ChartType } from '@kbn/visualization-utils';
import { LegendSize } from '@kbn/visualizations-plugin/public';
import { XYConfiguration } from '@kbn/visualizations-plugin/common';
import type { Datatable, DatatableColumn } from '@kbn/expressions-plugin/common';
Expand Down Expand Up @@ -78,19 +79,6 @@ interface LensVisServiceParams {
lensSuggestionsApi: LensSuggestionsApi;
}

export enum ChartType {
XY = 'XY',
Bar = 'Bar',
Line = 'Line',
Area = 'Area',
Donut = 'Donut',
Heatmap = 'Heat map',
Treemap = 'Treemap',
Tagcloud = 'Tag cloud',
Waffle = 'Waffle',
Table = 'Table',
}

export class LensVisService {
private state$: BehaviorSubject<LensVisServiceState>;
private services: Services;
Expand Down
14 changes: 1 addition & 13 deletions x-pack/plugins/lens/public/lens_suggestions_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,11 @@
*/
import type { VisualizeFieldContext } from '@kbn/ui-actions-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { ChartType } from '@kbn/visualization-utils';
import { getSuggestions } from './editor_frame_service/editor_frame/suggestion_helpers';
import type { DatasourceMap, VisualizationMap, VisualizeEditorContext } from './types';
import type { DataViewsState } from './state_management';

export enum ChartType {
XY = 'XY',
Bar = 'Bar',
Line = 'Line',
Area = 'Area',
Donut = 'Donut',
Heatmap = 'Heat map',
Treemap = 'Treemap',
Tagcloud = 'Tag cloud',
Waffle = 'Waffle',
Table = 'Table',
}

interface SuggestionsApiProps {
context: VisualizeFieldContext | VisualizeEditorContext;
dataView: DataView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
VisualizeESQLUserIntention,
} from '@kbn/observability-ai-assistant-plugin/public';
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import { getLensAttributesFromSuggestion } from '@kbn/visualization-utils';
import { getLensAttributesFromSuggestion, ChartType } from '@kbn/visualization-utils';
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import ReactDOM from 'react-dom';
import useAsync from 'react-use/lib/useAsync';
Expand All @@ -48,19 +48,6 @@ import type {
} from '../../common/functions/visualize_esql';
import { ObservabilityAIAssistantAppPluginStartDependencies } from '../types';

enum ChartType {
XY = 'XY',
Bar = 'Bar',
Line = 'Line',
Area = 'Area',
Donut = 'Donut',
Heatmap = 'Heat map',
Treemap = 'Treemap',
Tagcloud = 'Tag cloud',
Waffle = 'Waffle',
Table = 'Table',
}

interface VisualizeESQLProps {
/** Lens start contract, get the ES|QL charts suggestions api */
lens: LensPublicStart;
Expand Down

0 comments on commit 56fb6e0

Please sign in to comment.