ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How do I wrap addText to a new line after 40 characters?
Posted by ARJ DESIGNS on Jan-12-2012 03:16
I am adding text to a Angular Meter.  How do I wrap addText to a new line after 40
characters?  Is there a addText attribute?

Or should I use:

Dim m As AngularMeter

Dim _str As String
Dim _length As Integer
Dim _count As Integer
Dim _subStr As String

_str = mTitle.Text
_length = 0
_count = 0
_subStr = ""

While _length < _str.Length
_length += 40
_str = If(((_length + _count) >= (_str.Length)), _str, _str.Insert(_length +
_count, vbLf))
_count += 1
End While

m.addText(200, 40, _str, "arialbd.ttf", 12, Chart.TextColor, Chart.Center)

  Re: How do I wrap addText to a new line after 40 characters?
Posted by Peter Kwan on Jan-13-2012 01:13
Hi ARJ DESIGNS,

ChartDirector has a built-in method to wrap text if it exceeds certain length in pixels. For example, it can wrap text if it is longer than 300 pixels. It is something similar to text wrapping in a word processor or in a web page. It is not based on the number of characters.

If you must wrap text after 40 characters, you would need to use your own code to insert a line break character every 40 characters. (This is probably what your code is already doing.)

If you can modify the logic to wrap text after a certain length in pixels, you may use something like:

'Wrap text after 300 pixels
m.addText(200, 40, _str, "arialbd.ttf", 12, Chart.TextColor, Chart.Center).setMaxWidth(300)

Hope ths can help.

Regards
Peter Kwan

  Re: How do I wrap addText to a new line after 40 characters?
Posted by ARJ DESIGNS on Jan-13-2012 02:01
I tried setMaxWidth() using another number other < 300 and it seems to resize the text
area in pixels and wrap text.  It seems to work:

'Wrap text after 100 pixels
m.addText(200, 40, _str, "arialbd.ttf", 12, Chart.TextColor, Chart.Center).setMaxWidth(100)

But I think I have a bit more control with the code I am currently using by specifying when
to wrap by number of characters.  I may use this built-in method in conjunction with my
code.

Thanks.