Skip to content

Commit

Permalink
fix(vis_type_vega): Use default categorical color palette directly (o…
Browse files Browse the repository at this point in the history
…pensearch-project#3663)

rather than relying on vega.scheme. Also update vega.scheme name

Fixes opensearch-project#3582

Signed-off-by: Josh Romero <rmerqg@amazon.com>
Signed-off-by: vagimeli <vagimeli@amazon.com>
  • Loading branch information
joshuarrrr authored and vagimeli committed Apr 4, 2023
1 parent d752188 commit 235a2b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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': {
Expand Down Expand Up @@ -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' },
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vega/public/data_model/vega_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 235a2b3

Please sign in to comment.