|
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 David Thielen on Feb-23-2021 21:17 |
|
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
|
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: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 |
|