Hi,
Please take a look at the attached screenshot first.
I have a chart configured to draw some data. I need to draw SCIAxisMarkerAnnotation on Y axis. And it seems that annotation has alignment by right side of axis area. Is there a possibility to change it to left side of axis area?
- Andrei Sushynski asked 7 years ago
- last active 7 years ago
I have a DateTime X Axis, to which I have added a custom label provider – namely to convert UTC display time to LocalTime.
This works just fine for the AxisLabels, but I also have vertical line annotations and they are NOT using the label provider and are thus showing UTC times.
Is there any way to make the vertical line annotations use the same label provider? Or some way to override the vertical line annotation label function to set the time to local?
Picture Attached.
- Robert.Kriener asked 5 years ago
- last active 5 years ago
Hi,
I’d like to learn how to cancel creating annotation in the OnAnnotationCreatedListener(). Thanks.
annotationCreationModifier.setAnnotationCreationListener(new OnAnnotationCreatedListener() {
@Override
public void onAnnotationCreated(IAnnotation iAnnotation) {
if (outofbound) {
// remove current annotation
}
}
- Gang Xu asked 3 years ago
- last active 3 years ago
I have modified the single ended ray as found in another answer to be an infinite ray that extends both ends of the line until the touch the sides of the plot.
I would like to implement a label similar to in VerticalLineAnnotation but am unsure how I go about adding additional elements to the annotation’s template.
I have included my modified version of the rayannotation below.
/// <summary>
/// Defines a read-only or editable Line annotation, which draws a Ray to the edges of the chart viewport, depending on two X,Y coordinates
/// e.g. if X Y coordinates are placed inside the chart, then the line extends until it hits the edge or the chart viewport
/// </summary>
public class RayAnnotation : LineAnnotation
{
private Line _line;
private Line _ghostLine;
/// <summary>
/// Initializes a new instance of the <see cref="RayAnnotation" /> class.
/// </summary>
public RayAnnotation()
{
// Reuse LineAnnotation control template from SciChart
DefaultStyleKey = typeof(LineAnnotation);
}
/// <summary>
/// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate" />.
/// </summary>
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
AnnotationRoot = GetAndAssertTemplateChild<Grid>("PART_LineAnnotationRoot");
_line = GetAndAssertTemplateChild<Line>("PART_Line");
_ghostLine = GetAndAssertTemplateChild<Line>("PART_GhostLine");
}
/// <summary>
/// Override in derived classes to handle specific placement of the annotation at the given <see cref="AnnotationCoordinates" />
/// </summary>
/// <param name="coordinates">The normalised <see cref="AnnotationCoordinates" /></param>
protected override void PlaceAnnotation(AnnotationCoordinates coordinates)
{
// Calculate gradient of line
double m = (coordinates.Y1Coord - coordinates.Y2Coord) / (coordinates.X1Coord - coordinates.X2Coord);
double b = coordinates.Y1Coord - m * coordinates.X1Coord;
if (double.IsNaN(m) || double.IsInfinity(m))
{
// Possible divide by zero above, just draw a single point for now
_line.X1 = coordinates.X1Coord;
_line.Y1 = 0;
_line.X2 = coordinates.X1Coord;
_line.Y2 = base.ParentSurface.ModifierSurface.ActualHeight;
_ghostLine.X1 = coordinates.X1Coord;
_ghostLine.Y1 = 0;
_ghostLine.X2 = coordinates.X1Coord;
_ghostLine.Y2 = base.ParentSurface.ModifierSurface.ActualHeight;
return;
}
// Calulate projected X,Y point that touches the right/top edge, or left/bottom edge of the viewport
double projectedX1 = 0;
double projectedX2 = base.ParentSurface.ModifierSurface.ActualWidth;
double projectedY1 = m * projectedX1 + b;
double projectedY2 = m * projectedX2 + b;
if (projectedY1 < 0 || projectedY1 > base.ParentSurface.ModifierSurface.ActualHeight)
{
bool isDown = projectedY1 < 0;
projectedY1 = isDown ? 0 : base.ParentSurface.ModifierSurface.ActualHeight;
projectedX1 = (projectedY1-b) / m;
}
if (projectedY2 < 0 || projectedY2 > base.ParentSurface.ModifierSurface.ActualHeight)
{
bool isDown = projectedY2 < 0;
projectedY2 = isDown ? 0 : base.ParentSurface.ModifierSurface.ActualHeight;
projectedX2 = (projectedY2-b) / m;
}
//Console.WriteLine("Projected x{0:0.00},y{1:0.00},x{2:0.00},y{3:0.00}", projectedX1, projectedY1, projectedX2, projectedY2);
// Apply Calculated Line
_line.X1 = projectedX1;
_line.Y1 = projectedY1;
_line.X2 = projectedX2;
_line.Y2 = projectedY2;
_ghostLine.X1 = projectedX1;
_ghostLine.Y1 = projectedY1;
_ghostLine.X2 = projectedX2;
_ghostLine.Y2 = projectedY2;
}
}
- Hugoagogo asked 7 years ago
- last active 7 years ago