SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components


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)
NumericAxis yAxis = sciChartBuilder.newNumericAxis()

    Collections.addAll(surface.getXAxes(), xAxis);
    Collections.addAll(surface.getYAxes(), yAxis);

               FastCandlestickRenderableSeries rSeries =  sciChartBuilder.newCandlestickSeries().withDataSeries(stockPrices).withYAxisId(PRICES)

                HorizontalLineAnnotation horizontalLine = sciChartBuilder.newHorizontalLineAnnotation()
                        .withPosition(5d, 3.2d) // i have try to change this but wont work
                        .withStroke(2, ColorUtil.Orange)
    ohlcAxisMarker = sciChartBuilder.newAxisMarkerAnnotation().withY1(1d).withBackgroundColor(0xFF33DD33).withYAxisId(PRICES).build();

                UpdateSuspender.using(surface, new Runnable() {
                    public void run() {
                        Collections.addAll(surface.getAnnotations(), ohlcAxisMarker, horizontalLine);
                        Collections.addAll(surface.getRenderableSeries(), rSeries);
                        Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build());
  • You must 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,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.