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);
`
- Sergey Evdokimov asked 11 months ago
- last edited 11 months ago
-
Hi Sergey, there may be some specific differences in React Native vs. Java/Kotlin Android apps that is causing this. Could you share a project (on Github, or dropbox) with a *minimal* set of code to reproduce this? Please also include any special running instructions like npm-install, npm-start because we are not react-native experts. We’d love to get this working for you as it will benefit us and other users to have SciChart Android in React Native. Best regards, Andrew
-
Hi Andrew, I found solution in this issue https://github.com/facebook/react-native/issues/17968 – in our project we use first version – https://github.com/facebook/react-native/issues/17968#issuecomment-369855903 and in it crash annotation surface if use axis right or top, now i try use this https://github.com/facebook/react-native/issues/17968#issuecomment-697136929 on root surface and everything went well)) thank you
- You must login to post comments
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!!
- Sergey Evdokimov answered 11 months ago
- You must login to post comments
Please login first to submit.