0

I'm trying to plot the candles without them overlapping eachother like in the added image.

I played around a bit with the domain range but i'm having trouble figuring out how to keep/set a minimum spacing between the candles.

If someone could point me in the right direction it would be greatly appreciated.

    private DateAxis getTimeAxis() {
    final DateAxis dateAxis = new DateAxis("TIME_AXIS");
    dateAxis.setDateFormatOverride(DATE_TIME_FORMAT);

// this limits the visible candles but doesnt really solve the problem    
//        long start= ohlcs_series.getX(0,200).longValue(); // start from index 200
//        long end = ohlcs_series.getX(0,607).longValue(); // last candle
//
//        dateAxis.setRange(
//                new Date(start),
//                new Date(end + calculateEmptySpace())
//        );

    dateAxis.setLowerMargin(-0.025);
    dateAxis.setUpperMargin(0.15);

    Font bold = dateAxis.getLabelFont().deriveFont(Font.BOLD);
    dateAxis.setLabelFont(bold);
    return dateAxis;
}

/**
 * Returns the width of 50 candles
 * This is used to create some empty space after the last candle
 * */
private long calculateEmptySpace(){
    int indexOfLast = ohlcs_series.getSeries(0).getItemCount()-1;

    long lastCandle = ohlcs_series.getX(0, indexOfLast).longValue();
    long candle= ohlcs_series.getX(0,indexOfLast-50).longValue();

    return lastCandle-candle;
}

enter image description here

leroyv
  • 39
  • 4
  • 1
    As I recall, [pan and zoom](https://stackoverflow.com/a/44151032/230513) work well in this context. – trashgod Apr 15 '22 at 15:20

0 Answers0