Jump to content
Software FX Community

Wrap label´s text in Axes


Pagotti

Recommended Posts

Unfortunately, Chart FX API does not provide a property to customize Label text area height. You should reduce the text you are currently sending to axis labels. As a workaround, you can change label angle (chart1.AxisX.LabelAngle = 45;). I hope this helps.

Regarding the word-wrap question, you can't word-wrap on the axis as you can in a title.  As a suggestion - you can use the KeyLabels property (see API reference for details) to assign a short "nick name" to the axis itself and reserve the longer names for the legend box

Link to comment
Share on other sites

Edit: A little better results, less code. Forgot about the LabelTrimming property...

Chart1.AxisX.MaxSizePercentage = 30;
Chart1.AxisX.LabelTrimming = System.Drawing.StringTrimming.EllipsisWord;

 I might have found something that could help you. There is a property in the Axis class called MaxSizePercentage. It will limit the space taken by the axis as a percentage, but in a brute way. It will clip the begining of the string. To avoid that you could force the clipping of the end of the string, using the GetAxisLabel event. Make sure you turn on Notify for the Axis.

Chart1.AxisX.MaxSizePercentage = 30;
Chart1.AxisX.Notify = true;
Chart1.GetAxisLabel += new AxisLabelEventHandler(Chart1_GetAxisLabel);

 And...

protected void Chart1_GetAxisLabel(object sender, AxisLabelEventArgs e)
{
  if (e.Axis == Chart1.AxisX)
  {
  if (e.Text.Length > 13)
  {
  e.Text = e.Text.Substring(0, 10) + "...";
  }
  }
}

post-2902-1392240967221_thumb.png

Link to comment
Share on other sites

Hi.

The version that I use is 6.2 and I not found this properties (MaxSizePercentage and LableTrimming), but this approach give me an ideia.

I try to use Notify and GetAxisLabel event to insert a '\n' character in strings that has a certain size defined by a parameter or a percentage of total height of the control or to use KeyLabels with same technique.

If this work I post result here.

Thanks again!

Link to comment
Share on other sites

  • 2 weeks later...

Hi!

I tried to insert the '\n' char in text to force a break line, but the labels remain in one line.

I configure the AxisX.Style = AxisX.Style and (not SingleLine), but the result is an one line of text in X Axis.

How can I tell to control to be a multline for the labels on X Axis and dysplay it correctly?

Can you give me a sample?

Thanks!

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.

×
×
  • Create New...