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

Message ListMessage List     Post MessagePost Message

  Axis.setLabels() appears to not be working
Posted by David Thielen on Feb-23-2021 07:59
Hi;

I may not understand something (likely). But I have a problem where I believe I am setting the X axis correctly and yet it does not render the axis. The code is very complex so creating a sample program would take hours.

XYChart chart;

But what I have found is I call chart.xAxis().setLabels(arrayString) which passes an array of strings in the form "02-10". Right after calling that, I call chart.xAxis().getLabelTable() and it returns null.

Shouldn't it be returning the labels I passed in?

Or does XYChart require numbers or dates for both axis?

thanks - dave

  Re: Axis.setLabels() appears to not be working
Posted by Peter Kwan on Feb-23-2021 11:57
Hi David,

I think you have call makeLabelTable first.

CDMLTable t = chart.xAxis().makeLabelTable();

See:

https://www.advsofteng.com/doc/cdnet.htm#Axis.makeLabelTable.htm

An example that uses Axis.makeLabelTable is at:

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

If later in your code, you want to obtain the CDMLTable already created (instead of re-creating a CDMLTable), you can use Axis.getLabelTable.

Regards
Peter Kwan

  Re: Axis.setLabels() appears to not be working
Posted by David Thielen on Feb-23-2021 21:17
Attachments:
Hi;

Ok, I totally misunderstood what the label table is. So please forget that part.

The problem is our code renders the X axis for all the charts except one. Below is both what I want (X axis rendered) and what I'm getting (no X axis or tick marks). The calls I am making are:

axis.setColors(0xFF000000, Chart.TextColor, Chart.TextColor, Chart.Transparent);
axis.setTickWidth(3, 3);
axis.setTickLength2(12, 12)
axis.setWidth(3);
axis.setTickColor(0xFF000000, 0xFF000000);
axis.setLabelGap(25);
axis.setLabelStyle("Calibri", 31.25, 0xFF000000, 0);
axis.setTickOffset(0.5);

// arrLabels is String[30] with values like "02-10"
axis.setLabels(arrLabels);

axis.setIndent(true);

// yes called again - same array of same strings
axis.setLabels(arrLabels);

// not sure what/why this is here
for (int i=0; i<31; i++)
    axis.addLabel(i - 0.5, "-");

??? - thanks - dave
want.png
get.png

  Re: Axis.setLabels() appears to not be working
Posted by Peter Kwan on Feb-23-2021 22:26
Hi David,

The 0xFF000000 is the transparent color.

The first line axis.setColors sets the text color to the default text color (Chart.TextColor), but then another line code axis.setLabelStyle sets the text color to 0xFF000000 (transparent). May be you can try to use the color 0x000000 (black) or 0x444444 (dark grey) instead.

Regards
Peter Kwan

  Re: Axis.setLabels() appears to not be working
Posted by David Thielen on Feb-25-2021 01:16
Hi Peter;

Ok, so this is the inverse of Java then. In Java:

The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0 - 1.0 or 0 - 255. An alpha value of 1.0 or 255 means that the color is completely opaque and an alpha value of 0 or 0.0 means that the color is completely transparent.

ref: https://docs.oracle.com/javase/7/docs/api/java/awt/Color.html#:~:text=The%20alpha%20value%20defines%20the,the%20color%20is%20completely%20transparent.

??? - thanks - dave

  Re: Axis.setLabels() appears to not be working
Posted by David Thielen on Feb-25-2021 01:18
Hi again;

And Chart.TextColor is declared as 0xFFFF0002. Wouldn't this mean that the default text color is fully transparent?

??? - dave

  Re: Axis.setLabels() appears to not be working
Posted by Peter Kwan on Feb-25-2021 14:46
Hi David,

The color specification for ChartDirector is at:

https://www.advsofteng.com/doc/cdjava.htm#colorspec.htm

ChartDirector supports many programming languages, and can be used for desktop applications as well as web applications. Our design is to try to make sure the same code structure can run in different programming languages, so it may not follow some conventions of any particular programming language.

In ChartDirector, you can specify only the RGB component, like 0x000000 for black and 0x00FF00 for green. This is the most common color specification. For example, most color pickers use this convention.

https://www.w3schools.com/colors/colors_picker.asp

The above is the reason why ChartDirector uses 00 to mean fully opaque. In the Java convention, all 6 digits color must be fully transparent, as 0x00FF00 is the same as 0x0000FF00 in Java. The ChartDirector method is compatible with 6 digit color as well as 8 digit color.

All fully transparent colors like 0xFFFF0000 and 0xFF000000 are completely invisible and look the same. We do not need so many fully transparent colors. We only need one fully transparent color. In ChartDirector, it is Chart.Transparent (which is 0xFF000000). All other colors of the form 0xFFXXXXXX are reserved to have special meaning. That why in ChartDirector, any API that accepts 32-bit integer colors can also accept gradient colors, pattern colors, etc.. These colors are mapped to the reserved color range. That's is also why the default text color 0xFFFF0002 is not fully transparent. (It is in the reserved color range.)

Regards
Peter Kwan