@@ -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