Crystal Reports Article

How do I plot a bar chart(Graph) in Crystal Reports so that I get one color, say red to all the bars on the left of the axis and another color, say green to all bars on the right of the axis? (tested with Crystal Reports version 9.0, but should also work with version 8.5, i think)

 

How do I plot a bar chart(Graph) in Crystal Reports so that I get one color, say red to all the bars on the left of the axis and another color, say green to all the bars on the right of the axis?

You have a chart whose axis ranges from say -100 to +100 with a central axis, you need all the bars with negative values(to the left of the axis) to be in red color(or some color) and all the bars with positive values(to the right of the axis) in green or some color, as shown below.

Crystal Chart

Crystal Reports Chart


You can also plot a chart like this using the same technique, if your groups have both positive and negative values...

Crystal Chart

Crystal Reports Chart

There are two methods of doing it.

Method 1:This applies if you have both positive and negative values to be displayed in a single databse column.
1.Click Insert a Chart button
In the Chart Expert window,
2.on the Type Tab, untick the check box 'Automatically set chart options' at the top
3.select the option 'Horizontal' at the bottom of the window
4.Go to the Data tab and add the required fields to 'On change of' and 'Show value(s)' boxes
5.Go to the Axes Tab, untick the check box 'Auto range' and enter-100 in the Min box and 100 in the Max box
6.Go to the Options Tab, in the 'chart color' grid, select the option 'color' if not already selected and click 'Format' button which opens 'Chart color format expert'.
7.In the 'Chart color format expert' window, click the 'New' button, then in the 'Item editor' grid, select your field with the values to display(If you can't see your field in the drop down list, don't panic, go to Method2 discussed below), then select a condition,say 'is less than' type in 0 into the value box , then select a color from the 'Format color' list box.
8.Repeat the above step to insert another condition for a positive value.
9.click OK to close the window and again to close the chart expert.
10.Preview the report


Method 2:This applies if you have both positive and negative values to be displayed in a single databse column but can't find your field in the step 7 of Method1 above or the positive and negative values to be displayed come from two databse columns.
1.Create two formulas one containing only positive values and the other containing only the negative values. 2.Click Insert a Chart button
In the Chart Expert window,
3.In the Type Tab, untick the check box 'Automatically set chart options' at the top
4.select the option 'Horizontal' at the bottom of the window
5.Go to the Data tab and add the required field to the 'On change of' box and the formula with positive values to the 'Show value(s)' box
6.Go to the Axes Tab, untick the check box 'Auto range' and enter-100 in the Min box and 100 in the Max box
7.Go to the Options Tab, untick the check box 'Show legend' and click OK to close the chart expert.
8.Right click the chart, go to chart options-->General-->then Look tab, select 'color by series' in the color mode drop down.
9.Select a Bar, Right click, go to chart options-->Selected Item-->Fill tab, select a color, say green.
10.Right click the chart (not the inner grid), go to chart options-->Selected Item-->Fill tab, click the 'Transparent' button that's just above the color grid.
11.Create another chart exactly in the same as described above but this time adding the formula with only negative values at step 5 instead of the positive values formula and applying a different color to the bar at step 9.
12.Delete all the titles (chart options-->Titles) from the second chart.
13.Format the Data axis(numbers) and group axis of the second chart so that all the lables are invisible(such as applying white color ot them)
14.Now align both graphs, make them same size and place one over the other.
15.Preview the report (Make sure none of the graphs are selected, because if you select a graph, preview shows only the top one)

If you have any questions, shoot them to me and I'll try to have a look. My contact info on the Contact me Page.

Top

www.mahipalreddy.com
Terms and Conditions of Use
Copyright 2004 - 2006 Mahipal Padigela. All rights reserved.