Pre loader

Wrong annotation position with xAxis on top

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

Answered
0
0

Hello! I am try to create chart with axis on top in my react native app, chart is create succesfuly, but when I start add annotation – it shift to top by axis height – whats may be wrong?

`

// create
surface = new CSciChartSurface(context);
surface.setRenderSurface(new RenderSurface(context));

// Initialize the SciChartBuilder
SciChartBuilder.init(context);

// Obtain the SciChartBuilder instance
sciChartBuilder = SciChartBuilder.instance();

 xAxis = sciChartBuilder
      .newCategoryDateAxis()
      .withTextFormatting(DateChartFormatter.defaultDateFormat)
      .withGrowBy(0.0d, 0.04d)
      .withDrawMajorGridLines(true)
      .withDrawMinorGridLines(false)
      .withDrawMajorBands(false)
      .withDrawMajorTicks(false)
      .withAxisAlignment(AxisAlignment.Top)
      .build();
// same yaxis and any

VerticalLineAnnotation verticalLine = sciChartBuilder.newVerticalLineAnnotation()
        .withPosition(10, 16)
        .withStroke(2, ColorUtil.Orange)
        .withIsEditable(true)
        .build();

Collections.addAll(surface.getYAxes(), yAxis);
Collections.addAll(surface.getXAxes(), xAxis);
Collections.addAll(surface.getRenderableSeries(), lineRenderableSeries);
Collections.addAll(surface.getAnnotations(), verticalLine);

// add to view
this.addView(surface);

`

Version
4.4.0.4739
Images
  • You must to post comments
Best Answer
0
0

I found problem… i am use old version of this hack https://github.com/facebook/react-native/issues/17968
like:
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
}

and its move annotation surface to point 0, 0

now i use
private void refreshViewChildrenLayout(View view){
view.measure(
View.MeasureSpec.makeMeasureSpec(view.getMeasuredWidth(), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(view.getMeasuredHeight(), View.MeasureSpec.EXACTLY));
view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
}

and annotation render correctly!!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.