JFreeChart CandlestickChart how to change time interval?

197 views Asked by At

I'm creating an application that draws Candlestick Charts from a data in a text file. I also want the user to be able to choose different time intervals for the data. Let's say my starting data are 1s ticks in the following format:

CYBATON,0,20150101,080001,1.18,4.09,1.02,1.92

where "20150101" is a date and "080001" is a precise hour. Then I create OHLCItems with the following code responsible for setting OHLCItem's RegularTimePeriod:

    String stringDate ="20150101" + "080001";
    DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    Date date=null;
            try {
                date = format.parse(stringDate);
            } catch (ParseException e) {
                e.printStackTrace();
            }
    Hour hour=new Hour(date);
    OHLCItem ohlcItem=new OHLCItem(hour, open, max, min, close);

Now my chart will display data in a 1s ticks. Is there an easy way to switch to different ticks? Let's say hourly or daily? Or do I have to do it with manual calculations? If it's ok, I would also like to know how to store the entire date within the OHLCItem? Including year, month, day, hour, minute, seconds.

0

There are 0 answers