Pre loader

How to draw horizontal line follow AxisMarkerAnnotation

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

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());
                    }
                });
Version
3.0.0.4253
Images
  • You must to post comments
0
0

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies