IllegalArgumentException when trying to set annotation line outside of data range

11 posts, 2 answers
  1. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 Link to this post

    Hi,

    I'm making an application that displays financial charts for stocks.

    As part of the chart I will need to display a annotation line indicating the 'prev close' price.  Sometimes this value will be outside the range of values for the day.  For example the prev close might be 50.00 and the day's range might be 60-70 (due to pre/after market changes prior to the market opening).

    On the windows phone chart controls I was able to set the annotation value to outside the data range, and the chart would expand automatically.  On the android chart controls I am getting this error:

    java.lang.IllegalArgumentException: the value: 17022.09 is outside the range of the current axis. Current range is: 16820.0 to 16980.0

    The issue is that the prev close is not within the range of today's price range, which is normal.  Could you confirm that this is a bug with the charting controls for Android?

    Thanks,
    Mike
  2. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 in reply to Mike Link to this post

    Ok I resolved the issue - I can call rightVAxis.setMaximum(double) to increase the range
  3. DevCraft banner
  4. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 09 Jul 2014 Link to this post

    Hello Mike,

    It's great that you found an easy work around. We will revise this behavior for the next release. It is indeed more convenient if the chart could just expand its value range to accommodate the annotation.

    Please write again if you have more feedback you'd like to share.

    Regards,
    Victor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 in reply to Victor Link to this post

    I ran into an issue with the annotated line after adding in pan & zoom behavior as follows:

    ChartPanAndZoomBehavior panZoom = new ChartPanAndZoomBehavior();
            panZoom.setPanMode(ChartPanZoomMode.BOTH);
            panZoom.setZoomMode(ChartPanZoomMode.BOTH);
            _chart.getBehaviors().add(panZoom);

    The issue is that when zooming, the annotated line moves/scales correctly.  But after you zoom in and then pan around, the annotated line doesn't follow the pan behavior (so it stays stuck at the same vertical position on the screen).  Let me know if you need more info.
  6. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 in reply to Mike Link to this post

    The annotated line was added as follows:

    CartesianGridLineAnnotation annotation = new CartesianGridLineAnnotation(this, rightVAxis, open.floatValue());
                annotation.setStrokeEffect(new DashPathEffect(new float[] {2, 2}, 0));
                annotation.setStrokeColor(Color.RED);
                annotation.setStrokeWidth(1);
                _chart.getAnnotations().add(annotation);
  7. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 09 Jul 2014 Link to this post

    Hello Mike,

    Thanks for writing again. We are aware of the line rendering issue while panning and it has been fixed. The bug fix will be available in our next internal build or official release. If you need this fixed asap we can release a build for you to try.

    Please write again if you need further assistance.

    Regards,
    Victor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 in reply to Victor Link to this post

    If possible, a private build would be great
  9. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 in reply to Mike Link to this post

    Thanks,

    On another note, is there any way to clear/reset the minimum and maximum of an axis once setMinimum and setMaximum have been called?  The only way I can seem to find right now is to remove the axis and re-create it again.
  10. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 10 Jul 2014 Link to this post

    Hello Mike,

    Yes, you simply have to set the maximum and minimum to Double.POSITIVE_INFINITY and Double.NEGATIVE_INFINITY respectively. These are the default values. That is, if you are referring to LinearAxis or LogarithmicAxis.

    Regards,
    Victor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. Alex
    Alex avatar
    2 posts
    Member since:
    Aug 2014

    Posted 08 Sep 2014 Link to this post

    I'm having the same issue...

    "java.lang.IllegalArgumentException: the value: 14.0 is outside the range of the current axis. Current range is: 52.0 to 61.0"

    Any pointers as to solving this issue, other than iterating through the data and figuring out the max/min ?
  12. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 09 Sep 2014 Link to this post

    Hello Alex,

    Thanks for writing.
    We have revised the annotations behavior and now you can set values outside the axis range. If the value range of the axis increases for some reason, the annotation will be rendered in its place.

    The new behavior will be available in the next release which is due in October.
    Please write again if you have other questions.

    Regards,
    Victor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner