Skip to content

Commit 5e7e303

Browse files
[Lens] Remove background from lens embeddable (#83061) (#83251)
Co-authored-by: Kibana Machine <[email protected]>
1 parent eadb94b commit 5e7e303

File tree

3 files changed

+85
-38
lines changed

3 files changed

+85
-38
lines changed

x-pack/plugins/lens/public/pie_visualization/render_function.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ export function PieComponent(
253253

254254
onClickValue(desanitizeFilterContext(context));
255255
}}
256-
theme={chartTheme}
256+
theme={{
257+
...chartTheme,
258+
background: {
259+
color: undefined, // removes background for embeddables
260+
},
261+
}}
257262
baseTheme={chartBaseTheme}
258263
/>
259264
<Partition

x-pack/plugins/lens/public/xy_visualization/__snapshots__/expression.test.tsx.snap

Lines changed: 56 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/lens/public/xy_visualization/expression.tsx

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import {
2020
GeometryValue,
2121
XYChartSeriesIdentifier,
2222
StackMode,
23-
RecursivePartial,
24-
Theme,
2523
VerticalAlignment,
2624
HorizontalAlignment,
2725
} from '@elastic/charts';
@@ -222,36 +220,23 @@ export const getXyChartRenderer = (dependencies: {
222220
},
223221
});
224222

225-
function mergeThemeWithValueLabelsStyling(
226-
theme: RecursivePartial<Theme>,
227-
valuesLabelMode: string = 'hide',
228-
isHorizontal: boolean
229-
) {
223+
function getValueLabelsStyling(isHorizontal: boolean) {
230224
const VALUE_LABELS_MAX_FONTSIZE = 15;
231225
const VALUE_LABELS_MIN_FONTSIZE = 10;
232226
const VALUE_LABELS_VERTICAL_OFFSET = -10;
233227
const VALUE_LABELS_HORIZONTAL_OFFSET = 10;
234228

235-
if (valuesLabelMode === 'hide') {
236-
return theme;
237-
}
238229
return {
239-
...theme,
240-
...{
241-
barSeriesStyle: {
242-
...theme.barSeriesStyle,
243-
displayValue: {
244-
fontSize: { min: VALUE_LABELS_MIN_FONTSIZE, max: VALUE_LABELS_MAX_FONTSIZE },
245-
fill: { textInverted: true, textBorder: 2 },
246-
alignment: isHorizontal
247-
? {
248-
vertical: VerticalAlignment.Middle,
249-
}
250-
: { horizontal: HorizontalAlignment.Center },
251-
offsetX: isHorizontal ? VALUE_LABELS_HORIZONTAL_OFFSET : 0,
252-
offsetY: isHorizontal ? 0 : VALUE_LABELS_VERTICAL_OFFSET,
253-
},
254-
},
230+
displayValue: {
231+
fontSize: { min: VALUE_LABELS_MIN_FONTSIZE, max: VALUE_LABELS_MAX_FONTSIZE },
232+
fill: { textInverted: true, textBorder: 2 },
233+
alignment: isHorizontal
234+
? {
235+
vertical: VerticalAlignment.Middle,
236+
}
237+
: { horizontal: HorizontalAlignment.Center },
238+
offsetX: isHorizontal ? VALUE_LABELS_HORIZONTAL_OFFSET : 0,
239+
offsetY: isHorizontal ? 0 : VALUE_LABELS_VERTICAL_OFFSET,
255240
},
256241
};
257242
}
@@ -445,9 +430,8 @@ export function XYChart({
445430
// No histogram charts
446431
!isHistogramViz;
447432

448-
const baseThemeWithMaybeValueLabels = !shouldShowValueLabels
449-
? chartTheme
450-
: mergeThemeWithValueLabelsStyling(chartTheme, valueLabels, shouldRotate);
433+
const valueLabelsStyling =
434+
shouldShowValueLabels && valueLabels !== 'hide' && getValueLabelsStyling(shouldRotate);
451435

452436
const colorAssignments = getColorAssignments(args.layers, data, formatFactory);
453437

@@ -461,7 +445,16 @@ export function XYChart({
461445
}
462446
legendPosition={legend.position}
463447
showLegendExtra={false}
464-
theme={baseThemeWithMaybeValueLabels}
448+
theme={{
449+
...chartTheme,
450+
barSeriesStyle: {
451+
...chartTheme.barSeriesStyle,
452+
...valueLabelsStyling,
453+
},
454+
background: {
455+
color: undefined, // removes background for embeddables
456+
},
457+
}}
465458
baseTheme={chartBaseTheme}
466459
tooltip={{
467460
headerFormatter: (d) => safeXAccessorLabelRenderer(d.value),

0 commit comments

Comments
 (0)