Skip to content

Commit ec1b649

Browse files
committed
use color group panel
Signed-off-by: Qxisylolo <[email protected]>
1 parent 85fe532 commit ec1b649

26 files changed

+83
-65
lines changed

src/plugins/explore/public/components/visualizations/area/area_vis_config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('area_vis_config', () => {
2525

2626
// Check threshold lines
2727
expect(defaultAreaChartStyles.thresholdOptions).toMatchObject({
28-
baseColor: '#00BD6B',
28+
baseColor: '#017D73',
2929
thresholds: [],
3030
thresholdStyle: ThresholdMode.Off,
3131
});

src/plugins/explore/public/components/visualizations/bar/bar_chart_utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '../types';
1414
import { applyAxisStyling, getSchemaByAxis } from '../utils/utils';
1515
import { BarChartStyle } from './bar_vis_config';
16-
import { getColors, DEFAULT_GREY } from '../theme/default_colors';
16+
import { getColors, DEFAULT_GREY, resolveColor } from '../theme/default_colors';
1717

1818
export const inferTimeIntervals = (data: Array<Record<string, any>>, field: string | undefined) => {
1919
if (!data || data.length === 0 || !field) {
@@ -146,7 +146,10 @@ export const buildThresholdColorEncoding = (
146146

147147
const colorDomain = thresholdWithBase.reduce<number[]>((acc, val) => [...acc, val.value], []);
148148

149-
const colorRange = thresholdWithBase.reduce<string[]>((acc, val) => [...acc, val.color], []);
149+
const colorRange = thresholdWithBase.reduce<string[]>(
150+
(acc, val) => [...acc, resolveColor(val.color)],
151+
[]
152+
);
150153

151154
// exclusive for single numerical bucket bar
152155
if (!numericalField)

src/plugins/explore/public/components/visualizations/bar/bar_vis_config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('bar_vis_config', () => {
2828

2929
// Threshold and grid
3030
thresholdOptions: {
31-
baseColor: '#00BD6B',
31+
baseColor: '#017D73',
3232
thresholds: [],
3333
thresholdStyle: ThresholdMode.Off,
3434
},

src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { AxisColumnMappings, Threshold, VisFieldType } from '../types';
77
import { BarGaugeChartStyle } from './bar_gauge_vis_config';
8+
import { resolveColor } from '../theme/default_colors';
89

910
export const getBarOrientation = (
1011
styles: BarGaugeChartStyle,
@@ -117,14 +118,14 @@ export const generateParams = (
117118
if (i === 0) {
118119
result.push({
119120
name: `gradient${i}`,
120-
value: thresholds[0]?.color,
121+
value: resolveColor(thresholds[0]?.color),
121122
});
122123
continue;
123124
}
124125

125126
const allStops = thresholds.slice(0, i + 1).map((t) => ({
126127
offset: normalizeData(t.value, start, end),
127-
color: t.color,
128+
color: resolveColor(t.color),
128129
}));
129130

130131
const stops = [];

src/plugins/explore/public/components/visualizations/bar_gauge/bar_gauge_vis_config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('createBarGaugeConfig', () => {
2828
const config = createBarGaugeConfig();
2929
const defaults = config.ui.style.defaults;
3030
expect(defaults.thresholdOptions).toMatchObject({
31-
baseColor: '#00BD6B',
31+
baseColor: '#017D73',
3232
thresholds: [],
3333
});
3434
expect(defaults.valueCalculation).toBe('last');

src/plugins/explore/public/components/visualizations/bar_gauge/to_expression.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jest.mock('../utils/calculation', () => ({
1818
jest.mock('../theme/default_colors', () => ({
1919
darkenColor: jest.fn((color) => '#00000'),
2020
getColors: jest.fn(() => ({ text: 'black', statusGreen: 'green', backgroundShade: 'grey' })),
21+
resolveColor: jest.fn((color) => color),
2122
}));
2223

2324
jest.mock('../utils/utils', () => ({

src/plugins/explore/public/components/visualizations/bar_gauge/to_expression.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { groupBy } from 'lodash';
77
import { BarGaugeChartStyle } from './bar_gauge_vis_config';
88
import { VisColumn, AxisColumnMappings, VEGASCHEMA, Threshold, VisFieldType } from '../types';
99
import { calculateValue } from '../utils/calculation';
10-
import { getColors } from '../theme/default_colors';
10+
import { getColors, resolveColor } from '../theme/default_colors';
1111
import { getSchemaByAxis } from '../utils/utils';
1212
import {
1313
getBarOrientation,
@@ -241,7 +241,7 @@ export const createBarGaugeSpec = (
241241
mark: {
242242
type: 'bar',
243243
clip: true,
244-
color: threshold.color,
244+
color: resolveColor(threshold.color),
245245
},
246246
encoding: {
247247
[`${processedSymbol}`]: {
@@ -304,7 +304,10 @@ export const createBarGaugeSpec = (
304304
type: 'threshold',
305305
// last threshold which is just for max value capping in gradient mode
306306
domain: processedThresholds.map((t) => t.value),
307-
range: [getColors().backgroundShade, ...processedThresholds.map((t) => t.color)],
307+
range: [
308+
getColors().backgroundShade,
309+
...processedThresholds.map((t) => resolveColor(t.color)),
310+
],
308311
},
309312
legend: null,
310313
},
@@ -347,7 +350,10 @@ export const createBarGaugeSpec = (
347350
scale: {
348351
type: 'threshold',
349352
domain: processedThresholds.map((t) => t.value),
350-
range: [getColors().backgroundShade, ...processedThresholds.map((t) => t.color)],
353+
range: [
354+
getColors().backgroundShade,
355+
...processedThresholds.map((t) => resolveColor(t.color)),
356+
],
351357
},
352358
legend: null,
353359
},

src/plugins/explore/public/components/visualizations/gauge/gauge_vis_config.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('createGaugeConfig', () => {
3131
expect(defaults.showTitle).toBe(true);
3232
expect(defaults.title).toBe('');
3333
expect(defaults.thresholdOptions).toMatchObject({
34-
baseColor: '#00BD6B',
34+
baseColor: '#017D73',
3535
thresholds: [],
3636
});
3737
expect(defaults.valueCalculation).toBe('last');

src/plugins/explore/public/components/visualizations/gauge/to_expression.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
mergeThresholdsWithBase,
1414
getMaxAndMinBase,
1515
} from '../style_panel/threshold/threshold_utils';
16-
import { getColors, DEFAULT_GREY } from '../theme/default_colors';
16+
import { getColors, DEFAULT_GREY, resolveColor } from '../theme/default_colors';
1717
import { getUnitById, showDisplayValue } from '../style_panel/unit/collection';
1818

1919
export const createGauge = (
@@ -70,7 +70,7 @@ export const createGauge = (
7070
const fillColor =
7171
!targetThreshold || minBase > targetValue || minBase >= maxBase || !isValidNumber
7272
? DEFAULT_GREY
73-
: targetThreshold.color;
73+
: resolveColor(targetThreshold.color);
7474

7575
const ranges = generateRanges(mergedThresholds, maxBase);
7676

@@ -102,7 +102,9 @@ export const createGauge = (
102102
{ name: 'theta2_single_arc', value: 2 },
103103
];
104104

105-
const rangeArcs = ranges.map((range) => generateArcExpression(range.min, range.max, range.color));
105+
const rangeArcs = ranges.map((range) =>
106+
generateArcExpression(range.min, range.max, resolveColor(range.color))
107+
);
106108

107109
const titleLayer = styleOptions.showTitle
108110
? [

src/plugins/explore/public/components/visualizations/heatmap/heatmap_chart_utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { Encoding } from 'vega-lite/build/src/encoding';
77
import { AggregationType, VisColumn } from '../types';
88
import { HeatmapChartStyle } from './heatmap_vis_config';
99

10-
import { getColors, DEFAULT_GREY } from '../theme/default_colors';
10+
import { getColors, DEFAULT_GREY, resolveColor } from '../theme/default_colors';
1111

1212
// isRegular=== true refers to 2 dimension and 1 metric heatmap.
1313
export const createLabelLayer = (
@@ -108,7 +108,7 @@ export const enhanceStyle = (
108108
];
109109

110110
const colorDomain = thresholdWithBase.map<number>((val) => val.value);
111-
const colorRange = thresholdWithBase.map<string>((val) => val.color);
111+
const colorRange = thresholdWithBase.map<string>((val) => resolveColor(val.color));
112112

113113
// overwrite color scale type to quantize to map continuous domains to discrete output ranges
114114
markLayer.encoding.color.scale.type = 'threshold';

0 commit comments

Comments
 (0)