Page 1 of 1

X-axis increment, min and max

Posted: Mon Aug 18, 2008 7:01 pm
by 7667591
Hi,

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();

panel.add(chart);
FastLine fastLine = new FastLine(chart.getChart());
for (int i = 0; i < 12; i++) {
if ((i != 3) && (i != 7))
fastLine.add(i * i, " " + i);
}

//comment for first run
chart.getAxes().getBottom().setAutomatic(false);
chart.getAxes().getBottom().setIncrement(2.0);
chart.getAxes().getBottom().setMaximum(22.0);
chart.getAxes().getBottom().setMinimum(2.0);
//end of comment

frame.add(panel);
frame.setSize(600, 600);
frame.setVisible(true);
}
}


Do you think that the example program given above is working fine ?
Please run the program by commenting out the axis labels related settings first and for the second run use it as it is.


Thanks,
Varun

Posted: Tue Aug 19, 2008 11:42 am
by Pep
Hello Varun,

in case you want to set the minimum and maximum for an axis you have to use the SetMinMax method instead of set min and max separately :

chart.getAxes().getBottom().setMaximum(22.0);
chart.getAxes().getBottom().setMinimum(2.0);

should be :

chart.getAxes().getBottom().setMinMax(2.0,22.0);

Posted: Tue Aug 19, 2008 2:44 pm
by 7667591
Hi,

I do not think that there is difference in setminmax and setminimum, setmaximum.
At least I am getting the same result.
Did you see the chart generated using the code which I have posted earlier ?

Do you think that the axis labels are correct ? Is it following the rules set for min, max and increment ?

Thanks,
Varun

Posted: Thu Aug 21, 2008 11:16 am
by Pep
Hi Varun,

the problem is that in you code you use the Add method assign a label for each point, and as it does not add any point greater than 11 you labels from 11 to 22 (are " " + i ) are no added, so they are invisible, to solve this you should use simply :

fastLine.add(i * i);

Posted: Thu Aug 21, 2008 2:31 pm
by 7667591
Hi,

It was just a simple example but in real scenario we are not going to use add(double). Either you did not understand my question or TeeChart is falling short in so many places. What I have understood from my experiments with TeeChart is that, setminimum, setmaximum, setincrement will work only in few cases. My requirement is very simple to say,

min, max and increment for axes should work irrespective of the way in which the series is created. You have more than 10 overloaded add() methods in Series.

Thanks,
Varun

Posted: Fri Aug 22, 2008 8:54 am
by Pep
Hi Varun,

the important part here is the point labels, TeeChart does not allow to specify an axis label for point and then specify an increment. The only way to specify an increment would be by having the axis label style assigned to Value, this will allow to calculate the increment.
We already have this feature on our wish list ( allow to specify increment having axis labels style as TEXT ).
For the moment, a way around this would be to add the axis labels manually, once the series has been displayed. For example :

tChart2.getAxes().getBottom().getLabels().getItems().add(2);