Axis bug?

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Marian
Newbie
Newbie
Posts: 8
Joined: Tue Jan 29, 2008 12:00 am

Axis bug?

Post by Marian » Wed Feb 27, 2008 4:10 pm

Hi,
I am drawing time series into a chart. The bottom axis and its corresponding labels and grid lines behave little strange. If I insert multiple series points for a period of several days with DateTime x coordinates, the first label/grid line to be shown for each particular day seems not to be the [date]/00:00 but [date]/1:00.
Also if I set the increment to one day and add two points having their datetimes set to two consecutive dates with zero hours and minutes, the labels are shown not below these two days but an hour later.
Is there a simple workaround for this? Am I possibly missing something?

Thanks,
Marian

chart.getAxes().getBottom().setIncrement(
com.steema.teechart.misc.Utils.getDateTimeStep(com.steema.teechart.DateTimeStep.ONEDAY)
);

...

Candle cse = new Candle();
DateTime d = new DateTime(2008, 2, 26);
cse.add(d, 25, 40, 20, 30);

for (int i=0; i<24; i++)
{
d.add(Calendar.HOUR_OF_DAY, 1);
cse.add(d, 19, 35, 15, 30);
}
d.add(Calendar.HOUR_OF_DAY, 1);
cse.add(d, 19, 20, 2, 5);

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Feb 28, 2008 10:10 am

Hi Marian,

This is because TeeChart automatically sets labels so that they fit in the chart drawing area and they overlap. To achieve what you request you can use custom labels as shown here:

Code: Select all

        
        //tChart.getAxes().getBottom().setIncrement(com.steema.teechart.misc.Utils.getDateTimeStep(com.steema.teechart.DateTimeStep.ONEDAY));
      
        Candle cse = new Candle(tChart.getChart());
        
        DateTime d = new DateTime(2008, 2, 26);
        cse.add(d, 25, 40, 20, 30);

        for (int i=0; i<24; i++)
        { 
            d.add(java.util.Calendar.HOUR_OF_DAY, 1);
            cse.add(d, 19, 35, 15, 30);
        }
        d.add(java.util.Calendar.HOUR_OF_DAY, 1);
        cse.add(d, 19, 20, 2, 5);
        
        tChart.getAxes().getBottom().getLabels().getItems().clear();
        
        tChart.getAxes().getBottom().getLabels().getItems().add(cse.getXValues().getValue(0));
        tChart.getAxes().getBottom().getLabels().getItems().add(cse.getXValues().getValue(cse.getCount()-2));

        //tChart.getAxes().getBottom().getLabels().setDateTimeFormat("dd/mm/yyyy hh:mm:ss");
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply