Conditionally change color of data label

  • Hi all

    I have created a bar chart and have selected to show data labels and have set the BarLableStyle to Outside.

    My chart is working well but sometime the bar becoming too long and the data labels are placed inside making them unreadable.

    Is there a way to change the color of the label if it happens to fall inside the bar?

    Please see attached picture.

    Thanks

  • SceloM (10/30/2013)


    Hi all

    I have created a bar chart and have selected to show data labels and have set the BarLableStyle to Outside.

    My chart is working well but sometime the bar becoming too long and the data labels are placed inside making them unreadable.

    Is there a way to change the color of the label if it happens to fall inside the bar?

    Please see attached picture.

    Thanks

    When I tried this below for a horizontal bar chart I could not find a property that returns whether the label is inside or outside the bar. During testing I found using the default settings for font that the label went outside when the value of the bar was >= 95 % of the maximum.

    Workaround:

    1. Control the maximum value on the bottom axis. If the AUTO setting will decide dependent upon the values given then picks the next major increment. Using the calculation below you can mimic this behaviour but in a controlled way.

    =(floor(max(Fields!Quantity.Value,"DataSetName")/100)+1) * 100

    This will set the maximum to the next increment of 100. Change as required.

    2. Using the Labels properties of the Chart Series change the Color property to be expression controlled.

    =iif(Fields!Quantity.Value>=(0.95 * (floor(max(Fields!Quantity.Value,"DataSetName")/100)+1) * 100),"White","Black")

    The chart should then show as you requested (see attached).

    Fitz

  • Mark you are a life saver, I battled with this for a while and your work around did exactly what I wanted.

    Thank you for your assistance.:-)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply