I am building a real-time graph with CategoryDate X Axis and Numeric Y Axis. I found it hard to understand the Annotation API’s regarding the X and Y positions.
Looking at AnnotationsAreEasyFragment, it draw a Horizontal line of (seemingly) full width. it declares
sciChartBuilder.newHorizontalLineAnnotation() .withPosition(7d, 2.8d) .withStroke(2, ColorUtil.Orange) .build()
i can under Y = 2.8d, but what is the X=7d for? and in the next Horizontal line which is short, it declares .withPosition(5d, 3.2d)?? X=5d and X=7d gives such a big difference.
Since i am using CategoryDateAxis, referring to InteractionWithAnnotationsFragment to draw a vertical line at a specific date/time, there is a short line vertical line on 3rd Dec with the code
sciChartBuilder.newVerticalLineAnnotation() .withX1(20).withY1(35d).withY2(33d) ...
Since its a date axis, i would expect it to accept a Date.class (or long in millis) instead of .withX1(20). It doesnt even make sense! How exactly do i create full height vertical line at a specific date/time?
Thanks for your questions. Concerning setting the X coordinates for a HorizontalLineAnnotation, it depends on the Gravity value set via the setHorizontalGravity() method:
– If it equals to Gravity.FILL_HORIZONTAL, the X coords will be ignored completely.
– for Gravity.CENTER_HORIZONTAL, both X1 and X2 coords will be applied.
– for Gravity.RIGHT / LEFT, only X1 will be applied to the loose end of a line.
As to the second question, such ambiguity occurs because of the nature of CategoryDateAxis. It draws things based on series indexes, not actual Date values. So it is required to convert Date values into Indexes using Axis API. Please refer to the Convert Pixels to Chart Coordinates article for more details.
Hope this clarifies the issues! Please don’t hesitate to ask if it doesn’t,
Please login first to submit.