From 3275a7b1381dbe49f44e795854de2f75bea990fc Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 09:54:52 -0700 Subject: [PATCH] fix(vis_type_vega): Use default categorical color palette directly (#3663) (#3744) rather than relying on vega.scheme. Also update vega.scheme name Fixes https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3582 (cherry picked from commit e194bc57dae2972f215991f39f3b15fee85381ee) Signed-off-by: Josh Romero Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .../vis_type_vega/public/data_model/vega_parser.test.js | 5 +++-- src/plugins/vis_type_vega/public/data_model/vega_parser.ts | 2 +- src/plugins/vis_type_vega/public/vega_view/vega_base_view.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/vis_type_vega/public/data_model/vega_parser.test.js b/src/plugins/vis_type_vega/public/data_model/vega_parser.test.js index ea8ac40c34db..e9a3e1008cdd 100644 --- a/src/plugins/vis_type_vega/public/data_model/vega_parser.test.js +++ b/src/plugins/vis_type_vega/public/data_model/vega_parser.test.js @@ -30,6 +30,7 @@ import { cloneDeep } from 'lodash'; import { euiThemeVars } from '@osd/ui-shared-deps/theme'; +import { euiPaletteColorBlind } from '@elastic/eui'; import { VegaParser } from './vega_parser'; import { bypassExternalUrlCheck } from '../vega_view/vega_base_view'; @@ -88,7 +89,7 @@ describe(`VegaParser._setDefaultColors`, () => { tickColor: euiThemeVars.euiColorChartLines, }, background: 'transparent', - range: { category: { scheme: 'elastic' } }, + range: { category: euiPaletteColorBlind() }, mark: { color: '#54B399' }, style: { 'group-title': { @@ -121,7 +122,7 @@ describe(`VegaParser._setDefaultColors`, () => { tickColor: euiThemeVars.euiColorChartLines, }, background: 'transparent', - range: { category: { scheme: 'elastic' } }, + range: { category: euiPaletteColorBlind() }, arc: { fill: '#54B399' }, area: { fill: '#54B399' }, line: { stroke: '#54B399' }, 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 d1d5712ec7cc..64ed96f7e3e7 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,7 +677,7 @@ The URL is an identifier only. OpenSearch Dashboards and your browser will never */ _setDefaultColors() { // Default category coloring to the OpenSearch color scheme - this._setDefaultValue({ scheme: 'elastic' }, 'config', 'range', 'category'); + this._setDefaultValue(euiPaletteColorBlind(), 'config', 'range', 'category'); if (this.isVegaLite) { // Vega-Lite: set default color, works for fill and strike -- config: { mark: { color: '#54B399' }} 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 1286495af901..cf52df5d4557 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 @@ -41,7 +41,7 @@ import { opensearchFilters } from '../../../data/public'; import { getEnableExternalUrls, getData } from '../services'; import { extractIndexPatternsFromSpec } from '../lib/extract_index_pattern'; -vega.scheme('elastic', euiPaletteColorBlind()); +vega.scheme('euiPaletteColorBlind', euiPaletteColorBlind()); // Vega's extension functions are global. When called, // we forward execution to the instance-specific handler