cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports: Conditionally change bar colors on a stacked graph

former_member548403
Participant
0 Kudos

I have a simple bar graph chart that I am trying to make it highlight both the lowest and highest bar on the chart. I'm trying to use the stacked graph to show the highest and lowest values on the graph, but can this be really done, I wonder? It seems like the options are limited when it comes to manipulating the charts.

Accepted Solutions (0)

Answers (2)

Answers (2)

abhilash_kumar
Active Contributor

Hi Kenshin,

Try this please:

1. Create a formula called "Highlight" with this code:

If {Command.count} = Maximum({Command.count}) OR {Command.count} = Minimum({Command.count}) then 1 else 0

2. Insert a Crosstab. Add the incident_hour field as the first Row field and the "Highlight" formula field as the Second Row field

3. Add the Count field as the "Summarized field" and set its summary function as "Sum"

4. Right-click the Crosstab and select "Insert Chart"

5. Right-click the Chart and select Chart Expert > Color Highlight > New.

Under "Value of" choose the "Highlight" formula field. Set the operator as "is equal to" and select value as "1". Set its color as Black

Click "New" again and add the same "Highlight" formula field. This time set the operator as "not equal to" and select value as "1". Set this to another color and click OK.

6. You should now see that the highest and lowest are colored in Black whereas the rest are another color.

7. Next, highlight one of the bars > Right-click and select Chart options > Set the Overlap as -10.

8. Suppress the section that holds the crosstab.

I hope this helps.

-Abhilash

abhilash_kumar
Active Contributor
0 Kudos

Hi Kenshin,

What is datasource of this report? Is it a Command SQL or tables?

-Abhilash

former_member548403
Participant
0 Kudos

A command SQL.

select year, CallTypeGrp1, incident_hour, count(*) as count
from vw_all_incidents
where year = 2018
and CallTypeGrp1 = '{?CallTypeGrp1}'
group by CallTypeGrp1, incident_hour, year
order by year, incident_hour