# Annotation X and Y value

### 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
0
0

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.

Q1:
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.

Q2:
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?

Version
1.2.0
• You must to post comments
1
0

Hi there,

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,

Best regards,
Yuriy

• You must to post comments
Showing 1 result