Pre loader

Tag: Annotation

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 votes
19k views

Hi,
I’ve created a custom annotation and have set it’s .IsEditable property in code so the user can reposition it. I have two issues:
1.I want the user to be able to resize the “PPZLine” in the X direction, but I can’t figure out how to get the anchor points to appear.

  1. I want to be able to see the chart data that the annotation is covering. I tried setting AnnotationCanvas = BelowChart, but then I couldn’t move the annotation or get any annotation mouse handlers to trigger.

Here’s the annoation’s xaml:

<s:CustomAnnotation x:Class="CinchV2DemoWPF.Views.SciChart.PPZView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:CinchV2="clr-namespace:Cinch;assembly=Cinch.WPF"
             xmlns:meffed="clr-namespace:MEFedMVVM.ViewModelLocator;assembly=MEFedMVVM.WPF"
             xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:s="clr-namespace:Abt.Controls.SciChart;assembly=Abt.Controls.SciChart.Wpf" 
             meffed:ViewModelLocator.ViewModel="PPZViewModel"

             X1="{Binding X1}"
             Y1="{Binding Y1}"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

    <!-- price line must use margin 0,0 or obj will not be visible-->
        <s:BoxAnnotation Name="LongEntryMarker" Grid.Row="0"
                       Width="20"    Height="10"  Background="DarkViolet" Margin="0,0"  VerticalAlignment="Top" 
                         HorizontalAlignment="Right"
                         >
        </s:BoxAnnotation>

        <!-- long marker line MouseRightButtonDown="LongEntryMarker_OnMouseRightButtonDown"-->
        <s:BoxAnnotation Name="PPZLine" Grid.Row="1"
                       Width="150"    Height="5"  Background="red" Margin="0,0"  VerticalAlignment="Top" 
                         >
        </s:BoxAnnotation>
</Grid>
</s:CustomAnnotation>
  • tecman234 asked 11 years ago
  • last active 9 years ago
1 vote
12k views

Hello,

I have a scichart and bound to its VM class. Inside this VM there is a Highlights property.

On the MainWindow, I am placing two of this charts with their own VM instance.

The problem is that when the Annotations is bound, it is only drawn on the last chart as shown in the image.

If I manually code in xaml the annotations (no binding) then the annotations are drawn in both charts.

How can I make it work with the binding?

Thanks

  • Miguel Hau asked 10 years ago
  • last active 10 years ago
1 vote
17k views

Hi,

I have a scichart surface defined in xaml like this,

<local:SciChartSurface x:Name="_ChartSurface"  Annotations="{Binding ChartAnnotations}">

        </local:SciChartSurface>

In the code behind I have ChartAnnotations defined as,

 public const string ChartAnnotationsPropertyName = "ChartAnnotations";
        private AnnotationCollection _ChartAnnotations = new AnnotationCollection();
        public AnnotationCollection ChartAnnotations
        {
            get { return _ChartAnnotations; }
            set
            {
                if (_ChartAnnotations == value)
                    return;

                _ChartAnnotations = value;
                RaisePropertyChanged(ChartAnnotationsPropertyName);
            }
        }

 public ViewModelExample()
{  
  ChartAnnotations.CollectionChanged += ChartAnnotations_CollectionChanged;    
}

 void ChartAnnotations_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            RaisePropertyChanged(ChartAnnotationsPropertyName);          
        }

Than in the code behind, I just initialize and add some annotations to the ChartAnnotations collection to populate my chart. The problem is that my Annotations property on the scichart surface is still null, and the RaisePropertyChanged() is not affecting the Bindings at all. I’m certain that the DataContext is set right as other stuff in the graph works fine. I works when I explicitly set the surface’s Annotations property with my ChartAnnotations collection, but obviously this is less than ideal.

Is there an additional step that I’m missing here?

Thanks

  • kewur asked 10 years ago
  • last active 10 years ago
0 votes
10k views

HI,

After reading the example annotation code and articles in the forum, I still can’t find a way to achieve my purpose: My app has a thread to receive data sent by a server, the data may trigger an annotation created lively. My app also need to maintain all created annotations and change their properties like X/Y values or remove them later. So far I only see the way of creating annotation by clicking some button. I tries different ways but failed.

Please help me out with some detailed guides. I am a beginner for WPF.

regards
Chunxi

I try to do this in user thread:

LineAnnotation annotationBase = new LineAnnotation();
change annotationBase properties.

But get this exception:

2014-11-09 13:42:20,623 [11] ERROR WpfApplication2.MainWindow [(null)] – at System.Windows.Input.InputManager..ctor()
at System.Windows.Input.InputManager.GetCurrentInputManagerImpl()
at System.Windows.Input.KeyboardNavigation..ctor()
at System.Windows.FrameworkElement.FrameworkServices..ctor()
at System.Windows.FrameworkElement.EnsureFrameworkServices()
at System.Windows.FrameworkElement..ctor()
at System.Windows.Controls.Control..ctor()
at System.Windows.Controls.ContentControl..ctor()
at Abt.Controls.SciChart.ChartModifiers.ApiElementBase..ctor()
at Abt.Controls.SciChart.Visuals.Annotations.AnnotationBase..ctor()
at Abt.Controls.SciChart.Visuals.Annotations.LineAnnotationBase..ctor()
at Abt.Controls.SciChart.Visuals.Annotations.LineAnnotation..ctor()
at WpfApplication2.InstrumentViewModel.addZone() in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\InstrumentViewModel.cs:line 134
at WpfApplication2.InstrumentViewModel.addMA20(Int32 barIdx, Double ma) in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\InstrumentViewModel.cs:line 128
at WpfApplication2.MainWindow.processEMA(String str) in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 222
at WpfApplication2.MainWindow.consumeQueue() in c:\Users\jokeslala\Documents\Visual Studio 2013\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 155

  • chunxi asked 9 years ago
  • last active 9 years ago
1 vote
19k views

I have got a CustomTextAnnotation like in this example CustomTextAnnotation
I added a Rendertransform like this.

<s:TextAnnotation.RenderTransform>
    <RotateTransform Angle="90"/>
</s:TextAnnotation.RenderTransform>

But the AnchorPoint is not used as rotation center.
I thought of using ToCoordinate() but need a calculator for that which is not available within CustomTextAnnotation.

What is best practice to achive the requested rotation in sciChart?

0 votes
0 answers
12k views

Good day!
I have a problem with annotations. When I add them by double clicking on surface with this snippet of code:

private TextPointAnnotation LoadTextPointAnnotation(double x1, double y1)
        {
            var textPoint = new TextPointAnnotation
            {
                X1 = x1,
                Y1 = y1,
                ElementX2 = -10,
                ElementY2 = -5,
                ElementFontSize = 9,
                AnnotationName = "TXTAnnot" + _annotaionCount,
                ElementFontColor = Colors.Yellow,
                ElementWidth = 50,
                ElementHeight = 20,
                BorderBrush = new SolidColorBrush(Colors.Red),
                Background = new SolidColorBrush(Color.FromArgb(78, 255, 0, 0)),
                YAxisId = TextOfYAxis,
                IsHidden = !_isTextPointAnnotationsVisible,
                IsEditable = true,
                AnnotationCanvas = AnnotationCanvas.AboveChart,
                CanEditText = false
            };
            textPoint.ElementText = String.Format("{0}", textPoint.AnnotationName);
            textPoint.ContextMenu = BuildMenu(textPoint);
            textPoint.MouseMove += AnnotationMove;
            textPoint.MouseRightButtonDown += OnRightMouseAnnotationDown;
            textPoint.PreviewMouseLeftButtonDown += textPoint_PreviewMouseLeftButtonDown;
            textPoint.PreviewMouseMove += textPoint_PreviewMouseMove;
            AnnotationCollection.Add(textPoint);
            return textPoint;
        }

They are visible for mouse actions (for example, mouse move, mouse down and etc.)(Image 1)
But when I add them programmaticaly, for example in Loaded method- LoadTextPointAnnotation(100,200), they are not visible for mouse actions, that I’ve already mentioned above(Image 2).

What is the reason of strange behaviour?

Thanks in advance.

  • Egor asked 9 years ago
  • last active 9 years ago
0 votes
12k views

How to change IsEditable behaviour for a annotation ?

Requirement is to allow Editing (Allow resizing box annotation only on X1 or X2 or Y1 or Y2 side).

It must be possible to specify which sides we can resize. (IsEditable on X1 or X2 or (X1 and X2) all combinations ). Because I’m programmatically creating box annotations.

2 votes
13k views

I want to have a BoxAnnotation where Y1 (- double.Infinity) and Y2 (+ double.Infinity). Basically I wanna specify only X1 and X2. And the behaviour must ensure always the box annotations Y1 & Y2 stretch to visible area even when I resize (zoomout) the chart.

In the screen shot its not stretched.

0 votes
15k views

Here we use a TextAnnotation as follows

 var textAnnotation = new TextAnnotation
                                 {
                                     Name = seriesAnnotationParameter.Name,
                                     Text = seriesAnnotationParameter.Text,
                                     ToolTip = seriesAnnotationParameter.ToolTip,
                                     XAxisId = XAxisId,
                                     YAxisId = YAxisId,
                                     X1 = seriesAnnotationParameter.X1,
                                     Y1 = seriesAnnotationParameter.Y1,
                                     HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
                                     VerticalAnchorPoint = VerticalAnchorPoint.Center,
                                     TextAlignment = TextAlignment.Center,
                                     Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)),
                                     Opacity = 0.5,
                                     BorderThickness = new Thickness(1),
                                     CornerRadius = new CornerRadius(1),
                                     IsEditable = false
                                 };

It works perfectly all-rite when you attach it to the chart the first time as in attached image TextAnnotation_Good.png. However, after zooming in or zooming out, the annotation is resized to undesirable sizes as in attached image TextAnnotation_Bad.png.

How to make TextAnnotation to resize itself based on the size of text inside it ?

This is a very special TextAnnotation centered around a x,y coordinate. There is never X2,Y2 for this use case.

0 votes
0 answers
12k views

I am considering applying server-side licensing for my javerScript application.

In the document below, there is a phrase “Our server-side licensing component is written in C++.”
(https://support.scichart.com/index.php?/Knowledgebase/Article/View/17256/42/)

However, there is only asp.net sample code on the provided github.
(https://github.com/ABTSoftware/SciChart.JS.Examples/tree/master/Sandbox/demo-dotnet-server-licensing)

I wonder if there is a sample code implemented in C++ for server-side licensing.

Can you provide c++ sample code?
Also, are there any examples to run on Ubuntu?

0 votes
9k views

Hi, I need some new type of annotation, for example, TriangleAnnotation or HexagonalAnnotation. I would rather derive the new type from AnnotationBase than from CustomAnnotation, because I need more control points than one. what shall I do?

1 vote
13k views

Hi, Andrew. I want to change the style of the control handle of annotation, including color, size, shape and so on. Forthmore, I want to and a rotating handle, even the control handle of corner radius in BoxAnnotation. Could you give me some suggestions?

0 votes
18k views

Hi

I don’t understand how to disable dragging an annotation with mouse. I didn’t find anything in your documentation.

I have a simple annotation as follows:

                                <s:HorizontalLineAnnotation x:Name="line" IsEditable="False" IsManipulationEnabled="False"  IsAttached="True" Y1="2020" ShowLabel="True" LabelValue="" LabelPlacement="TopRight" Stroke="Red"/>

tried with IsEditable=”False” IsManipulationEnabled=”False” IsAttached=”True” but nothing seems to work.

Could you please help me ?
thank you

  • lorenzo522 asked 8 years ago
  • last active 8 years ago
0 votes
12k views

To whom this may concern:

I’m having a slight issue (bug, possibly?) with custom annotations. I have created a custom annotation with an image (XAML shown below)

<s:CustomAnnotation x:Class="Dashboard.SciChartCustomComponents.CustomAnnotations.MicrostructureAnnotation"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
                    xmlns:local="clr-namespace:Dashboard.SciChartCustomComponents.CustomAnnotations"
                    mc:Ignorable="d">

    <Border BorderBrush="White" BorderThickness="2" Background="Black">
        <StackPanel>
            <Image x:Name="annotationImage" Stretch="None" Width="150" Height="100" Visibility="Collapsed"/>
            <TextBlock x:Name="annotationText" HorizontalAlignment="Center"/>
            <TextBlock x:Name="parameterText" HorizontalAlignment="Center" Visibility="Collapsed"/>
        </StackPanel>
    </Border>

</s:CustomAnnotation>

The image is applied with the following code (note the anchor points are bottom-right):

var annotation = new MicrostructureAnnotation
{
    HorizontalAnchorPoint = HorizontalAnchorPoint.Right,
    VerticalAnchorPoint = VerticalAnchorPoint.Bottom,
    IsEditable = true,
    X1 = xValue, // Both Obtained from hitpoint X- and Y-Values
    Y1 = yValue
};

annotation.annotationImage.Source = // some image Uri
annotation.annotationText.Text = // some text
annotation.parameterText.Text = // some other text

So this successfully shows the annotation as i liked, shown in 1.png.

Now I have a function that collapses the visibility of the image, which yields an annotation that is removed from its anchor point (although the top-left location remains the same), shown in 2.png.

If I try to move the annotation after removing the image, the anchor point is in the location of where the top-left anchor should be when the image collapses but the image is still in the wrong location, shown in 3.png.

When I finally do move the annotation, the annotation moves away from the cursor to the top-left anchor point, shown in 4.png.

Again i’m not sure if this is a bug, but could someone please advise?

Thanks kindly!

— Ari

Edit: I don’t have this problem when setting the anchor points to top-left.

  • Ari Sagiv asked 8 years ago
  • last active 8 years ago
0 votes
11k views

How to get current Y value of annotation in code behind?

enter image description here

0 votes
9k views

Hi;

I would like to delete selected annotation when “delete” key are pressed on it; like this :

(newAnnotation as AnnotationBase).KeyDown += (o, e) =>
{
this._chart.Annotations.Remove(newAnnotation);
};

I made this method when I create annotation on CreationModifier.AnnotationCreated event.
but is not work; the event are not handled.
Can you tell me how can I do this please

0 votes
9k views

I’m adding an annotation to a chart with a DateTime x-axis. Without a label the annotation is successfully added. However, if I specify a label I get an InvalidOperationException when Add() is called. The exception message is “The Type this is a test is not a valid Comparable Type”}:

                var annotation = new VerticalLineAnnotation
                {
                    VerticalAlignment = VerticalAlignment.Stretch,
                    ShowLabel = true,
                    X1 = time.DateTime,
                    Stroke = System.Windows.Media.Brushes.Orange,
                    LabelPlacement = LabelPlacement.TopRight,
                    LabelValue = "this is a test",
                    LabelsOrientation = Orientation.Vertical
                };

                MyChart.Annotations.Add(annotation);

The LabelValue is obviously of type string and non-null and indeed of type IComparable. Any reason I can’t add it?

  • Dan Pilat asked 7 years ago
  • last active 6 years ago
0 votes
6k views

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?

0 votes
13k views

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
0 votes
11k views

Dear All,

I would like to ask are there any method to draw a line (or annotation) by user touch event ?

For example user touch the chart to set the starting point of the line and then touch/drag to another point to draw the line.

Thanks.

  • Ray Hung asked 7 years ago
  • last active 5 years ago
0 votes
9k views

I hope you can help me I have managed to change the font color, size, but I do not know how to put the annotation with underlined font, who could give me a clue please. I would like to get something like what is shown in the image I attached. Thanks in advance.

0 votes
9k views

Hi, guys

Is there something similar like

  • (void)bringSubviewToFront:(UIView *)view;
  • (void)sendSubviewToBack:(UIView *)view;

from UIView but for chart Annotations?

Best regards,
Sushynski Andrei

0 votes
13k views

I’m currently trying to adapt an example to post here as an example repro– But in the meantime I figured I’d post and see if there are any fundamental problems with trying to do this.

The exception message states:

Additional information: Cannot get data-value from coordinate as the associated Axis is null
0 votes
15k views

It seems that if the axis is collapsed, all associated annotation labels are not visible (but their annotation line is visible).
Is there property or the like that will allow labels to be shown which are associated with a collapsed axis?

0 votes
10k views

When Im trying to remove an annotation, I’m receiving an error:

java.lang.NullPointerException: Attempt to invoke interface method
‘void
com.scichart.charting.visuals.annotations.IAnnotationPlacementStrategy.drawAdorner(android.graphics.Canvas)’
on a null object reference
at
com.scichart.charting.visuals.annotations.AnnotationBase.onDrawAdorner(SourceFile:889)
at
com.scichart.charting.visuals.annotations.AdornerLayer.onDraw(SourceFile:144)
at android.view.View.draw(View.java:17071)
at android.view.View.updateDisplayListIfDirty(View.java:16053)

I’ve tried many ways, like:

UpdateSuspender.using(priceChart, new Runnable() {
    @Override
    public void run() {
        priceChart.getAnnotations().clear();
    }
});

and

UpdateSuspender.using(priceChart, new Runnable() {
    @Override
    public void run() {
        priceChart.getAnnotations().remove(myAnnotation);
    }
});
0 votes
9k views

Dear all,

I am evaluating the graph control and I need to cover a request for my customer project.

The thing is that my customer have a bunch of data which gets display as scatter graph view.

The idea is that if the user is placing the mouse over a point, I need to display the current point value (x,y) as an information.
Then in an other hand, if the user click on the point, I need to open a text box and enter a description for that point. The comment and point link will be store in a database to be able to recall.

How cqn I do the 2 operations of displaying values on mouse over and poo up a text box for comment on point ckick ?

Thanks for your help on this

regards

  • sc sc asked 6 years ago
  • last active 2 years ago
0 votes
0 answers
9k views

Dear all,

I have my axis which are position on the Laft side of my chart. Then I have an annotation wich is define and where the labelPlacementProperty=”Axis”. By doing so the value of the axis when we move the cursor is display in a rectangle box.

my customer would like to get the labelPlacementProperty=”Right”, but by doing so , I am loosing the small rectangle around the axis value.

What is the way to get the annotation axis appearing on right side but still having the value inside a rectangle ?

(see image below)

0 votes
10k views

I have an issue with the latest version of Scichart. I have a chart which we are exporting to an image after cloning. We are using the CreateCloneOfSurfaceInMemory API call to take the clone. The problem is that, the annotations are getting lost from the cloned surface. I spent some time debugging and found that this is getting lost when we have VerticalSliceModifier in the Modifier group. I have attached the SciChart_CreateAnnotationsDynamically example which is modified to replicate this issue.

0 votes
8k views

I’m trying to add annotations on a chart but they are rendering above my legend.

Initially (similar to most of the demo code I’ve seen), I setup my modifiers, then created my series and animated them in — then added my annotations (adding to annotationGroup). This created a timeline of blank chart surface with legend (good so far), annotations popping in before the chart series animated in (weird / not good) and on TOP of the legend (really bad), then the animation of the series after that.

I’ve tried about everything I can think of and the best I’ve been able to do is use a completion block of the animation rendering the series — and moved my chart modifiers (and legend) into that completion block. If I put the annotations in the completion block, they will render after the chart modifier and I have the same problem (even if placed after the chart modifiers). I have to set the annotations before the animation, and then the chart modifier in the completion block will work and the legend will be above the . Of course, this is a bit odd too — as first my annotations pop up by themselves on the blank surface, followed by my series animating in, then at the end of the 2 second animation, the legend just pops in.

I really would like my legend to be rendered first on the blank surface and the annotations and chart series to animate in together under my legend. I’m gathering that’s unlikely (at least the animation part) — but is there anyway I can place my legend first and still have the annotations go under it? It feels like the layers should be: modifiers > annotations > rendered series. I also I’ve read this order before in some WPF docs I believe, but doesn’t seem to be respected on iOS?

UPDATE: My current work around isn’t sufficient because I really need access to the renderable series to create the annotations which means I really can’t defer my chart modifiers (i.e. legend) until after the annotations. Additionally, if I need to update (remove / re-add) an annotation due to a series being deactivated in the legend, now my annotations are on top of the legend again.

0 votes
8k views

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.

0 votes
8k views

Hello there,

I’m trying to implement adding line annotation on touch, but this causes crash.

I’m watching example android app in fragment CreateAnnotationsDynamicallyFragment.

I guess, it should be very easy, but example uses data binding and part of code is hidden somewhere + source code is obfuscated, so it’s hard for me to understand what is wrong.

Can someone give a short example of how to add annotation on touch?

Thanks

Exception:

 Process: process_name, PID: 24978
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Comparable com.scichart.charting.visuals.axes.IAxis.getDataValue(float)' on a null object reference
    at com.scichart.charting.modifiers.AnnotationCreationModifier.a(SourceFile:203)
    at com.scichart.charting.modifiers.AnnotationCreationModifier.onTouchDown(SourceFile:155)
0 votes
8k views

When I enter PathAnnotation in the xaml, I get the error “The type ‘s:PathAnnotation’ was not found.” I do have the following Annotation types available:
– AxisMarkerAnnotation
– BoxAnnotation
– CustomAnnotation
– HorizontalLineAnnotation
– LineAnnotation
– LineArrowAnnotation
– SeriesValueAxisMarkerAnnotation
– TextAnnotation
– VerticalLineAnnotation

I want to be able to make a star shape annotation, and PathAnnotation seemed to be the only way to do this. Please let me know if there’s another way to do this.

Thanks,
Rachel

0 votes
7k views

There is a problem with annotation drag listeners. OnDragEnded and in fact also OnDragStarted are called all the time (just like onDragDelta) instead of only on those particular events

Steps to reproduce
just add a listener to annotation (in my case CustomAnnotation)

.withAnnotationDragListener(object : OnAnnotationDragListener {
            override fun onDragDelta(annotation: IAnnotation, x: Float, y: Float) {
                //whatever
            }

            override fun onDragStarted(p0: IAnnotation?) {
                "onDRAGSTARTED".log()
            }
            override fun onDragEnded(p0: IAnnotation?) {
                "ONDRAGENDED".log()
            }
        })

Is there a solution?

0 votes
7k views
 var annotationMax = new HorizontalLineAnnotation () {
                            Stroke = new SolidColorBrush (Colors.DarkRed),
                            HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                            Y1 = item.MaxBandwith,
                            Y2 = item.MaxBandwith,
                            X1 = item.FromWavelength,
                            X2 = item.ToWavelength,
                        };
                        var label = annotationMax.AddLabel ();

after last line label is null
???

0 votes
6k views

I use a simple box annotation to highlight a section candlesticks on a chart. Currently I only see how to set this annotation X1 and X2 to Major grid units (ie 1,2,3,4,5). Since I would like to have this box annotation fully highlight only the desired candlesticks, is there a way to offset this X1 and X2 position by 0.5 so that it would include only (and fully) the desired candles? Apologies if I have missed this in the docs somewhere but I have been unable to find anything to accomplish this.

EDIT: For my x axis I am using a CategoryDateTimeAxis

Thank you.

  • Leland asked 4 years ago
  • last active 4 years ago
0 votes
6k views

Hello,

I have two questions about how to get axes or annotations by ID.

First, I trying to update the VisibleRange for X axis in the internalUpdate function in the UniformHeatmapSeriesTooltip. When I use getAxisById, my ECG data series is gone from the chart. But it works if I use getDefault() instead (axis Id not defined). So I kind of confused.

private class CustomHeatmapTooltip extends UniformHeatmapSeriesTooltip {

        public CustomHeatmapTooltip(Context context, UniformHeatmapSeriesInfo heatmapInfo) {
            super(context, heatmapInfo);
        }
        @Override
        protected void internalUpdate(UniformHeatmapSeriesInfo heatmapInfo) {
            ecgSurface.getXAxes().getAxisById("ecgx").setVisibleRange(new DateRange(startDate, stopDate));
        }
}

Second, I have one vertical line annotation and multiple text annotations. Every time I render the heatmap, I want to remove the text annotations and add some new text annotations as needed, without touching the vertical line annotation. Is there a way to only remove the text annotations?

Thanks a lot.

  • Gang Xu asked 4 years ago
  • last active 4 years ago
0 votes
7k views

Hello,

I want to implement a custom deltaX cursor in my software. It consists in two vertical lines that can be moved be the user and the idea to get the delta x (DateTime) between the two lines.
I’ve started to implement it by using two custom VerticalLineAnnotation added to a VerticalSliceManager. As my chart is a real time chart, I don’t want my cursors postions changed exepct on user interaction, that’s why I set to Relative the CoordinateMode property of my two Annotations.
The display and the interaction works fine, but when I try to retrieve the actual position of one cursor to compute the delta I have some trouble to convert the relative position to a DateTime value.
I have override the OnDragDelta() method, the relative value of X1 is correct but when I try to convert it into a DateTime by using FromRelativeCoordinate, I still have Date in 1899. I also try to interpret this as OA Date but I still have wrong date.

Do you have an idea ?
Thanks

 public override void OnDragDelta()
    {
        if (_sciChartSurface.XAxis != null)
        {
            double dataValue = (double)this.FromRelativeCoordinate((double)this.X1, _sciChartSurface.XAxis);
            DateTime classic = new DateTime((long)dataValue);
            DateTime fromOa = DateTime.FromOADate(dataValue);
            Debug.WriteLine("CLASSIC "+ classic);
            Debug.WriteLine("OA "+ fromOa);
        }
    }
0 votes
9k views

Hi,

I’ve been wondering. In SciChart’s current WPF version, is there any way to configure the default ViewportManager (or create a new customized one in a simple way) such that whenever I call its ZoomExtents method, the X and Y axes’ ranges will include any custom annotations I’ve added to the chart’s annotations collection?

My custom annotations are basically Images, with fixed Width and Height, and I set their X1 and Y1 properties to hold certain data points I have on the chart. The issue is, I need axes’ ranges to include the Image in it’s entirety, meaning I would have to somehow convert their Widths and Heights to “data point values”, since the new visible range should be in terms of data values, if I’m not mistaken.

Any good example to how this could be done?

  • Ilan Rozen asked 4 years ago
  • last active 4 years ago
0 votes
6k views

Hi,

I’d like to enable AnnotationCreationListener with a toggle button pressed down, and disable it with the button released. It’s different from the Android sample code in Create Annotation Dynamically. I have a few questions when I’m trying to code. I’m not sure if my approach is on the right track. Please advise, thanks.

// insert button listener
    insertAnnotationButton = findViewById(R.id.annotationInsertButton);
    insertAnnotationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // TODO: add chartmodifier/annotationCreationModifier when button pressed down
            if (insertAnnotationButton.isChecked()) {
                annotationCreationModifier.setAnnotationType(???); // how to set type to vertical line annotation?
                DefaultAnnotationFactory annotationFactory = new DefaultAnnotationFactory();
                annotationFactory.setFactoryForAnnotationType(DefaultAnnotationFactory.VERTICAL_LINE_ANNOTATION, new IAnnotationFactory() {
                    @NonNull
                    @Override
                    public IAnnotation createAnnotation(@NonNull ISciChartSurface parentSurface, int annotationType) {
                        return sciChartBuilder.newVerticalLineAnnotation().withIsEditable(true).withStroke(1, White).withVerticalGravity(Gravity.FILL_VERTICAL).build();
                    }
                });
                annotationCreationModifier.setAnnotationFactory(annotationFactory);
                annotationCreationModifier.setAnnotationCreationListener(new OnAnnotationCreatedListener() {
                    @Override
                    public void onAnnotationCreated(IAnnotation iAnnotation) {
                        // how to get X coordinate of the annotation and update my annotation variable

                    }
                });
                ecmSurface.getChartModifiers().add(sciChartBuilder.newModifierGroup().withModifier(annotationCreationModifier)..build());
            } else {
                // how to remove annotationCreationModifier from ChartModifiers?
                ecmSurface.getChartModifiers().remove(???);
            }
        }
    });
  • Gang Xu asked 3 years ago
  • last active 3 years ago
0 votes
4k views

Hello,
I am trying to make an annotation draggable. I tried setting the isEditable property to true, but nothing happened. I can’t find the right documentation for draggable annotations . My code for creating the Annotation it’s below:

sciChartSurface.annotations.add(new LineAnnotation({
    stroke: "#279B27", strokeThickness: 3,
    xCoordinateMode: ECoordinateMode.DataValue,
    x1: 0,
    x2: 0,
    yCoordinateMode: ECoordinateMode.Relative,
    y1: 0,
    y2: 1,
    isEditable: true,
}));
0 votes
0 answers
9k views

Hi
Sometimes when I call annotation.setIsHidden in a surface with RenderSurfaceGl, not works.
what should I do?

0 votes
5k views

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
0 votes
3k views

Hi,

Can you please tell me how to show an annotation(extends at BoxAnnotation(x1, y1, 2, y2)) that starts at a certain point(x1, y1) and ends at the end of the chart. That is, the starting point (x1) is known, and the end point (x2) at the very end of the surface (graph)?
Thanks in advance.

Regards,
Batyr

1 vote
5k views

Is there any way to provide annotation tooltip onmouseover? Perhaps I can subscribe on surface mouse events and manage visibility and positions on “tooltip” annotations by myself? If so, could you please provide reference to surface mouse events API.

1 vote
5k views

Hi, Support team.

I’m using MVVM pattern and trying to implement multi-chart which can insert Box Annotations at the same time into each chart .
So I’m testing in SciChart Example [“DigitalAnalyzerPerformanceDemo”] to know how to implement this.

But what i only got is just looping through and create annotation for each ChannelViewModels.

In the Demo, the VisibleRange ‘XRange’ is shared to all the ChannelViewModels by binding TwoWay-mode in ParentViewModel without looping for each ChildViewModels.
Like this, I wonder is there ways to apply BoxAnnotation all the ChannelViewModel at the same time by binding in ParentViewModel.

    <!-- BottomAxis -->
        <s:SciChartSurface Grid.Column="1">
            <s:SciChartSurface.XAxis>
                <s:NumericAxis Height="30"
                               AxisAlignment="Bottom"
                               VisibleRange="{Binding XRange, Mode=TwoWay}"                 
                               LabelProvider="{StaticResource TimeLabelProvider}"
                               MajorTickLineStyle="{StaticResource TimeAxisMajorTickLineStyle}"
                               MinorTickLineStyle="{StaticResource TimeAxisMinorTickLineStyle}"/>
            </s:SciChartSurface.XAxis>
            <s:SciChartSurface.YAxis>
                <s:NumericAxis Visibility="Collapsed"/>
            </s:SciChartSurface.YAxis>
        </s:SciChartSurface>
    </Grid>

    <!--  Create an X Axis with GrowBy  -->
     <s:SciChartSurface.XAxis>
           <s:NumericAxis Style="{StaticResource HiddenAxisStyle}"
                    VisibleRangeLimitMode="Min"
                    VisibleRangeLimit="0,0"
                    VisibleRange="{Binding DataContext.XRange, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}"/>
     </s:SciChartSurface.XAxis>

I tried to bind annotation in ParentViewModel like XRange Binding method, But it doesn’t work.


This is View.xaml.

<Grid Grid.IsSharedSizeScope="True" IsEnabled="{Binding IsLoading, Converter={StaticResource InvertBooleanConverter}}">


    <!-- BottomAxis -->
        <s:SciChartSurface Grid.Column="1">
            <s:SciChartSurface.XAxis>
                <s:NumericAxis Height="30"
                               AxisAlignment="Bottom"
                               VisibleRange="{Binding XRange, Mode=TwoWay}"                 
                               LabelProvider="{StaticResource TimeLabelProvider}"
                               MajorTickLineStyle="{StaticResource TimeAxisMajorTickLineStyle}"
                               MinorTickLineStyle="{StaticResource TimeAxisMinorTickLineStyle}"/>
            </s:SciChartSurface.XAxis>
            <s:SciChartSurface.YAxis>
                <s:NumericAxis Visibility="Collapsed"/>
            </s:SciChartSurface.YAxis>
        </s:SciChartSurface>
    </Grid>

    <!-- Channels -->
        <ScrollViewer Background="#1C1C1E"
                      VerticalScrollBarVisibility="Auto"
                      HorizontalScrollBarVisibility="Disabled">

            <b:Interaction.Behaviors>
                <common:DigitalAnalyzerScrollBehavior ChannelHeightDelta="10" ChangeChannelHeightCommand="{Binding ChangeChannelHeightCommand}"/>
            </b:Interaction.Behaviors>

            <ItemsControl x:Name="chartItemsControl" ItemsSource="{Binding ChannelViewModels}">

                <b:Interaction.Behaviors>
                    <common:FocusedChannelScrollBehavior ScrollToFocusedChannel="False"/>
                </b:Interaction.Behaviors>

                <ItemsControl.ItemTemplate>
                    <DataTemplate DataType="{x:Type local:ChannelViewModel}">
                        <Grid Background="#2D2C32" Height="{Binding ChannelHeight, Mode=OneWay}" Focusable="False" UseLayoutRounding="False" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="ChannelNames" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Border BorderThickness="0,0,0,1" BorderBrush="#1C1C1E">
                                <DockPanel>
                                    <Border DockPanel.Dock="Left"     
                                            Background="{Binding ChannelColor, Mode=OneWay}" 
                                            Width="5"/>

                                    <TextBlock DockPanel.Dock="Left"
                                               Margin="10,5"
                                               VerticalAlignment="Center"
                                               Foreground="White"
                                               Text="{Binding ChannelName}"/>
                                </DockPanel>
                            </Border>

                            <s:SciChartSurface x:Name="channelSurface" Grid.Column="1"
                                               RenderableSeries="{Binding RenderableSeries}"
                                               Annotations="{s:AnnotationsBinding  DataContext.Annotations, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2} }">

                                <!--  Create an X Axis with GrowBy  -->
                                <s:SciChartSurface.XAxis>
                                    <s:NumericAxis Style="{StaticResource HiddenAxisStyle}"
                                                   VisibleRangeLimitMode="Min"
                                                   VisibleRangeLimit="0,0"
                                                   VisibleRange="{Binding DataContext.XRange, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}"/>
                                </s:SciChartSurface.XAxis>

                                <!--  Create a Y Axis with GrowBy. Optional bands give a cool look and feel for minimal performance impact  -->
                                <s:SciChartSurface.YAxis>
                                    <s:NumericAxis Style="{StaticResource HiddenAxisStyle}"
                                                   VisibleRange="{Binding YRange, Mode=OneWay}"/>
                                </s:SciChartSurface.YAxis>

                                <s:SciChartSurface.ChartModifier>
                                    <s:ModifierGroup s:MouseManager.MouseEventGroup="ChannelModifierGroup">
                                        <s:RubberBandXyZoomModifier IsAnimated="False" IsXAxisOnly="True" ZoomExtentsY="False" ReceiveHandledEvents="True" IsEnabled="{Binding IsChecked, Mode=OneWay, ElementName=IsZoomEnabled}"/>
                                        <s:ZoomPanModifier ZoomExtentsY="False" XyDirection="XDirection" IsEnabled="{Binding IsChecked, Mode=OneWay, ElementName=IsPanEnabled}"/>
                                        <s:ZoomExtentsModifier XyDirection="XDirection" IsAnimated="False" />
                                        <s:MouseWheelZoomModifier XyDirection="XDirection" />
                                    </s:ModifierGroup>
                                </s:SciChartSurface.ChartModifier>
                            </s:SciChartSurface>

                            <Border Grid.Column="1"
                                    BorderThickness="0,0,0,1"
                                    BorderBrush="#2D2C32"
                                    VerticalAlignment="Bottom"/>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Border>


</Grid>

This is ViewModel.cs

public class DigitalAnalyzerExampleViewModel : BaseViewModel
{
    private bool _isLoading;
    private DoubleRange _xRange;

    public DigitalAnalyzerExampleViewModel()
    {
        ChannelViewModels = new ObservableCollection<ChannelViewModel>();
        Annotations = new ObservableCollection<IAnnotationViewModel>();
        Annotations.Add(new BoxAnnotationViewModel() { X1 = 0, X2 = 1000, Y1 = 0, Y2 = 1 }); //I want to implement sharing annotation like this.

        SelectedChannelType = "Digital";
        SelectedChannelCount = 32;
        SelectedPointCount = 1000000;
        SelectedResamplingPrecision =ResamplingPrecision.Default;
        SelectedStrokeThickness = 1;

        ChangeChannelHeightCommand = new ActionCommand<object>((d) =>
        {
            var delta = (double)d;
            foreach (var channelViewModel in ChannelViewModels)
            {
                channelViewModel.SetChannelHeightDelta(delta);
            }
        });

        AddChannelCommand = new ActionCommand(async () =>
        {
            IsLoading = true;

            var isDigital = SelectedChannelType == "Digital";
            await AddChannels(isDigital ? 1 : 0, isDigital ? 0 : 1);

            IsLoading = false;
        });

        LoadChannelsCommand = new ActionCommand(async () =>
        {
            IsLoading = true;

            // Clear ViewModels
            foreach (var channelVm in ChannelViewModels)
            {
                channelVm.Clear();
            }
            ChannelViewModels.Clear();
            XRange = null;

            // Create a bunch of Digital channels
            await AddChannels(SelectedChannelCount, 0);

            XRange = new DoubleRange(0, SelectedPointCount);
            IsLoading = false;
        });

        LoadChannelsCommand.Execute(null);
    }


    public ObservableCollection<ChannelViewModel> ChannelViewModels { get; private set; }
    public ObservableCollection<IAnnotationViewModel> Annotations { get; private set; }

    public string SelectedChannelType { get; set; }


    public ResamplingPrecision SelectedResamplingPrecision { get; set; }

    public int SelectedChannelCount { get; set; }

    public ActionCommand<object> ChangeChannelHeightCommand { get; }

    public ActionCommand AddChannelCommand { get; }

    public ActionCommand LoadChannelsCommand { get; }

    public long TotalPoints => ChannelViewModels.Sum(c => (long)c.DataCount);

    public bool IsLoading
    {
        get => _isLoading;
        set
        {
            _isLoading = value;
            OnPropertyChanged(nameof(IsLoading));
        }
    }

    public bool IsEmpty => ChannelViewModels.Count <= 0;

    public DoubleRange XRange
    {
        get => _xRange;
        set
        {
            _xRange = value;
            OnPropertyChanged(nameof(XRange));
        }
    }
}

+Attached image below is what i want to implement.
++I also attached tried code in .zip .

1 vote
0 answers
11k views

Hi,

I have annotation, users can it drag and drop. But for it first need select this annotation and after drag it(with re-touching).
How to immediately drag annotation(without re-touching)?

Thanks in advance.

Regards,
Batyr

1 vote
5k views

Previously I used AnnotationCreationModifier and my custom annotations were added by one left button mouse click on the chart surface (the annotation was added to the collection and the event handler “AnnotationCreated” fired). Now I’m trying to switch to using the mvvm pattern and I have problems adding my custom annotations using AnnotationCreationModifierMVVM.

Now it works like this:
1) I click (mouse left button) on the chart surface to add an annotation and it is added to the collection and displayed.
2) I click on the chart surface again, and only after that the event handler “AnnotationCreated” is called.

If I carry out some external manipulations with the added annotation between first and second click (for example, moving to the given coordinates by the button click), annotation moved, but when I hover the mouse over the chart surface, it returns to it’s original position. And this behavior will be until I click again on the chart surface so that the event handler “AnnotationCreated” is called.

The built-in annotations work fine though (for examle, VerticalLineAnnotationViewModel or HorizontalLineAnnotationViewModel are successfully added to the collection and call the event handler “AnnotationCreated” by one click on chart surface).

Is it possible to somehow fix this behavior of the custom annotation so that it is added to the collection and triggers an event “AnnotationCreated” for one click on the chart surface, as was the case with AnnotationCreationModifier? I am attaching an example code:

MainWindow.xaml

<Window x:Class="WpfAppMvvm.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
    xmlns:ext="http://schemas.abtsoftware.co.uk/scichart/exampleExternals"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
<Grid>
    <s:SciChartSurface Annotations="{s:AnnotationsBinding Annotations}">
        <s:SciChartSurface.XAxis>
            <s:NumericAxis AxisTitle="X"/>
        </s:SciChartSurface.XAxis>
        <s:SciChartSurface.YAxis>
            <s:NumericAxis AxisAlignment="Left" AxisTitle="Y"/>
        </s:SciChartSurface.YAxis>
        <s:SciChartSurface.ChartModifier>
            <s:ModifierGroup>
                <s:AnnotationCreationModifierMVVM IsEnabled="True" AnnotationViewModelsCollection="{Binding Annotations}" AnnotationViewModelType="{Binding AnnotationType}">
                    <i:Interaction.Behaviors>
                        <ext:EventToCommandBehavior Command="{Binding AnnotationCreatedCommand}" Event="AnnotationCreated" PassArguments="True"/>
                    </i:Interaction.Behaviors>
                </s:AnnotationCreationModifierMVVM>
            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>
    </s:SciChartSurface>
</Grid>

MainWindow.xaml.cs

using System.Windows;
namespace WpfAppMvvm
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new MainWindowViewModel();
        }
    }
}

MainWindowViewModel.cs

using SciChart.Charting.ChartModifiers;
using SciChart.Charting.Common.Helpers;
using SciChart.Charting.Model.ChartSeries;
using SciChart.Examples.ExternalDependencies.Common;
using System;
using System.Collections.ObjectModel;
using System.Windows;
namespace WpfAppMvvm
{
    internal class MainWindowViewModel:BaseViewModel
    {
        public ObservableCollection<IAnnotationViewModel> Annotations { get; private set; }
        public Type AnnotationType { get; private set; }
        public ActionCommand<AnnotationCreationMVVMArgs> AnnotationCreatedCommand { get; private set; }

        public MainWindowViewModel()
        {
            Annotations = new ObservableCollection<IAnnotationViewModel>();
            AnnotationType = typeof(MyCustomAnnotationViewModel);
            AnnotationCreatedCommand = new ActionCommand<AnnotationCreationMVVMArgs>(ExecCmd, e => true);
        }
        private void ExecCmd(AnnotationCreationMVVMArgs e)
        {
            MessageBox.Show("OnAnnotationCreated executed");
        }
    }
}

MyCustomAnnotation.xaml

<s:CustomAnnotationForMvvm x:Class="WpfAppMvvm.MyCustomAnnotation"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
    <Ellipse
        Width="20"
        Height="20"
        Fill="Transparent"
        Stroke="Red"
        StrokeThickness="3"
    />
</Grid>

MyCustomAnnotation.xaml.cs

using SciChart.Charting.Visuals.Annotations;

namespace WpfAppMvvm
{
    public partial class MyCustomAnnotation : CustomAnnotationForMvvm
    {
        public MyCustomAnnotation()
        {
            InitializeComponent();
        }
    }
}

MyCustomAnnotationViewModel.cs

using SciChart.Charting.Model.ChartSeries;
using System;

namespace WpfAppMvvm
{
    public class MyCustomAnnotationViewModel:CustomAnnotationViewModel
    {
    public override Type ViewType => typeof(MyCustomAnnotation);
    }
}
1 vote
7k views

I’m having issues with displaying my vertical annotations on my chart. Below is the code for creating the annotation and adding it to the chart.

var annotationLine = new VerticalLineAnnotation();
annotationLine.XAxisId = XAxisID;
annotationLine.YAxisId = YAxisID;
annotationLine.Stroke = new SolidColorBrush(Colors.Blue);
annotationLine.StrokeThickness = 2;
annotationLine.IsHidden = false;
annotationLine.AnnotationCanvas = AnnotationCanvas.BelowChart;
annotationLine.Y1 = 0;
annotationLine.Y2 = ControlHeight;
annotationLine.X1 = xValues[i];
Surface.Annotations.Add(annotationLine);

I have verified that the XAxisId and the YAxisId are correct and match the id of the only axes that I have on the chart
I have verified that the xValues[i] is a valid value on the chart and within the bounds of the viewport

The tricky part here is that I am reading live streaming EEG data from a device and inserting manual triggers into the data. This works fine and the annotations appear in the chart as they are within the bounds of the chart.
I then record that data to a file (currently csv but will be doing EDF as soon as I get this figured out) where the annotation data is present (verified)
It’s when I try to read the file into my application that I can’t get the annotations to appear on the SciChart. I’m using the code above for both the live streaming data (working) and the file reading (not working) so I’m really baffled by this and could use any insight anyone has.

Thank you

1 vote
5k views

Hello,

Is there away to extend a LineAnnotationViewModel to the right? I see there is a ExtendedLineAnnotaion
But that only seems to be available in the DrawingTools API.

Thank you

  • Leland asked 1 year ago
  • last active 1 year ago
1 vote
4k views

I have a real time updated chart and users can add annotation to the chart. The position of the annotation will be updated with the chart data. I would like to stop updating the annotation position while user dragging the annotation. So I added a flag (e.g. isDragging) to the annotation dragStarted and dragEnded events. The isDragging flag will be set to true in dragStarted and then set to false in dragEnded. I will check this flag before updating the annotation position.

Here’s the problem, the annotation dragStarted event will be triggered when users do panning in the chart. But the dragEnded will not be triggered in this case. It breaks my plan to stop updating the annotation position as the isDragging will be incorrect. Is it a bug that the annotation dragStarted event (but not the dragEnded event) triggered when panning?

  • Quyen Sy asked 1 year ago
  • last active 1 year ago
Showing 1 - 50 of 60 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies