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

Message ListMessage List     Post MessagePost Message

  XY chart left axis text alignment. How do you change it?
Posted by TonyVSUK on Nov-25-2021 19:57
Attachments:
I've been trying to get the text aligned correctly, but cannot seem to do it.

The attached image shows the problem.

If I use the following code, the text is in the correct place to the left of the graph, but right aligned (top graph).

TextBox *pBox = c->yAxis()->setTitle(m_strAxisTitleYLeft, m_pfont_AxisLabels->GetFaceName(), m_pfont_AxisLabels->GetPointSize() * scale);
pBox->setAlignment(Chart::Left);


If I use this, the text is correctly aligned, but not where I want it.

TextBox *pBox = c->yAxis()->setTitle(m_strAxisTitleYLeft, m_pfont_AxisLabels->GetFaceName(), m_pfont_AxisLabels->GetPointSize() * scale);
pBox->setAlignment(Chart::Center);


I'm sure I'm missing another call somewhere, but I cannot find it in the help.

Thanks in advance,

Tony.
labelleft.jpg

  Re: XY chart left axis text alignment. How do you change it?
Posted by Peter Kwan on Nov-26-2021 00:13
Hi TonyVSUK,

Try adding "<*block,halign=center*>" before the title text, like:

c->yAxis()->setTitle((
    (std::string("<*block,halign=center*>") + m_strAxisTitleYLeft).c_str(),
    m_pfont_AxisLabels->GetFaceName(), m_pfont_AxisLabels->GetPointSize() * scale);

Most of the visual text in ChartDirector supports a the "ChartDirector Mark Up Language". See:

https://www.advsofteng.com/doc/cdcpp.htm#cdml.htm

By prepending the "<*block,halign=center*>", the entire title text becomes a single "block". The text is center aligned inside the block. The setTitle API uses the block as the title, and put it to the left of the axis (the default).

Regards
Peter Kwan