diff --git a/src/plugins/vis_augmenter/public/plugin.ts b/src/plugins/vis_augmenter/public/plugin.ts index a6b1642f585a..5e73c2b58744 100644 --- a/src/plugins/vis_augmenter/public/plugin.ts +++ b/src/plugins/vis_augmenter/public/plugin.ts @@ -62,8 +62,6 @@ export class VisAugmenterPlugin setVisualizations(visualizations); setCore(core); - // registers the triggers & actions defined in this plugin - // also maps any triggers to possible actions registerTriggersAndActions(core); const savedAugmentVisLoader = createSavedAugmentVisLoader({ diff --git a/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts b/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts index 9261e001b93d..bfdb64735195 100644 --- a/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts +++ b/src/plugins/vis_augmenter/public/ui_actions_bootstrap.ts @@ -16,7 +16,8 @@ import { CONTEXT_MENU_TRIGGER, EmbeddableContext } from '../../embeddable/public import { getUiActions } from './services'; // Overriding the mappings defined in UIActions plugin so that -// the new trigger and action definitions resolve +// the new trigger and action definitions resolve. +// This is a common pattern among internal Dashboards plugins. declare module '../../ui_actions/public' { export interface TriggerContextMapping { [OPEN_EVENTS_FLYOUT_TRIGGER]: AugmentVisContext; diff --git a/src/plugins/vis_type_vega/public/data_model/vega_parser.ts b/src/plugins/vis_type_vega/public/data_model/vega_parser.ts index e60ae9287425..b219fe75527a 100644 --- a/src/plugins/vis_type_vega/public/data_model/vega_parser.ts +++ b/src/plugins/vis_type_vega/public/data_model/vega_parser.ts @@ -677,6 +677,8 @@ The URL is an identifier only. OpenSearch Dashboards and your browser will never */ _setDefaultColors() { // Default category coloring to the OpenSearch color scheme + // TODO: this should be fixed as part of + // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3582 this._setDefaultValue({ scheme: 'category10' }, 'config', 'range', 'category'); if (this.isVegaLite) { diff --git a/src/plugins/vis_type_vega/public/expressions/vega_fn.ts b/src/plugins/vis_type_vega/public/expressions/vega_fn.ts index 57549e239aed..cd9cf976873a 100644 --- a/src/plugins/vis_type_vega/public/expressions/vega_fn.ts +++ b/src/plugins/vis_type_vega/public/expressions/vega_fn.ts @@ -51,7 +51,9 @@ interface Arguments { savedObjectId: string; } -export type VisParams = Required; +export interface VisParams { + spec: string; +} export type VegaExpressionFunctionDefinition = ExpressionFunctionDefinition< 'vega', @@ -91,15 +93,11 @@ export const createVegaFn = ( async fn(input, args, context) { const vegaRequestHandler = createVegaRequestHandler(dependencies, context); - const timeRange = get(input, 'timeRange') as TimeRange; - const query = get(input, 'query') as Query; - const filters = get(input, 'filters') as any; - const response = await vegaRequestHandler({ - timeRange, - query, - filters, - visParams: { spec: args.spec, savedObjectId: args.savedObjectId }, + timeRange: get(input, 'timeRange') as TimeRange, + query: get(input, 'query') as Query, + filters: get(input, 'filters') as any, + visParams: { spec: args.spec }, }); return { diff --git a/src/plugins/vis_type_vega/public/vega_view/vega_base_view.js b/src/plugins/vis_type_vega/public/vega_view/vega_base_view.js index 5c93b20aaa8a..b37974ebb88b 100644 --- a/src/plugins/vis_type_vega/public/vega_view/vega_base_view.js +++ b/src/plugins/vis_type_vega/public/vega_view/vega_base_view.js @@ -284,11 +284,11 @@ export class VegaBaseView { this._addDestroyHandler(() => tthandler.hideTooltip()); } - // trigger the open events flyout UIAction if a click happens on an annotation datapoint + // TODO: The filtering on the item ('annotation datapoint' vs. regular datapoint, etc.) will be handled in + // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3317 + // Right now, clicking anywhere on the chart will trigger the flyout to open. /* eslint-disable */ view.addEventListener('click', function (event, item) { - // TODO: add filtering to determine if the item is a datapoint, and whether or not it is an - // "annotation" datapoint vs. regular datapoint const { savedObjectId } = get(view, '_opensearchDashboardsView._visInput', {}); getUiActions().getTrigger(OPEN_EVENTS_FLYOUT_TRIGGER).exec({ savedObjectId }); }); diff --git a/src/plugins/vis_type_vega/public/vega_view/vega_tooltip.js b/src/plugins/vis_type_vega/public/vega_view/vega_tooltip.js index eb640bd57529..0e51b6c2068e 100644 --- a/src/plugins/vis_type_vega/public/vega_view/vega_tooltip.js +++ b/src/plugins/vis_type_vega/public/vega_view/vega_tooltip.js @@ -63,12 +63,12 @@ export class TooltipHandler { view.tooltip(this.handler.bind(this)); } - // test handler + /** + * The handler function. + */ handler(view, event, item, value) { this.hideTooltip(); - //console.log('item: ', item); - // hide tooltip for null, undefined, or empty string values if (value == null || value === '') { return; @@ -87,6 +87,7 @@ export class TooltipHandler { // with a large number of tests, hence suppressing eslint here. // eslint-disable-next-line no-unsanitized/property // el.innerHTML = createTooltipContent(value, _.escape, 2); + /* eslint-disable */ el.innerHTML = this.createTooltipHtml(value); // add to DOM to calculate tooltip size @@ -117,6 +118,8 @@ export class TooltipHandler { el.setAttribute('style', `top: ${pos.top}px; left: ${pos.left}px`); } + // TODO: This is where the custom tooltip will be handled - see here for details: + // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3317 /* eslint-disable */ createTooltipHtml(value) { return '

some custom tooltip

'; diff --git a/src/plugins/vis_type_vega/public/vega_visualization.js b/src/plugins/vis_type_vega/public/vega_visualization.js index b7cae964ae5b..9bacd1b59fa3 100644 --- a/src/plugins/vis_type_vega/public/vega_visualization.js +++ b/src/plugins/vis_type_vega/public/vega_visualization.js @@ -84,7 +84,6 @@ export const createVegaVisualization = ({ getServiceSettings }) => const serviceSettings = await getServiceSettings(); const { filterManager } = this.dataPlugin.query; const { timefilter } = this.dataPlugin.query.timefilter; - const vegaViewParams = { parentEl: this._el, applyFilter: this._vis.API.events.applyFilter, diff --git a/src/plugins/visualizations/public/expressions/vis.ts b/src/plugins/visualizations/public/expressions/vis.ts index 7a994a51e7d6..acf747973dee 100644 --- a/src/plugins/visualizations/public/expressions/vis.ts +++ b/src/plugins/visualizations/public/expressions/vis.ts @@ -41,6 +41,7 @@ import { EventEmitter } from 'events'; import _ from 'lodash'; import { VisParams, PersistedState } from '../../../../plugins/visualizations/public'; + import { getTypes } from '../services'; import { VisType } from '../vis_types'; diff --git a/src/plugins/visualizations/public/legacy/build_pipeline.ts b/src/plugins/visualizations/public/legacy/build_pipeline.ts index 97bc4126d662..d751e088c99d 100644 --- a/src/plugins/visualizations/public/legacy/build_pipeline.ts +++ b/src/plugins/visualizations/public/legacy/build_pipeline.ts @@ -268,11 +268,8 @@ const adjustVislibDimensionFormmaters = (vis: Vis, dimensions: { y: any[] }): vo }; export const buildPipelineVisFunction: BuildPipelineVisFunction = { - vega: (params, schemas, uiState, meta) => { - return `vega ${prepareString('spec', params.spec)} ${prepareString( - 'savedObjectId', - meta?.savedObjectId - )}`; + vega: (params) => { + return `vega ${prepareString('spec', params.spec)}`; }, input_control_vis: (params) => { return `input_control_vis ${prepareJson('visConfig', params)}`; @@ -424,16 +421,11 @@ export const buildPipeline = async (vis: Vis, params: BuildPipelineParams) => { const schemas = getSchemas(vis, params); - const meta = { - savedObjectId: get(vis, 'id', ''), - }; - if (buildPipelineVisFunction[vis.type.name]) { pipeline += buildPipelineVisFunction[vis.type.name]( { title, ...vis.params }, schemas, - uiState, - meta + uiState ); } else if (vislibCharts.includes(vis.type.name)) { const visConfig = { ...vis.params };