|
Missing Negative Signs in Labels |
Posted by Karl Ruetz on Jul-16-2014 23:08 |
|
I am using Qt 5.3.0/gcc and ChartDirector 5.1 on MacOS 10.9.4.
I am creating a histogram using an XYChart and addBarLayer.
Here is the data:
0
0
6
18
114
471
651
96
18
1
Here are the labels:
-43.133
-36.613
-30.092
-23.572
-17.052
-10.532
-4.012
2.508
9.029
15.549
Here is the addBarLayer call:
xycHist->addBarLayer(DoubleArray(rBucketCnts, iBuckets), 0x33CC33);
Here is the setLabels call:
xycHist->xAxis()->setLabels(StringArray(psNames, iBuckets));
I have uploaded the resulting chart as an attachment.
The problem is the minus signs are missing from the labels. I am I doing something wrong?
Thanks!
|
Re: Missing Negative Signs in Labels |
Posted by Peter Kwan on Jul-17-2014 01:00 |
|
Hi Karl,
In ChartDirector, if string labels are used in Axis.setLabels, the leading minus character will
be treated to mean the label should have a minor tick, and the character will not be
actually rendered. If you look carefully, you can see the tick for the labels with the leading
minus character is slightly shorter.
To actually draw the minus character, you would need to use \\-43.133 (add the backslash
as the first character). Note that in C++, if entered as string literals in C++ source code,
the backslash is the escape character, and a backslash character needs to be entered as
"\\\\".
If all your labels are numbers, another method is to use the numbers as the labels, not the
text strings, that is, use DoubleArray for the labels, not StringArray. In this case, the
negative numbers will be plotted with a leading minus character.
Hope this can help.
Regards
Peter Kwan |
Re: Missing Negative Signs in Labels |
Posted by Karl Ruetz on Jul-17-2014 01:37 |
|
Worked perfectly, thank you. |
|