Thursday, March 29, 2012

Draw Axis on Barchart

Hi,

I have a little problem with my barchart.
The chart shows negative and positive values and i want a simple vertical black line at 0.
But I havent found any solutions for this problem yet that satisfies me.

What I tried:
- Draw a normal line and place it above the graph -> doesnt work in all renderers
(Overlapping Reportitems are not supported ....)

-with the parameter "Cross At"
i have labels on the axis and if i "cross at" 0, the labels also move into the middle and overlap
with the bars/point labels

- with Gridlines (so far the best solution)
Chart with a fixed range (for example -100 to +100) and set the gridline interval to 100
this prints 3 Gridlines, 1st at -100, 2nd at 0 (what I want) and a 3rd at +100 - that would be ok for me
BUT i need a variable chart range!
so if the chart range goes from -100 to +200, i have a gridline at +100 crossing all bars !!

here are some pictures of my problem

what i want:
http://www.hmayer.net/show_image.php?id=4387&scaled&scalesize=800&nocount=y

what i got:
http://www.hmayer.net/show_image.php?id=4386&scaled&scalesize=800&nocount=y

any other ideas?

thanks,
GerhardYou can accomplish this with the following expression, if you are willing to have the min and max for the axis be the same absolute value. The expression calculates the largest value, in absolute terms, and sets the min(with negation), max and major interval properties on the Y-axis to this expression.

Min:

=-Math.Max(Max(Fields!FieldName.Value), Math.Abs(Min(Fields!FieldName.Value)))

Max:
=Math.Max(Max(Fields!FieldName.Value), Math.Abs(Min(Fields!FieldName.Value)))

Major Interval:
=Math.Max(Max(Fields!FieldName.Value), Math.Abs(Min(Fields!FieldName.Value)))

Note: Expressions for these properties are not su supported in RS 2000

Another approach would be to set the Cross At to 0 and not use tick marks or axis labels on the axis. Instead of using the labels, you could use a table placed beside the chart that contains these values. It may be tricky to get the labels line up correctly--make sure to sort the category group and the table the same way.

Ian

No comments:

Post a Comment