Here my code, i try to draw a chart with candle stick and horizontal line with real time data update, but HorizontalLineAnnotation never show, here my code:
final CategoryDateAxis xAxis = sciChartBuilder.newCategoryDateAxis()
.withGrowBy(0, 0.01)
.withVisibleRange(80, 102)
.build();
NumericAxis yAxis = sciChartBuilder.newNumericAxis()
.withAxisId(PRICES)
.withTextFormatting(“0.00”)
.withAutoRangeMode(AutoRange.Always)
.build();
Collections.addAll(surface.getXAxes(), xAxis);
Collections.addAll(surface.getYAxes(), yAxis);
FastCandlestickRenderableSeries rSeries = sciChartBuilder.newCandlestickSeries().withDataSeries(stockPrices).withYAxisId(PRICES)
.build();
HorizontalLineAnnotation horizontalLine = sciChartBuilder.newHorizontalLineAnnotation()
.withPosition(5d, 3.2d) // i have try to change this but wont work
.withStroke(2, ColorUtil.Orange)
.withHorizontalGravity(Gravity.RIGHT)
.withIsEditable(true)
.build();
ohlcAxisMarker = sciChartBuilder.newAxisMarkerAnnotation().withY1(1d).withBackgroundColor(0xFF33DD33).withYAxisId(PRICES).build();
UpdateSuspender.using(surface, new Runnable() {
@Override
public void run() {
Collections.addAll(surface.getAnnotations(), ohlcAxisMarker, horizontalLine);
Collections.addAll(surface.getRenderableSeries(), rSeries);
Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build());
}
});
- tran hai asked 4 years ago
- You must login to post comments
Hi there,
First of all you need to set YAxisId for HorizontalLineAnnotation as you do for candlestick series and AxisMarkerAnnotation. Then you need to ensure that you set correct position for it, so annotation is within chart’s viewport.
Regarding second part of question about following – you just need to set annotation at same position as AxisMarkerAnnotation and when you update position of one annotation, then set the same position for another.
Best regards,
Yura
- Yura Khariton answered 4 years ago
- You must login to post comments
Please login first to submit.