Jump to content
Software FX Community

Y-Axis Label Justification / Wrapping


MMCCPaulEden
 Share

Recommended Posts

Hi

 If you have large y-axis labels on a Gantt chart (50+ characters) the label texts have a tendency to not display correctly with either the text justification pushing the labels outside the bounds of the control or overflowing the bounds.  Is it possible tomake your lables wrap text instead?

 

Thanks

 

Paul

Link to comment
Share on other sites

The reason why sometimes you might get a clipped axis is because there is a property (PlotArea.MinSize) that assigns a minimum percentage of the available space to the plotarea. If you would rather have the axis unclipped you can use the following XAML

<cfx:Chart.PlotArea>  <cfx:PlotAreaAttributes MinSize="0"/></cfx:Chart.PlotArea>

Although we have no properties to easily word wrap the labels in an axis, we should be able to support this through templating. There is a small bug preventing this scenario. As soon as it is fixed you will be able to do something like

<cfx:Chart.AxisX>  <cfx:Axis>   <cfx:Axis.Template>   <DataTemplate>   <TextBlock Width="90" Text="{Binding Path=DataItem.Name}" TextWrapping="Wrap" Foreground="{Binding Path=Foreground}" FontFamily="{Binding Path=FontFamily}" FontSize="{Binding Path=FontSize}"/>   </DataTemplate>   </cfx:Axis.Template>  </cfx:Axis></cfx:Chart.AxisX>

Regards,

JuanC

Link to comment
Share on other sites

Hi

We're having trouble making this work. 

Given the Template of:


<Window.Resources>

<!-- //' Axis-x label wrapping-->

<DataTemplate x:Key="ChartLabel" >

<TextBlock Width="50" Text="{Binding Path=DataItem.Name}" TextWrapping="Wrap" Foreground="Black" FontFamily="{Binding Path=FontFamily}" FontSize="{Binding Path=FontSize}"/>

</DataTemplate>

</Window.Resources>
Setting the Axis-x labels manually(for testing):

oChart.AxisX.Labels.Items.Add(

"really very quite long lbl2");oChart.AxisX.Labels.Items.Add("really very quite long lbl3");

oChart.AxisX.Labels.Items.Add(

"really very quite long lbl4");
Applying template:

oChart.AxisX.Template = Resources[

"ChartLabel"] as DataTemplate;

When the above compiles the axis-x labels go not appear - I can understand that DataItem.Name doe snot exist (that is the compiler message that get generated) but I can't fathom what the binding should be.

 

Many thanks

Paul

Link to comment
Share on other sites

There is a check in our code that will prevent you from templating axis labels when you are not using Chart.ItemsSource, if this was only for testing wrapping in the current build you will have to create a collection of simple CLR objects with 2 properties (one numeric to be plotted and a string property to use in the X axis) and use Chart.ItemsSource to populate the chart with it.

We will support axis labels templating with manual data in future builds and your binding will be to either DataItem or Text, e.g.

<TextBlock Text="{Binding Path=DataItem}"/>

Regards,

JuanC

Link to comment
Share on other sites

If you are passing data to the chart using Chart.ItemsSource but need to pass labels manually then you will have to bind to Text because DataItem will point to your CLR object.

We should have a new hotfix including support for this in a couple of days.

Regards,

JuanC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...