Pre loader

How to change the design of the axes in android scichart

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

Is it possible to give an arrow type style to the axes? As seen in the attached image.

It would be perfect!

Otherwise, I would like to know if it is not possible, not to take into account this characteristic in my development.

I hope you can give me a clue please. Thanks in advance.

Version
V1 SDK
Images
  • You must to post comments
0
0

Hi Julio,

Well SciChart.Android does not support such drawing out of the box for now but you customize chart and add desired behavior on your own.

For example you can use LineArrowAnnotation to draw these arrows but you’ll need to slightly modify this annotation type to prevent clipping because by default it is clipped to annotation surface ( rectangular area where renderable series are drawn ):

 public class LineArrowAnnotationWithoutClipping extends LineArrowAnnotation {
    private final Rect clipBounds = new Rect();

    public LineArrowAnnotationWithoutClipping(Context context) {
        super(context);
    }

    @Override
    protected void internalDraw(Canvas canvas, PointF lineStart, PointF lineEnd) {
        try {
            canvas.save();

            // need to extend clip bounds prevent clipping
            // in our case we extend it to cover entire chart
            final ISciChartSurface parentSurface = getParentSurface();
            parentSurface.getBoundsRelativeTo(clipBounds, parentSurface.getAnnotationSurface());

            // apply new clip rect
            canvas.clipRect(clipBounds, Region.Op.REPLACE);

            // draw annotation
            super.internalDraw(canvas, lineStart, lineEnd);
        } finally {
            canvas.restore();
        }
    }
}

Then you just need to initialize annotations with relative coordinates, specify arrow size, stroke and then add them into annotation collection of the chart:

    final LineArrowAnnotationWithoutClipping xAxisArrow = new LineArrowAnnotationWithoutClipping(getActivity());
    final LineArrowAnnotationWithoutClipping yAxisArrow = new LineArrowAnnotationWithoutClipping(getActivity());

    final float length = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getActivity().getResources().getDisplayMetrics());
    final float width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getActivity().getResources().getDisplayMetrics());

    xAxisArrow.setCoordinateMode(AnnotationCoordinateMode.Relative);
    xAxisArrow.setHeadWidth(width); xAxisArrow.setHeadLength(length);
    xAxisArrow.setX1(0d); xAxisArrow.setX2(1d);
    xAxisArrow.setY1(1d); xAxisArrow.setY2(1d);

    yAxisArrow.setCoordinateMode(AnnotationCoordinateMode.Relative);
    yAxisArrow.setHeadWidth(width); yAxisArrow.setHeadLength(length);
    yAxisArrow.setX1(0d); yAxisArrow.setX2(0d);
    yAxisArrow.setY1(1d); yAxisArrow.setY2(0d);

   Collections.addAll(surface.getAnnotations(), xAxisArrow, yAxisArrow);

Is this suitable for your needs?

Best regards,
Yura

Images
  • Julio Olivos
    Thank you very much for quick reply, this is excellent. Many thanks again.
  • 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