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

Message ListMessage List     Post MessagePost Message

  X-axis labels as 3-row table
Posted by at on Sep-27-2023 18:04
Attachments:
Hi Peter, need your advice on the best way to make the x-axis labels converted into a table with 3 rows (see attached)? I'm aware of the makeLabelTable API but it's only one row and seems not compatible if the axis has label step?
1. The original labels are in the format Label1-Label2-Label3 and should be broken down when pass for drawing.
2. If the neighboring labels are the same, it should span into one column only.
3. Should be compatible with zooming feature and label step if possible.

Thanks.
Screen Shot 2023-09-27 at 17.42.35 PM.png
Screen Shot 2023-09-27 at 17.42.35 PM.png

230.14 Kb

  Re: X-axis labels as 3-row table
Posted by Peter Kwan on Sep-28-2023 03:07
Hi at,

The makeLabelTable can achieve what you need.

The makeLabelTable returns a CDMLTable object, that is pre-filled with one row of cells containing the x-axis labels. The CDMLTable object allows you to modify the table. You can modify the cells, add more rows or columns to the table, etc. For example, the following sample code adds 3 extra rows to the table and fill them with 3 arrays. It also adds one more column and fill it with icons.

https://www.advsofteng.com/doc/cdphp.htm#datatable.htm

The CDMLTable.setCell API also allows you to add content to a cell that spans multiple rows and columns. For example, the following code will change the top row (the row that contains the x-axis labels), so that only half of the labels are visible and each label will span two columns and the labels will be rotated by 90 degrees.

# Create the initial table
$table = $c->xAxis->makeLabelTable();

# Modify the top row to show only half of the labels
for ($i = 0; $i < count($labels); $i += 2) {
    #Each label occupies two cells
     $table->setCell($i, 0, 2, 1, $labels[$i]);
}

# rotate content by 90 degrees
$table->getRowStyle(0)->setFontAngle(90);


For your case, instead of using fixed column count of 2, you can write some code to determine how many columns a label should occupy and use it to add the cell.

Best Regards
Peter Kwan