Page 1 of 1

Distance between axis title and axis labels

Posted: Mon Nov 10, 2008 8:45 pm
by 7667591
Hi,

How do we control the distance between axis title and axis labels?
http://picasaweb.google.com/cbvarun/Ste ... 4912540786

Thanks,
Varun

Posted: Tue Nov 11, 2008 9:38 am
by narcis
Hi Varun,

You need to set labels CustomSize like this:

Code: Select all

        myChart.getAxes().getLeft().getLabels().setCustomSize(30);

Posted: Wed Nov 12, 2008 7:40 pm
by 7667591

Code: Select all

package com.amd.ngeda.chart.teechart;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.steema.teechart.TChart;
import com.steema.teechart.styles.FastLine;

public class Test {

	public static void main(String[] args) {
		JFrame frame = new JFrame();
		JPanel panel = new JPanel();
		panel.setSize(600, 600);
		TChart chart = new TChart();
		chart.getAxes().getLeft().getTitle().setText("Help Needed");
		chart.getAxes().getLeft().getLabels().setCustomSize(30);
		chart.getAxes().getLeft().getLabels().setValueFormat("0.00E0");
		panel.add(chart);
		FastLine fastLine = new FastLine(chart.getChart());
		for (int i = 0; i < 100; i++) {
			fastLine.add(i, i * i);
		}

		frame.add(panel);
		frame.setSize(600, 600);
		frame.setVisible(true);
	}
}
If you run this code then you will see that title and labels are overlapping.
I want to know whether I can set a min distance between AXIS TITLE and AXIS LABELS.

What is the difference between chart.getAxes().getLeft().getLabels().setCustomSize(30);
and
chart.getAxes().getLeft().getTitle().setCustomSize(30);

Thanks,
Varun

Posted: Thu Nov 13, 2008 9:57 am
by narcis
Hi Varun,

Yes, in that particular case you need to set a bigger size for the labels so that title and labels don't overlap:

Code: Select all

        chart.getAxes().getLeft().getTitle().setText("Help Needed");
        chart.getAxes().getLeft().getLabels().setCustomSize(50);
        chart.getAxes().getLeft().getLabels().setValueFormat("0.00E0");
        FastLine fastLine = new FastLine(chart.getChart());
        for (int i = 0; i < 100; i++) {
            fastLine.add(i, i * i);
        }
What is the difference between chart.getAxes().getLeft().getLabels().setCustomSize(30);
and
chart.getAxes().getLeft().getTitle().setCustomSize(30);
The difference is that the first sets a custom size for axis labels while the second one sets a custom size for the axis title. As described in context sensitive help:

getLabels().setCustomSize(int value) changes the spacing occupied by the axis labels between the Ticks and the Title.

getTitle().setCustomSize(int value) sets the spacing between the axis/labels and the outer panel edge.

Posted: Thu Nov 13, 2008 2:56 pm
by 7667591
I know that a bigger size would solve it. But I was not looking for this answer. I want to set it dynamically based on the size of the labels. The axis format can be different based on the type of chart and based on the user input. At least it would have been better if teechart could do it automatically.

Posted: Thu Nov 13, 2008 3:34 pm
by narcis
Hi Varun,

Yes, this is a known issue on the list to be enhanced for future releases.

For doing something automatic you could do something like this:

Code: Select all

        myChart.getAxes().getLeft().getTitle().setText("Help Needed");
        myChart.getAxes().getLeft().getLabels().setValueFormat("0.00E0");
        FastLine fastLine = new FastLine(myChart.getChart());
        for (int i = 0; i < 100; i++) {
            fastLine.add(i, i * i);
        } 
        
        myChart.invalidate();
        int tmp = myChart.getAxes().getLeft().maxLabelsWidth();
        myChart.getAxes().getLeft().getLabels().setCustomSize(tmp);
But I found that maxLabelsWidth property is not working. I've added this defect (TJ71013569) to the list to be fixed for next releases.

Posted: Fri Nov 14, 2008 7:30 pm
by 7667591
Will you be able to provide a patch for this ??. This funtionality is very important for the look and feel of the chart.

Thanks,
Varun

Posted: Mon Nov 17, 2008 9:57 am
by narcis
Hi Varun,

This is a high priority item in the bug list to be fixed but I'm not able to give you an estimate date at the moment. When the issue is fixed we will try to send you source code files with the fix.

Posted: Fri Feb 06, 2009 11:09 pm
by 7667592
Hello Narcis,
Varun is no longer with our company. You will not be able to send him the fix any longer. Please send to me.

Thanks,
Jesse

Posted: Mon Feb 09, 2009 9:36 am
by yeray
Hi Jessie,

Ok, I've sent to your registered mail account the fix of this issue.

Re: Distance between axis title and axis labels

Posted: Thu Jul 30, 2009 8:33 am
by 12054002
We also have the same issue. Can we get the solution?

Re: Distance between axis title and axis labels

Posted: Thu Jul 30, 2009 9:18 am
by narcis
Hi mahendran,

We just replied to your other thread about the same issue:

http://www.teechart.net/support/viewtop ... 949#p41949