|
Chart Formatting |
Posted by Tom on Aug-13-2011 04:58 |
|
Hi,
I have two small questions.
Firstly, is there a way to format the y-axis so the labels are left aligned instead of right aligned?
Secondly, my chart has major and minor ticks on the y-axis and only major ticks on the x-axis. The color of the minor y- and major x- are the same color and the major y- ticks are a darker color. Currently the ticks of the x-axis are drawn over the darker ticks of the y-axis. Is there a way to change this so the y-axis ticks are drawn over the x-axis ticks?
Thank you in advance for any help.
Tom |
Re: Chart Formatting |
Posted by Peter Kwan on Aug-14-2011 00:08 |
|
Hi Tom,
1. The y-axis labels can be "left aligned". But you need to specify what should the labels aligned to.
Suppose you want the labels to left aligned to the left edge of the chart. The code is like (Java/C#):
ChartDirector.TextBox t = c.yAxis().setLabelStyle("arial.ttf", 8);
t.setSize(c.getPlotArea().getLeftX(), 0);
t.setAlignment(Chart.Left);
2. Is the y-axis scale specified by your code (as opposed to automatically determined by ChartDirector)? If your code specifies where are the major ticks, you can use addMark to draw mark lines for the y-axis instead of using major grid lines. The code is like:
//assume the y-axis scale is 0 - 100, and there is a major grid line every 10 units
for (int y = 10; y < 100; y+= 10)
c.yAxis().addMark(y, majorGridLineColor);
Hope this can help.
Regards
Peter Kwan |
Re: Chart Formatting |
Posted by Tom on Aug-16-2011 07:07 |
|
Thank you Peter, both of your suggestions worked wonderfully.
I have had one more issue arrive and I hope you can help me out again.
I am trying to put a title/label at the end of the x-axis.
I have tried using the axis setMultiFormat to set the last tick to the title, which works great if the last tick is near the end of the graph, but it doesn't have to be.
I have also tried the axis setTitle method with an offset, which would also work great, except when there is a tick near the end of the graph in which case the label and title overwrite each other.
Any guidance would be appreciated.
Thank you,
Tom |
Re: Chart Formatting |
Posted by Peter Kwan on Aug-16-2011 16:38 |
|
Hi Tom,
You may add an axis title using the BottomRight or Right alignment. For example:
c.xAxis().setTitle("USD (millions)", "Arial Bold", 10).setAlignment(Chart.BottomRight);
Hope this can help.
Regards
Peter Kwan |
Re: Chart Formatting |
Posted by Tom on Aug-16-2011 22:35 |
|
Thank you.
You help was much appreciated.
Tom |
|