|
How to specify edge colors for just certain borders of cells in a LabelTable |
Posted by Patrick on Jan-13-2015 07:39 |
|
I would like to put a border between each of the vertical axis labels in the bottom row, but
no border on the top or bottom of each cell. Also, the same for each cell in the horizontal
text in the first axis label row. I've hand drawn what I would like to have in the attached
image.
I've also attached my code.
Thanks!
|
Re: How to specify edge colors for just certain borders of cells in a LabelTable |
Posted by Peter Kwan on Jan-14-2015 01:44 |
|
Hi Patrick,
Since you mentioned about "LabelTable" in the subject, I assumed the labels on the x-axis
are created as a CDMLTable using Axis.makeLabelTable. In this case, by default, there
should be borders around the cells. (Your code probably has disabled the borders.) So one
possibility for your case is to simply enable the cell borders.
If you want to just draw some vertical lines line in your message, you may try to use
custom drawing. After creating the entire chart, add the following lines of code:
//draw the chart and return the DrawArea object for additional custom drawing
DrawArea d = c.makeChart3();
//the y coordinates for the end points of the long and short lines
int y1 = c.getPlotArea().getBottomY() + 1;
int y2 = y1 + table.getRowHeight(0);
int y3 = y1 + table.getHeight();
for (int i = 0; i <= c.xAxis.getMaxValue() + 1; ++i)
d.line(c.getXCoor(i - 0.5), (i % 3 == 0) ? y1 : y2, c.getXCoor(i - 0.5), y3, 0x99aaff, 3);
Hope this can help.
Regards
Peter Kwan |
Re: How to specify edge colors for just certain borders of cells in a LabelTable |
Posted by John Schortz on Feb-16-2015 20:58 |
|
Hello Peter, this is a very timely topic as I have just discovered I can not control borders around individual label table cells. Attached is an example of my output. I am using Perl version.
I have the edge color set to white (0x00ffffff) at the table level. $dt is the "data table" from makeLabelTable:
$dt->getStyle()->setBackground(0x00ffffff,0x00ffffff);
Then I try to put a border around an individual row. I found that I can not control edge either by row or individual cell. In my example, "Prudence" row uses cell methods. I am using red edge color simply to make the border lines apparent:
$dt->getCell(0,0)->setBackground(0x004f81bd,0x00ff0000);
$dt->getCell(1,0)->setBackground(0x004f81bd,0x00ff0000);
"Realism" row uses row method:
$dt->getRowStyle(7)->setBackground(0x00ffffff,0x00ff0000);
Notice how I am not getting a bottom edge with either method?
I don't think I can control CDMLTable borders like HTML tables, where I can put borders around only the table, only a row, or only an individual cell. Drawing lines is a bit tedious, but if it's the only solution for now, it will have to do. Either way, I <3 ChartDirector, and thank you for such a great product!
|
Re: How to specify edge colors for just certain borders of cells in a LabelTable |
Posted by Peter Kwan on Feb-17-2015 06:06 |
|
Hi John,
I suspect the bottom edge is not visible because it is overwritten by the white edge of the
cell below. (The bottom edge of one cell is the top edge of the next cell.) If this is the
cause of the problem, using a transparent border color for the other cells may solve the
problem:
$dt->getStyle()->setBackground(Transparent, Transparent);
oe
$dt->getStyle()->setBackground(0x00ffffff, Transparent);
Hope this can help.
Regards
Peter Kwan |
Re: How to specify edge colors for just certain borders of cells in a LabelTable |
Posted by John Schortz on Feb-17-2015 07:26 |
|
AHA! Yes, setting the edge to transparent at the table level allowed the 'missing' edges to show through. The axis line also reappeared. Thank you very much for your quick response, and thank you to Patrick also for his question. I may just format my lines according to your response to his question because there seems to be no ability to control particular edge sides (top/bottom, left/right). Setting edge at row-level also sets edges between cells in that row. |
Re: How to specify edge colors for just certain borders of cells in a LabelTable |
Posted by Peter Kwan on Feb-18-2015 00:51 |
|
Hi John,
If your table is created using Axis.makeLabelTable on the horizontal axis (that is, the table
is either at the bottom or at the top of the plot area), on way to underline a row is to insert
an empty row and configure that empty row to be 1 pixel in height (using Box.setSize) and
set a border color for the row. Because row is only 1 pixel in height, it would appear as a
line. The line would appear to be 2 pixels in thickness (1 pixel for the top border, 1 pixel for
the bottom border).
Hope this can help.
Regards
Peter Kwan |
|