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

Message ListMessage List     Post MessagePost Message

  text box in plot area
Posted by Roeber on Sep-09-2025 18:00
Hi,

sometimes the names of the Y-axis are quite long. What I would like to do is either:

rotate them by 90° (so they appear horizontally), or

create a text box that shows the name in the top-left corner of the plot area (or more generally, positioned relative to the plot area). Simply using the plot area offset does not help, was thera are some hidden axis offsets I have no access to.

How can I achieve this?

Thanks in advance!

  Re: text box in plot area
Posted by Peter Kwan on Sep-09-2025 23:05
Hi Roeber,

ChartDirector is very flexible  and it should be able to achieve what you need.

I am not too sure exactly how you want to put the axis name. In any case, there are several ChartDirector examples that demonstrate different ways to position the y-axis title. As I do not know which programming language you are using, I just random use the .NET version of the sample code as examples.

In most of the sample code, the y-axis is rotated by 90 degrees so the text flows from bottom to top vertically. See:

https://www.advsofteng.com/doc/cdnet.htm#colorbar.htm

You can certain rotate the y-axis title by 90 degrees so that it flows horizontally from left to right, top to bottom. See:

https://www.advsofteng.com/doc/cdnet.htm#depthbar.htm

You can also put the y-axis title at the top of the axis, like:

https://www.advsofteng.com/doc/cdnet.htm#multiaxes.htm

To "create a text box that shows the name in the top-left corner of the plot area", you just need to add a textbox to the top-left corner of the plot area, and set its alignment to bottom-right. In C# code, it is like:

c.addText(c.getPlotArea().getLeftX(), c.getPlotArea().getTopY(), "Some Text", "Arial Bold", 8, 0x000000, Chart.BottomRight);

In the above, the "c.getPlotArea().getLeftX(), c.getPlotArea().getTopY()" is the (x, y) coordinates of the top-left corner of the plot area. The alignment "Chart.BottomRight" means the bottom-right corner of the textbox is positioned at the given (x, y) coordinates, which is the top-left corner of the plot area.

If you need further help. please inform me what is your programming language. You may provide an image to help me understand the layout you want to use.

Best Regards
Peter Kwan

  Re: text box in plot area
Posted by Roeber on Sep-10-2025 14:33
Attachments:
Hi, thank you for the help. Unfortunately , the 'left' lignment does not work. I use C++.
It seems the 'left' alignment always starts at the chart left side not the plot area. I send you some screenshots. I do

does not work:
      tb = chart.addText(chart.getPlotArea()->getLeftX(), chart.getPlotArea()->getTopY(), qPrintable(dataSettings->name));
      tb->setAlignment(Chart::TopLeft);


works:
      tb = chart.addText(chart.getPlotArea()->getRightX(), chart.getPlotArea()->getTopY(), qPrintable(dataSettings->name));
      tb->setAlignment(Chart::TopRight);
Screenshot 2025-09-10 082937.png
Screenshot 2025-09-10 082909.png

  Re: text box in plot area
Posted by Roeber on Sep-10-2025 15:13
Ah, I found the solution. I need to call packPlotAReay first, then it works as expected.