Page 1 of 1

Axis bug?

Posted: Wed Feb 27, 2008 4:10 pm
by 7667115
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);

Posted: Thu Feb 28, 2008 10:10 am
by narcis
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");