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

Message ListMessage List     Post MessagePost Message

  About addTitle method
Posted by Daniel on Oct-10-2016 17:08
Hi Peter,
My question is related to how a barchart Title is aligned into its row. I used - in vb classic - the following lines:

Dim C As XYChart
    Set C = cd.XYChart(560, 300) 'Create a XYChart object of size 560 x 300 pixels

    With C
        .setBackground .linearGradientColor(0, 0, 0, 100, &H99CCFF, &HFFFFFF), &H888888
        .setRoundedFrame
        .setDropShadow
        .addTitle("Orange WO's by week", "timesbi.ttf", 18).setMargin2 0, 0, 16, 0
    End With

Now, using the setMargin2 method I expected to be able to set the first argument (leftMargin) as I want but it doesn't have any effect, either it is set to zero or greater ...
All my attempts to move the title on the left side failed. It seems that addTitle in conjunction with setMargin2 will align always the title on the center. To avoid this, I saw in your samples that you prefer to create a textbox followed by its setAlignment method :

Set textbox = c.yAxis().setTitle("Title X")
Call textbox.setAlignment(cd.TopLeft2)

The question is : Do I have any possibility to arrange the title on the left-right side (horizontally) using only one statement with .addTitle method ? Thank you in advance.

Regards,
Daniel

  Re: About addTitle method
Posted by Peter Kwan on Oct-10-2016 18:45
Hi Daniel,

The addTitle will automatically configured the title to be on the top-center. The addTitle2 permits several other commonly used positions. For example:

Call c.addTitle2(cd.TopLeft, "Orange WO's by week", "timesbi.ttf", 18)

An example is at:

http://www.advsofteng.com/doc/cdcom.htm#polarspline.htm

If you need even more flexibility, you would need to use BaseChart.addText.

Hope this can help.

Regards
Peter Kwan

  Re: About addTitle method
Posted by Daniel on Oct-11-2016 17:09
Hi Peter,
Thank you for your quick response. The addTitle2 method doesn't help too much because it has no granularity between cd.left and cd.center...Just for the sake of curiosity, why don't you merge these two methods in only one more functional ? On the other way, the addText has the whole flexibility what I need (in terms of x, y moving). But, as an interesting thing, meanwhile I succeeded to move the title on the left side - via addTitle method - using in setPos method negative values ...So setPos did the trick inside addTitle :

.addTitle("Orange WO's by week", "timesbi.ttf", 18).setPos -50, 16

Sometimes I feel many functions and methods within ChartDirector should be reconsidered / rewritten or simplified a bit even overall CD is one of the best charts library in the world.

Regards,
Daniel

  Re: About addTitle method
Posted by Peter Kwan on Oct-11-2016 22:26
Hi Daniel,

I think if we allow the position to be determined like addTitle(xPos, yPos, "My Title" ...), then it is just them same as addText(xPos, yPos, "My Title", ....). For your case, I wonder why you do not just use addText instead of addTitle?

When we design the API, originally there is the addText API, which can put text anywhere. Then we think the most common case is for the text to be used as the chart title, so we created another API addTitle, which is the same as addText, but is preconfigured for certain positions. Internally, addTitle just calls addText. That is why addTitle does not have detail position, otherwise it is the same as addText.

Anyway, for many text manipulation, there is also a features called CDML which is much more flexible. You can even specify multiple fonts and colors and vertical and horizontal offsets for the title text. See:

http://www.advsofteng.com/doc/cdcom.htm#cdml.htm

Hope this can help.

Regards
Peter Kwan

  Re: About addTitle method
Posted by Daniel on Oct-12-2016 16:25
Hello Peter,
You are right, addText is more flexible than addTitle but all the more considering they have internally a common structure you could reduce both methods to one allowing both x,y parameters and cd.center (top, bottom,left and right). For example would be interesting to have posibility to set x at a certain value and instead y to put cd.center. I think you get the idea, you could mix the preconfigured positions with x,y properties and in this way you will cover all needs and options. Anyway, your library is very rich in possibilities. Is it written in C++ ? Thank you for your support. I intend to post a new message because I don't have any idea how to put a black border around some bullets displayed in the legend box ...