[ES|QL] Disables new color mapping for suggested charts (#168068)

## Summary

There are cases in ES|QL where a query might return a lot of buckets.
With our new color mapping system a lot of buckets were greyed out and
there were many concerns.

For this reason I am disabling the new color mapping for these
suggestions (users can always turn it on)

I m fine with this as a temporary solution but I think we need to
re-think:

- having 10 colored buckets was a business decision we took, is it ok
for ES|QL though?
- possibly for cases like this another chart should be suggested, we
agreed with @markov00 that we are going to revisit all the suggestions
soonish and improve. We might need a different suggestion system per
datasource but this is a quite big project and needs a lot of
discussions. Until then, we can have the color mapping disabled by
default for the ES|QL suggestions.

**Now**
<img width="2492" alt="image"
src="2327ccf3-d0d0-4ee7-bf1a-25e3d282003b">

**Before**
<img width="2495" alt="image"
src="9c35f90b-04d6-4e39-9eb6-a5e2d2df335f">
This commit is contained in:
Stratoula Kalafateli 2023-10-09 09:56:26 +03:00 committed by GitHub
parent e52957f167
commit 2f3180b70a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,12 @@
import type { VisualizeFieldContext } from '@kbn/ui-actions-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
import { getSuggestions } from './editor_frame_service/editor_frame/suggestion_helpers';
import type { DatasourceMap, VisualizationMap, VisualizeEditorContext } from './types';
import type {
DatasourceMap,
VisualizationMap,
VisualizeEditorContext,
SuggestionRequest,
} from './types';
import type { DataViewsState } from './state_management';
interface SuggestionsApi {
@ -18,6 +23,14 @@ interface SuggestionsApi {
excludedVisualizations?: string[];
}
const PREFERRED_PALETTE: SuggestionRequest['mainPalette'] = {
type: 'legacyPalette',
value: {
name: 'default',
type: 'palette',
},
};
export const suggestionsApi = ({
context,
dataView,
@ -62,6 +75,7 @@ export const suggestionsApi = ({
visualizationState: undefined,
visualizeTriggerFieldContext: context,
dataViews,
mainPalette: PREFERRED_PALETTE,
});
if (!suggestions.length) return [];
const activeVisualization = suggestions[0];
@ -84,6 +98,7 @@ export const suggestionsApi = ({
activeVisualization: visualizationMap[activeVisualization.visualizationId],
visualizationState: activeVisualization.visualizationState,
dataViews,
mainPalette: PREFERRED_PALETTE,
}).filter((sug) => !sug.hide && sug.visualizationId !== 'lnsLegacyMetric');
const suggestionsList = [activeVisualization, ...newSuggestions];
// until we separate the text based suggestions logic from the dataview one,