Can I change text color in bar graphs based on the underlying bar color?

BarChart[numbers, BaseStyle -> Directive[FontFamily -> font, FontSize -> 13], 
 ChartStyle -> 10, ImageSize -> 560, BarOrigin -> Left, 
 ChartLabels -> Placed[languages, After], 
 LabelingFunction -> (Placed[
  Style[#, If[Plus @@ ColorData[10, Last[#2]] < 1.5, White, Black]], Center] &), 
 AxesLabel -> {"", "millions\nof speakers"}]

Out0


An alternative placement of the numbers:

BarChart[numbers, BaseStyle -> Directive[FontFamily -> font, FontSize -> 13], 
 ChartStyle -> 10, ImageSize -> 560, BarOrigin -> Left, 
 ChartLabels -> Placed[languages, After],
 LabelingFunction -> (Placed[
  Style[#, If[Plus @@ ColorData[10, Last[#2]] < 1.5, White, Black]], Left] &), 
 AxesLabel -> {"", "millions\nof speakers"}]

Out

BarChart[numbers, BaseStyle -> Directive[FontFamily -> font, FontSize -> 13], 
 ChartStyle -> 10, ImageSize -> 560, BarOrigin -> Left, 
 ChartLabels -> Placed[languages, After],
 LabelingFunction -> (Placed[
     Style[#, If[Plus @@ ColorData[10, Last[#2]] < 1.5, White, Black]], 
       {0 + 2/3*Min[numbers]/#, 0.5}] &), 
 AxesLabel -> {"", "millions\nof speakers"}]

Out2

BarChart[numbers, BaseStyle -> Directive[FontFamily -> font, FontSize -> 13], 
 ChartStyle -> 10, ImageSize -> 560, BarOrigin -> Left, 
 ChartLabels -> Placed[languages, After],
 LabelingFunction -> (Placed[
     Row[{Spacer[10], 
       Style[#, If[Plus @@ ColorData[10, Last[#2]] < 1.5, White, Black]]}], Left] &), 
 AxesLabel -> {"", "millions\nof speakers"}]

Out3


BarChart[numbers, 
 BaseStyle -> Directive[FontFamily -> font, FontSize -> 13], 
 ChartStyle -> 10, ImageSize -> 560, BarOrigin -> Left, 
 ChartLabels -> Placed[{languages}, {{{1, 0.5}, {-0.2, 0.5}}}, # &], 
 AxesLabel -> {"", "millions\nof speakers"}, 
 LabelingFunction -> (Placed[Panel[#1, FrameMargins -> 0], Center] &)]

enter image description here

Tags:

Charts

Color