.. where idx_timeD is an int like 20 or 30.chart.getAxes().getLeft().calcXPosValue(idx_timeD)
candleSeries.calcXPos(idx_timeD)
line.calcXPos(idx_timeD)
Every time, calcXPos returns zero. I have also tried calling it with values 0, 1, and 2 (explicitly).
Also, as you can see I have tried using the chart, the series (it is displaying price chart candles) and my custom lines to get the point coordinates, but all return zero. Yet they are draw beautifully on my chart.
Here is some more complete code:
chart = new TChart();
chart.getGraphics3D().setSmoothingMode(true);
chart.getAspect().setView3D(false); // 2d
chart.getLegend().setVisible(false); // no legend
chart.getPanel().setMarginLeft(1);
chart.getPanel().setMarginRight(1);
chart.getPanel().setMarginTop(1);
chart.getPanel().setMarginBottom(1);
chart.getPanel().setBevelOuter(BevelStyle.NONE); // no bevel
chart.getPanel().setColor(new Color(broker.getBackgroundColour())); // set background color
chart.getWalls().setVisible(true); // walls not visible (for maximum chart area)
chart.getWalls().setSize(1);
chart.getWalls().setView3D(false);
chart.getAxes().getTop().setVisible(false); // hide top axis
chart.getAxes().getLeft().setVisible(false); // hide left axis
chart.getAxes().getRight().setVisible(true); // show right axis
chart.getAxes().getRight().getAxisPen().setWidth(1); // set right axis pen
chart.getAxes().getRight().setAutomatic(true); // set right axis to auto-scale
chart.getAxes().getRight().getGrid().setColor(new Color(broker.getAxisColour())); // set right axis colour
chart.getAxes().getRight().getGrid().setTransparency(85);
chart.getAxes().getRight().getTitle().setVisible(false);
chart.getAxes().getRight().getLabels().getFont().setSize(10);
chart.getAxes().getRight().getLabels().getFont().setName("Arial");
chart.getAxes().getBottom().setVisible(true); // show right axis
chart.getAxes().getBottom().getAxisPen().setWidth(1); // set right axis pen
chart.getAxes().getBottom().setAutomatic(true); // set axis to auto-scale
chart.getAxes().getBottom().getGrid().setColor(new Color(broker.getAxisColour())); // set bttom axis colour
chart.getAxes().getBottom().getGrid().setTransparency(85);
chart.getAxes().getBottom().getTitle().setVisible(false);
chart.getAxes().getBottom().getLabels().getFont().setSize(10);
chart.getAxes().getBottom().getLabels().getFont().setName("Arial");
chart.getHeader().setVisible(false); // no header
// candle series
com.steema.teechart.styles.Candle candleSeries = new com.steema.teechart.styles.Candle(chart.getChart());
candleSeries.setVerticalAxis(VerticalAxis.RIGHT); // apply to right axis
candleSeries.setDownCloseColor(new Color(broker.getCandleDownCloseColour())); // set colour of down close
candleSeries.setUpCloseColor(new Color(broker.getCandleUpCloseColour())); // set colour of up close
candleSeries.getXValues().setDateTime(false);
int candleWidth = (int)((width / pricegraph.size()) * 0.;
if(candleWidth < 2) {
candleSeries.setCandleWidth( 2 );
} else if(candleWidth > {
candleSeries.setCandleWidth( 8 );
} else {
candleSeries.setCandleWidth(candleWidth );
}
// XA line
com.steema.teechart.styles.Line xa = new com.steema.teechart.styles.Line(chart.getChart());
xa.setColor(new Color(broker.getSupportColour()));
xa.getLinePen().setWidth(2);
xa.setVerticalAxis(VerticalAxis.RIGHT); // apply to right axis
xa.getXValues().setDateTime(false);
// target line 1
com.steema.teechart.styles.Line t1 = new com.steema.teechart.styles.Line(chart.getChart());
t1.setColor(new Color(broker.getResistanceColour()));
t1.getLinePen().setWidth(1);
t1.setVerticalAxis(VerticalAxis.RIGHT); // apply to right axis
t1.getXValues().setDateTime(false);
// add lines
if (timeX.getTime() > 0) {
xa.add(idx_timeX, priceX);
}
if (timeA.getTime() > 0) {
xa.add(idx_timeA, priceA);
}
xa.add(idx_timeB, priceB);
xa.add(idx_timeC, priceC);
xa.add(idx_timeD, priceD);
// add target lines
t1.add(idx_timeD, target10);
t1.add(idx_timeD+50, target10);
//all return zero!!
System.out.println("candleSeries.calcXPos(idx_timeD) : " + candleSeries.calcXPos(idx_timeD));
System.out.println("candleSeries.calcXPosValue(idx_timeD) : " + candleSeries.calcXPosValue(idx_timeD));
System.out.println("" + t3.calcXPos(0));
System.out.println("" + t3.calcXPos(1));
System.out.println("" + t3.calcXPos(2));
System.out.println("" + t3.calcXPosValue(0));
System.out.println("" + t3.calcXPosValue(1));
System.out.println("" + t3.calcXPosValue(2));
System.out.println("chart.getAxes().getRight().calcPosValue(idx_timeD) : " + chart.getAxes().getRight().calcPosValue(idx_timeD));
System.out.println("chart.getAxes().getRight().calcXPosValue(1) : " + chart.getAxes().getRight().calcXPosValue(1));