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

Message ListMessage List     Post MessagePost Message

  background image plus text in a table's cell
Posted by Wacky on Jul-08-2014 22:44
Hi,

i'm trying to make some table as i have a varying number of lines.

it works very well, but it seems, as i wish to add some text in the same cell above an image (for example, the number 1 above a triangle, 2 above a round, ...), that the first cell (with the image) is erase by the second.

i would like to know if it's normal or if i could do that ?

thanks,

  Re: background image plus text in a table's cell
Posted by Peter Kwan on Jul-09-2014 04:53
Hi Wacky,

I am not too sure if I understand your enquiry.

Consider the "Data Table (1)" sample code. In that example, the table contains icons, which
are images. The icons are added to the table cell using the code (in C#):

table.setText(0, 1, layer.getLegendIcon(0))

To add a "1" above the icon image in the same cell, you can simply change the code to:

table.setText(0, 1, "1\\n" + layer.getLegendIcon(0))

In the above, the cell contains include "1", followed by a line break "\\n", followed by the
icon image. Is this what you need?

Regards
Peter Kwan

  Re: background image plus text in a table's cell
Posted by Wacky on Jul-09-2014 14:52
Attachments:
Hi Peter,

thanks for your response,

i'd like to insert the number in the image, like in the attachment file.

i had try with the code below (in php) :

// gom
$this_cell = $table->setCell(1, $table->getRowCount() - 1, 1, 1, "<*block, width=50, halign=center *><*img=../../css/img/round_green.png*><*/*>");

// value
$this_cell = $table->setText(1, $table->getRowCount() - 1, 1);
$this_cell->setBackground(Transparent, Transparent);

only the image works, as only the text, but the two at the same time seems the second replace and erase  the cell before writing in it.

Wacky
round_1.png

  Re: background image plus text in a table's cell
Posted by Peter Kwan on Jul-10-2014 01:54
Hi Wacky,

It is normal that putting text to one cell with replace existing content on that cell. Even if
you are manipulating HTML table with Javascript, you would get the same behaviour.

For your case, may be you can try to use something like:

<*block, width=50, halign=center *><*img=../../css/img/round_green.png*<*/*>
\\n<*block,width=50,height=1,halign=center,valign=bottom*><*yOffset=10*>1<*/*>

The CDML above contains an image icon and the text "1" in two lines. The second line is
configured to be a block 1 pixel in height with bottom alignment. It means the bottom of the
text is aligned with the bottom of the block. As the box is only 1 pixel in height, most of the
text will overflow the top border of the block and go into the first block (the image) above it
and overlap with the image. To position the text at the center of the image, we need to
apply an additional yoffset, rough equal to the (height_of_icon - font_size) / 2.

Hope this can help.

Regards
Peter Kwan

  Re: background image plus text in a table's cell
Posted by Wacky on Jul-16-2014 15:13
Hi Peter,

it works very well,
a great thanks to you and you library !

Wacky