Is it possible to orient labels differently ?

Answered (Verified) This post has 2 verified answers and 5 replies

Not Ranked
Posts: 5
giltnerj0 Posted: Mon Nov 23, 2009 @ 8:40 AM
In my chart some of the XAxis labels are too long and are combining with the next bar. Is there a way to orient the text vertically instead of horizontally ? Thanks

Answered (Verified) Verified Answers

Top 25 Contributor
Posts: 186
Answered (Verified) dusko Posted: Tue Nov 24, 2009 @ 10:45 AM
Verified by giltnerj0

Hi,

You can set angle axis annotation angle like this:

 

Therefore, you are setting the angle to an axis annotation level, because an annotation may have more than one level.

<ch:Chart  ...>
  <ch:Chart.XAxis>
    <ch:Axis  >
      <ch:Axis.Annotation>
        <ch:AxisAnnotation>
          <ch:AxisAnnotation.Levels>
            <ch:AxisAnnotationLevel Angle="90"/>
          </ch:AxisAnnotation.Levels>
        </ch:AxisAnnotation>
      </ch:Axis.Annotation>
    </ch:Axis>
  </ch:Chart.XAxis>
  <ch:Chart.DataSeries >
   ...
  </ch:Chart.DataSeries>
</ch:Chart>

Therefore, you are setting the angle to an axis annotation level, because an annotation may have more than one level. You may also try angle -90, or any other angle.

 

I hope this helps.

Not Ranked
Posts: 5
Answered (Verified) giltnerj0 Posted: Mon Nov 30, 2009 @ 5:13 AM
Verified by dusko
I chose to do it from code behind as well, just use the same properties.

if

 

(Chart.XAxis.Annotation != null)

{

Chart.XAxis.Annotation.Levels.Clear();

}

 

else

{

Chart.XAxis.Annotation =

new AxisAnnotation();

}

 

AxisAnnotationLevel annotation = new AxisAnnotationLevel();

annotation.Angle = -30.00;

Chart.XAxis.Annotation.Levels.Add(annotation);

All Replies

Top 25 Contributor
Posts: 186
Answered (Verified) dusko Posted: Tue Nov 24, 2009 @ 10:45 AM
Verified by giltnerj0

Hi,

You can set angle axis annotation angle like this:

 

Therefore, you are setting the angle to an axis annotation level, because an annotation may have more than one level.

<ch:Chart  ...>
  <ch:Chart.XAxis>
    <ch:Axis  >
      <ch:Axis.Annotation>
        <ch:AxisAnnotation>
          <ch:AxisAnnotation.Levels>
            <ch:AxisAnnotationLevel Angle="90"/>
          </ch:AxisAnnotation.Levels>
        </ch:AxisAnnotation>
      </ch:Axis.Annotation>
    </ch:Axis>
  </ch:Chart.XAxis>
  <ch:Chart.DataSeries >
   ...
  </ch:Chart.DataSeries>
</ch:Chart>

Therefore, you are setting the angle to an axis annotation level, because an annotation may have more than one level. You may also try angle -90, or any other angle.

 

I hope this helps.

Not Ranked
Posts: 6
sjharris7 Posted: Thu Nov 26, 2009 @ 5:42 AM
Hi,

I need to do exaclty the same thing as giltnerj0 but I am doing it dynamically so I would like to know how to do it in the code behind?

Si
Not Ranked
Posts: 5
Answered (Verified) giltnerj0 Posted: Mon Nov 30, 2009 @ 5:13 AM
Verified by dusko
I chose to do it from code behind as well, just use the same properties.

if

 

(Chart.XAxis.Annotation != null)

{

Chart.XAxis.Annotation.Levels.Clear();

}

 

else

{

Chart.XAxis.Annotation =

new AxisAnnotation();

}

 

AxisAnnotationLevel annotation = new AxisAnnotationLevel();

annotation.Angle = -30.00;

Chart.XAxis.Annotation.Levels.Add(annotation);

Not Ranked
Posts: 6
lesnikowski Posted: Thu Jun 9, 2011 @ 9:18 AM
This simply does not work in the latest release.

First you'll get bunch of NullReference from AxisAnnotationLevel.ActualFormattingString

If you specify empty FormattingString, exceptions will not by thrown but it will stil not work.

Here's the xaml I use:

<cart:XYChart.XAxis>
            <cart:Axis>
                <cart:Axis.Annotation>
                    <cart:AxisAnnotationScheme>
                        <cart:AxisAnnotationScheme.Levels>
                            <cart:AxisAnnotationLevel FormattingString="" Angle="90"/> 
                        </cart:AxisAnnotationScheme.Levels>
                    </cart:AxisAnnotationScheme>
                </cart:Axis.Annotation>
            </cart:Axis>
        </cart:XYChart.XAxis> 
Top 25 Contributor
Posts: 186
dusko Posted: Thu Jun 9, 2011 @ 9:51 AM

In the 2011.1 release you can rotate annotations as follows:

<ch:XYChart ...>
    <ch:XYChart.XAxisArea>
        <ch:AxisCoordinates Angle="90"/>
    </ch:XYChart.XAxisArea>
</ch:XYChart>
Page 1 of 1 (6 items)